Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Varia: Include Jetpack Content Options #7518

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 11 additions & 42 deletions varia/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,17 @@ function 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' );
Expand Down Expand Up @@ -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.
*/
Expand Down
4 changes: 1 addition & 3 deletions varia/template-parts/content/content-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading