Currently I'm developing WordPress Theme.Within my theme I'm using Customizer API.I added some controls,setting,sections It works.
Also, I created new PHP file called class-customizer-control.php
.Inside this file I'll put all custom controls, so I created one custom control (textarea):
<?php
include_once ABSPATH . 'wp-includes/class-wp-customize-control.php';
/**
* Add Custom controls to Customizer API
*/
function bedakb_gamer_customcontrols() {
class Custom_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
}
}
}
add_action('customize_register', 'bedakb_gamer_customcontrols');
?>
Next, I added control, inside customization file, that using Textarea custom control:
$wp_customize->add_control( new Custom_Textarea_Control($wp_customize, 'bedakb_ad728', array(
'label' => __('Adsense 728x90', 'bedakb_gamer'),
'section' => 'bedakb_adsense',
'priority' => 10,
)));
But when I try to open Customization in Wp-admin, I got error:
Fatal error: Class 'Custom_Textarea_Control' not found in C:\xampp\htdocs\wp2\wp-content\themes\bedakb_gamer\inc\customizer.php on line 35
wp-includes
? You should includeclass-customizer-control.php
from your theme'sfunctions.php
.