is_header_footer_builder_active && '1' == $inherit_desk_logo && '' !== $header_logo ) { $classes[] = 'ast-sticky-custom-logo'; } if ( ( '1' == $main_stick || ( 'enabled' == $sticky_header_meta && ( 'on' == $sticky_primary_header_meta || 'disabled' == $sticky_primary_header_meta ) ) ) ) { $classes[] = 'ast-primary-sticky-enabled'; } return $classes; } /** * Site Header -
* * @since 1.0.0 */ public function none_header_markup() { $main_stick = astra_get_option( 'header-main-stick' ); $header_style = astra_get_option( 'sticky-header-style' ); $inherit_desk_logo = astra_get_option( 'different-sticky-logo', false ); $sticky_header_meta = astra_get_option_meta( 'stick-header-meta' ); $sticky_primary_header_meta = astra_get_option_meta( 'header-main-stick-meta' ); if ( '1' == $inherit_desk_logo && ( '1' == $main_stick || ( 'enabled' == $sticky_header_meta && ( 'on' == $sticky_primary_header_meta || 'disabled' == $sticky_primary_header_meta ) ) ) && 'none' == $header_style ) { // Logo For None Effect. add_filter( 'astra_has_custom_logo', '__return_true' ); add_filter( 'get_custom_logo', array( $this, 'none_custom_logo' ), 10, 2 ); } if ( true === astra_addon_builder_helper()->is_header_footer_builder_active && 'none' == $header_style ) { // Logo For None Effect. add_filter( 'astra_has_custom_logo', '__return_true' ); add_filter( 'get_custom_logo', array( $this, 'none_custom_logo' ), 10, 2 ); } } /** * Method to return string 'disabled'. * * @return string Returns 'disabled' string literal. * @since 4.6.9 */ public function disabled() { return 'disabled'; } /** * Site Header -
* * @since 1.0.0 */ public function fixed_header_markup() { if ( apply_filters( 'astra_fixed_header_markup_enabled', true ) ) { $main_stick = astra_get_option( 'header-main-stick' ); $above_stick = astra_get_option( 'header-above-stick' ); $below_stick = astra_get_option( 'header-below-stick' ); $inherit_desk_logo = astra_get_option( 'different-sticky-logo', false ); $sticky_header_meta = astra_get_option_meta( 'stick-header-meta' ); $sticky_primary_header_meta = astra_get_option_meta( 'header-main-stick-meta' ); $sticky_above_header_meta = astra_get_option_meta( 'header-above-stick-meta' ); $sticky_below_header_meta = astra_get_option_meta( 'header-below-stick-meta' ); if ( ! ( ( '1' == $main_stick || ( 'enabled' == $sticky_header_meta && ( 'on' == $sticky_primary_header_meta || 'disabled' == $sticky_primary_header_meta ) ) ) || ( '1' == $above_stick || ( 'enabled' == $sticky_header_meta && ( 'on' == $sticky_above_header_meta || 'disabled' == $sticky_above_header_meta ) ) ) || ( '1' == $below_stick || ( 'enabled' == $sticky_header_meta && ( 'on' == $sticky_below_header_meta || 'disabled' == $sticky_below_header_meta ) ) ) ) ) { return; } $sticky_header_style = astra_get_option( 'sticky-header-style' ); $sticky_hide_on_scroll = astra_get_option( 'sticky-hide-on-scroll' ); if ( 'none' == $sticky_header_style && ! $sticky_hide_on_scroll ) { return; } $header_logo = astra_get_option( 'sticky-header-logo' ); if ( '1' == $inherit_desk_logo && '' != $header_logo ) { add_filter( 'astra_has_custom_logo', '__return_true' ); add_filter( 'astra_disable_site_identity', '__return_true' ); add_filter( 'astra_main_header_retina', '__return_false' ); add_filter( 'astra_replace_logo_width', '__return_false' ); add_filter( 'get_custom_logo', array( $this, 'sticky_custom_logo' ), 10, 2 ); } add_filter( 'astra_show_site_title_h1_tag', '__return_false' ); // Filters to make header & component ID unique. add_filter( 'astra_header_site_navigation_id', array( $this, 'update_navigation_id' ), 10, 1 ); add_filter( 'astra_header_menu_ul_id', array( $this, 'update_menu_ul_id' ), 10, 1 ); // Check if globally enabled or specific post/page enabled. $disable_above_markup = ! $above_stick && ! ( 'enabled' == $sticky_header_meta && ( 'on' === $sticky_above_header_meta || 'disabled' === $sticky_above_header_meta ) ); $disable_main_markup = ! $main_stick && ! ( 'enabled' == $sticky_header_meta && ( 'on' == $sticky_primary_header_meta || 'disabled' === $sticky_primary_header_meta ) ); $disable_below_markup = ! $below_stick && ! ( 'enabled' == $sticky_header_meta && ( 'on' == $sticky_below_header_meta || 'disabled' === $sticky_below_header_meta ) ); ?>
style="visibility: hidden;" data-type="fixed-header">
%2$s', esc_url( home_url( '/' ) ), wp_get_attachment_image( $custom_logo_id, $size, false, array( 'class' => 'custom-logo', ) ), astra_attr( 'site-title-none-sticky-custom-link', array( 'class' => '', ) ) ); remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'sticky_replace_header_logo_attr' ) ); $html = $html . $logo; } return $html; } /** * Filter the output of logo to fix Googles Error about itemprop logo. * * @since 1.0.0 * @param String $html HTML Markup of the logo. * @param int $blog_id ID of the blog to get the custom logo for. * * @return String Custom logo HTML output */ public function sticky_custom_logo( $html, $blog_id ) { $header_logo = astra_get_option( 'sticky-header-logo' ); if ( '' !== $header_logo ) { /* Replace sticky header logo and width */ add_filter( 'wp_get_attachment_image_attributes', array( $this, 'sticky_replace_header_logo_attr' ), 10, 3 ); $custom_logo_id = attachment_url_to_postid( $header_logo ); $size = 'ast-sticky-logo-size'; if ( is_customize_preview() ) { $size = 'full'; } $html = sprintf( '', esc_url( home_url( '/' ) ), wp_get_attachment_image( $custom_logo_id, $size, false, array( 'class' => 'custom-logo', ) ), astra_attr( 'site-title-sticky-custom-logo-link', array( 'class' => '', ) ) ); remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'sticky_replace_header_logo_attr' ) ); } return $html; } /** * Replace header logo. * * @param array $attr Image. * @param object $attachment Image obj. * @param sting $size Size name. * * @return array Image attr. */ public function sticky_replace_header_logo_attr( $attr, $attachment, $size ) { $custom_logo = astra_get_option( 'sticky-header-logo' ); $custom_logo_id = attachment_url_to_postid( $custom_logo ); if ( $custom_logo_id == $attachment->ID ) { $attach_data = array(); if ( ! is_customize_preview() ) { $attach_data = wp_get_attachment_image_src( $attachment->ID, 'ast-sticky-logo-size' ); if ( isset( $attach_data[0] ) ) { $attr['src'] = $attach_data[0]; } } $file_type = wp_check_filetype( $attr['src'] ); $file_extension = $file_type['ext']; if ( 'svg' == $file_extension ) { $attr['width'] = '100%'; $attr['height'] = '100%'; $attr['class'] = 'astra-logo-svg'; } $diff_retina_logo = astra_get_option( 'different-sticky-retina-logo' ); if ( '1' == $diff_retina_logo ) { $retina_logo = astra_get_option( 'sticky-header-retina-logo' ); $custom_logo = $attr['src']; $attr['srcset'] = ''; if ( '' !== $retina_logo ) { if ( astra_check_is_ie() ) { // Replace header logo url to retina logo url. $attr['src'] = $retina_logo; } $attr['srcset'] = $custom_logo . ' 1x, ' . $retina_logo . ' 2x'; } } } return $attr; } /** * Enqueue Admin Scripts Callback * * @param String $hook Screen name where the hook is fired. */ public function admin_enqueue_scripts( $hook ) { if ( in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) { $post_types = get_post_types( array( 'public' => true ) ); $screen = get_current_screen(); $post_type = $screen->id; if ( in_array( $post_type, (array) $post_types ) ) { /* Directory and Extension */ $file_prefix = '.min'; $dir_name = 'minified'; if ( SCRIPT_DEBUG ) { $file_prefix = ''; $dir_name = 'unminified'; } wp_enqueue_script( 'astra-ext-sticky-header-metabox', ASTRA_ADDON_EXT_STICKY_HEADER_URI . 'assets/js/' . $dir_name . '/metabox' . $file_prefix . '.js', array( 'jquery' ), ASTRA_EXT_VER, true ); } } } /** * Add Scripts Callback */ public function add_scripts() { /*** Start Path Logic */ /* Define Variables */ $uri = ASTRA_ADDON_EXT_STICKY_HEADER_URI . 'assets/js/'; $path = ASTRA_ADDON_EXT_STICKY_HEADER_DIR . 'assets/js/'; /* Directory and Extension */ $file_prefix = '.min'; $dir_name = 'minified'; if ( SCRIPT_DEBUG ) { $file_prefix = ''; $dir_name = 'unminified'; } $js_uri = $uri . $dir_name . '/'; $js_dir = $path . $dir_name . '/'; if ( defined( 'ASTRA_THEME_HTTP2' ) && ASTRA_THEME_HTTP2 ) { $gen_path = $js_uri; } else { $gen_path = $js_dir; } /*** End Path Logic */ Astra_Minify::add_dependent_js( 'jquery' ); if ( version_compare( '1.0.17', ASTRA_THEME_VERSION ) > -1 ) { Astra_Minify::add_js( $gen_path . 'sticky-header-compatibility' . $file_prefix . '.js' ); } Astra_Minify::add_js( $gen_path . 'sticky-header' . $file_prefix . '.js' ); } /** * Add Localize variables * * @param array $localize_vars Localize variables array. * @return array */ public function localize_variables( $localize_vars ) { $site_layout = ''; if ( Astra_Ext_Extension::is_active( 'site-layouts' ) ) { $site_layout = astra_get_option( 'site-layout' ); } /** * Stick Header */ $localize_vars['header_main_stick'] = astra_get_option( 'header-main-stick' ); $localize_vars['header_above_stick'] = astra_get_option( 'header-above-stick' ); $localize_vars['header_below_stick'] = astra_get_option( 'header-below-stick' ); $localize_vars['stick_header_meta'] = astra_get_option_meta( 'stick-header-meta' ); $localize_vars['header_main_stick_meta'] = astra_get_option_meta( 'header-main-stick-meta' ); $localize_vars['header_above_stick_meta'] = astra_get_option_meta( 'header-above-stick-meta' ); $localize_vars['header_below_stick_meta'] = astra_get_option_meta( 'header-below-stick-meta' ); /** * Sticky Header on Devices */ $localize_vars['sticky_header_on_devices'] = astra_get_option_meta( 'sticky-header-on-devices' ); /** * Sticky Header Style */ $localize_vars['sticky_header_style'] = astra_get_option_meta( 'sticky-header-style' ); $localize_vars['sticky_hide_on_scroll'] = astra_get_option_meta( 'sticky-hide-on-scroll' ); /** * Breakpoint */ $localize_vars['break_point'] = astra_header_break_point(); $localize_vars['tablet_break_point'] = astra_addon_get_tablet_breakpoint(); $localize_vars['mobile_break_point'] = astra_addon_get_mobile_breakpoint(); $localize_vars['header_main_shrink'] = astra_get_option( 'header-main-shrink' ); $localize_vars['header_logo_width'] = astra_get_option( 'ast-header-logo-width' ); $localize_vars['responsive_header_logo_width'] = astra_get_option( 'ast-header-responsive-logo-width' ); $localize_vars['stick_origin_position'] = apply_filters( 'astra_addon_sticky_header_stick_origin_position', false ); /** * Site Layout */ $localize_vars['site_layout'] = esc_attr( $site_layout ); $localize_vars['site_content_width'] = ( ASTRA_THEME_CONTAINER_PADDING_TWICE + astra_get_option( 'site-content-width' ) ); $localize_vars['site_layout_padded_width'] = ( astra_get_option( 'site-layout-padded-width', 1200 ) ); $localize_vars['site_layout_box_width'] = ( astra_get_option( 'site-layout-box-width', 1200 ) ); /** * Is new header builder active. */ $localize_vars['header_builder_active'] = astra_addon_builder_helper()->is_header_footer_builder_active; $localize_vars['component_limit'] = astra_addon_builder_helper()->component_limit; return $localize_vars; } /** * Add Meta Options * * @param array $meta_option Page Meta. * @return array */ public function add_options( $meta_option ) { $meta_option['stick-header-meta'] = array( 'sanitize' => 'FILTER_SANITIZE_STRING', 'default' => astra_get_option_meta( 'stick-header-meta' ), ); $meta_option['header-main-stick-meta'] = array( 'sanitize' => 'FILTER_SANITIZE_STRING', 'default' => astra_get_option_meta( 'header-main-stick-meta' ), ); if ( Astra_Ext_Extension::is_active( 'header-sections' ) ) { $meta_option['header-above-stick-meta'] = array( 'sanitize' => 'FILTER_SANITIZE_STRING', 'default' => astra_get_option_meta( 'header-above-stick-meta' ), ); $meta_option['header-below-stick-meta'] = array( 'sanitize' => 'FILTER_SANITIZE_STRING', 'default' => astra_get_option_meta( 'header-below-stick-meta' ), ); } return $meta_option; } /** * Sticky Header Meta Field markup * * Loads appropriate template file based on the style option selected in options panel. * * @param array $meta Page Meta. * @since 1.0.0 */ public function add_options_markup( $meta ) { /** * Get options */ $sticky_main = ( isset( $meta['header-main-stick-meta']['default'] ) ) ? $meta['header-main-stick-meta']['default'] : 'on'; $stick_header_meta = ( isset( $meta['stick-header-meta']['default'] ) ) ? $meta['stick-header-meta']['default'] : 'default'; $show_meta_field = ! astra_check_is_bb_themer_layout(); if ( Astra_Ext_Extension::is_active( 'header-sections' ) ) { $sticky_top = ( isset( $meta['header-above-stick-meta']['default'] ) ) ? $meta['header-above-stick-meta']['default'] : 'on'; $sticky_below = ( isset( $meta['header-below-stick-meta']['default'] ) ) ? $meta['header-below-stick-meta']['default'] : 'on'; } ?>


/>

/>

/>

(int) $max_value, 'height' => 0, 'crop' => false, ); } return $sizes; } } } /** * Kicking this off by calling 'get_instance()' method */ Astra_Ext_Sticky_Header_Markup::get_instance();