Last active
August 29, 2015 14:26
-
-
Save devinsays/f0ed4a4d52b5f5a72e7b to your computer and use it in GitHub Desktop.
Customize control to output arbitrary content or HTML.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$wp_customize->add_setting( 'example-control', array() ); | |
$wp_customize->add_control( new Prefix_Custom_Content( $wp_customize, 'example-control', array( | |
'section' => 'title_tagline', | |
'priority' => 20, | |
'label' => __( 'Example Control', 'govpress' ), | |
'content' => __( 'Content to output. Use <a href="#">HTML</a> if you like.', 'textdomain' ) . '</p>', | |
'description' => __( 'Optional: Example Description.', 'textdomain' ), | |
) ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Prefix_Custom_Content' ) ) : | |
class Prefix_Custom_Content extends WP_Customize_Control { | |
// Whitelist content parameter | |
public $content = ''; | |
/** | |
* Render the control's content. | |
* | |
* Allows the content to be overriden without having to rewrite the wrapper. | |
* | |
* @since 1.0.0 | |
* @return void | |
*/ | |
public function render_content() { | |
if ( isset( $this->label ) ) { | |
echo '<span class="customize-control-title">' . $this->label . '</span>'; | |
} | |
if ( isset( $this->content ) ) { | |
echo $this->content; | |
} | |
if ( isset( $this->description ) ) { | |
echo '<span class="description customize-control-description">' . $this->description . '</span>'; | |
} | |
} | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment