add_section( 'baw_content_section' , array( 'title' => __( 'Content', 'baw' ), 'priority' => 1, ) ); $wp_customize->add_setting( 'content_max_width', array ( 'default' => 0, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'content_max_width', array( 'type' => 'range', 'section' => 'baw_content_section', 'label' => __( 'Content max width', 'baw' ), 'input_attrs' => array( 'min' => 0, 'max' => 2000, 'step' => 100, ), ) ); $wp_customize->add_setting( 'content_padding', array ( 'default' => 0, 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'content_padding', array( 'type' => 'range', 'section' => 'baw_content_section', 'label' => __( 'Content Padding', 'baw' ), 'input_attrs' => array( 'min' => 0, 'max' => 200, 'step' => 1, ), ) ); $wp_customize->add_setting( 'hide_home_content', array ( 'default' => '', 'sanitize_callback' => 'baw_sanitize_checkbox', ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'hide_home_content', array( 'label' => __( 'Hide sidebar and content on home page', 'baw' ), 'section' => 'baw_content_section', 'type' => 'checkbox', ) ) ); } add_action( 'customize_register', 'baw_customize_register_content' ); /******************************************** * Content Styles *********************************************/ function baw_content_styles () { $content_max_width = get_theme_mod( 'content_max_width' ); $hide_home_content = get_theme_mod( 'hide_home_content' ); $content_padding = get_theme_mod( 'content_padding' ); if($content_max_width) { $content_max_width_style = "#content,.h-center {max-width: {$content_max_width}px !important;}";} else {$content_max_width_style ="";} if($hide_home_content and (is_home() or is_front_page())) { $hide_home_content_style = "#content #primary, body #content #secondary {display: none !important;}";} else {$hide_home_content_style ="";} if($content_padding) { $content_padding_style = "#content,.h-center {padding: {$content_padding}px !important;}";} else {$content_padding_style ="";} wp_add_inline_style( 'black-and-white-style', $content_max_width_style.$hide_home_content_style.$content_padding_style ); } add_action( 'wp_enqueue_scripts', 'baw_content_styles' );