注册用于自定义选项的窗口小部件控件回调。
原型
register_widget_control( int|string $name, callable $control_callback, int $width = '', int $height = '' )
描述
允许$ name为一个数组,它接受三个元素来获取第一个元素,第三个元素用于名称,或者只使用数组的第一个元素作为名称。
参考:
- wp_register_widget_control()
参数
$name
(int|string)
(Required)
边栏ID。
$control_callback
(callable)
(Required)
窗口小部件控件回调以显示和处理表单。
$width
(int)
(Optional)
小部件宽度。
$height
(int)
(Optional)
小部件高度。
源文件
路径:wp-includes/deprecated.php
<?php
...
function register_widget_control($name, $control_callback, $width = '', $height = '') {
_deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' );
// Compat
if ( is_array($name) ) {
if ( count($name) == 3 )
$name = sprintf($name[0], $name[2]);
else
$name = $name[0];
}
$id = sanitize_title($name);
$options = array();
if ( !empty($width) )
$options['width'] = $width;
if ( !empty($height) )
$options['height'] = $height;
$params = array_slice(func_get_args(), 4);
$args = array($id, $name, $control_callback, $options);
if ( !empty($params) )
$args = array_merge($args, $params);
call_user_func_array('wp_register_widget_control', $args);
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/register_widget_control/