diff -r 34716fd837a4 -r be944660c56a wp/wp-admin/includes/template.php --- a/wp/wp-admin/includes/template.php Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-admin/includes/template.php Wed Sep 21 18:19:35 2022 +0200 @@ -25,17 +25,17 @@ * * @see wp_terms_checklist() * - * @param int $post_id Optional. Post to generate a categories checklist for. Default 0. - * $selected_cats must not be an array. Default 0. - * @param int $descendants_and_self Optional. ID of the category to output along with its descendants. - * Default 0. - * @param int[] $selected_cats Optional. Array of category IDs to mark as checked. Default false. - * @param int[] $popular_cats Optional. Array of category IDs to receive the "popular-category" class. - * Default false. - * @param Walker $walker Optional. Walker object to use to build the output. - * Default is a Walker_Category_Checklist instance. - * @param bool $checked_ontop Optional. Whether to move checked items out of the hierarchy and to - * the top of the list. Default true. + * @param int $post_id Optional. Post to generate a categories checklist for. Default 0. + * $selected_cats must not be an array. Default 0. + * @param int $descendants_and_self Optional. ID of the category to output along with its descendants. + * Default 0. + * @param int[]|false $selected_cats Optional. Array of category IDs to mark as checked. Default false. + * @param int[]|false $popular_cats Optional. Array of category IDs to receive the "popular-category" class. + * Default false. + * @param Walker $walker Optional. Walker object to use to build the output. + * Default is a Walker_Category_Checklist instance. + * @param bool $checked_ontop Optional. Whether to move checked items out of the hierarchy and to + * the top of the list. Default true. */ function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) { wp_terms_checklist( @@ -813,7 +813,7 @@ $cur_hh = current_time( 'H' ); $cur_mn = current_time( 'i' ); - $month = ''; - $day = ''; - $year = ''; - $hour = ''; - $minute = ''; + $day = ''; + $year = ''; + $hour = ''; + $minute = ''; echo '
'; /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */ @@ -972,7 +972,7 @@ ?>

-
@@ -1014,14 +1014,14 @@ * add_submenu_page() to create a new screen (and hence screen_id), * make sure your menu slug conforms to the limits of sanitize_key() * otherwise the 'screen' menu may not correctly render on your page. - * @param string $context Optional. The context within the screen where the boxes + * @param string $context Optional. The context within the screen where the box * 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'. - * @param string $priority Optional. The priority within the context where the boxes - * should show ('high', 'low'). Default 'default'. + * @param string $priority Optional. The priority within the context where the box should show. + * Accepts 'high', 'core', 'default', or 'low'. Default 'default'. * @param array $callback_args Optional. Data that should be set as the $args property * of the box array (which is the second parameter passed * to your callback). Default null. @@ -1148,17 +1148,23 @@ if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) { if ( current_user_can( 'install_plugins' ) ) { + $install_url = wp_nonce_url( + self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), + 'save_wporg_username_' . get_current_user_id() + ); + echo '

'; - printf( - /* translators: %s: A link to install the Classic Editor plugin. */ - __( 'Please install the Classic Editor plugin to use this meta box.' ), - esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ) ) - ); + /* translators: %s: A link to install the Classic Editor plugin. */ + printf( __( 'Please install the Classic Editor plugin to use this meta box.' ), esc_url( $install_url ) ); echo '

'; } } elseif ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) { if ( current_user_can( 'activate_plugins' ) ) { - $activate_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php' ), 'activate-plugin_classic-editor/classic-editor.php' ); + $activate_url = wp_nonce_url( + self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php' ), + 'activate-plugin_classic-editor/classic-editor.php' + ); + echo '

'; /* translators: %s: A link to activate the Classic Editor plugin. */ printf( __( 'Please activate the Classic Editor plugin to use this meta box.' ), esc_url( $activate_url ) ); @@ -1321,7 +1327,7 @@ echo ''; echo '' . __( 'Warning:' ) . ' '; } - echo "{$box['title']}"; + echo $box['title']; echo "\n"; if ( 'dashboard_browser_nag' !== $box['id'] ) { @@ -1592,7 +1598,7 @@ * * Part of the Settings API. Use this to define a settings field that will show * as part of a settings section inside a settings page. The fields are shown using - * do_settings_fields() in do_settings-sections() + * do_settings_fields() in do_settings_sections(). * * The $callback argument should be the name of a function that echoes out the * HTML input tags for this setting field. Use get_option() to retrieve existing @@ -1797,7 +1803,16 @@ * * @param string $setting Optional. Slug title of a specific setting whose errors you want. * @param bool $sanitize Optional. Whether to re-sanitize the setting value before returning errors. - * @return array Array of settings errors. + * @return array { + * Array of settings errors. + * + * @type string $setting Slug title of the setting to which this error applies. + * @type string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output. + * @type string $message The formatted message text to display to the user (will be shown inside styled + * `

` and `

` tags). + * @type string $type Optional. Message type, controls HTML class. Possible values include 'error', + * 'success', 'warning', 'info'. Default 'error'. + * } */ function get_settings_errors( $setting = '', $sanitize = false ) { global $wp_settings_errors; @@ -2016,14 +2031,14 @@ wp_enqueue_style( 'colors' ); ?>

- + ID ) { + if ( (int) get_option( 'page_on_front' ) === $post->ID ) { $post_states['page_on_front'] = _x( 'Front Page', 'page label' ); } - if ( intval( get_option( 'page_for_posts' ) ) === $post->ID ) { + if ( (int) get_option( 'page_for_posts' ) === $post->ID ) { $post_states['page_for_posts'] = _x( 'Posts Page', 'page label' ); } } - if ( intval( get_option( 'wp_page_for_privacy_policy' ) ) === $post->ID ) { + if ( (int) get_option( 'wp_page_for_privacy_policy' ) === $post->ID ) { $post_states['page_for_privacy_policy'] = _x( 'Privacy Policy Page', 'page label' ); } @@ -2228,10 +2243,45 @@ * Outputs the attachment media states as HTML. * * @since 3.2.0 + * @since 5.6.0 Added the `$echo` parameter and a return value. * * @param WP_Post $post The attachment post to retrieve states for. + * @param bool $echo Optional. Whether to echo the post states as an HTML string. Default true. + * @return string Media states string. */ -function _media_states( $post ) { +function _media_states( $post, $echo = true ) { + $media_states = get_media_states( $post ); + $media_states_string = ''; + + if ( ! empty( $media_states ) ) { + $state_count = count( $media_states ); + $i = 0; + + $media_states_string .= ' — '; + + foreach ( $media_states as $state ) { + $sep = ( ++$i === $state_count ) ? '' : ', '; + + $media_states_string .= "$state$sep"; + } + } + + if ( $echo ) { + echo $media_states_string; + } + + return $media_states_string; +} + +/** + * Retrieves an array of media states from an attachment. + * + * @since 5.6.0 + * + * @param WP_Post $post The attachment to retrieve states for. + * @return string[] Array of media state labels keyed by their state. + */ +function get_media_states( $post ) { static $header_images; $media_states = array(); @@ -2261,6 +2311,13 @@ $media_states[] = __( 'Current Header Image' ); } } + + if ( get_theme_support( 'custom-header', 'video' ) && has_header_video() ) { + $mods = get_theme_mods(); + if ( isset( $mods['header_video'] ) && $post->ID === $mods['header_video'] ) { + $media_states[] = __( 'Current Header Video' ); + } + } } if ( current_theme_supports( 'custom-background' ) ) { @@ -2294,20 +2351,7 @@ * 'Background Image', 'Site Icon', 'Logo'. * @param WP_Post $post The current attachment object. */ - $media_states = apply_filters( 'display_media_states', $media_states, $post ); - - if ( ! empty( $media_states ) ) { - $state_count = count( $media_states ); - $i = 0; - - echo ' — '; - - foreach ( $media_states as $state ) { - $sep = ( ++$i === $state_count ) ? '' : ', '; - - echo "$state$sep"; - } - } + return apply_filters( 'display_media_states', $media_states, $post ); } /** @@ -2622,11 +2666,31 @@ } /** - * Output a notice when editing the page for posts (internal use only). + * Outputs a notice when editing the page for posts (internal use only). * * @ignore * @since 4.2.0 */ function _wp_posts_page_notice() { - echo '

' . __( 'You are currently editing the page that shows your latest posts.' ) . '

'; + printf( + '

%s

', + __( 'You are currently editing the page that shows your latest posts.' ) + ); } + +/** + * Outputs a notice when editing the page for posts in the block editor (internal use only). + * + * @ignore + * @since 5.8.0 + */ +function _wp_block_editor_posts_page_notice() { + wp_add_inline_script( + 'wp-notices', + sprintf( + 'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { isDismissible: false } )', + __( 'You are currently editing the page that shows your latest posts.' ) + ), + 'after' + ); +}