Translate and prettify post formats for display. Also, filterable by themes/plugins to add new ones. see #14746

git-svn-id: http://svn.automattic.com/wordpress/trunk@16191 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2010-11-04 18:33:50 +00:00
parent 0e77a0b5e4
commit b581a43b30
2 changed files with 24 additions and 2 deletions

View File

@ -158,11 +158,13 @@ echo esc_html( $visibility_trans ); ?></span>
if ( 'post' == $post->post_type && current_theme_supports( 'post-formats' ) ) :
$post_formats = get_theme_support( 'post-formats' );
$post_formats_display = get_post_format_strings();
if ( is_array( $post_formats[0] ) ) :
$post_format = get_post_format( $post->ID );
if ( !$post_format )
$post_format = '0';
$post_format_display = ( $post_format ) ? $post_format : __('Default');
$post_format_display = $post_formats_display[$post_format];
?>
<div class="misc-pub-section" id="post-formats"><label for="post-format"><?php _e( 'Format:' ); ?></label>
@ -173,7 +175,7 @@ if ( is_array( $post_formats[0] ) ) :
<select id="post-format" name="post_format">
<option value="0" <?php selected( $post_format, '0' ); ?>><?php _e('Default'); ?></option>
<?php foreach ( $post_formats[0] as $format ) : ?>
<option value="<?php echo esc_attr( $format ); ?>" <?php selected( $post_format, $format ); ?>><?php echo esc_html( $format ); ?></option>
<option value="<?php echo esc_attr( $format ); ?>" <?php selected( $post_format, $format ); ?>><?php echo esc_html( $post_formats_display[$format] ); ?></option>
<?php endforeach; ?>
</select>
<a href="#post-formats" class="save-post-format hide-if-no-js button"><?php _e('OK'); ?></a>

View File

@ -5212,4 +5212,24 @@ function wp_quickpress_form( $args = array(), $post_type = 'post'){
endif;
}
/**
* Returns an array of post format slugs to their translated and pretty display versions
*
* @return array The array of translations
*/
function get_post_format_strings() {
$strings = array(
'0' => _x( 'Default', 'Post format' ),
'aside' => _x( 'Aside', 'Post format' ),
'chat' => _x( 'Chat', 'Post format' ),
'gallery' => _x( 'Gallery', 'Post format' ),
'link' => _x( 'Link', 'Post format' ),
'image' => _x( 'Image', 'Post format' ),
'quote' => _x( 'Quote', 'Post format' ),
'status' => _x( 'Status', 'Post format' ),
'video' => _x( 'Video', 'Post format' )
);
return apply_filters( 'post_format_strings', $strings );
}
?>