Ticket #21583: 21583.12.diff
File 21583.12.diff, 28.8 KB (added by , 12 years ago) |
---|
-
wp-includes/admin-bar.php
657 657 ) ); 658 658 } 659 659 660 function wp_admin_bar_screen_options( $wp_admin_bar ) { 661 662 if ( get_current_screen()->show_screen_options() ) { 663 $wp_admin_bar->add_menu( array( 664 'parent' => 'top-secondary', 665 'id' => 'screen-options', 666 'title' => '<span class="ab-icon"></span>', 667 'href' => '', 668 ) ); 669 670 get_current_screen()->render_options( 'screen-options', $wp_admin_bar ); 671 } 672 673 $wp_admin_bar->add_menu( array( 674 'parent' => 'top-secondary', 675 'id' => 'screen-help', 676 'title' => 'Help<span class="ab-icon"></span>', 677 'href' => '', 678 ) ); 679 680 get_current_screen()->render_help( 'screen-help', $wp_admin_bar ); 681 } 660 682 /** 661 683 * Add secondary menus. 662 684 * -
wp-includes/js/admin-bar.js
10 10 node.attr('tabindex', '0').attr('tabindex', tab); 11 11 }; 12 12 13 $('#wpadminbar').removeClass('nojq').removeClass('nojs').find('li.menupop'). hoverIntent({13 $('#wpadminbar').removeClass('nojq').removeClass('nojs').find('li.menupop').not('.sticky').hoverIntent({ 14 14 over: function(e){ 15 15 $(this).addClass('hover'); 16 heightCheck($(this)); 16 17 }, 17 18 out: function(e){ 18 19 $(this).removeClass('hover'); … … 22 23 interval: 100 23 24 }); 24 25 26 $('.sticky', '#wpadminbar').click(function(e){ 27 e.preventDefault(); 28 $(this).toggleClass('hover'); 29 }); 30 25 31 $('#wp-admin-bar-get-shortlink').click(function(e){ 26 32 e.preventDefault(); 27 33 $(this).addClass('selected').children('.shortlink-input').blur(function(){ … … 66 72 e.preventDefault(); 67 73 $('html, body').animate({ scrollTop: 0 }, 'fast'); 68 74 }); 75 76 69 77 70 78 }); 79 80 function heightCheck( menu ) { 81 // Add overflow if sub menu height exceeds window height 82 var wHeight = jQuery(window).height(), 83 toolbarPlusPadding = 28 + 23, 84 subWrapper = menu.find('.ab-sub-wrapper'), 85 subMenuHeight = subWrapper.height() + toolbarPlusPadding; 86 87 if ( subMenuHeight > wHeight ) 88 subWrapper.css({ 'overflow-y': 'auto', 'overflow-x': 'hidden', 'height': wHeight - toolbarPlusPadding + 'px'}); 89 } 90 71 91 } else { 72 92 (function(d, w) { 73 93 var addEvent = function( obj, type, fn ) { -
wp-includes/css/admin-bar.css
310 310 } 311 311 312 312 /** 313 * Screen Options 314 */ 315 316 #wpadminbar #wp-admin-bar-screen-options ul { 317 min-width: 200px; 318 padding: 0 0 15px; 319 } 320 321 #wpadminbar #wp-admin-bar-screen-options li { 322 padding: 0 12px; 323 } 324 325 #wpadminbar #wp-admin-bar-screen-options h5 { 326 padding: 15px 0 0; 327 color: #888; 328 font-size: 11px; 329 text-transform: uppercase; 330 } 331 332 #wpadminbar #wp-admin-bar-screen-options label { 333 display: block; 334 } 335 336 #wpadminbar #wp-admin-bar-per-page-1 label { 337 display: inline; 338 } 339 340 #wpadminbar li.ab-title:hover, 341 #wpadminbar li.ab-title:focus, 342 #wpadminbar li.ab-inline:hover, 343 #wpadminbar li.ab-inline:focus { 344 background: transparent; 345 } 346 347 #wpadminbar li#wp-admin-bar-column-layout, 348 #wpadminbar li#wp-admin-bar-per-page { 349 margin-top: 15px; 350 border-top: 1px solid #e0e0e0; 351 } 352 353 #wpadminbar li.ab-inline { 354 display: inline-block; 355 padding-right: 5px !important; 356 } 357 358 #wpadminbar #wp-admin-bar-screen-options li.ab-inline * { 359 display: inline; 360 } 361 362 #wpadminbar #wp-admin-bar-screen-options input[type=checkbox] { 363 float: left; 364 margin: 7px 10px 1px 0; 365 } 366 367 #wpadminbar #wp-admin-bar-screen-options input[type=radio] { 368 float: left; 369 margin: 7px 5px 1px 0; 370 } 371 372 #wpadminbar #wp-admin-bar-screen-options .postbox-title-action { 373 display: none; 374 } 375 376 #wpadminbar input[type='number'] { 377 padding-left: 7px; 378 color: #888; 379 text-shadow: none; 380 } 381 382 383 /** 313 384 * My Account 314 385 */ 315 386 #wp-admin-bar-my-account > ul { … … 517 588 } 518 589 519 590 /** 591 * Sticky menu toggle arrows 592 */ 593 #wpadminbar .sticky .sticky-indicator { 594 position: relative; 595 float: right; 596 width: 20px; 597 height: 16px; 598 margin-top: 6px; 599 background-image: url("../images/admin-bar-sprite.png"); 600 background-position: 0 -254px; 601 background-repeat: no-repeat; 602 cursor: pointer; 603 } 604 605 #wpadminbar .sticky.hover .sticky-indicator { 606 background-position: 0 -228px; 607 } 608 609 /** 520 610 * WP Logo icon 521 611 */ 522 612 #wp-admin-bar-wp-logo > .ab-item .ab-icon { … … 573 663 } 574 664 575 665 /** 666 * Screen Settings icon 667 */ 668 #wpadminbar #wp-admin-bar-screen-options > .ab-item .ab-icon { 669 background-image: url(../images/admin-bar-sprite.png?d=20111130); 670 background-position: -3px -252px; 671 background-repeat: no-repeat; 672 } 673 674 #wpadminbar.nojs #wp-admin-bar-screen-options:hover > .ab-item .ab-icon, 675 #wpadminbar #wp-admin-bar-screen-options.hover > .ab-item .ab-icon { 676 background-image: url(../images/admin-bar-sprite.png?d=20111130); 677 background-position: -3px -228px; 678 background-repeat: no-repeat; 679 } 680 681 /** 576 682 * Customize support classes 577 683 */ 578 684 .no-customize-support .hide-if-no-customize, … … 590 696 #wp-admin-bar-wp-logo > .ab-item .ab-icon, 591 697 #wp-admin-bar-updates > .ab-item .ab-icon, 592 698 #wp-admin-bar-comments > .ab-item .ab-icon, 593 #wpadminbar #wp-admin-bar-new-content > .ab-item .ab-icon { 594 background-image: url(../images/admin-bar-sprite-2x.png?d=20120830); 595 background-size: 20px 220px; 699 #wpadminbar #wp-admin-bar-new-content > .ab-item .ab-icon, 700 #wpadminbar #wp-admin-bar-screen-options > .ab-item .ab-icon, 701 #wpadminbar .sticky .sticky-indicator { 702 background-image: url( "../images/admin-bar-sprite-2x.png?d=20120830" ); 703 background-size: 20px 276px; 596 704 } 597 705 } 598 706 -
wp-includes/class-wp-admin-bar.php
104 104 'parent' => false, 105 105 'href' => false, 106 106 'group' => false, 107 'sticky' => false, 107 108 'meta' => array(), 108 109 ); 109 110 … … 396 397 397 398 $is_parent = ! empty( $node->children ); 398 399 $has_link = ! empty( $node->href ); 400 $has_title = ! empty( $node->title ); 401 $is_sticky = $node->sticky === true ? true : false; 399 402 400 403 $tabindex = isset( $node->meta['tabindex'] ) ? (int) $node->meta['tabindex'] : ''; 401 404 $aria_attributes = $tabindex ? 'tabindex="' . $tabindex . '"' : ''; … … 410 413 if ( ! empty( $node->meta['class'] ) ) 411 414 $menuclass .= $node->meta['class']; 412 415 416 if ( $is_sticky ) 417 $menuclass .= 'sticky'; 418 413 419 if ( $menuclass ) 414 420 $menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"'; 415 421 416 422 ?> 417 423 418 424 <li id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $menuclass; ?>><?php 419 if ( $has_link ): 420 ?><a class="ab-item" <?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php 421 if ( ! empty( $node->meta['onclick'] ) ) : 422 ?> onclick="<?php echo esc_js( $node->meta['onclick'] ); ?>"<?php 425 if ( $has_title ): 426 if ( $has_link ): 427 ?><a class="ab-item" <?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php 428 if ( ! empty( $node->meta['onclick'] ) ) : 429 ?> onclick="<?php echo esc_js( $node->meta['onclick'] ); ?>"<?php 430 endif; 431 if ( ! empty( $node->meta['target'] ) ) : 432 ?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php 423 433 endif; 424 if ( ! empty( $node->meta['target'] ) ) : 425 ?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php 434 if ( ! empty( $node->meta['title'] ) ) : 435 ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php 436 endif; 437 ?>><?php 438 else: 439 ?><a href="#" onclick="return false;" class="ab-item ab-empty-item" <?php echo $aria_attributes; 440 if ( ! empty( $node->meta['title'] ) ) : 441 ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php 442 endif; 443 ?>><?php 426 444 endif; 427 if ( ! empty( $node->meta['title'] ) ) : 428 ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php 445 446 echo $node->title; 447 448 if ( $is_sticky ) : 449 ?><span class="sticky-indicator"></span><?php 429 450 endif; 430 ?>><?php 431 else:432 ?><div class="ab-item ab-empty-item" <?php echo $aria_attributes;433 if ( ! empty( $node->meta['title'] ) ):434 ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php451 452 if ( $has_link ) : 453 ?></a><?php 454 else: 455 ?></a><?php 435 456 endif; 436 ?>><?php437 457 endif; 438 458 439 echo $node->title;440 441 if ( $has_link ) :442 ?></a><?php443 else:444 ?></div><?php445 endif;446 447 459 if ( $is_parent ) : 448 460 ?><div class="ab-sub-wrapper"><?php 449 461 foreach ( $node->children as $group ) { … … 455 467 if ( ! empty( $node->meta['html'] ) ) 456 468 echo $node->meta['html']; 457 469 470 if ( ! empty( $node->meta['html_callback'] ) ) 471 call_user_func( $node->meta['html_callback'] ); 458 472 ?> 459 473 </li><?php 460 474 } … … 483 497 } 484 498 add_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 ); 485 499 500 if ( is_admin() ) 501 add_action( 'admin_bar_menu', 'wp_admin_bar_screen_options', 90 ); 502 486 503 add_action( 'admin_bar_menu', 'wp_admin_bar_add_secondary_groups', 200 ); 487 504 488 505 do_action( 'add_admin_bar_menus' ); -
wp-admin/includes/screen.php
49 49 * @param string|WP_Screen $screen 50 50 */ 51 51 function meta_box_prefs( $screen ) { 52 global $wp_meta_boxes; 53 54 if ( is_string( $screen ) ) 55 $screen = convert_to_screen( $screen ); 56 57 if ( empty($wp_meta_boxes[$screen->id]) ) 58 return; 59 60 $hidden = get_hidden_meta_boxes($screen); 61 62 foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) { 63 foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) { 64 foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) { 65 if ( false == $box || ! $box['title'] ) 66 continue; 67 // Submit box cannot be hidden 68 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) 69 continue; 70 $box_id = $box['id']; 71 echo '<label for="' . $box_id . '-hide">'; 72 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"' : '') . ' />'; 73 echo "{$box['title']}</label>\n"; 74 } 75 } 76 } 52 return; 77 53 } 78 54 79 55 /** … … 754 730 * @since 3.3.0 755 731 */ 756 732 public function render_screen_meta() { 733 return; 734 } 757 735 736 public function show_screen_options() { 737 global $wp_meta_boxes; 738 739 if ( is_bool( $this->_show_screen_options ) ) 740 return $this->_show_screen_options; 741 742 $columns = get_column_headers( $this ); 743 744 $show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' ); 745 746 $this->_screen_settings = apply_filters( 'screen_settings', '', $this ); 747 748 switch ( $this->id ) { 749 case 'widgets': 750 $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"; 751 break; 752 } 753 754 if ( $this->_screen_settings || $this->_options ) 755 $show_screen = true; 756 757 $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this ); 758 return $this->_show_screen_options; 759 } 760 761 /** 762 * Render the screen options tab. 763 * 764 * @since 3.3.0 765 */ 766 public function render_screen_options() { 767 return; 768 } 769 770 /* 771 * Render screen options in the admin bar 772 * 773 */ 774 function render_options( $parent, $wp_admin_bar ) { 775 $this->render_show_on_screen( $parent, $wp_admin_bar ); 776 $this->render_layout( $parent, $wp_admin_bar ); 777 $this->render_per_page( $parent, $wp_admin_bar ); 778 // @todo $this->_screen_settings 779 } 780 781 function render_show_on_screen( $parent, $wp_admin_bar ) { 782 global $wp_meta_boxes; 783 784 if ( ! $this->show_screen_options() ) 785 return; 786 787 $columns = get_column_headers( $this ); 788 789 if ( ! isset( $wp_meta_boxes[ $this->id ] ) && ( ! $columns || isset( $columns['_title'] ) ) ) 790 return; 791 792 $wp_admin_bar->add_menu( array( 793 'id' => 'show-on-screen', 794 'parent' => $parent, 795 'href' => '', 796 'meta' => array( 797 'html' => '<h5 class="ab-item">' . __( 'Show on screen' ) . '</h5>', 798 'class' => 'ab-title' 799 ), 800 ) ); 801 802 // Render meta box show/hide. 803 if ( isset( $wp_meta_boxes[ $this->id ] ) ) { 804 $hidden = get_hidden_meta_boxes($this); 805 806 foreach ( array_keys($wp_meta_boxes[$this->id]) as $context ) { 807 foreach ( array_keys($wp_meta_boxes[$this->id][$context]) as $priority ) { 808 foreach ( $wp_meta_boxes[$this->id][$context][$priority] as $box ) { 809 if ( false == $box || ! $box['title'] ) 810 continue; 811 // Submit box cannot be hidden 812 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) 813 continue; 814 $box_id = $box['id']; 815 $html = '<label class="ab-item" for="' . $box_id . '-hide">' . 816 '<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"' : '') . ' />' . 817 "{$box['title']}</label>\n"; 818 $wp_admin_bar->add_menu( array( 819 'id' => 'show-on-screen-' . $box_id, 820 'parent' => $parent, 821 'href' => '', 822 'meta' => array( 'html' => $html ), 823 ) ); 824 } 825 } 826 } 827 828 if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) { 829 if ( isset( $_GET['welcome'] ) ) { 830 $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; 831 update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); 832 } else { 833 $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); 834 if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) 835 $welcome_checked = false; 836 } 837 $html = '<label class="ab-item" for="wp_welcome_panel-hide">' . 838 '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />' . 839 _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; 840 $wp_admin_bar->add_menu( array( 841 'id' => 'show-on-screen-' . $box_id, 842 'parent' => $parent, 843 'href' => '', 844 'meta' => array( 'html' => $html ), 845 ) ); 846 } 847 } 848 849 // Render column show/hide. 850 if ( $columns ) { 851 $hidden = get_hidden_columns( $this ); 852 853 if ( ! empty( $columns['_title'] ) ) { 854 echo '<h5>' . $columns['_title'] . '</h5>'; 855 } 856 857 $special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' ); 858 859 foreach ( $columns as $column => $title ) { 860 // Can't hide these for they are special 861 if ( in_array( $column, $special ) ) 862 continue; 863 if ( empty( $title ) ) 864 continue; 865 866 if ( 'comments' == $column ) 867 $title = __( 'Comments' ); 868 $id = "$column-hide"; 869 $html = '<label class="ab-item" for="' . $id . '">' . 870 '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />' . 871 "$title</label>\n"; 872 $wp_admin_bar->add_menu( array( 873 'id' => 'show-on-screen-' . $column, 874 'parent' => $parent, 875 'href' => '', 876 'meta' => array( 'html' => $html ), 877 ) ); 878 } 879 } 880 } 881 882 function render_layout( $parent, $wp_admin_bar ) { 883 // Back compat for plugins using the filter instead of add_screen_option() 884 $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this ); 885 886 if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) 887 $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) ); 888 889 if ( $this->get_option( 'layout_columns' ) ) { 890 $this->columns = (int) get_user_option("screen_layout_$this->id"); 891 892 if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) 893 $this->columns = $this->get_option( 'layout_columns', 'default' ); 894 } 895 $GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat. 896 897 if ( ! $this->get_option('layout_columns') ) 898 return; 899 900 $screen_layout_columns = $this->get_columns(); 901 $num = $this->get_option( 'layout_columns', 'max' ); 902 903 $wp_admin_bar->add_menu( array( 904 'id' => 'column-layout', 905 'parent' => $parent, 906 'href' => '', 907 'meta' => array( 908 'html' => '<h5 class="ab-item">' . __( 'Column Layout' ) . '</h5>', 909 'class' => 'ab-title' 910 ), 911 ) ); 912 913 for ( $i = 1; $i <= $num; ++$i ) { 914 $html = '<label class="ab-item columns-prefs columns-prefs-' . $i . '">' . 915 "<input type='radio' name='screen_columns' value='" . $i . "'" . 916 checked( $screen_layout_columns, $i, false ) . '/>' . 917 esc_html( $i ) . 918 '</label>'; 919 920 $wp_admin_bar->add_menu( array( 921 'id' => 'column-layout-' . $i, 922 'parent' => $parent, 923 'href' => '', 924 'meta' => array( 925 'html' => $html, 926 'class' => 'ab-inline' 927 ), 928 ) ); 929 } 930 } 931 932 /** 933 * Render the items per page option 934 * 935 * @since 3.5.0 936 */ 937 function render_per_page( $parent, $wp_admin_bar ) { 938 // @todo form and nonce 939 // wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); 940 941 if ( ! $this->get_option( 'per_page' ) ) 942 return; 943 944 $per_page_label = $this->get_option( 'per_page', 'label' ); 945 946 $option = $this->get_option( 'per_page', 'option' ); 947 if ( ! $option ) 948 $option = str_replace( '-', '_', "{$this->id}_per_page" ); 949 950 $per_page = (int) get_user_option( $option ); 951 if ( empty( $per_page ) || $per_page < 1 ) { 952 $per_page = $this->get_option( 'per_page', 'default' ); 953 if ( ! $per_page ) 954 $per_page = 20; 955 } 956 957 if ( 'edit_comments_per_page' == $option ) { 958 $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; 959 $per_page = apply_filters( 'comments_per_page', $per_page, $comment_status ); 960 } elseif ( 'categories_per_page' == $option ) { 961 $per_page = apply_filters( 'edit_categories_per_page', $per_page ); 962 } else { 963 $per_page = apply_filters( $option, $per_page ); 964 } 965 966 // Back compat 967 if ( isset( $this->post_type ) ) 968 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type ); 969 970 $wp_admin_bar->add_menu( array( 971 'id' => 'per-page', 972 'parent' => $parent, 973 'href' => '', 974 'meta' => array( 975 'html' => '<h5 class="ab-item">' . __( 'Items Per Page' ) . '</h5>', 976 'class' => 'ab-title' 977 ), 978 ) ); 979 980 if ( $per_page_label ) { 981 $html = '<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]" 982 id="' . esc_attr( $option ) . '" maxlength="3" value="' . esc_attr( $per_page ) . '" />'; 983 $wp_admin_bar->add_menu( array( 984 'id' => 'per-page-1', 985 'parent' => $parent, 986 'href' => '', 987 'meta' => array( 988 'html' => $html, 989 'class' => 'ab-inline' 990 ), 991 ) ); 992 } 993 994 $html = get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ) . 995 "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />"; 996 997 $wp_admin_bar->add_menu( array( 998 'id' => 'per-page-submit', 999 'parent' => $parent, 1000 'href' => '', 1001 'meta' => array( 1002 'html' => $html, 1003 'class' => 'ab-inline' 1004 ), 1005 ) ); 1006 } 1007 1008 function render_help( $parent, $wp_admin_bar ) { 758 1009 // Call old contextual_help_list filter. 759 1010 self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this ); 760 1011 … … 776 1027 ) ); 777 1028 } 778 1029 1030 $wp_admin_bar->add_menu( array( 1031 'id' => 'contextual-help-content', 1032 'parent' => $parent, 1033 'href' => '', 1034 'meta' => array( 'html_callback' => array( $this, '_render_help' ) ), 1035 ) ); 1036 } 1037 1038 function _render_help() { 779 1039 $help_sidebar = $this->get_help_sidebar(); 780 1040 781 $help_class = 'hidden';782 1041 if ( ! $help_sidebar ) 783 1042 $help_class .= ' no-sidebar'; 784 1043 785 1044 // Time to render! 786 1045 ?> 787 <div id="screen-meta" class="metabox-prefs">788 789 1046 <div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>"> 790 1047 <div id="contextual-help-back"></div> 791 1048 <div id="contextual-help-columns"> … … 841 1098 </div> 842 1099 </div> 843 1100 <?php 844 // Setup layout columns845 846 // Back compat for plugins using the filter instead of add_screen_option()847 $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );848 849 if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) )850 $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) );851 852 if ( $this->get_option( 'layout_columns' ) ) {853 $this->columns = (int) get_user_option("screen_layout_$this->id");854 855 if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) )856 $this->columns = $this->get_option( 'layout_columns', 'default' );857 }858 $GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat.859 860 // Add screen options861 if ( $this->show_screen_options() )862 $this->render_screen_options();863 ?>864 </div>865 <?php866 if ( ! $this->get_help_tabs() && ! $this->show_screen_options() )867 return;868 ?>869 <div id="screen-meta-links">870 <?php if ( $this->get_help_tabs() ) : ?>871 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">872 <a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></a>873 </div>874 <?php endif;875 if ( $this->show_screen_options() ) : ?>876 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">877 <a href="#screen-options-wrap" id="show-settings-link" class="show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e( 'Screen Options' ); ?></a>878 </div>879 <?php endif; ?>880 </div>881 <?php882 1101 } 883 1102 884 public function show_screen_options() {885 global $wp_meta_boxes;886 887 if ( is_bool( $this->_show_screen_options ) )888 return $this->_show_screen_options;889 890 $columns = get_column_headers( $this );891 892 $show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' );893 894 $this->_screen_settings = apply_filters( 'screen_settings', '', $this );895 896 switch ( $this->id ) {897 case 'widgets':898 $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";899 break;900 }901 902 if ( $this->_screen_settings || $this->_options )903 $show_screen = true;904 905 $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );906 return $this->_show_screen_options;907 }908 909 1103 /** 910 * Render the screen options tab.911 *912 * @since 3.3.0913 */914 public function render_screen_options() {915 global $wp_meta_boxes, $wp_list_table;916 917 $columns = get_column_headers( $this );918 $hidden = get_hidden_columns( $this );919 920 ?>921 <div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>">922 <form id="adv-settings" action="" method="post">923 <?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?>924 <h5><?php _e( 'Show on screen' ); ?></h5>925 <?php926 endif;927 928 if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?>929 <div class="metabox-prefs">930 <?php931 meta_box_prefs( $this );932 933 if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) {934 if ( isset( $_GET['welcome'] ) ) {935 $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;936 update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );937 } else {938 $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );939 if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) )940 $welcome_checked = false;941 }942 echo '<label for="wp_welcome_panel-hide">';943 echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';944 echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";945 }946 ?>947 <br class="clear" />948 </div>949 <?php endif;950 if ( $columns ) :951 if ( ! empty( $columns['_title'] ) ) : ?>952 <h5><?php echo $columns['_title']; ?></h5>953 <?php endif; ?>954 <div class="metabox-prefs">955 <?php956 $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname');957 958 foreach ( $columns as $column => $title ) {959 // Can't hide these for they are special960 if ( in_array( $column, $special ) )961 continue;962 if ( empty( $title ) )963 continue;964 965 if ( 'comments' == $column )966 $title = __( 'Comments' );967 $id = "$column-hide";968 echo '<label for="' . $id . '">';969 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />';970 echo "$title</label>\n";971 }972 ?>973 <br class="clear" />974 </div>975 <?php endif;976 977 $this->render_screen_layout();978 $this->render_per_page_options();979 echo $this->_screen_settings;980 981 ?>982 <div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>983 </form>984 </div>985 <?php986 }987 988 /**989 1104 * Render the option for number of columns on the page 990 1105 * 991 1106 * @since 3.3.0 992 1107 */ 993 1108 function render_screen_layout() { 994 if ( ! $this->get_option('layout_columns') ) 995 return; 996 997 $screen_layout_columns = $this->get_columns(); 998 $num = $this->get_option( 'layout_columns', 'max' ); 999 1000 ?> 1001 <h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5> 1002 <div class='columns-prefs'><?php 1003 _e('Number of Columns:'); 1004 for ( $i = 1; $i <= $num; ++$i ): 1005 ?> 1006 <label class="columns-prefs-<?php echo $i; ?>"> 1007 <input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>' 1008 <?php checked( $screen_layout_columns, $i ); ?> /> 1009 <?php echo esc_html( $i ); ?> 1010 </label> 1011 <?php 1012 endfor; ?> 1013 </div> 1014 <?php 1109 return; 1015 1110 } 1016 1111 1017 1112 /** … … 1020 1115 * @since 3.3.0 1021 1116 */ 1022 1117 function render_per_page_options() { 1023 if ( ! $this->get_option( 'per_page' ) ) 1024 return; 1025 1026 $per_page_label = $this->get_option( 'per_page', 'label' ); 1027 1028 $option = $this->get_option( 'per_page', 'option' ); 1029 if ( ! $option ) 1030 $option = str_replace( '-', '_', "{$this->id}_per_page" ); 1031 1032 $per_page = (int) get_user_option( $option ); 1033 if ( empty( $per_page ) || $per_page < 1 ) { 1034 $per_page = $this->get_option( 'per_page', 'default' ); 1035 if ( ! $per_page ) 1036 $per_page = 20; 1037 } 1038 1039 if ( 'edit_comments_per_page' == $option ) { 1040 $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; 1041 $per_page = apply_filters( 'comments_per_page', $per_page, $comment_status ); 1042 } elseif ( 'categories_per_page' == $option ) { 1043 $per_page = apply_filters( 'edit_categories_per_page', $per_page ); 1044 } else { 1045 $per_page = apply_filters( $option, $per_page ); 1046 } 1047 1048 // Back compat 1049 if ( isset( $this->post_type ) ) 1050 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type ); 1051 1052 ?> 1053 <div class="screen-options"> 1054 <?php if ( $per_page_label ) : ?> 1055 <input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]" 1056 id="<?php echo esc_attr( $option ); ?>" maxlength="3" 1057 value="<?php echo esc_attr( $per_page ); ?>" /> 1058 <label for="<?php echo esc_attr( $option ); ?>"> 1059 <?php echo esc_html( $per_page_label ); ?> 1060 </label> 1061 <?php endif; 1062 1063 echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?> 1064 <input type='hidden' name='wp_screen_options[option]' value='<?php echo esc_attr($option); ?>' /> 1065 </div> 1066 <?php 1118 return; 1067 1119 } 1068 1120 } -
wp-admin/admin-header.php
115 115 <div id="wpcontent"> 116 116 117 117 <?php 118 $current_screen->set_parentage( $parent_file ); 118 119 do_action('in_admin_header'); 119 120 ?> 120 121 … … 122 123 <?php 123 124 unset($title_class, $blog_name, $total_update_count, $update_title); 124 125 125 $current_screen->set_parentage( $parent_file );126 127 126 ?> 128 127 129 128 <div id="wpbody-content" aria-label="<?php esc_attr_e('Main content'); ?>"> 130 129 <?php 131 130 132 $current_screen->render_screen_meta();133 134 131 if ( is_network_admin() ) 135 132 do_action('network_admin_notices'); 136 133 elseif ( is_user_admin() )