Of course. I also include the action/function to add theme support for custom headers in this file, but I’ve not duplicated it as it is posted in my original question.
Thanks.
/**
* Add the JS for the live preview
*/
add_action('customize_preview_init', 'customiser_live_preview');
function customiser_live_preview(){
wp_enqueue_script('theme-customiser', get_template_directory_uri().'/admin/js/customise.js', array( 'jquery','customize-preview' ), '', true);
}
/**
* Add custom controls to the theme customiser
*/
add_action('customize_register', 'register_costomisation_controls');
function register_costomisation_controls($wp_customize){
$wp_customize->add_section('footer_section' , array(
'title' => __('Footer', 'dd_theme'),
'priority' => 1010
));
$wp_customize->add_setting('footer_background_colour' ,array(
'default' => '#CFCFCF',
'transport' => 'postMessage'
));
$wp_customize->add_setting('footer_text' ,array(
'default' => '',
'transport' => 'refresh'
));
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'footer_background_colour',
array(
'label' => __('Background Colour', 'dd_theme'),
'section' => 'footer_section',
'settings' => 'footer_background_colour'
)
)
);
$wp_customize->add_control(
new Customize_Textarea_Control(
$wp_customize,
'footer_text',
array(
'label' => __('Text', 'dd_theme'),
'section' => 'footer_section',
'settings' => 'footer_text'
)
)
);
}
/**
* Output the relevant styles for customised settings in the header
*/
add_action('wp_head', 'output_costomisation_css');
function output_costomisation_css(){
?>
<style type="text/css">
#footer-full-width{
background-color: <?php echo get_theme_mod('footer_background_colour'); ?>;
}
</style>
<?php
}
/**
* Custom control class for including a textarea in the theme customiser
*/
if(class_exists('WP_Customize_Control')){
class Customize_Textarea_Control extends WP_Customize_Control{
public $type = 'textarea';
public function render_content(){
?>
<label>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<textarea rows="5" style="width:100%;" <?php $this->link(); ?>><?php echo esc_textarea( $this->value() ); ?></textarea>
</label>
<?php
}
}
}