+class Header_Footer_Elementor
+{
+ /**
+ * Current theme template
+ */
+ public string $template;
+
+ /**
+ * Instance of Elemenntor Frontend class.
+ *
+ * @var object \Elementor\Frontend()
+ */
+ private static object $elementor_instance;
+
+ /**
+ * Instance of HFE_Admin
+ */
+ private static Header_Footer_Elementor $_instance = null;
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ $this->template = get_template();
+
+ $is_elementor_callable = defined('ELEMENTOR_VERSION') && is_callable('Elementor\Plugin::instance') ? true : false;
+
+ $required_elementor_version = '3.5.0';
+
+ $is_elementor_outdated = $is_elementor_callable && (! version_compare(ELEMENTOR_VERSION, $required_elementor_version, '>=')) ? true : false;
+
+ if (! $is_elementor_callable || $is_elementor_outdated) {
+ $this->elementor_not_available($is_elementor_callable, $is_elementor_outdated);
+ }
+
+ if ($is_elementor_callable) {
+ self::$elementor_instance = Elementor\Plugin::instance();
+
+ $this->includes();
+ $this->load_textdomain();
+
+ add_action('init', [ $this, 'setup_settings_page' ]);
+
+ if ($this->template === 'genesis') {
+ require HFE_DIR . 'themes/genesis/class-hfe-genesis-compat.php';
+ } elseif ($this->template === 'astra') {
+ require HFE_DIR . 'themes/astra/class-hfe-astra-compat.php';
+ } elseif ($this->template === 'bb-theme' || $this->template === 'beaver-builder-theme') {
+ $this->template = 'beaver-builder-theme';
+ require HFE_DIR . 'themes/bb-theme/class-hfe-bb-theme-compat.php';
+ } elseif ($this->template === 'generatepress') {
+ require HFE_DIR . 'themes/generatepress/class-hfe-generatepress-compat.php';
+ } elseif ($this->template === 'oceanwp') {
+ require HFE_DIR . 'themes/oceanwp/class-hfe-oceanwp-compat.php';
+ } elseif ($this->template === 'storefront') {
+ require HFE_DIR . 'themes/storefront/class-hfe-storefront-compat.php';
+ } elseif ($this->template === 'hello-elementor') {
+ require HFE_DIR . 'themes/hello-elementor/class-hfe-hello-elementor-compat.php';
+ } else {
+ add_filter('hfe_settings_tabs', [ $this, 'setup_unsupported_theme' ]);
+ add_action('init', [ $this, 'setup_fallback_support' ]);
+ }
+
+ if (get_option('hfe_plugin_is_activated') === 'yes') {
+ add_action('admin_init', [ $this, 'show_setup_wizard' ]);
+ }
+
+ // Scripts and styles.
+ add_action('wp_enqueue_scripts', [ $this, 'enqueue_scripts' ]);
+
+ add_action('admin_enqueue_scripts', [ $this, 'enqueue_admin_scripts' ]);
+
+ add_filter('body_class', [ $this, 'body_class' ]);
+ add_action('switch_theme', [ $this, 'reset_unsupported_theme_notice' ]);
+
+ add_shortcode('hfe_template', [ $this, 'render_template' ]);
+
+ add_action('astra_notice_before_markup_header-footer-elementor-rating', [ $this, 'rating_notice_css' ]);
+ add_action('admin_init', [ $this, 'register_notices' ]);
+
+ // BSF Analytics Tracker.
+ if (! class_exists('BSF_Analytics_Loader')) {
+ require_once HFE_DIR . 'admin/bsf-analytics/class-bsf-analytics-loader.php';
+ }
+
+ $bsf_analytics = BSF_Analytics_Loader::get_instance();
+
+ $bsf_analytics->set_entity(
+ [
+ 'bsf' => [
+ 'product_name' => 'Elementor Header & Footer builder',
+ 'path' => HFE_DIR . 'admin/bsf-analytics',
+ 'author' => 'Brainstorm Force',
+ 'time_to_display' => '+24 hours',
+ ],
+ ]
+ );
+ }
+ }
+
+ /**
+ * Instance of Header_Footer_Elementor
+ *
+ * @return Header_Footer_Elementor Instance of Header_Footer_Elementor
+ */
+ public static function instance(): Header_Footer_Elementor
+ {
+ if (! isset(self::$_instance)) {
+ self::$_instance = new self();
+ }
+
+ return self::$_instance;
+ }
+
+ /**
+ * Reset the Unsupported theme nnotice after a theme is switched.
+ *
+ * @since 1.0.16
+ */
+ public function reset_unsupported_theme_notice(): void
+ {
+ delete_user_meta(get_current_user_id(), 'unsupported-theme');
+ }
+
+ /**
+ * Register Astra Notices.
+ *
+ * @since 1.2.0
+ */
+ public function register_notices(): void
+ {
+ $image_path = HFE_URL . 'assets/images/header-footer-elementor-icon.svg';
+
+ Astra_Notices::add_notice(
+ [
+ 'id' => 'header-footer-elementor-rating',
+ 'type' => '',
+ 'message' => sprintf(
+ '

@@ -174,480 +172,456 @@ public function register_notices() {
',
- $image_path,
- __( 'Hello! Seems like you have used Elementor Header & Footer Builder to build this website — Thanks a ton!', 'header-footer-elementor' ),
- __( 'Could you please do us a BIG favor and give it a 5-star rating on WordPress? This would boost our motivation and help other users make a comfortable decision while choosing the Elementor Header & Footer Builder.', 'header-footer-elementor' ),
- 'https://wordpress.org/support/plugin/header-footer-elementor/reviews/?filter=5#new-post',
- __( 'Ok, you deserve it', 'header-footer-elementor' ),
- MONTH_IN_SECONDS,
- __( 'Nope, maybe later', 'header-footer-elementor' ),
- __( 'I already did', 'header-footer-elementor' )
- ),
- 'show_if' => ( hfe_header_enabled() || hfe_footer_enabled() || hfe_is_before_footer_enabled() ) ? true : false,
- 'repeat-notice-after' => MONTH_IN_SECONDS,
- 'display-notice-after' => 1296000, // Display notice after 15 days.
- 'priority' => 18,
- 'display-with-other-notices' => false,
- ]
- );
- }
-
- /**
- * Enqueue CSS for the Rating Notice.
- *
- * @since 1.2.0
- * @return void
- */
- public function rating_notice_css() {
- wp_enqueue_style( 'hfe-admin-style', HFE_URL . 'assets/css/admin-header-footer-elementor.css', [], HFE_VER );
- }
-
- /**
- * Prints the admin notics when Elementor is not installed or activated or version outdated.
- *
- * @since 1.5.9
- * @param boolean $is_elementor_callable specifies if elementor is available.
- * @param boolean $is_elementor_outdated specifies if elementor version is old.
- * @return void
- */
- public function elementor_not_available( $is_elementor_callable, $is_elementor_outdated ) {
-
- if ( ( ! did_action( 'elementor/loaded' ) ) || ( ! $is_elementor_callable ) ) {
- add_action( 'admin_notices', [ $this, 'elementor_not_installed_activated' ] );
- add_action( 'network_admin_notices', [ $this, 'elementor_not_installed_activated' ] );
- return;
- }
-
- if ( $is_elementor_outdated ) {
- add_action( 'admin_notices', [ $this, 'elementor_outdated' ] );
- add_action( 'network_admin_notices', [ $this, 'elementor_outdated' ] );
- return;
- }
- }
-
- /**
- * Prints the admin notics when Elementor is not installed or activated.
- *
- * @return void
- */
- public function elementor_not_installed_activated() {
-
- $screen = get_current_screen();
- if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
- return;
- }
-
- if ( ! did_action( 'elementor/loaded' ) ) {
- // Check user capability.
- if ( ! ( current_user_can( 'activate_plugins' ) && current_user_can( 'install_plugins' ) ) ) {
- return;
- }
-
- /* TO DO */
- $class = 'notice notice-error';
- /* translators: %s: html tags */
- $message = sprintf( __( 'The %1$sElementor Header & Footer Builder%2$s plugin requires %1$sElementor%2$s plugin installed & activated.', 'header-footer-elementor' ), '
', '' );
-
- $plugin = 'elementor/elementor.php';
-
- if ( _is_elementor_installed() ) {
-
- $action_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin );
- $button_label = __( 'Activate Elementor', 'header-footer-elementor' );
-
- } else {
-
- $action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
- $button_label = __( 'Install Elementor', 'header-footer-elementor' );
- }
-
- $button = '
' . esc_html( $button_label ) . '
';
-
- printf( '
', esc_attr( $class ), wp_kses_post( $message ), wp_kses_post( $button ) );
- }
- }
-
- /**
- * Prints the admin notics when Elementor version is outdated.
- *
- * @return void
- */
- public function elementor_outdated() {
-
- // Check user capability.
- if ( ! ( current_user_can( 'activate_plugins' ) && current_user_can( 'install_plugins' ) ) ) {
- return;
- }
-
- /* TO DO */
- $class = 'notice notice-error';
- /* translators: %s: html tags */
- $message = sprintf( __( 'The %1$sElementor Header & Footer Builder%2$s plugin has stopped working because you are using an older version of %1$sElementor%2$s plugin.', 'header-footer-elementor' ), '
', '' );
-
- $plugin = 'elementor/elementor.php';
-
- if ( file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' ) ) {
-
- $action_url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $plugin . '&', 'upgrade-plugin_' . $plugin );
- $button_label = __( 'Update Elementor', 'header-footer-elementor' );
-
- } else {
-
- $action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
- $button_label = __( 'Install Elementor', 'header-footer-elementor' );
- }
-
- $button = '
' . esc_html( $button_label ) . '
';
-
- printf( '
', esc_attr( $class ), wp_kses_post( $message ), wp_kses_post( $button ) );
- }
-
- /**
- * Prints the admin notics when Elementor is not installed or activated.
- *
- * @return void
- */
- public function show_setup_wizard() {
-
- $screen = get_current_screen();
- $screen_id = $screen ? $screen->id : '';
-
- if ( 'plugins' !== $screen_id ) {
- return;
- }
-
- /* TO DO */
- $class = 'notice notice-info is-dismissible';
- $setting_url = admin_url( 'edit.php?post_type=elementor-hf' );
- $image_path = HFE_URL . 'assets/images/header-footer-elementor-icon.svg';
-
- /* translators: %s: html tags */
- $notice_message = sprintf( __( 'Thank you for installing %1$s Elementor Header & Footer Builder %2$s Plugin! Click here to %3$sget started. %4$s', 'header-footer-elementor' ), '
', '', '
', '' );
-
- Astra_Notices::add_notice(
- [
- 'id' => 'header-footer-install-notice',
- 'type' => 'info',
- /* translators: %s: html tags */
- 'message' => sprintf(
- '

+ $image_path,
+ __('Hello! Seems like you have used Elementor Header & Footer Builder to build this website — Thanks a ton!', 'header-footer-elementor'),
+ __('Could you please do us a BIG favor and give it a 5-star rating on WordPress? This would boost our motivation and help other users make a comfortable decision while choosing the Elementor Header & Footer Builder.', 'header-footer-elementor'),
+ 'https://wordpress.org/support/plugin/header-footer-elementor/reviews/?filter=5#new-post',
+ __('Ok, you deserve it', 'header-footer-elementor'),
+ MONTH_IN_SECONDS,
+ __('Nope, maybe later', 'header-footer-elementor'),
+ __('I already did', 'header-footer-elementor')
+ ),
+ 'show_if' => hfe_header_enabled() || hfe_footer_enabled() || hfe_is_before_footer_enabled() ? true : false,
+ 'repeat-notice-after' => MONTH_IN_SECONDS,
+ 'display-notice-after' => 1296000, // Display notice after 15 days.
+ 'priority' => 18,
+ 'display-with-other-notices' => false,
+ ]
+ );
+ }
+
+ /**
+ * Enqueue CSS for the Rating Notice.
+ *
+ * @since 1.2.0
+ */
+ public function rating_notice_css(): void
+ {
+ wp_enqueue_style('hfe-admin-style', HFE_URL . 'assets/css/admin-header-footer-elementor.css', [], HFE_VER);
+ }
+
+ /**
+ * Prints the admin notics when Elementor is not installed or activated or version outdated.
+ *
+ * @since 1.5.9
+ *
+ * @param bool $is_elementor_callable specifies if elementor is available.
+ * @param bool $is_elementor_outdated specifies if elementor version is old.
+ */
+ public function elementor_not_available(bool $is_elementor_callable, bool $is_elementor_outdated): void
+ {
+ if ((! did_action('elementor/loaded')) || (! $is_elementor_callable)) {
+ add_action('admin_notices', [ $this, 'elementor_not_installed_activated' ]);
+ add_action('network_admin_notices', [ $this, 'elementor_not_installed_activated' ]);
+ return;
+ }
+
+ if ($is_elementor_outdated) {
+ add_action('admin_notices', [ $this, 'elementor_outdated' ]);
+ add_action('network_admin_notices', [ $this, 'elementor_outdated' ]);
+ return;
+ }
+ }
+
+ /**
+ * Prints the admin notics when Elementor is not installed or activated.
+ */
+ public function elementor_not_installed_activated(): void
+ {
+ $screen = get_current_screen();
+ if (isset($screen->parent_file) && $screen->parent_file === 'plugins.php' && $screen->id === 'update') {
+ return;
+ }
+
+ if (! did_action('elementor/loaded')) {
+ // Check user capability.
+ if (! (current_user_can('activate_plugins') && current_user_can('install_plugins'))) {
+ return;
+ }
+
+ /* TO DO */
+ $class = 'notice notice-error';
+ /* translators: %s: html tags */
+ $message = sprintf(__('The %1$sElementor Header & Footer Builder%2$s plugin requires %1$sElementor%2$s plugin installed & activated.', 'header-footer-elementor'), '
', '');
+
+ $plugin = 'elementor/elementor.php';
+
+ if (_is_elementor_installed()) {
+ $action_url = wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin);
+ $button_label = __('Activate Elementor', 'header-footer-elementor');
+ } else {
+ $action_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
+ $button_label = __('Install Elementor', 'header-footer-elementor');
+ }
+
+ $button = '
' . esc_html($button_label) . '
';
+
+ printf('
', esc_attr($class), wp_kses_post($message), wp_kses_post($button));
+ }
+ }
+
+ /**
+ * Prints the admin notics when Elementor version is outdated.
+ */
+ public function elementor_outdated(): void
+ {
+ // Check user capability.
+ if (! (current_user_can('activate_plugins') && current_user_can('install_plugins'))) {
+ return;
+ }
+
+ /* TO DO */
+ $class = 'notice notice-error';
+ /* translators: %s: html tags */
+ $message = sprintf(__('The %1$sElementor Header & Footer Builder%2$s plugin has stopped working because you are using an older version of %1$sElementor%2$s plugin.', 'header-footer-elementor'), '
', '');
+
+ $plugin = 'elementor/elementor.php';
+
+ if (file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) {
+ $action_url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=') . $plugin . '&', 'upgrade-plugin_' . $plugin);
+ $button_label = __('Update Elementor', 'header-footer-elementor');
+ } else {
+ $action_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
+ $button_label = __('Install Elementor', 'header-footer-elementor');
+ }
+
+ $button = '
' . esc_html($button_label) . '
';
+
+ printf('
', esc_attr($class), wp_kses_post($message), wp_kses_post($button));
+ }
+
+ /**
+ * Prints the admin notics when Elementor is not installed or activated.
+ */
+ public function show_setup_wizard(): void
+ {
+ $screen = get_current_screen();
+ $screen_id = $screen ? $screen->id : '';
+
+ if ($screen_id !== 'plugins') {
+ return;
+ }
+
+ /* TO DO */
+ $class = 'notice notice-info is-dismissible';
+ $setting_url = admin_url('edit.php?post_type=elementor-hf');
+ $image_path = HFE_URL . 'assets/images/header-footer-elementor-icon.svg';
+
+ /* translators: %s: html tags */
+ $notice_message = sprintf(__('Thank you for installing %1$s Elementor Header & Footer Builder %2$s Plugin! Click here to %3$sget started. %4$s', 'header-footer-elementor'), '
', '', '
', '');
+
+ Astra_Notices::add_notice(
+ [
+ 'id' => 'header-footer-install-notice',
+ 'type' => 'info',
+ /* translators: %s: html tags */
+ 'message' => sprintf(
+ '
',
- $image_path,
- $notice_message
- ),
- 'repeat-notice-after' => false,
- 'priority' => 18,
- 'display-with-other-notices' => false,
- ]
- );
- }
-
- /**
- * Loads the globally required files for the plugin.
- *
- * @return void
- */
- public function includes() {
- require_once HFE_DIR . 'admin/class-hfe-admin.php';
-
- require_once HFE_DIR . 'inc/hfe-functions.php';
-
- // Load Elementor Canvas Compatibility.
- require_once HFE_DIR . 'inc/class-hfe-elementor-canvas-compat.php';
-
- // Load WPML & Polylang Compatibility if WPML is installed and activated.
- if ( defined( 'ICL_SITEPRESS_VERSION' ) || defined( 'POLYLANG_BASENAME' ) ) {
- require_once HFE_DIR . 'inc/compatibility/class-hfe-wpml-compatibility.php';
- }
-
- // Load the Admin Notice Class.
- require_once HFE_DIR . 'inc/lib/astra-notices/class-astra-notices.php';
-
- // Load Target rules.
- require_once HFE_DIR . 'inc/lib/target-rule/class-astra-target-rules-fields.php';
- // Setup upgrade routines.
- require_once HFE_DIR . 'inc/class-hfe-update.php';
-
- // Load the widgets.
- require HFE_DIR . 'inc/widgets-manager/class-widgets-loader.php';
- }
-
- /**
- * Loads textdomain for the plugin.
- *
- * @return void
- */
- public function load_textdomain() {
- load_plugin_textdomain( 'header-footer-elementor' );
- }
-
- /**
- * Enqueue styles and scripts.
- *
- * @return void
- */
- public function enqueue_scripts() {
- wp_enqueue_style( 'hfe-style', HFE_URL . 'assets/css/header-footer-elementor.css', [], HFE_VER );
-
- if ( class_exists( '\Elementor\Plugin' ) ) {
- $elementor = \Elementor\Plugin::instance();
- $elementor->frontend->enqueue_styles();
- }
-
- if ( class_exists( '\ElementorPro\Plugin' ) ) {
- $elementor_pro = \ElementorPro\Plugin::instance();
- $elementor_pro->enqueue_styles();
- }
-
- if ( hfe_header_enabled() ) {
- if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
- $css_file = new \Elementor\Core\Files\CSS\Post( get_hfe_header_id() );
- } elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
- $css_file = new \Elementor\Post_CSS_File( get_hfe_header_id() );
- }
-
- $css_file->enqueue();
- }
-
- if ( hfe_footer_enabled() ) {
- if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
- $css_file = new \Elementor\Core\Files\CSS\Post( get_hfe_footer_id() );
- } elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
- $css_file = new \Elementor\Post_CSS_File( get_hfe_footer_id() );
- }
-
- $css_file->enqueue();
- }
-
- if ( hfe_is_before_footer_enabled() ) {
- if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
- $css_file = new \Elementor\Core\Files\CSS\Post( hfe_get_before_footer_id() );
- } elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
- $css_file = new \Elementor\Post_CSS_File( hfe_get_before_footer_id() );
- }
- $css_file->enqueue();
- }
- }
-
- /**
- * Load admin styles on header footer elementor edit screen.
- *
- * @return void
- */
- public function enqueue_admin_scripts() {
- global $pagenow;
- $screen = get_current_screen();
-
- if ( ( 'elementor-hf' == $screen->id && ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) ) || ( 'edit.php' == $pagenow && 'edit-elementor-hf' == $screen->id ) ) {
-
- wp_enqueue_style( 'hfe-admin-style', HFE_URL . 'admin/assets/css/ehf-admin.css', [], HFE_VER );
- wp_enqueue_script( 'hfe-admin-script', HFE_URL . 'admin/assets/js/ehf-admin.js', [ 'jquery', 'updates' ], HFE_VER, true );
-
- }
- }
-
- /**
- * Adds classes to the body tag conditionally.
- *
- * @param array $classes array with class names for the body tag.
- *
- * @return array array with class names for the body tag.
- */
- public function body_class( $classes ) {
- if ( hfe_header_enabled() ) {
- $classes[] = 'ehf-header';
- }
-
- if ( hfe_footer_enabled() ) {
- $classes[] = 'ehf-footer';
- }
-
- $classes[] = 'ehf-template-' . $this->template;
- $classes[] = 'ehf-stylesheet-' . get_stylesheet();
-
- return $classes;
- }
-
- /**
- * Display Settings Page options
- *
- * @since 1.6.0
- * @return void
- */
- public function setup_settings_page() {
-
- require_once HFE_DIR . 'inc/class-hfe-settings-page.php';
- }
-
- /**
- * Display Unsupported theme notice if the current theme does add support for 'header-footer-elementor'
- *
- * @param array $hfe_settings_tabs settings array tabs.
- * @since 1.0.3
- * @return array
- */
- public function setup_unsupported_theme( $hfe_settings_tabs = [] ) {
- if ( ! current_theme_supports( 'header-footer-elementor' ) ) {
- $hfe_settings_tabs['hfe_settings'] = [
- 'name' => __( 'Theme Support', 'header-footer-elementor' ),
- 'url' => admin_url( 'themes.php?page=hfe-settings' ),
- ];
- }
- return $hfe_settings_tabs;
- }
-
- /**
- * Add support for theme if the current theme does add support for 'header-footer-elementor'
- *
- * @since 1.6.1
- * @return void
- */
- public function setup_fallback_support() {
-
- if ( ! current_theme_supports( 'header-footer-elementor' ) ) {
- $hfe_compatibility_option = get_option( 'hfe_compatibility_option', '1' );
-
- if ( '1' === $hfe_compatibility_option ) {
- if ( ! class_exists( 'HFE_Default_Compat' ) ) {
- require_once HFE_DIR . 'themes/default/class-hfe-default-compat.php';
- }
- } elseif ( '2' === $hfe_compatibility_option ) {
- require HFE_DIR . 'themes/default/class-global-theme-compatibility.php';
- }
- }
- }
-
- /**
- * Prints the Header content.
- *
- * @return void
- */
- public static function get_header_content() {
- $header_content = self::$elementor_instance->frontend->get_builder_content_for_display( get_hfe_header_id() );
- echo $header_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- }
-
- /**
- * Prints the Footer content.
- *
- * @return void
- */
- public static function get_footer_content() {
- echo "';
- }
-
- /**
- * Prints the Before Footer content.
- *
- * @return void
- */
- public static function get_before_footer_content() {
- echo "';
- }
-
- /**
- * Get option for the plugin settings
- *
- * @param string $setting Option name.
- * @param string $default Default value to be received if the option value is not stored in the option.
- *
- * @return mixed | string
- */
- public static function get_settings( $setting = '', $default = '' ) {
- if ( 'type_header' == $setting || 'type_footer' == $setting || 'type_before_footer' == $setting ) {
- $templates = self::get_template_id( $setting );
-
- $template = ! is_array( $templates ) ? $templates : $templates[0];
-
- $template = apply_filters( "hfe_get_settings_{$setting}", $template );
-
- return $template;
- }
- }
-
- /**
- * Get header or footer template id based on the meta query.
- *
- * @param String $type Type of the template header/footer.
- *
- * @return Mixed Returns the header or footer template id if found, else returns string ''.
- */
- public static function get_template_id( $type ) {
- $option = [
- 'location' => 'ehf_target_include_locations',
- 'exclusion' => 'ehf_target_exclude_locations',
- 'users' => 'ehf_target_user_roles',
- ];
-
- $hfe_templates = Astra_Target_Rules_Fields::get_instance()->get_posts_by_conditions( 'elementor-hf', $option );
-
- foreach ( $hfe_templates as $template ) {
- if ( get_post_meta( absint( $template['id'] ), 'ehf_template_type', true ) === $type ) {
- if ( function_exists( 'pll_current_language' ) ) {
- if ( pll_current_language( 'slug' ) == pll_get_post_language( $template['id'], 'slug' ) ) {
- return $template['id'];
- }
- } else {
- return $template['id'];
- }
- }
- }
-
- return '';
- }
-
- /**
- * Callback to shortcode.
- *
- * @param array $atts attributes for shortcode.
- * @return string
- */
- public function render_template( $atts ) {
- $atts = shortcode_atts(
- [
- 'id' => '',
- ],
- $atts,
- 'hfe_template'
- );
-
- $id = ! empty( $atts['id'] ) ? apply_filters( 'hfe_render_template_id', intval( $atts['id'] ) ) : '';
-
- if ( empty( $id ) ) {
- return '';
- }
-
- if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
- $css_file = new \Elementor\Core\Files\CSS\Post( $id );
- } elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
- // Load elementor styles.
- $css_file = new \Elementor\Post_CSS_File( $id );
- }
- $css_file->enqueue();
-
- return self::$elementor_instance->frontend->get_builder_content_for_display( $id );
- }
+ $image_path,
+ $notice_message
+ ),
+ 'repeat-notice-after' => false,
+ 'priority' => 18,
+ 'display-with-other-notices' => false,
+ ]
+ );
+ }
+
+ /**
+ * Loads the globally required files for the plugin.
+ */
+ public function includes(): void
+ {
+ require_once HFE_DIR . 'admin/class-hfe-admin.php';
+
+ require_once HFE_DIR . 'inc/hfe-functions.php';
+
+ // Load Elementor Canvas Compatibility.
+ require_once HFE_DIR . 'inc/class-hfe-elementor-canvas-compat.php';
+
+ // Load WPML & Polylang Compatibility if WPML is installed and activated.
+ if (defined('ICL_SITEPRESS_VERSION') || defined('POLYLANG_BASENAME')) {
+ require_once HFE_DIR . 'inc/compatibility/class-hfe-wpml-compatibility.php';
+ }
+
+ // Load the Admin Notice Class.
+ require_once HFE_DIR . 'inc/lib/astra-notices/class-astra-notices.php';
+
+ // Load Target rules.
+ require_once HFE_DIR . 'inc/lib/target-rule/class-astra-target-rules-fields.php';
+ // Setup upgrade routines.
+ require_once HFE_DIR . 'inc/class-hfe-update.php';
+
+ // Load the widgets.
+ require HFE_DIR . 'inc/widgets-manager/class-widgets-loader.php';
+ }
+
+ /**
+ * Loads textdomain for the plugin.
+ */
+ public function load_textdomain(): void
+ {
+ load_plugin_textdomain('header-footer-elementor');
+ }
+
+ /**
+ * Enqueue styles and scripts.
+ */
+ public function enqueue_scripts(): void
+ {
+ wp_enqueue_style('hfe-style', HFE_URL . 'assets/css/header-footer-elementor.css', [], HFE_VER);
+
+ if (class_exists('\Elementor\Plugin')) {
+ $elementor = \Elementor\Plugin::instance();
+ $elementor->frontend->enqueue_styles();
+ }
+
+ if (class_exists('\ElementorPro\Plugin')) {
+ $elementor_pro = \ElementorPro\Plugin::instance();
+ $elementor_pro->enqueue_styles();
+ }
+
+ if (hfe_header_enabled()) {
+ if (class_exists('\Elementor\Core\Files\CSS\Post')) {
+ $css_file = new \Elementor\Core\Files\CSS\Post(get_hfe_header_id());
+ } elseif (class_exists('\Elementor\Post_CSS_File')) {
+ $css_file = new \Elementor\Post_CSS_File(get_hfe_header_id());
+ }
+
+ $css_file->enqueue();
+ }
+
+ if (hfe_footer_enabled()) {
+ if (class_exists('\Elementor\Core\Files\CSS\Post')) {
+ $css_file = new \Elementor\Core\Files\CSS\Post(get_hfe_footer_id());
+ } elseif (class_exists('\Elementor\Post_CSS_File')) {
+ $css_file = new \Elementor\Post_CSS_File(get_hfe_footer_id());
+ }
+
+ $css_file->enqueue();
+ }
+
+ if (hfe_is_before_footer_enabled()) {
+ if (class_exists('\Elementor\Core\Files\CSS\Post')) {
+ $css_file = new \Elementor\Core\Files\CSS\Post(hfe_get_before_footer_id());
+ } elseif (class_exists('\Elementor\Post_CSS_File')) {
+ $css_file = new \Elementor\Post_CSS_File(hfe_get_before_footer_id());
+ }
+ $css_file->enqueue();
+ }
+ }
+
+ /**
+ * Load admin styles on header footer elementor edit screen.
+ */
+ public function enqueue_admin_scripts(): void
+ {
+ global $pagenow;
+ $screen = get_current_screen();
+
+ if (($screen->id === 'elementor-hf' && ($pagenow === 'post.php' || $pagenow === 'post-new.php')) || ($pagenow === 'edit.php' && $screen->id === 'edit-elementor-hf')) {
+ wp_enqueue_style('hfe-admin-style', HFE_URL . 'admin/assets/css/ehf-admin.css', [], HFE_VER);
+ wp_enqueue_script('hfe-admin-script', HFE_URL . 'admin/assets/js/ehf-admin.js', [ 'jquery', 'updates' ], HFE_VER, true);
+ }
+ }
+
+ /**
+ * Adds classes to the body tag conditionally.
+ *
+ * @param array $classes array with class names for the body tag.
+ *
+ * @return array array with class names for the body tag.
+ */
+ public function body_class(array $classes): array
+ {
+ if (hfe_header_enabled()) {
+ $classes[] = 'ehf-header';
+ }
+
+ if (hfe_footer_enabled()) {
+ $classes[] = 'ehf-footer';
+ }
+
+ $classes[] = 'ehf-template-' . $this->template;
+ $classes[] = 'ehf-stylesheet-' . get_stylesheet();
+
+ return $classes;
+ }
+
+ /**
+ * Display Settings Page options
+ *
+ * @since 1.6.0
+ */
+ public function setup_settings_page(): void
+ {
+ require_once HFE_DIR . 'inc/class-hfe-settings-page.php';
+ }
+
+ /**
+ * Display Unsupported theme notice if the current theme does add support for 'header-footer-elementor'
+ *
+ * @param array $hfe_settings_tabs settings array tabs.
+ *
+ * @since 1.0.3
+ */
+ public function setup_unsupported_theme(array $hfe_settings_tabs = []): array
+ {
+ if (! current_theme_supports('header-footer-elementor')) {
+ $hfe_settings_tabs['hfe_settings'] = [
+ 'name' => __('Theme Support', 'header-footer-elementor'),
+ 'url' => admin_url('themes.php?page=hfe-settings'),
+ ];
+ }
+ return $hfe_settings_tabs;
+ }
+
+ /**
+ * Add support for theme if the current theme does add support for 'header-footer-elementor'
+ *
+ * @since 1.6.1
+ */
+ public function setup_fallback_support(): void
+ {
+ if (! current_theme_supports('header-footer-elementor')) {
+ $hfe_compatibility_option = get_option('hfe_compatibility_option', '1');
+
+ if ($hfe_compatibility_option === '1') {
+ if (! class_exists('HFE_Default_Compat')) {
+ require_once HFE_DIR . 'themes/default/class-hfe-default-compat.php';
+ }
+ } elseif ($hfe_compatibility_option === '2') {
+ require HFE_DIR . 'themes/default/class-global-theme-compatibility.php';
+ }
+ }
+ }
+
+ /**
+ * Prints the Header content.
+ */
+ public static function get_header_content(): void
+ {
+ $header_content = self::$elementor_instance->frontend->get_builder_content_for_display(get_hfe_header_id());
+ echo $header_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ }
+
+ /**
+ * Prints the Footer content.
+ */
+ public static function get_footer_content(): void
+ {
+ echo "';
+ }
+
+ /**
+ * Prints the Before Footer content.
+ */
+ public static function get_before_footer_content(): void
+ {
+ echo "';
+ }
+
+ /**
+ * Get option for the plugin settings
+ *
+ * @param string $setting Option name.
+ * @param string $default Default value to be received if the option value is not stored in the option.
+ */
+ public static function get_settings(string $setting = '', string $default = ''): mixed
+ {
+ if ($setting === 'type_header' || $setting === 'type_footer' || $setting === 'type_before_footer') {
+ $templates = self::get_template_id($setting);
+
+ $template = ! is_array($templates) ? $templates : $templates[0];
+
+ return apply_filters("hfe_get_settings_{$setting}", $template);
+ }
+ }
+
+ /**
+ * Get header or footer template id based on the meta query.
+ *
+ * @param String $type Type of the template header/footer.
+ *
+ * @return Mixed Returns the header or footer template id if found, else returns string ''.
+ */
+ public static function get_template_id(string $type): mixed
+ {
+ $option = [
+ 'location' => 'ehf_target_include_locations',
+ 'exclusion' => 'ehf_target_exclude_locations',
+ 'users' => 'ehf_target_user_roles',
+ ];
+
+ $hfe_templates = Astra_Target_Rules_Fields::get_instance()->get_posts_by_conditions('elementor-hf', $option);
+
+ foreach ($hfe_templates as $template) {
+ if (get_post_meta(absint($template['id']), 'ehf_template_type', true) === $type) {
+ if (function_exists('pll_current_language')) {
+ if (pll_current_language('slug') === pll_get_post_language($template['id'], 'slug')) {
+ return $template['id'];
+ }
+ } else {
+ return $template['id'];
+ }
+ }
+ }
+
+ return '';
+ }
+
+ /**
+ * Callback to shortcode.
+ *
+ * @param array $atts attributes for shortcode.
+ */
+ public function render_template(array $atts): string
+ {
+ $atts = shortcode_atts(
+ [
+ 'id' => '',
+ ],
+ $atts,
+ 'hfe_template'
+ );
+
+ $id = ! empty($atts['id']) ? apply_filters('hfe_render_template_id', intval($atts['id'])) : '';
+
+ if (empty($id)) {
+ return '';
+ }
+
+ if (class_exists('\Elementor\Core\Files\CSS\Post')) {
+ $css_file = new \Elementor\Core\Files\CSS\Post($id);
+ } elseif (class_exists('\Elementor\Post_CSS_File')) {
+ // Load elementor styles.
+ $css_file = new \Elementor\Post_CSS_File($id);
+ }
+ $css_file->enqueue();
+
+ return self::$elementor_instance->frontend->get_builder_content_for_display($id);
+ }
}
/**
* Is elementor plugin installed.
*/
-if ( ! function_exists( '_is_elementor_installed' ) ) {
-
- /**
- * Check if Elementor is installed
- *
- * @since 1.6.0
- *
- * @access public
- * @return bool
- */
- function _is_elementor_installed() {
- return ( file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' ) ) ? true : false;
- }
+if (! function_exists('_is_elementor_installed')) {
+ /**
+ * Check if Elementor is installed
+ *
+ * @since 1.6.0
+ *
+ * @access public
+ */
+ function _is_elementor_installed(): bool
+ {
+ return file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php') ? true : false;
+ }
}
diff --git a/inc/class-hfe-elementor-canvas-compat.php b/inc/class-hfe-elementor-canvas-compat.php
index 3a06dd59a..d8aeee812 100644
--- a/inc/class-hfe-elementor-canvas-compat.php
+++ b/inc/class-hfe-elementor-canvas-compat.php
@@ -1,4 +1,7 @@
=' ) ) {
- add_action( 'elementor/page_templates/canvas/before_content', [ $this, 'render_header' ] );
- } else {
- add_action( 'wp_head', [ $this, 'render_header' ] );
- }
- }
-
- if ( hfe_footer_enabled() ) {
-
- // Action `elementor/page_templates/canvas/after_content` is introduced in Elementor Version 1.9.0.
- if ( version_compare( ELEMENTOR_VERSION, '1.9.0', '>=' ) ) {
- add_action( 'elementor/page_templates/canvas/after_content', [ $this, 'render_footer' ] );
- } else {
- add_action( 'wp_footer', [ $this, 'render_footer' ] );
- }
- }
-
- if ( hfe_is_before_footer_enabled() ) {
-
- // check if current page template is Elemenntor Canvas.
- if ( 'elementor_canvas' == get_page_template_slug() ) {
- $override_cannvas_template = get_post_meta( hfe_get_before_footer_id(), 'display-on-canvas-template', true );
-
- if ( '1' == $override_cannvas_template ) {
- add_action( 'elementor/page_templates/canvas/after_content', 'hfe_render_before_footer', 9 );
- }
- }
- }
- }
-
- /**
- * Render the header if display template on elementor canvas is enabled
- * and current template is Elementor Canvas
- *
- * @return void
- */
- public function render_header() {
-
- // bail if current page template is not Elemenntor Canvas.
- if ( 'elementor_canvas' !== get_page_template_slug() ) {
- return;
- }
-
- $override_cannvas_template = get_post_meta( get_hfe_header_id(), 'display-on-canvas-template', true );
-
- if ( '1' == $override_cannvas_template ) {
- hfe_render_header();
- }
- }
-
- /**
- * Render the footer if display template on elementor canvas is enabled
- * and current template is Elementor Canvas
- *
- * @return void
- */
- public function render_footer() {
-
- // bail if current page template is not Elemenntor Canvas.
- if ( 'elementor_canvas' !== get_page_template_slug() ) {
- return;
- }
-
- $override_cannvas_template = get_post_meta( get_hfe_footer_id(), 'display-on-canvas-template', true );
-
- if ( '1' == $override_cannvas_template ) {
- hfe_render_footer();
- }
- }
+class HFE_Elementor_Canvas_Compat
+{
+ /**
+ * Instance of HFE_Elementor_Canvas_Compat.
+ */
+ private static HFE_Elementor_Canvas_Compat $instance;
+
+ /**
+ * Initiator
+ */
+ public static function instance(): HFE_Elementor_Canvas_Compat
+ {
+ if (! isset(self::$instance)) {
+ self::$instance = new HFE_Elementor_Canvas_Compat();
+
+ add_action('wp', [ self::$instance, 'hooks' ]);
+ }
+
+ return self::$instance;
+ }
+
+ /**
+ * Run all the Actions / Filters.
+ */
+ public function hooks(): void
+ {
+ if (hfe_header_enabled()) {
+ // Action `elementor/page_templates/canvas/before_content` is introduced in Elementor Version 1.4.1.
+ if (version_compare(ELEMENTOR_VERSION, '1.4.1', '>=')) {
+ add_action('elementor/page_templates/canvas/before_content', [ $this, 'render_header' ]);
+ } else {
+ add_action('wp_head', [ $this, 'render_header' ]);
+ }
+ }
+
+ if (hfe_footer_enabled()) {
+ // Action `elementor/page_templates/canvas/after_content` is introduced in Elementor Version 1.9.0.
+ if (version_compare(ELEMENTOR_VERSION, '1.9.0', '>=')) {
+ add_action('elementor/page_templates/canvas/after_content', [ $this, 'render_footer' ]);
+ } else {
+ add_action('wp_footer', [ $this, 'render_footer' ]);
+ }
+ }
+
+ if (hfe_is_before_footer_enabled()) {
+ // check if current page template is Elemenntor Canvas.
+ if (get_page_template_slug() === 'elementor_canvas') {
+ $override_cannvas_template = get_post_meta(hfe_get_before_footer_id(), 'display-on-canvas-template', true);
+
+ if ($override_cannvas_template === '1') {
+ add_action('elementor/page_templates/canvas/after_content', 'hfe_render_before_footer', 9);
+ }
+ }
+ }
+ }
+
+ /**
+ * Render the header if display template on elementor canvas is enabled
+ * and current template is Elementor Canvas
+ */
+ public function render_header(): void
+ {
+ // bail if current page template is not Elemenntor Canvas.
+ if (get_page_template_slug() !== 'elementor_canvas') {
+ return;
+ }
+
+ $override_cannvas_template = get_post_meta(get_hfe_header_id(), 'display-on-canvas-template', true);
+
+ if ($override_cannvas_template === '1') {
+ hfe_render_header();
+ }
+ }
+
+ /**
+ * Render the footer if display template on elementor canvas is enabled
+ * and current template is Elementor Canvas
+ */
+ public function render_footer(): void
+ {
+ // bail if current page template is not Elemenntor Canvas.
+ if (get_page_template_slug() !== 'elementor_canvas') {
+ return;
+ }
+
+ $override_cannvas_template = get_post_meta(get_hfe_footer_id(), 'display-on-canvas-template', true);
+
+ if ($override_cannvas_template === '1') {
+ hfe_render_footer();
+ }
+ }
}
HFE_Elementor_Canvas_Compat::instance();
diff --git a/inc/class-hfe-settings-page.php b/inc/class-hfe-settings-page.php
index 589743a93..e69de29bb 100644
--- a/inc/class-hfe-settings-page.php
+++ b/inc/class-hfe-settings-page.php
@@ -1,855 +0,0 @@
- 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' ),
- 'popup_dismiss' => false,
- 'data_source' => 'HFE',
- ];
-
- $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 ) {
-
- $this->hfe_tabs();
- $this->hfe_modal();
- return $views;
- }
-
- /**
- * 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 Elementor Header & Footer Builder 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'
- );
- ?>
-
-
- ';
- esc_attr_e( 'Elementor Header & Footer Builder ', 'header-footer-elementor' );
- echo '';
- $this->hfe_tabs();
- ?>
-
- get_themes_support();
- break;
-
- case 'hfe-about':
- $this->get_about_html();
- break;
-
- case 'default':
- break;
- }
- }
- }
-
- /**
- * Settings page - load modal content.
- *
- * Call back function for add submenu page function.
- *
- * @since 1.6.2
- * @return (void | bool)
- */
- public function hfe_modal() {
- $is_dismissed = [];
- $is_dismissed = get_user_meta( get_current_user_id(), 'hfe-popup' );
-
- $is_subscribed = get_user_meta( get_current_user_ID(), 'hfe-subscribed' );
- $subscribe_valid = ( is_array( $is_subscribed ) && isset( $is_subscribed[0] ) && 'yes' === $is_subscribed[0] ) ? 'yes' : false;
-
- if ( ( ! empty( $is_dismissed ) && 'dismissed' === $is_dismissed[0] ) || 'yes' === $subscribe_valid ) {
- return false;
- } else {
- $this->get_guide_modal();
- }
- }
-
- /**
- * Function for adding tabs
- *
- * @since 1.6.0
- * @return void
- */
- public function hfe_tabs() {
- ?>
-
- __( 'All Templates', 'header-footer-elementor' ),
- 'url' => admin_url( 'edit.php?post_type=elementor-hf' ),
- ];
- }
-
- self::$hfe_settings_tabs['hfe_about'] = [
- 'name' => __( 'About Us', 'header-footer-elementor' ),
- 'url' => admin_url( 'themes.php?page=hfe-about' ),
- ];
-
- $tabs = apply_filters( 'hfe_settings_tabs', self::$hfe_settings_tabs );
-
- foreach ( $tabs as $tab_id => $tab ) {
-
- $tab_slug = str_replace( '_', '-', $tab_id );
-
- $active_tab = ( ( isset( $_GET['page'] ) && $tab_slug == $_GET['page'] ) || ( ! isset( $_GET['page'] ) && 'hfe_templates' == $tab_id ) ) ? $tab_id : ''; // PHPCS:Ignore WordPress.Security.NonceVerification.Recommended
-
- $active = ( $active_tab == $tab_id ) ? ' nav-tab-active' : '';
-
- echo '
';
- echo esc_html( $tab['name'] );
- echo '';
- }
-
- ?>
-
- post_type || 'appearance_page_hfe-guide' === $current_screen->id || 'appearance_page_hfe-about' === $current_screen->id || 'appearance_page_hfe-settings' === $current_screen->id ) );
-
- if ( $is_elementor_screen ) {
- $footer_text = sprintf(
- /* translators: 1: Elementor, 2: Link to plugin review */
- __( 'Help us spread the word about the plugin by leaving %2$s %1$s %3$s ratings on %2$s WordPress.org %3$s. Thank you from the Brainstorm Force team!', 'header-footer-elementor' ),
- '★★★★★',
- '
',
- ''
- );
- }
-
- return $footer_text;
- }
-
- /**
- * Function for theme support tab
- *
- * @since 1.6.0
- * @return void
- */
- public function get_themes_support() {
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
', '', '', '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
-
-
-
-
-
- get_form_row_1(); ?>
- get_form_row_2(); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- output_about_info();
- $this->output_about_addons();
- }
-
- /**
- * Function for Astra Pro white labels with defaults.
- *
- * @since 1.6.24
- * @return array
- */
- protected function get_white_label() {
- $white_labels = is_callable( 'Astra_Admin_Helper::get_admin_settings_option' ) ? \Astra_Admin_Helper::get_admin_settings_option( '_astra_ext_white_label', true ) : [];
-
- $theme_name = ! empty( $white_labels['astra']['name'] ) ? $white_labels['astra']['name'] : 'Astra';
-
- return [
- 'theme_name' => $theme_name,
- /* translators: %s: theme name */
- 'description' => ! empty( $white_labels['astra']['description'] ) ? $white_labels['astra']['description'] : esc_html( sprintf( __( 'Powering over 1+ Million websites, %s is loved for the fast performance and ease of use it offers. It is suitable for all kinds of websites like blogs, portfolios, business, and WooCommerce stores.', 'header-footer-elementor' ), esc_html( $theme_name ) ) ),
- 'theme_icon' => ! empty( $white_labels['astra']['icon'] ) ? $white_labels['astra']['icon'] : '',
- 'author_url' => ! empty( $white_labels['astra']['author_url'] ) ? $white_labels['astra']['author_url'] : 'https://wpastra.com/',
- ];
- }
-
- /**
- * Display the General Info section of About tab.
- *
- * @since 1.6.0
- * @return void
- */
- protected function output_about_info() {
-
- $white_labels = $this->get_white_label();
-
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- get_bsf_plugins();
- $can_install_plugins = $this->hfe_can_install( 'plugin' );
- $can_install_themes = $this->hfe_can_install( 'theme' );
-
- ?>
-
-
- $details ) :
-
- $plugin_data = $this->get_plugin_data( $plugin, $details, $all_plugins, $all_themes );
-
- ?>
-
-
-
-
; ?>)
-
-
- ',
- '',
- esc_html( $plugin_data['details']['name'] )
- );
- ?>
-
-
-
-
-
-
-
-
- ' . wp_kses_post( $plugin_data['status_text'] ) . ''
- );
- ?>
-
-
-
-
-
-
-
-
-
- name || 'Astra' === $theme->parent_theme ) ) ) {
-
- // Status text/status.
- $plugin_data['status_class'] = 'status-active';
- $plugin_data['status_text'] = esc_html__( 'Active', 'header-footer-elementor' );
- // Button text/status.
- $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-secondary disabled';
- $plugin_data['action_text'] = esc_html__( 'Activated', 'header-footer-elementor' );
- $plugin_data['plugin_src'] = esc_attr( $addon );
- } else {
- // Status text/status.
- $plugin_data['status_class'] = 'status-inactive';
- $plugin_data['status_text'] = esc_html__( 'Inactive', 'header-footer-elementor' );
- // Button text/status.
- $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-secondary';
- $plugin_data['action_text'] = esc_html__( 'Activate', 'header-footer-elementor' );
- $plugin_data['plugin_src'] = esc_attr( $addon );
- }
- } else {
- // install if already doesn't exists.
- // Status text/status.
- $plugin_data['status_class'] = 'status-download';
- if ( isset( $details['act'] ) && 'go-to-url' === $details['act'] ) {
- $plugin_data['status_class'] = 'status-go-to-url';
- }
- $plugin_data['status_text'] = esc_html__( 'Not Installed', 'header-footer-elementor' );
- // Button text/status.
- $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-primary';
- $plugin_data['action_text'] = esc_html__( 'Install', 'header-footer-elementor' );
- $plugin_data['plugin_src'] = esc_url( $details['url'] );
-
- if ( $have_pro ) {
- $plugin_data['status_class'] = '';
- $plugin_data['action_text'] = esc_html__( 'Visit Website', 'header-footer-elementor' );
- }
- }
-
- $plugin_data['details'] = $details;
-
- return $plugin_data;
- }
-
- /**
- * List of plugins that we propose to install.
- *
- * @since 1.6.0
- *
- * @return array
- */
- protected function get_bsf_plugins() {
-
- $white_labels = $this->get_white_label();
-
- $images_url = HFE_URL . 'assets/images/settings/';
-
- return [
-
- 'astra' => [
- 'icon' => ! empty( $white_labels['theme_icon'] ) ? $white_labels['theme_icon'] : $images_url . 'plugin-astra.png',
- 'type' => 'theme',
- 'name' => $white_labels['theme_name'],
- 'desc' => $white_labels['description'],
- 'wporg' => 'https://wordpress.org/themes/astra/',
- 'url' => 'https://downloads.wordpress.org/theme/astra.zip',
- 'siteurl' => $white_labels['author_url'],
- 'pro' => false,
- 'slug' => 'astra',
- ],
-
- 'astra-sites/astra-sites.php' => [
- 'icon' => $images_url . 'plugin-st.png',
- 'type' => 'plugin',
- 'name' => esc_html__( 'Starter Templates', 'header-footer-elementor' ),
- 'desc' => esc_html__( 'A popular templates plugin that provides an extensive library of professional and fully customizable 600+ ready website and templates. More than 1+ Million websites have built with this plugin.', 'header-footer-elementor' ),
- 'wporg' => 'https://wordpress.org/plugins/astra-sites/',
- 'url' => 'https://downloads.wordpress.org/plugin/astra-sites.zip',
- 'siteurl' => 'https://startertemplates.com/',
- 'pro' => false,
- 'slug' => 'astra-sites',
- ],
-
- 'ultimate-elementor/ultimate-elementor.php' => [
- 'icon' => $images_url . 'plugin-uae.png',
- 'type' => 'plugin',
- 'name' => esc_html__( 'Ultimate Addons for Elementor', 'header-footer-elementor' ),
- 'desc' => esc_html__( 'It’s a collection of 40+ unique, creative, and optimized Elementor widgets with 100+ readymade templates. Trusted by more than 600+ K web professionals. It’s a #1 toolkit for Elementor Page Builder.', 'header-footer-elementor' ),
- 'wporg' => '',
- 'url' => 'https://ultimateelementor.com/',
- 'siteurl' => 'https://ultimateelementor.com/',
- 'pro' => true,
- 'slug' => 'ultimate-elementor',
- ],
- ];
- }
-
- /**
- * Determine if the plugin/addon installations are allowed.
- *
- * @since 1.6.0
- * @param string $type defines addon type.
- * @return bool
- */
- public function hfe_can_install( $type ) {
-
- if ( ! in_array( $type, [ 'plugin', 'theme' ], true ) ) {
- return false;
- }
-
- // Determine whether file modifications are allowed.
- if ( ! wp_is_file_mod_allowed( 'hfe_can_install' ) ) {
- return false;
- }
-
- if ( 'theme' === $type ) {
- if ( ! current_user_can( 'install_themes' ) ) {
- return false;
- }
-
- return true;
-
- } elseif ( 'plugin' === $type ) {
- if ( ! current_user_can( 'install_plugins' ) ) {
- return false;
- }
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Add settings link to the Plugins page.
- *
- * @since 1.6.0
- *
- * @param array $links Plugin row links.
- *
- * @return array $links
- */
- public function settings_link( $links ) {
-
- $custom['settings'] = sprintf(
- '
%s',
- esc_url(
- add_query_arg(
- [
- 'post_type' => 'elementor-hf',
- ],
- admin_url( 'edit.php' )
- )
- ),
- esc_attr__( 'Go to HFE Settings page', 'header-footer-elementor' ),
- esc_html__( 'Settings', 'header-footer-elementor' )
- );
-
- return array_merge( $custom, (array) $links );
- }
-}
-
-new HFE_Settings_Page();
diff --git a/inc/class-hfe-update.php b/inc/class-hfe-update.php
index c99caf607..79c589721 100644
--- a/inc/class-hfe-update.php
+++ b/inc/class-hfe-update.php
@@ -1,176 +1,184 @@
+ *
* @copyright Copyright (c) 2019, Header Footer Elementor
+ *
* @link https://github.com/Nikschavan/header-footer-elementor/
+ *
* @since HFE 1.1.4
*/
-if ( ! defined( 'ABSPATH' ) ) {
- exit; // Exit if accessed directly.
+if (! defined('ABSPATH')) {
+ exit; // Exit if accessed directly.
}
-if ( ! class_exists( 'HFE_Update' ) ) {
-
- /**
- * HFE_Update initial setup
- *
- * @since 1.1.4
- */
- class HFE_Update {
-
- /**
- * Option key for stored version number.
- *
- * @since 1.1.4
- * @var string
- */
- // phpcs:ignore
- private string $db_option_key = '_hfe_db_version';
-
- /**
- * Constructor
- *
- * @since 1.1.4
- */
- public function __construct() {
-
- // Theme Updates.
- if ( is_admin() ) {
- add_action( 'admin_init', [ $this, 'init' ], 5 );
- } else {
- add_action( 'wp', [ $this, 'init' ], 5 );
- }
- }
-
- /**
- * Implement theme update logic.
- *
- * @since 1.1.4
- * @return void
- */
- public function init() {
- do_action( 'hfe_update_before' );
-
- if ( ! $this->needs_db_update() ) {
- return;
- }
-
- $db_version = get_option( $this->db_option_key, false );
-
- if ( version_compare( $db_version, '1.2.0-beta.2', '<' ) ) {
- $this->setup_default_terget_rules();
- }
-
- // flush rewrite rules on plugin update.
- flush_rewrite_rules(); // PHPCS:Ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules
-
- $this->update_db_version();
-
- do_action( 'hfe_update_after' );
- }
-
- /**
- * Set default target rules for header, footer, before footers being used before target rules were added to the plugin.
- *
- * @since 1.2.0-beta.1
- * @return void
- */
- private function setup_default_terget_rules() {
- $default_include_locations = [
- 'rule' => [ 0 => 'basic-global' ],
- 'specific' => [],
- ];
-
- $header_id = $this->get_legacy_template_id( 'type_header' );
- $footer_id = $this->get_legacy_template_id( 'type_footer' );
- $before_footer_id = $this->get_legacy_template_id( 'type_before_footer' );
-
- // Header.
- if ( ! empty( $header_id ) ) {
- update_post_meta( $header_id, 'ehf_target_include_locations', $default_include_locations );
- }
-
- // Footer.
- if ( ! empty( $footer_id ) ) {
- update_post_meta( $footer_id, 'ehf_target_include_locations', $default_include_locations );
- }
-
- // Before Footer.
- if ( ! empty( $before_footer_id ) ) {
- update_post_meta( $before_footer_id, 'ehf_target_include_locations', $default_include_locations );
- }
- }
-
- /**
- * Get header or footer template id based on the meta query.
- *
- * @param string $type Type of the template header/footer.
- *
- * @return mixed Returns the header or footer template id if found, else returns string ''.
- */
- public function get_legacy_template_id( $type ) {
- $args = [
- 'post_type' => 'elementor-hf',
- 'meta_key' => 'ehf_template_type',
- 'meta_value' => $type, // PHPCS:Ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
- 'meta_type' => 'post',
- 'meta_compare' => '>=',
- 'orderby' => 'meta_value',
- 'order' => 'ASC',
- 'meta_query' => [ // PHPCS:Ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
- 'relation' => 'OR',
- [
- 'key' => 'ehf_template_type',
- 'value' => $type,
- 'compare' => '==',
- 'type' => 'post',
- ],
- ],
- ];
-
- $args = apply_filters( 'hfe_get_template_id_args', $args );
- $template = new WP_Query(
- $args
- );
-
- if ( $template->have_posts() ) {
- $posts = wp_list_pluck( $template->posts, 'ID' );
- return $posts[0];
- }
-
- return '';
- }
-
- /**
- * Check if db upgrade is required.
- *
- * @since 1.1.4
- * @return bool True if stored database version is lower than constant; false if otherwise.
- */
- private function needs_db_update() {
- $db_version = get_option( $this->db_option_key, false );
-
- if ( false === $db_version || version_compare( $db_version, HFE_VER ) ) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Update DB version.
- *
- * @since 1.1.4
- * @return void
- */
- private function update_db_version() {
- update_option( $this->db_option_key, HFE_VER );
- }
- }
+if (! class_exists('HFE_Update')) {
+ /**
+ * HFE_Update initial setup
+ *
+ * @since 1.1.4
+ */
+ class HFE_Update
+ {
+ /**
+ * Option key for stored version number.
+ *
+ * @since 1.1.4
+ */
+ // phpcs:ignore
+ private string $db_option_key = '_hfe_db_version';
+
+ /**
+ * Constructor
+ *
+ * @since 1.1.4
+ */
+ public function __construct()
+ {
+ // Theme Updates.
+ if (is_admin()) {
+ add_action('admin_init', [ $this, 'init' ], 5);
+ } else {
+ add_action('wp', [ $this, 'init' ], 5);
+ }
+ }
+
+ /**
+ * Implement theme update logic.
+ *
+ * @since 1.1.4
+ */
+ public function init(): void
+ {
+ do_action('hfe_update_before');
+
+ if (! $this->needs_db_update()) {
+ return;
+ }
+
+ $db_version = get_option($this->db_option_key, false);
+
+ if (version_compare($db_version, '1.2.0-beta.2', '<')) {
+ $this->setup_default_terget_rules();
+ }
+
+ // flush rewrite rules on plugin update.
+ flush_rewrite_rules(); // PHPCS:Ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules
+
+ $this->update_db_version();
+
+ do_action('hfe_update_after');
+ }
+
+ /**
+ * Get header or footer template id based on the meta query.
+ *
+ * @param string $type Type of the template header/footer.
+ *
+ * @return mixed Returns the header or footer template id if found, else returns string ''.
+ */
+ public function get_legacy_template_id(string $type): mixed
+ {
+ $args = [
+ 'post_type' => 'elementor-hf',
+ 'meta_key' => 'ehf_template_type',
+ 'meta_value' => $type, // PHPCS:Ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
+ 'meta_type' => 'post',
+ 'meta_compare' => '>=',
+ 'orderby' => 'meta_value',
+ 'order' => 'ASC',
+ 'meta_query' => [ // PHPCS:Ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+ 'relation' => 'OR',
+ [
+ 'key' => 'ehf_template_type',
+ 'value' => $type,
+ 'compare' => '==',
+ 'type' => 'post',
+ ],
+ ],
+ ];
+
+ $args = apply_filters('hfe_get_template_id_args', $args);
+ $template = new WP_Query(
+ $args
+ );
+
+ if ($template->have_posts()) {
+ $posts = wp_list_pluck($template->posts, 'ID');
+ return $posts[0];
+ }
+
+ return '';
+ }
+
+ /**
+ * Set default target rules for header, footer, before footers being used before target rules were added to the plugin.
+ *
+ * @since 1.2.0-beta.1
+ */
+ private function setup_default_terget_rules(): void
+ {
+ $default_include_locations = [
+ 'rule' => [ 0 => 'basic-global' ],
+ 'specific' => [],
+ ];
+
+ $header_id = $this->get_legacy_template_id('type_header');
+ $footer_id = $this->get_legacy_template_id('type_footer');
+ $before_footer_id = $this->get_legacy_template_id('type_before_footer');
+
+ // Header.
+ if (! empty($header_id)) {
+ update_post_meta($header_id, 'ehf_target_include_locations', $default_include_locations);
+ }
+
+ // Footer.
+ if (! empty($footer_id)) {
+ update_post_meta($footer_id, 'ehf_target_include_locations', $default_include_locations);
+ }
+
+ // Before Footer.
+ if (! empty($before_footer_id)) {
+ update_post_meta($before_footer_id, 'ehf_target_include_locations', $default_include_locations);
+ }
+ }
+
+ /**
+ * Check if db upgrade is required.
+ *
+ * @since 1.1.4
+ *
+ * @return bool True if stored database version is lower than constant; false if otherwise.
+ */
+ private function needs_db_update(): bool
+ {
+ $db_version = get_option($this->db_option_key, false);
+
+ if ($db_version === false || version_compare($db_version, HFE_VER)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Update DB version.
+ *
+ * @since 1.1.4
+ */
+ private function update_db_version(): void
+ {
+ update_option($this->db_option_key, HFE_VER);
+ }
+ }
}
new HFE_Update();
diff --git a/inc/compatibility/class-hfe-wpml-compatibility.php b/inc/compatibility/class-hfe-wpml-compatibility.php
index 011c00bd2..0e1a0cdab 100644
--- a/inc/compatibility/class-hfe-wpml-compatibility.php
+++ b/inc/compatibility/class-hfe-wpml-compatibility.php
@@ -1,84 +1,93 @@
-
-
-
+
+
+
-
-
+
+
-
-
+
+ get_notice_by_id( $notice_id );
- $capability = isset( $notice['capability'] ) ? $notice['capability'] : 'manage_options';
-
- if ( ! apply_filters( 'astra_notices_user_cap_check', current_user_can( $capability ) ) ) {
- return;
- }
-
- if ( false === wp_verify_nonce( $nonce, 'astra-notices' ) ) {
- wp_send_json_error( esc_html_e( 'WordPress Nonce not validated.', 'header-footer-elementor' ) );
- }
-
- // Valid inputs?
- if ( ! empty( $notice_id ) ) {
-
- if ( ! empty( $repeat_notice_after ) ) {
- set_transient( $notice_id, true, $repeat_notice_after );
- } else {
- update_user_meta( get_current_user_id(), $notice_id, 'notice-dismissed' );
- }
-
- wp_send_json_success();
- }
-
- wp_send_json_error();
- }
-
- /**
- * Enqueue Scripts.
- *
- * @since 1.0.0
- * @return void
- */
- public function enqueue_scripts() {
- wp_register_style( 'astra-notices', self::get_url() . 'notices.css', array(), self::$version );
- wp_register_script( 'astra-notices', self::get_url() . 'notices.js', array( 'jquery' ), self::$version, true );
- wp_localize_script(
- 'astra-notices',
- 'astraNotices',
- array(
- '_notice_nonce' => wp_create_nonce( 'astra-notices' ),
- )
- );
- }
-
- /**
- * Sort the notices based on the given priority of the notice.
- * This function is called from usort()
- *
- * @since 1.5.2
- * @param array $notice_1 First notice.
- * @param array $notice_2 Second Notice.
- * @return array
- */
- public function sort_notices( $notice_1, $notice_2 ) {
- if ( ! isset( $notice_1['priority'] ) ) {
- $notice_1['priority'] = 10;
- }
- if ( ! isset( $notice_2['priority'] ) ) {
- $notice_2['priority'] = 10;
- }
-
- return $notice_1['priority'] - $notice_2['priority'];
- }
-
- /**
- * Get all registered notices.
- * Since v1.1.8 it is recommended to register the notices on
- *
- * @return array|null
- */
- private function get_notices() {
- usort( self::$notices, array( $this, 'sort_notices' ) );
-
- return self::$notices;
- }
-
- /**
- * Get notice by notice_id
- *
- * @param string $notice_id Notice id.
- *
- * @return array notice based on the notice id.
- */
- private function get_notice_by_id( $notice_id ) {
- if ( empty( $notice_id ) ) {
- return array();
- }
-
- $notices = $this->get_notices();
- $notice = wp_list_filter(
- $notices,
- array(
- 'id' => $notice_id,
- )
- );
-
- return ! empty( $notice ) ? $notice[0] : array();
- }
-
- /**
- * Display the notices in the WordPress admin.
- *
- * @since 1.0.0
- * @return void
- */
- public function show_notices() {
- $defaults = array(
- 'id' => '', // Optional, Notice ID. If empty it set `astra-notices-id-<$array-index>`.
- 'type' => 'info', // Optional, Notice type. Default `info`. Expected [info, warning, notice, error].
- 'message' => '', // Optional, Message.
- 'show_if' => true, // Optional, Show notice on custom condition. E.g. 'show_if' => if( is_admin() ) ? true, false, .
- 'repeat-notice-after' => '', // Optional, Dismiss-able notice time. It'll auto show after given time.
- 'display-notice-after' => false, // Optional, Dismiss-able notice time. It'll auto show after given time.
- 'class' => '', // Optional, Additional notice wrapper class.
- 'priority' => 10, // Priority of the notice.
- 'display-with-other-notices' => true, // Should the notice be displayed if other notices are being displayed from Astra_Notices.
- 'is_dismissible' => true,
- 'capability' => 'manage_options', // User capability - This capability is required for the current user to see this notice.
- );
-
- // Count for the notices that are rendered.
- $notices_displayed = 0;
- $notices = $this->get_notices();
-
- foreach ( $notices as $key => $notice ) {
- $notice = wp_parse_args( $notice, $defaults );
-
- // Show notices only for users with `manage_options` cap.
- if ( ! current_user_can( $notice['capability'] ) ) {
- continue;
- }
-
- $notice['id'] = self::get_notice_id( $notice, $key );
- $notice['classes'] = self::get_wrap_classes( $notice );
-
- // Notices visible after transient expire.
- if ( isset( $notice['show_if'] ) && true === $notice['show_if'] ) {
-
- // don't display the notice if it is not supposed to be displayed with other notices.
- if ( 0 !== $notices_displayed && false === $notice['display-with-other-notices'] ) {
- continue;
- }
-
- if ( self::is_expired( $notice ) ) {
-
- self::markup( $notice );
- ++$notices_displayed;
- }
- }
- }
-
- }
-
- /**
- * Render a notice.
- *
- * @since 1.0.0
- * @param array $notice Notice markup.
- * @return void
- */
- public static function markup( $notice = array() ) {
- wp_enqueue_script( 'astra-notices' );
- wp_enqueue_style( 'astra-notices' );
-
- do_action( 'astra_notice_before_markup' );
-
- do_action( "astra_notice_before_markup_{$notice['id']}" );
-
- ?>
-
- register_general_content_controls();
- $this->register_cart_typo_content_controls();
- }
-
- /**
- * Register Menu Cart General Controls.
- *
- * @since 1.4.0
- * @access protected
- * @return void
- */
- protected function register_general_content_controls() {
-
- $this->start_controls_section(
- 'section_general_fields',
- [
- 'label' => __( 'Menu Cart', 'header-footer-elementor' ),
- ]
- );
-
- $this->add_control(
- 'hfe_cart_type',
- [
- 'label' => __( 'Type', 'header-footer-elementor' ),
- 'type' => Controls_Manager::SELECT,
- 'default' => 'default',
- 'options' => [
- 'default' => __( 'Default', 'header-footer-elementor' ),
- 'custom' => __( 'Custom', 'header-footer-elementor' ),
- ],
- ]
- );
-
- $this->add_control(
- 'icon',
- [
- 'label' => __( 'Icon', 'header-footer-elementor' ),
- 'type' => Controls_Manager::SELECT,
- 'options' => [
- 'bag-light' => __( 'Bag Light', 'header-footer-elementor' ),
- 'bag-medium' => __( 'Bag Medium', 'header-footer-elementor' ),
- 'bag-solid' => __( 'Bag Solid', 'header-footer-elementor' ),
- ],
- 'default' => 'bag-light',
- 'prefix_class' => 'toggle-icon--',
- 'condition' => [
- 'hfe_cart_type' => 'custom',
- ],
- ]
- );
-
- $this->add_control(
- 'items_indicator',
- [
- 'label' => __( 'Items Count', 'header-footer-elementor' ),
- 'type' => Controls_Manager::SELECT,
- 'options' => [
- 'none' => __( 'None', 'header-footer-elementor' ),
- 'bubble' => __( 'Bubble', 'header-footer-elementor' ),
- ],
- 'prefix_class' => 'hfe-menu-cart--items-indicator-',
- 'default' => 'bubble',
- 'condition' => [
- 'hfe_cart_type' => 'custom',
- ],
- ]
- );
-
- $this->add_control(
- 'show_subtotal',
- [
- 'label' => __( 'Show Total Price', 'header-footer-elementor' ),
- 'type' => Controls_Manager::SWITCHER,
- 'label_on' => __( 'Yes', 'header-footer-elementor' ),
- 'label_off' => __( 'No', 'header-footer-elementor' ),
- 'return_value' => 'yes',
- 'default' => 'yes',
- 'prefix_class' => 'hfe-menu-cart--show-subtotal-',
- 'condition' => [
- 'hfe_cart_type' => 'custom',
- ],
- ]
- );
-
- $this->add_control(
- 'hide_empty_indicator',
- [
- 'label' => __( 'Hide Empty', 'header-footer-elementor' ),
- 'type' => Controls_Manager::SWITCHER,
- 'label_on' => __( 'Yes', 'header-footer-elementor' ),
- 'label_off' => __( 'No', 'header-footer-elementor' ),
- 'return_value' => 'hide',
- 'prefix_class' => 'hfe-menu-cart--empty-indicator-',
- 'description' => __( 'This will hide the items count until the cart is empty', 'header-footer-elementor' ),
- 'condition' => [
- 'items_indicator!' => 'none',
- 'hfe_cart_type' => 'custom',
- ],
- ]
- );
-
- $this->add_responsive_control(
- 'align',
- [
- 'label' => __( 'Alignment', 'header-footer-elementor' ),
- 'type' => Controls_Manager::CHOOSE,
- 'options' => [
- 'left' => [
- 'title' => __( 'Left', 'header-footer-elementor' ),
- 'icon' => 'eicon-text-align-left',
- ],
- 'center' => [
- 'title' => __( 'Center', 'header-footer-elementor' ),
- 'icon' => 'eicon-text-align-center',
- ],
- 'right' => [
- 'title' => __( 'Right', 'header-footer-elementor' ),
- 'icon' => 'eicon-text-align-right',
- ],
- ],
- 'frontend_available' => true,
- 'prefix_class' => 'elementor%s-align-',
- 'default' => '',
- ]
- );
-
- $this->end_controls_section();
- }
-
-
- /**
- * Register Menu Cart Typography Controls.
- *
- * @since 1.4.0
- * @access protected
- * @return void
- */
- protected function register_cart_typo_content_controls() {
- $this->start_controls_section(
- 'section_heading_typography',
- [
- 'label' => __( 'Menu Cart', 'header-footer-elementor' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- ]
- );
-
- $this->add_group_control(
- Group_Control_Typography::get_type(),
- [
- 'name' => 'toggle_button_typography',
- 'global' => [
- 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
- ],
- 'selector' => '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button',
- 'condition' => [
- 'hfe_cart_type' => 'custom',
- ],
- ]
- );
- $this->add_control(
- 'icon_size',
- [
- 'label' => __( 'Size', 'header-footer-elementor' ),
- 'type' => Controls_Manager::SLIDER,
- 'range' => [
- 'px' => [
- 'min' => 15,
- 'max' => 30,
- ],
- ],
- 'selectors' => [
- '{{WRAPPER}} .hfe-masthead-custom-menu-items .hfe-site-header-cart .hfe-site-header-cart-li ' => 'font-size: {{SIZE}}{{UNIT}};',
- ],
- 'condition' => [
- 'hfe_cart_type' => 'default',
- ],
- ]
- );
- $this->add_control(
- 'toggle_button_border_width',
- [
- 'label' => __( 'Border Width', 'header-footer-elementor' ),
- 'type' => Controls_Manager::DIMENSIONS,
- 'size_units' => [ 'px' ],
- 'default' => [
- 'top' => '1',
- 'bottom' => '1',
- 'left' => '1',
- 'right' => '1',
- 'unit' => 'px',
- ],
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button,{{WRAPPER}} .hfe-cart-menu-wrap-default .hfe-cart-count:after, {{WRAPPER}} .hfe-cart-menu-wrap-default .hfe-cart-count' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
- ],
- ]
- );
-
- $this->add_control(
- 'toggle_button_border_radius',
- [
- 'label' => __( 'Border Radius', 'header-footer-elementor' ),
- 'type' => Controls_Manager::DIMENSIONS,
- 'default' => [
- 'top' => '',
- 'bottom' => '',
- 'left' => '',
- 'right' => '',
- 'unit' => 'px',
- ],
- 'size_units' => [ 'px', 'em', '%' ],
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button,{{WRAPPER}} .hfe-cart-menu-wrap-default .hfe-cart-count:after, {{WRAPPER}} .hfe-cart-menu-wrap-default .hfe-cart-count' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
- ],
-
- ]
- );
-
- $this->add_responsive_control(
- 'toggle_button_padding',
- [
- 'label' => __( 'Padding', 'header-footer-elementor' ),
- 'type' => Controls_Manager::DIMENSIONS,
- 'size_units' => [ 'px', 'em' ],
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}',
- ],
- 'condition' => [
- 'hfe_cart_type' => 'custom',
- ],
- 'frontend_available' => true,
- ]
- );
-
- $this->start_controls_tabs( 'toggle_button_colors' );
-
- $this->start_controls_tab(
- 'toggle_button_normal_colors',
- [
- 'label' => __( 'Normal', 'header-footer-elementor' ),
- ]
- );
-
- $this->add_control(
- 'toggle_button_text_color',
- [
- 'label' => __( 'Text Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button,{{WRAPPER}} .hfe-cart-menu-wrap-default span.hfe-cart-count' => 'color: {{VALUE}}',
- ],
- ]
- );
-
- $this->add_control(
- 'toggle_button_icon_color',
- [
- 'label' => __( 'Icon Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-icon' => 'color: {{VALUE}}',
- ],
- 'condition' => [
- 'hfe_cart_type' => 'custom',
- ],
- ]
- );
-
- $this->add_control(
- 'toggle_button_background_color',
- [
- 'label' => __( 'Background Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button,{{WRAPPER}} .hfe-cart-menu-wrap-default span.hfe-cart-count' => 'background-color: {{VALUE}}',
- ],
- ]
- );
-
- $this->add_control(
- 'toggle_button_border_color',
- [
- 'label' => __( 'Border Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button,{{WRAPPER}} .hfe-cart-menu-wrap-default .hfe-cart-count:after, {{WRAPPER}} .hfe-masthead-custom-menu-items .hfe-cart-menu-wrap-default .hfe-cart-count' => 'border-color: {{VALUE}}',
- ],
- ]
- );
-
- $this->end_controls_tab();
-
- $this->start_controls_tab(
- 'toggle_button_hover_colors',
- [
- 'label' => __( 'Hover', 'header-footer-elementor' ),
- ]
- );
-
- $this->add_control(
- 'toggle_button_hover_text_color',
- [
- 'label' => __( 'Text Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button:hover,{{WRAPPER}} .hfe-cart-menu-wrap-default span.hfe-cart-count:hover' => 'color: {{VALUE}}',
- ],
- ]
- );
-
- $this->add_control(
- 'toggle_button_hover_icon_color',
- [
- 'label' => __( 'Icon Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button:hover .elementor-button-icon' => 'color: {{VALUE}}',
- ],
- 'condition' => [
- 'hfe_cart_type' => 'custom',
- ],
- ]
- );
-
- $this->add_control(
- 'toggle_button_hover_background_color',
- [
- 'label' => __( 'Background Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button:hover,{{WRAPPER}} .hfe-cart-menu-wrap-default span.hfe-cart-count:hover' => 'background-color: {{VALUE}}',
- ],
- ]
- );
-
- $this->add_control(
- 'toggle_button_hover_border_color',
- [
- 'label' => __( 'Border Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button:hover,{{WRAPPER}} .hfe-cart-menu-wrap-default:hover .hfe-cart-count:after, {{WRAPPER}} .hfe-cart-menu-wrap-default:hover .hfe-cart-count' => 'border-color: {{VALUE}}',
- ],
- ]
- );
-
- $this->end_controls_tab();
-
- $this->end_controls_tabs();
- $this->add_control(
- 'toggle_icon_size',
- [
- 'label' => __( 'Icon Size', 'header-footer-elementor' ),
- 'type' => Controls_Manager::SLIDER,
- 'range' => [
- 'px' => [
- 'min' => 0,
- 'max' => 50,
- ],
- ],
- 'size_units' => [ 'px', 'em' ],
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-icon' => 'font-size: {{SIZE}}{{UNIT}}',
- ],
- 'condition' => [
- 'hfe_cart_type' => 'custom',
- ],
- 'separator' => 'before',
- ]
- );
-
- $this->add_control(
- 'toggle_icon_spacing',
- [
- 'label' => __( 'Icon Spacing', 'header-footer-elementor' ),
- 'type' => Controls_Manager::SLIDER,
- 'range' => [
- 'px' => [
- 'min' => 0,
- 'max' => 50,
- ],
- ],
- 'size-units' => [ 'px', 'em' ],
- 'selectors' => [
- 'body:not(.rtl) {{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-text' => 'margin-right: {{SIZE}}{{UNIT}}',
- 'body.rtl {{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-text' => 'margin-left: {{SIZE}}{{UNIT}}',
- ],
- 'condition' => [
- 'hfe_cart_type' => 'custom',
- ],
- ]
- );
-
- $this->end_controls_section();
-
- $this->start_controls_section(
- 'section_icon',
- [
- 'label' => __( 'Items Count', 'header-footer-elementor' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- 'condition' => [
- 'icon[value]!' => '',
- 'items_indicator!' => 'none',
- 'hfe_cart_type' => 'custom',
- ],
- ]
- );
-
- $this->add_control(
- 'items_indicator_distance',
- [
- 'label' => __( 'Distance', 'header-footer-elementor' ),
- 'type' => Controls_Manager::SLIDER,
- 'default' => [
- 'unit' => 'em',
- ],
- 'range' => [
- 'em' => [
- 'min' => 0,
- 'max' => 4,
- 'step' => 0.1,
- ],
- ],
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-icon[data-counter]:before' => 'right: -{{SIZE}}{{UNIT}}; top: -{{SIZE}}{{UNIT}}',
- ],
- 'condition' => [
- 'items_indicator' => 'bubble',
- ],
- ]
- );
-
- $this->start_controls_tabs( 'count_colors' );
-
- $this->start_controls_tab(
- 'count_normal_colors',
- [
- 'label' => __( 'Normal', 'header-footer-elementor' ),
- ]
- );
-
- $this->add_control(
- 'items_indicator_text_color',
- [
- 'label' => __( 'Text Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-icon[data-counter]:before' => 'color: {{VALUE}}',
- ],
- 'condition' => [
- 'items_indicator!' => 'none',
- ],
- ]
- );
-
- $this->add_control(
- 'items_indicator_background_color',
- [
- 'label' => __( 'Background Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-icon[data-counter]:before' => 'background-color: {{VALUE}}',
- ],
- 'condition' => [
- 'items_indicator' => 'bubble',
- ],
- ]
- );
-
- $this->end_controls_tab();
-
- $this->start_controls_tab(
- 'count_hover_colors',
- [
- 'label' => __( 'Hover', 'header-footer-elementor' ),
- ]
- );
-
- $this->add_control(
- 'items_indicator_text_hover_color',
- [
- 'label' => __( 'Text Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle:hover .elementor-button-icon[data-counter]:before' => 'color: {{VALUE}}',
- ],
- 'condition' => [
- 'items_indicator!' => 'none',
- ],
- ]
- );
-
- $this->add_control(
- 'items_indicator_background_hover_color',
- [
- 'label' => __( 'Background Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .hfe-menu-cart__toggle:hover .elementor-button-icon[data-counter]:before' => 'background-color: {{VALUE}}',
- ],
- 'condition' => [
- 'items_indicator' => 'bubble',
- ],
- ]
- );
-
- $this->end_controls_tab();
-
- $this->end_controls_tabs();
-
- $this->end_controls_section();
- }
-
- /**
- * Render Menu Cart output on the frontend.
- *
- * Written in PHP and used to generate the final HTML.
- *
- * @since 1.4.0
- * @access protected
- * @return void
- */
- protected function render() {
-
- if ( null === WC()->cart ) {
- return;
- }
-
- $settings = $this->get_settings_for_display();
- $cart_type = $settings['hfe_cart_type'];
-
- ?>
-
-
- register_general_content_controls();
+ $this->register_cart_typo_content_controls();
+ }
+
+ /**
+ * Register Menu Cart General Controls.
+ *
+ * @since 1.4.0
+ *
+ * @access protected
+ */
+ protected function register_general_content_controls(): void
+ {
+ $this->start_controls_section(
+ 'section_general_fields',
+ [
+ 'label' => __('Menu Cart', 'header-footer-elementor'),
+ ]
+ );
+
+ $this->add_control(
+ 'hfe_cart_type',
+ [
+ 'label' => __('Type', 'header-footer-elementor'),
+ 'type' => Controls_Manager::SELECT,
+ 'default' => 'default',
+ 'options' => [
+ 'default' => __('Default', 'header-footer-elementor'),
+ 'custom' => __('Custom', 'header-footer-elementor'),
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'icon',
+ [
+ 'label' => __('Icon', 'header-footer-elementor'),
+ 'type' => Controls_Manager::SELECT,
+ 'options' => [
+ 'bag-light' => __('Bag Light', 'header-footer-elementor'),
+ 'bag-medium' => __('Bag Medium', 'header-footer-elementor'),
+ 'bag-solid' => __('Bag Solid', 'header-footer-elementor'),
+ ],
+ 'default' => 'bag-light',
+ 'prefix_class' => 'toggle-icon--',
+ 'condition' => [
+ 'hfe_cart_type' => 'custom',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'items_indicator',
+ [
+ 'label' => __('Items Count', 'header-footer-elementor'),
+ 'type' => Controls_Manager::SELECT,
+ 'options' => [
+ 'none' => __('None', 'header-footer-elementor'),
+ 'bubble' => __('Bubble', 'header-footer-elementor'),
+ ],
+ 'prefix_class' => 'hfe-menu-cart--items-indicator-',
+ 'default' => 'bubble',
+ 'condition' => [
+ 'hfe_cart_type' => 'custom',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'show_subtotal',
+ [
+ 'label' => __('Show Total Price', 'header-footer-elementor'),
+ 'type' => Controls_Manager::SWITCHER,
+ 'label_on' => __('Yes', 'header-footer-elementor'),
+ 'label_off' => __('No', 'header-footer-elementor'),
+ 'return_value' => 'yes',
+ 'default' => 'yes',
+ 'prefix_class' => 'hfe-menu-cart--show-subtotal-',
+ 'condition' => [
+ 'hfe_cart_type' => 'custom',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'hide_empty_indicator',
+ [
+ 'label' => __('Hide Empty', 'header-footer-elementor'),
+ 'type' => Controls_Manager::SWITCHER,
+ 'label_on' => __('Yes', 'header-footer-elementor'),
+ 'label_off' => __('No', 'header-footer-elementor'),
+ 'return_value' => 'hide',
+ 'prefix_class' => 'hfe-menu-cart--empty-indicator-',
+ 'description' => __('This will hide the items count until the cart is empty', 'header-footer-elementor'),
+ 'condition' => [
+ 'items_indicator!' => 'none',
+ 'hfe_cart_type' => 'custom',
+ ],
+ ]
+ );
+
+ $this->add_responsive_control(
+ 'align',
+ [
+ 'label' => __('Alignment', 'header-footer-elementor'),
+ 'type' => Controls_Manager::CHOOSE,
+ 'options' => [
+ 'left' => [
+ 'title' => __('Left', 'header-footer-elementor'),
+ 'icon' => 'eicon-text-align-left',
+ ],
+ 'center' => [
+ 'title' => __('Center', 'header-footer-elementor'),
+ 'icon' => 'eicon-text-align-center',
+ ],
+ 'right' => [
+ 'title' => __('Right', 'header-footer-elementor'),
+ 'icon' => 'eicon-text-align-right',
+ ],
+ ],
+ 'frontend_available' => true,
+ 'prefix_class' => 'elementor%s-align-',
+ 'default' => '',
+ ]
+ );
+
+ $this->end_controls_section();
+ }
+
+ /**
+ * Register Menu Cart Typography Controls.
+ *
+ * @since 1.4.0
+ *
+ * @access protected
+ */
+ protected function register_cart_typo_content_controls(): void
+ {
+ $this->start_controls_section(
+ 'section_heading_typography',
+ [
+ 'label' => __('Menu Cart', 'header-footer-elementor'),
+ 'tab' => Controls_Manager::TAB_STYLE,
+ ]
+ );
+
+ $this->add_group_control(
+ Group_Control_Typography::get_type(),
+ [
+ 'name' => 'toggle_button_typography',
+ 'global' => [
+ 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
+ ],
+ 'selector' => '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button',
+ 'condition' => [
+ 'hfe_cart_type' => 'custom',
+ ],
+ ]
+ );
+ $this->add_control(
+ 'icon_size',
+ [
+ 'label' => __('Size', 'header-footer-elementor'),
+ 'type' => Controls_Manager::SLIDER,
+ 'range' => [
+ 'px' => [
+ 'min' => 15,
+ 'max' => 30,
+ ],
+ ],
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-masthead-custom-menu-items .hfe-site-header-cart .hfe-site-header-cart-li ' => 'font-size: {{SIZE}}{{UNIT}};',
+ ],
+ 'condition' => [
+ 'hfe_cart_type' => 'default',
+ ],
+ ]
+ );
+ $this->add_control(
+ 'toggle_button_border_width',
+ [
+ 'label' => __('Border Width', 'header-footer-elementor'),
+ 'type' => Controls_Manager::DIMENSIONS,
+ 'size_units' => [ 'px' ],
+ 'default' => [
+ 'top' => '1',
+ 'bottom' => '1',
+ 'left' => '1',
+ 'right' => '1',
+ 'unit' => 'px',
+ ],
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button,{{WRAPPER}} .hfe-cart-menu-wrap-default .hfe-cart-count:after, {{WRAPPER}} .hfe-cart-menu-wrap-default .hfe-cart-count' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'toggle_button_border_radius',
+ [
+ 'label' => __('Border Radius', 'header-footer-elementor'),
+ 'type' => Controls_Manager::DIMENSIONS,
+ 'default' => [
+ 'top' => '',
+ 'bottom' => '',
+ 'left' => '',
+ 'right' => '',
+ 'unit' => 'px',
+ ],
+ 'size_units' => [ 'px', 'em', '%' ],
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button,{{WRAPPER}} .hfe-cart-menu-wrap-default .hfe-cart-count:after, {{WRAPPER}} .hfe-cart-menu-wrap-default .hfe-cart-count' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
+ ],
+
+ ]
+ );
+
+ $this->add_responsive_control(
+ 'toggle_button_padding',
+ [
+ 'label' => __('Padding', 'header-footer-elementor'),
+ 'type' => Controls_Manager::DIMENSIONS,
+ 'size_units' => [ 'px', 'em' ],
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}',
+ ],
+ 'condition' => [
+ 'hfe_cart_type' => 'custom',
+ ],
+ 'frontend_available' => true,
+ ]
+ );
+
+ $this->start_controls_tabs('toggle_button_colors');
+
+ $this->start_controls_tab(
+ 'toggle_button_normal_colors',
+ [
+ 'label' => __('Normal', 'header-footer-elementor'),
+ ]
+ );
+
+ $this->add_control(
+ 'toggle_button_text_color',
+ [
+ 'label' => __('Text Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button,{{WRAPPER}} .hfe-cart-menu-wrap-default span.hfe-cart-count' => 'color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'toggle_button_icon_color',
+ [
+ 'label' => __('Icon Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-icon' => 'color: {{VALUE}}',
+ ],
+ 'condition' => [
+ 'hfe_cart_type' => 'custom',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'toggle_button_background_color',
+ [
+ 'label' => __('Background Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button,{{WRAPPER}} .hfe-cart-menu-wrap-default span.hfe-cart-count' => 'background-color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'toggle_button_border_color',
+ [
+ 'label' => __('Border Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button,{{WRAPPER}} .hfe-cart-menu-wrap-default .hfe-cart-count:after, {{WRAPPER}} .hfe-masthead-custom-menu-items .hfe-cart-menu-wrap-default .hfe-cart-count' => 'border-color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->end_controls_tab();
+
+ $this->start_controls_tab(
+ 'toggle_button_hover_colors',
+ [
+ 'label' => __('Hover', 'header-footer-elementor'),
+ ]
+ );
+
+ $this->add_control(
+ 'toggle_button_hover_text_color',
+ [
+ 'label' => __('Text Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button:hover,{{WRAPPER}} .hfe-cart-menu-wrap-default span.hfe-cart-count:hover' => 'color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'toggle_button_hover_icon_color',
+ [
+ 'label' => __('Icon Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button:hover .elementor-button-icon' => 'color: {{VALUE}}',
+ ],
+ 'condition' => [
+ 'hfe_cart_type' => 'custom',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'toggle_button_hover_background_color',
+ [
+ 'label' => __('Background Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button:hover,{{WRAPPER}} .hfe-cart-menu-wrap-default span.hfe-cart-count:hover' => 'background-color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'toggle_button_hover_border_color',
+ [
+ 'label' => __('Border Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button:hover,{{WRAPPER}} .hfe-cart-menu-wrap-default:hover .hfe-cart-count:after, {{WRAPPER}} .hfe-cart-menu-wrap-default:hover .hfe-cart-count' => 'border-color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->end_controls_tab();
+
+ $this->end_controls_tabs();
+ $this->add_control(
+ 'toggle_icon_size',
+ [
+ 'label' => __('Icon Size', 'header-footer-elementor'),
+ 'type' => Controls_Manager::SLIDER,
+ 'range' => [
+ 'px' => [
+ 'min' => 0,
+ 'max' => 50,
+ ],
+ ],
+ 'size_units' => [ 'px', 'em' ],
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-icon' => 'font-size: {{SIZE}}{{UNIT}}',
+ ],
+ 'condition' => [
+ 'hfe_cart_type' => 'custom',
+ ],
+ 'separator' => 'before',
+ ]
+ );
+
+ $this->add_control(
+ 'toggle_icon_spacing',
+ [
+ 'label' => __('Icon Spacing', 'header-footer-elementor'),
+ 'type' => Controls_Manager::SLIDER,
+ 'range' => [
+ 'px' => [
+ 'min' => 0,
+ 'max' => 50,
+ ],
+ ],
+ 'size-units' => [ 'px', 'em' ],
+ 'selectors' => [
+ 'body:not(.rtl) {{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-text' => 'margin-right: {{SIZE}}{{UNIT}}',
+ 'body.rtl {{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-text' => 'margin-left: {{SIZE}}{{UNIT}}',
+ ],
+ 'condition' => [
+ 'hfe_cart_type' => 'custom',
+ ],
+ ]
+ );
+
+ $this->end_controls_section();
+
+ $this->start_controls_section(
+ 'section_icon',
+ [
+ 'label' => __('Items Count', 'header-footer-elementor'),
+ 'tab' => Controls_Manager::TAB_STYLE,
+ 'condition' => [
+ 'icon[value]!' => '',
+ 'items_indicator!' => 'none',
+ 'hfe_cart_type' => 'custom',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'items_indicator_distance',
+ [
+ 'label' => __('Distance', 'header-footer-elementor'),
+ 'type' => Controls_Manager::SLIDER,
+ 'default' => [
+ 'unit' => 'em',
+ ],
+ 'range' => [
+ 'em' => [
+ 'min' => 0,
+ 'max' => 4,
+ 'step' => 0.1,
+ ],
+ ],
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-icon[data-counter]:before' => 'right: -{{SIZE}}{{UNIT}}; top: -{{SIZE}}{{UNIT}}',
+ ],
+ 'condition' => [
+ 'items_indicator' => 'bubble',
+ ],
+ ]
+ );
+
+ $this->start_controls_tabs('count_colors');
+
+ $this->start_controls_tab(
+ 'count_normal_colors',
+ [
+ 'label' => __('Normal', 'header-footer-elementor'),
+ ]
+ );
+
+ $this->add_control(
+ 'items_indicator_text_color',
+ [
+ 'label' => __('Text Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-icon[data-counter]:before' => 'color: {{VALUE}}',
+ ],
+ 'condition' => [
+ 'items_indicator!' => 'none',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'items_indicator_background_color',
+ [
+ 'label' => __('Background Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle .elementor-button-icon[data-counter]:before' => 'background-color: {{VALUE}}',
+ ],
+ 'condition' => [
+ 'items_indicator' => 'bubble',
+ ],
+ ]
+ );
+
+ $this->end_controls_tab();
+
+ $this->start_controls_tab(
+ 'count_hover_colors',
+ [
+ 'label' => __('Hover', 'header-footer-elementor'),
+ ]
+ );
+
+ $this->add_control(
+ 'items_indicator_text_hover_color',
+ [
+ 'label' => __('Text Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle:hover .elementor-button-icon[data-counter]:before' => 'color: {{VALUE}}',
+ ],
+ 'condition' => [
+ 'items_indicator!' => 'none',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'items_indicator_background_hover_color',
+ [
+ 'label' => __('Background Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-menu-cart__toggle:hover .elementor-button-icon[data-counter]:before' => 'background-color: {{VALUE}}',
+ ],
+ 'condition' => [
+ 'items_indicator' => 'bubble',
+ ],
+ ]
+ );
+
+ $this->end_controls_tab();
+
+ $this->end_controls_tabs();
+
+ $this->end_controls_section();
+ }
+
+ /**
+ * Render Menu Cart output on the frontend.
+ *
+ * Written in PHP and used to generate the final HTML.
+ *
+ * @since 1.4.0
+ *
+ * @access protected
+ */
+ protected function render(): void
+ {
+ if (WC()->cart === null) {
+ return;
+ }
+
+ $settings = $this->get_settings_for_display();
+ $cart_type = $settings['hfe_cart_type'];
+
+ ?>
+
+
+ register_content_copy_right_controls();
- }
- /**
- * Register Copyright General Controls.
- *
- * @since 1.2.0
- * @access protected
- * @return void
- */
- protected function register_content_copy_right_controls() {
- $this->start_controls_section(
- 'section_title',
- [
- 'label' => __( 'Copyright', 'header-footer-elementor' ),
- ]
- );
-
- $this->add_control(
- 'shortcode',
- [
- 'label' => __( 'Copyright Text', 'header-footer-elementor' ),
- 'type' => Controls_Manager::TEXTAREA,
- 'dynamic' => [
- 'active' => true,
- ],
- 'default' => __( 'Copyright © [hfe_current_year] [hfe_site_title] | Powered by [hfe_site_title]', 'header-footer-elementor' ),
- ]
- );
-
- $this->add_control(
- 'link',
- [
- 'label' => __( 'Link', 'header-footer-elementor' ),
- 'type' => Controls_Manager::URL,
- 'placeholder' => __( 'https://your-link.com', 'header-footer-elementor' ),
- ]
- );
-
- $this->add_responsive_control(
- 'align',
- [
- 'label' => __( 'Alignment', 'header-footer-elementor' ),
- 'type' => Controls_Manager::CHOOSE,
- 'options' => [
- 'left' => [
- 'title' => __( 'Left', 'header-footer-elementor' ),
- 'icon' => 'fa fa-align-left',
- ],
- 'center' => [
- 'title' => __( 'Center', 'header-footer-elementor' ),
- 'icon' => 'fa fa-align-center',
- ],
- 'right' => [
- 'title' => __( 'Right', 'header-footer-elementor' ),
- 'icon' => 'fa fa-align-right',
- ],
- ],
- 'selectors' => [
- '{{WRAPPER}} .hfe-copyright-wrapper' => 'text-align: {{VALUE}};',
- ],
- 'frontend_available' => true,
- ]
- );
-
- $this->add_control(
- 'title_color',
- [
- 'label' => __( 'Text Color', 'header-footer-elementor' ),
- 'type' => Controls_Manager::COLOR,
- 'global' => [
- 'default' => Global_Colors::COLOR_TEXT,
- ],
- 'selectors' => [
- // Stronger selector to avoid section style from overwriting.
- '{{WRAPPER}} .hfe-copyright-wrapper a, {{WRAPPER}} .hfe-copyright-wrapper' => 'color: {{VALUE}};',
- ],
- ]
- );
-
- $this->add_group_control(
- Group_Control_Typography::get_type(),
- [
- 'name' => 'caption_typography',
- 'selector' => '{{WRAPPER}} .hfe-copyright-wrapper, {{WRAPPER}} .hfe-copyright-wrapper a',
- 'global' => [
- 'default' => Global_Typography::TYPOGRAPHY_TEXT,
- ],
- ]
- );
- }
-
- /**
- * Render Copyright output on the frontend.
- *
- * Written in PHP and used to generate the final HTML.
- *
- * @since 1.2.0
- * @access protected
- * @return void
- */
- protected function render() {
- $settings = $this->get_settings_for_display();
- $link = isset( $settings['link']['url'] ) ? $settings['link']['url'] : '';
-
- if ( ! empty( $link ) ) {
- $this->add_link_attributes( 'link', $settings['link'] );
- }
-
- $copy_right_shortcode = do_shortcode( shortcode_unautop( $settings['shortcode'] ) ); ?>
-
- get_settings( 'shortcode' ) );
- }
-
- /**
- * Render shortcode widget output in the editor.
- *
- * Written as a Backbone JavaScript template and used to generate the live preview.
- *
- * @since 1.3.0
- * @access protected
- * @return void
- */
- protected function content_template() {}
+class Copyright extends Widget_Base
+{
+ /**
+ * Retrieve the widget name.
+ *
+ * @since 1.2.0
+ *
+ * @access public
+ *
+ * @return string Widget name.
+ */
+ public function get_name(): string
+ {
+ return 'copyright';
+ }
+ /**
+ * Retrieve the widget title.
+ *
+ * @since 1.2.0
+ *
+ * @access public
+ *
+ * @return string Widget title.
+ */
+ public function get_title(): string
+ {
+ return __('Copyright', 'header-footer-elementor');
+ }
+ /**
+ * Retrieve the widget icon.
+ *
+ * @since 1.2.0
+ *
+ * @access public
+ *
+ * @return string Widget icon.
+ */
+ public function get_icon(): string
+ {
+ return 'hfe-icon-copyright-widget';
+ }
+ /**
+ * Retrieve the list of categories the widget belongs to.
+ *
+ * Used to determine where to display the widget in the editor.
+ *
+ * Note that currently Elementor supports only one category.
+ * When multiple categories passed, Elementor uses the first one.
+ *
+ * @since 1.2.0
+ *
+ * @access public
+ *
+ * @return array Widget categories.
+ */
+ public function get_categories(): array
+ {
+ return [ 'hfe-widgets' ];
+ }
+
+ /**
+ * Render shortcode widget as plain content.
+ *
+ * Override the default behavior by printing the shortcode instead of rendering it.
+ *
+ * @since 1.2.0
+ *
+ * @access public
+ */
+ public function render_plain_content(): void
+ {
+ // In plain mode, render without shortcode.
+ echo esc_attr($this->get_settings('shortcode'));
+ }
+
+ /**
+ * Indicates if the widget's content is dynamic.
+ *
+ * This method returns true if the widget's output is dynamic and should not be cached,
+ * or false if the content is static and can be cached.
+ *
+ * @since 1.6.41
+ *
+ * @return bool True for dynamic content, false for static content.
+ */
+ protected function is_dynamic_content(): bool // phpcs:ignore
+ {return false;
+ }
+
+ /**
+ * Register Copyright controls.
+ *
+ * @since 1.5.7
+ *
+ * @access protected
+ */
+ protected function register_controls(): void
+ {
+ $this->register_content_copy_right_controls();
+ }
+ /**
+ * Register Copyright General Controls.
+ *
+ * @since 1.2.0
+ *
+ * @access protected
+ */
+ protected function register_content_copy_right_controls(): void
+ {
+ $this->start_controls_section(
+ 'section_title',
+ [
+ 'label' => __('Copyright', 'header-footer-elementor'),
+ ]
+ );
+
+ $this->add_control(
+ 'shortcode',
+ [
+ 'label' => __('Copyright Text', 'header-footer-elementor'),
+ 'type' => Controls_Manager::TEXTAREA,
+ 'dynamic' => [
+ 'active' => true,
+ ],
+ 'default' => __('Copyright © [hfe_current_year] [hfe_site_title] | Powered by [hfe_site_title]', 'header-footer-elementor'),
+ ]
+ );
+
+ $this->add_control(
+ 'link',
+ [
+ 'label' => __('Link', 'header-footer-elementor'),
+ 'type' => Controls_Manager::URL,
+ 'placeholder' => __('https://your-link.com', 'header-footer-elementor'),
+ ]
+ );
+
+ $this->add_responsive_control(
+ 'align',
+ [
+ 'label' => __('Alignment', 'header-footer-elementor'),
+ 'type' => Controls_Manager::CHOOSE,
+ 'options' => [
+ 'left' => [
+ 'title' => __('Left', 'header-footer-elementor'),
+ 'icon' => 'fa fa-align-left',
+ ],
+ 'center' => [
+ 'title' => __('Center', 'header-footer-elementor'),
+ 'icon' => 'fa fa-align-center',
+ ],
+ 'right' => [
+ 'title' => __('Right', 'header-footer-elementor'),
+ 'icon' => 'fa fa-align-right',
+ ],
+ ],
+ 'selectors' => [
+ '{{WRAPPER}} .hfe-copyright-wrapper' => 'text-align: {{VALUE}};',
+ ],
+ 'frontend_available' => true,
+ ]
+ );
+
+ $this->add_control(
+ 'title_color',
+ [
+ 'label' => __('Text Color', 'header-footer-elementor'),
+ 'type' => Controls_Manager::COLOR,
+ 'global' => [
+ 'default' => Global_Colors::COLOR_TEXT,
+ ],
+ 'selectors' => [
+ // Stronger selector to avoid section style from overwriting.
+ '{{WRAPPER}} .hfe-copyright-wrapper a, {{WRAPPER}} .hfe-copyright-wrapper' => 'color: {{VALUE}};',
+ ],
+ ]
+ );
+
+ $this->add_group_control(
+ Group_Control_Typography::get_type(),
+ [
+ 'name' => 'caption_typography',
+ 'selector' => '{{WRAPPER}} .hfe-copyright-wrapper, {{WRAPPER}} .hfe-copyright-wrapper a',
+ 'global' => [
+ 'default' => Global_Typography::TYPOGRAPHY_TEXT,
+ ],
+ ]
+ );
+ }
+
+ /**
+ * Render Copyright output on the frontend.
+ *
+ * Written in PHP and used to generate the final HTML.
+ *
+ * @since 1.2.0
+ *
+ * @access protected
+ */
+ protected function render(): void
+ {
+ $settings = $this->get_settings_for_display();
+ $link = $settings['link']['url'] ?? '';
+
+ if (! empty($link)) {
+ $this->add_link_attributes('link', $settings['link']);
+ }
+
+ $copy_right_shortcode = do_shortcode(shortcode_unautop($settings['shortcode'])); ?>
+
+ classes ) ? [] : (array) $item->classes;
- $submenu = $args->has_children ? ' hfe-has-submenu' : '';
-
- if ( 0 === $depth ) {
- array_push( $classes, 'parent' );
- }
- $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
- $class_names = ' class="' . esc_attr( $class_names ) . $submenu . ' hfe-creative-menu"';
- $value = apply_filters( 'nav_menu_li_values', $value );
-
- $output .= $indent . '
';
- }
- }
+ if (! did_action('wp_body_open')) {
+ echo '';
+ }
+ }
}
new Global_Theme_Compatibility();
diff --git a/themes/default/class-hfe-default-compat.php b/themes/default/class-hfe-default-compat.php
index 242e3a310..36e9d2095 100644
--- a/themes/default/class-hfe-default-compat.php
+++ b/themes/default/class-hfe-default-compat.php
@@ -1,4 +1,7 @@
-
-
+
+