wp_register_widget_control [ WordPress Function ]
| Parameters: |
|
| Defined at: |
|
Registers widget control callback for customizing options.
The options contains the 'height', 'width', and 'id_base' keys. The 'height' option is never used. The 'width' option is the width of the fully expanded control form, but try hard to use the default width. The 'id_base' is for multi-widgets (widgets which allow multiple instances such as the text widget), an id_base must be provided. The widget id will end up looking like {$id_base}-{$unique_number}.
Source
<?php
function wp_register_widget_control($id, $name, $control_callback, $options = array()) {
global $wp_registered_widget_controls, $wp_registered_widget_updates, $wp_registered_widgets, $_wp_deprecated_widgets_callbacks;
$id = strtolower($id);
$id_base = _get_widget_id_base($id);
if ( empty($control_callback) ) {
unset($wp_registered_widget_controls[$id]);
unset($wp_registered_widget_updates[$id_base]);
return;
}
if ( in_array($control_callback, $_wp_deprecated_widgets_callbacks, true) && !is_callable($control_callback) ) {
if ( isset($wp_registered_widgets[$id]) )
unset($wp_registered_widgets[$id]);
return;
}
if ( isset($wp_registered_widget_controls[$id]) && !did_action( 'widgets_init' ) )
return;
$defaults = array('width' => 250, 'height' => 200 ); // height is never used
$options = wp_parse_args($options, $defaults);
$options['width'] = (int) $options['width'];
$options['height'] = (int) $options['height'];
$widget = array(
'name' => $name,
'id' => $id,
'callback' => $control_callback,
'params' => array_slice(func_get_args(), 4)
);
$widget = array_merge($widget, $options);
$wp_registered_widget_controls[$id] = $widget;
if ( isset($wp_registered_widget_updates[$id_base]) )
return;
if ( isset($widget['params'][0]['number']) )
$widget['params'][0]['number'] = -1;
unset($widget['width'], $widget['height'], $widget['name'], $widget['id']);
$wp_registered_widget_updates[$id_base] = $widget;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/wp register widget control « WordPress Codex
Description. Registers widget control callback for customizing options. The options contains the height , width , and id_base keys. The height option is never ...
codex.wordpress.org - WordPress › Support » How to use wp_register_widget_control and ...
How to use wp_register_widget_control and wp_register_sidebar_widget (3 posts). nischalmaniar. Member Posted 1 year ago #. I am creating a theme where I ...
wordpress.org - wp_register_widget_control and wp_register_sidebar_widget
Mar 25, 2009 ... Greets: I'm in the process of creating a widget pack must like edublogs has: http:// edublogs.org/the-widget-pack-plugin/ Basically it's a single ...
premium.wpmudev.org - Wordpress Multi-Widgets | JustCoded
May 6, 2009 ... WordPress site does not recommend to use “wp_register_widget_control ()” function. But it is impossible to create multiple widgets without this ...
justcoded.com
Kullanýcý Tartýþmalarý [ wordpress.org ]
- Chouby on "How to correctly widgetize my plugin with register and actions?"
- mtpultz on "How to correctly widgetize my plugin with register and actions?"
- mtpultz on "How to correctly widgetize my plugin with register and actions?"
- mtpultz on "How to correctly widgetize my plugin with register and actions?"
- Chouby on "How to correctly widgetize my plugin with register and actions?"
- mtpultz on "How to correctly widgetize my plugin with register and actions?"
- Chouby on "How to correctly widgetize my plugin with register and actions?"
- mtpultz on "How to correctly widgetize my plugin with register and actions?"
- styledev on "How to use wp_register_widget_control and wp_register_sidebar_widget"
- Luis zuno on "How to use wp_register_widget_control and wp_register_sidebar_widget"