WP_Widget_Media::_register_one() WordPress Method

The WP_Widget_Media::_register_one() method is used to register a single widget with WordPress. This method takes two arguments: the id of the widget to be registered and an array of options for the widget. The options array can contain any of the following: - the id of the widget - the name of the widget - the description of the widget - the classname of the widget - the width of the widget - the height of the widget - the number of columns to display in the widget - the number of rows to display in the widget - whether or not to display the widget in the sidebar - whether or not to display the widget in the footer - whether or not to display the widget on the front page This method can be used to programmatically register a widget with WordPress. This can be useful if you have a custom widget that you want to make available to your users.

WP_Widget_Media::_register_one( int $number = -1 ) #

Add hooks while registering all widget instances of this widget class.


Parameters

$number

(int)(Optional) The unique order number of this widget instance compared to other instances of the same class.

Default value: -1


Top ↑

Source

File: wp-includes/widgets/class-wp-widget-media.php

	public function _register_one( $number = -1 ) {
		parent::_register_one( $number );
		if ( $this->registered ) {
			return;
		}
		$this->registered = true;

		// 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' ) );

		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_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts().
		add_action( 'admin_footer-widgets.php', array( $this, 'render_control_template_scripts' ) );

		add_filter( 'display_media_states', array( $this, 'display_media_state' ), 10, 2 );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.