'widget_text', 'description' => __( 'Arbitrary text or HTML.' ), 'customize_selective_refresh' => true, ); $control_ops = array( 'width' => 400, 'height' => 350, ); parent::__construct( 'text', __( 'Text' ), $widget_ops, $control_ops ); } /** * Add hooks for enqueueing assets when registering all widget instances of this widget class. * * @since 4.8.0 * @access public */ public function _register() { // Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) ); // Note that the widgets component in the customizer will also do the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). add_action( 'admin_footer-widgets.php', array( $this, 'render_control_template_scripts' ) ); parent::_register(); } /** * Outputs the content for the current Text widget instance. * * @since 2.8.0 * @access public * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current Text widget instance. */ public function widget( $args, $instance ) { /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $text = ! empty( $instance['text'] ) ? $instance['text'] : ''; /** * Filters the content of the Text widget. * * @since 2.3.0 * @since 4.4.0 Added the `$this` parameter. * * @param string $text The widget content. * @param array $instance Array of settings for the current widget. * @param WP_Widget_Text $this Current Text widget instance. */ $text = apply_filters( 'widget_text', $text, $instance, $this ); if ( isset( $instance['filter'] ) ) { if ( 'content' === $instance['filter'] ) { /** * Filters the content of the Text widget to apply changes expected from the visual (TinyMCE) editor. * * By default a subset of the_content filters are applied, including wpautop and wptexturize. * * @since 4.8.0 * * @param string $text The widget content. * @param array $instance Array of settings for the current widget. * @param WP_Widget_Text $this Current Text widget instance. */ $text = apply_filters( 'widget_text_content', $text, $instance, $this ); } elseif ( $instance['filter'] ) { $text = wpautop( $text ); // Back-compat for instances prior to 4.8. } } echo $args['before_widget']; if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } ?>
'', 'text' => '', ) ); ?>