diff --git a/includes/block-functions.php b/includes/block-functions.php index 5f694ab..37b6f7e 100644 --- a/includes/block-functions.php +++ b/includes/block-functions.php @@ -635,12 +635,14 @@ function tumblr3_block_haspages( $atts, $content = '' ): string { * @return string */ function tumblr3_block_showheaderimage( $atts, $content = '' ): string { - return ( 'remove-header' !== get_theme_mod( 'header_image', 'remove-header' ) ) ? tumblr3_do_shortcode( $content ) : ''; + return ( get_theme_mod( 'show_header_image', true ) && + 'remove-header' !== get_theme_mod( 'header_image', 'remove-header' ) ) + ? tumblr3_do_shortcode( $content ) : ''; } add_shortcode( 'block_showheaderimage', 'tumblr3_block_showheaderimage' ); /** - * Rendered if you have "Show header image" disabled. + * Rendered if you have "Show header image" disabled. * * @param array $atts The attributes of the shortcode. * @param string $content The content of the shortcode. @@ -648,7 +650,9 @@ function tumblr3_block_showheaderimage( $atts, $content = '' ): string { * @return string */ function tumblr3_block_hideheaderimage( $atts, $content = '' ): string { - return ( 'remove-header' === get_theme_mod( 'header_image', 'remove-header' ) ) ? tumblr3_do_shortcode( $content ) : ''; + return ( ! get_theme_mod( 'show_header_image', true ) || + 'remove-header' === get_theme_mod( 'header_image', 'remove-header' ) ) + ? tumblr3_do_shortcode( $content ) : ''; } add_shortcode( 'block_hideheaderimage', 'tumblr3_block_hideheaderimage' ); diff --git a/src/Customizer.php b/src/Customizer.php index 3bb1c24..e7746e0 100644 --- a/src/Customizer.php +++ b/src/Customizer.php @@ -228,6 +228,25 @@ public function global_options( $wp_customize ): void { ) ); + // Add a show header image checkbox control. + $wp_customize->add_setting( + 'show_header_image', + array( + 'default' => 'yes', + 'sanitize_callback' => 'sanitize_text_field', + ) + ); + + $wp_customize->add_control( + 'show_header_image', + array( + 'label' => __( 'Show Header Image', 'tumblr3' ), + 'section' => 'tumblr3_boolean', + 'type' => 'checkbox', + 'priority' => 10, + ) + ); + // Add a stretch header image checkbox control. $wp_customize->add_setting( 'stretch_header_image',