=' ) ) { 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 ); } // Add the Action Links. // phpcs:ignore Squiz.PHP.CommentedOutCode.Found, Squiz.Commenting.InlineComment.InvalidEndChar // add_filter( 'plugin_action_links_' . HFE_PATH, array( $this, 'add_action_links' ) ); /* 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' ); } 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 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_content' => __( 'Could you please do us a favor and give us a 5-star rating on Trustpilot? It would help others choose Ultimate Addons for Elementor with confidence. Thank 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 x.x.x * @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( $_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__( 'Error occurred, The version selected is invalid. Try selecting 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(); } /** * Show action on plugin page. * * @param array $links links. * @return array */ public function add_action_links( $links ) { $default_url = admin_url( 'admin.php?page=' . $this->menu_slug ); $mylinks = [ '' . __( 'Settings', 'Elementor Header & Footer Builder', 'header-footer-elementor' ) . '', //phpcs:ignore WordPress.WP.I18n.TextDomainMismatch ]; return array_merge( $mylinks, $links ); } /** * Settings tab array * * @var settings tabs */ public static $hfe_settings_tabs; /** * 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 ); } /** * 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( sanitize_text_field( $_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' ); $show_theme_support = 'no'; $hfe_theme_status = get_option( 'hfe_is_theme_supported', 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/sure-triggers.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', '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. '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, ] ); 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' ); $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' ), '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 ) { // The following methods are currently disabled but may be used in the future. // $this->hfe_tabs(); // $this->hfe_modal();. 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' ); register_setting( 'hfe-plugin-guide', 'hfe_guide_email' ); register_setting( 'hfe-plugin-guide', 'hfe_guide_fname' ); } /** * 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 need 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 that works fine almost will all themes. In case, 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 ); ?>
plugin.', 'header-footer-elementor' ), [ 'a' => [ 'href' => [], ], ] ), 'https://github.com/Nikschavan/header-footer-elementor/wiki/Adding-Header-Footer-Elementor-support-for-your-theme' ); ?>
menu_slug; $capability = 'manage_options'; add_menu_page( __( 'UAE Lite', 'header-footer-elementor' ), __( 'UAE', 'header-footer-elementor' ), $capability, $menu_slug, [ $this, 'render' ], 'none', '59' ); // Add the Dashboard Submenu. add_submenu_page( $menu_slug, __( 'UAE Lite', 'header-footer-elementor' ), __( 'Dashboard', 'header-footer-elementor' ), $capability, $menu_slug, [ $this, 'render' ], 1 ); // Add the Settings Submenu. add_submenu_page( $menu_slug, __( 'Settings', 'header-footer-elementor' ), __( 'Settings', 'header-footer-elementor' ), $capability, $menu_slug . '#settings', [ $this, 'render' ], 9 ); } /** * Settings page. * * Call back function for add submenu page function. * * @since x.x.x * @return void */ public function render() { $menu_page_slug = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : $this->menu_slug; //phpcs:ignore WordPress.Security.NonceVerification.Recommended $page_action = ''; if ( isset( $_GET['action'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended $page_action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended $page_action = str_replace( '_', '-', $page_action ); } include_once HFE_DIR . 'inc/settings/admin-base.php'; } /** * Renders the admin settings content. * * @since 1.0.0 * @param sting $menu_page_slug current page name. * @param sting $page_action current page action. * * @return void */ public function render_content() { if ( ! current_user_can( 'manage_options' ) ) { return; } if ( self::is_current_page( 'hfe' ) ) { include_once HFE_DIR . 'inc/settings/settings-app.php'; } } /** * Settings page. * * Call back function for add submenu page function. * * @since 1.6.0 * @return void */ public function hfe_settings_page() { echo '', '', '', '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>