Add post formats to quick edit and bulk edit. Fixes #18083.

git-svn-id: http://svn.automattic.com/wordpress/trunk@18722 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
duck_ 2011-09-19 17:02:58 +00:00
parent 5a4061bb13
commit 698957e40e
6 changed files with 37 additions and 5 deletions

View File

@ -987,6 +987,25 @@ class WP_Posts_List_Table extends WP_List_Table {
</div>
<?php if ( post_type_supports( $screen->post_type, 'post-formats' ) && current_theme_supports( 'post-formats' ) ) :
$post_formats = get_theme_support( 'post-formats' );
if ( is_array( $post_formats[0] ) ) : ?>
<div class="inline-edit-group">
<label class="alignleft" for="post_format">
<span class="title"><?php _e( 'Post Format' ); ?></span>
<select name="post_format" id="post_format">
<?php if ( $bulk ) : ?>
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<?php endif; ?>
<option value="0"><?php _ex( 'Standard', 'Post format' ); ?></option>
<?php foreach ( $post_formats[0] as $format ): ?>
<option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
<?php endforeach; ?>
</select></label>
</div>
<?php endif; ?>
<?php endif; // post-formats ?>
</div></fieldset>
<?php

View File

@ -307,9 +307,9 @@ function bulk_edit_posts( $post_data = null ) {
foreach ( $post_data['tax_input'] as $tax_name => $terms ) {
if ( empty($terms) )
continue;
if ( is_taxonomy_hierarchical( $tax_name ) )
if ( is_taxonomy_hierarchical( $tax_name ) ) {
$tax_input[$tax_name] = array_map( 'absint', $terms );
else {
} else {
$tax_input[$tax_name] = preg_replace( '/\s*,\s*/', ',', rtrim( trim($terms), ' ,' ) );
$tax_input[$tax_name] = explode(',', $tax_input[$tax_name]);
}
@ -332,6 +332,14 @@ function bulk_edit_posts( $post_data = null ) {
}
}
if ( isset( $post_data['post_format'] ) ) {
if ( '0' == $post_data['post_format'] )
$post_data['post_format'] = false;
// don't change the post format if it's not supported or not '0' (standard)
elseif ( ! current_theme_supports( 'post-formats', $post_data['post_format'] ) )
unset( $post_data['post_format'] );
}
$updated = $skipped = $locked = array();
foreach ( $post_IDs as $post_ID ) {
$post_type_object = get_post_type_object( get_post_type( $post_ID ) );
@ -382,6 +390,8 @@ function bulk_edit_posts( $post_data = null ) {
unstick_post( $post_ID );
}
if ( isset( $post_data['post_format'] ) )
set_post_format( $post_ID, $post_data['post_format'] );
}
return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );

View File

@ -310,6 +310,9 @@ function get_inline_data($post) {
if ( !$post_type_object->hierarchical )
echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
if ( post_type_supports( $post->post_type, 'post-formats' ) )
echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
echo '</div>';
}

View File

@ -129,7 +129,7 @@ inlineEditPost = {
if ( typeof(id) == 'object' )
id = t.getId(id);
fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password'];
fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password', 'post_format'];
if ( t.type == 'page' )
fields.push('post_parent', 'menu_order', 'page_template');

File diff suppressed because one or more lines are too long

View File

@ -323,7 +323,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20100407', 1 );
$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20110609', 1 );
$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20110919', 1 );
$scripts->add_script_data( 'inline-edit-post', 'inlineEditL10n', array(
'error' => __('Error while saving the changes.'),
'ntdeltitle' => __('Remove From Bulk Edit'),