Changeset 18911 for trunk/wp-admin/includes/screen.php
- Timestamp:
- 10/07/2011 04:57:12 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/screen.php
r18896 r18911 15 15 * @return array Containing the headers in the format id => UI String 16 16 */ 17 function get_column_headers( $screen ) { // TODO: fold into WP_Screen?17 function get_column_headers( $screen ) { 18 18 if ( is_string( $screen ) ) 19 19 $screen = convert_to_screen( $screen ); … … 36 36 * @return array 37 37 */ 38 function get_hidden_columns( $screen ) { // TODO: fold into WP_Screen38 function get_hidden_columns( $screen ) { 39 39 if ( is_string( $screen ) ) 40 40 $screen = convert_to_screen( $screen ); … … 44 44 45 45 /** 46 * {@internal Missing Short Description}} 47 * 48 * @since 2.7.0 49 * 50 * @param unknown_type $screen 51 */ 52 function meta_box_prefs($screen) { 53 global $wp_meta_boxes; 54 55 if ( is_string($screen) ) 56 $screen = convert_to_screen($screen); 57 58 if ( empty($wp_meta_boxes[$screen->id]) ) 59 return; 60 61 $hidden = get_hidden_meta_boxes($screen); 62 63 foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) { 64 foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) { 65 foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) { 66 if ( false == $box || ! $box['title'] ) 67 continue; 68 // Submit box cannot be hidden 69 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) 70 continue; 71 $box_id = $box['id']; 72 echo '<label for="' . $box_id . '-hide">'; 73 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"' : '') . ' />'; 74 echo "{$box['title']}</label>\n"; 75 } 76 } 77 } 78 } 79 80 /** 46 81 * Get Hidden Meta Boxes 47 82 * … … 51 86 * @return array Hidden Meta Boxes 52 87 */ 53 function get_hidden_meta_boxes( $screen ) { // TODO: fold into WP_Screen88 function get_hidden_meta_boxes( $screen ) { 54 89 if ( is_string( $screen ) ) 55 90 $screen = convert_to_screen( $screen ); … … 63 98 else 64 99 $hidden = array( 'slugdiv' ); 65 66 100 $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen); 67 101 } 68 102 69 103 return $hidden; 104 } 105 106 /** 107 * {@internal Missing Short Description}} 108 * 109 * @since 2.7.0 110 */ 111 function favorite_actions( $screen = null ) { 112 $default_action = false; 113 114 if ( is_string($screen) ) 115 $screen = convert_to_screen($screen); 116 117 if ( $screen->is_user ) 118 return; 119 120 if ( isset($screen->post_type) ) { 121 $post_type_object = get_post_type_object($screen->post_type); 122 if ( 'add' != $screen->action ) 123 $default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts)); 124 else 125 $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts)); 126 } 127 128 if ( !$default_action ) { 129 if ( $screen->is_network ) { 130 $default_action = array('sites.php' => array( __('Sites'), 'manage_sites')); 131 } else { 132 switch ( $screen->id ) { 133 case 'upload': 134 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files')); 135 break; 136 case 'media': 137 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files')); 138 break; 139 case 'link-manager': 140 case 'link': 141 if ( 'add' != $screen->action ) 142 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links')); 143 else 144 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links')); 145 break; 146 case 'users': 147 $default_action = array('user-new.php' => array(__('New User'), 'create_users')); 148 break; 149 case 'user': 150 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users')); 151 break; 152 case 'plugins': 153 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins')); 154 break; 155 case 'plugin-install': 156 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins')); 157 break; 158 case 'themes': 159 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes')); 160 break; 161 case 'theme-install': 162 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes')); 163 break; 164 default: 165 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts')); 166 break; 167 } 168 } 169 } 170 171 if ( !$screen->is_network ) { 172 $actions = array( 173 'post-new.php' => array(__('New Post'), 'edit_posts'), 174 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'), 175 'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'), 176 'media-new.php' => array(__('Upload'), 'upload_files'), 177 'edit-comments.php' => array(__('Comments'), 'moderate_comments') 178 ); 179 } else { 180 $actions = array( 181 'sites.php' => array( __('Sites'), 'manage_sites'), 182 'users.php' => array( __('Users'), 'manage_network_users') 183 ); 184 } 185 186 $default_key = array_keys($default_action); 187 $default_key = $default_key[0]; 188 if ( isset($actions[$default_key]) ) 189 unset($actions[$default_key]); 190 $actions = array_merge($default_action, $actions); 191 $actions = apply_filters( 'favorite_actions', $actions, $screen ); 192 193 $allowed_actions = array(); 194 foreach ( $actions as $action => $data ) { 195 if ( current_user_can($data[1]) ) 196 $allowed_actions[$action] = $data[0]; 197 } 198 199 if ( empty($allowed_actions) ) 200 return; 201 202 $first = array_keys($allowed_actions); 203 $first = $first[0]; 204 echo '<div id="favorite-actions">'; 205 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>'; 206 echo '<div id="favorite-inside">'; 207 208 array_shift($allowed_actions); 209 210 foreach ( $allowed_actions as $action => $label) { 211 echo "<div class='favorite-action'><a href='$action'>"; 212 echo $label; 213 echo "</a></div>\n"; 214 } 215 echo "</div></div>\n"; 70 216 } 71 217 … … 78 224 * @return object An object containing the safe screen name and id 79 225 */ 80 function convert_to_screen( $screen ) { // TODO: fold into WP_Screen?226 function convert_to_screen( $screen ) { 81 227 $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen); 82 228 … … 86 232 $screen .= '-user'; 87 233 88 // why do we need this?$screen = (string) apply_filters( 'screen_meta_screen', $screen );234 $screen = (string) apply_filters( 'screen_meta_screen', $screen ); 89 235 $screen = (object) array('id' => $screen, 'base' => $screen); 90 236 return $screen; 91 237 } 92 238 93 function screen_icon( $for = '' ) { // TODO: fold into WP_Screen? 94 global $current_screen; 95 96 if ( !isset($current_screen) ) 239 /** 240 * Add contextual help text for a page. 241 * 242 * Creates a 'Screen Info' help tab. 243 * 244 * @since 2.7.0 245 * 246 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions. 247 * @param string $help The content of a 'Screen Info' help tab. 248 * 249 * @todo: deprecate? 250 */ 251 function add_contextual_help($screen, $help) { 252 global $_wp_contextual_help; 253 254 if ( is_string($screen) ) 255 $screen = convert_to_screen($screen); 256 257 if ( !isset($_wp_contextual_help) ) 258 $_wp_contextual_help = array(); 259 260 $_wp_contextual_help[$screen->id] = $help; 261 } 262 263 /** 264 * Register and configure an admin screen option 265 * 266 * @since 3.1.0 267 * 268 * @param string $option An option name. 269 * @param mixed $args Option dependent arguments 270 * @return void 271 */ 272 function add_screen_option( $option, $args = array() ) { 273 $current_screen = get_current_screen(); 274 275 if ( ! $current_screen ) 97 276 return; 98 277 99 echo $current_screen->get_screen_icon( $for ); 278 return $current_screen->add_option( $option, $args ); 279 } 280 281 function screen_icon( $screen = '' ) { 282 echo get_screen_icon( $screen ); 283 } 284 285 function get_screen_icon( $screen = '' ) { 286 global $current_screen, $typenow; 287 288 if ( empty($screen) ) 289 $screen = $current_screen; 290 elseif ( is_string($screen) ) 291 $name = $screen; 292 293 $class = 'icon32'; 294 295 if ( empty($name) ) { 296 if ( !empty($screen->parent_base) ) 297 $name = $screen->parent_base; 298 else 299 $name = $screen->base; 300 301 if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type ) 302 $name = 'edit-pages'; 303 304 $post_type = ''; 305 if ( isset( $screen->post_type ) ) 306 $post_type = $screen->post_type; 307 elseif ( $current_screen == $screen ) 308 $post_type = $typenow; 309 if ( $post_type ) 310 $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type ); 311 } 312 313 return '<div id="icon-' . esc_attr( $name ) . '" class="' . $class . '"><br /></div>'; 100 314 } 101 315 … … 125 339 * @param string $id Screen id, optional. 126 340 */ 127 function set_current_screen( $id = '' ) {341 function set_current_screen( $id = '' ) { 128 342 global $current_screen; 129 343 130 if ( !is_a( $current_screen, 'WP_Screen' ) ) 131 $current_screen = new WP_Screen( $id ); 132 133 // why do we need this? $current_screen = apply_filters('current_screen', $current_screen); 344 $current_screen = new WP_Screen( $id ); 345 346 $current_screen = apply_filters('current_screen', $current_screen); 134 347 } 135 348 … … 252 465 * @access private 253 466 */ 254 private $_options = array( 255 '_context' => '', 256 '_screen_settings' => '' 257 ); 258 259 /** 260 * Show screen options if any. 467 private $_options = array(); 468 469 470 /** 471 * Stores the result of the public show_screen_options function. 261 472 * 262 473 * @since 3.3.0 … … 264 475 * @access private 265 476 */ 266 private $_show_options = false; 477 private $_show_screen_options; 478 479 /** 480 * Stores the 'screen_settings' section of screen options. 481 * 482 * @since 3.3.0 483 * @var string 484 * @access private 485 */ 486 private $_screen_settings; 267 487 268 488 /** … … 281 501 $screen = $hook_suffix; 282 502 $screen = str_replace('.php', '', $screen); 283 284 503 if ( preg_match('/-add|-new$/', $screen) ) 285 504 $action = 'add'; 286 287 505 $screen = str_replace('-new', '', $screen); 288 506 $screen = str_replace('-add', '', $screen); … … 290 508 } else { 291 509 $id = sanitize_key( $id ); 292 293 510 if ( false !== strpos($id, '-') ) { 294 511 list( $id, $typenow ) = explode('-', $id, 2); 295 296 512 if ( taxonomy_exists( $typenow ) ) { 297 513 $id = 'edit-tags'; … … 308 524 if ( 'index' == $this->base ) 309 525 $this->base = 'dashboard'; 310 311 526 if ( 'index' == $this->id ) 312 527 $this->id = 'dashboard'; … … 315 530 if ( empty($typenow) ) 316 531 $typenow = 'post'; 317 318 532 $this->id .= '-' . $typenow; 319 533 $this->post_type = $typenow; … … 321 535 if ( empty($typenow) ) 322 536 $typenow = 'post'; 323 324 537 $this->id = $typenow; 325 538 $this->post_type = $typenow; … … 327 540 if ( empty($taxnow) ) 328 541 $taxnow = 'post_tag'; 329 330 542 $this->id = 'edit-' . $taxnow; 331 543 $this->taxonomy = $taxnow; … … 360 572 /** 361 573 * Adds an option for the screen. 362 * Use the 'add_screen_help_and_options' actionto add screen options.574 * Call this in template files after admin.php is loaded and before admin-header.php is loaded to add screen options. 363 575 * 364 576 * @since 3.3.0 365 577 * 366 578 * @param string $option Option ID 367 * @param mixed $args Associative array of arguments particular to the default $option or the HTML string to be printed in the Screen Options tab. 368 */ 369 public function add_option( $option, $args = null ) { 370 if ( is_array($args) && !empty($option) ) 371 $this->_options[ $option ] = $args; 372 elseif ( is_string($option) ) 373 $this->_options['_screen_settings'] .= $option; 374 else 375 return false; 376 377 $this->_show_options = true; 378 return true; 379 } 380 381 /** 382 * Adds option context. 383 * Use the 'add_screen_help_and_options' action to add it. Will not be shown if there aren't any screen options. 384 * 385 * @since 3.3.0 386 * 387 * @param string $text 388 */ 389 public function add_option_context( $text ) { 390 $this->_options['_context'] .= $text; 579 * @param array $args Associative array of arguments particular to the given $option. 580 */ 581 public function add_option( $option, $args = array() ) { 582 $this->_options[ $option ] = $args; 391 583 } 392 584 393 585 /** 394 586 * Add a help tab to the contextual help for the screen. 395 * Use the 'add_screen_help_and_options' actionto add contextual help tabs.587 * Call this in template files after admin.php is loaded and before admin-header.php is loaded to add contextual help tabs. 396 588 * 397 589 * @since 3.3.0 … … 399 591 * @param array $args 400 592 * - string - title - Title for the tab. 401 * - string - id - Tab ID. 402 * - string - section - Section title for the tab. Optional. 593 * - string - id - Tab ID. Optional. 403 594 * - string - content - Help tab content in plain text or HTML. Optional. 404 595 * - callback - callback - A callback to generate the tab content. Optional. … … 409 600 'title' => false, 410 601 'id' => false, 411 'section' => false,412 602 'content' => '', 413 'callback' => false 603 'callback' => false, 414 604 ); 415 605 $args = wp_parse_args( $args, $defaults ); 416 606 417 // Ensure we have title and ID. 418 if ( ! $args['title'] || ! $args['id'] ) 419 return false; 607 // Ensure we have a title. 608 if ( ! $args['title'] ) 609 return; 610 611 // Create an id from the title if one is not provided. 612 if ( ! $args['id'] ) 613 $args['id'] = sanitize_html_class( $args['title'] ); 420 614 421 615 $this->_help_tabs[] = $args; 422 return true;423 616 } 424 617 425 618 /** 426 619 * Add a sidebar to the contextual help for the screen. 427 * Use the 'add_screen_help_and_options' actionto add a sidebar to the contextual help.620 * Call this in template files after admin.php is loaded and before admin-header.php is loaded to add a sidebar to the contextual help. 428 621 * 429 622 * @since 3.3.0 … … 432 625 */ 433 626 public function add_help_sidebar( $content ) { 434 if ( empty($this->_help_sidebar) ) // add only one 435 $this->_help_sidebar = $content; 627 $this->_help_sidebar = $content; 436 628 } 437 629 … … 445 637 public function render_screen_meta() { 446 638 global $_wp_contextual_help; 447 448 // Intended for adding Help and Screen Options.449 do_action('add_screen_help_and_options', $this);450 639 451 640 // Call old contextual_help_list filter. 452 641 if ( ! isset( $_wp_contextual_help ) ) 453 642 $_wp_contextual_help = array(); 454 455 // why are we filtering a global? $_wp_contextual_help = apply_filters( 'contextual_help_list', $_wp_contextual_help, $this ); 643 $_wp_contextual_help = apply_filters( 'contextual_help_list', $_wp_contextual_help, $this ); 456 644 457 645 if ( isset( $_wp_contextual_help[ $this->id ] ) ) { 458 646 // Call old contextual_help filter. 459 // why are we filtering the same global second time??460 647 $contextual_help = apply_filters( 'contextual_help', $_wp_contextual_help[ $this->id ], $this->id, $this ); 461 648 462 649 $this->add_help_tab( array( 463 'title' => __('Screen Info'), 464 'id' => 'screen-info', 465 'content' => $_wp_contextual_help[ $this->id ] 650 'title' => __('Screen Info'), 651 'content' => $contextual_help, 652 ) ); 653 } 654 655 // Add screen options tab 656 if ( $this->show_screen_options() ) { 657 $this->add_help_tab( array( 658 'title' => __('Screen Options'), 659 'callback' => array( $this, 'render_screen_options' ), 466 660 ) ); 467 661 } … … 474 668 <div class="contextual-help-tabs"> 475 669 <ul> 476 <?php 477 478 if ( $this->_show_options ) {479 $class = true;670 <?php foreach ( $this->_help_tabs as $i => $tab ): 671 $link_id = "tab-link-{$tab['id']}"; 672 $panel_id = "tab-panel-{$tab['id']}"; 673 $classes = ( $i == 0 ) ? 'active' : ''; 480 674 ?> 481 <li id="tab-link-screen-options" class="active"> 482 <a href="#tab-panel-screen-options"> 483 <?php _e('Screen Options'); ?> 484 </a> 485 </li> 486 <?php 487 } 488 489 foreach ( $this->_help_tabs as $i => $tab ) { 490 $id = esc_attr($tab['id']); 491 $class = empty($class) && $i == 0 ? ' class="active"' : ''; 492 ?> 493 <li id="<?php echo "tab-link-$id"; ?>"<?php echo $class; ?>> 494 <a href="<?php echo "#tab-panel-$id"; ?>"> 675 676 <li id="<?php echo esc_attr( $link_id ); ?>" class="<?php echo esc_attr( $classes ); ?>"> 677 <a href="<?php echo esc_url( "#$panel_id" ); ?>"> 495 678 <?php echo esc_html( $tab['title'] ); ?> 496 679 </a> 497 680 </li> 498 <?php }?>681 <?php endforeach; ?> 499 682 </ul> 500 683 </div> 501 <?php 502 503 if ( $this->_help_sidebar ) 504 echo '<div class="contextual-help-sidebar">' . $this->_help_sidebar . '</div>'; 505 506 ?> 684 685 <div class="contextual-help-sidebar"> 686 <?php echo $this->_help_sidebar; ?> 687 </div> 688 507 689 <div class="contextual-help-tabs-wrap"> 508 <?php 509 510 if ( $this->_show_options ) { 511 $class2 = true; 512 echo '<div id="tab-panel-screen-options" class="help-tab-content active">'; 513 514 if ( !empty($this->_options['_context']) ) 515 echo $this->_options['_context']; 516 517 $this->render_screen_options(); 518 echo '</div>'; 519 } 520 521 foreach ( $this->_help_tabs as $i => $tab ) { 522 $class2 = empty($class2) && $i == 0 ? ' active' : ''; 690 <?php foreach ( $this->_help_tabs as $i => $tab ): 691 $panel_id = "tab-panel-{$tab['id']}"; 692 $classes = ( $i == 0 ) ? 'active' : ''; 693 $classes .= ' help-tab-content'; 523 694 ?> 524 695 525 <div id="<?php echo esc_attr( "tab-panel-{$tab['id']}" ); ?>" class="help-tab-content<?php echo $class2; ?>"> 696 <div id="<?php echo esc_attr( $panel_id ); ?>" class="<?php echo esc_attr( $classes ); ?>"> 697 <h3><?php echo esc_html( $tab['title'] ); ?></h3> 526 698 <?php 527 if ( $tab['section'] )528 echo '<h3>' . esc_html( $tab['section'] ) . '</h3>';529 530 699 // Print tab content. 531 700 echo $tab['content']; … … 536 705 ?> 537 706 </div> 538 <?php }?>707 <?php endforeach; ?> 539 708 </div> 540 709 </div> … … 543 712 } 544 713 545 /** 546 * Render the screen options tab. 547 * 548 * @since 3.3.0 549 */ 550 public function render_screen_options() { 551 552 $screen_settings = $this->_options['_screen_settings']; 553 554 // Default screen_settings for various screens. 555 // TODO: should probably be set on these screens, not here. 714 public function show_screen_options() { 715 global $wp_meta_boxes, $wp_list_table; 716 717 if ( is_bool( $this->_show_screen_options ) ) 718 return $this->_show_screen_options; 719 720 $columns = get_column_headers( $this ); 721 722 $show_screen = false; 723 if ( ! empty( $wp_meta_boxes[ $this->id ] ) || ! empty( $columns ) ) 724 $show_screen = true; 725 726 // Check if there are per-page options. 727 $show_screen = $show_screen || isset( $this->_options['per_page'] ); 728 729 $this->_screen_settings = apply_filters( 'screen_settings', '', $this ); 730 556 731 switch ( $this->id ) { 557 732 case 'widgets': 558 $screen_settings .= '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n"; 733 $this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n"; 734 $show_screen = true; 559 735 break; 560 736 } 561 737 562 // TODO: deprecate 563 $screen_settings = apply_filters( 'screen_settings', $screen_settings, $this ); 564 565 echo '<form id="adv-settings" action="" method="post">'; 566 567 $this->render_table_columns_prefs(); 568 $this->render_metabox_prefs(); 569 $this->render_screen_layout(); 570 $this->render_per_page_options(); 571 echo $screen_settings; 572 573 wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); 574 echo '</form>'; 575 576 } 577 578 /** 579 * Render the option for hiding table columns on the page 580 * 581 * @since 3.3.0 582 */ 583 function render_table_columns_prefs() { 738 if ( ! empty( $this->_screen_settings ) ) 739 $show_screen = true; 740 741 if ( ! empty( $this->_options ) ) 742 $show_screen = true; 743 744 $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this ); 745 return $this->_show_screen_options; 746 } 747 748 /** 749 * Render the screen options tab. 750 * 751 * @since 3.3.0 752 */ 753 public function render_screen_options() { 754 global $wp_meta_boxes, $wp_list_table; 755 584 756 $columns = get_column_headers( $this ); 585 586 if ( ! empty( $columns ) ) { 587 $hidden = get_hidden_columns( $this ); 588 ?> 757 $hidden = get_hidden_columns( $this ); 758 759 ?> 760 <form id="adv-settings" action="" method="post"> 761 <?php if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?> 762 <h5><?php _ex('Show on screen', 'Metaboxes') ?></h5> 763 <div class="metabox-prefs"> 764 <?php meta_box_prefs( $this ); ?> 765 <br class="clear" /> 766 </div> 767 <?php endif; 768 if ( ! empty( $columns ) ) : ?> 589 769 <h5><?php echo ( isset( $columns['_title'] ) ? $columns['_title'] : _x('Show on screen', 'Columns') ) ?></h5> 590 770 <div class="metabox-prefs"> … … 601 781 if ( 'comments' == $column ) 602 782 $title = __( 'Comments' ); 603 604 783 $id = "$column-hide"; 605 784 echo '<label for="' . $id . '">'; … … 610 789 <br class="clear" /> 611 790 </div> 612 <?php } 613 } 614 615 /** 616 * Render the option for hiding metaboxes on the page 617 * 618 * @since 3.3.0 619 */ 620 function render_metabox_prefs() { 621 global $wp_meta_boxes; 622 623 if ( !empty( $wp_meta_boxes[ $this->id ] ) ) { 624 $hidden = get_hidden_meta_boxes($this); 625 ?> 626 <h5><?php _ex('Show on screen', 'Metaboxes') ?></h5> 627 <div class="metabox-prefs"> 628 <?php 629 630 foreach ( array_keys($wp_meta_boxes[$this->id]) as $context ) { 631 foreach ( array_keys($wp_meta_boxes[$this->id][$context]) as $priority ) { 632 foreach ( $wp_meta_boxes[$this->id][$context][$priority] as $box ) { 633 if ( false == $box || ! $box['title'] ) 634 continue; 635 // Submit box cannot be hidden 636 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) 637 continue; 638 $box_id = $box['id']; 639 echo '<label for="' . $box_id . '-hide">'; 640 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"' : '') . ' />'; 641 echo "{$box['title']}</label>\n"; 642 } 643 } 644 } 645 646 ?> 647 <br class="clear" /> 648 </div> 649 <?php 650 } 791 <?php endif; 792 793 $this->render_screen_layout(); 794 $this->render_per_page_options(); 795 echo $this->_screen_settings; 796 797 ?> 798 <div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div> 799 </form> 800 <?php 651 801 } 652 802 … … 660 810 661 811 // Back compat for plugins using the filter instead of add_screen_option() 662 // TODO: deprecate it663 812 $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this ); 664 813 665 814 if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) 666 $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) );815 add_screen_option( 'layout_columns', array('max' => $columns[ $this->id ] ) ); 667 816 668 817 if ( ! isset( $this->_options['layout_columns'] ) ) { … … 702 851 */ 703 852 function render_per_page_options() { 704 if ( empty( $this->_options['per_page'] ) )853 if ( ! isset( $this->_options['per_page'] ) ) 705 854 return; 706 855 … … 751 900 <?php 752 901 } 753 754 function get_screen_icon( $for = '' ) { 755 756 if ( !empty($for) && is_string($for) ) { 757 $name = $for; 758 } else { 759 if ( !empty($this->parent_base) ) 760 $name = $this->parent_base; 761 else 762 $name = $this->base; 763 } 764 765 if ( 'edit' == $name && isset($this->post_type) && 'page' == $this->post_type ) 766 $name = 'edit-pages'; 767 768 $class = ''; 769 if ( !empty( $this->post_type ) ) 770 $class = ' ' . sanitize_html_class( 'icon32-posts-' . $this->post_type ); 771 772 return '<div id="icon-' . esc_attr( $name ) . '" class="icon32' . $class . '"><br /></div>'; 773 } 774 } 775 902 }
Note: See TracChangeset
for help on using the changeset viewer.