+
@@ -558,7 +471,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 +514,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 +573,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 +582,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.
+ * Filter values for the meta key dropdown in the Custom Fields meta box.
*
- * @since 2.1.0
+ * Returning a non-null value will effectively short-circuit and avoid a
+ * potentially expensive query against postmeta.
*
- * @param int $limit Number of custom fields to retrieve. Default 30.
+ * @since 4.4.0
+ *
+ * @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 ) {
+ /**
+ * Filter 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';
@@ -742,9 +671,9 @@ function meta_form( $post = null ) {
* Print out HTML form date elements for editing post or comment publish date.
*
* @since 0.71
+ * @since 4.4.0 Converted to use get_comment() instead of the global `$comment`.
*
- * @global WP_Locale $wp_locale
- * @global object $comment
+ * @global WP_Locale $wp_locale
*
* @param int|bool $edit Accepts 1|true for editing the date, 0|false for adding the date.
* @param int|bool $for_post Accepts 1|true for applying the date to a post, 0|false for a comment.
@@ -753,7 +682,7 @@ function meta_form( $post = null ) {
* Default 0|false.
*/
function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
- global $wp_locale, $comment;
+ global $wp_locale;
$post = get_post();
if ( $for_post )
@@ -767,7 +696,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
// echo ' '.__( 'Edit timestamp' ).' ';
$time_adj = current_time('timestamp');
- $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
+ $post_date = ($for_post) ? $post->post_date : get_comment()->comment_date;
$jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
$mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
$aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
@@ -848,18 +777,20 @@ function page_template_dropdown( $default = '' ) {
* Print out option HTML elements for the page parents drop-down.
*
* @since 1.5.0
+ * @since 4.4.0 `$post` argument was added.
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*
- * @param int $default Optional. The default page ID to be pre-selected. Default 0.
- * @param int $parent Optional. The parent page ID. Default 0.
- * @param int $level Optional. Page depth level. Default 0.
+ * @param int $default Optional. The default page ID to be pre-selected. Default 0.
+ * @param int $parent Optional. The parent page ID. Default 0.
+ * @param int $level Optional. Page depth level. Default 0.
+ * @param int|WP_Post $post Post ID or WP_Post object.
*
* @return null|false Boolean False if page has no children, otherwise print out html elements
*/
-function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
+function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) {
global $wpdb;
- $post = get_post();
+ $post = get_post( $post );
$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) );
if ( $items ) {
@@ -935,44 +866,56 @@ function wp_import_upload_form( $action ) {
-
+
id ) ) {
+ return;
+ }
$page = $screen->id;
@@ -1083,9 +1026,13 @@ function do_meta_boxes( $screen, $context, $object ) {
$i++;
$hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
echo '' . "\n";
- if ( 'dashboard_browser_nag' != $box['id'] )
- echo '
';
- echo "
{$box['title']} \n";
+ if ( 'dashboard_browser_nag' != $box['id'] ) {
+ echo '
';
+ echo '' . sprintf( __( 'Toggle panel: %s' ), $box['title'] ) . ' ';
+ echo ' ';
+ echo ' ';
+ }
+ echo "
{$box['title']} \n";
echo '
' . "\n";
call_user_func($box['callback'], $object, $box);
echo "
\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 ) {
-
+
@@ -1222,10 +1186,12 @@ 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;
@@ -1259,16 +1225,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
@@ -1305,7 +1271,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 +1281,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 +1475,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,7 +1485,7 @@ function find_posts_div($found_action = '') {
?>
@@ -1719,8 +1685,7 @@ function _post_states($post) {
if ( 'draft' == $post->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,12 +1693,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 +1708,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 = ', ';
@@ -1783,20 +1750,24 @@ function _media_states( $post ) {
$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.
*
* @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 +1789,7 @@ function _media_states( $post ) {
function compression_test() {
?>
- '_invalid', 'base' => '_are_belong_to_us' );
}
@@ -2197,6 +2016,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 +2026,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 +2061,18 @@ function wp_star_rating( $args = array() ) {
$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
}
- echo '
';
- echo '
' . $title . ' ';
- echo str_repeat( '
', $full_stars );
- echo str_repeat( '
', $half_stars );
- echo str_repeat( '
', $empty_stars);
- echo '
';
+ $output = '
';
+ $output .= '
' . $title . ' ';
+ $output .= str_repeat( '
', $full_stars );
+ $output .= str_repeat( '
', $half_stars );
+ $output .= str_repeat( '
', $empty_stars );
+ $output .= '
';
+
+ if ( $r['echo'] ) {
+ echo $output;
+ }
+
+ return $output;
}
/**