i have create come script for Add Wp-Editer
it’s working fine in other place but not working in Widget
and Page Builder by SiteOrigin please help me…
look like this
My script as bellow.
<?php
// Register widget
function register_getstarted_widget() {
register_widget('mansukh_Aboutus');
}
add_action('widgets_init', 'register_getstarted_widget');
/**
* Adds About Us widget.
*/
class mansukh_Aboutus extends WP_Widget {
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
'mansukh_aboutus', // Base ID
__('Fulgent About Us', 'mansukh'), // Name
array('description' => __('Displays a About Us section.', 'mansukh'),) // Args
);
}
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget($args, $instance) {
echo $args['before_widget'];
/* if (!empty($instance['title'])) {
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
} */
/* Home About Us */
$mansukh_home_title = !empty($instance['mansukh_home_title']) ? sanitize_text_field($instance['mansukh_home_title']) : '';
$mansukh_home_aboutus = !empty($instance['mansukh_home_aboutus']) ? wpautop($instance['mansukh_home_aboutus']) : '';
?>
<div class="section-row about-secton">
<div class="container">
<div class="row">
<div class="col-md-12 main-objective">
<div class="row">
<div class="<?php echo $mansukh_home_aboutus ? 'col-md-6' : 'col-md-12' ?> col-sm-12">
<?php echo $mansukh_home_aboutus; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
echo $args['after_widget'];
}
/**
* Back-end widget form.
*
* @see WP_Widget::form()
*
* @param array $instance Previously saved values from database.
*/
public function form($instance) {
#$title = !empty($instance['title']) ? $instance['title'] : __('New title', 'mansukh');
/* Home About Us */
$mansukh_home_title = !empty($instance['mansukh_home_title']) ? sanitize_text_field($instance['mansukh_home_title']) : '';
$mansukh_home_aboutus = !empty($instance['mansukh_home_aboutus']) ? wpautop($instance['mansukh_home_aboutus']) : '';
/*
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>">
</p>
*/
?>
<div class="page-widget themeoption-themes1">
<div class="section theme-tabs">
<div class="theme-option-inner-tab-group">
<div class="ft-control">
<label class="explain" for="<?php echo $this->get_field_id('mansukh_home_title'); ?>"><?php _e('About Us Title', 'mansukh'); ?></label>
<input id="<?php echo $this->get_field_id('mansukh_home_title'); ?>" class="of-input" type="text" name="<?php echo $this->get_field_name('mansukh_home_title'); ?>"
value="<?php echo $mansukh_home_title; ?>" placeholder="<?php _e('About Us Title', 'mansukh'); ?>" />
</div>
</div>
</div>
<div class="section theme-tabs">
<div class="theme-option-inner-tab-group">
<div class="ft-control">
<label class="explain" for="<?php echo $this->get_field_id('mansukh_home_aboutus'); ?>"><?php _e('Aboutus Details', 'mansukh'); ?></label>
<?php
$mansukh_editor_id = $this->get_field_id('mansukh_home_aboutus');
$mansukh_editor_name = $this->get_field_name('mansukh_home_aboutus');
$mansukh_settings = array(
'textarea_name' => $mansukh_editor_name,
'textarea_rows' => 20,
'media_buttons' => false,
'teeny' => true,
);
wp_editor($mansukh_home_aboutus, $mansukh_editor_id, $mansukh_settings);
?>
</div>
</div>
</div>
</div>
<?php
}
/**
* Sanitize widget form values as they are saved.
*
* @see WP_Widget::update()
*
* @param array $new_instance Values just sent to be saved.
* @param array $old_instance Previously saved values from database.
*
* @return array Updated safe values to be saved.
*/
public function update($new_instance, $old_instance) {
$instance = array();
#$instance['title'] = (!empty($new_instance['title']) ) ? strip_tags($new_instance['title']) : '';
/* Home Banner */
$instance['mansukh_home_title'] = (!empty($new_instance['mansukh_home_title']) ) ? sanitize_text_field($new_instance['mansukh_home_title']) : '';
$instance['mansukh_home_aboutus'] = (!empty($new_instance['mansukh_home_aboutus']) ) ? wpautop($new_instance['mansukh_home_aboutus']) : '';
return $instance;
}
}
// End About Us Widget.
?>
The issue is that there is a hidden widget where the TinyMCE appears first.
Instead of copying the answer, check it out here: https://wordpress.stackexchange.com/questions/82670/why-cant-wp-editor-be-used-in-a-custom-widget
It is a bit complicated, but only workaround.
Today after two years I faced the similar problem and solved it.
I was using hero widget in page builder, typed some line and wanted to make it headline, but editor was not allowing any options, while in normal editor all was OK. But it did not work when I was in page builder mode.
I restarted my computer, deleted all cache and it worked when I used other browser.
This can be easily done with the default widget which is in your wp-includes/widgets/class-wp-widget-text.php
Just copy the code into your functions.php of your child theme.
Rename class name “WP_Widget_Text” to Any other name you need
You can change the widget name in following code. Do not change any other code.
parent::__construct( ‘text’, __( ‘Your new widget name’ ), $widget_ops, $control_ops );
Then register the widget using following code.
Screenshot