164 * @param int $number Number of terms to retrieve. Defaults to 10. |
164 * @param int $number Number of terms to retrieve. Defaults to 10. |
165 * @param bool $echo Optionally output the list as well. Defaults to true. |
165 * @param bool $echo Optionally output the list as well. Defaults to true. |
166 * @return array List of popular term IDs. |
166 * @return array List of popular term IDs. |
167 */ |
167 */ |
168 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { |
168 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { |
169 global $post_ID; |
169 $post = get_post(); |
170 |
170 |
171 if ( $post_ID ) |
171 if ( $post && $post->ID ) |
172 $checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids')); |
172 $checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids')); |
173 else |
173 else |
174 $checked_terms = array(); |
174 $checked_terms = array(); |
175 |
175 |
176 $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); |
176 $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); |
177 |
177 |
330 <div id="replyhead" style="display:none;"><h5><?php _e( 'Reply to Comment' ); ?></h5></div> |
330 <div id="replyhead" style="display:none;"><h5><?php _e( 'Reply to Comment' ); ?></h5></div> |
331 <div id="addhead" style="display:none;"><h5><?php _e('Add new Comment'); ?></h5></div> |
331 <div id="addhead" style="display:none;"><h5><?php _e('Add new Comment'); ?></h5></div> |
332 <div id="edithead" style="display:none;"> |
332 <div id="edithead" style="display:none;"> |
333 <div class="inside"> |
333 <div class="inside"> |
334 <label for="author"><?php _e('Name') ?></label> |
334 <label for="author"><?php _e('Name') ?></label> |
335 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" /> |
335 <input type="text" name="newcomment_author" size="50" value="" id="author" /> |
336 </div> |
336 </div> |
337 |
337 |
338 <div class="inside"> |
338 <div class="inside"> |
339 <label for="author-email"><?php _e('E-mail') ?></label> |
339 <label for="author-email"><?php _e('E-mail') ?></label> |
340 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" /> |
340 <input type="text" name="newcomment_author_email" size="50" value="" id="author-email" /> |
341 </div> |
341 </div> |
342 |
342 |
343 <div class="inside"> |
343 <div class="inside"> |
344 <label for="author-url"><?php _e('URL') ?></label> |
344 <label for="author-url"><?php _e('URL') ?></label> |
345 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" /> |
345 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" /> |
346 </div> |
346 </div> |
347 <div style="clear:both;"></div> |
347 <div style="clear:both;"></div> |
348 </div> |
348 </div> |
349 |
349 |
350 <div id="replycontainer"> |
350 <div id="replycontainer"> |
351 <?php |
351 <?php |
352 $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ); |
352 $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ); |
353 wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings, 'tabindex' => 104 ) ); |
353 wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) ); |
354 ?> |
354 ?> |
355 </div> |
355 </div> |
356 |
356 |
357 <p id="replysubmit" class="submit"> |
357 <p id="replysubmit" class="submit"> |
358 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a> |
358 <a href="#comments-form" class="save button-primary alignright"> |
359 <a href="#comments-form" class="save button-primary alignright" tabindex="104"> |
|
360 <span id="addbtn" style="display:none;"><?php _e('Add Comment'); ?></span> |
359 <span id="addbtn" style="display:none;"><?php _e('Add Comment'); ?></span> |
361 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span> |
360 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span> |
362 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a> |
361 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a> |
363 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> |
362 <a href="#comments-form" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a> |
|
363 <span class="waiting spinner"></span> |
364 <span class="error" style="display:none;"></span> |
364 <span class="error" style="display:none;"></span> |
365 <br class="clear" /> |
365 <br class="clear" /> |
366 </p> |
366 </p> |
367 |
367 |
368 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" /> |
368 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" /> |
487 $entry['meta_id'] = (int) $entry['meta_id']; |
487 $entry['meta_id'] = (int) $entry['meta_id']; |
488 |
488 |
489 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); |
489 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); |
490 |
490 |
491 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; |
491 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; |
492 $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']}' />"; |
492 $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]' type='text' size='20' value='{$entry['meta_key']}' />"; |
493 |
493 |
494 $r .= "\n\t\t<div class='submit'>"; |
494 $r .= "\n\t\t<div class='submit'>"; |
495 $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' ) ); |
495 $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) ); |
496 $r .= "\n\t\t"; |
496 $r .= "\n\t\t"; |
497 $r .= get_submit_button( __( 'Update' ), "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta" , 'updatemeta', false, array( 'tabindex' => '6' ) ); |
497 $r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) ); |
498 $r .= "</div>"; |
498 $r .= "</div>"; |
499 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); |
499 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); |
500 $r .= "</td>"; |
500 $r .= "</td>"; |
501 |
501 |
502 $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>"; |
502 $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]' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>"; |
503 return $r; |
503 return $r; |
504 } |
504 } |
505 |
505 |
506 /** |
506 /** |
507 * {@internal Missing Short Description}} |
507 * {@internal Missing Short Description}} |
532 |
532 |
533 <tbody> |
533 <tbody> |
534 <tr> |
534 <tr> |
535 <td id="newmetaleft" class="left"> |
535 <td id="newmetaleft" class="left"> |
536 <?php if ( $keys ) { ?> |
536 <?php if ( $keys ) { ?> |
537 <select id="metakeyselect" name="metakeyselect" tabindex="7"> |
537 <select id="metakeyselect" name="metakeyselect"> |
538 <option value="#NONE#"><?php _e( '— Select —' ); ?></option> |
538 <option value="#NONE#"><?php _e( '— Select —' ); ?></option> |
539 <?php |
539 <?php |
540 |
540 |
541 foreach ( $keys as $key ) { |
541 foreach ( $keys as $key ) { |
542 echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>"; |
542 echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>"; |
543 } |
543 } |
544 ?> |
544 ?> |
545 </select> |
545 </select> |
546 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> |
546 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" value="" /> |
547 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> |
547 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> |
548 <span id="enternew"><?php _e('Enter new'); ?></span> |
548 <span id="enternew"><?php _e('Enter new'); ?></span> |
549 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a> |
549 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a> |
550 <?php } else { ?> |
550 <?php } else { ?> |
551 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> |
551 <input type="text" id="metakeyinput" name="metakeyinput" value="" /> |
552 <?php } ?> |
552 <?php } ?> |
553 </td> |
553 </td> |
554 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td> |
554 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea></td> |
555 </tr> |
555 </tr> |
556 |
556 |
557 <tr><td colspan="2" class="submit"> |
557 <tr><td colspan="2"> |
558 <?php submit_button( __( 'Add Custom Field' ), 'add:the-list:newmeta', 'addmeta', false, array( 'id' => 'addmetasub', 'tabindex' => '9' ) ); ?> |
558 <div class="submit"> |
|
559 <?php submit_button( __( 'Add Custom Field' ), 'secondary', 'addmeta', false, array( 'id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta' ) ); ?> |
|
560 </div> |
559 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?> |
561 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?> |
560 </td></tr> |
562 </td></tr> |
561 </tbody> |
563 </tbody> |
562 </table> |
564 </table> |
563 <?php |
565 <?php |
573 * @param unknown_type $for_post |
575 * @param unknown_type $for_post |
574 * @param unknown_type $tab_index |
576 * @param unknown_type $tab_index |
575 * @param unknown_type $multi |
577 * @param unknown_type $multi |
576 */ |
578 */ |
577 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { |
579 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { |
578 global $wp_locale, $post, $comment; |
580 global $wp_locale, $comment; |
|
581 $post = get_post(); |
579 |
582 |
580 if ( $for_post ) |
583 if ( $for_post ) |
581 $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); |
584 $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); |
582 |
585 |
583 $tab_index_attribute = ''; |
586 $tab_index_attribute = ''; |
668 * @param unknown_type $parent |
671 * @param unknown_type $parent |
669 * @param unknown_type $level |
672 * @param unknown_type $level |
670 * @return unknown |
673 * @return unknown |
671 */ |
674 */ |
672 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { |
675 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { |
673 global $wpdb, $post_ID; |
676 global $wpdb; |
|
677 $post = get_post(); |
674 $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) ); |
678 $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) ); |
675 |
679 |
676 if ( $items ) { |
680 if ( $items ) { |
677 foreach ( $items as $item ) { |
681 foreach ( $items as $item ) { |
678 // A page cannot be its own parent. |
682 // A page cannot be its own parent. |
679 if (!empty ( $post_ID ) ) { |
683 if ( $post->ID && $item->ID == $post->ID ) |
680 if ( $item->ID == $post_ID ) { |
684 continue; |
681 continue; |
685 |
682 } |
|
683 } |
|
684 $pad = str_repeat( ' ', $level * 3 ); |
686 $pad = str_repeat( ' ', $level * 3 ); |
685 if ( $item->ID == $default) |
687 if ( $item->ID == $default) |
686 $current = ' selected="selected"'; |
688 $current = ' selected="selected"'; |
687 else |
689 else |
688 $current = ''; |
690 $current = ''; |
768 } |
770 } |
769 echo $p . $r; |
771 echo $p . $r; |
770 } |
772 } |
771 |
773 |
772 /** |
774 /** |
773 * {@internal Missing Short Description}} |
|
774 * |
|
775 * @since 2.3.0 |
|
776 * |
|
777 * @param unknown_type $size |
|
778 * @return unknown |
|
779 */ |
|
780 function wp_convert_hr_to_bytes( $size ) { |
|
781 $size = strtolower($size); |
|
782 $bytes = (int) $size; |
|
783 if ( strpos($size, 'k') !== false ) |
|
784 $bytes = intval($size) * 1024; |
|
785 elseif ( strpos($size, 'm') !== false ) |
|
786 $bytes = intval($size) * 1024 * 1024; |
|
787 elseif ( strpos($size, 'g') !== false ) |
|
788 $bytes = intval($size) * 1024 * 1024 * 1024; |
|
789 return $bytes; |
|
790 } |
|
791 |
|
792 /** |
|
793 * {@internal Missing Short Description}} |
|
794 * |
|
795 * @since 2.3.0 |
|
796 * |
|
797 * @param unknown_type $bytes |
|
798 * @return unknown |
|
799 */ |
|
800 function wp_convert_bytes_to_hr( $bytes ) { |
|
801 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' ); |
|
802 $log = log( $bytes, 1024 ); |
|
803 $power = (int) $log; |
|
804 $size = pow(1024, $log - $power); |
|
805 return $size . $units[$power]; |
|
806 } |
|
807 |
|
808 /** |
|
809 * {@internal Missing Short Description}} |
|
810 * |
|
811 * @since 2.5.0 |
|
812 * |
|
813 * @return unknown |
|
814 */ |
|
815 function wp_max_upload_size() { |
|
816 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); |
|
817 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); |
|
818 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); |
|
819 return $bytes; |
|
820 } |
|
821 |
|
822 /** |
|
823 * Outputs the form used by the importers to accept the data to be imported |
775 * Outputs the form used by the importers to accept the data to be imported |
824 * |
776 * |
825 * @since 2.0.0 |
777 * @since 2.0.0 |
826 * |
778 * |
827 * @param string $action The action attribute for the form. |
779 * @param string $action The action attribute for the form. |
833 if ( ! empty( $upload_dir['error'] ) ) : |
785 if ( ! empty( $upload_dir['error'] ) ) : |
834 ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p> |
786 ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p> |
835 <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php |
787 <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php |
836 else : |
788 else : |
837 ?> |
789 ?> |
838 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>"> |
790 <form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>"> |
839 <p> |
791 <p> |
840 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>) |
792 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>) |
841 <input type="file" id="upload" name="import" size="25" /> |
793 <input type="file" id="upload" name="import" size="25" /> |
842 <input type="hidden" name="action" value="save" /> |
794 <input type="hidden" name="action" value="save" /> |
843 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> |
795 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> |
1038 */ |
990 */ |
1039 function add_settings_section($id, $title, $callback, $page) { |
991 function add_settings_section($id, $title, $callback, $page) { |
1040 global $wp_settings_sections; |
992 global $wp_settings_sections; |
1041 |
993 |
1042 if ( 'misc' == $page ) { |
994 if ( 'misc' == $page ) { |
1043 _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) ); |
995 _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) ); |
1044 $page = 'general'; |
996 $page = 'general'; |
|
997 } |
|
998 |
|
999 if ( 'privacy' == $page ) { |
|
1000 _deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) ); |
|
1001 $page = 'reading'; |
1045 } |
1002 } |
1046 |
1003 |
1047 if ( !isset($wp_settings_sections) ) |
1004 if ( !isset($wp_settings_sections) ) |
1048 $wp_settings_sections = array(); |
1005 $wp_settings_sections = array(); |
1049 if ( !isset($wp_settings_sections[$page]) ) |
1006 if ( !isset($wp_settings_sections[$page]) ) |
1082 if ( 'misc' == $page ) { |
1039 if ( 'misc' == $page ) { |
1083 _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) ); |
1040 _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) ); |
1084 $page = 'general'; |
1041 $page = 'general'; |
1085 } |
1042 } |
1086 |
1043 |
|
1044 if ( 'privacy' == $page ) { |
|
1045 _deprecated_argument( __FUNCTION__, '3.5', __( 'The privacy options group has been removed. Use another settings group.' ) ); |
|
1046 $page = 'reading'; |
|
1047 } |
|
1048 |
1087 if ( !isset($wp_settings_fields) ) |
1049 if ( !isset($wp_settings_fields) ) |
1088 $wp_settings_fields = array(); |
1050 $wp_settings_fields = array(); |
1089 if ( !isset($wp_settings_fields[$page]) ) |
1051 if ( !isset($wp_settings_fields[$page]) ) |
1090 $wp_settings_fields[$page] = array(); |
1052 $wp_settings_fields[$page] = array(); |
1091 if ( !isset($wp_settings_fields[$page][$section]) ) |
1053 if ( !isset($wp_settings_fields[$page][$section]) ) |
1105 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections |
1067 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections |
1106 * @since 2.7.0 |
1068 * @since 2.7.0 |
1107 * |
1069 * |
1108 * @param string $page The slug name of the page whos settings sections you want to output |
1070 * @param string $page The slug name of the page whos settings sections you want to output |
1109 */ |
1071 */ |
1110 function do_settings_sections($page) { |
1072 function do_settings_sections( $page ) { |
1111 global $wp_settings_sections, $wp_settings_fields; |
1073 global $wp_settings_sections, $wp_settings_fields; |
1112 |
1074 |
1113 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) |
1075 if ( ! isset( $wp_settings_sections ) || !isset( $wp_settings_sections[$page] ) ) |
1114 return; |
1076 return; |
1115 |
1077 |
1116 foreach ( (array) $wp_settings_sections[$page] as $section ) { |
1078 foreach ( (array) $wp_settings_sections[$page] as $section ) { |
1117 if ( $section['title'] ) |
1079 if ( $section['title'] ) |
1118 echo "<h3>{$section['title']}</h3>\n"; |
1080 echo "<h3>{$section['title']}</h3>\n"; |
1119 call_user_func($section['callback'], $section); |
1081 |
1120 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) ) |
1082 if ( $section['callback'] ) |
|
1083 call_user_func( $section['callback'], $section ); |
|
1084 |
|
1085 if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) ) |
1121 continue; |
1086 continue; |
1122 echo '<table class="form-table">'; |
1087 echo '<table class="form-table">'; |
1123 do_settings_fields($page, $section['id']); |
1088 do_settings_fields( $page, $section['id'] ); |
1124 echo '</table>'; |
1089 echo '</table>'; |
1125 } |
1090 } |
1126 } |
1091 } |
1127 |
1092 |
1128 /** |
1093 /** |
1146 return; |
1111 return; |
1147 |
1112 |
1148 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { |
1113 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { |
1149 echo '<tr valign="top">'; |
1114 echo '<tr valign="top">'; |
1150 if ( !empty($field['args']['label_for']) ) |
1115 if ( !empty($field['args']['label_for']) ) |
1151 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>'; |
1116 echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>'; |
1152 else |
1117 else |
1153 echo '<th scope="row">' . $field['title'] . '</th>'; |
1118 echo '<th scope="row">' . $field['title'] . '</th>'; |
1154 echo '<td>'; |
1119 echo '<td>'; |
1155 call_user_func($field['callback'], $field['args']); |
1120 call_user_func($field['callback'], $field['args']); |
1156 echo '</td>'; |
1121 echo '</td>'; |
1222 |
1187 |
1223 // If $sanitize is true, manually re-run the sanitizisation for this option |
1188 // If $sanitize is true, manually re-run the sanitizisation for this option |
1224 // This allows the $sanitize_callback from register_setting() to run, adding |
1189 // This allows the $sanitize_callback from register_setting() to run, adding |
1225 // any settings errors you want to show by default. |
1190 // any settings errors you want to show by default. |
1226 if ( $sanitize ) |
1191 if ( $sanitize ) |
1227 sanitize_option( $setting, get_option($setting)); |
1192 sanitize_option( $setting, get_option( $setting ) ); |
1228 |
1193 |
1229 // If settings were passed back from options.php then use them |
1194 // If settings were passed back from options.php then use them |
1230 // Ignore transients if $sanitize is true, we don't want the old values anyway |
1195 if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) { |
1231 if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors') ) { |
1196 $wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) ); |
1232 $settings_errors = get_transient('settings_errors'); |
1197 delete_transient( 'settings_errors' ); |
1233 delete_transient('settings_errors'); |
1198 } |
1234 // Otherwise check global in case validation has been run on this pageload |
1199 |
1235 } elseif ( count( $wp_settings_errors ) ) { |
1200 // Check global in case errors have been added on this pageload |
1236 $settings_errors = $wp_settings_errors; |
1201 if ( ! count( $wp_settings_errors ) ) |
1237 } else { |
1202 return array(); |
1238 return; |
|
1239 } |
|
1240 |
1203 |
1241 // Filter the results to those of a specific setting if one was set |
1204 // Filter the results to those of a specific setting if one was set |
1242 if ( $setting ) { |
1205 if ( $setting ) { |
1243 foreach ( (array) $settings_errors as $key => $details ) |
1206 $setting_errors = array(); |
1244 if ( $setting != $details['setting'] ) |
1207 foreach ( (array) $wp_settings_errors as $key => $details ) { |
1245 unset( $settings_errors[$key] ); |
1208 if ( $setting == $details['setting'] ) |
1246 } |
1209 $setting_errors[] = $wp_settings_errors[$key]; |
1247 return $settings_errors; |
1210 } |
|
1211 return $setting_errors; |
|
1212 } |
|
1213 |
|
1214 return $wp_settings_errors; |
1248 } |
1215 } |
1249 |
1216 |
1250 /** |
1217 /** |
1251 * Display settings errors registered by add_settings_error() |
1218 * Display settings errors registered by add_settings_error() |
1252 * |
1219 * |
1309 |
1276 |
1310 <input type="hidden" name="affected" id="affected" value="" /> |
1277 <input type="hidden" name="affected" id="affected" value="" /> |
1311 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> |
1278 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> |
1312 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> |
1279 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> |
1313 <input type="text" id="find-posts-input" name="ps" value="" /> |
1280 <input type="text" id="find-posts-input" name="ps" value="" /> |
1314 <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> |
1281 <span class="spinner"></span> |
1315 |
1282 <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /> |
1316 <?php |
|
1317 $post_types = get_post_types( array('public' => true), 'objects' ); |
|
1318 foreach ( $post_types as $post ) { |
|
1319 if ( 'attachment' == $post->name ) |
|
1320 continue; |
|
1321 ?> |
|
1322 <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'); ?> /> |
|
1323 <label for="find-posts-<?php echo esc_attr($post->name); ?>"><?php echo $post->label; ?></label> |
|
1324 <?php |
|
1325 } ?> |
|
1326 </div> |
1283 </div> |
1327 <div id="find-posts-response"></div> |
1284 <div id="find-posts-response"></div> |
1328 </div> |
1285 </div> |
1329 <div class="find-box-buttons"> |
1286 <div class="find-box-buttons"> |
1330 <input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" /> |
1287 <input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" /> |
1342 * |
1299 * |
1343 * @uses attr |
1300 * @uses attr |
1344 * @since 2.7.0 |
1301 * @since 2.7.0 |
1345 */ |
1302 */ |
1346 function the_post_password() { |
1303 function the_post_password() { |
1347 global $post; |
1304 $post = get_post(); |
1348 if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password ); |
1305 if ( isset( $post->post_password ) ) |
|
1306 echo esc_attr( $post->post_password ); |
1349 } |
1307 } |
1350 |
1308 |
1351 /** |
1309 /** |
1352 * Get the post title. |
1310 * Get the post title. |
1353 * |
1311 * |
1354 * The post title is fetched and if it is blank then a default string is |
1312 * The post title is fetched and if it is blank then a default string is |
1355 * returned. |
1313 * returned. |
1356 * |
1314 * |
1357 * @since 2.7.0 |
1315 * @since 2.7.0 |
1358 * @param int $post_id The post id. If not supplied the global $post is used. |
1316 * @param mixed $post Post id or object. If not supplied the global $post is used. |
1359 * @return string The post title if set |
1317 * @return string The post title if set |
1360 */ |
1318 */ |
1361 function _draft_or_post_title( $post_id = 0 ) { |
1319 function _draft_or_post_title( $post = 0 ) { |
1362 $title = get_the_title($post_id); |
1320 $title = get_the_title( $post ); |
1363 if ( empty($title) ) |
1321 if ( empty( $title ) ) |
1364 $title = __('(no title)'); |
1322 $title = __( '(no title)' ); |
1365 return $title; |
1323 return $title; |
1366 } |
1324 } |
1367 |
1325 |
1368 /** |
1326 /** |
1369 * Display the search query. |
1327 * Display the search query. |
1392 global $hook_suffix, $current_user, $admin_body_class, $wp_locale; |
1350 global $hook_suffix, $current_user, $admin_body_class, $wp_locale; |
1393 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); |
1351 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); |
1394 |
1352 |
1395 $current_screen = get_current_screen(); |
1353 $current_screen = get_current_screen(); |
1396 |
1354 |
|
1355 @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); |
1397 _wp_admin_html_begin(); |
1356 _wp_admin_html_begin(); |
1398 ?> |
1357 ?> |
1399 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title> |
1358 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title> |
1400 <?php |
1359 <?php |
1401 wp_enqueue_style( 'colors' ); |
1360 wp_enqueue_style( 'colors' ); |
1428 do_action('admin_head'); |
1387 do_action('admin_head'); |
1429 |
1388 |
1430 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); |
1389 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); |
1431 ?> |
1390 ?> |
1432 </head> |
1391 </head> |
1433 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin no-js iframe <?php echo apply_filters( 'admin_body_class', '' ) . ' ' . $admin_body_class; ?>"> |
1392 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo apply_filters( 'admin_body_class', '' ) . ' ' . $admin_body_class; ?>"> |
1434 <script type="text/javascript"> |
1393 <script type="text/javascript"> |
1435 //<![CDATA[ |
1394 //<![CDATA[ |
1436 (function(){ |
1395 (function(){ |
1437 var c = document.body.className; |
1396 var c = document.body.className; |
1438 c = c.replace(/no-js/, 'js'); |
1397 c = c.replace(/no-js/, 'js'); |
1629 * mapping attributes to their values, such as array( 'tabindex' => '1' ). |
1588 * mapping attributes to their values, such as array( 'tabindex' => '1' ). |
1630 * These attributes will be output as attribute="value", such as tabindex="1". |
1589 * These attributes will be output as attribute="value", such as tabindex="1". |
1631 * Defaults to no other attributes. Other attributes can also be provided as a |
1590 * Defaults to no other attributes. Other attributes can also be provided as a |
1632 * string such as 'tabindex="1"', though the array format is typically cleaner. |
1591 * string such as 'tabindex="1"', though the array format is typically cleaner. |
1633 */ |
1592 */ |
1634 function get_submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) { |
1593 function get_submit_button( $text = null, $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = null ) { |
1635 switch ( $type ) : |
1594 if ( ! is_array( $type ) ) |
1636 case 'primary' : |
1595 $type = explode( ' ', $type ); |
1637 case 'secondary' : |
1596 |
1638 $class = 'button-' . $type; |
1597 $button_shorthand = array( 'primary', 'small', 'large' ); |
1639 break; |
1598 $classes = array( 'button' ); |
1640 case 'delete' : |
1599 foreach ( $type as $t ) { |
1641 $class = 'button-secondary delete'; |
1600 if ( 'secondary' === $t || 'button-secondary' === $t ) |
1642 break; |
1601 continue; |
1643 default : |
1602 $classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t; |
1644 $class = $type; // Custom cases can just pass in the classes they want to be used |
1603 } |
1645 endswitch; |
1604 $class = implode( ' ', array_unique( $classes ) ); |
1646 $text = ( null == $text ) ? __( 'Save Changes' ) : $text; |
1605 |
|
1606 if ( 'delete' === $type ) |
|
1607 $class = 'button-secondary delete'; |
|
1608 |
|
1609 $text = $text ? $text : __( 'Save Changes' ); |
1647 |
1610 |
1648 // Default the id attribute to $name unless an id was specifically provided in $other_attributes |
1611 // Default the id attribute to $name unless an id was specifically provided in $other_attributes |
1649 $id = $name; |
1612 $id = $name; |
1650 if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) { |
1613 if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) { |
1651 $id = $other_attributes['id']; |
1614 $id = $other_attributes['id']; |
1704 * Format: array( hook_suffix => pointer_id ) |
1667 * Format: array( hook_suffix => pointer_id ) |
1705 */ |
1668 */ |
1706 |
1669 |
1707 $registered_pointers = array( |
1670 $registered_pointers = array( |
1708 'index.php' => 'wp330_toolbar', |
1671 'index.php' => 'wp330_toolbar', |
1709 'post-new.php' => 'wp330_media_uploader', |
1672 'post-new.php' => 'wp350_media', |
1710 'post.php' => 'wp330_media_uploader', |
1673 'post.php' => 'wp350_media', |
1711 'themes.php' => array( 'wp330_saving_widgets', 'wp340_customize_current_theme_link' ), |
1674 'themes.php' => array( 'wp330_saving_widgets', 'wp340_customize_current_theme_link' ), |
1712 'appearance_page_custom-header' => 'wp340_choose_image_from_library', |
1675 'appearance_page_custom-header' => 'wp340_choose_image_from_library', |
1713 'appearance_page_custom-background' => 'wp340_choose_image_from_library', |
1676 'appearance_page_custom-background' => 'wp340_choose_image_from_library', |
1714 ); |
1677 ); |
1715 |
1678 |
1718 return; |
1681 return; |
1719 |
1682 |
1720 $pointers = (array) $registered_pointers[ $hook_suffix ]; |
1683 $pointers = (array) $registered_pointers[ $hook_suffix ]; |
1721 |
1684 |
1722 $caps_required = array( |
1685 $caps_required = array( |
1723 'wp330_media_uploader' => array( 'upload_files' ), |
|
1724 'wp330_saving_widgets' => array( 'edit_theme_options', 'switch_themes' ), |
1686 'wp330_saving_widgets' => array( 'edit_theme_options', 'switch_themes' ), |
1725 'wp340_customize_current_theme_link' => array( 'edit_theme_options' ), |
1687 'wp340_customize_current_theme_link' => array( 'edit_theme_options' ), |
1726 'wp340_choose_image_from_library' => array( 'edit_theme_options' ), |
1688 'wp340_choose_image_from_library' => array( 'edit_theme_options' ), |
|
1689 'wp350_media' => array( 'upload_files' ), |
1727 ); |
1690 ); |
1728 |
1691 |
1729 // Get dismissed pointers |
1692 // Get dismissed pointers |
1730 $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); |
1693 $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); |
1731 |
1694 |
1756 * |
1719 * |
1757 * @since 3.3.0 |
1720 * @since 3.3.0 |
1758 * |
1721 * |
1759 * @param string $pointer_id The pointer ID. |
1722 * @param string $pointer_id The pointer ID. |
1760 * @param string $selector The HTML elements, on which the pointer should be attached. |
1723 * @param string $selector The HTML elements, on which the pointer should be attached. |
1761 * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.dev.js). |
1724 * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.js). |
1762 */ |
1725 */ |
1763 private static function print_js( $pointer_id, $selector, $args ) { |
1726 private static function print_js( $pointer_id, $selector, $args ) { |
1764 if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) ) |
1727 if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) ) |
1765 return; |
1728 return; |
1766 |
1729 |
1813 /** |
1776 /** |
1814 * Print 'Updated Media Uploader' for 3.3.0. |
1777 * Print 'Updated Media Uploader' for 3.3.0. |
1815 * |
1778 * |
1816 * @since 3.3.0 |
1779 * @since 3.3.0 |
1817 */ |
1780 */ |
1818 public static function pointer_wp330_media_uploader() { |
1781 public static function pointer_wp330_media_uploader() {} |
1819 $content = '<h3>' . __( 'Updated Media Uploader' ) . '</h3>'; |
|
1820 $content .= '<p>' . __( 'The single media icon now launches the uploader for all file types, and the new drag and drop interface makes uploading a breeze.' ) . '</p>'; |
|
1821 |
|
1822 WP_Internal_Pointers::print_js( 'wp330_media_uploader', '#content-add_media', array( |
|
1823 'content' => $content, |
|
1824 'position' => array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' ), |
|
1825 ) ); |
|
1826 } |
|
1827 |
1782 |
1828 /** |
1783 /** |
1829 * Print 'New Feature: Saving Widgets' for 3.3.0. |
1784 * Print 'New Feature: Saving Widgets' for 3.3.0. |
1830 * |
1785 * |
1831 * @since 3.3.0 |
1786 * @since 3.3.0 |
1869 'content' => $content, |
1824 'content' => $content, |
1870 'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'defer_loading' => true ), |
1825 'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'defer_loading' => true ), |
1871 ) ); |
1826 ) ); |
1872 } |
1827 } |
1873 |
1828 |
|
1829 public static function pointer_wp350_media() { |
|
1830 $content = '<h3>' . __( 'New Media Manager' ) . '</h3>'; |
|
1831 $content .= '<p>' . __( 'Uploading files and creating image galleries has a whole new look. Check it out!' ) . '</p>'; |
|
1832 |
|
1833 self::print_js( 'wp350_media', '.insert-media', array( |
|
1834 'content' => $content, |
|
1835 'position' => array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' ), |
|
1836 ) ); |
|
1837 } |
|
1838 |
1874 /** |
1839 /** |
1875 * Prevents new users from seeing existing 'new feature' pointers. |
1840 * Prevents new users from seeing existing 'new feature' pointers. |
1876 * |
1841 * |
1877 * @since 3.3.0 |
1842 * @since 3.3.0 |
1878 */ |
1843 */ |
1879 public static function dismiss_pointers_for_new_users( $user_id ) { |
1844 public static function dismiss_pointers_for_new_users( $user_id ) { |
1880 add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp330_toolbar,wp330_media_uploader,wp330_saving_widgets,wp340_choose_image_from_library,wp340_customize_current_theme_link' ); |
1845 add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp330_toolbar,wp330_saving_widgets,wp340_choose_image_from_library,wp340_customize_current_theme_link,wp350_media' ); |
1881 } |
1846 } |
1882 } |
1847 } |
1883 |
1848 |
1884 add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); |
1849 add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); |
1885 add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) ); |
1850 add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) ); |