mirror of
git://develop.git.wordpress.org/
synced 2025-01-18 05:18:42 +01:00
Post Formats: In bulk_edit_posts()
, set post format before the post is updated, for consistency with edit_post()
.
This makes sure that plugins hooked to `save_post` get the right post format. Props Chouby, SergeyBiryukov. Fixes #41396. git-svn-id: https://develop.svn.wordpress.org/trunk@41187 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b22e409f81
commit
ddc6fafd06
@ -564,6 +564,11 @@ function bulk_edit_posts( $post_data = null ) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isset( $post_data['post_format'] ) ) {
|
||||||
|
set_post_format( $post_ID, $post_data['post_format'] );
|
||||||
|
unset( $post_data['tax_input']['post_format'] );
|
||||||
|
}
|
||||||
|
|
||||||
$updated[] = wp_update_post( $post_data );
|
$updated[] = wp_update_post( $post_data );
|
||||||
|
|
||||||
if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
|
if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
|
||||||
@ -572,9 +577,6 @@ function bulk_edit_posts( $post_data = null ) {
|
|||||||
else
|
else
|
||||||
unstick_post( $post_ID );
|
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 );
|
return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );
|
||||||
|
@ -207,7 +207,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
|||||||
/**
|
/**
|
||||||
* @ticket 27792
|
* @ticket 27792
|
||||||
*/
|
*/
|
||||||
function test_bulk_edit_posts_stomping() {
|
public function test_bulk_edit_posts_stomping() {
|
||||||
wp_set_current_user( self::$admin_id );
|
wp_set_current_user( self::$admin_id );
|
||||||
|
|
||||||
$post1 = self::factory()->post->create( array(
|
$post1 = self::factory()->post->create( array(
|
||||||
@ -244,6 +244,31 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
|||||||
$this->assertEquals( 'closed', $post->ping_status );
|
$this->assertEquals( 'closed', $post->ping_status );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 41396
|
||||||
|
*/
|
||||||
|
public function test_bulk_edit_posts_should_set_post_format_before_wp_update_post_runs() {
|
||||||
|
wp_set_current_user( self::$admin_id );
|
||||||
|
|
||||||
|
$request = array(
|
||||||
|
'post_format' => 'aside',
|
||||||
|
'_status' => -1,
|
||||||
|
'post' => array( self::$post_id ),
|
||||||
|
);
|
||||||
|
|
||||||
|
add_action( 'save_post', array( $this, 'check_post_format' ) );
|
||||||
|
|
||||||
|
bulk_edit_posts( $request );
|
||||||
|
|
||||||
|
remove_action( 'save_post', array( $this, 'check_post_format' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function check_post_format( $post_id ) {
|
||||||
|
if ( self::$post_id === $post_id ) {
|
||||||
|
$this->assertEquals( 'aside', get_post_format( $post_id ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ticket 38293
|
* @ticket 38293
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user