+
@@ -556,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
*
@@ -599,21 +514,23 @@ 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
*
+ * @staticvar string $update_nonce
+ *
* @param array $entry
* @param int $count
* @return string
*/
function _list_meta_row( $entry, &$count ) {
- static $update_nonce = false;
+ static $update_nonce = '';
if ( is_protected_meta( $entry['meta_key'], 'post' ) )
return '';
- if ( !$update_nonce )
+ if ( ! $update_nonce )
$update_nonce = wp_create_nonce( 'add-meta' );
$r = '';
@@ -656,6 +573,8 @@ function _list_meta_row( $entry, &$count ) {
*
* @since 1.2.0
*
+ * @global wpdb $wpdb WordPress database abstraction object.
+ *
* @param WP_Post $post Optional. The post being edited.
*/
function meta_form( $post = null ) {
@@ -663,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 meta_key
- FROM $wpdb->postmeta
- GROUP BY meta_key
- 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';
@@ -736,6 +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
*
* @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.
@@ -744,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 )
@@ -758,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 );
@@ -772,23 +710,24 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
$cur_hh = gmdate( 'H', $time_adj );
$cur_mn = gmdate( 'i', $time_adj );
- $month = '' . __( 'Month' ) . ' \n";
+ $month = '' . __( 'Month' ) . ' \n";
for ( $i = 1; $i < 13; $i = $i +1 ) {
$monthnum = zeroise($i, 2);
- $month .= "\t\t\t" . '';
+ $monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
+ $month .= "\t\t\t" . ' ';
/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
- $month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . " \n";
+ $month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "\n";
}
- $month .= ' ';
+ $month .= ' ';
- $day = '' . __( 'Day' ) . ' ';
- $year = '' . __( 'Year' ) . ' ';
- $hour = '' . __( 'Hour' ) . ' ';
- $minute = '' . __( 'Minute' ) . ' ';
+ $day = '' . __( 'Day' ) . ' ';
+ $year = '' . __( 'Year' ) . ' ';
+ $hour = '' . __( 'Hour' ) . ' ';
+ $minute = '' . __( 'Minute' ) . ' ';
echo '';
/* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
- printf( __( '%1$s %2$s, %3$s @ %4$s : %5$s' ), $month, $day, $year, $hour, $minute );
+ printf( __( '%1$s %2$s, %3$s @ %4$s:%5$s' ), $month, $day, $year, $hour, $minute );
echo '
';
@@ -838,16 +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 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 ) {
@@ -923,42 +866,56 @@ function wp_import_upload_form( $action ) {
-
+
id ) ) {
+ return;
+ }
$page = $screen->id;
@@ -1022,10 +979,12 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
*
* @since 2.5.0
*
+ * @global array $wp_meta_boxes
+ *
* @staticvar bool $already_sorted
- * @param string|WP_Screen $screen Screen identifier
- * @param string $context box context
- * @param mixed $object gets passed to the box callback function as first parameter
+ * @param string|WP_Screen $screen Screen identifier
+ * @param string $context box context
+ * @param mixed $object gets passed to the box callback function as first parameter
* @return int number of meta_boxes
*/
function do_meta_boxes( $screen, $context, $object ) {
@@ -1067,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";
@@ -1086,21 +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;
@@ -1126,9 +1108,9 @@ function remove_meta_box($id, $screen, $context) {
*
* @uses global $wp_meta_boxes Used to retrieve registered meta boxes.
*
- * @param string|object $screen The screen identifier.
- * @param string $context The meta box context.
- * @param mixed $object gets passed to the section callback function as first parameter.
+ * @param string|object $screen The screen identifier.
+ * @param string $context The meta box context.
+ * @param mixed $object gets passed to the section callback function as first parameter.
* @return int number of meta boxes as accordion sections.
*/
function do_accordion_sections( $screen, $context, $object ) {
@@ -1169,7 +1151,7 @@ function do_accordion_sections( $screen, $context, $object ) {
-
+
@@ -1204,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;
@@ -1241,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
@@ -1287,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;
@@ -1297,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 );
@@ -1465,9 +1449,9 @@ function get_settings_errors( $setting = '', $sanitize = false ) {
*
* @since 3.0.0
*
- * @param string $setting Optional slug title of a specific setting who's errors you want.
- * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
- * @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted.
+ * @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.
*/
function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
@@ -1491,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
*
@@ -1501,7 +1485,7 @@ function find_posts_div($found_action = '') {
?>
@@ -1576,6 +1560,10 @@ function _admin_search_query() {
*
* @since 2.7.0
*
+ * @global string $hook_suffix
+ * @global string $admin_body_class
+ * @global WP_Locale $wp_locale
+ *
* @param string $title Optional. Title of the Iframe page. Default empty.
* @param bool $deprecated Not used.
*/
@@ -1637,7 +1625,11 @@ if ( is_rtl() )
/** This filter is documented in wp-admin/admin-header.php */
$admin_body_classes = apply_filters( 'admin_body_class', '' );
?>
- class="wp-admin wp-core-ui no-js iframe ">
+ class="wp-admin wp-core-ui no-js iframe ">
- ' . __( 'Edit Lock' ) . '';
- $content .= '
' . __( 'Someone else is editing this. No need to refresh; the lock will disappear when they’re done.' ) . '
';
-
- self::print_js( 'wp360_locks', 'tr.wp-locked .locked-indicator', array(
- 'content' => $content,
- 'position' => array( 'edge' => 'left', 'align' => 'left' ),
- ) );
- }
-
- public static function pointer_wp390_widgets() {
- if ( ! current_theme_supports( 'widgets' ) ) {
- return;
- }
-
- $content = '
' . __( 'New Feature: Live Widget Previews' ) . ' ';
- $content .= '
' . __( 'Add, edit, and play around with your widgets from the Customizer.' ) . ' ' . __( 'Preview your changes in real-time and only save them when you’re ready.' ) . '
';
-
- if ( 'themes' === get_current_screen()->id ) {
- $selector = '.theme.active .customize';
- $position = array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' );
- } else {
- $selector = 'a[href^="customize.php"]';
- if ( is_rtl() ) {
- $position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-5px' );
- } else {
- $position = array( 'edge' => 'left', 'align' => 'center', 'my' => 'left-5px' );
- }
- }
-
- self::print_js( 'wp390_widgets', $selector, array(
- 'content' => $content,
- 'position' => $position,
- ) );
- }
-
- public static function pointer_wp410_dfw() {
- // Don't show when editor-scrolling is not used.
- if ( empty( $GLOBALS['_wp_editor_expand'] ) ) {
- return;
- }
-
- $content = '
' . __( 'Distraction-Free Writing' ) . ' ';
- $content .= '
' . __( 'Enable distraction-free writing mode, and everything surrounding the editor will fade away when you start typing. Move your mouse out of the editor to reveal everything again.' ) . '
';
-
- if ( is_rtl() ) {
- $position = array( 'edge' => 'left', 'align' => 'center', 'my' => 'left+40 top-11', 'at' => 'left top' );
- } else {
- $position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-40 top-11', 'at' => 'right top' );
- }
-
- self::print_js( 'wp410_dfw', '#wp-content-wrap', array(
- 'content' => $content,
- 'position' => $position,
- ) );
- }
-
- /**
- * Prevents new users from seeing existing 'new feature' pointers.
- *
- * @since 3.3.0
- *
- * @param int $user_id User ID.
- */
- public static function dismiss_pointers_for_new_users( $user_id ) {
- add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp360_locks,wp390_widgets' );
- }
-}
-
-add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
-add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) );
-
/**
* Convert a screen string to a screen object
*
@@ -2152,7 +1979,7 @@ add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_poi
* @return WP_Screen Screen object.
*/
function convert_to_screen( $hook_name ) {
- if ( ! class_exists( 'WP_Screen' ) ) {
+ if ( ! class_exists( 'WP_Screen', false ) ) {
_doing_it_wrong( 'convert_to_screen(), add_meta_box()', __( "Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead." ), '3.3' );
return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' );
}
@@ -2189,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.
*
@@ -2197,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 );
@@ -2229,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;
}
/**