customizer help
-
I’m trying to learn how to add stuff to the customizer. I’ve added a piece of code to the below customizer.php. My added code is between the comments:
/* my custom stuff */ ... ... ... /* end of my custom stuff */
I’ve added a panel, section, setting and control. Just to see it appear in the dashboard and take it from there. Nothing new appears in the Customizer screen in the admin panel of the theme (apart from the customizer addition, it’s a fresh underscores theme installation.
<?php /** * netspace Theme Customizer * * @package netspace */ /** * Add postMessage support for site title and description for the Theme Customizer. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. */ function netspace_customize_register( $wp_customize ) { $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; /* my custom stuff */ $wp_customize->add_panel( 'custom_panel', array( 'priority' => 10, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __( 'Custom Panel', 'netspace'), 'description' => '', ) ); $wp_customize->add_section( 'custom_section', array( 'priority' => 10, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Custom Section', 'netspace'), 'description' => '', 'panel' => 'custom_panel', ) ); $wp_customize->add_setting( 'custom_text_id', array( 'default' => '', 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'transport' => '', 'sanitize_callback' => 'esc_textarea', ) ); $wp_customize->add_control( 'textarea_text_id', array( 'type' => 'textarea', 'priority' => 10, 'section' => 'custom_section', 'label' => __( 'Textarea Field', 'textdomain' ), 'description' => '', ) ); /* end of my custom stuff */ if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'netspace_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'netspace_customize_partial_blogdescription', ) ); } } add_action( 'customize_register', 'netspace_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function netspace_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function netspace_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function netspace_customize_preview_js() { wp_enqueue_script( 'netspace-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'netspace_customize_preview_js' );
What have I missed? Thank you.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘customizer help’ is closed to new replies.