Changeset 18874 for trunk/wp-admin/includes/screen.php
- Timestamp:
- 10/04/2011 03:32:12 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/screen.php
r18867 r18874 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 ) { // TODO: fold into WP_Screen? 18 18 if ( is_string( $screen ) ) 19 19 $screen = convert_to_screen( $screen ); … … 44 44 45 45 /** 46 * {@internal Missing Short Description}}47 *48 * @since 2.7.049 *50 * @param unknown_type $screen51 */52 function meta_box_prefs($screen) { // TODO: fold into WP_Screen53 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 hidden69 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 /**81 46 * Get Hidden Meta Boxes 82 47 * … … 98 63 else 99 64 $hidden = array( 'slugdiv' ); 65 100 66 $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen); 101 67 } 102 68 103 69 return $hidden; 104 }105 106 /**107 * {@internal Missing Short Description}}108 *109 * @since 2.7.0110 */111 function favorite_actions( $screen = null ) { // TODO: deprecate and remove?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 else125 $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 else144 $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";216 70 } 217 71 … … 224 78 * @return object An object containing the safe screen name and id 225 79 */ 226 function convert_to_screen( $screen ) { // TODO: fold into WP_Screen 80 function convert_to_screen( $screen ) { // TODO: fold into WP_Screen? 227 81 $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen); 228 82 … … 237 91 } 238 92 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 function add_contextual_help($screen, $help) { // TODO: deprecate 250 global $_wp_contextual_help; 251 252 if ( is_string($screen) ) 253 $screen = convert_to_screen($screen); 254 255 if ( !isset($_wp_contextual_help) ) 256 $_wp_contextual_help = array(); 257 258 $_wp_contextual_help[$screen->id] = $help; 259 } 260 261 /** 262 * Register and configure an admin screen option 263 * 264 * @since 3.1.0 265 * 266 * @param string $option An option name. 267 * @param mixed $args Option dependent arguments 268 * @return void 269 */ 270 function add_screen_option( $option, $args = array() ) { // TODO: set deprecated 271 $current_screen = get_current_screen(); 272 273 if ( ! $current_screen ) 93 function screen_icon( $for = '' ) { // TODO: fold into WP_Screen? 94 global $current_screen; 95 96 if ( !isset($current_screen) ) 274 97 return; 275 98 276 return $current_screen->add_option( $option, $args ); 277 } 278 279 function screen_icon( $screen = '' ) { // TODO: fold into WP_Screen 280 echo get_screen_icon( $screen ); 281 } 282 283 function get_screen_icon( $screen = '' ) { // TODO: fold into WP_Screen 284 global $current_screen, $typenow; 285 286 if ( empty($screen) ) 287 $screen = $current_screen; 288 elseif ( is_string($screen) ) 289 $name = $screen; 290 291 $class = 'icon32'; 292 293 if ( empty($name) ) { 294 if ( !empty($screen->parent_base) ) 295 $name = $screen->parent_base; 296 else 297 $name = $screen->base; 298 299 if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type ) 300 $name = 'edit-pages'; 301 302 $post_type = ''; 303 if ( isset( $screen->post_type ) ) 304 $post_type = $screen->post_type; 305 elseif ( $current_screen == $screen ) 306 $post_type = $typenow; 307 if ( $post_type ) 308 $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type ); 309 } 310 311 return '<div id="icon-' . esc_attr( $name ) . '" class="' . $class . '"><br /></div>'; 99 echo $current_screen->get_screen_icon( $for ); 312 100 } 313 101 … … 340 128 global $current_screen; 341 129 342 if ( is_a( $current_screen, 'WP_Screen' ) ) 343 return; 344 345 $current_screen = new WP_Screen( $id ); 130 if ( !is_a( $current_screen, 'WP_Screen' ) ) 131 $current_screen = new WP_Screen( $id ); 346 132 347 133 // why do we need this? $current_screen = apply_filters('current_screen', $current_screen); … … 479 265 */ 480 266 private $_show_options = false; 481 482 /**483 * Stores the 'screen_settings' section of screen options.484 *485 * @since 3.3.0486 * @var string487 * @access private488 */489 private $_screen_settings = '';490 267 491 268 /** … … 665 442 global $_wp_contextual_help; 666 443 444 // Intended for adding Help and Screen Options. 667 445 do_action('add_screen_help_and_options'); 668 446 … … 780 558 $screen_settings = apply_filters( 'screen_settings', $screen_settings, $this ); 781 559 782 ?> 783 <form id="adv-settings" action="" method="post"> 784 <?php 560 echo '<form id="adv-settings" action="" method="post">'; 785 561 786 562 $this->render_table_columns_prefs(); … … 790 566 echo $screen_settings; 791 567 792 wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?>793 </form>794 <?php 568 wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); 569 echo '</form>'; 570 795 571 } 796 572 … … 840 616 global $wp_meta_boxes; 841 617 842 if ( isset( $wp_meta_boxes[ $this->id ] ) ) { 618 if ( !empty( $wp_meta_boxes[ $this->id ] ) ) { 619 $hidden = get_hidden_meta_boxes($this); 843 620 ?> 844 621 <h5><?php _ex('Show on screen', 'Metaboxes') ?></h5> 845 622 <div class="metabox-prefs"> 846 <?php meta_box_prefs( $this ); ?> 623 <?php 624 625 foreach ( array_keys($wp_meta_boxes[$this->id]) as $context ) { 626 foreach ( array_keys($wp_meta_boxes[$this->id][$context]) as $priority ) { 627 foreach ( $wp_meta_boxes[$this->id][$context][$priority] as $box ) { 628 if ( false == $box || ! $box['title'] ) 629 continue; 630 // Submit box cannot be hidden 631 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) 632 continue; 633 $box_id = $box['id']; 634 echo '<label for="' . $box_id . '-hide">'; 635 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"' : '') . ' />'; 636 echo "{$box['title']}</label>\n"; 637 } 638 } 639 } 640 641 ?> 847 642 <br class="clear" /> 848 643 </div> … … 958 753 <?php 959 754 } 755 756 function get_screen_icon( $for = '' ) { 757 758 if ( !empty($for) && is_string($for) ) { 759 $name = $for; 760 } else { 761 if ( !empty($this->parent_base) ) 762 $name = $this->parent_base; 763 else 764 $name = $this->base; 765 } 766 767 if ( 'edit' == $name && isset($this->post_type) && 'page' == $this->post_type ) 768 $name = 'edit-pages'; 769 770 $class = ''; 771 if ( !empty( $this->post_type ) ) 772 $class = ' ' . sanitize_html_class( 'icon32-posts-' . $this->post_type ); 773 774 return '<div id="icon-' . esc_attr( $name ) . '" class="icon32' . $class . '"><br /></div>'; 775 } 960 776 } 961 777
Note: See TracChangeset
for help on using the changeset viewer.