wp_render_widget_control() WordPress Function

The wp_render_widget_control() function is used to render the HTML for a given widget control. This function is typically called by the dynamic_sidebar() function when a widget is being displayed in the admin panel. The wp_render_widget_control() function accepts two parameters: the id of the widget control to render, and an array of options for the widget control. The array of options must at least include the 'type' option, which specifies the type of widget control to render. Other options that may be included in the array are 'title', 'description', and 'width'. The wp_render_widget_control() function returns the HTML for the given widget control.

wp_render_widget_control( string $id ) #

Calls the control callback of a widget and returns the output.


Parameters

$id

(string)(Required)Widget ID.


Top ↑

Return

(string|null)


Top ↑

Source

File: wp-includes/widgets.php

function wp_render_widget_control( $id ) {
	global $wp_registered_widget_controls;

	if ( ! isset( $wp_registered_widget_controls[ $id ]['callback'] ) ) {
		return null;
	}

	$callback = $wp_registered_widget_controls[ $id ]['callback'];
	$params   = $wp_registered_widget_controls[ $id ]['params'];

	ob_start();

	if ( is_callable( $callback ) ) {
		call_user_func_array( $callback, $params );
	}

	return ob_get_clean();
}


Top ↑

Changelog

Changelog
VersionDescription
5.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.