add_section( 'bromine_layout_section', array( 'title' => __( 'Bromine Layout', 'bromine' ), 'capability' => 'edit_theme_options', 'description' => __( 'Choose your theme\'s layout.', 'bromine' ) ) ); $wp_customize->add_section( 'bromine_copyright_section', array( 'title' => __( 'Bromine Copyright', 'bromine' ), 'capability' => 'edit_theme_options', 'description' => __( 'Actually, the copyright is shown as Copyright © "Date" - "Your blog name". You can change "Date" - "Your blog name" here and remove the theme dev (me) text: Theme Bromine notice.', 'bromine' ), ) ); /** * Add our settings * @link http://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_setting */ // Layout setting $wp_customize->add_setting( 'bromine_layout[layout_setting]', array( 'default' => 'right-sidebar', 'type' => 'option', 'sanitize_callback' => 'bromine_sanitize_radio_layout' ) ); // Header menu text color setting $wp_customize->add_setting( 'bromine_header_menu_color', array( 'default' => '#5bcad3', 'sanitize_callback' => 'sanitize_hex_color' ) ); // Header background color setting $wp_customize->add_setting( 'bromine_header_bg_color', array( 'default' => '#363141', 'sanitize_callback' => 'sanitize_hex_color' ) ); // Copyright owner text $wp_customize->add_setting( 'bromine_copyright_owner', array( 'default' => '', 'sanitize_callback' => 'bromine_sanitize_text' ) ); // Remove the "Theme Bromine by Manoz" in the footer? $wp_customize->add_setting( 'bromine_theme_dev', array( 'default' => 'no', 'sanitize_callback' => 'bromine_sanitize_radio_copyright' ) ); /** * Add our controls * @link http://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_control */ // Layout control $wp_customize->add_control( 'layout_control', array( 'type' => 'radio', 'label' => __( 'Theme layout', 'bromine' ), 'section' => 'bromine_layout_section', 'choices' => array( 'left-sidebar' => __( 'Left sidebar', 'bromine' ), 'right-sidebar' => __( 'Right sidebar', 'bromine' ) ), 'settings' => 'bromine_layout[layout_setting]' ) ); // Header menu color control $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_menu_color_control', array( 'label' => __( 'Header menu color', 'bromine' ), 'section' => 'colors', 'settings' => 'bromine_header_menu_color' ) ) ); // Header background color control $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_bg_color_control', array( 'label' => __( 'Header background color', 'bromine' ), 'section' => 'colors', 'settings' => 'bromine_header_bg_color' ) ) ); // Copyright owner control $wp_customize->add_control( 'copyright_owner_control', array( 'label' => __( 'Copyright owner', 'bromine' ), 'section' => 'bromine_copyright_section', 'settings' => 'bromine_copyright_owner', 'type' => 'text', ) ); // Theme dev control $wp_customize->add_control( 'theme_dev_control', array( 'type' => 'radio', 'label' => __( 'Remove the "Theme Bromine" notice in the footer?', 'bromine' ), 'section' => 'bromine_copyright_section', 'choices' => array( 'no' => __( 'Nope :)', 'bromine' ), 'yes' => __( 'Yep :(', 'bromine' ) ), 'settings' => 'bromine_theme_dev' ) ); } /** * Add a CSS class to the body tag depending * on which layout is chosen in the customizer. * @link https://codex.wordpress.org/Function_Reference/body_class#Add_Classes_By_Filters */ add_filter( 'body_class', 'bromine_body_classes' ); function bromine_body_classes( $classes ) { $bromine_layout = get_option( 'bromine_layout' ); $classes[] = $bromine_layout['layout_setting']; return $classes; } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ add_action( 'customize_preview_init', 'bromine_customize_preview_js' ); function bromine_customize_preview_js() { wp_enqueue_script( 'bro_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '0.0.1', true ); } /** * Sanitize some fields */ function bromine_sanitize_text( $input ) { return wp_kses_post( force_balance_tags( $input ) ); } function bromine_sanitize_radio_layout( $input ) { $valid = array( 'left-sidebar' => __( 'Left sidebar', 'bromine' ), 'right-sidebar' => __( 'Right sidebar', 'bromine' ) ); if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } } function bromine_sanitize_radio_copyright( $input ) { $valid = array( 'no' => __( 'Nope :)', 'bromine' ), 'yes' => __( 'Yep :(', 'bromine' ) ); if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } }