X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/dc1231b7312fbdca99e9e887cc2bb35a28f85cdc..16e7b37c7914d753890c1a05a9335f3b43751eb8:/wp-admin/includes/template.php
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index a0b248f9..edf9a864 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" . '
';
}
}
@@ -432,7 +341,7 @@ function get_inline_data($post) {
}
/**
- * {@internal Missing Short Description}}
+ * Outputs the in-line comment reply-to form in the Comments list table.
*
* @since 2.7.0
*
@@ -446,7 +355,7 @@ function get_inline_data($post) {
function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) {
global $wp_list_table;
/**
- * Filter the in-line comment reply-to form output in the Comments
+ * Filters the in-line comment reply-to form output in the Comments
* list table.
*
* Returning a non-empty value here will short-circuit display
@@ -482,16 +391,29 @@ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $
@@ -532,6 +445,7 @@ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $
if ( current_user_can( 'unfiltered_html' ) )
wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
?>
+
@@ -558,7 +472,7 @@ function wp_comment_trashnotice() {
}
/**
- * {@internal Missing Short Description}}
+ * Outputs a post's public meta data in the Custom Fields meta box.
*
* @since 1.2.0
*
@@ -601,7 +515,7 @@ function list_meta( $meta ) {
}
/**
- * {@internal Missing Short Description}}
+ * Outputs a single row of public meta data in the Custom Fields meta box.
*
* @since 2.5.0
*
@@ -660,7 +574,7 @@ function _list_meta_row( $entry, &$count ) {
*
* @since 1.2.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*
* @param WP_Post $post Optional. The post being edited.
*/
@@ -669,21 +583,37 @@ function meta_form( $post = null ) {
$post = get_post( $post );
/**
- * Filter the number of custom fields to retrieve for the drop-down
- * in the Custom Fields meta box.
+ * Filters values for the meta key dropdown in the Custom Fields meta box.
+ *
+ * Returning a non-null value will effectively short-circuit and avoid a
+ * potentially expensive query against postmeta.
*
- * @since 2.1.0
+ * @since 4.4.0
*
- * @param int $limit Number of custom fields to retrieve. Default 30.
+ * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
+ * @param WP_Post $post The current post object.
*/
- $limit = apply_filters( 'postmeta_form_limit', 30 );
- $sql = "SELECT DISTINCT meta_key
- FROM $wpdb->postmeta
- WHERE meta_key NOT BETWEEN '_' AND '_z'
- HAVING meta_key NOT LIKE %s
- ORDER BY meta_key
- LIMIT %d";
- $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
+ $keys = apply_filters( 'postmeta_form_keys', null, $post );
+
+ if ( null === $keys ) {
+ /**
+ * Filters the number of custom fields to retrieve for the drop-down
+ * in the Custom Fields meta box.
+ *
+ * @since 2.1.0
+ *
+ * @param int $limit Number of custom fields to retrieve. Default 30.
+ */
+ $limit = apply_filters( 'postmeta_form_limit', 30 );
+ $sql = "SELECT DISTINCT meta_key
+ FROM $wpdb->postmeta
+ WHERE meta_key NOT BETWEEN '_' AND '_z'
+ HAVING meta_key NOT LIKE %s
+ ORDER BY meta_key
+ LIMIT %d";
+ $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
+ }
+
if ( $keys ) {
natcasesort( $keys );
$meta_key_input_id = 'metakeyselect';
@@ -728,7 +658,7 @@ function meta_form( $post = null ) {
\n";
@@ -1102,23 +1060,39 @@ 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 The context within the screen where the box is set to display.
+ * 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.
*/
-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;
@@ -1136,7 +1110,7 @@ function remove_meta_box($id, $screen, $context) {
/**
* Meta Box Accordion Template Function
*
- * Largely made up of abstracted code from {@link do_meta_boxes()}, this
+ * Largely made up of abstracted code from do_meta_boxes(), this
* function serves to build meta boxes as list items for display as
* a collapsible accordion.
*
@@ -1187,7 +1161,7 @@ function do_accordion_sections( $screen, $context, $object ) {
-
+
@@ -1222,21 +1196,23 @@ function do_accordion_sections( $screen, $context, $object ) {
*
* @global $wp_settings_sections Storage array of all settings sections added to admin pages
*
- * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags.
- * @param string $title Formatted title of the section. Shown as the heading for the section.
- * @param string $callback Function that echos out any content at the top of the section (between heading and fields).
- * @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();
+ * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags.
+ * @param string $title Formatted title of the section. Shown as the heading for the section.
+ * @param callable $callback Function that echos out any content at the top of the section (between heading and fields).
+ * @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();
*/
function add_settings_section($id, $title, $callback, $page) {
global $wp_settings_sections;
if ( 'misc' == $page ) {
- _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
+ _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
$page = 'general';
}
if ( 'privacy' == $page ) {
- _deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
+ _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
$page = 'reading';
}
@@ -1259,16 +1235,16 @@ function add_settings_section($id, $title, $callback, $page) {
*
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
*
- * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
- * @param string $title Formatted title of the field. Shown as the label for the field
- * during output.
- * @param string $callback Function that fills the field with the desired form inputs. The
- * function should echo its output.
- * @param string $page The slug-name of the settings page on which to show the section
- * (general, reading, writing, ...).
- * @param string $section Optional. The slug-name of the section of the settings page
- * in which to show the box. Default 'default'.
- * @param array $args {
+ * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
+ * @param string $title Formatted title of the field. Shown as the label for the field
+ * during output.
+ * @param callable $callback Function that fills the field with the desired form inputs. The
+ * function should echo its output.
+ * @param string $page The slug-name of the settings page on which to show the section
+ * (general, reading, writing, ...).
+ * @param string $section Optional. The slug-name of the section of the settings page
+ * in which to show the box. Default 'default'.
+ * @param array $args {
* Optional. Extra arguments used when outputting the field.
*
* @type string $label_for When supplied, the setting title will be wrapped
@@ -1282,12 +1258,12 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default',
global $wp_settings_fields;
if ( 'misc' == $page ) {
- _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
+ _deprecated_argument( __FUNCTION__, '3.0.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
$page = 'general';
}
if ( 'privacy' == $page ) {
- _deprecated_argument( __FUNCTION__, '3.5', __( 'The privacy options group has been removed. Use another settings group.' ) );
+ _deprecated_argument( __FUNCTION__, '3.5.0', __( 'The privacy options group has been removed. Use another settings group.' ) );
$page = 'reading';
}
@@ -1305,7 +1281,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 +1291,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 );
@@ -1417,7 +1393,8 @@ function add_settings_error( $setting, $code, $message, $type = 'error' ) {
*
* Use the $sanitize argument to manually re-sanitize the option before returning errors.
* This is useful if you have errors or notices you want to show even when the user
- * hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook)
+ * hasn't submitted data (i.e. when they first load an options page, or in the {@see 'admin_notices'}
+ * action hook).
*
* @since 3.0.0
*
@@ -1462,16 +1439,16 @@ function get_settings_errors( $setting = '', $sanitize = false ) {
}
/**
- * Display settings errors registered by {@see add_settings_error()}.
+ * Display settings errors registered by add_settings_error().
*
* Part of the Settings API. Outputs a div for each error retrieved by
- * {@see get_settings_errors()}.
+ * get_settings_errors().
*
* This is called automatically after a settings page based on the
* Settings API is submitted. Errors should be added during the validation
- * callback function for a setting defined in {@see register_setting()}
+ * callback function for a setting defined in register_setting().
*
- * The $sanitize option is passed into {@see get_settings_errors()} and will
+ * The $sanitize option is passed into get_settings_errors() and will
* re-run the setting sanitization
* on its current value.
*
@@ -1485,7 +1462,8 @@ function get_settings_errors( $setting = '', $sanitize = false ) {
*
* @param string $setting Optional slug title of a specific setting who's errors you want.
* @param bool $sanitize Whether to re-sanitize the setting value before returning errors.
- * @param bool $hide_on_update If set to true errors will not be shown if the settings page has already been submitted.
+ * @param bool $hide_on_update If set to true errors will not be shown if the settings page has
+ * already been submitted.
*/
function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
@@ -1509,7 +1487,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
*
@@ -1519,8 +1497,8 @@ function find_posts_div($found_action = '') {
?>
-
-
+
+
@@ -1538,7 +1516,7 @@ function find_posts_div($found_action = '') {
-
+
@@ -1546,10 +1524,9 @@ function find_posts_div($found_action = '') {
}
/**
- * Display the post password.
+ * Displays the post password.
*
- * The password is passed through {@link esc_attr()} to ensure that it
- * is safe for placing in an html attribute.
+ * The password is passed through esc_attr() to ensure that it is safe for placing in an html attribute.
*
* @since 2.7.0
*/
@@ -1578,10 +1555,10 @@ function _draft_or_post_title( $post = 0 ) {
}
/**
- * Display the search query.
+ * Displays the search query.
*
- * A simple wrapper to display the "s" parameter in a GET URI. This function
- * should only be used when {@link the_search_query()} cannot.
+ * A simple wrapper to display the "s" parameter in a `GET` URI. This function
+ * should only be used when the_search_query() cannot.
*
* @since 2.7.0
*/
@@ -1648,7 +1625,7 @@ do_action( "admin_head-$hook_suffix" );
/** This action is documented in wp-admin/admin-header.php */
do_action( 'admin_head' );
-$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
+$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
if ( is_rtl() )
$admin_body_class .= ' rtl';
@@ -1685,11 +1662,19 @@ function iframe_footer() {
* but run the hooks anyway since they output JavaScript
* or other needed content.
*/
- ?>
+
+ /**
+ * @global string $hook_suffix
+ */
+ global $hook_suffix;
+ ?>
post_status && 'draft' != $post_status )
$post_states['draft'] = __('Draft');
if ( 'pending' == $post->post_status && 'pending' != $post_status )
- /* translators: post state */
- $post_states['pending'] = _x('Pending', 'post state');
+ $post_states['pending'] = _x('Pending', 'post status');
if ( is_sticky($post->ID) )
$post_states['sticky'] = __('Sticky');
@@ -1728,28 +1712,30 @@ 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' );
+ }
}
/**
- * Filter the default post display states used in the posts list table.
+ * Filters the default post display states used in the posts list table.
*
* @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 = ', ';
@@ -1769,34 +1755,63 @@ function _media_states( $post ) {
if ( current_theme_supports( 'custom-header') ) {
$meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true );
- if ( ! empty( $meta_header ) && $meta_header == $stylesheet )
- $media_states[] = __( 'Header Image' );
+
+ if ( is_random_header_image() ) {
+ $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
+
+ if ( $meta_header == $stylesheet && in_array( $post->ID, $header_images ) ) {
+ $media_states[] = __( 'Header Image' );
+ }
+ } else {
+ $header_image = get_header_image();
+
+ // Display "Header Image" if the image was ever used as a header image
+ if ( ! empty( $meta_header ) && $meta_header == $stylesheet && $header_image !== wp_get_attachment_url( $post->ID ) ) {
+ $media_states[] = __( 'Header Image' );
+ }
+
+ // Display "Current Header Image" if the image is currently the header image
+ if ( $header_image && $header_image == wp_get_attachment_url( $post->ID ) ) {
+ $media_states[] = __( 'Current Header Image' );
+ }
+ }
}
if ( current_theme_supports( 'custom-background') ) {
$meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
- if ( ! empty( $meta_background ) && $meta_background == $stylesheet )
+
+ if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) {
$media_states[] = __( 'Background Image' );
+
+ $background_image = get_background_image();
+ if ( $background_image && $background_image == wp_get_attachment_url( $post->ID ) ) {
+ $media_states[] = __( 'Current Background Image' );
+ }
+ }
}
if ( $post->ID == get_option( 'site_icon' ) ) {
$media_states[] = __( 'Site Icon' );
}
+ if ( $post->ID == get_theme_mod( 'site_logo' ) ) {
+ $media_states[] = __( 'Logo' );
+ }
+
/**
- * Filter the default media display states for items in the Media list table.
+ * Filters the default media display states for items in the Media list table.
*
* @since 3.2.0
*
* @param array $media_states An array of media states. Default 'Header Image',
- * 'Background Image', 'Site Icon'.
+ * 'Background Image', 'Site Icon', 'Logo'.
*/
$media_states = apply_filters( 'display_media_states', $media_states );
if ( ! empty( $media_states ) ) {
$state_count = count( $media_states );
$i = 0;
- echo ' - ';
+ echo ' — ';
foreach ( $media_states as $state ) {
++$i;
( $i == $state_count ) ? $sep = '' : $sep = ', ';
@@ -1818,6 +1833,7 @@ function _media_states( $post ) {
function compression_test() {
?>
- '_invalid', 'base' => '_are_belong_to_us' );
}
@@ -2176,14 +2037,13 @@ function convert_to_screen( $hook_name ) {
*/
function _local_storage_notice() {
?>
-