Skip to content

Instantly share code, notes, and snippets.

@2ndkauboy
Created December 13, 2016 00:50
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 2ndkauboy/de00ee10bd7950d48f94b2e3d5c6880f to your computer and use it in GitHub Desktop.
Save 2ndkauboy/de00ee10bd7950d48f94b2e3d5c6880f to your computer and use it in GitHub Desktop.
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