~canonical-sysadmins/wordpress/3.9.x

« back to all changes in this revision

Viewing changes to wp-admin/includes/widgets.php

  • Committer: Andrew Glen-Young
  • Date: 2011-03-08 14:47:51 UTC
  • Revision ID: andrew.glen-young@canonical.com-20110308144751-1n6spqgayztf9h77
[AGY] import 3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 */
8
8
 
9
9
/**
10
 
 * Display list of the available widgets, either all or matching search.
11
 
 *
12
 
 * The search parameter are search terms separated by spaces.
13
 
 *
14
 
 * @since unknown
15
 
 *
16
 
 * @param string $show Optional, default is all. What to display, can be 'all', 'unused', or 'used'.
17
 
 * @param string $_search Optional. Search for widgets. Should be unsanitized.
 
10
 * Display list of the available widgets.
 
11
 *
 
12
 * @since 2.5.0
18
13
 */
19
14
function wp_list_widgets() {
20
15
        global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
21
16
 
22
17
        $sort = $wp_registered_widgets;
23
 
        usort( $sort, create_function( '$a, $b', 'return strnatcasecmp( $a["name"], $b["name"] );' ) );
 
18
        usort( $sort, '_sort_name_callback' );
24
19
        $done = array();
25
20
 
26
21
        foreach ( $sort as $widget ) {
52
47
}
53
48
 
54
49
/**
 
50
 * Callback to sort array by a 'name' key.
 
51
 *
 
52
 * @since 3.1.0
 
53
 * @access private
 
54
 */
 
55
function _sort_name_callback( $a, $b ) {
 
56
        return strnatcasecmp( $a['name'], $b['name'] );
 
57
}
 
58
 
 
59
/**
55
60
 * Show the widgets and their settings for a sidebar.
56
61
 * Used in the the admin widget config screen.
57
62
 *
58
 
 * @since unknown
 
63
 * @since 2.5.0
59
64
 *
60
65
 * @param string $sidebar id slug of the sidebar
61
66
 */
79
84
/**
80
85
 * {@internal Missing Short Description}}
81
86
 *
82
 
 * @since unknown
 
87
 * @since 2.5.0
83
88
 *
84
89
 * @param array $params
85
90
 * @return array
93
98
        $id = isset($params[0]['_temp_id']) ? $params[0]['_temp_id'] : $widget_id;
94
99
        $hidden = isset($params[0]['_hide']) ? ' style="display:none;"' : '';
95
100
 
96
 
        $params[0]['before_widget'] = "<div id='widget-${i}_$id' class='widget'$hidden>";
 
101
        $params[0]['before_widget'] = "<div id='widget-{$i}_{$id}' class='widget'$hidden>";
97
102
        $params[0]['after_widget'] = "</div>";
98
103
        $params[0]['before_title'] = "%BEG_OF_TITLE%"; // deprecated
99
104
        $params[0]['after_title'] = "%END_OF_TITLE%"; // deprecated
123
128
 *
124
129
 * Called from dynamic_sidebar().
125
130
 *
126
 
 * @since unknown
 
131
 * @since 2.5.0
127
132
 *
128
133
 * @param array $sidebar_args
129
134
 * @return array
203
208
                </div>
204
209
                <div class="alignright<?php if ( 'noform' === $has_form ) echo ' widget-control-noform'; ?>">
205
210
                <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback " title="" alt="" />
206
 
                <input type="submit" name="savewidget" class="button-primary widget-control-save" value="<?php esc_attr_e('Save'); ?>" />
 
211
                <?php submit_button( __( 'Save' ), 'button-primary widget-control-save', 'savewidget', false ); ?>
207
212
                </div>
208
213
                <br class="clear" />
209
214
        </div>