WordPress.org

Make WordPress Core

Changeset 18782


Ignore:
Timestamp:
09/26/11 21:32:10 (3 years ago)
Author:
nacin
Message:

Move WP_Screen and friends (15 functions) into admin/includes/screen.php. see #18690.

Location:
trunk/wp-admin/includes
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/admin.php

    r17293 r18782  
    3434require_once(ABSPATH . 'wp-admin/includes/post.php'); 
    3535 
     36/** WordPress Administration Screen API */ 
     37require_once(ABSPATH . 'wp-admin/includes/screen.php'); 
     38 
    3639/** WordPress Taxonomy Administration API */ 
    3740require_once(ABSPATH . 'wp-admin/includes/taxonomy.php'); 
  • trunk/wp-admin/includes/screen.php

    r18781 r18782  
    11<?php 
    22/** 
    3  * Template WordPress Administration API. 
    4  * 
    5  * A Big Mess. Also some neat functions that are nicely written. 
     3 * WordPress Administration Screen API. 
    64 * 
    75 * @package WordPress 
    86 * @subpackage Administration 
    97 */ 
    10  
    11  
    12 // 
    13 // Category Checklists 
    14 // 
    15  
    16 /** 
    17  * {@internal Missing Short Description}} 
    18  * 
    19  * @since 2.5.1 
    20  */ 
    21 class Walker_Category_Checklist extends Walker { 
    22     var $tree_type = 'category'; 
    23     var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this 
    24  
    25     function start_lvl(&$output, $depth, $args) { 
    26         $indent = str_repeat("\t", $depth); 
    27         $output .= "$indent<ul class='children'>\n"; 
    28     } 
    29  
    30     function end_lvl(&$output, $depth, $args) { 
    31         $indent = str_repeat("\t", $depth); 
    32         $output .= "$indent</ul>\n"; 
    33     } 
    34  
    35     function start_el(&$output, $category, $depth, $args) { 
    36         extract($args); 
    37         if ( empty($taxonomy) ) 
    38             $taxonomy = 'category'; 
    39  
    40         if ( $taxonomy == 'category' ) 
    41             $name = 'post_category'; 
    42         else 
    43             $name = 'tax_input['.$taxonomy.']'; 
    44  
    45         $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; 
    46         $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; 
    47     } 
    48  
    49     function end_el(&$output, $category, $depth, $args) { 
    50         $output .= "</li>\n"; 
    51     } 
    52 } 
    53  
    54 /** 
    55  * {@internal Missing Short Description}} 
    56  * 
    57  * @since 2.5.1 
    58  * 
    59  * @param unknown_type $post_id 
    60  * @param unknown_type $descendants_and_self 
    61  * @param unknown_type $selected_cats 
    62  * @param unknown_type $popular_cats 
    63  */ 
    64 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) { 
    65     wp_terms_checklist($post_id, 
    66         array( 
    67             'taxonomy' => 'category', 
    68             'descendants_and_self' => $descendants_and_self, 
    69             'selected_cats' => $selected_cats, 
    70             'popular_cats' => $popular_cats, 
    71             'walker' => $walker, 
    72             'checked_ontop' => $checked_ontop 
    73   )); 
    74 } 
    75  
    76 /** 
    77  * Taxonomy independent version of wp_category_checklist 
    78  * 
    79  * @since 3.0.0 
    80  * 
    81  * @param int $post_id 
    82  * @param array $args 
    83  */ 
    84 function wp_terms_checklist($post_id = 0, $args = array()) { 
    85     $defaults = array( 
    86         'descendants_and_self' => 0, 
    87         'selected_cats' => false, 
    88         'popular_cats' => false, 
    89         'walker' => null, 
    90         'taxonomy' => 'category', 
    91         'checked_ontop' => true 
    92     ); 
    93     extract( wp_parse_args($args, $defaults), EXTR_SKIP ); 
    94  
    95     if ( empty($walker) || !is_a($walker, 'Walker') ) 
    96         $walker = new Walker_Category_Checklist; 
    97  
    98     $descendants_and_self = (int) $descendants_and_self; 
    99  
    100     $args = array('taxonomy' => $taxonomy); 
    101  
    102     $tax = get_taxonomy($taxonomy); 
    103     $args['disabled'] = !current_user_can($tax->cap->assign_terms); 
    104  
    105     if ( is_array( $selected_cats ) ) 
    106         $args['selected_cats'] = $selected_cats; 
    107     elseif ( $post_id ) 
    108         $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); 
    109     else 
    110         $args['selected_cats'] = array(); 
    111  
    112     if ( is_array( $popular_cats ) ) 
    113         $args['popular_cats'] = $popular_cats; 
    114     else 
    115         $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); 
    116  
    117     if ( $descendants_and_self ) { 
    118         $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); 
    119         $self = get_term( $descendants_and_self, $taxonomy ); 
    120         array_unshift( $categories, $self ); 
    121     } else { 
    122         $categories = (array) get_terms($taxonomy, array('get' => 'all')); 
    123     } 
    124  
    125     if ( $checked_ontop ) { 
    126         // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) 
    127         $checked_categories = array(); 
    128         $keys = array_keys( $categories ); 
    129  
    130         foreach( $keys as $k ) { 
    131             if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) { 
    132                 $checked_categories[] = $categories[$k]; 
    133                 unset( $categories[$k] ); 
    134             } 
    135         } 
    136  
    137         // Put checked cats on top 
    138         echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args)); 
    139     } 
    140     // Then the rest of them 
    141     echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); 
    142 } 
    143  
    144 /** 
    145  * {@internal Missing Short Description}} 
    146  * 
    147  * @since 2.5.0 
    148  * 
    149  * @param unknown_type $taxonomy 
    150  * @param unknown_type $default 
    151  * @param unknown_type $number 
    152  * @param unknown_type $echo 
    153  * @return unknown 
    154  */ 
    155 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { 
    156     global $post_ID; 
    157  
    158     if ( $post_ID ) 
    159         $checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids')); 
    160     else 
    161         $checked_terms = array(); 
    162  
    163     $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); 
    164  
    165     $tax = get_taxonomy($taxonomy); 
    166     if ( ! current_user_can($tax->cap->assign_terms) ) 
    167         $disabled = 'disabled="disabled"'; 
    168     else 
    169         $disabled = ''; 
    170  
    171     $popular_ids = array(); 
    172     foreach ( (array) $terms as $term ) { 
    173         $popular_ids[] = $term->term_id; 
    174         if ( !$echo ) // hack for AJAX use 
    175             continue; 
    176         $id = "popular-$taxonomy-$term->term_id"; 
    177         $checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : ''; 
    178         ?> 
    179  
    180         <li id="<?php echo $id; ?>" class="popular-category"> 
    181             <label class="selectit"> 
    182             <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/> 
    183                 <?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?> 
    184             </label> 
    185         </li> 
    186  
    187         <?php 
    188     } 
    189     return $popular_ids; 
    190 } 
    191  
    192 /** 
    193  * {@internal Missing Short Description}} 
    194  * 
    195  * @since 2.5.1 
    196  * 
    197  * @param unknown_type $link_id 
    198  */ 
    199 function wp_link_category_checklist( $link_id = 0 ) { 
    200     $default = 1; 
    201  
    202     if ( $link_id ) { 
    203         $checked_categories = wp_get_link_cats( $link_id ); 
    204         // No selected categories, strange 
    205         if ( ! count( $checked_categories ) ) 
    206             $checked_categories[] = $default; 
    207     } else { 
    208         $checked_categories[] = $default; 
    209     } 
    210  
    211     $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) ); 
    212  
    213     if ( empty( $categories ) ) 
    214         return; 
    215  
    216     foreach ( $categories as $category ) { 
    217         $cat_id = $category->term_id; 
    218         $name = esc_html( apply_filters( 'the_category', $category->name ) ); 
    219         $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : ''; 
    220         echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>"; 
    221     } 
    222 } 
    2238 
    2249/** 
     
    25641 
    25742    return (array) get_user_option( 'manage' . $screen->id . 'columnshidden' ); 
    258 } 
    259  
    260 // adds hidden fields with the data for use in the inline editor for posts and pages 
    261 /** 
    262  * {@internal Missing Short Description}} 
    263  * 
    264  * @since 2.7.0 
    265  * 
    266  * @param unknown_type $post 
    267  */ 
    268 function get_inline_data($post) { 
    269     $post_type_object = get_post_type_object($post->post_type); 
    270     if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) ) 
    271         return; 
    272  
    273     $title = esc_textarea( trim( $post->post_title ) ); 
    274  
    275     echo ' 
    276 <div class="hidden" id="inline_' . $post->ID . '"> 
    277     <div class="post_title">' . $title . '</div> 
    278     <div class="post_name">' . apply_filters('editable_slug', $post->post_name) . '</div> 
    279     <div class="post_author">' . $post->post_author . '</div> 
    280     <div class="comment_status">' . esc_html( $post->comment_status ) . '</div> 
    281     <div class="ping_status">' . esc_html( $post->ping_status ) . '</div> 
    282     <div class="_status">' . esc_html( $post->post_status ) . '</div> 
    283     <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div> 
    284     <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div> 
    285     <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div> 
    286     <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div> 
    287     <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div> 
    288     <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div> 
    289     <div class="post_password">' . esc_html( $post->post_password ) . '</div>'; 
    290  
    291     if ( $post_type_object->hierarchical ) 
    292         echo '<div class="post_parent">' . $post->post_parent . '</div>'; 
    293  
    294     if ( $post->post_type == 'page' ) 
    295         echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>'; 
    296  
    297     if ( $post_type_object->hierarchical ) 
    298         echo '<div class="menu_order">' . $post->menu_order . '</div>'; 
    299  
    300     $taxonomy_names = get_object_taxonomies( $post->post_type ); 
    301     foreach ( $taxonomy_names as $taxonomy_name) { 
    302         $taxonomy = get_taxonomy( $taxonomy_name ); 
    303  
    304         if ( $taxonomy->hierarchical && $taxonomy->show_ui ) 
    305                 echo '<div class="post_category" id="'.$taxonomy_name.'_'.$post->ID.'">' . implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array('fields'=>'ids')) ) . '</div>'; 
    306         elseif ( $taxonomy->show_ui ) 
    307             echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">' . esc_html( str_replace( ',', ', ', get_terms_to_edit($post->ID, $taxonomy_name) ) ) . '</div>'; 
    308     } 
    309  
    310     if ( !$post_type_object->hierarchical ) 
    311         echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>'; 
    312  
    313     if ( post_type_supports( $post->post_type, 'post-formats' ) ) 
    314         echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>'; 
    315  
    316     echo '</div>'; 
    317 } 
    318  
    319 /** 
    320  * {@internal Missing Short Description}} 
    321  * 
    322  * @since 2.7.0 
    323  * 
    324  * @param unknown_type $position 
    325  * @param unknown_type $checkbox 
    326  * @param unknown_type $mode 
    327  */ 
    328 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) { 
    329     // allow plugin to replace the popup content 
    330     $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) ); 
    331  
    332     if ( ! empty($content) ) { 
    333         echo $content; 
    334         return; 
    335     } 
    336  
    337     if ( $mode == 'single' ) { 
    338         $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); 
    339     } else { 
    340         $wp_list_table = _get_list_table('WP_Comments_List_Table'); 
    341     } 
    342  
    343 ?> 
    344 <form method="get" action=""> 
    345 <?php if ( $table_row ) : ?> 
    346 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange"> 
    347 <?php else : ?> 
    348 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;"> 
    349 <?php endif; ?> 
    350     <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div> 
    351  
    352     <div id="edithead" style="display:none;"> 
    353         <div class="inside"> 
    354         <label for="author"><?php _e('Name') ?></label> 
    355         <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" /> 
    356         </div> 
    357  
    358         <div class="inside"> 
    359         <label for="author-email"><?php _e('E-mail') ?></label> 
    360         <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" /> 
    361         </div> 
    362  
    363         <div class="inside"> 
    364         <label for="author-url"><?php _e('URL') ?></label> 
    365         <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" /> 
    366         </div> 
    367         <div style="clear:both;"></div> 
    368     </div> 
    369  
    370     <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div> 
    371  
    372     <p id="replysubmit" class="submit"> 
    373     <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a> 
    374     <a href="#comments-form" class="save button-primary alignright" tabindex="104"> 
    375     <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span> 
    376     <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a> 
    377     <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> 
    378     <span class="error" style="display:none;"></span> 
    379     <br class="clear" /> 
    380     </p> 
    381  
    382     <input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" /> 
    383     <input type="hidden" name="action" id="action" value="" /> 
    384     <input type="hidden" name="comment_ID" id="comment_ID" value="" /> 
    385     <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" /> 
    386     <input type="hidden" name="status" id="status" value="" /> 
    387     <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" /> 
    388     <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" /> 
    389     <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" /> 
    390     <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false ); ?> 
    391     <?php wp_comment_form_unfiltered_html_nonce(); ?> 
    392 <?php if ( $table_row ) : ?> 
    393 </td></tr></tbody></table> 
    394 <?php else : ?> 
    395 </div></div> 
    396 <?php endif; ?> 
    397 </form> 
    398 <?php 
    399 } 
    400  
    401 /** 
    402  * Output 'undo move to trash' text for comments 
    403  * 
    404  * @since 2.9.0 
    405  */ 
    406 function wp_comment_trashnotice() { 
    407 ?> 
    408 <div class="hidden" id="trash-undo-holder"> 
    409     <div class="trash-undo-inside"><?php printf(__('Comment by %s moved to the trash.'), '<strong></strong>'); ?> <span class="undo untrash"><a href="#"><?php _e('Undo'); ?></a></span></div> 
    410 </div> 
    411 <div class="hidden" id="spam-undo-holder"> 
    412     <div class="spam-undo-inside"><?php printf(__('Comment by %s marked as spam.'), '<strong></strong>'); ?> <span class="undo unspam"><a href="#"><?php _e('Undo'); ?></a></span></div> 
    413 </div> 
    414 <?php 
    415 } 
    416  
    417 /** 
    418  * {@internal Missing Short Description}} 
    419  * 
    420  * @since 1.2.0 
    421  * 
    422  * @param unknown_type $meta 
    423  */ 
    424 function list_meta( $meta ) { 
    425     // Exit if no meta 
    426     if ( ! $meta ) { 
    427         echo ' 
    428 <table id="list-table" style="display: none;"> 
    429     <thead> 
    430     <tr> 
    431         <th class="left">' . _x( 'Name', 'meta name' ) . '</th> 
    432         <th>' . __( 'Value' ) . '</th> 
    433     </tr> 
    434     </thead> 
    435     <tbody id="the-list" class="list:meta"> 
    436     <tr><td></td></tr> 
    437     </tbody> 
    438 </table>'; //TBODY needed for list-manipulation JS 
    439         return; 
    440     } 
    441     $count = 0; 
    442 ?> 
    443 <table id="list-table"> 
    444     <thead> 
    445     <tr> 
    446         <th class="left"><?php _ex( 'Name', 'meta name' ) ?></th> 
    447         <th><?php _e( 'Value' ) ?></th> 
    448     </tr> 
    449     </thead> 
    450     <tbody id='the-list' class='list:meta'> 
    451 <?php 
    452     foreach ( $meta as $entry ) 
    453         echo _list_meta_row( $entry, $count ); 
    454 ?> 
    455     </tbody> 
    456 </table> 
    457 <?php 
    458 } 
    459  
    460 /** 
    461  * {@internal Missing Short Description}} 
    462  * 
    463  * @since 2.5.0 
    464  * 
    465  * @param unknown_type $entry 
    466  * @param unknown_type $count 
    467  * @return unknown 
    468  */ 
    469 function _list_meta_row( $entry, &$count ) { 
    470     static $update_nonce = false; 
    471  
    472     if ( is_protected_meta( $entry['meta_key'], 'post' ) ) 
    473         return; 
    474  
    475     if ( !$update_nonce ) 
    476         $update_nonce = wp_create_nonce( 'add-meta' ); 
    477  
    478     $r = ''; 
    479     ++ $count; 
    480     if ( $count % 2 ) 
    481         $style = 'alternate'; 
    482     else 
    483         $style = ''; 
    484  
    485     if ( is_serialized( $entry['meta_value'] ) ) { 
    486         if ( is_serialized_string( $entry['meta_value'] ) ) { 
    487             // this is a serialized string, so we should display it 
    488             $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); 
    489         } else { 
    490             // this is a serialized array/object so we should NOT display it 
    491             --$count; 
    492             return; 
    493         } 
    494     } 
    495  
    496     $entry['meta_key'] = esc_attr($entry['meta_key']); 
    497     $entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea /> 
    498     $entry['meta_id'] = (int) $entry['meta_id']; 
    499  
    500     $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); 
    501  
    502     $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; 
    503     $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />"; 
    504  
    505     $r .= "\n\t\t<div class='submit'>"; 
    506     $r .= get_submit_button( __( 'Delete' ), "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta", "deletemeta[{$entry['meta_id']}]", false, array( 'tabindex' => '6' ) ); 
    507     $r .= "\n\t\t"; 
    508     $r .= get_submit_button( __( 'Update' ), "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta" , 'updatemeta', false, array( 'tabindex' => '6' ) ); 
    509     $r .= "</div>"; 
    510     $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); 
    511     $r .= "</td>"; 
    512  
    513     $r .= "\n\t\t<td><label class='screen-reader-text' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>"; 
    514     return $r; 
    515 } 
    516  
    517 /** 
    518  * {@internal Missing Short Description}} 
    519  * 
    520  * @since 1.2.0 
    521  */ 
    522 function meta_form() { 
    523     global $wpdb; 
    524     $limit = (int) apply_filters( 'postmeta_form_limit', 30 ); 
    525     $keys = $wpdb->get_col( " 
    526         SELECT meta_key 
    527         FROM $wpdb->postmeta 
    528         GROUP BY meta_key 
    529         HAVING meta_key NOT LIKE '\_%' 
    530         ORDER BY meta_key 
    531         LIMIT $limit" ); 
    532     if ( $keys ) 
    533         natcasesort($keys); 
    534 ?> 
    535 <p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p> 
    536 <table id="newmeta"> 
    537 <thead> 
    538 <tr> 
    539 <th class="left"><label for="metakeyselect"><?php _ex( 'Name', 'meta name' ) ?></label></th> 
    540 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th> 
    541 </tr> 
    542 </thead> 
    543  
    544 <tbody> 
    545 <tr> 
    546 <td id="newmetaleft" class="left"> 
    547 <?php if ( $keys ) { ?> 
    548 <select id="metakeyselect" name="metakeyselect" tabindex="7"> 
    549 <option value="#NONE#"><?php _e( '&mdash; Select &mdash;' ); ?></option> 
    550 <?php 
    551  
    552     foreach ( $keys as $key ) { 
    553         echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>"; 
    554     } 
    555 ?> 
    556 </select> 
    557 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> 
    558 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> 
    559 <span id="enternew"><?php _e('Enter new'); ?></span> 
    560 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a> 
    561 <?php } else { ?> 
    562 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> 
    563 <?php } ?> 
    564 </td> 
    565 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td> 
    566 </tr> 
    567  
    568 <tr><td colspan="2" class="submit"> 
    569 <?php submit_button( __( 'Add Custom Field' ), 'add:the-list:newmeta', 'addmeta', false, array( 'id' => 'addmetasub', 'tabindex' => '9' ) ); ?> 
    570 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?> 
    571 </td></tr> 
    572 </tbody> 
    573 </table> 
    574 <?php 
    575  
    576 } 
    577  
    578 /** 
    579  * {@internal Missing Short Description}} 
    580  * 
    581  * @since 0.71 
    582  * 
    583  * @param unknown_type $edit 
    584  * @param unknown_type $for_post 
    585  * @param unknown_type $tab_index 
    586  * @param unknown_type $multi 
    587  */ 
    588 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { 
    589     global $wp_locale, $post, $comment; 
    590  
    591     if ( $for_post ) 
    592         $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); 
    593  
    594     $tab_index_attribute = ''; 
    595     if ( (int) $tab_index > 0 ) 
    596         $tab_index_attribute = " tabindex=\"$tab_index\""; 
    597  
    598     // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />'; 
    599  
    600     $time_adj = current_time('timestamp'); 
    601     $post_date = ($for_post) ? $post->post_date : $comment->comment_date; 
    602     $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj ); 
    603     $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj ); 
    604     $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj ); 
    605     $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj ); 
    606     $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj ); 
    607     $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj ); 
    608  
    609     $cur_jj = gmdate( 'd', $time_adj ); 
    610     $cur_mm = gmdate( 'm', $time_adj ); 
    611     $cur_aa = gmdate( 'Y', $time_adj ); 
    612     $cur_hh = gmdate( 'H', $time_adj ); 
    613     $cur_mn = gmdate( 'i', $time_adj ); 
    614  
    615     $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n"; 
    616     for ( $i = 1; $i < 13; $i = $i +1 ) { 
    617         $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"'; 
    618         if ( $i == $mm ) 
    619             $month .= ' selected="selected"'; 
    620         $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n"; 
    621     } 
    622     $month .= '</select>'; 
    623  
    624     $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; 
    625     $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />'; 
    626     $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; 
    627     $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; 
    628  
    629     echo '<div class="timestamp-wrap">'; 
    630     /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */ 
    631     printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute); 
    632  
    633     echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />'; 
    634  
    635     if ( $multi ) return; 
    636  
    637     echo "\n\n"; 
    638     foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) { 
    639         echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n"; 
    640         $cur_timeunit = 'cur_' . $timeunit; 
    641         echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n"; 
    642     } 
    643 ?> 
    644  
    645 <p> 
    646 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a> 
    647 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a> 
    648 </p> 
    649 <?php 
    650 } 
    651  
    652 /** 
    653  * {@internal Missing Short Description}} 
    654  * 
    655  * @since 1.5.0 
    656  * 
    657  * @param unknown_type $default 
    658  */ 
    659 function page_template_dropdown( $default = '' ) { 
    660     $templates = get_page_templates(); 
    661     ksort( $templates ); 
    662     foreach (array_keys( $templates ) as $template ) 
    663         : if ( $default == $templates[$template] ) 
    664             $selected = " selected='selected'"; 
    665         else 
    666             $selected = ''; 
    667     echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>"; 
    668     endforeach; 
    669 } 
    670  
    671 /** 
    672  * {@internal Missing Short Description}} 
    673  * 
    674  * @since 1.5.0 
    675  * 
    676  * @param unknown_type $default 
    677  * @param unknown_type $parent 
    678  * @param unknown_type $level 
    679  * @return unknown 
    680  */ 
    681 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { 
    682     global $wpdb, $post_ID; 
    683     $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) ); 
    684  
    685     if ( $items ) { 
    686         foreach ( $items as $item ) { 
    687             // A page cannot be its own parent. 
    688             if (!empty ( $post_ID ) ) { 
    689                 if ( $item->ID == $post_ID ) { 
    690                     continue; 
    691                 } 
    692             } 
    693             $pad = str_repeat( '&nbsp;', $level * 3 ); 
    694             if ( $item->ID == $default) 
    695                 $current = ' selected="selected"'; 
    696             else 
    697                 $current = ''; 
    698  
    699             echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>"; 
    700             parent_dropdown( $default, $item->ID, $level +1 ); 
    701         } 
    702     } else { 
    703         return false; 
    704     } 
    705 } 
    706  
    707 /** 
    708  * {@internal Missing Short Description}} 
    709  * 
    710  * @since 2.0.0 
    711  * 
    712  * @param unknown_type $id 
    713  * @return unknown 
    714  */ 
    715 function the_attachment_links( $id = false ) { 
    716     $id = (int) $id; 
    717     $post = & get_post( $id ); 
    718  
    719     if ( $post->post_type != 'attachment' ) 
    720         return false; 
    721  
    722     $icon = wp_get_attachment_image( $post->ID, 'thumbnail', true ); 
    723     $attachment_data = wp_get_attachment_metadata( $id ); 
    724     $thumb = isset( $attachment_data['thumb'] ); 
    725 ?> 
    726 <form id="the-attachment-links"> 
    727 <table> 
    728     <col /> 
    729     <col class="widefat" /> 
    730     <tr> 
    731         <th scope="row"><?php _e( 'URL' ) ?></th> 
    732         <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo esc_textarea( wp_get_attachment_url() ); ?></textarea></td> 
    733     </tr> 
    734 <?php if ( $icon ) : ?> 
    735     <tr> 
    736         <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th> 
    737         <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td> 
    738     </tr> 
    739     <tr> 
    740         <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th> 
    741         <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td> 
    742     </tr> 
    743 <?php else : ?> 
    744     <tr> 
    745         <th scope="row"><?php _e( 'Link to file' ) ?></th> 
    746         <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td> 
    747     </tr> 
    748     <tr> 
    749         <th scope="row"><?php _e( 'Link to page' ) ?></th> 
    750         <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td> 
    751     </tr> 
    752 <?php endif; ?> 
    753 </table> 
    754 </form> 
    755 <?php 
    756 } 
    757  
    758  
    759 /** 
    760  * Print out <option> html elements for role selectors 
    761  * 
    762  * @since 2.1.0 
    763  * 
    764  * @param string $selected slug for the role that should be already selected 
    765  */ 
    766 function wp_dropdown_roles( $selected = false ) { 
    767     $p = ''; 
    768     $r = ''; 
    769  
    770     $editable_roles = get_editable_roles(); 
    771  
    772     foreach ( $editable_roles as $role => $details ) { 
    773         $name = translate_user_role($details['name'] ); 
    774         if ( $selected == $role ) // preselect specified role 
    775             $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>"; 
    776         else 
    777             $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>"; 
    778     } 
    779     echo $p . $r; 
    780 } 
    781  
    782 /** 
    783  * {@internal Missing Short Description}} 
    784  * 
    785  * @since 2.3.0 
    786  * 
    787  * @param unknown_type $size 
    788  * @return unknown 
    789  */ 
    790 function wp_convert_hr_to_bytes( $size ) { 
    791     $size = strtolower($size); 
    792     $bytes = (int) $size; 
    793     if ( strpos($size, 'k') !== false ) 
    794         $bytes = intval($size) * 1024; 
    795     elseif ( strpos($size, 'm') !== false ) 
    796         $bytes = intval($size) * 1024 * 1024; 
    797     elseif ( strpos($size, 'g') !== false ) 
    798         $bytes = intval($size) * 1024 * 1024 * 1024; 
    799     return $bytes; 
    800 } 
    801  
    802 /** 
    803  * {@internal Missing Short Description}} 
    804  * 
    805  * @since 2.3.0 
    806  * 
    807  * @param unknown_type $bytes 
    808  * @return unknown 
    809  */ 
    810 function wp_convert_bytes_to_hr( $bytes ) { 
    811     $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' ); 
    812     $log = log( $bytes, 1024 ); 
    813     $power = (int) $log; 
    814     $size = pow(1024, $log - $power); 
    815     return $size . $units[$power]; 
    816 } 
    817  
    818 /** 
    819  * {@internal Missing Short Description}} 
    820  * 
    821  * @since 2.5.0 
    822  * 
    823  * @return unknown 
    824  */ 
    825 function wp_max_upload_size() { 
    826     $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); 
    827     $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); 
    828     $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); 
    829     return $bytes; 
    830 } 
    831  
    832 /** 
    833  * Outputs the form used by the importers to accept the data to be imported 
    834  * 
    835  * @since 2.0.0 
    836  * 
    837  * @param string $action The action attribute for the form. 
    838  */ 
    839 function wp_import_upload_form( $action ) { 
    840     $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); 
    841     $size = wp_convert_bytes_to_hr( $bytes ); 
    842     $upload_dir = wp_upload_dir(); 
    843     if ( ! empty( $upload_dir['error'] ) ) : 
    844         ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p> 
    845         <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php 
    846     else : 
    847 ?> 
    848 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>"> 
    849 <p> 
    850 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>) 
    851 <input type="file" id="upload" name="import" size="25" /> 
    852 <input type="hidden" name="action" value="save" /> 
    853 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> 
    854 </p> 
    855 <?php submit_button( __('Upload file and import'), 'button' ); ?> 
    856 </form> 
    857 <?php 
    858     endif; 
    859 } 
    860  
    861 /** 
    862  * Add a meta box to an edit form. 
    863  * 
    864  * @since 2.5.0 
    865  * 
    866  * @param string $id String for use in the 'id' attribute of tags. 
    867  * @param string $title Title of the meta box. 
    868  * @param string $callback Function that fills the box with the desired content. The function should echo its output. 
    869  * @param string $page The type of edit page on which to show the box (post, page, link). 
    870  * @param string $context The context within the page where the boxes should show ('normal', 'advanced'). 
    871  * @param string $priority The priority within the context where the boxes should show ('high', 'low'). 
    872  */ 
    873 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) { 
    874     global $wp_meta_boxes; 
    875  
    876     if ( !isset($wp_meta_boxes) ) 
    877         $wp_meta_boxes = array(); 
    878     if ( !isset($wp_meta_boxes[$page]) ) 
    879         $wp_meta_boxes[$page] = array(); 
    880     if ( !isset($wp_meta_boxes[$page][$context]) ) 
    881         $wp_meta_boxes[$page][$context] = array(); 
    882  
    883     foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) { 
    884         foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { 
    885             if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) 
    886                 continue; 
    887  
    888             // If a core box was previously added or removed by a plugin, don't add. 
    889             if ( 'core' == $priority ) { 
    890                 // If core box previously deleted, don't add 
    891                 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) 
    892                     return; 
    893                 // If box was added with default priority, give it core priority to maintain sort order 
    894                 if ( 'default' == $a_priority ) { 
    895                     $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id]; 
    896                     unset($wp_meta_boxes[$page][$a_context]['default'][$id]); 
    897                 } 
    898                 return; 
    899             } 
    900             // If no priority given and id already present, use existing priority 
    901             if ( empty($priority) ) { 
    902                 $priority = $a_priority; 
    903             // else if we're adding to the sorted priority, we don't know the title or callback. Grab them from the previously added context/priority. 
    904             } elseif ( 'sorted' == $priority ) { 
    905                 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title']; 
    906                 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback']; 
    907                 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args']; 
    908             } 
    909             // An id can be in only one priority and one context 
    910             if ( $priority != $a_priority || $context != $a_context ) 
    911                 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); 
    912         } 
    913     } 
    914  
    915     if ( empty($priority) ) 
    916         $priority = 'low'; 
    917  
    918     if ( !isset($wp_meta_boxes[$page][$context][$priority]) ) 
    919         $wp_meta_boxes[$page][$context][$priority] = array(); 
    920  
    921     $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args); 
    922 } 
    923  
    924 /** 
    925  * Meta-Box template function 
    926  * 
    927  * @since 2.5.0 
    928  * 
    929  * @param string $page page identifier, also known as screen identifier 
    930  * @param string $context box context 
    931  * @param mixed $object gets passed to the box callback function as first parameter 
    932  * @return int number of meta_boxes 
    933  */ 
    934 function do_meta_boxes($page, $context, $object) { 
    935     global $wp_meta_boxes; 
    936     static $already_sorted = false; 
    937  
    938     $hidden = get_hidden_meta_boxes($page); 
    939  
    940     printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context)); 
    941  
    942     $i = 0; 
    943     do { 
    944         // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose 
    945         if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) { 
    946             foreach ( $sorted as $box_context => $ids ) { 
    947                 foreach ( explode(',', $ids ) as $id ) { 
    948                     if ( $id && 'dashboard_browser_nag' !== $id ) 
    949                         add_meta_box( $id, null, null, $page, $box_context, 'sorted' ); 
    950                 } 
    951             } 
    952         } 
    953         $already_sorted = true; 
    954  
    955         if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) 
    956             break; 
    957  
    958         foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) { 
    959             if ( isset($wp_meta_boxes[$page][$context][$priority]) ) { 
    960                 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { 
    961                     if ( false == $box || ! $box['title'] ) 
    962                         continue; 
    963                     $i++; 
    964                     $style = ''; 
    965                     $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; 
    966                     echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n"; 
    967                     if ( 'dashboard_browser_nag' != $box['id'] ) 
    968                         echo '<div class="handlediv" title="' . esc_attr__('Click to toggle') . '"><br /></div>'; 
    969                     echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n"; 
    970                     echo '<div class="inside">' . "\n"; 
    971                     call_user_func($box['callback'], $object, $box); 
    972                     echo "</div>\n"; 
    973                     echo "</div>\n"; 
    974                 } 
    975             } 
    976         } 
    977     } while(0); 
    978  
    979     echo "</div>"; 
    980  
    981     return $i; 
    982  
    983 } 
    984  
    985 /** 
    986  * Remove a meta box from an edit form. 
    987  * 
    988  * @since 2.6.0 
    989  * 
    990  * @param string $id String for use in the 'id' attribute of tags. 
    991  * @param string $page The type of edit page on which to show the box (post, page, link). 
    992  * @param string $context The context within the page where the boxes should show ('normal', 'advanced'). 
    993  */ 
    994 function remove_meta_box($id, $page, $context) { 
    995     global $wp_meta_boxes; 
    996  
    997     if ( !isset($wp_meta_boxes) ) 
    998         $wp_meta_boxes = array(); 
    999     if ( !isset($wp_meta_boxes[$page]) ) 
    1000         $wp_meta_boxes[$page] = array(); 
    1001     if ( !isset($wp_meta_boxes[$page][$context]) ) 
    1002         $wp_meta_boxes[$page][$context] = array(); 
    1003  
    1004     foreach ( array('high', 'core', 'default', 'low') as $priority ) 
    1005         $wp_meta_boxes[$page][$context][$priority][$id] = false; 
    100643} 
    100744 
     
    1068105 
    1069106/** 
    1070  * Add a new section to a settings page. 
    1071  * 
    1072  * Part of the Settings API. Use this to define new settings sections for an admin page. 
    1073  * Show settings sections in your admin page callback function with do_settings_sections(). 
    1074  * Add settings fields to your section with add_settings_field() 
    1075  * 
    1076  * The $callback argument should be the name of a function that echoes out any 
    1077  * content you want to show at the top of the settings section before the actual 
    1078  * fields. It can output nothing if you want. 
    1079  * 
    1080  * @since 2.7.0 
    1081  * 
    1082  * @global $wp_settings_sections Storage array of all settings sections added to admin pages 
    1083  * 
    1084  * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags. 
    1085  * @param string $title Formatted title of the section. Shown as the heading for the section. 
    1086  * @param string $callback Function that echos out any content at the top of the section (between heading and fields). 
    1087  * @param string $page The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page(); 
    1088  */ 
    1089 function add_settings_section($id, $title, $callback, $page) { 
    1090     global $wp_settings_sections; 
    1091  
    1092     if ( 'misc' == $page ) { 
    1093         _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) ); 
    1094         $page = 'general'; 
    1095     } 
    1096  
    1097     if ( !isset($wp_settings_sections) ) 
    1098         $wp_settings_sections = array(); 
    1099     if ( !isset($wp_settings_sections[$page]) ) 
    1100         $wp_settings_sections[$page] = array(); 
    1101     if ( !isset($wp_settings_sections[$page][$id]) ) 
    1102         $wp_settings_sections[$page][$id] = array(); 
    1103  
    1104     $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); 
    1105 } 
    1106  
    1107 /** 
    1108  * Add a new field to a section of a settings page 
    1109  * 
    1110  * Part of the Settings API. Use this to define a settings field that will show 
    1111  * as part of a settings section inside a settings page. The fields are shown using 
    1112  * do_settings_fields() in do_settings-sections() 
    1113  * 
    1114  * The $callback argument should be the name of a function that echoes out the 
    1115  * html input tags for this setting field. Use get_option() to retrieve existing 
    1116  * values to show. 
    1117  * 
    1118  * @since 2.7.0 
    1119  * 
    1120  * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections 
    1121  * 
    1122  * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags. 
    1123  * @param string $title Formatted title of the field. Shown as the label for the field during output. 
    1124  * @param string $callback Function that fills the field with the desired form inputs. The function should echo its output. 
    1125  * @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...). 
    1126  * @param string $section The slug-name of the section of the settings page in which to show the box (default, ...). 
    1127  * @param array $args Additional arguments 
    1128  */ 
    1129 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) { 
    1130     global $wp_settings_fields; 
    1131  
    1132     if ( 'misc' == $page ) { 
    1133         _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) ); 
    1134         $page = 'general'; 
    1135     } 
    1136  
    1137     if ( !isset($wp_settings_fields) ) 
    1138         $wp_settings_fields = array(); 
    1139     if ( !isset($wp_settings_fields[$page]) ) 
    1140         $wp_settings_fields[$page] = array(); 
    1141     if ( !isset($wp_settings_fields[$page][$section]) ) 
    1142         $wp_settings_fields[$page][$section] = array(); 
    1143  
    1144     $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args); 
    1145 } 
    1146  
    1147 /** 
    1148  * Prints out all settings sections added to a particular settings page 
    1149  * 
    1150  * Part of the Settings API. Use this in a settings page callback function 
    1151  * to output all the sections and fields that were added to that $page with 
    1152  * add_settings_section() and add_settings_field() 
    1153  * 
    1154  * @global $wp_settings_sections Storage array of all settings sections added to admin pages 
    1155  * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections 
    1156  * @since 2.7.0 
    1157  * 
    1158  * @param string $page The slug name of the page whos settings sections you want to output 
    1159  */ 
    1160 function do_settings_sections($page) { 
    1161     global $wp_settings_sections, $wp_settings_fields; 
    1162  
    1163     if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) 
    1164         return; 
    1165  
    1166     foreach ( (array) $wp_settings_sections[$page] as $section ) { 
    1167         if ( $section['title'] ) 
    1168             echo "<h3>{$section['title']}</h3>\n"; 
    1169         call_user_func($section['callback'], $section); 
    1170         if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) ) 
    1171             continue; 
    1172         echo '<table class="form-table">'; 
    1173         do_settings_fields($page, $section['id']); 
    1174         echo '</table>'; 
    1175     } 
    1176 } 
    1177  
    1178 /** 
    1179  * Print out the settings fields for a particular settings section 
    1180  * 
    1181  * Part of the Settings API. Use this in a settings page to output 
    1182  * a specific section. Should normally be called by do_settings_sections() 
    1183  * rather than directly. 
    1184  * 
    1185  * @global $wp_settings_fields Storage array of settings fields and their pages/sections 
    1186  * 
    1187  * @since 2.7.0 
    1188  * 
    1189  * @param string $page Slug title of the admin page who's settings fields you want to show. 
    1190  * @param section $section Slug title of the settings section who's fields you want to show. 
    1191  */ 
    1192 function do_settings_fields($page, $section) { 
    1193     global $wp_settings_fields; 
    1194  
    1195     if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) 
    1196         return; 
    1197  
    1198     foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { 
    1199         echo '<tr valign="top">'; 
    1200         if ( !empty($field['args']['label_for']) ) 
    1201             echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>'; 
    1202         else 
    1203             echo '<th scope="row">' . $field['title'] . '</th>'; 
    1204         echo '<td>'; 
    1205         call_user_func($field['callback'], $field['args']); 
    1206         echo '</td>'; 
    1207         echo '</tr>'; 
    1208     } 
    1209 } 
    1210  
    1211 /** 
    1212  * Register a settings error to be displayed to the user 
    1213  * 
    1214  * Part of the Settings API. Use this to show messages to users about settings validation 
    1215  * problems, missing settings or anything else. 
    1216  * 
    1217  * Settings errors should be added inside the $sanitize_callback function defined in 
    1218  * register_setting() for a given setting to give feedback about the submission. 
    1219  * 
    1220  * By default messages will show immediately after the submission that generated the error. 
    1221  * Additional calls to settings_errors() can be used to show errors even when the settings 
    1222  * page is first accessed. 
    1223  * 
    1224  * @since 3.0.0 
    1225  * 
    1226  * @global array $wp_settings_errors Storage array of errors registered during this pageload 
    1227  * 
    1228  * @param string $setting Slug title of the setting to which this error applies 
    1229  * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output. 
    1230  * @param string $message The formatted message text to display to the user (will be shown inside styled <div> and <p>) 
    1231  * @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'. 
    1232  */ 
    1233 function add_settings_error( $setting, $code, $message, $type = 'error' ) { 
    1234     global $wp_settings_errors; 
    1235  
    1236     if ( !isset($wp_settings_errors) ) 
    1237         $wp_settings_errors = array(); 
    1238  
    1239     $new_error = array( 
    1240         'setting' => $setting, 
    1241         'code' => $code, 
    1242         'message' => $message, 
    1243         'type' => $type 
    1244     ); 
    1245     $wp_settings_errors[] = $new_error; 
    1246 } 
    1247  
    1248 /** 
    1249  * Fetch settings errors registered by add_settings_error() 
    1250  * 
    1251  * Checks the $wp_settings_errors array for any errors declared during the current 
    1252  * pageload and returns them. 
    1253  * 
    1254  * If changes were just submitted ($_GET['settings-updated']) and settings errors were saved 
    1255  * to the 'settings_errors' transient then those errors will be returned instead. This 
    1256  * is used to pass errors back across pageloads. 
    1257  * 
    1258  * Use the $sanitize argument to manually re-sanitize the option before returning errors. 
    1259  * This is useful if you have errors or notices you want to show even when the user 
    1260  * hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook) 
    1261  * 
    1262  * @since 3.0.0 
    1263  * 
    1264  * @global array $wp_settings_errors Storage array of errors registered during this pageload 
    1265  * 
    1266  * @param string $setting Optional slug title of a specific setting who's errors you want. 
    1267  * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors. 
    1268  * @return array Array of settings errors 
    1269  */ 
    1270 function get_settings_errors( $setting = '', $sanitize = FALSE ) { 
    1271     global $wp_settings_errors; 
    1272  
    1273     // If $sanitize is true, manually re-run the sanitizisation for this option 
    1274     // This allows the $sanitize_callback from register_setting() to run, adding 
    1275     // any settings errors you want to show by default. 
    1276     if ( $sanitize ) 
    1277         sanitize_option( $setting, get_option($setting)); 
    1278  
    1279     // If settings were passed back from options.php then use them 
    1280     // Ignore transients if $sanitize is true, we don't want the old values anyway 
    1281     if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors') ) { 
    1282         $settings_errors = get_transient('settings_errors'); 
    1283         delete_transient('settings_errors'); 
    1284     // Otherwise check global in case validation has been run on this pageload 
    1285     } elseif ( count( $wp_settings_errors ) ) { 
    1286         $settings_errors = $wp_settings_errors; 
    1287     } else { 
    1288         return; 
    1289     } 
    1290  
    1291     // Filter the results to those of a specific setting if one was set 
    1292     if ( $setting ) { 
    1293         foreach ( (array) $settings_errors as $key => $details ) 
    1294             if ( $setting != $details['setting'] ) 
    1295                 unset( $settings_errors[$key] ); 
    1296     } 
    1297     return $settings_errors; 
    1298 } 
    1299  
    1300 /** 
    1301  * Display settings errors registered by add_settings_error() 
    1302  * 
    1303  * Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors(). 
    1304  * 
    1305  * This is called automatically after a settings page based on the Settings API is submitted. 
    1306  * Errors should be added during the validation callback function for a setting defined in register_setting() 
    1307  * 
    1308  * The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization 
    1309  * on its current value. 
    1310  * 
    1311  * The $hide_on_update option will cause errors to only show when the settings page is first loaded. 
    1312  * if the user has already saved new values it will be hidden to avoid repeating messages already 
    1313  * shown in the default error reporting after submission. This is useful to show general errors like missing 
    1314  * settings when the user arrives at the settings page. 
    1315  * 
    1316  * @since 3.0.0 
    1317  * 
    1318  * @param string $setting Optional slug title of a specific setting who's errors you want. 
    1319  * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors. 
    1320  * @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted. 
    1321  */ 
    1322 function settings_errors( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) { 
    1323  
    1324     if ($hide_on_update AND $_GET['settings-updated']) return; 
    1325  
    1326     $settings_errors = get_settings_errors( $setting, $sanitize ); 
    1327  
    1328     if ( !is_array($settings_errors) ) return; 
    1329  
    1330     $output = ''; 
    1331     foreach ( $settings_errors as $key => $details ) { 
    1332         $css_id = 'setting-error-' . $details['code']; 
    1333         $css_class = $details['type'] . ' settings-error'; 
    1334         $output .= "<div id='$css_id' class='$css_class'> \n"; 
    1335         $output .= "<p><strong>{$details['message']}</strong></p>"; 
    1336         $output .= "</div> \n"; 
    1337     } 
    1338     echo $output; 
    1339 } 
    1340  
    1341 /** 
    1342  * {@internal Missing Short Description}} 
    1343  * 
    1344  * @since 2.7.0 
    1345  * 
    1346  * @param unknown_type $found_action 
    1347  */ 
    1348 function find_posts_div($found_action = '') { 
    1349 ?> 
    1350     <div id="find-posts" class="find-box" style="display:none;"> 
    1351         <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div> 
    1352         <div class="find-box-inside"> 
    1353             <div class="find-box-search"> 
    1354                 <?php if ( $found_action ) { ?> 
    1355                     <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" /> 
    1356                 <?php } ?> 
    1357  
    1358                 <input type="hidden" name="affected" id="affected" value="" /> 
    1359                 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> 
    1360                 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> 
    1361                 <input type="text" id="find-posts-input" name="ps" value="" /> 
    1362                 <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> 
    1363  
    1364                 <?php 
    1365                 $post_types = get_post_types( array('public' => true), 'objects' ); 
    1366                 foreach ( $post_types as $post ) { 
    1367                     if ( 'attachment' == $post->name ) 
    1368                         continue; 
    1369                 ?> 
    1370                 <input type="radio" name="find-posts-what" id="find-posts-<?php echo esc_attr($post->name); ?>" value="<?php echo esc_attr($post->name); ?>" <?php checked($post->name,  'post'); ?> /> 
    1371                 <label for="find-posts-<?php echo esc_attr($post->name); ?>"><?php echo $post->label; ?></label> 
    1372                 <?php 
    1373                 } ?> 
    1374             </div> 
    1375             <div id="find-posts-response"></div> 
    1376         </div> 
    1377         <div class="find-box-buttons"> 
    1378             <input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" /> 
    1379             <?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?> 
    1380         </div> 
    1381     </div> 
    1382 <?php 
    1383 } 
    1384  
    1385 /** 
    1386  * Display the post password. 
    1387  * 
    1388  * The password is passed through {@link esc_attr()} to ensure that it 
    1389  * is safe for placing in an html attribute. 
    1390  * 
    1391  * @uses attr 
    1392  * @since 2.7.0 
    1393  */ 
    1394 function the_post_password() { 
    1395     global $post; 
    1396     if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password ); 
    1397 } 
    1398  
    1399 /** 
    1400107 * {@internal Missing Short Description}} 
    1401108 * 
     
    1507214    } 
    1508215    echo "</div></div>\n"; 
    1509 } 
    1510  
    1511 /** 
    1512  * Get the post title. 
    1513  * 
    1514  * The post title is fetched and if it is blank then a default string is 
    1515  * returned. 
    1516  * 
    1517  * @since 2.7.0 
    1518  * @param int $post_id The post id. If not supplied the global $post is used. 
    1519  * @return string The post title if set 
    1520  */ 
    1521 function _draft_or_post_title( $post_id = 0 ) { 
    1522     $title = get_the_title($post_id); 
    1523     if ( empty($title) ) 
    1524         $title = __('(no title)'); 
    1525     return $title; 
    1526 } 
    1527  
    1528 /** 
    1529  * Display the search query. 
    1530  * 
    1531  * A simple wrapper to display the "s" parameter in a GET URI. This function 
    1532  * should only be used when {@link the_search_query()} cannot. 
    1533  * 
    1534  * @uses attr 
    1535  * @since 2.7.0 
    1536  * 
    1537  */ 
    1538 function _admin_search_query() { 
    1539     echo isset($_REQUEST['s']) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : ''; 
    1540 } 
    1541  
    1542 /** 
    1543  * Generic Iframe header for use with Thickbox 
    1544  * 
    1545  * @since 2.7.0 
    1546  * @param string $title Title of the Iframe page. 
    1547  * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued). 
    1548  * 
    1549  */ 
    1550 function iframe_header( $title = '', $limit_styles = false ) { 
    1551     show_admin_bar( false ); 
    1552     global $hook_suffix, $current_screen, $current_user, $admin_body_class, $wp_locale; 
    1553     $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); 
    1554     $admin_body_class .= ' iframe'; 
    1555  
    1556 ?><!DOCTYPE html> 
    1557 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> 
    1558 <head> 
    1559 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 
    1560 <title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title> 
    1561 <?php 
    1562 wp_enqueue_style( 'colors' ); 
    1563 ?> 
    1564 <script type="text/javascript"> 
    1565 //<![CDATA[ 
    1566 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; 
    1567 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();} 
    1568 var userSettings = { 
    1569         'url': '<?php echo SITECOOKIEPATH; ?>', 
    1570         'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>', 
    1571         'time':'<?php echo time() ?>' 
    1572     }, 
    1573     ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', 
    1574     pagenow = '<?php echo $current_screen->id; ?>', 
    1575     typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>', 
    1576     adminpage = '<?php echo $admin_body_class; ?>', 
    1577     thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', 
    1578     decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>', 
    1579     isRtl = <?php echo (int) is_rtl(); ?>; 
    1580 //]]> 
    1581 </script> 
    1582 <?php 
    1583 do_action('admin_enqueue_scripts', $hook_suffix); 
    1584 do_action("admin_print_styles-$hook_suffix"); 
    1585 do_action('admin_print_styles'); 
    1586 do_action("admin_print_scripts-$hook_suffix"); 
    1587 do_action('admin_print_scripts'); 
    1588 do_action("admin_head-$hook_suffix"); 
    1589 do_action('admin_head'); 
    1590 ?> 
    1591 </head> 
    1592 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>  class="no-js <?php echo $admin_body_class; ?>"> 
    1593 <script type="text/javascript"> 
    1594 //<![CDATA[ 
    1595 (function(){ 
    1596 var c = document.body.className; 
    1597 c = c.replace(/no-js/, 'js'); 
    1598 document.body.className = c; 
    1599 })(); 
    1600 //]]> 
    1601 </script> 
    1602 <?php 
    1603 } 
    1604  
    1605 /** 
    1606  * Generic Iframe footer for use with Thickbox 
    1607  * 
    1608  * @since 2.7.0 
    1609  * 
    1610  */ 
    1611 function iframe_footer() { 
    1612     //We're going to hide any footer output on iframe pages, but run the hooks anyway since they output Javascript or other needed content. ?> 
    1613     <div class="hidden"> 
    1614 <?php 
    1615     do_action('admin_footer', ''); 
    1616     do_action('admin_print_footer_scripts'); ?> 
    1617     </div> 
    1618 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script> 
    1619 </body> 
    1620 </html> 
    1621 <?php 
    1622 } 
    1623  
    1624 function _post_states($post) { 
    1625     $post_states = array(); 
    1626     if ( isset($_GET['post_status']) ) 
    1627         $post_status = $_GET['post_status']; 
    1628     else 
    1629         $post_status = ''; 
    1630  
    1631     if ( !empty($post->post_password) ) 
    1632         $post_states['protected'] = __('Password protected'); 
    1633     if ( 'private' == $post->post_status && 'private' != $post_status ) 
    1634         $post_states['private'] = __('Private'); 
    1635     if ( 'draft' == $post->post_status && 'draft' != $post_status ) 
    1636         $post_states['draft'] = __('Draft'); 
    1637     if ( 'pending' == $post->post_status && 'pending' != $post_status ) 
    1638         /* translators: post state */ 
    1639         $post_states['pending'] = _x('Pending', 'post state'); 
    1640     if ( is_sticky($post->ID) ) 
    1641         $post_states['sticky'] = __('Sticky'); 
    1642  
    1643     $post_states = apply_filters( 'display_post_states', $post_states ); 
    1644  
    1645     if ( ! empty($post_states) ) { 
    1646         $state_count = count($post_states); 
    1647         $i = 0; 
    1648         echo ' - '; 
    1649         foreach ( $post_states as $state ) { 
    1650             ++$i; 
    1651             ( $i == $state_count ) ? $sep = '' : $sep = ', '; 
    1652             echo "<span class='post-state'>$state$sep</span>"; 
    1653         } 
    1654     } 
    1655  
    1656     if ( get_post_format( $post->ID ) ) 
    1657         echo ' - <span class="post-state-format">' . get_post_format_string( get_post_format( $post->ID ) ) . '</span>'; 
    1658 } 
    1659  
    1660 function _media_states( $post ) { 
    1661     $media_states = array(); 
    1662     $stylesheet = get_option('stylesheet'); 
    1663  
    1664     if ( current_theme_supports( 'custom-header') ) { 
    1665         $meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true ); 
    1666         if ( ! empty( $meta_header ) && $meta_header == $stylesheet ) 
    1667             $media_states[] = __( 'Header Image' ); 
    1668     } 
    1669  
    1670     if ( current_theme_supports( 'custom-background') ) { 
    1671         $meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true ); 
    1672         if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) 
    1673             $media_states[] = __( 'Background Image' ); 
    1674     } 
    1675  
    1676     $media_states = apply_filters( 'display_media_states', $media_states ); 
    1677  
    1678     if ( ! empty( $media_states ) ) { 
    1679         $state_count = count( $media_states ); 
    1680         $i = 0; 
    1681         echo ' - '; 
    1682         foreach ( $media_states as $state ) { 
    1683             ++$i; 
    1684             ( $i == $state_count ) ? $sep = '' : $sep = ', '; 
    1685             echo "<span class='post-state'>$state$sep</span>"; 
    1686         } 
    1687     } 
    1688216} 
    1689217 
     
    2037565 
    2038566/** 
    2039  * Test support for compressing JavaScript from PHP 
    2040  * 
    2041  * Outputs JavaScript that tests if compression from PHP works as expected 
    2042  * and sets an option with the result. Has no effect when the current user 
    2043  * is not an administrator. To run the test again the option 'can_compress_scripts' 
    2044  * has to be deleted. 
    2045  * 
    2046  * @since 2.8.0 
    2047  */ 
    2048 function compression_test() { 
    2049 ?> 
    2050     <script type="text/javascript"> 
    2051     /* <![CDATA[ */ 
    2052     var testCompression = { 
    2053         get : function(test) { 
    2054             var x; 
    2055             if ( window.XMLHttpRequest ) { 
    2056                 x = new XMLHttpRequest(); 
    2057             } else { 
    2058                 try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};} 
    2059             } 
    2060  
    2061             if (x) { 
    2062                 x.onreadystatechange = function() { 
    2063                     var r, h; 
    2064                     if ( x.readyState == 4 ) { 
    2065                         r = x.responseText.substr(0, 18); 
    2066                         h = x.getResponseHeader('Content-Encoding'); 
    2067                         testCompression.check(r, h, test); 
    2068                     } 
    2069                 } 
    2070  
    2071                 x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true); 
    2072                 x.send(''); 
    2073             } 
    2074         }, 
    2075  
    2076         check : function(r, h, test) { 
    2077             if ( ! r && ! test ) 
    2078                 this.get(1); 
    2079  
    2080             if ( 1 == test ) { 
    2081                 if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) ) 
    2082                     this.get('no'); 
    2083                 else 
    2084                     this.get(2); 
    2085  
    2086                 return; 
    2087             } 
    2088  
    2089             if ( 2 == test ) { 
    2090                 if ( '"wpCompressionTest' == r ) 
    2091                     this.get('yes'); 
    2092                 else 
    2093                     this.get('no'); 
    2094             } 
    2095         } 
    2096     }; 
    2097     testCompression.check(); 
    2098     /* ]]> */ 
    2099     </script> 
    2100 <?php 
    2101 } 
    2102  
    2103 /** 
    2104567 *  Get the current screen object 
    2105568 * 
     
    2132595 
    2133596    $current_screen = apply_filters('current_screen', $current_screen); 
    2134 } 
    2135  
    2136 /** 
    2137  * Echos a submit button, with provided text and appropriate class 
    2138  * 
    2139  * @since 3.1.0 
    2140  * 
    2141  * @param string $text The text of the button (defaults to 'Save Changes') 
    2142  * @param string $type The type of button. One of: primary, secondary, delete 
    2143  * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute 
    2144  *               is given in $other_attributes below, $name will be used as the button's id. 
    2145  * @param bool $wrap True if the output button should be wrapped in a paragraph tag, 
    2146  *             false otherwise. Defaults to true 
    2147  * @param array|string $other_attributes Other attributes that should be output with the button, 
    2148  *                     mapping attributes to their values, such as array( 'tabindex' => '1' ). 
    2149  *                     These attributes will be output as attribute="value", such as tabindex="1". 
    2150  *                     Defaults to no other attributes. Other attributes can also be provided as a 
    2151  *                     string such as 'tabindex="1"', though the array format is typically cleaner. 
    2152  */ 
    2153 function submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) { 
    2154     echo get_submit_button( $text, $type, $name, $wrap, $other_attributes ); 
    2155 } 
    2156  
    2157 /** 
    2158  * Returns a submit button, with provided text and appropriate class 
    2159  * 
    2160  * @since 3.1.0 
    2161  * 
    2162  * @param string $text The text of the button (defaults to 'Save Changes') 
    2163  * @param string $type The type of button. One of: primary, secondary, delete 
    2164  * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute 
    2165  *               is given in $other_attributes below, $name will be used as the button's id. 
    2166  * @param bool $wrap True if the output button should be wrapped in a paragraph tag, 
    2167  *             false otherwise. Defaults to true 
    2168  * @param array|string $other_attributes Other attributes that should be output with the button, 
    2169  *                     mapping attributes to their values, such as array( 'tabindex' => '1' ). 
    2170  *                     These attributes will be output as attribute="value", such as tabindex="1". 
    2171  *                     Defaults to no other attributes. Other attributes can also be provided as a 
    2172  *                     string such as 'tabindex="1"', though the array format is typically cleaner. 
    2173  */ 
    2174 function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) { 
    2175     switch ( $type ) : 
    2176         case 'primary' : 
    2177         case 'secondary' : 
    2178             $class = 'button-' . $type; 
    2179             break; 
    2180         case 'delete' : 
    2181             $class = 'button-secondary delete'; 
    2182             break; 
    2183         default : 
    2184             $class = $type; // Custom cases can just pass in the classes they want to be used 
    2185     endswitch; 
    2186     $text = ( NULL == $text ) ? __( 'Save Changes' ) : $text; 
    2187  
    2188     // Default the id attribute to $name unless an id was specifically provided in $other_attributes 
    2189     $id = $name; 
    2190     if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) { 
    2191         $id = $other_attributes['id']; 
    2192         unset( $other_attributes['id'] ); 
    2193     } 
    2194  
    2195     $attributes = ''; 
    2196     if ( is_array( $other_attributes ) ) { 
    2197         foreach ( $other_attributes as $attribute => $value ) { 
    2198             $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important 
    2199         } 
    2200     } else if ( !empty( $other_attributes ) ) { // Attributes provided as a string 
    2201         $attributes = $other_attributes; 
    2202     } 
    2203  
    2204     $button = '<input type="submit" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ); 
    2205     $button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />'; 
    2206  
    2207     if ( $wrap ) { 
    2208         $button = '<p class="submit">' . $button . '</p>'; 
    2209     } 
    2210  
    2211     return $button; 
    2212 } 
    2213  
    2214 /** 
    2215  * Initializes the new feature pointers. 
    2216  * 
    2217  * @since 3.3.0 
    2218  * 
    2219  * Pointer user settings: 
    2220  *    p0 - Admin bar pointer, added 3.3. 
    2221  */ 
    2222 function wp_pointer_enqueue( $hook_suffix ) { 
    2223     $enqueue = false; 
    2224  
    2225     $admin_bar = get_user_setting( 'p0', 0 ); 
    2226     if ( ! $admin_bar && apply_filters( 'show_wp_pointer_admin_bar', true ) ) { 
    2227         $enqueue = true; 
    2228         add_action( 'admin_print_footer_scripts', '_wp_pointer_print_admin_bar' ); 
    2229     } 
    2230  
    2231     if ( $enqueue ) { 
    2232         wp_enqueue_style( 'wp-pointer' ); 
    2233         wp_enqueue_script( 'wp-pointer' ); 
    2234         wp_enqueue_script( 'utils' ); 
    2235     } 
    2236 } 
    2237 add_action( 'admin_enqueue_scripts', 'wp_pointer_enqueue' ); 
    2238  
    2239 function _wp_pointer_print_admin_bar() { 
    2240     $pointer_content  = '<h3>' . ('The admin bar has been updated in WordPress 3.3.') . '</h3>'; 
    2241     $pointer_content .= '<p>' . sprintf( ('Have some feedback? Visit this <a href="%s">ticket</a>.'), 'http://core.trac.wordpress.org/ticket/18197' ) . '</p>'; 
    2242     $pointer_content .= '<p>' . sprintf( ('P.S. You are looking at a new admin pointer. Chime in <a href="%s">here</a>.'), 'http://core.trac.wordpress.org/ticket/18693' ) . '</p>'; 
    2243  
    2244 ?> 
    2245 <script type="text/javascript"> 
    2246 //<![CDATA[ 
    2247 jQuery(document).ready( function($) { 
    2248     $('#wpadminbar').pointer({ 
    2249         content: '<?php echo $pointer_content; ?>', 
    2250         position: { 
    2251             my: 'left top', 
    2252             at: 'center bottom', 
    2253             offset: '-25 0' 
    2254         }, 
    2255         close: function() { 
    2256             setUserSetting( 'p0', '1' ); 
    2257         } 
    2258     }).pointer('open'); 
    2259 }); 
    2260 //]]> 
    2261 </script> 
    2262 <?php 
    2263597} 
    2264598 
  • trunk/wp-admin/includes/template.php

    r18781 r18782  
    220220        echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>"; 
    221221    } 
    222 } 
    223  
    224 /** 
    225  * Get the column headers for a screen 
    226  * 
    227  * @since 2.7.0 
    228  * 
    229  * @param string|object $screen The screen you want the headers for 
    230  * @return array Containing the headers in the format id => UI String 
    231  */ 
    232 function get_column_headers( $screen ) { 
    233     if ( is_string( $screen ) ) 
    234         $screen = convert_to_screen( $screen ); 
    235  
    236     global $_wp_column_headers; 
    237  
    238     if ( !isset( $_wp_column_headers[ $screen->id ] ) ) { 
    239         $_wp_column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() ); 
    240     } 
    241  
    242     return $_wp_column_headers[ $screen->id ]; 
    243 } 
    244  
    245 /** 
    246  * Get a list of hidden columns. 
    247  * 
    248  * @since 2.7.0 
    249  * 
    250  * @param string|object $screen The screen you want the hidden columns for 
    251  * @return array 
    252  */ 
    253 function get_hidden_columns( $screen ) { 
    254     if ( is_string( $screen ) ) 
    255         $screen = convert_to_screen( $screen ); 
    256  
    257     return (array) get_user_option( 'manage' . $screen->id . 'columnshidden' ); 
    258222} 
    259223 
     
    1007971 
    1008972/** 
    1009  * {@internal Missing Short Description}} 
    1010  * 
    1011  * @since 2.7.0 
    1012  * 
    1013  * @param unknown_type $screen 
    1014  */ 
    1015 function meta_box_prefs($screen) { 
    1016     global $wp_meta_boxes; 
    1017  
    1018     if ( is_string($screen) ) 
    1019         $screen = convert_to_screen($screen); 
    1020  
    1021     if ( empty($wp_meta_boxes[$screen->id]) ) 
    1022         return; 
    1023  
    1024     $hidden = get_hidden_meta_boxes($screen); 
    1025  
    1026     foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) { 
    1027         foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) { 
    1028             foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) { 
    1029                 if ( false == $box || ! $box['title'] ) 
    1030                     continue; 
    1031                 // Submit box cannot be hidden 
    1032                 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) 
    1033                     continue; 
    1034                 $box_id = $box['id']; 
    1035                 echo '<label for="' . $box_id . '-hide">'; 
    1036                 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"' : '') . ' />'; 
    1037                 echo "{$box['title']}</label>\n"; 
    1038             } 
    1039         } 
    1040     } 
    1041 } 
    1042  
    1043 /** 
    1044  * Get Hidden Meta Boxes 
    1045  * 
    1046  * @since 2.7.0 
    1047  * 
    1048  * @param string|object $screen Screen identifier 
    1049  * @return array Hidden Meta Boxes 
    1050  */ 
    1051 function get_hidden_meta_boxes( $screen ) { 
    1052     if ( is_string( $screen ) ) 
    1053         $screen = convert_to_screen( $screen ); 
    1054  
    1055     $hidden = get_user_option( "metaboxhidden_{$screen->id}" ); 
    1056  
    1057     // Hide slug boxes by default 
    1058     if ( !is_array( $hidden ) ) { 
    1059         if ( 'post' == $screen->base || 'page' == $screen->base ) 
    1060             $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); 
    1061         else 
    1062             $hidden = array( 'slugdiv' ); 
    1063         $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen); 
    1064     } 
    1065  
    1066     return $hidden; 
    1067 } 
    1068  
    1069 /** 
    1070973 * Add a new section to a settings page. 
    1071974 * 
     
    13951298    global $post; 
    13961299    if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password ); 
    1397 } 
    1398  
    1399 /** 
    1400  * {@internal Missing Short Description}} 
    1401  * 
    1402  * @since 2.7.0 
    1403  */ 
    1404 function favorite_actions( $screen = null ) { 
    1405     $default_action = false; 
    1406  
    1407     if ( is_string($screen) ) 
    1408         $screen = convert_to_screen($screen); 
    1409  
    1410     if ( $screen->is_user ) 
    1411         return; 
    1412  
    1413     if ( isset($screen->post_type) ) { 
    1414         $post_type_object = get_post_type_object($screen->post_type); 
    1415         if ( 'add' != $screen->action ) 
    1416             $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)); 
    1417         else 
    1418             $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts)); 
    1419     } 
    1420  
    1421     if ( !$default_action ) { 
    1422         if ( $screen->is_network ) { 
    1423             $default_action = array('sites.php' => array( __('Sites'), 'manage_sites')); 
    1424         } else { 
    1425             switch ( $screen->id ) { 
    1426                 case 'upload': 
    1427                     $default_action = array('media-new.php' => array(__('New Media'), 'upload_files')); 
    1428                     break; 
    1429                 case 'media': 
    1430                     $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files')); 
    1431                     break; 
    1432                 case 'link-manager': 
    1433                 case 'link': 
    1434                     if ( 'add' != $screen->action ) 
    1435                         $default_action = array('link-add.php' => array(__('New Link'), 'manage_links')); 
    1436                     else 
    1437                         $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links')); 
    1438                     break; 
    1439                 case 'users': 
    1440                     $default_action = array('user-new.php' => array(__('New User'), 'create_users')); 
    1441                     break; 
    1442                 case 'user': 
    1443                     $default_action = array('users.php' => array(__('Edit Users'), 'edit_users')); 
    1444                     break; 
    1445                 case 'plugins': 
    1446                     $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins')); 
    1447                     break; 
    1448                 case 'plugin-install': 
    1449                     $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins')); 
    1450                     break; 
    1451                 case 'themes': 
    1452                     $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes')); 
    1453                     break; 
    1454                 case 'theme-install': 
    1455                     $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes')); 
    1456                     break; 
    1457                 default: 
    1458                     $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts')); 
    1459                     break; 
    1460             } 
    1461         } 
    1462     } 
    1463  
    1464     if ( !$screen->is_network ) { 
    1465         $actions = array( 
    1466             'post-new.php' => array(__('New Post'), 'edit_posts'), 
    1467             'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'), 
    1468             'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'), 
    1469             'media-new.php' => array(__('Upload'), 'upload_files'), 
    1470             'edit-comments.php' => array(__('Comments'), 'moderate_comments') 
    1471             ); 
    1472     } else { 
    1473         $actions = array( 
    1474             'sites.php' => array( __('Sites'), 'manage_sites'), 
    1475             'users.php' => array( __('Users'), 'manage_network_users') 
    1476         ); 
    1477     } 
    1478  
    1479     $default_key = array_keys($default_action); 
    1480     $default_key = $default_key[0]; 
    1481     if ( isset($actions[$default_key]) ) 
    1482         unset($actions[$default_key]); 
    1483     $actions = array_merge($default_action, $actions); 
    1484     $actions = apply_filters( 'favorite_actions', $actions, $screen ); 
    1485  
    1486     $allowed_actions = array(); 
    1487     foreach ( $actions as $action => $data ) { 
    1488         if ( current_user_can($data[1]) ) 
    1489             $allowed_actions[$action] = $data[0]; 
    1490     } 
    1491  
    1492     if ( empty($allowed_actions) ) 
    1493         return; 
    1494  
    1495     $first = array_keys($allowed_actions); 
    1496     $first = $first[0]; 
    1497     echo '<div id="favorite-actions">'; 
    1498     echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>'; 
    1499     echo '<div id="favorite-inside">'; 
    1500  
    1501     array_shift($allowed_actions); 
    1502  
    1503     foreach ( $allowed_actions as $action => $label) { 
    1504         echo "<div class='favorite-action'><a href='$action'>"; 
    1505         echo $label; 
    1506         echo "</a></div>\n"; 
    1507     } 
    1508     echo "</div></div>\n"; 
    15091300} 
    15101301 
     
    16891480 
    16901481/** 
    1691  * Convert a screen string to a screen object 
    1692  * 
    1693  * @since 3.0.0 
    1694  * 
    1695  * @param string $screen The name of the screen 
    1696  * @return object An object containing the safe screen name and id 
    1697  */ 
    1698 function convert_to_screen( $screen ) { 
    1699     $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen); 
    1700  
    1701     if ( is_network_admin() ) 
    1702         $screen .= '-network'; 
    1703     elseif ( is_user_admin() ) 
    1704         $screen .= '-user'; 
    1705  
    1706     $screen = (string) apply_filters( 'screen_meta_screen', $screen ); 
    1707     $screen = (object) array('id' => $screen, 'base' => $screen); 
    1708     return $screen; 
    1709 } 
    1710  
    1711 function screen_meta($screen) { 
    1712     global $wp_meta_boxes, $_wp_contextual_help, $wp_list_table, $wp_current_screen_options; 
    1713  
    1714     if ( is_string($screen) ) 
    1715         $screen = convert_to_screen($screen); 
    1716  
    1717     $columns = get_column_headers( $screen ); 
    1718     $hidden = get_hidden_columns( $screen ); 
    1719  
    1720     $meta_screens = array('index' => 'dashboard'); 
    1721  
    1722     if ( isset($meta_screens[$screen->id]) ) { 
    1723         $screen->id = $meta_screens[$screen->id]; 
    1724         $screen->base = $screen->id; 
    1725     } 
    1726  
    1727     $show_screen = false; 
    1728     if ( !empty($wp_meta_boxes[$screen->id]) || !empty($columns) ) 
    1729         $show_screen = true; 
    1730  
    1731     $screen_options = screen_options($screen); 
    1732     if ( $screen_options ) 
    1733         $show_screen = true; 
    1734  
    1735     if ( !isset($_wp_contextual_help) ) 
    1736         $_wp_contextual_help = array(); 
    1737  
    1738     $settings = apply_filters('screen_settings', '', $screen); 
    1739  
    1740     switch ( $screen->id ) { 
    1741         case 'widgets': 
    1742             $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"; 
    1743             $show_screen = true; 
    1744             break; 
    1745     } 
    1746     if ( ! empty( $settings ) ) 
    1747         $show_screen = true; 
    1748  
    1749     if ( !empty($wp_current_screen_options) ) 
    1750         $show_screen = true; 
    1751  
    1752     $show_screen = apply_filters('screen_options_show_screen', $show_screen, $screen); 
    1753  
    1754     // If we have screen options, add the menu to the admin bar. 
    1755     if ( $show_screen ) 
    1756         add_action( 'admin_bar_menu', 'wp_admin_bar_screen_options_menu', 80 ); 
    1757  
    1758  
    1759 ?> 
    1760 <div id="screen-meta"> 
    1761 <?php if ( $show_screen ) : ?> 
    1762 <div id="screen-options-wrap" class="hidden"> 
    1763     <form id="adv-settings" action="" method="post"> 
    1764     <?php if ( isset($wp_meta_boxes[$screen->id]) ) : ?> 
    1765         <h5><?php _ex('Show on screen', 'Metaboxes') ?></h5> 
    1766         <div class="metabox-prefs"> 
    1767             <?php meta_box_prefs($screen); ?> 
    1768             <br class="clear" /> 
    1769         </div> 
    1770         <?php endif; 
    1771         if ( ! empty($columns) ) : ?> 
    1772         <h5><?php echo ( isset( $columns['_title'] ) ?  $columns['_title'] :  _x('Show on screen', 'Columns') ) ?></h5> 
    1773         <div class="metabox-prefs"> 
    1774 <?php 
    1775     $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname'); 
    1776  
    1777     foreach ( $columns as $column => $title ) { 
    1778         // Can't hide these for they are special 
    1779         if ( in_array( $column, $special ) ) 
    1780             continue; 
    1781         if ( empty( $title ) ) 
    1782             continue; 
    1783  
    1784         if ( 'comments' == $column ) 
    1785             $title = __( 'Comments' ); 
    1786         $id = "$column-hide"; 
    1787         echo '<label for="' . $id . '">'; 
    1788         echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />'; 
    1789         echo "$title</label>\n"; 
    1790     } 
    1791 ?> 
    1792             <br class="clear" /> 
    1793         </div> 
    1794     <?php endif; 
    1795     echo screen_layout($screen); 
    1796  
    1797     if ( !empty( $screen_options ) ) { 
    1798         ?> 
    1799         <h5><?php _ex('Show on screen', 'Screen Options') ?></h5> 
    1800         <?php 
    1801     } 
    1802  
    1803     echo $screen_options; 
    1804     echo $settings; ?> 
    1805     <div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div> 
    1806     </form> 
    1807 </div> 
    1808  
    1809 <?php endif; // $show_screen 
    1810  
    1811     $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen); 
    1812     ?> 
    1813     <div id="contextual-help-wrap" class="hidden"> 
    1814     <?php 
    1815     $contextual_help = ''; 
    1816     if ( isset($_wp_contextual_help[$screen->id]) && is_array($_wp_contextual_help[$screen->id]) ) { 
    1817         $contextual_help .= '<div class="metabox-prefs">' . "\n"; 
    1818  
    1819         /* 
    1820          * Loop through ['contextual-help-tabs'] 
    1821          *   - It's a nested array where $key=>$value >> $title=>$content 
    1822          * Has no output so can only loop the array once 
    1823          */ 
    1824         $contextual_help_tabs = ''; // store looped content for later 
    1825         $contextual_help_panels = ''; // store looped content for later 
    1826  
    1827         $tab_active = true; 
    1828  
    1829         foreach ( $_wp_contextual_help[$screen->id]['tabs'] as $tab ) { 
    1830             $tab_slug = sanitize_html_class( $tab[ 0 ] ); 
    1831             $contextual_help_tabs .= '<li class="tab-' . $tab_slug . ( ($tab_active) ? ' active' : '' ) . '">'; 
    1832             $contextual_help_tabs .= '<a href="#' . $tab_slug . '">' . $tab[1] . '</a>'; 
    1833             $contextual_help_tabs .= '</li>' ."\n"; 
    1834              
    1835             $contextual_help_panels .= '<div id="' . $tab_slug . '" class="help-tab-content' . ( ($tab_active) ? ' active' : '' ) . '">'; 
    1836             $contextual_help_panels .= $tab[2]; 
    1837             $contextual_help_panels .= "</div>\n"; 
    1838  
    1839             $tab_active = false; 
    1840         } 
    1841  
    1842         // Start output from loop: Tabbed help content 
    1843         $contextual_help .= '<ul class="contextual-help-tabs">' . "\n"; 
    1844         $contextual_help .= $contextual_help_tabs; 
    1845         $contextual_help .= '</ul>' ."\n"; 
    1846         $contextual_help .= '<div class="contextual-help-tabs-wrap">' . "\n"; 
    1847         $contextual_help .= $contextual_help_panels; 
    1848         $contextual_help .= "</div>\n"; 
    1849         // END: Tabbed help content 
    1850  
    1851         // Sidebar to right of tabs 
    1852         $contextual_help .= '<div class="contextual-help-links">' . "\n"; 
    1853         $contextual_help .= $_wp_contextual_help[$screen->id]['sidebar']; 
    1854         $contextual_help .= "</div>\n"; 
    1855          
    1856         $contextual_help .= "</div>\n"; // end metabox 
    1857          
    1858     } elseif ( isset($_wp_contextual_help[$screen->id]) ) { 
    1859         $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen->id] . "</div>\n"; 
    1860     } else { 
    1861         $contextual_help .= '<div class="metabox-prefs">'; 
    1862         $default_help  = __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>'); 
    1863         $default_help .= '<br />'; 
    1864         $default_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>'); 
    1865         $contextual_help .= apply_filters('default_contextual_help', $default_help); 
    1866         $contextual_help .= '</div>' . "\n"; 
    1867     } 
    1868  
    1869     echo apply_filters('contextual_help', $contextual_help, $screen->id, $screen); 
    1870     ?> 
    1871     </div> 
    1872  
    1873 </div> <?php // #screen-meta 
    1874 } 
    1875  
    1876 /** 
    1877  * Add contextual help text for a page 
    1878  * 
    1879  * The array $help takes the following format: 
    1880  *  array( 'contextual-help-tabs'   => array( $tab1_title => $tab1_value [, $tab2_title => $tab2_value, ...] ), 
    1881  *      'contextual-help-links' => $help_links_as_string ) 
    1882  * 
    1883  * For backwards compatability, a string is also accepted. 
    1884  * 
    1885  * @since 2.7.0 
    1886  * 
    1887  * @param string    $screen The handle for the screen to add help to.  This is usually the hook name returned by the add_*_page() functions. 
    1888  * @param array|string  $help   Creates tabs & links columns within help text in array. 
    1889  * 
    1890  */ 
    1891 function add_contextual_help($screen, $help) { 
    1892     global $_wp_contextual_help; 
    1893  
    1894     if ( is_string($screen) ) 
    1895         $screen = convert_to_screen($screen); 
    1896  
    1897     if ( !isset($_wp_contextual_help) ) 
    1898         $_wp_contextual_help = array(); 
    1899  
    1900     $_wp_contextual_help[$screen->id] = $help; 
    1901 } 
    1902  
    1903 function screen_layout($screen) { 
    1904     global $screen_layout_columns, $wp_current_screen_options; 
    1905  
    1906     if ( is_string($screen) ) 
    1907         $screen = convert_to_screen($screen); 
    1908  
    1909     // Back compat for plugins using the filter instead of add_screen_option() 
    1910     $columns = apply_filters('screen_layout_columns', array(), $screen->id, $screen); 
    1911     if ( !empty($columns) && isset($columns[$screen->id]) ) 
    1912         add_screen_option('layout_columns', array('max' => $columns[$screen->id]) ); 
    1913  
    1914     if ( !isset($wp_current_screen_options['layout_columns']) ) { 
    1915         $screen_layout_columns = 0; 
    1916         return ''; 
    1917     } 
    1918  
    1919     $screen_layout_columns = get_user_option("screen_layout_$screen->id"); 
    1920     $num = $wp_current_screen_options['layout_columns']['max']; 
    1921  
    1922     if ( ! $screen_layout_columns ) { 
    1923         if ( isset($wp_current_screen_options['layout_columns']['default']) ) 
    1924             $screen_layout_columns = $wp_current_screen_options['layout_columns']['default']; 
    1925         else 
    1926             $screen_layout_columns = 'auto'; 
    1927     } 
    1928  
    1929     $i = 1; 
    1930     $return = '<h5>' . __('Screen Layout') . "</h5>\n<div class='columns-prefs'>" . __('Number of Columns:') . "\n"; 
    1931     while ( $i <= $num ) { 
    1932         $return .= "<label><input type='radio' name='screen_columns' value='$i'" . ( ($screen_layout_columns == $i) ? " checked='checked'" : "" ) . " /> $i</label>\n"; 
    1933         ++$i; 
    1934     } 
    1935     $return .= "<label><input type='radio' id='wp_auto_columns' name='screen_columns' value='auto'" . ( ($screen_layout_columns == 'auto') ? " checked='checked'" : "" ) . " />" . __('auto') . "</label>\n"; 
    1936     $return .= "</div>\n"; 
    1937     return $return; 
    1938 } 
    1939  
    1940 /** 
    1941  * Register and configure an admin screen option 
    1942  * 
    1943  * @since 3.1.0 
    1944  * 
    1945  * @param string $option An option name. 
    1946  * @param mixed $args Option dependent arguments 
    1947  * @return void 
    1948  */ 
    1949 function add_screen_option( $option, $args = array() ) { 
    1950     global $wp_current_screen_options; 
    1951  
    1952     if ( !isset($wp_current_screen_options) ) 
    1953         $wp_current_screen_options = array(); 
    1954  
    1955     $wp_current_screen_options[$option] = $args; 
    1956 } 
    1957  
    1958 function screen_options($screen) { 
    1959     global $wp_current_screen_options; 
    1960  
    1961     if ( is_string($screen) ) 
    1962         $screen = convert_to_screen($screen); 
    1963  
    1964     if ( !isset($wp_current_screen_options['per_page']) ) 
    1965         return ''; 
    1966  
    1967     $per_page_label = $wp_current_screen_options['per_page']['label']; 
    1968  
    1969     if ( empty($wp_current_screen_options['per_page']['option']) ) { 
    1970         $option = str_replace( '-', '_', "{$screen->id}_per_page" ); 
    1971     } else { 
    1972         $option = $wp_current_screen_options['per_page']['option']; 
    1973     } 
    1974  
    1975     $per_page = (int) get_user_option( $option ); 
    1976     if ( empty( $per_page ) || $per_page < 1 ) { 
    1977         if ( isset($wp_current_screen_options['per_page']['default']) ) 
    1978             $per_page = $wp_current_screen_options['per_page']['default']; 
    1979         else 
    1980             $per_page = 20; 
    1981     } 
    1982  
    1983     if ( 'edit_comments_per_page' == $option ) 
    1984         $per_page = apply_filters( 'comments_per_page', $per_page, isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all' ); 
    1985     elseif ( 'categories_per_page' == $option ) 
    1986         $per_page = apply_filters( 'edit_categories_per_page', $per_page ); 
    1987     else 
    1988         $per_page = apply_filters( $option, $per_page ); 
    1989  
    1990     // Back compat 
    1991     if ( isset( $screen->post_type ) ) 
    1992         $per_page = apply_filters( 'edit_posts_per_page', $per_page, $screen->post_type ); 
    1993  
    1994     $return = "<div class='screen-options'>\n"; 
    1995     if ( !empty($per_page_label) ) 
    1996         $return .= "<input type='text' class='screen-per-page' name='wp_screen_options[value]' id='$option' maxlength='3' value='$per_page' /> <label for='$option'>$per_page_label</label>\n"; 
    1997     $return .= get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); 
    1998     $return .= "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />"; 
    1999     $return .= "</div>\n"; 
    2000     return $return; 
    2001 } 
    2002  
    2003 function screen_icon( $screen = '' ) { 
    2004     echo get_screen_icon( $screen ); 
    2005 } 
    2006  
    2007 function get_screen_icon( $screen = '' ) { 
    2008     global $current_screen, $typenow; 
    2009  
    2010     if ( empty($screen) ) 
    2011         $screen = $current_screen; 
    2012     elseif ( is_string($screen) ) 
    2013         $name = $screen; 
    2014  
    2015     $class = 'icon32'; 
    2016  
    2017     if ( empty($name) ) { 
    2018         if ( !empty($screen->parent_base) ) 
    2019             $name = $screen->parent_base; 
    2020         else 
    2021             $name = $screen->base; 
    2022  
    2023         if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type ) 
    2024             $name = 'edit-pages'; 
    2025  
    2026         $post_type = ''; 
    2027         if ( isset( $screen->post_type ) ) 
    2028             $post_type = $screen->post_type; 
    2029         elseif ( $current_screen == $screen ) 
    2030             $post_type = $typenow; 
    2031         if ( $post_type ) 
    2032             $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type ); 
    2033     } 
    2034  
    2035     return '<div id="icon-' . esc_attr( $name ) . '" class="' . $class . '"><br /></div>'; 
    2036 } 
    2037  
    2038 /** 
    20391482 * Test support for compressing JavaScript from PHP 
    20401483 * 
     
    20991542    </script> 
    21001543<?php 
    2101 } 
    2102  
    2103 /** 
    2104  *  Get the current screen object 
    2105  * 
    2106  *  @since 3.1.0 
    2107  * 
    2108  * @return object Current screen object 
    2109  */ 
    2110 function get_current_screen() { 
    2111     global $current_screen; 
    2112  
    2113     if ( !isset($current_screen) ) 
    2114         return null; 
    2115  
    2116     return $current_screen; 
    2117 } 
    2118  
    2119 /** 
    2120  * Set the current screen object 
    2121  * 
    2122  * @since 3.0.0 
    2123  * 
    2124  * @uses $current_screen 
    2125  * 
    2126  * @param string $id Screen id, optional. 
    2127  */ 
    2128 function set_current_screen( $id =  '' ) { 
    2129     global $current_screen; 
    2130  
    2131     $current_screen = new WP_Screen( $id ); 
    2132  
    2133     $current_screen = apply_filters('current_screen', $current_screen); 
    21341544} 
    21351545 
     
    22621672<?php 
    22631673} 
    2264  
    2265 class WP_Screen { 
    2266     var $action = ''; 
    2267     var $base; 
    2268     var $id; 
    2269     var $is_network; 
    2270     var $is_user; 
    2271     var $parent_base; 
    2272     var $parent_file; 
    2273     var $post_type; 
    2274     var $taxonomy; 
    2275  
    2276     function __construct( $id = '' ) { 
    2277         global $hook_suffix, $typenow, $taxnow; 
    2278  
    2279         $action = ''; 
    2280  
    2281         if ( empty( $id ) ) { 
    2282             $screen = $hook_suffix; 
    2283             $screen = str_replace('.php', '', $screen); 
    2284             if ( preg_match('/-add|-new$/', $screen) ) 
    2285                 $action = 'add'; 
    2286             $screen = str_replace('-new', '', $screen); 
    2287             $screen = str_replace('-add', '', $screen); 
    2288             $this->id = $this->base = $screen; 
    2289         } else { 
    2290             $id = sanitize_key( $id ); 
    2291             if ( false !== strpos($id, '-') ) { 
    2292                 list( $id, $typenow ) = explode('-', $id, 2); 
    2293                 if ( taxonomy_exists( $typenow ) ) { 
    2294                     $id = 'edit-tags'; 
    2295                     $taxnow = $typenow; 
    2296                     $typenow = ''; 
    2297                 } 
    2298             } 
    2299             $this->id = $this->base = $id; 
    2300         } 
    2301  
    2302         $this->action = $action; 
    2303  
    2304         // Map index to dashboard 
    2305         if ( 'index' == $this->base ) 
    2306             $this->base = 'dashboard'; 
    2307         if ( 'index' == $this->id ) 
    2308             $this->id = 'dashboard'; 
    2309  
    2310         if ( 'edit' == $this->id ) { 
    2311             if ( empty($typenow) ) 
    2312                 $typenow = 'post'; 
    2313             $this->id .= '-' . $typenow; 
    2314             $this->post_type = $typenow; 
    2315         } elseif ( 'post' == $this->id ) { 
    2316             if ( empty($typenow) ) 
    2317                 $typenow = 'post'; 
    2318             $this->id = $typenow; 
    2319             $this->post_type = $typenow; 
    2320         } elseif ( 'edit-tags' == $this->id ) { 
    2321             if ( empty($taxnow) ) 
    2322                 $taxnow = 'post_tag'; 
    2323             $this->id = 'edit-' . $taxnow; 
    2324             $this->taxonomy = $taxnow; 
    2325         } 
    2326  
    2327         $this->is_network = is_network_admin(); 
    2328         $this->is_user = is_user_admin(); 
    2329  
    2330         if ( $this->is_network ) { 
    2331             $this->base .= '-network'; 
    2332             $this->id .= '-network'; 
    2333         } elseif ( $this->is_user ) { 
    2334             $this->base .= '-user'; 
    2335             $this->id .= '-user'; 
    2336         } 
    2337     } 
    2338  
    2339     function set_parentage( $parent_file ) { 
    2340         $this->parent_file = $parent_file; 
    2341         $this->parent_base = preg_replace('/\?.*$/', '', $parent_file); 
    2342         $this->parent_base = str_replace('.php', '', $this->parent_base); 
    2343     } 
    2344  
    2345     function add_option( $option, $args = array() ) { 
    2346         return add_screen_option( $option, $args ); 
    2347     } 
    2348  
    2349     function add_help_tab( $id, $title, $content) { 
    2350         global $_wp_contextual_help; 
    2351  
    2352         $_wp_contextual_help[$this->id]['tabs'][] = array( $id, $title, $content ); 
    2353     } 
    2354  
    2355     function add_help_sidebar( $content ) { 
    2356         global $_wp_contextual_help; 
    2357  
    2358         $_wp_contextual_help[$this->id]['sidebar'] = $content; 
    2359     } 
    2360 } 
Note: See TracChangeset for help on using the changeset viewer.