php - Fatal error: Class 'WP_Customize_Control' not found - WordPress -
im building own wordperss theme , when starting on wordpress customizer theme options have come in little bit of trouble.
basically im trying create textarea , have read need create extended class , call under add_control function of wordpress.
i have tried , works in customizer mode enter other part of site error:
fatal error: class 'wp_customize_control' not found
as works 100% within customizer it's self other page including admin message.
here class:
class ublxlportfolio_textarea 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 } }
do need wrap in conditional tag? if be??
am doing wrong?
to clarify @robert's correct answer:
class wp_customize_control loaded when theme customizer acutally used. so, need define class within function bind 'customize_register' action.
example:
add_action( 'customize_register', 'my_customize_register' ); function my_customize_register($wp_customize) { //class definition must within my_customie_register function class ublxlportfolio_textarea extends wp_customize_control { ... } //other stuff }
Comments
Post a Comment