Skip to content

Instantly share code, notes, and snippets.

@jaseinatl
Created February 22, 2019 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaseinatl/97043c20e76f916894cbd18aa7312c5d to your computer and use it in GitHub Desktop.
Save jaseinatl/97043c20e76f916894cbd18aa7312c5d to your computer and use it in GitHub Desktop.
Unable to get new Section or Controls in Customizer.
<?php
/**
* WhirledLaw Theme Customizer
*
* @package WhirledLaw
*/
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
/**
* Create Logo Setting and Upload Control
*/
function whirledlaw_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';
/*I just added this to make sure that I was actually modifying the customizer, which it is.
I understand that this is already handled by the add_theme_support method, it is just a test
and it works, so I'm getting this far.
*/
$wp_customize->add_setting('site_logo');
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'site_logo',
array(
'label' => 'Upload MF Logo',
'section' => 'title_tagline',
'settings' => 'site_logo',
) ) );
// Add Footer Section -- NOT WORKING
$wp_customize->add_section('site_footer', array(
'title' => 'Site Footer',
'description' => 'Select content to appear in the footer fixed to the bottom of the window',
'priority' => 120,
));
/*the next controls originally were set to section=>site_footer. But I changed them to see if they would work
with the built-in sections "title_tagline". No luck. I even moved the add_section part to the end in case it was erroring out
still didn't help.
*/
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_left_label',
array(
'label' => __( 'Left Label', 'whirledlaw' ),
'section' => 'title_tagline',
'settings' => 'footer_left_label',
'type' => 'text',
)
)
);
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_left',
array(
'label' => __( 'Left Content', 'whirledlaw' ),
'section' => 'title_tagline',
'settings' => 'footer_left_content',
'type' => 'dropdown-pages',
)
)
);
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_mid',
array(
'label' => __( 'Center Content', 'whirledlaw' ),
'section' => 'title_tagline',
'settings' => 'footer_mid_content',
'type' => 'dropdown-pages',
)
)
);
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_left_label',
array(
'label' => __( 'Center Label', 'whirledlaw' ),
'section' => 'title_tagline',
'settings' => 'footer_left_label',
'type' => 'text',
)
)
);
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_mid',
array(
'label' => __( 'Right Content', 'whirledlaw' ),
'section' => 'title_tagline',
'settings' => 'footer_right_content',
'type' => 'dropdown-pages',
)
)
);
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'footer_left_label',
array(
'label' => __( 'Right Label', 'whirledlaw' ),
'section' => 'title_tagline',
'settings' => 'footer_left_label',
'type' => 'text',
)
)
);
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'render_callback' => 'whirledlaw_customize_partial_blogname',
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => 'whirledlaw_customize_partial_blogdescription',
) );
}
}
add_action( 'customize_register', 'whirledlaw_customize_register' );
/**
* Render the site title for the selective refresh partial.
*
* @return void
*/
function whirledlaw_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @return void
*/
function whirledlaw_customize_partial_blogdescription() {
bloginfo( 'description' );
}
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function whirledlaw_customize_preview_js() {
wp_enqueue_script( 'whirledlaw-customizer', get_template_directory_uri() . '/inc/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'whirledlaw_customize_preview_js' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment