]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/widgets.php
Wordpress 2.7.1
[autoinstalls/wordpress.git] / wp-admin / includes / widgets.php
index 52d1d7b1ca9f8d3171e11f4e66d344f42f7977ef..9e15d54855db2a22b3c1ec311cf9e0f030d93c40 100644 (file)
@@ -1,6 +1,21 @@
 <?php
+/**
+ * WordPress Widgets Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
 
-// $_search is unsanitized
+/**
+ * Display list of widgets, either all or matching search.
+ *
+ * The search parameter are search terms separated by spaces.
+ *
+ * @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.
+ */
 function wp_list_widgets( $show = 'all', $_search = false ) {
        global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
        if ( $_search ) {
@@ -46,9 +61,11 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
                        if ( ( 'unused' == $show && $sidebar ) || ( 'used' == $show && !$sidebar ) )
                                continue;
 
+                       if ( ! isset( $widget['params'][0] ) )
+                               $widget['params'][0] = array();
                        ob_start();
-                               $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show ), 1 => $widget['params'][0] ) );
-                               $sidebar_args = call_user_func_array( 'wp_widget_control', $args );
+                       $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template', '_show' => $show ), 1 => $widget['params'][0] ) );
+                       $sidebar_args = call_user_func_array( 'wp_widget_control', $args );
                        $widget_control_template = ob_get_contents();
                        ob_end_clean();
 
@@ -84,7 +101,7 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
                                        'edit' => $widget['id'],
                                        'key' => array_search( $widget['id'], $sidebars_widgets[$sidebar] ),
                                ) ) );
-                               
+
                                $widget_control_template = '<textarea rows="1" cols="1">' . htmlspecialchars( $widget_control_template ) . '</textarea>';
                        }
 
@@ -148,8 +165,13 @@ function wp_list_widgets( $show = 'all', $_search = false ) {
 <?php
 }
 
-
-
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param string $sidebar
+ */
 function wp_list_widget_controls( $sidebar ) {
        add_filter( 'dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar' );
 ?>
@@ -163,7 +185,14 @@ function wp_list_widget_controls( $sidebar ) {
 <?php
 }
 
-
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param array $params
+ * @return array
+ */
 function wp_list_widget_controls_dynamic_sidebar( $params ) {
        global $wp_registered_widgets;
        static $i = 0;
@@ -182,15 +211,22 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) {
        return $params;
 }
 
-/*
- * Meta widget used to display the control form for a widget.  Called from dynamic_sidebar()
+/**
+ * Meta widget used to display the control form for a widget.
+ *
+ * Called from dynamic_sidebar().
+ *
+ * @since unknown
+ *
+ * @param array $sidebar_args
+ * @return array
  */
 function wp_widget_control( $sidebar_args ) {
        global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets, $edit_widget;
        $widget_id = $sidebar_args['widget_id'];
        $sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false;
 
-       $control = $wp_registered_widget_controls[$widget_id];
+       $control = isset($wp_registered_widget_controls[$widget_id]) ? $wp_registered_widget_controls[$widget_id] : 0;
        $widget  = $wp_registered_widgets[$widget_id];
 
        $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : 'no-key'; // position of widget in sidebar
@@ -198,6 +234,13 @@ function wp_widget_control( $sidebar_args ) {
        $edit = -1 <  $edit_widget && is_numeric($key) && $edit_widget === $key; // (bool) are we currently editing this widget
 
        $id_format = $widget['id'];
+
+       if ( ! isset( $sidebar_args['_show'] ) )
+               $sidebar_args['_show'] = '';
+
+       if ( ! isset( $sidebar_args['_display'] ) )
+               $sidebar_args['_display'] = '';
+
        // We aren't showing a widget control, we're outputing a template for a mult-widget control
        if ( 'all' == $sidebar_args['_show'] && 'template' == $sidebar_args['_display'] && isset($control['params'][0]['number']) ) {
                // number == -1 implies a template where id numbers are replaced by a generic '%i%'
@@ -262,11 +305,11 @@ function wp_widget_control( $sidebar_args ) {
 
                                <?php if ( $control ) : ?>
 
-                               <a class="widget-action widget-control-save wp-no-js-hidden edit alignleft" href="#save:<?php echo $id_format; ?>"><?php _e('Change'); ?></a>
+                               <a class="button widget-action widget-control-save hide-if-no-js edit alignleft" href="#save:<?php echo $id_format; ?>"><?php _e('Done'); ?></a>
 
                                <?php endif; ?>
 
-                               <a class="widget-action widget-control-remove delete alignright" href="<?php echo clean_url( wp_nonce_url( add_query_arg( array( 'remove' => $id_format, 'key' => $key ) ), "remove-widget_$widget[id]" ) ); ?>"><?php _e('Remove'); ?></a>
+                               <a class="button widget-action widget-control-remove alignright" href="<?php echo clean_url( wp_nonce_url( add_query_arg( array( 'remove' => $id_format, 'key' => $key ) ), "remove-widget_$widget[id]" ) ); ?>"><?php _e('Remove'); ?></a>
                                <br class="clear" />
                        </div>
                </div>
@@ -276,6 +319,14 @@ function wp_widget_control( $sidebar_args ) {
        return $sidebar_args;
 }
 
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since unknown
+ *
+ * @param string $string
+ * @return string
+ */
 function wp_widget_control_ob_filter( $string ) {
        if ( false === $beg = strpos( $string, '%BEG_OF_TITLE%' ) )
                return '';
@@ -286,4 +337,4 @@ function wp_widget_control_ob_filter( $string ) {
        return trim( wp_specialchars( strip_tags( $string ) ) );
 }
 
-?>
+?>
\ No newline at end of file