Varia: Include Jetpack Content Options (#7518)

* Varia: Fix Jetpack Content Options

* Ensure options take effect
This commit is contained in:
Aurorum 2023-12-05 13:09:18 +00:00 committed by GitHub
parent 012258cc65
commit 448a2ecbaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 45 deletions

View file

@ -225,7 +225,17 @@ if ( ! function_exists( 'varia_setup' ) ) :
'enable_theme_default' => true,
)
);
// Add support for Content Options.
add_theme_support( 'jetpack-content-options', array(
'blog-display' => 'content',
'featured-images' => array(
'archive' => true,
'archive-default' => true,
'post' => true,
'page' => true,
),
) );
}
endif;
add_action( 'after_setup_theme', 'varia_setup' );
@ -479,47 +489,6 @@ function varia_customize_header_footer( $wp_customize ) {
}
add_action( 'customize_register', 'varia_customize_header_footer' );
/**
* Add ability to show or hide featured images on pages
*/
function varia_customize_content_options( $wp_customize ) {
// Add Content section.
$wp_customize->add_section(
'jetpack_content_options',
array(
'title' => esc_html__( 'Content Options', 'varia' ),
'priority' => 100,
)
);
// Add visibility setting for featured images on pages
$wp_customize->add_setting(
'show_featured_image_on_pages',
array(
'default' => false,
'type' => 'theme_mod',
'transport' => 'refresh',
'sanitize_callback' => 'varia_sanitize_checkbox',
)
);
// Add control for the visibility of featured images on pages
$wp_customize->add_control(
'show_featured_image_on_pages',
array(
'label' => esc_html__( 'Show the featured image on pages', 'varia' ),
'description' => esc_html__( 'Check to display a featured image at the top of your pages when they have one.', 'varia' ),
'section' => 'jetpack_content_options',
'priority' => 10,
'type' => 'checkbox',
'settings' => 'show_featured_image_on_pages',
)
);
}
add_action( 'customize_register', 'varia_customize_content_options' );
/**
* SVG Icons class.
*/

View file

@ -17,9 +17,7 @@
<?php get_template_part( 'template-parts/header/entry', 'header' ); ?>
</header>
<?php if ( true === get_theme_mod( 'show_featured_image_on_pages', false ) ) : ?>
<?php varia_post_thumbnail(); ?>
<?php endif; ?>
<?php varia_post_thumbnail(); ?>
<div class="entry-content">
<?php