X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/699231ae09f7057a4d0000cdf32e50a3df6a04ca..53f4633144ed68c8b8fb5861f992b5489894a940:/wp-admin/includes/widgets.php diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php index aef0dbaf..36cf6449 100644 --- a/wp-admin/includes/widgets.php +++ b/wp-admin/includes/widgets.php @@ -7,20 +7,18 @@ */ /** - * Display list of the available widgets, either all or matching search. + * Display list of the available widgets. * - * The search parameter are search terms separated by spaces. + * @since 2.5.0 * - * @since unknown - * - * @param string $show Optional, default is all. What to display, can be 'all', 'unused', or 'used'. - * @param string $_search Optional. Search for widgets. Should be unsanitized. + * @global array $wp_registered_widgets + * @global array $wp_registered_widget_controls */ function wp_list_widgets() { - global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls; + global $wp_registered_widgets, $wp_registered_widget_controls; $sort = $wp_registered_widgets; - usort( $sort, create_function( '$a, $b', 'return strnatcasecmp( $a["name"], $b["name"] );' ) ); + usort( $sort, '_sort_name_callback' ); $done = array(); foreach ( $sort as $widget ) { @@ -51,35 +49,64 @@ function wp_list_widgets() { } } +/** + * Callback to sort array by a 'name' key. + * + * @since 3.1.0 + * @access private + * + * @return int + */ +function _sort_name_callback( $a, $b ) { + return strnatcasecmp( $a['name'], $b['name'] ); +} + /** * Show the widgets and their settings for a sidebar. - * Used in the the admin widget config screen. + * Used in the admin widget config screen. * - * @since unknown + * @since 2.5.0 * * @param string $sidebar id slug of the sidebar + * @param string optional $sidebar_name Include the HTML for the sidebar name */ -function wp_list_widget_controls( $sidebar ) { +function wp_list_widget_controls( $sidebar, $sidebar_name = '' ) { add_filter( 'dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar' ); - echo "
\n"; - $description = wp_sidebar_description( $sidebar ); - if ( !empty( $description ) ) { - echo "\n"; + echo '
'; + + if ( $sidebar_name ) { + ?> + + '; + + if ( ! empty( $description ) ) { + echo '

' . $description . '

'; } + echo '
'; + dynamic_sidebar( $sidebar ); - echo "
\n"; + + echo ''; } /** * {@internal Missing Short Description}} * - * @since unknown + * @since 2.5.0 + * + * @global array $wp_registered_widgets + * + * @staticvar int $i * * @param array $params * @return array @@ -93,7 +120,7 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) { $id = isset($params[0]['_temp_id']) ? $params[0]['_temp_id'] : $widget_id; $hidden = isset($params[0]['_hide']) ? ' style="display:none;"' : ''; - $params[0]['before_widget'] = "
"; + $params[0]['before_widget'] = "
"; $params[0]['after_widget'] = "
"; $params[0]['before_title'] = "%BEG_OF_TITLE%"; // deprecated $params[0]['after_title'] = "%END_OF_TITLE%"; // deprecated @@ -105,7 +132,14 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) { return $params; } -function next_widget_id_number($id_base) { +/** + * + * @global array $wp_registered_widgets + * + * @param string $id_base + * @return int + */ +function next_widget_id_number( $id_base ) { global $wp_registered_widgets; $number = 1; @@ -123,7 +157,11 @@ function next_widget_id_number($id_base) { * * Called from dynamic_sidebar(). * - * @since unknown + * @since 2.5.0 + * + * @global array $wp_registered_widgets + * @global array $wp_registered_widget_controls + * @global array $sidebars_widgets * * @param array $sidebar_args * @return array @@ -155,11 +193,14 @@ function wp_widget_control( $sidebar_args ) { $query_arg['key'] = $key; } - // We aren't showing a widget control, we're outputing a template for a mult-widget control + /* + * We aren't showing a widget control, we're outputting a template + * for a multi-widget control. + */ if ( isset($sidebar_args['_display']) && 'template' == $sidebar_args['_display'] && $widget_number ) { // number == -1 implies a template where id numbers are replaced by a generic '__i__' $control['params'][0]['number'] = -1; - // with id_base widget id's are constructed like {$id_base}-{$id_number} + // With id_base widget id's are constructed like {$id_base}-{$id_number}. if ( isset($control['id_base']) ) $id_format = $control['id_base'] . '-__i__'; } @@ -174,13 +215,17 @@ function wp_widget_control( $sidebar_args ) {

-
+
- - + 'widget-' . esc_attr( $id_format ) . '-savewidget' ) ); ?> +

@@ -215,6 +260,6 @@ function wp_widget_control( $sidebar_args ) {