123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- /**
- * Blank Canvas Theme: Customizer
- *
- * @package Blank Canvas
- * @since 1.0.0
- */
- if ( ! class_exists( 'Blank_Canvas_Customize' ) ) {
- /**
- * Customizer Settings.
- *
- * @since 1.0.0
- */
- class Blank_Canvas_Customize {
- /**
- * Constructor. Instantiate the object.
- *
- * @access public
- *
- * @since 1.0.0
- */
- public function __construct() {
- add_action( 'customize_register', array( $this, 'register' ) );
- add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_disabled_header_custom_logo_notification_script') );
- }
- /**
- * Register customizer options.
- *
- * @access public
- *
- * @since 1.0.0
- *
- * @param WP_Customize_Manager $wp_customize Theme Customizer object.
- *
- * @return void
- */
- public function register( $wp_customize ) {
- // Add Content section.
- $wp_customize->add_section(
- 'jetpack_content_options',
- array(
- 'title' => esc_html__( 'Content Options', 'blank-canvas' ),
- 'priority' => 100,
- )
- );
- // Add setting to show the site header.
- $wp_customize->add_setting(
- 'show_site_header',
- array(
- 'default' => false,
- 'type' => 'theme_mod',
- 'transport' => 'refresh',
- 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
- )
- );
- // Add control to show the site header.
- $wp_customize->add_control(
- 'show_site_header',
- array(
- 'label' => esc_html__( 'Enable site header and top menu', 'blank-canvas' ),
- 'description' => esc_html__( 'Check to show a standard site header, navigation menu and social links menu on the top of every page. These can be configured in the "Site Identity" and "Menus" panels.', 'blank-canvas' ),
- 'section' => 'jetpack_content_options',
- 'priority' => 10,
- 'type' => 'checkbox',
- 'settings' => 'show_site_header',
- )
- );
- // Add setting to show the site footer.
- $wp_customize->add_setting(
- 'show_site_footer',
- array(
- 'default' => false,
- 'type' => 'theme_mod',
- 'transport' => 'refresh',
- 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
- )
- );
- // Add control to show the site footer.
- $wp_customize->add_control(
- 'show_site_footer',
- array(
- 'label' => esc_html__( 'Enable widgets and footer menu', 'blank-canvas' ),
- 'description' => esc_html__( "Check to show a navigation menu and widgets in your site's footer area.", 'blank-canvas' ),
- 'section' => 'jetpack_content_options',
- 'priority' => 10,
- 'type' => 'checkbox',
- 'settings' => 'show_site_footer',
- )
- );
- // Add setting to show post and page titles.
- $wp_customize->add_setting(
- 'show_post_and_page_titles',
- array(
- 'default' => false,
- 'type' => 'theme_mod',
- 'transport' => 'refresh',
- 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
- )
- );
- // Add control to show post and page titles.
- $wp_customize->add_control(
- 'show_post_and_page_titles',
- array(
- 'label' => esc_html__( 'Show post and page titles', 'blank-canvas' ),
- 'description' => esc_html__( 'Check to show titles at the top of single posts and pages.', 'blank-canvas' ),
- 'section' => 'jetpack_content_options',
- 'priority' => 10,
- 'type' => 'checkbox',
- 'settings' => 'show_post_and_page_titles',
- )
- );
-
- // Add setting to show the comments
- $wp_customize->add_setting(
- 'show_comments',
- array(
- 'default' => false,
- 'type' => 'theme_mod',
- 'transport' => 'refresh',
- 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
- )
- );
- // Add control to show the comments.
- $wp_customize->add_control(
- 'show_comments',
- array(
- 'label' => esc_html__( 'Make comments visible', 'blank-canvas' ),
- 'description' => esc_html__( 'Check to show comments underneath posts and pages. Comments can be configured in your site’s Discussion settings screen.', 'blank-canvas' ),
- 'section' => 'jetpack_content_options',
- 'priority' => 10,
- 'type' => 'checkbox',
- 'settings' => 'show_comments',
- )
- );
- }
-
- /**
- * Displays a notification above the custom logo control when you have set a logo,
- * but it's not visible since the site header is disabled.
- *
- * @access public
- *
- * @return void
- */
- public function enqueue_disabled_header_custom_logo_notification_script() {
- $handle = 'disabled-site-header-custom-logo-notification';
- $src = get_stylesheet_directory_uri() . '/assets/js/disabled-site-header-custom-logo-notification.js';
- $deps = array( 'customize-controls' );
- wp_enqueue_script( $handle, $src, $deps );
- wp_localize_script(
- $handle,
- 'disabled_site_header_custom_logo_notification_translations',
- array(
- 'custom_logo_notification_content' => __( 'Your logo will not be shown on all posts and pages. To display your logo, follow the instructions above to enable your site header.', 'blank-canvas'),
- )
- );
- }
- /**
- * Sanitize boolean for checkbox.
- *
- * @access public
- *
- * @since 1.0.0
- *
- * @param bool $checked Whether or not a box is checked.
- *
- * @return bool
- */
- public static function sanitize_checkbox( $checked = null ) {
- return (bool) isset( $checked ) && true === $checked;
- }
- }
- new Blank_Canvas_Customize();
- }
|