wppaste
WordPress

WP_Widget_Text

Since
2.8.0
Source
wp-includes/widgets/class-wp-widget-text.php:17
Core class used to implement a Text widget.

Compatibility

WordPress
since 2.8.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 4

Every hook that fires from inside WP_Widget_Text, in the order it appears in the class, grouped by the method that fires it.

Properties · 1

$registeredboolprotected
Whether or not the widget has been registered yet.

Methods · 11

Source code

class WP_Widget_Text extends WP_Widget { 	/**	 * Whether or not the widget has been registered yet.	 *	 * @since 4.8.1	 * @var bool	 */	protected $registered = false; 	/**	 * Sets up a new Text widget instance.	 *	 * @since 2.8.0	 */	public function __construct() {		$widget_ops  = array(			'classname'                   => 'widget_text',			'description'                 => __( 'Arbitrary text.' ),			'customize_selective_refresh' => true,			'show_instance_in_rest'       => true,		);		$control_ops = array(			'width'  => 400,			'height' => 350,		);		parent::__construct( 'text', __( 'Text' ), $widget_ops, $control_ops );	} 	/**	 * Adds hooks for enqueueing assets when registering all widget instances of this widget class.	 *	 * @param int $number Optional. The unique order number of this widget instance	 *                    compared to other instances of the same class. Default -1.	 */	public function _register_one( $number = -1 ) {		parent::_register_one( $number );		if ( $this->registered ) {			return;		}		$this->registered = true; 		if ( $this->is_preview() ) {			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) );		} 		/*		 * 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( 'WP_Widget_Text', 'render_control_template_scripts' ) );	} 	/**	 * Determines whether a given instance is legacy and should bypass using TinyMCE.	 *	 * @since 4.8.1	 *	 * @param array $instance {	 *     Instance data.	 *	 *     @type string      $text   Content.	 *     @type bool|string $filter Whether autop or content filters should apply.	 *     @type bool        $legacy Whether widget is in legacy mode.	 * }	 * @return bool Whether Text widget instance contains legacy data.	 */	public function is_legacy_instance( $instance ) { 		// Legacy mode when not in visual mode.		if ( isset( $instance['visual'] ) ) {			return ! $instance['visual'];		}

Changelog

Introduced in 2.8.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/widgets/class-wp-widget-text.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.