Skip to content

Commit

Permalink
added setup for hfe nps
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshay Urankar authored and Akshay Urankar committed Jan 8, 2025
1 parent 847cc68 commit d894085
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build/main.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '7308ebd37e6188c7aa97');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'f06c918009181b168113');
6 changes: 6 additions & 0 deletions inc/class-header-footer-elementor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

}

/**
Expand Down
34 changes: 34 additions & 0 deletions inc/class-hfe-settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,47 @@ 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 {
add_filter( 'wp_check_filetype_and_ext', [ $this, 'real_mime_types' ], 10, 4 );
}
}

/**
* 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
*/
Expand Down
102 changes: 102 additions & 0 deletions inc/lib/class-uae-nps-survey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php
/**
* UAE.
*
* @package UAE
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

if ( ! class_exists( 'Uae_Nps_Survey' ) ) :

/**
* Admin
*/
class Uae_Nps_Survey {
/**
* Instance
*
* @since 1.0.0
* @var (Object) Uae_Nps_Survey
*/
private static $instance = null;

/**
* Get Instance
*
* @since 1.0.0
*
* @return object Class object.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}

return self::$instance;
}

/**
* Constructor.
*
* @since 1.0.0
*/
private function __construct() {
$this->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;

0 comments on commit d894085

Please sign in to comment.