wp/wp-admin/includes/template.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    23  *
    23  *
    24  * @since 2.5.1
    24  * @since 2.5.1
    25  *
    25  *
    26  * @see wp_terms_checklist()
    26  * @see wp_terms_checklist()
    27  *
    27  *
    28  * @param int    $post_id              Optional. Post to generate a categories checklist for. Default 0.
    28  * @param int         $post_id              Optional. Post to generate a categories checklist for. Default 0.
    29  *                                     $selected_cats must not be an array. Default 0.
    29  *                                          $selected_cats must not be an array. Default 0.
    30  * @param int    $descendants_and_self Optional. ID of the category to output along with its descendants.
    30  * @param int         $descendants_and_self Optional. ID of the category to output along with its descendants.
    31  *                                     Default 0.
    31  *                                          Default 0.
    32  * @param int[]  $selected_cats        Optional. Array of category IDs to mark as checked. Default false.
    32  * @param int[]|false $selected_cats        Optional. Array of category IDs to mark as checked. Default false.
    33  * @param int[]  $popular_cats         Optional. Array of category IDs to receive the "popular-category" class.
    33  * @param int[]|false $popular_cats         Optional. Array of category IDs to receive the "popular-category" class.
    34  *                                     Default false.
    34  *                                          Default false.
    35  * @param Walker $walker               Optional. Walker object to use to build the output.
    35  * @param Walker      $walker               Optional. Walker object to use to build the output.
    36  *                                     Default is a Walker_Category_Checklist instance.
    36  *                                          Default is a Walker_Category_Checklist instance.
    37  * @param bool   $checked_ontop        Optional. Whether to move checked items out of the hierarchy and to
    37  * @param bool        $checked_ontop        Optional. Whether to move checked items out of the hierarchy and to
    38  *                                     the top of the list. Default true.
    38  *                                          the top of the list. Default true.
    39  */
    39  */
    40 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
    40 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
    41 	wp_terms_checklist(
    41 	wp_terms_checklist(
    42 		$post_id,
    42 		$post_id,
    43 		array(
    43 		array(
   811 	$cur_mm = current_time( 'm' );
   811 	$cur_mm = current_time( 'm' );
   812 	$cur_aa = current_time( 'Y' );
   812 	$cur_aa = current_time( 'Y' );
   813 	$cur_hh = current_time( 'H' );
   813 	$cur_hh = current_time( 'H' );
   814 	$cur_mn = current_time( 'i' );
   814 	$cur_mn = current_time( 'i' );
   815 
   815 
   816 	$month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
   816 	$month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select class="form-required" ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
   817 	for ( $i = 1; $i < 13; $i = $i + 1 ) {
   817 	for ( $i = 1; $i < 13; $i = $i + 1 ) {
   818 		$monthnum  = zeroise( $i, 2 );
   818 		$monthnum  = zeroise( $i, 2 );
   819 		$monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
   819 		$monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
   820 		$month    .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>';
   820 		$month    .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>';
   821 		/* translators: 1: Month number (01, 02, etc.), 2: Month abbreviation. */
   821 		/* translators: 1: Month number (01, 02, etc.), 2: Month abbreviation. */
   822 		$month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n";
   822 		$month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n";
   823 	}
   823 	}
   824 	$month .= '</select></label>';
   824 	$month .= '</select></label>';
   825 
   825 
   826 	$day    = '<label><span class="screen-reader-text">' . __( 'Day' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
   826 	$day    = '<label><span class="screen-reader-text">' . __( 'Day' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
   827 	$year   = '<label><span class="screen-reader-text">' . __( 'Year' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" /></label>';
   827 	$year   = '<label><span class="screen-reader-text">' . __( 'Year' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
   828 	$hour   = '<label><span class="screen-reader-text">' . __( 'Hour' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
   828 	$hour   = '<label><span class="screen-reader-text">' . __( 'Hour' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
   829 	$minute = '<label><span class="screen-reader-text">' . __( 'Minute' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
   829 	$minute = '<label><span class="screen-reader-text">' . __( 'Minute' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>';
   830 
   830 
   831 	echo '<div class="timestamp-wrap">';
   831 	echo '<div class="timestamp-wrap">';
   832 	/* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
   832 	/* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
   833 	printf( __( '%1$s %2$s, %3$s at %4$s:%5$s' ), $month, $day, $year, $hour, $minute );
   833 	printf( __( '%1$s %2$s, %3$s at %4$s:%5$s' ), $month, $day, $year, $hour, $minute );
   834 
   834 
   970 	$upload_dir = wp_upload_dir();
   970 	$upload_dir = wp_upload_dir();
   971 	if ( ! empty( $upload_dir['error'] ) ) :
   971 	if ( ! empty( $upload_dir['error'] ) ) :
   972 		?>
   972 		?>
   973 		<div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p>
   973 		<div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p>
   974 		<p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
   974 		<p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
   975 								<?php
   975 		<?php
   976 	else :
   976 	else :
   977 		?>
   977 		?>
   978 <form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
   978 <form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
   979 <p>
   979 <p>
   980 		<?php
   980 		<?php
  1012  *                                              screen ID, WP_Screen object, or array of screen IDs. Default
  1012  *                                              screen ID, WP_Screen object, or array of screen IDs. Default
  1013  *                                              is the current screen.  If you have used add_menu_page() or
  1013  *                                              is the current screen.  If you have used add_menu_page() or
  1014  *                                              add_submenu_page() to create a new screen (and hence screen_id),
  1014  *                                              add_submenu_page() to create a new screen (and hence screen_id),
  1015  *                                              make sure your menu slug conforms to the limits of sanitize_key()
  1015  *                                              make sure your menu slug conforms to the limits of sanitize_key()
  1016  *                                              otherwise the 'screen' menu may not correctly render on your page.
  1016  *                                              otherwise the 'screen' menu may not correctly render on your page.
  1017  * @param string                 $context       Optional. The context within the screen where the boxes
  1017  * @param string                 $context       Optional. The context within the screen where the box
  1018  *                                              should display. Available contexts vary from screen to
  1018  *                                              should display. Available contexts vary from screen to
  1019  *                                              screen. Post edit screen contexts include 'normal', 'side',
  1019  *                                              screen. Post edit screen contexts include 'normal', 'side',
  1020  *                                              and 'advanced'. Comments screen contexts include 'normal'
  1020  *                                              and 'advanced'. Comments screen contexts include 'normal'
  1021  *                                              and 'side'. Menus meta boxes (accordion sections) all use
  1021  *                                              and 'side'. Menus meta boxes (accordion sections) all use
  1022  *                                              the 'side' context. Global default is 'advanced'.
  1022  *                                              the 'side' context. Global default is 'advanced'.
  1023  * @param string                 $priority      Optional. The priority within the context where the boxes
  1023  * @param string                 $priority      Optional. The priority within the context where the box should show.
  1024  *                                              should show ('high', 'low'). Default 'default'.
  1024  *                                              Accepts 'high', 'core', 'default', or 'low'. Default 'default'.
  1025  * @param array                  $callback_args Optional. Data that should be set as the $args property
  1025  * @param array                  $callback_args Optional. Data that should be set as the $args property
  1026  *                                              of the box array (which is the second parameter passed
  1026  *                                              of the box array (which is the second parameter passed
  1027  *                                              to your callback). Default null.
  1027  *                                              to your callback). Default null.
  1028  */
  1028  */
  1029 function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
  1029 function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
  1146 	}
  1146 	}
  1147 	echo '</p>';
  1147 	echo '</p>';
  1148 
  1148 
  1149 	if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) {
  1149 	if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) {
  1150 		if ( current_user_can( 'install_plugins' ) ) {
  1150 		if ( current_user_can( 'install_plugins' ) ) {
       
  1151 			$install_url = wp_nonce_url(
       
  1152 				self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ),
       
  1153 				'save_wporg_username_' . get_current_user_id()
       
  1154 			);
       
  1155 
  1151 			echo '<p>';
  1156 			echo '<p>';
  1152 			printf(
  1157 			/* translators: %s: A link to install the Classic Editor plugin. */
  1153 				/* translators: %s: A link to install the Classic Editor plugin. */
  1158 			printf( __( 'Please install the <a href="%s">Classic Editor plugin</a> to use this meta box.' ), esc_url( $install_url ) );
  1154 				__( 'Please install the <a href="%s">Classic Editor plugin</a> to use this meta box.' ),
       
  1155 				esc_url( wp_nonce_url( self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ), 'save_wporg_username_' . get_current_user_id() ) )
       
  1156 			);
       
  1157 			echo '</p>';
  1159 			echo '</p>';
  1158 		}
  1160 		}
  1159 	} elseif ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) {
  1161 	} elseif ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) {
  1160 		if ( current_user_can( 'activate_plugins' ) ) {
  1162 		if ( current_user_can( 'activate_plugins' ) ) {
  1161 			$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' );
  1163 			$activate_url = wp_nonce_url(
       
  1164 				self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php' ),
       
  1165 				'activate-plugin_classic-editor/classic-editor.php'
       
  1166 			);
       
  1167 
  1162 			echo '<p>';
  1168 			echo '<p>';
  1163 			/* translators: %s: A link to activate the Classic Editor plugin. */
  1169 			/* translators: %s: A link to activate the Classic Editor plugin. */
  1164 			printf( __( 'Please activate the <a href="%s">Classic Editor plugin</a> to use this meta box.' ), esc_url( $activate_url ) );
  1170 			printf( __( 'Please activate the <a href="%s">Classic Editor plugin</a> to use this meta box.' ), esc_url( $activate_url ) );
  1165 			echo '</p>';
  1171 			echo '</p>';
  1166 		}
  1172 		}
  1319 					echo '<h2 class="hndle">';
  1325 					echo '<h2 class="hndle">';
  1320 					if ( 'dashboard_php_nag' === $box['id'] ) {
  1326 					if ( 'dashboard_php_nag' === $box['id'] ) {
  1321 						echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
  1327 						echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
  1322 						echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
  1328 						echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
  1323 					}
  1329 					}
  1324 					echo "{$box['title']}";
  1330 					echo $box['title'];
  1325 					echo "</h2>\n";
  1331 					echo "</h2>\n";
  1326 
  1332 
  1327 					if ( 'dashboard_browser_nag' !== $box['id'] ) {
  1333 					if ( 'dashboard_browser_nag' !== $box['id'] ) {
  1328 						$widget_title = $box['title'];
  1334 						$widget_title = $box['title'];
  1329 
  1335 
  1590 /**
  1596 /**
  1591  * Add a new field to a section of a settings page.
  1597  * Add a new field to a section of a settings page.
  1592  *
  1598  *
  1593  * Part of the Settings API. Use this to define a settings field that will show
  1599  * Part of the Settings API. Use this to define a settings field that will show
  1594  * as part of a settings section inside a settings page. The fields are shown using
  1600  * as part of a settings section inside a settings page. The fields are shown using
  1595  * do_settings_fields() in do_settings-sections()
  1601  * do_settings_fields() in do_settings_sections().
  1596  *
  1602  *
  1597  * The $callback argument should be the name of a function that echoes out the
  1603  * The $callback argument should be the name of a function that echoes out the
  1598  * HTML input tags for this setting field. Use get_option() to retrieve existing
  1604  * HTML input tags for this setting field. Use get_option() to retrieve existing
  1599  * values to show.
  1605  * values to show.
  1600  *
  1606  *
  1795  *
  1801  *
  1796  * @global array $wp_settings_errors Storage array of errors registered during this pageload
  1802  * @global array $wp_settings_errors Storage array of errors registered during this pageload
  1797  *
  1803  *
  1798  * @param string $setting  Optional. Slug title of a specific setting whose errors you want.
  1804  * @param string $setting  Optional. Slug title of a specific setting whose errors you want.
  1799  * @param bool   $sanitize Optional. Whether to re-sanitize the setting value before returning errors.
  1805  * @param bool   $sanitize Optional. Whether to re-sanitize the setting value before returning errors.
  1800  * @return array Array of settings errors.
  1806  * @return array {
       
  1807  *     Array of settings errors.
       
  1808  *
       
  1809  *     @type string $setting Slug title of the setting to which this error applies.
       
  1810  *     @type string $code    Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
       
  1811  *     @type string $message The formatted message text to display to the user (will be shown inside styled
       
  1812  *                           `<div>` and `<p>` tags).
       
  1813  *     @type string $type    Optional. Message type, controls HTML class. Possible values include 'error',
       
  1814  *                           'success', 'warning', 'info'. Default 'error'.
       
  1815  * }
  1801  */
  1816  */
  1802 function get_settings_errors( $setting = '', $sanitize = false ) {
  1817 function get_settings_errors( $setting = '', $sanitize = false ) {
  1803 	global $wp_settings_errors;
  1818 	global $wp_settings_errors;
  1804 
  1819 
  1805 	/*
  1820 	/*
  2014 <title><?php bloginfo( 'name' ); ?> &rsaquo; <?php echo $title; ?> &#8212; <?php _e( 'WordPress' ); ?></title>
  2029 <title><?php bloginfo( 'name' ); ?> &rsaquo; <?php echo $title; ?> &#8212; <?php _e( 'WordPress' ); ?></title>
  2015 	<?php
  2030 	<?php
  2016 	wp_enqueue_style( 'colors' );
  2031 	wp_enqueue_style( 'colors' );
  2017 	?>
  2032 	?>
  2018 <script type="text/javascript">
  2033 <script type="text/javascript">
  2019 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
  2034 addLoadEvent = function(func){if(typeof jQuery!=='undefined')jQuery(document).ready(func);else if(typeof wpOnload!=='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
  2020 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
  2035 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
  2021 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
  2036 var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?>',
  2022 	pagenow = '<?php echo $current_screen->id; ?>',
  2037 	pagenow = '<?php echo esc_js( $current_screen->id ); ?>',
  2023 	typenow = '<?php echo $current_screen->post_type; ?>',
  2038 	typenow = '<?php echo esc_js( $current_screen->post_type ); ?>',
  2024 	adminpage = '<?php echo $admin_body_class; ?>',
  2039 	adminpage = '<?php echo esc_js( $admin_body_class ); ?>',
  2025 	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
  2040 	thousandsSeparator = '<?php echo esc_js( $wp_locale->number_format['thousands_sep'] ); ?>',
  2026 	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
  2041 	decimalPoint = '<?php echo esc_js( $wp_locale->number_format['decimal_point'] ); ?>',
  2027 	isRtl = <?php echo (int) is_rtl(); ?>;
  2042 	isRtl = <?php echo (int) is_rtl(); ?>;
  2028 </script>
  2043 </script>
  2029 	<?php
  2044 	<?php
  2030 	/** This action is documented in wp-admin/admin-header.php */
  2045 	/** This action is documented in wp-admin/admin-header.php */
  2031 	do_action( 'admin_enqueue_scripts', $hook_suffix );
  2046 	do_action( 'admin_enqueue_scripts', $hook_suffix );
  2104 
  2119 
  2105 	/** This action is documented in wp-admin/admin-footer.php */
  2120 	/** This action is documented in wp-admin/admin-footer.php */
  2106 	do_action( 'admin_print_footer_scripts' );
  2121 	do_action( 'admin_print_footer_scripts' );
  2107 	?>
  2122 	?>
  2108 	</div>
  2123 	</div>
  2109 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
  2124 <script type="text/javascript">if(typeof wpOnload==='function')wpOnload();</script>
  2110 </body>
  2125 </body>
  2111 </html>
  2126 </html>
  2112 	<?php
  2127 	<?php
  2113 }
  2128 }
  2114 
  2129 
  2194 	if ( 'future' === $post->post_status ) {
  2209 	if ( 'future' === $post->post_status ) {
  2195 		$post_states['scheduled'] = _x( 'Scheduled', 'post status' );
  2210 		$post_states['scheduled'] = _x( 'Scheduled', 'post status' );
  2196 	}
  2211 	}
  2197 
  2212 
  2198 	if ( 'page' === get_option( 'show_on_front' ) ) {
  2213 	if ( 'page' === get_option( 'show_on_front' ) ) {
  2199 		if ( intval( get_option( 'page_on_front' ) ) === $post->ID ) {
  2214 		if ( (int) get_option( 'page_on_front' ) === $post->ID ) {
  2200 			$post_states['page_on_front'] = _x( 'Front Page', 'page label' );
  2215 			$post_states['page_on_front'] = _x( 'Front Page', 'page label' );
  2201 		}
  2216 		}
  2202 
  2217 
  2203 		if ( intval( get_option( 'page_for_posts' ) ) === $post->ID ) {
  2218 		if ( (int) get_option( 'page_for_posts' ) === $post->ID ) {
  2204 			$post_states['page_for_posts'] = _x( 'Posts Page', 'page label' );
  2219 			$post_states['page_for_posts'] = _x( 'Posts Page', 'page label' );
  2205 		}
  2220 		}
  2206 	}
  2221 	}
  2207 
  2222 
  2208 	if ( intval( get_option( 'wp_page_for_privacy_policy' ) ) === $post->ID ) {
  2223 	if ( (int) get_option( 'wp_page_for_privacy_policy' ) === $post->ID ) {
  2209 		$post_states['page_for_privacy_policy'] = _x( 'Privacy Policy Page', 'page label' );
  2224 		$post_states['page_for_privacy_policy'] = _x( 'Privacy Policy Page', 'page label' );
  2210 	}
  2225 	}
  2211 
  2226 
  2212 	/**
  2227 	/**
  2213 	 * Filters the default post display states used in the posts list table.
  2228 	 * Filters the default post display states used in the posts list table.
  2226 
  2241 
  2227 /**
  2242 /**
  2228  * Outputs the attachment media states as HTML.
  2243  * Outputs the attachment media states as HTML.
  2229  *
  2244  *
  2230  * @since 3.2.0
  2245  * @since 3.2.0
       
  2246  * @since 5.6.0 Added the `$echo` parameter and a return value.
  2231  *
  2247  *
  2232  * @param WP_Post $post The attachment post to retrieve states for.
  2248  * @param WP_Post $post The attachment post to retrieve states for.
  2233  */
  2249  * @param bool    $echo Optional. Whether to echo the post states as an HTML string. Default true.
  2234 function _media_states( $post ) {
  2250  * @return string Media states string.
       
  2251  */
       
  2252 function _media_states( $post, $echo = true ) {
       
  2253 	$media_states        = get_media_states( $post );
       
  2254 	$media_states_string = '';
       
  2255 
       
  2256 	if ( ! empty( $media_states ) ) {
       
  2257 		$state_count = count( $media_states );
       
  2258 		$i           = 0;
       
  2259 
       
  2260 		$media_states_string .= ' &mdash; ';
       
  2261 
       
  2262 		foreach ( $media_states as $state ) {
       
  2263 			$sep = ( ++$i === $state_count ) ? '' : ', ';
       
  2264 
       
  2265 			$media_states_string .= "<span class='post-state'>$state$sep</span>";
       
  2266 		}
       
  2267 	}
       
  2268 
       
  2269 	if ( $echo ) {
       
  2270 		echo $media_states_string;
       
  2271 	}
       
  2272 
       
  2273 	return $media_states_string;
       
  2274 }
       
  2275 
       
  2276 /**
       
  2277  * Retrieves an array of media states from an attachment.
       
  2278  *
       
  2279  * @since 5.6.0
       
  2280  *
       
  2281  * @param WP_Post $post The attachment to retrieve states for.
       
  2282  * @return string[] Array of media state labels keyed by their state.
       
  2283  */
       
  2284 function get_media_states( $post ) {
  2235 	static $header_images;
  2285 	static $header_images;
  2236 
  2286 
  2237 	$media_states = array();
  2287 	$media_states = array();
  2238 	$stylesheet   = get_option( 'stylesheet' );
  2288 	$stylesheet   = get_option( 'stylesheet' );
  2239 
  2289 
  2257 			}
  2307 			}
  2258 
  2308 
  2259 			// Display "Current Header Image" if the image is currently the header image.
  2309 			// Display "Current Header Image" if the image is currently the header image.
  2260 			if ( $header_image && wp_get_attachment_url( $post->ID ) === $header_image ) {
  2310 			if ( $header_image && wp_get_attachment_url( $post->ID ) === $header_image ) {
  2261 				$media_states[] = __( 'Current Header Image' );
  2311 				$media_states[] = __( 'Current Header Image' );
       
  2312 			}
       
  2313 		}
       
  2314 
       
  2315 		if ( get_theme_support( 'custom-header', 'video' ) && has_header_video() ) {
       
  2316 			$mods = get_theme_mods();
       
  2317 			if ( isset( $mods['header_video'] ) && $post->ID === $mods['header_video'] ) {
       
  2318 				$media_states[] = __( 'Current Header Video' );
  2262 			}
  2319 			}
  2263 		}
  2320 		}
  2264 	}
  2321 	}
  2265 
  2322 
  2266 	if ( current_theme_supports( 'custom-background' ) ) {
  2323 	if ( current_theme_supports( 'custom-background' ) ) {
  2292 	 *
  2349 	 *
  2293 	 * @param string[] $media_states An array of media states. Default 'Header Image',
  2350 	 * @param string[] $media_states An array of media states. Default 'Header Image',
  2294 	 *                               'Background Image', 'Site Icon', 'Logo'.
  2351 	 *                               'Background Image', 'Site Icon', 'Logo'.
  2295 	 * @param WP_Post  $post         The current attachment object.
  2352 	 * @param WP_Post  $post         The current attachment object.
  2296 	 */
  2353 	 */
  2297 	$media_states = apply_filters( 'display_media_states', $media_states, $post );
  2354 	return apply_filters( 'display_media_states', $media_states, $post );
  2298 
       
  2299 	if ( ! empty( $media_states ) ) {
       
  2300 		$state_count = count( $media_states );
       
  2301 		$i           = 0;
       
  2302 
       
  2303 		echo ' &mdash; ';
       
  2304 
       
  2305 		foreach ( $media_states as $state ) {
       
  2306 			$sep = ( ++$i === $state_count ) ? '' : ', ';
       
  2307 
       
  2308 			echo "<span class='post-state'>$state$sep</span>";
       
  2309 		}
       
  2310 	}
       
  2311 }
  2355 }
  2312 
  2356 
  2313 /**
  2357 /**
  2314  * Test support for compressing JavaScript from PHP
  2358  * Test support for compressing JavaScript from PHP
  2315  *
  2359  *
  2620 
  2664 
  2621 	return $output;
  2665 	return $output;
  2622 }
  2666 }
  2623 
  2667 
  2624 /**
  2668 /**
  2625  * Output a notice when editing the page for posts (internal use only).
  2669  * Outputs a notice when editing the page for posts (internal use only).
  2626  *
  2670  *
  2627  * @ignore
  2671  * @ignore
  2628  * @since 4.2.0
  2672  * @since 4.2.0
  2629  */
  2673  */
  2630 function _wp_posts_page_notice() {
  2674 function _wp_posts_page_notice() {
  2631 	echo '<div class="notice notice-warning inline"><p>' . __( 'You are currently editing the page that shows your latest posts.' ) . '</p></div>';
  2675 	printf(
  2632 }
  2676 		'<div class="notice notice-warning inline"><p>%s</p></div>',
       
  2677 		__( 'You are currently editing the page that shows your latest posts.' )
       
  2678 	);
       
  2679 }
       
  2680 
       
  2681 /**
       
  2682  * Outputs a notice when editing the page for posts in the block editor (internal use only).
       
  2683  *
       
  2684  * @ignore
       
  2685  * @since 5.8.0
       
  2686  */
       
  2687 function _wp_block_editor_posts_page_notice() {
       
  2688 	wp_add_inline_script(
       
  2689 		'wp-notices',
       
  2690 		sprintf(
       
  2691 			'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { isDismissible: false } )',
       
  2692 			__( 'You are currently editing the page that shows your latest posts.' )
       
  2693 		),
       
  2694 		'after'
       
  2695 	);
       
  2696 }