| 1 | Index: wp-includes/admin-bar.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/admin-bar.php (revision 21603) |
|---|
| 4 | +++ wp-includes/admin-bar.php (working copy) |
|---|
| 5 | @@ -656,6 +656,17 @@ |
|---|
| 6 | ) ); |
|---|
| 7 | } |
|---|
| 8 | |
|---|
| 9 | +function wp_admin_bar_screen_options( $wp_admin_bar ) { |
|---|
| 10 | + |
|---|
| 11 | + $wp_admin_bar->add_menu( array( |
|---|
| 12 | + 'parent' => 'top-secondary', |
|---|
| 13 | + 'id' => 'screen-options', |
|---|
| 14 | + 'title' => '(cog)', |
|---|
| 15 | + 'href' => '', |
|---|
| 16 | + ) ); |
|---|
| 17 | + |
|---|
| 18 | + get_current_screen()->render_options( 'screen-options', $wp_admin_bar ); |
|---|
| 19 | +} |
|---|
| 20 | /** |
|---|
| 21 | * Add secondary menus. |
|---|
| 22 | * |
|---|
| 23 | Index: wp-includes/class-wp-admin-bar.php |
|---|
| 24 | =================================================================== |
|---|
| 25 | --- wp-includes/class-wp-admin-bar.php (revision 21603) |
|---|
| 26 | +++ wp-includes/class-wp-admin-bar.php (working copy) |
|---|
| 27 | @@ -396,6 +396,7 @@ |
|---|
| 28 | |
|---|
| 29 | $is_parent = ! empty( $node->children ); |
|---|
| 30 | $has_link = ! empty( $node->href ); |
|---|
| 31 | + $has_title = ! empty( $node->title ); |
|---|
| 32 | |
|---|
| 33 | $tabindex = isset( $node->meta['tabindex'] ) ? (int) $node->meta['tabindex'] : ''; |
|---|
| 34 | $aria_attributes = $tabindex ? 'tabindex="' . $tabindex . '"' : ''; |
|---|
| 35 | @@ -416,34 +417,36 @@ |
|---|
| 36 | ?> |
|---|
| 37 | |
|---|
| 38 | <li id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $menuclass; ?>><?php |
|---|
| 39 | - if ( $has_link ): |
|---|
| 40 | - ?><a class="ab-item" <?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php |
|---|
| 41 | - if ( ! empty( $node->meta['onclick'] ) ) : |
|---|
| 42 | - ?> onclick="<?php echo esc_js( $node->meta['onclick'] ); ?>"<?php |
|---|
| 43 | + if ( $has_title ): |
|---|
| 44 | + if ( $has_link ): |
|---|
| 45 | + ?><a class="ab-item" <?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php |
|---|
| 46 | + if ( ! empty( $node->meta['onclick'] ) ) : |
|---|
| 47 | + ?> onclick="<?php echo esc_js( $node->meta['onclick'] ); ?>"<?php |
|---|
| 48 | + endif; |
|---|
| 49 | + if ( ! empty( $node->meta['target'] ) ) : |
|---|
| 50 | + ?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php |
|---|
| 51 | endif; |
|---|
| 52 | - if ( ! empty( $node->meta['target'] ) ) : |
|---|
| 53 | - ?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php |
|---|
| 54 | + if ( ! empty( $node->meta['title'] ) ) : |
|---|
| 55 | + ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php |
|---|
| 56 | + endif; |
|---|
| 57 | + ?>><?php |
|---|
| 58 | + else: |
|---|
| 59 | + ?><div class="ab-item ab-empty-item" <?php echo $aria_attributes; |
|---|
| 60 | + if ( ! empty( $node->meta['title'] ) ) : |
|---|
| 61 | + ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php |
|---|
| 62 | + endif; |
|---|
| 63 | + ?>><?php |
|---|
| 64 | endif; |
|---|
| 65 | - if ( ! empty( $node->meta['title'] ) ) : |
|---|
| 66 | - ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php |
|---|
| 67 | + |
|---|
| 68 | + echo $node->title; |
|---|
| 69 | + |
|---|
| 70 | + if ( $has_link ) : |
|---|
| 71 | + ?></a><?php |
|---|
| 72 | + else: |
|---|
| 73 | + ?></div><?php |
|---|
| 74 | endif; |
|---|
| 75 | - ?>><?php |
|---|
| 76 | - else: |
|---|
| 77 | - ?><div class="ab-item ab-empty-item" <?php echo $aria_attributes; |
|---|
| 78 | - if ( ! empty( $node->meta['title'] ) ) : |
|---|
| 79 | - ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php |
|---|
| 80 | - endif; |
|---|
| 81 | - ?>><?php |
|---|
| 82 | endif; |
|---|
| 83 | |
|---|
| 84 | - echo $node->title; |
|---|
| 85 | - |
|---|
| 86 | - if ( $has_link ) : |
|---|
| 87 | - ?></a><?php |
|---|
| 88 | - else: |
|---|
| 89 | - ?></div><?php |
|---|
| 90 | - endif; |
|---|
| 91 | - |
|---|
| 92 | if ( $is_parent ) : |
|---|
| 93 | ?><div class="ab-sub-wrapper"><?php |
|---|
| 94 | foreach ( $node->children as $group ) { |
|---|
| 95 | @@ -483,6 +486,9 @@ |
|---|
| 96 | } |
|---|
| 97 | add_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 ); |
|---|
| 98 | |
|---|
| 99 | + if ( is_admin() ) |
|---|
| 100 | + add_action( 'admin_bar_menu', 'wp_admin_bar_screen_options', 90 ); |
|---|
| 101 | + |
|---|
| 102 | add_action( 'admin_bar_menu', 'wp_admin_bar_add_secondary_groups', 200 ); |
|---|
| 103 | |
|---|
| 104 | do_action( 'add_admin_bar_menus' ); |
|---|
| 105 | Index: wp-admin/includes/screen.php |
|---|
| 106 | =================================================================== |
|---|
| 107 | --- wp-admin/includes/screen.php (revision 21603) |
|---|
| 108 | +++ wp-admin/includes/screen.php (working copy) |
|---|
| 109 | @@ -49,31 +49,7 @@ |
|---|
| 110 | * @param string|WP_Screen $screen |
|---|
| 111 | */ |
|---|
| 112 | function meta_box_prefs( $screen ) { |
|---|
| 113 | - global $wp_meta_boxes; |
|---|
| 114 | - |
|---|
| 115 | - if ( is_string( $screen ) ) |
|---|
| 116 | - $screen = convert_to_screen( $screen ); |
|---|
| 117 | - |
|---|
| 118 | - if ( empty($wp_meta_boxes[$screen->id]) ) |
|---|
| 119 | - return; |
|---|
| 120 | - |
|---|
| 121 | - $hidden = get_hidden_meta_boxes($screen); |
|---|
| 122 | - |
|---|
| 123 | - foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) { |
|---|
| 124 | - foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) { |
|---|
| 125 | - foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) { |
|---|
| 126 | - if ( false == $box || ! $box['title'] ) |
|---|
| 127 | - continue; |
|---|
| 128 | - // Submit box cannot be hidden |
|---|
| 129 | - if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) |
|---|
| 130 | - continue; |
|---|
| 131 | - $box_id = $box['id']; |
|---|
| 132 | - echo '<label for="' . $box_id . '-hide">'; |
|---|
| 133 | - echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />'; |
|---|
| 134 | - echo "{$box['title']}</label>\n"; |
|---|
| 135 | - } |
|---|
| 136 | - } |
|---|
| 137 | - } |
|---|
| 138 | + return; |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | /** |
|---|
| 142 | @@ -870,114 +846,171 @@ |
|---|
| 143 | * @since 3.3.0 |
|---|
| 144 | */ |
|---|
| 145 | public function render_screen_options() { |
|---|
| 146 | - global $wp_meta_boxes, $wp_list_table; |
|---|
| 147 | + return; |
|---|
| 148 | + } |
|---|
| 149 | |
|---|
| 150 | + /* |
|---|
| 151 | + * Render screen options in the admin bar |
|---|
| 152 | + * |
|---|
| 153 | + */ |
|---|
| 154 | + function render_options( $parent, $wp_admin_bar ) { |
|---|
| 155 | + $this->render_show_on_screen( $parent, $wp_admin_bar ); |
|---|
| 156 | + $this->render_layout( $parent, $wp_admin_bar ); |
|---|
| 157 | + $this->render_per_page( $parent, $wp_admin_bar ); |
|---|
| 158 | + // @todo $this->_screen_settings |
|---|
| 159 | + } |
|---|
| 160 | + |
|---|
| 161 | + function render_show_on_screen( $parent, $wp_admin_bar ) { |
|---|
| 162 | + global $wp_meta_boxes; |
|---|
| 163 | + |
|---|
| 164 | + if ( ! $this->show_screen_options() ) |
|---|
| 165 | + return; |
|---|
| 166 | + |
|---|
| 167 | $columns = get_column_headers( $this ); |
|---|
| 168 | - $hidden = get_hidden_columns( $this ); |
|---|
| 169 | |
|---|
| 170 | - ?> |
|---|
| 171 | - <div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>"> |
|---|
| 172 | - <form id="adv-settings" action="" method="post"> |
|---|
| 173 | - <?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?> |
|---|
| 174 | - <h5><?php _e( 'Show on screen' ); ?></h5> |
|---|
| 175 | - <?php |
|---|
| 176 | - endif; |
|---|
| 177 | + if ( ! isset( $wp_meta_boxes[ $this->id ] ) && ( ! $columns || isset( $columns['_title'] ) ) ) |
|---|
| 178 | + return; |
|---|
| 179 | |
|---|
| 180 | - if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?> |
|---|
| 181 | - <div class="metabox-prefs"> |
|---|
| 182 | - <?php |
|---|
| 183 | - meta_box_prefs( $this ); |
|---|
| 184 | + $wp_admin_bar->add_menu( array( |
|---|
| 185 | + 'id' => 'show-on-screen', |
|---|
| 186 | + 'parent' => $parent, |
|---|
| 187 | + 'href' => '', |
|---|
| 188 | + 'meta' => array( 'html' => '<h5 class="ab-item">' . __( 'Show on screen' ) . '</h5>' ), |
|---|
| 189 | + ) ); |
|---|
| 190 | |
|---|
| 191 | - if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) { |
|---|
| 192 | - if ( isset( $_GET['welcome'] ) ) { |
|---|
| 193 | - $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; |
|---|
| 194 | - update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); |
|---|
| 195 | - } else { |
|---|
| 196 | - $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); |
|---|
| 197 | - if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) |
|---|
| 198 | - $welcome_checked = false; |
|---|
| 199 | - } |
|---|
| 200 | - echo '<label for="wp_welcome_panel-hide">'; |
|---|
| 201 | - echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />'; |
|---|
| 202 | - echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; |
|---|
| 203 | + // Render meta box show/hide. |
|---|
| 204 | + if ( isset( $wp_meta_boxes[ $this->id ] ) ) { |
|---|
| 205 | + $hidden = get_hidden_meta_boxes($this); |
|---|
| 206 | + |
|---|
| 207 | + foreach ( array_keys($wp_meta_boxes[$this->id]) as $context ) { |
|---|
| 208 | + foreach ( array_keys($wp_meta_boxes[$this->id][$context]) as $priority ) { |
|---|
| 209 | + foreach ( $wp_meta_boxes[$this->id][$context][$priority] as $box ) { |
|---|
| 210 | + if ( false == $box || ! $box['title'] ) |
|---|
| 211 | + continue; |
|---|
| 212 | + // Submit box cannot be hidden |
|---|
| 213 | + if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) |
|---|
| 214 | + continue; |
|---|
| 215 | + $box_id = $box['id']; |
|---|
| 216 | + $html = '<label class="ab-item" for="' . $box_id . '-hide">' . |
|---|
| 217 | + '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />' . |
|---|
| 218 | + "{$box['title']}</label>\n"; |
|---|
| 219 | + $wp_admin_bar->add_menu( array( |
|---|
| 220 | + 'id' => 'show-on-screen-' . $box_id, |
|---|
| 221 | + 'parent' => $parent, |
|---|
| 222 | + 'href' => '', |
|---|
| 223 | + 'meta' => array( 'html' => $html ), |
|---|
| 224 | + ) ); |
|---|
| 225 | } |
|---|
| 226 | - ?> |
|---|
| 227 | - <br class="clear" /> |
|---|
| 228 | - </div> |
|---|
| 229 | - <?php endif; |
|---|
| 230 | - if ( $columns ) : |
|---|
| 231 | - if ( ! empty( $columns['_title'] ) ) : ?> |
|---|
| 232 | - <h5><?php echo $columns['_title']; ?></h5> |
|---|
| 233 | - <?php endif; ?> |
|---|
| 234 | - <div class="metabox-prefs"> |
|---|
| 235 | - <?php |
|---|
| 236 | - $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname'); |
|---|
| 237 | + } |
|---|
| 238 | + } |
|---|
| 239 | |
|---|
| 240 | - foreach ( $columns as $column => $title ) { |
|---|
| 241 | - // Can't hide these for they are special |
|---|
| 242 | - if ( in_array( $column, $special ) ) |
|---|
| 243 | - continue; |
|---|
| 244 | - if ( empty( $title ) ) |
|---|
| 245 | - continue; |
|---|
| 246 | - |
|---|
| 247 | - if ( 'comments' == $column ) |
|---|
| 248 | - $title = __( 'Comments' ); |
|---|
| 249 | - $id = "$column-hide"; |
|---|
| 250 | - echo '<label for="' . $id . '">'; |
|---|
| 251 | - echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />'; |
|---|
| 252 | - echo "$title</label>\n"; |
|---|
| 253 | + if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) { |
|---|
| 254 | + if ( isset( $_GET['welcome'] ) ) { |
|---|
| 255 | + $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; |
|---|
| 256 | + update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); |
|---|
| 257 | + } else { |
|---|
| 258 | + $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); |
|---|
| 259 | + if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) |
|---|
| 260 | + $welcome_checked = false; |
|---|
| 261 | } |
|---|
| 262 | - ?> |
|---|
| 263 | - <br class="clear" /> |
|---|
| 264 | - </div> |
|---|
| 265 | - <?php endif; |
|---|
| 266 | + $html = '<label class="ab-item" for="wp_welcome_panel-hide">' . |
|---|
| 267 | + '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />' . |
|---|
| 268 | + _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; |
|---|
| 269 | + $wp_admin_bar->add_menu( array( |
|---|
| 270 | + 'id' => 'show-on-screen-' . $box_id, |
|---|
| 271 | + 'parent' => $parent, |
|---|
| 272 | + 'href' => '', |
|---|
| 273 | + 'meta' => array( 'html' => $html ), |
|---|
| 274 | + ) ); |
|---|
| 275 | + } |
|---|
| 276 | + } |
|---|
| 277 | |
|---|
| 278 | - $this->render_screen_layout(); |
|---|
| 279 | - $this->render_per_page_options(); |
|---|
| 280 | - echo $this->_screen_settings; |
|---|
| 281 | + // Render column show/hide. |
|---|
| 282 | + if ( $columns ) { |
|---|
| 283 | + $hidden = get_hidden_columns( $this ); |
|---|
| 284 | |
|---|
| 285 | - ?> |
|---|
| 286 | - <div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div> |
|---|
| 287 | - </form> |
|---|
| 288 | - </div> |
|---|
| 289 | - <?php |
|---|
| 290 | + if ( ! empty( $columns['_title'] ) ) { |
|---|
| 291 | + echo '<h5>' . $columns['_title'] . '</h5>'; |
|---|
| 292 | + } |
|---|
| 293 | + |
|---|
| 294 | + $special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' ); |
|---|
| 295 | + |
|---|
| 296 | + foreach ( $columns as $column => $title ) { |
|---|
| 297 | + // Can't hide these for they are special |
|---|
| 298 | + if ( in_array( $column, $special ) ) |
|---|
| 299 | + continue; |
|---|
| 300 | + if ( empty( $title ) ) |
|---|
| 301 | + continue; |
|---|
| 302 | + |
|---|
| 303 | + if ( 'comments' == $column ) |
|---|
| 304 | + $title = __( 'Comments' ); |
|---|
| 305 | + $id = "$column-hide"; |
|---|
| 306 | + $html = '<label class="ab-item" for="' . $id . '">' . |
|---|
| 307 | + '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />' . |
|---|
| 308 | + "$title</label>\n"; |
|---|
| 309 | + $wp_admin_bar->add_menu( array( |
|---|
| 310 | + 'id' => 'show-on-screen-' . $column, |
|---|
| 311 | + 'parent' => $parent, |
|---|
| 312 | + 'href' => '', |
|---|
| 313 | + 'meta' => array( 'html' => $html ), |
|---|
| 314 | + ) ); |
|---|
| 315 | + } |
|---|
| 316 | + } |
|---|
| 317 | } |
|---|
| 318 | |
|---|
| 319 | - /** |
|---|
| 320 | - * Render the option for number of columns on the page |
|---|
| 321 | - * |
|---|
| 322 | - * @since 3.3.0 |
|---|
| 323 | - */ |
|---|
| 324 | - function render_screen_layout() { |
|---|
| 325 | + function render_layout( $parent, $wp_admin_bar ) { |
|---|
| 326 | + // Back compat for plugins using the filter instead of add_screen_option() |
|---|
| 327 | + $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this ); |
|---|
| 328 | + |
|---|
| 329 | + if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) |
|---|
| 330 | + $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) ); |
|---|
| 331 | + |
|---|
| 332 | + if ( $this->get_option( 'layout_columns' ) ) { |
|---|
| 333 | + $this->columns = (int) get_user_option("screen_layout_$this->id"); |
|---|
| 334 | + |
|---|
| 335 | + if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) |
|---|
| 336 | + $this->columns = $this->get_option( 'layout_columns', 'default' ); |
|---|
| 337 | + } |
|---|
| 338 | + $GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat. |
|---|
| 339 | + |
|---|
| 340 | if ( ! $this->get_option('layout_columns') ) |
|---|
| 341 | return; |
|---|
| 342 | |
|---|
| 343 | $screen_layout_columns = $this->get_columns(); |
|---|
| 344 | $num = $this->get_option( 'layout_columns', 'max' ); |
|---|
| 345 | |
|---|
| 346 | - ?> |
|---|
| 347 | - <h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5> |
|---|
| 348 | - <div class='columns-prefs'><?php |
|---|
| 349 | - _e('Number of Columns:'); |
|---|
| 350 | - for ( $i = 1; $i <= $num; ++$i ): |
|---|
| 351 | - ?> |
|---|
| 352 | - <label class="columns-prefs-<?php echo $i; ?>"> |
|---|
| 353 | - <input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>' |
|---|
| 354 | - <?php checked( $screen_layout_columns, $i ); ?> /> |
|---|
| 355 | - <?php echo esc_html( $i ); ?> |
|---|
| 356 | - </label> |
|---|
| 357 | - <?php |
|---|
| 358 | - endfor; ?> |
|---|
| 359 | - </div> |
|---|
| 360 | - <?php |
|---|
| 361 | + $wp_admin_bar->add_menu( array( |
|---|
| 362 | + 'id' => 'column-layout', |
|---|
| 363 | + 'parent' => $parent, |
|---|
| 364 | + 'href' => '', |
|---|
| 365 | + 'meta' => array( 'html' => '<h5 class="ab-item">' . __( 'Column Layout' ) . '</h5>' ), |
|---|
| 366 | + ) ); |
|---|
| 367 | + |
|---|
| 368 | + for ( $i = 1; $i <= $num; ++$i ) { |
|---|
| 369 | + $html = '<label class="ab-item" class="columns-prefs-' . $i . '">' . |
|---|
| 370 | + "<input type='radio' name='screen_columns' value='" . $i . "'" . |
|---|
| 371 | + checked( $screen_layout_columns, $i, false ) . '/>' . |
|---|
| 372 | + esc_html( $i ) . |
|---|
| 373 | + '</label>'; |
|---|
| 374 | + |
|---|
| 375 | + $wp_admin_bar->add_menu( array( |
|---|
| 376 | + 'id' => 'column-layout-' . $i, |
|---|
| 377 | + 'parent' => $parent, |
|---|
| 378 | + 'href' => '', |
|---|
| 379 | + 'meta' => array( 'html' => $html ), |
|---|
| 380 | + ) ); |
|---|
| 381 | + } |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | /** |
|---|
| 385 | * Render the items per page option |
|---|
| 386 | * |
|---|
| 387 | - * @since 3.3.0 |
|---|
| 388 | + * @since 3.5.0 |
|---|
| 389 | */ |
|---|
| 390 | - function render_per_page_options() { |
|---|
| 391 | + function render_per_page( $parent, $wp_admin_bar ) { |
|---|
| 392 | + // @todo form and nonce |
|---|
| 393 | + // wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); |
|---|
| 394 | + |
|---|
| 395 | if ( ! $this->get_option( 'per_page' ) ) |
|---|
| 396 | return; |
|---|
| 397 | |
|---|
| 398 | @@ -1007,20 +1040,53 @@ |
|---|
| 399 | if ( isset( $this->post_type ) ) |
|---|
| 400 | $per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type ); |
|---|
| 401 | |
|---|
| 402 | - ?> |
|---|
| 403 | - <div class="screen-options"> |
|---|
| 404 | - <?php if ( $per_page_label ) : ?> |
|---|
| 405 | - <input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]" |
|---|
| 406 | - id="<?php echo esc_attr( $option ); ?>" maxlength="3" |
|---|
| 407 | - value="<?php echo esc_attr( $per_page ); ?>" /> |
|---|
| 408 | - <label for="<?php echo esc_attr( $option ); ?>"> |
|---|
| 409 | - <?php echo esc_html( $per_page_label ); ?> |
|---|
| 410 | - </label> |
|---|
| 411 | - <?php endif; |
|---|
| 412 | + $wp_admin_bar->add_menu( array( |
|---|
| 413 | + 'id' => 'per-page', |
|---|
| 414 | + 'parent' => $parent, |
|---|
| 415 | + 'href' => '', |
|---|
| 416 | + 'meta' => array( 'html' => '<h5 class="ab-item">' . __( 'Items Per Page' ) . '</h5>' ), |
|---|
| 417 | + ) ); |
|---|
| 418 | |
|---|
| 419 | - echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?> |
|---|
| 420 | - <input type='hidden' name='wp_screen_options[option]' value='<?php echo esc_attr($option); ?>' /> |
|---|
| 421 | - </div> |
|---|
| 422 | - <?php |
|---|
| 423 | + if ( $per_page_label ) { |
|---|
| 424 | + $html = '<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]" |
|---|
| 425 | + id="' . esc_attr( $option ) . '" maxlength="3" value="' . esc_attr( $per_page ) . '" />' . |
|---|
| 426 | + '<label class="ab-item" for="' . esc_attr( $option ) . '">' . |
|---|
| 427 | + esc_html( $per_page_label ) . |
|---|
| 428 | + '</label>'; |
|---|
| 429 | + $wp_admin_bar->add_menu( array( |
|---|
| 430 | + 'id' => 'per-page-1', |
|---|
| 431 | + 'parent' => $parent, |
|---|
| 432 | + 'href' => '', |
|---|
| 433 | + 'meta' => array( 'html' => $html ), |
|---|
| 434 | + ) ); |
|---|
| 435 | + } |
|---|
| 436 | + |
|---|
| 437 | + $html = get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ) . |
|---|
| 438 | + "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />"; |
|---|
| 439 | + |
|---|
| 440 | + $wp_admin_bar->add_menu( array( |
|---|
| 441 | + 'id' => 'per-page-submit', |
|---|
| 442 | + 'parent' => $parent, |
|---|
| 443 | + 'href' => '', |
|---|
| 444 | + 'meta' => array( 'html' => $html ), |
|---|
| 445 | + ) ); |
|---|
| 446 | } |
|---|
| 447 | + |
|---|
| 448 | + /** |
|---|
| 449 | + * Render the option for number of columns on the page |
|---|
| 450 | + * |
|---|
| 451 | + * @since 3.3.0 |
|---|
| 452 | + */ |
|---|
| 453 | + function render_screen_layout() { |
|---|
| 454 | + return; |
|---|
| 455 | + } |
|---|
| 456 | + |
|---|
| 457 | + /** |
|---|
| 458 | + * Render the items per page option |
|---|
| 459 | + * |
|---|
| 460 | + * @since 3.3.0 |
|---|
| 461 | + */ |
|---|
| 462 | + function render_per_page_options() { |
|---|
| 463 | + return; |
|---|
| 464 | + } |
|---|
| 465 | } |
|---|
| 466 | Index: wp-admin/admin-header.php |
|---|
| 467 | =================================================================== |
|---|
| 468 | --- wp-admin/admin-header.php (revision 21603) |
|---|
| 469 | +++ wp-admin/admin-header.php (working copy) |
|---|
| 470 | @@ -115,6 +115,7 @@ |
|---|
| 471 | <div id="wpcontent"> |
|---|
| 472 | |
|---|
| 473 | <?php |
|---|
| 474 | +$current_screen->set_parentage( $parent_file ); |
|---|
| 475 | do_action('in_admin_header'); |
|---|
| 476 | ?> |
|---|
| 477 | |
|---|
| 478 | @@ -122,15 +123,11 @@ |
|---|
| 479 | <?php |
|---|
| 480 | unset($title_class, $blog_name, $total_update_count, $update_title); |
|---|
| 481 | |
|---|
| 482 | -$current_screen->set_parentage( $parent_file ); |
|---|
| 483 | - |
|---|
| 484 | ?> |
|---|
| 485 | |
|---|
| 486 | <div id="wpbody-content" aria-label="<?php esc_attr_e('Main content'); ?>"> |
|---|
| 487 | <?php |
|---|
| 488 | |
|---|
| 489 | -$current_screen->render_screen_meta(); |
|---|
| 490 | - |
|---|
| 491 | if ( is_network_admin() ) |
|---|
| 492 | do_action('network_admin_notices'); |
|---|
| 493 | elseif ( is_user_admin() ) |
|---|