wp_render_widget_control

The timeline below displays how wordpress function wp_render_widget_control has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Calls the control callback of a widget and returns the output.
 *
 * @since 5.8.0
 *
 * @global array $wp_registered_widget_controls The registered widget controls.
 *
 * @param string $id Widget ID.
 * @return string|null
 */
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();
}

WordPress Version: 5.8

/**
 * Calls the control callback of a widget and returns the output.
 *
 * @since 5.8.0
 *
 * @param string $id Widget ID.
 * @return string|null
 */
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();
}