On this page
WP_Widget_Text::_register_one( int $number = -1 )
Add hooks for enqueueing assets when registering all widget instances of this widget class.
Parameters
$numberint Optional-
The unique order number of this widget instance compared to other instances of the same class.
Default:
-1
Source
File: wp-includes/widgets/class-wp-widget-text.php. View all references
public function _register_one( $number = -1 ) {
parent::_register_one( $number );
if ( $this->registered ) {
return;
}
$this->registered = true;
wp_add_inline_script( 'text-widgets', sprintf( 'wp.textWidgets.idBases.push( %s );', wp_json_encode( $this->id_base ) ) );
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' ) );
}
Related
Uses
| Uses | Description |
|---|---|
| wp_add_inline_script() wp-includes/functions.wp-scripts.php | Adds extra code to a registered script. |
| WP_Widget::_register_one() wp-includes/class-wp-widget.php | Registers an instance of the widget class. |
| wp_json_encode() wp-includes/functions.php | Encodes a variable into JSON, with some sanity checks. |
| add_action() wp-includes/plugin.php | Adds a callback function to an action hook. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_widget_text/_register_one