X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/dc1231b7312fbdca99e9e887cc2bb35a28f85cdc..refs/tags/wordpress-4.4:/wp-admin/includes/template.php
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index a0b248f9..e65c7d0f 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -8,126 +8,16 @@
* @subpackage Administration
*/
+/** Walker_Category_Checklist class */
+require_once( ABSPATH . 'wp-admin/includes/class-walker-category-checklist.php' );
+
+/** WP_Internal_Pointers class */
+require_once( ABSPATH . 'wp-admin/includes/class-wp-internal-pointers.php' );
+
//
// Category Checklists
//
-/**
- * Walker to output an unordered list of category checkbox input elements.
- *
- * @since 2.5.1
- *
- * @see Walker
- * @see wp_category_checklist()
- * @see wp_terms_checklist()
- */
-class Walker_Category_Checklist extends Walker {
- public $tree_type = 'category';
- public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
-
- /**
- * Starts the list before the elements are added.
- *
- * @see Walker:start_lvl()
- *
- * @since 2.5.1
- *
- * @param string $output Passed by reference. Used to append additional content.
- * @param int $depth Depth of category. Used for tab indentation.
- * @param array $args An array of arguments. @see wp_terms_checklist()
- */
- public function start_lvl( &$output, $depth = 0, $args = array() ) {
- $indent = str_repeat("\t", $depth);
- $output .= "$indent
\n";
- }
-
- /**
- * Ends the list of after the elements are added.
- *
- * @see Walker::end_lvl()
- *
- * @since 2.5.1
- *
- * @param string $output Passed by reference. Used to append additional content.
- * @param int $depth Depth of category. Used for tab indentation.
- * @param array $args An array of arguments. @see wp_terms_checklist()
- */
- public function end_lvl( &$output, $depth = 0, $args = array() ) {
- $indent = str_repeat("\t", $depth);
- $output .= "$indent
\n";
- }
-
- /**
- * Start the element output.
- *
- * @see Walker::start_el()
- *
- * @since 2.5.1
- *
- * @param string $output Passed by reference. Used to append additional content.
- * @param object $category The current term object.
- * @param int $depth Depth of the term in reference to parents. Default 0.
- * @param array $args An array of arguments. @see wp_terms_checklist()
- * @param int $id ID of the current term.
- */
- public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
- if ( empty( $args['taxonomy'] ) ) {
- $taxonomy = 'category';
- } else {
- $taxonomy = $args['taxonomy'];
- }
-
- if ( $taxonomy == 'category' ) {
- $name = 'post_category';
- } else {
- $name = 'tax_input[' . $taxonomy . ']';
- }
-
- $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
- $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
-
- $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
-
- /** This filter is documented in wp-includes/category-template.php */
- if ( ! empty( $args['list_only'] ) ) {
- $aria_cheched = 'false';
- $inner_class = 'category';
-
- if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
- $inner_class .= ' selected';
- $aria_cheched = 'true';
- }
-
- $output .= "\n" . '
\n";
@@ -1102,23 +1049,40 @@ function do_meta_boxes( $screen, $context, $object ) {
}
/**
- * Remove a meta box from an edit form.
+ * Removes a meta box from one or more screens.
*
* @since 2.6.0
+ * @since 4.4.0 The `$screen` parameter now accepts an array of screen IDs.
*
* @global array $wp_meta_boxes
*
- * @param string $id String for use in the 'id' attribute of tags.
- * @param string|object $screen The screen on which to show the box (post, page, link).
- * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
+ * @param string $id Meta box ID (used in the 'id' attribute for the meta box).
+ * @param string|array|WP_Screen $screen The screen or screens on which the meta box is shown (such as a
+ * post type, 'link', or 'comment'). Accepts a single screen ID,
+ * WP_Screen object, or array of screen IDs.
+ * @param string $context Optional. The context within the screen where the boxes
+ * should display. Available contexts vary from screen to
+ * screen. Post edit screen contexts include 'normal', 'side',
+ * and 'advanced'. Comments screen contexts include 'normal'
+ * and 'side'. Menus meta boxes (accordion sections) all use
+ * the 'side' context. Global default is 'advanced'.
*/
-function remove_meta_box($id, $screen, $context) {
+function remove_meta_box( $id, $screen, $context ) {
global $wp_meta_boxes;
- if ( empty( $screen ) )
+ if ( empty( $screen ) ) {
$screen = get_current_screen();
- elseif ( is_string( $screen ) )
+ } elseif ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
+ } elseif ( is_array( $screen ) ) {
+ foreach ( $screen as $single_screen ) {
+ remove_meta_box( $id, $single_screen, $context );
+ }
+ }
+
+ if ( ! isset( $screen->id ) ) {
+ return;
+ }
$page = $screen->id;
@@ -1187,7 +1151,7 @@ function do_accordion_sections( $screen, $context, $object ) {
-
+
@@ -1305,7 +1269,7 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default',
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
* @since 2.7.0
*
- * @param string $page The slug name of the page whos settings sections you want to output
+ * @param string $page The slug name of the page whose settings sections you want to output
*/
function do_settings_sections( $page ) {
global $wp_settings_sections, $wp_settings_fields;
@@ -1315,7 +1279,7 @@ function do_settings_sections( $page ) {
foreach ( (array) $wp_settings_sections[$page] as $section ) {
if ( $section['title'] )
- echo "
{$section['title']}
\n";
+ echo "
{$section['title']}
\n";
if ( $section['callback'] )
call_user_func( $section['callback'], $section );
@@ -1509,7 +1473,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
}
/**
- * {@internal Missing Short Description}}
+ * Outputs the modal window used for attaching media to posts or pages in the media-listing screen.
*
* @since 2.7.0
*
@@ -1728,12 +1692,14 @@ function _post_states($post) {
$post_states['scheduled'] = __( 'Scheduled' );
}
- if ( get_option( 'page_on_front' ) == $post->ID ) {
- $post_states['page_on_front'] = __( 'Front Page' );
- }
+ if ( 'page' === get_option( 'show_on_front' ) ) {
+ if ( intval( get_option( 'page_on_front' ) ) === $post->ID ) {
+ $post_states['page_on_front'] = __( 'Front Page' );
+ }
- if ( get_option( 'page_for_posts' ) == $post->ID ) {
- $post_states['page_for_posts'] = __( 'Posts Page' );
+ if ( intval( get_option( 'page_for_posts' ) ) === $post->ID ) {
+ $post_states['page_for_posts'] = __( 'Posts Page' );
+ }
}
/**
@@ -1741,15 +1707,15 @@ function _post_states($post) {
*
* @since 2.8.0
*
- * @param array $post_states An array of post display states.
- * @param int $post The post ID.
+ * @param array $post_states An array of post display states.
+ * @param WP_Post $post The current post object.
*/
$post_states = apply_filters( 'display_post_states', $post_states, $post );
if ( ! empty($post_states) ) {
$state_count = count($post_states);
$i = 0;
- echo ' - ';
+ echo ' — ';
foreach ( $post_states as $state ) {
++$i;
( $i == $state_count ) ? $sep = '' : $sep = ', ';
@@ -1796,7 +1762,7 @@ function _media_states( $post ) {
if ( ! empty( $media_states ) ) {
$state_count = count( $media_states );
$i = 0;
- echo ' - ';
+ echo ' — ';
foreach ( $media_states as $state ) {
++$i;
( $i == $state_count ) ? $sep = '' : $sep = ', ';
@@ -1998,159 +1964,6 @@ function _wp_admin_html_begin() {
pointer callback
- * )
- *
- * Example:
- * array(
- * 'themes.php' => 'wp390_widgets'
- * )
- */
- $registered_pointers = array(
- // None currently
- );
-
- // Check if screen related pointer is registered
- if ( empty( $registered_pointers[ $hook_suffix ] ) )
- return;
-
- $pointers = (array) $registered_pointers[ $hook_suffix ];
-
- /*
- * Specify required capabilities for feature pointers
- *
- * Format:
- * array(
- * pointer callback => Array of required capabilities
- * )
- *
- * Example:
- * array(
- * 'wp390_widgets' => array( 'edit_theme_options' )
- * )
- */
- $caps_required = array(
- // None currently
- );
-
- // Get dismissed pointers
- $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
-
- $got_pointers = false;
- foreach ( array_diff( $pointers, $dismissed ) as $pointer ) {
- if ( isset( $caps_required[ $pointer ] ) ) {
- foreach ( $caps_required[ $pointer ] as $cap ) {
- if ( ! current_user_can( $cap ) )
- continue 2;
- }
- }
-
- // Bind pointer print function
- add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) );
- $got_pointers = true;
- }
-
- if ( ! $got_pointers )
- return;
-
- // Add pointers script and style to queue
- wp_enqueue_style( 'wp-pointer' );
- wp_enqueue_script( 'wp-pointer' );
- }
-
- /**
- * Print the pointer JavaScript data.
- *
- * @since 3.3.0
- *
- * @static
- *
- * @param string $pointer_id The pointer ID.
- * @param string $selector The HTML elements, on which the pointer should be attached.
- * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.js).
- */
- private static function print_js( $pointer_id, $selector, $args ) {
- if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) )
- return;
-
- ?>
-
- '_invalid', 'base' => '_are_belong_to_us' );
}
@@ -2197,6 +2010,8 @@ function _local_storage_notice() {
* number of ratings may also be displayed by passing the $number parameter.
*
* @since 3.8.0
+ * @since 4.4.0 Introduced the `echo` parameter.
+ *
* @param array $args {
* Optional. Array of star ratings arguments.
*
@@ -2205,13 +2020,16 @@ function _local_storage_notice() {
* @type string $type Format that the $rating is in. Valid values are 'rating' (default),
* or, 'percent'. Default 'rating'.
* @type int $number The number of ratings that makes up this rating. Default 0.
+ * @type bool $echo Whether to echo the generated markup. False to return the markup instead
+ * of echoing it. Default true.
* }
*/
function wp_star_rating( $args = array() ) {
$defaults = array(
'rating' => 0,
- 'type' => 'rating',
+ 'type' => 'rating',
'number' => 0,
+ 'echo' => true,
);
$r = wp_parse_args( $args, $defaults );
@@ -2237,12 +2055,18 @@ function wp_star_rating( $args = array() ) {
$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
}
- echo '