diff --git a/build/main.asset.php b/build/main.asset.php index c7426513..2a5751f9 100644 --- a/build/main.asset.php +++ b/build/main.asset.php @@ -1 +1 @@ - array('react', 'react-dom', 'wp-api-fetch', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '7308ebd37e6188c7aa97'); + array('react', 'react-dom', 'wp-api-fetch', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'f06c918009181b168113'); diff --git a/inc/class-header-footer-elementor.php b/inc/class-header-footer-elementor.php index e798d64a..0e5a9fd7 100644 --- a/inc/class-header-footer-elementor.php +++ b/inc/class-header-footer-elementor.php @@ -413,6 +413,12 @@ public function includes() { require HFE_DIR . 'inc/widgets-manager/class-extensions-loader.php'; require_once HFE_DIR . 'inc/settings/hfe-settings-api.php'; + + // Load the NPS Survey library. + if ( ! class_exists( 'Uabb_Pro_Nps_Survey' ) ) { + require_once HFE_DIR . 'inc/lib/class-uae-nps-survey.php'; + } + } /** diff --git a/inc/class-hfe-settings-page.php b/inc/class-hfe-settings-page.php index 5b019586..b1484fd3 100644 --- a/inc/class-hfe-settings-page.php +++ b/inc/class-hfe-settings-page.php @@ -65,6 +65,8 @@ public function __construct() { /* Flow content view */ add_action( 'hfe_render_admin_page_content', [ $this, 'render_content' ], 10, 2 ); + add_action( 'admin_footer', __CLASS__. '::show_nps_notice' ); + if ( version_compare( get_bloginfo( 'version' ), '5.1.0', '>=' ) ) { add_filter( 'wp_check_filetype_and_ext', [ $this, 'real_mime_types_5_1_0' ], 10, 5 ); } else { @@ -72,6 +74,38 @@ public function __construct() { } } + /** + * Render UAE NPS Survey Notice. + * + * @since x.x.x + * @return void + */ + public static function show_nps_notice() { + $uae_logo = HFE_URL . 'assets/images/settings/logo.svg'; + \Nps_Survey::show_nps_notice( + 'nps-survey-hfe', + array( + 'show_if' => true, // Add your display conditions. + 'dismiss_timespan' => 2 * WEEK_IN_SECONDS, + 'display_after' => 0, + 'plugin_slug' => 'hfe', + 'show_on_screens' => array( 'toplevel_page_hfe' ), + 'message' => array( + // Step 1 i.e rating input. + 'logo' => esc_url( $uae_logo ), + 'plugin_name' => __( 'Ultimate Addons for Elementor', 'hfe' ), + 'nps_rating_message' => __( 'How likely are you to recommend Ultimate Addons for Elementor to your friends or colleagues?', 'hfe' ), + // Step 2A i.e. positive. + 'feedback_content' => __( 'Could you please do us a favor and give us a 5-star rating on WordPress? It would help others choose Ultimate Addons for Beaver Builder with confidence. Thank you!', 'hfe' ), + 'plugin_rating_link' => esc_url( 'https://www.trustpilot.com/review/brainstormforce.com' ), + // Step 2B i.e. negative. + 'plugin_rating_title' => __( 'Thank you for your feedback', 'hfe' ), + 'plugin_rating_content' => __( 'We value your input. How can we improve your experience?', 'hfe' ), + ), + ) + ); + } + /** * Get Elementor edit page link */ diff --git a/inc/lib/class-uae-nps-survey.php b/inc/lib/class-uae-nps-survey.php new file mode 100644 index 00000000..601997ed --- /dev/null +++ b/inc/lib/class-uae-nps-survey.php @@ -0,0 +1,102 @@ +version_check(); + add_action( 'init', array( $this, 'load' ), 999 ); + } + + /** + * Version Check + * + * @return void + */ + public function version_check() { + + $file = realpath( dirname( __FILE__ ) . '/nps-survey/version.json' ); + + // Is file exist? + if ( is_file( $file ) ) { + + $file_data = json_decode( file_get_contents( $file ), true ); //phpcs:ignore WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsUnknown + + global $nps_survey_version, $nps_survey_init; + + $path = realpath( dirname( __FILE__ ) . '/nps-survey/nps-survey.php' ); + + $version = isset( $file_data['nps-survey'] ) ? $file_data['nps-survey'] : 0; + + if ( null === $nps_survey_version ) { + $nps_survey_version = '1.0.0'; + } + + // Compare versions. + if ( version_compare( $version, $nps_survey_version, '>=' ) ) { + $nps_survey_version = $version; + $nps_survey_init = $path; + } + } + } + + /** + * Load latest plugin + * + * @return void + */ + public function load() { + + global $nps_survey_version, $nps_survey_init; + if ( is_file( realpath( $nps_survey_init ) ) ) { + include_once realpath( $nps_survey_init ); + } + } + } + + /** + * Kicking this off by calling 'get_instance()' method + */ + Uae_Nps_Survey::get_instance(); + +endif;