Skip to content

Instantly share code, notes, and snippets.

@2ndkauboy

2ndkauboy/footer.php Secret

Created Dec 13, 2016
Embed
What would you like to do?
TwentyFifteen with a footer text customizer control including an edit shortcode.
<?php
/**
* Enqueue the parent style
*/
function twentyfifteen_parent_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'twentyfifteen_parent_enqueue_styles' );
/**
* Adds an control to set a custom footer text.
*
* @param WP_Customize_Manager $wp_customize The customizer manager.
*/
function twentyfifteen_footer_setting_custom_footer( $wp_customize ) {
$wp_customize->add_setting( 'custom_footer_text', array(
'type' => 'theme_mod',
) );
$wp_customize->add_control( 'custom_footer_text', array(
'label' => __( 'Custom footer text', 'twentyfifteen-footer' ),
'type' => 'textarea',
'section' => 'custom_footer',
) );
$wp_customize->add_section( 'custom_footer', array(
'title' => __( 'Custom footer text', 'twentyfifteen-footer' ),
'description' => __( 'Set the footer text here', 'twentyfifteen-footer' ),
'priority' => 160,
'capability' => 'edit_theme_options',
) );
$wp_customize->get_setting( 'custom_footer_text' )->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial( 'custom_footer_text', array(
'selector' => '.site-info .footer-text',
'render_callback' => 'twentyfifteen_footer_partial_custom_footer_text',
) );
}
add_action( 'customize_register', 'twentyfifteen_footer_setting_custom_footer' );
/**
* Callback function fot the selective refresh
*/
function twentyfifteen_footer_partial_custom_footer_text() {
echo get_theme_mod( 'custom_footer_text' );
}
/**
Theme Name: TwentyFifteen Footer Text
Template: twentyfifteen
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.