Changeset 49223
- Timestamp:
- 10/20/2020 03:12:07 AM (4 years ago)
- Location:
- trunk/src
- Files:
-
- 3 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 -
trunk/src/wp-includes/media-template.php
r49222 r49223 460 460 <# } #> 461 461 462 <# if ( data.mediaStates ) { #> 463 <div class="media-states"><strong><?php _e( 'Used as:' ); ?></strong> {{ data.mediaStates }}</div> 464 <# } #> 465 462 466 <div class="compat-meta"> 463 467 <# if ( data.compat && data.compat.meta ) { #> … … 672 676 <span class="screen-reader-text">{{ data.fileLengthHumanReadable }}</span> 673 677 </div> 678 <# } #> 679 680 <# if ( data.mediaStates ) { #> 681 <div class="media-states"><strong><?php _e( 'Used as:' ); ?></strong> {{ data.mediaStates }}</div> 674 682 <# } #> 675 683 -
trunk/src/wp-includes/media.php
r49209 r49223 3977 3977 } 3978 3978 3979 $media_states = get_media_states( $attachment ); 3980 if ( ! empty( $media_states ) ) { 3981 $response['mediaStates'] = implode( ', ', $media_states ); 3982 } 3983 3979 3984 /** 3980 3985 * Filters the attachment data prepared for JavaScript.
Note: See TracChangeset
for help on using the changeset viewer.