Skip to content

Commit 4c41358

Browse files
authored
Change sticky toggles (#549)
* changed sticky header toggles. * removed error_log
1 parent 8a5da16 commit 4c41358

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

src/assets/js/customizer/edit.js

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ const { __ } = wp.i18n;
129129
$( '#masthead-sticky' ).css( 'display', 'none' );
130130
} else if ( api( 'bgtfw_fixed_header' ) && api( 'bgtfw_fixed_header' )() ) {
131131
$( '#masthead-sticky' ).css( 'display', 'block' );
132+
} else if ( $( '#masthead-sticky' ).is('[class*="sticky-template"]' ) ) {
133+
$( '#masthead-sticky' ).css( 'display', 'block' );
132134
}
133135
} );
134136
},

src/includes/class-boldgrid-framework-api.php

+23-7
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ public function body_classes( $classes ) {
554554

555555
$classes[] = 'custom-header';
556556

557-
if ( get_theme_mod( 'bgtfw_fixed_header' ) ) {
557+
if ( get_theme_mod( 'bgtfw_fixed_header' ) || apply_filters( 'crio_premium_get_sticky_page_header', $post_id ) ) {
558558
if ( 'header-top' === get_theme_mod( 'bgtfw_header_layout_position' ) ) {
559559
$classes[] = 'header-slide-in';
560560
} else {
@@ -1363,12 +1363,6 @@ public static function dynamic_header() {
13631363
* @return string Rendered HTML for dyanmic layout element.
13641364
*/
13651365
public static function dynamic_sticky_header( $preset = null ) {
1366-
$markup = '';
1367-
$markup .= '<header id="masthead-sticky" ' . BoldGrid::add_class( 'header', [ 'header', 'sticky' ], false ) . '>';
1368-
ob_start();
1369-
do_action( 'boldgrid_header_top' );
1370-
$markup .= ob_get_clean();
1371-
13721366
if ( ! is_front_page() && is_home() ) {
13731367
$id = get_option( 'page_for_posts' );
13741368
} else {
@@ -1377,8 +1371,30 @@ public static function dynamic_sticky_header( $preset = null ) {
13771371

13781372
$page_header = apply_filters( 'crio_premium_get_sticky_page_header', $id );
13791373

1374+
$sticky_template_class = get_theme_mod( 'bgtfw_sticky_page_headers_global_enabled' ) && ! empty( $page_header ) ? 'sticky-template-' . $page_header : '';
1375+
1376+
$header_classes = array(
1377+
'header',
1378+
'sticky',
1379+
);
1380+
1381+
if ( ! empty( $sticky_template_class ) ) {
1382+
$header_classes[] = $sticky_template_class;
1383+
}
1384+
1385+
$markup = '';
1386+
$markup .= '<header id="masthead-sticky" ' . BoldGrid::add_class( 'header', $header_classes, false ) . '>';
1387+
ob_start();
1388+
do_action( 'boldgrid_header_top' );
1389+
$markup .= ob_get_clean();
1390+
13801391
if ( get_theme_mod( 'bgtfw_sticky_page_headers_global_enabled' ) && ! empty( $page_header ) ) {
13811392
if ( 'disabled' !== $page_header ) {
1393+
error_log(
1394+
'page_header: ' . json_encode(
1395+
apply_filters( 'the_content', get_post_field( 'post_content', $page_header ) )
1396+
)
1397+
);
13821398
$markup .= apply_filters( 'the_content', get_post_field( 'post_content', $page_header ) );
13831399
}
13841400
} else {

src/includes/class-boldgrid-framework.php

+27-4
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,15 @@ private function define_theme_hooks() {
452452
$this->loader->add_filter( 'boldgrid_site_identity', $boldgrid_theme, 'print_title_tagline' );
453453

454454
// Sticky Header - Removed template_redirect as it was unnecessary and caused duplication of the sticky header sometimes.
455-
if ( is_customize_preview() || ( true === get_theme_mod( 'bgtfw_fixed_header' ) ) || ( true === get_theme_mod( 'bgtfw_fixed_header' ) && 'header-top' === get_theme_mod( 'bgtfw_header_layout_position', 'header-top' ) ) ) {
456-
add_action( 'boldgrid_header_after', function() {
455+
add_action( 'boldgrid_header_after', function( $id ) {
456+
if ( $this->maybe_show_sticky_header( $id ) ) {
457457
?>
458458
<div <?php BoldGrid::add_class( 'sticky_header', [ 'bgtfw-sticky-header', 'site-header' ] ); ?>>
459459
<?php echo BoldGrid::dynamic_sticky_header(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
460460
</div>
461461
<?php
462-
}, 20 );
463-
}
462+
}
463+
}, 20 );
464464

465465
// Password protected post/page form.
466466
$this->loader->add_filter( 'the_password_form', $boldgrid_theme, 'password_form' );
@@ -472,6 +472,29 @@ private function define_theme_hooks() {
472472
$this->custom_header();
473473
}
474474

475+
/**
476+
* Maybe Show Sticky Header
477+
*
478+
* @since SINCEVERSION
479+
*/
480+
public function maybe_show_sticky_header( $id ) {
481+
if ( is_customize_preview() || true === get_theme_mod( 'bgtfw_fixed_header' ) ) {
482+
return true;
483+
}
484+
485+
if ( true === get_theme_mod( 'bgtfw_fixed_header' ) && 'header-top' === get_theme_mod( 'bgtfw_header_layout_position', 'header-top' ) ) {
486+
return true;
487+
}
488+
489+
$sticky_header_template = apply_filters( 'crio_premium_get_sticky_page_header', $id );
490+
491+
if ( ! empty( $sticky_header_template ) ) {
492+
return true;
493+
}
494+
495+
return false;
496+
}
497+
475498
/**
476499
* This contains hooks for our theme's custom header implementation.
477500
*

0 commit comments

Comments
 (0)