=' ) ) {
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 );
}
/* Flow content view */
add_action( 'hfe_render_admin_page_content', [ $this, 'render_content' ], 10, 2 );
if ( ! HFE_Helper::is_pro_active() ) {
add_action( 'admin_footer', __CLASS__ . '::show_nps_notice' );
}
}
/**
* Show action on plugin page.
*
* @param array $links links.
* @return array
* @since 2.4.5
*/
public function upgrade_pro_link( $links ) {
$plugin_file = 'ultimate-elementor/ultimate-elementor.php';
if ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) && ! HFE_Helper::is_pro_active() ) {
$links[] = '' . esc_html__( 'Go Pro', 'header-footer-elementor' ) . '';
}
return $links;
}
/**
* Add meta links to the plugin row (under description).
*
* @param array $links Array of plugin meta links.
* @param string $file Plugin file path.
* @return array Modified plugin meta links.
* @since 2.5.2
*/
public function add_rating_meta_links( array $links, string $file ): array {
if ( HFE_PATH === $file ) {
$stars = str_repeat( '', 5 );
$links[] = sprintf(
'%s',
esc_url( 'https://wordpress.org/support/plugin/header-footer-elementor/reviews/#new-post' ),
esc_attr__( 'Rate our plugin', 'header-footer-elementor' ),
$stars
);
}
return $links;
}
/**
* Adding Rating footer to dashboard pages.
*
* @since 2.4.5
* @return void
*/
public function uae_custom_admin_footer_text( $footer_text ) {
$screen = get_current_screen();
if (
( isset( $_GET['page'] ) && 'hfe' === sanitize_text_field( wp_unslash( $_GET['page'] ) ) ) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended
( isset( $screen->post_type ) && $screen->post_type === 'elementor-hf' )
) {
$footer_text = sprintf(
/* translators: %1$s is bold plugin name, %2$s is the review link */
__( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'header-footer-elementor' ),
'UAE',
'★★★★★'
);
}
return $footer_text;
}
/**
* Render UAE NPS Survey Notice.
*
* @since 2.1.0
* @return void
*/
public static function show_nps_notice() {
if ( class_exists( 'Nps_Survey' ) ) {
$uae_logo = HFE_URL . 'assets/images/settings/logo.svg';
\Nps_Survey::show_nps_notice(
'nps-survey-header-footer-elementor',
[
'show_if' => true, // Add your display conditions.
'dismiss_timespan' => 2 * WEEK_IN_SECONDS,
'display_after' => 2 * WEEK_IN_SECONDS,
'plugin_slug' => 'header-footer-elementor',
'show_on_screens' => [ 'toplevel_page_hfe' ],
'message' => [
// Step 1 i.e rating input.
'logo' => esc_url( $uae_logo ),
'plugin_name' => __( 'Ultimate Addons for Elementor', 'header-footer-elementor' ),
'nps_rating_message' => __( 'How likely are you to recommend Ultimate Addons for Elementor to your friends or colleagues?', 'header-footer-elementor' ),
// Step 2A i.e. positive.
'feedback_title' => __( 'Thanks a lot for your feedback! 😍', 'header-footer-elementor' ),
'feedback_content' => __( 'Thanks for using Ultimate Addons! Got feedback or suggestions to make it even better? We’d love to hear from you.', 'header-footer-elementor' ),
'plugin_rating_link' => esc_url( 'https://www.trustpilot.com/review/ultimateelementor.com' ),
// Step 2B i.e. negative.
'plugin_rating_title' => __( 'Thank you for your feedback', 'header-footer-elementor' ),
'plugin_rating_content' => __( 'We value your input. How can we improve your experience?', 'header-footer-elementor' ),
],
]
);
}
}
/**
* Get Elementor edit page link
*/
public static function get_elementor_new_page_url() {
if ( class_exists( '\Elementor\Plugin' ) && current_user_can( 'edit_pages' ) ) {
// Ensure Elementor is loaded.
$query_args = [
'action' => 'elementor_new_post',
'post_type' => 'page',
];
$new_post_url = add_query_arg( $query_args, admin_url( 'edit.php' ) );
$new_post_url = add_query_arg( '_wpnonce', wp_create_nonce( 'elementor_action_new_post' ), $new_post_url );
return $new_post_url;
}
return '';
}
/**
* UAELite version rollback.
*
* Rollback to previous version.
*
* Fired by `admin_post_uaelite_rollback` action.
*
* @since 2.2.1
* @access public
*/
public function post_uaelite_rollback() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die(
esc_html__( 'You do not have permission to access this page.', 'header-footer-elementor' ),
esc_html__( 'Rollback to Previous Version', 'header-footer-elementor' ),
[
'response' => 200,
]
);
}
check_admin_referer( 'uaelite_rollback' );
$rollback_versions = HFE_Helper::get_rollback_versions_options();
$update_version = isset( $_GET['version'] ) ? sanitize_text_field( wp_unslash( $_GET['version'] ) ) : '';
// Extract version values from the rollback_versions array.
$version_values = array_column( $rollback_versions, 'value' );
if ( empty( $update_version ) || ! in_array( $update_version, $version_values, true ) ) {
wp_die( esc_html__( 'The selected version is invalid. Please try a different version.', 'header-footer-elementor' ) );
}
$plugin_slug = basename( HFE_FILE, '.php' );
if ( class_exists( 'HFE_Rollback' ) ) {
$rollback = new \HFE_Rollback(
[
'version' => $update_version,
'plugin_name' => HFE_PATH,
'plugin_slug' => $plugin_slug,
'package_url' => sprintf( 'https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, $update_version ),
]
);
$rollback->run();
wp_die(
'',
esc_html__( 'Rollback to Previous Version', 'header-footer-elementor' ),
[
'response' => 200,
]
);
}
wp_die();
}
/**
* Adds CSS to Hide the extra submenu added for the settings tab.
*
* @since 1.6.0
* @return void
*/
public function hfe_global_css() {
wp_enqueue_style( 'hfe-admin-style', HFE_URL . 'admin/assets/css/ehf-admin.css', [], HFE_VER );
}
/**
* Fetch and return the user's email.
*
* @since 1.6.0
* @return string|null The user's email if logged in, null otherwise.
*/
public function fetch_user_email() {
$current_user = wp_get_current_user();
if ( $current_user->ID !== 0 ) {
return $current_user->user_email;
} else {
return null;
}
}
/**
* Fetch and return the user's first name.
*
* @since 2.4.5
* @return string|null The user's name if logged in, null otherwise.
*/
public function fetch_user_fname() {
$current_user = wp_get_current_user();
if ( 0 !== $current_user->ID ) {
return $current_user->user_firstname;
} else {
return null;
}
}
/**
* Fetch and return the current user's last name.
*
* @since 2.8.7
* @return string|null The user's last name if logged in, null otherwise.
*/
public function fetch_user_lname() {
$current_user = wp_get_current_user();
if ( 0 !== $current_user->ID ) {
return $current_user->user_lastname;
} else {
return null;
}
}
/**
* Fetch and return the site URL.
*
* @since 2.4.5
* @return string|null
*/
public function fetch_site_url() {
$siteurl = get_option('siteURL');
if ( !empty( $siteurl ) ) {
return $siteurl;
} else {
return null;
}
}
/**
* Load admin styles on header footer elementor edit screen.
*
* @return void
*/
public function enqueue_admin_scripts() {
global $pagenow, $post_type;
$uae_logo = HFE_URL . 'assets/images/settings/dashboard-logo.svg';
$white_logo = HFE_URL . 'assets/images/settings/white-logo.svg';
$show_view_all = ( $post_type === 'elementor-hf' && $pagenow === 'post.php' ) ? 'yes' : 'no';
$hfe_edit_url = admin_url( 'edit.php?post_type=elementor-hf' );
$is_hfe_post = ( 'elementor-hf' === $post_type && ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) ) ? 'yes' : 'no';
$additional_condition = ( isset( $_GET['post_type'] ) && 'elementor-hf' === sanitize_text_field( $_GET['post_type'] ) &&
( 'edit.php' === $GLOBALS['pagenow'] || 'post.php' === $GLOBALS['pagenow'] || 'post-new.php' === $GLOBALS['pagenow'] ) ) ||
( isset( $_GET['post'] ) && 'post.php' === $GLOBALS['pagenow'] && isset( $_GET['action'] ) && 'edit' === sanitize_text_field( $_GET['action'] ) && 'elementor-hf' === get_post_type( absint( $_GET['post'] ) ) ) ||
( 'post-new.php' === $GLOBALS['pagenow'] && isset( $_GET['post_type'] ) && 'elementor-hf' === sanitize_text_field( $_GET['post_type'] ) );
if ( (
self::is_current_page( 'hfe' ) ||
$additional_condition
) &&
! HFE_Helper::is_pro_active()
) {
$rollback_versions = HFE_Helper::get_rollback_versions_options();
$st_status = HFE_Helper::free_starter_templates_status();
$stpro_status = HFE_Helper::premium_starter_templates_status();
$st_link = HFE_Helper::starter_templates_link();
$hfe_post_url = admin_url( 'post-new.php?post_type=elementor-hf' );
// Fetch the user's email.
$user_email = $this->fetch_user_email();
$user_name = $this->fetch_user_fname();
$user_lastname = $this->fetch_user_lname();
$siteurl = $this->fetch_site_url();
$show_theme_support = 'no';
$hfe_theme_status = get_option( 'hfe_is_theme_supported', false );
$analytics_status = get_option( 'uae_usage_optin', false );
if ( ( ! current_theme_supports( 'header-footer-elementor' ) ) && ! $hfe_theme_status ) {
$show_theme_support = 'yes';
}
$theme_option = get_option( 'hfe_compatibility_option', '1' );
wp_enqueue_script(
'header-footer-elementor-react-app',
HFE_URL . 'build/main.js',
[ 'wp-element', 'wp-dom-ready', 'wp-api-fetch' ],
HFE_VER,
true
);
wp_set_script_translations( 'header-footer-elementor-react-app', 'header-footer-elementor', HFE_DIR . 'languages' );
wp_localize_script(
'header-footer-elementor-react-app',
'hfeSettingsData',
[
'hfe_nonce_action' => wp_create_nonce( 'wp_rest' ),
'installer_nonce' => wp_create_nonce( 'updates' ),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'ajax_nonce' => wp_create_nonce( 'hfe-widget-nonce' ),
'templates_url' => HFE_URL . 'assets/images/settings/starter-templates.png',
'column_url' => HFE_URL . 'assets/images/settings/column.png',
'template_url' => HFE_URL . 'assets/images/settings/template.png',
'icon_url' => HFE_URL . 'assets/images/settings/logo.svg',
'elementor_page_url' => self::get_elementor_new_page_url(),
'astra_url' => HFE_URL . 'assets/images/settings/astra.svg',
'starter_url' => HFE_URL . 'assets/images/settings/starter-templates.svg',
'surecart_url' => HFE_URL . 'assets/images/settings/surecart.svg',
'suretriggers_url' => HFE_URL . 'assets/images/settings/OttoKit-Symbol-Primary.svg',
'theme_url_selected' => HFE_URL . 'assets/images/settings/theme.svg',
'theme_url' => HFE_URL . 'assets/images/settings/layout-template.svg',
'version_url' => HFE_URL . 'assets/images/settings/version.svg',
'version__selected_url' => HFE_URL . 'assets/images/settings/git-compare.svg',
'tracking_url' => HFE_URL . 'assets/images/settings/tracking.svg',
'tracking__selected_url' => HFE_URL . 'assets/images/settings/tracking_selected.svg',
'branding_url' => HFE_URL . 'assets/images/settings/branding.svg',
'branding__selected_url' => HFE_URL . 'assets/images/settings/branding-selected.svg',
'user_url' => HFE_URL . 'assets/images/settings/user.svg',
'user__selected_url' => HFE_URL . 'assets/images/settings/user-selected.svg',
'integrations_url' => HFE_URL . 'assets/images/settings/integrations.svg', // Update the path to your assets folder.
'welcome_banner' => HFE_URL . 'assets/images/settings/welcome-banner.png',
'build_banner' => HFE_URL . 'assets/images/settings/build_banner.png',
'special_reward' => HFE_URL . 'assets/images/settings/build_bg.png',
'success_banner' => HFE_URL . 'assets/images/settings/success_bg.png',
'success_badge' => HFE_URL . 'assets/images/settings/success_badge.svg',
'icon_svg' => HFE_URL . 'assets/images/settings/uae-logo-svg.svg',
'augemented_url' => HFE_URL . 'assets/images/settings/augemented_reality_widgets.png',
'rocket_svg' => HFE_URL . 'assets/images/settings/rocket.svg',
'augmented_reality' => HFE_URL . 'assets/images/settings/augmented_reality.png',
'welcome_new' => HFE_URL . 'assets/images/settings/welcome_new.png',
'icon_new' => HFE_URL . 'assets/images/settings/icon_2.svg',
'create_new' => HFE_URL . 'assets/images/settings/create_new_banner.png',
'uaelite_previous_version' => isset( $rollback_versions[0]['value'] ) ? $rollback_versions[0]['value'] : '',
'uaelite_versions' => $rollback_versions,
'uaelite_rollback_url' => esc_url( add_query_arg( 'version', 'VERSION', wp_nonce_url( admin_url( 'admin-post.php?action=uaelite_rollback' ), 'uaelite_rollback' ) ) ),
'uaelite_current_version' => defined( 'HFE_VER' ) ? HFE_VER : '',
'show_theme_support' => $show_theme_support,
'theme_option' => $theme_option,
'st_status' => $st_status,
'hfe_settings_url' => admin_url( 'admin.php?page=hfe' ),
'header_footer_builder' => admin_url( 'edit.php?post_type=elementor-hf' ),
'st_pro_status' => $stpro_status,
'st_link' => $st_link,
'hfe_post_url' => $hfe_post_url,
'is_hfe_post' => $is_hfe_post,
'user_email' => $user_email,
'user_fname' => $user_name,
'user_lname' => $user_lastname,
'siteurl' => $siteurl,
'analytics_status' => $analytics_status,
'onboarding_success_url' => admin_url( 'admin.php?page=hfe#onboardingsuccess' ),
'uaelite_subscription' => get_option( 'uaelite_subscription', false )
]
);
wp_enqueue_style(
'header-footer-elementor-react-styles',
HFE_URL . 'build/main.css',
[],
HFE_VER
);
}
if ( '' !== $uae_logo && '' !== $white_logo ) {
$custom_css = '
#toplevel_page_hfe .wp-menu-image {
background-image: url(' . esc_url( $uae_logo ) . ') !important;
background-size: 23px 34px !important;
background-repeat: no-repeat !important;
background-position: center !important;
}
#toplevel_page_hfe.wp-menu-open .wp-menu-image,
#toplevel_page_hfe .wp-has-current-submenu .wp-menu-image {
background-image: url(' . esc_url( $white_logo ) . ') !important;
}
';
wp_add_inline_style( 'wp-admin', $custom_css );
}
wp_enqueue_script( 'hfe-admin-script', HFE_URL . 'admin/assets/js/ehf-admin.js', [ 'jquery', 'updates' ], HFE_VER, true );
$is_dismissed = get_user_meta( get_current_user_id(), 'hfe-popup' );
$upgrade_notice_dismissed = get_user_meta( get_current_user_id(), 'hfe_upgrade_notice_dismissed', 'false' ) === 'true';
$strings = [
'addon_activate' => esc_html__( 'Activate', 'header-footer-elementor' ),
'addon_activated' => esc_html__( 'Activated', 'header-footer-elementor' ),
'addon_active' => esc_html__( 'Active', 'header-footer-elementor' ),
'addon_deactivate' => esc_html__( 'Deactivate', 'header-footer-elementor' ),
'addon_inactive' => esc_html__( 'Inactive', 'header-footer-elementor' ),
'addon_install' => esc_html__( 'Install', 'header-footer-elementor' ),
'theme_installed' => esc_html__( 'Theme Installed', 'header-footer-elementor' ),
'plugin_installed' => esc_html__( 'Plugin Installed', 'header-footer-elementor' ),
'addon_download' => esc_html__( 'Download', 'header-footer-elementor' ),
'addon_exists' => esc_html__( 'Already Exists.', 'header-footer-elementor' ),
'visit_site' => esc_html__( 'Visit Website', 'header-footer-elementor' ),
'plugin_error' => esc_html__( 'Could not install. Please download from WordPress.org and install manually.', 'header-footer-elementor' ),
'subscribe_success' => esc_html__( 'Your details are submitted successfully.', 'header-footer-elementor' ),
'subscribe_error' => esc_html__( 'Encountered an error while performing your request.', 'header-footer-elementor' ),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'hfe-admin-nonce' ),
'installer_nonce' => wp_create_nonce( 'updates' ),
'upgrade_notice_dismissed' => $upgrade_notice_dismissed,
'popup_dismiss' => false,
'data_source' => 'HFE',
'show_all_hfe' => $show_view_all,
'hfe_edit_url' => $hfe_edit_url,
'view_all_text' => esc_html__( 'View All', 'header-footer-elementor' ),
'header_footer_builder' => $hfe_edit_url,
];
$strings = apply_filters( 'hfe_admin_strings', $strings );
wp_localize_script(
'hfe-admin-script',
'hfe_admin_data',
$strings
);
}
/**
* Adds a tab in plugin submenu page.
*
* @since 1.6.0
* @param string $views to add tab to current post type view.
*
* @return mixed
*/
public function hfe_settings( $views ) {
return $views;
}
/**
* CHeck if it is current page by parameters
*
* @param string $page_slug Menu name.
* @param string $action Menu name.
*
* @return string page url
*/
public static function is_current_page( $page_slug = '', $action = '' ) {
$page_matched = false;
if ( empty( $page_slug ) ) {
return false;
}
$current_page_slug = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
$current_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! is_array( $action ) ) {
$action = explode( ' ', $action );
}
if ( $page_slug === $current_page_slug && in_array( $current_action, $action, true ) ) {
$page_matched = true;
}
return $page_matched;
}
/**
* Function for registering the settings api.
*
* @since 1.6.0
* @return void
*/
public function hfe_admin_init() {
register_setting( 'hfe-plugin-options', 'hfe_compatibility_option' );
add_settings_section( 'hfe-options', __( 'Add Theme Support', 'header-footer-elementor' ), [ $this, 'hfe_compatibility_callback' ], 'Settings' );
add_settings_field( 'hfe-way', 'Methods to Add Theme Support', [ $this, 'hfe_compatibility_option_callback' ], 'Settings', 'hfe-options' );
}
/**
* Call back function for the ssettings api function add_settings_section
*
* This function can be used to add description of the settings sections
*
* @since 1.6.0
* @return void
*/
public function hfe_compatibility_callback() {
$message = __( 'The Ultimate Addons for Elementor plugin needs compatibility with your current theme to work smoothly.
Following are two methods that enable theme support for the plugin.
Method 1 is selected by default and works fine with almost all themes. If you face any issue with the header or footer template, try choosing Method 2.', 'header-footer-elementor' );
$allowed_html = [ 'br' => [] ];
echo wp_kses( $message, $allowed_html );
}
/**
* Call back function for the ssettings api function add_settings_field
*
* This function will contain the markup for the input feilds that we can add.
*
* @since 1.6.0
* @return void
*/
public function hfe_compatibility_option_callback() {
$hfe_radio_button = get_option( 'hfe_compatibility_option', '1' );
wp_enqueue_style( 'hfe-admin-style', HFE_URL . 'admin/assets/css/ehf-admin.css', [], HFE_VER );
?>