Changeset 49223 for trunk/src/wp-admin/includes/template.php
- Timestamp:
- 10/20/2020 03:12:07 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/template.php
r49205 r49223 2238 2238 * 2239 2239 * @since 3.2.0 2240 * @since 5.6.0 Added the `$echo` parameter. 2240 2241 * 2241 2242 * @param WP_Post $post The attachment post to retrieve states for. 2242 */ 2243 function _media_states( $post ) { 2243 * @param bool $echo Optional. Whether to echo the post states as an HTML string. Default true. 2244 * @return string Media states string. 2245 */ 2246 function _media_states( $post, $echo = true ) { 2247 $media_states = get_media_states( $post ); 2248 $media_states_string = ''; 2249 2250 if ( ! empty( $media_states ) ) { 2251 $state_count = count( $media_states ); 2252 $i = 0; 2253 2254 $media_states_string .= ' — '; 2255 2256 foreach ( $media_states as $state ) { 2257 $sep = ( ++$i === $state_count ) ? '' : ', '; 2258 2259 $media_states_string .= "<span class='post-state'>$state$sep</span>"; 2260 } 2261 } 2262 2263 if ( $echo ) { 2264 echo $media_states_string; 2265 } 2266 2267 return $media_states_string; 2268 } 2269 2270 /** 2271 * Retrieves an array of media states from an attachment. 2272 * 2273 * @since 5.6.0 2274 * 2275 * @param WP_Post $post The attachment to retrieve states for. 2276 * @return string[] Array of media state labels keyed by their state. 2277 */ 2278 function get_media_states( $post ) { 2244 2279 static $header_images; 2245 2280 … … 2311 2346 * @param WP_Post $post The current attachment object. 2312 2347 */ 2313 $media_states = apply_filters( 'display_media_states', $media_states, $post ); 2314 2315 if ( ! empty( $media_states ) ) { 2316 $state_count = count( $media_states ); 2317 $i = 0; 2318 2319 echo ' — '; 2320 2321 foreach ( $media_states as $state ) { 2322 $sep = ( ++$i === $state_count ) ? '' : ', '; 2323 2324 echo "<span class='post-state'>$state$sep</span>"; 2325 } 2326 } 2348 return apply_filters( 'display_media_states', $media_states, $post ); 2327 2349 } 2328 2350
Note: See TracChangeset
for help on using the changeset viewer.