Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/wp-includes/class-wp-xmlrpc-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@ protected function _prepare_user( $user, $fields ) {
* @type string $post_status Post status. Default 'draft'
* @type string $post_title Post title.
* @type int $post_author Post author ID.
* @type int $menu_order Post order. Default 0.
* @type string $post_excerpt Post excerpt.
* @type string $post_content Post content.
* @type string $post_date_gmt Post date in GMT.
Expand Down Expand Up @@ -1475,6 +1476,7 @@ protected function _insert_post( $user, $content_struct ) {
'post_name' => null,
'post_thumbnail' => null,
'post_parent' => 0,
'menu_order' => 0,
'ping_status' => '',
'comment_status' => '',
'custom_fields' => null,
Expand Down
58 changes: 58 additions & 0 deletions tests/phpunit/tests/xmlrpc/wp/editPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,64 @@ public function test_edit_own_post() {
$this->assertSame( $new_title, $out->post_title );
}

/**
* @ticket 40863
* @dataProvider data_menu_order
*
* @param string $post_type Post type.
* @param int $menu_order Menu order.
*/
public function test_menu_order( $post_type, $menu_order ) {
$editor_id = $this->make_user_by_role( 'editor' );
$post_id = self::factory()->post->create(
array(
'post_author' => $editor_id,
'post_type' => $post_type,
'menu_order' => 10,
)
);

$result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, array( 'menu_order' => $menu_order ) ) );

$this->assertNotIXRError( $result );
$this->assertTrue( $result );
$this->assertSame( $menu_order, get_post( $post_id )->menu_order );
}

/**
* Data provider for test_menu_order().
*
* @return array
*/
public function data_menu_order() {
return array(
'post' => array( 'post', 5 ),
'page' => array( 'page', 5 ),
'zero order' => array( 'page', 0 ),
'negative order' => array( 'page', -5 ),
);
}

/**
* @ticket 40863
*/
public function test_menu_order_is_preserved_when_omitted() {
$editor_id = $this->make_user_by_role( 'editor' );
$post_id = self::factory()->post->create(
array(
'post_author' => $editor_id,
'post_type' => 'page',
'menu_order' => 10,
)
);

$result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, array( 'post_title' => 'Updated title' ) ) );

$this->assertNotIXRError( $result );
$this->assertTrue( $result );
$this->assertSame( 10, get_post( $post_id )->menu_order );
}

public function test_capable_edit_others_post() {
$contributor_id = $this->make_user_by_role( 'contributor' );
$this->make_user_by_role( 'editor' );
Expand Down
35 changes: 35 additions & 0 deletions tests/phpunit/tests/xmlrpc/wp/newPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,41 @@ public function test_basic_content() {
$this->assertStringMatchesFormat( '%d', $result );
}

/**
* @ticket 40863
* @dataProvider data_menu_order
*
* @param string $post_type Post type.
* @param int $menu_order Menu order.
*/
public function test_menu_order( $post_type, $menu_order ) {
$this->make_user_by_role( 'editor' );

$post = array(
'post_title' => 'Menu order test',
'post_type' => $post_type,
'menu_order' => $menu_order,
);
$result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );

$this->assertNotIXRError( $result );
$this->assertSame( $menu_order, get_post( $result )->menu_order );
}

/**
* Data provider for test_menu_order().
*
* @return array
*/
public function data_menu_order() {
return array(
'post' => array( 'post', 5 ),
'page' => array( 'page', 5 ),
'zero order' => array( 'page', 0 ),
'negative order' => array( 'page', -5 ),
);
}

public function test_ignore_id() {
$this->make_user_by_role( 'author' );

Expand Down
Loading