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
10 changes: 10 additions & 0 deletions src/wp-admin/css/edit.css
Original file line number Diff line number Diff line change
Expand Up @@ -706,12 +706,22 @@ form#tags-filter {
font-weight: 600;
}

#post-status-select,
#post-visibility-select,
#comment-status-radio {
line-height: 1.5;
margin-top: 3px;
}

#post-status-select select {
max-width: 100%;
width: 100%;
}
Comment on lines +716 to +719

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this change since that way the buttons don't really shift depending on the width of the selected value. This is even more relevant on languages where those strings are longer.

But it seems like max-width is not necessary?

Suggested change
#post-status-select select {
max-width: 100%;
width: 100%;
}
#post-status-select select {
width: 100%;
}


#post-status-select .post-status-actions {
margin: 0.7em 0 0;
}

#linksubmitdiv .inside, /* Old Link Manager back-compat. */
#poststuff #submitdiv .inside {
margin: 0;
Expand Down
6 changes: 4 additions & 2 deletions src/wp-admin/includes/meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ function post_submit_meta_box( $post, $args = array() ) {
<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e( 'Draft' ); ?></option>
<?php endif; ?>
</select>
<a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e( 'OK' ); ?></a>
<a href="#post_status" class="cancel-post-status hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a>
<p class="post-status-actions">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we achieve the margin effect without changing the markup?

<a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e( 'OK' ); ?></a>
<a href="#post_status" class="cancel-post-status hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a>
</p>
</div>
<?php
}
Expand Down
47 changes: 47 additions & 0 deletions tests/phpunit/tests/admin/includesMetaBoxes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

/**
* @group admin
*/
class Tests_Admin_IncludesMetaBoxes extends WP_UnitTestCase {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are irrelevant and can be deleted

protected static $admin_id;

public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
}

public function set_up() {
parent::set_up();

require_once ABSPATH . 'wp-admin/includes/meta-boxes.php';

wp_set_current_user( self::$admin_id );
}

public function test_post_submit_meta_box_status_controls_keep_legacy_select_contract() {
$post = self::factory()->post->create_and_get( array( 'post_status' => 'draft' ) );
$output = $this->get_post_submit_meta_box_output( $post );

$this->assertStringContainsString( '<select name="post_status" id="post_status">', $output );
$this->assertStringNotContainsString( '<fieldset id="post_status"', $output );
$this->assertStringContainsString( '<option selected=\'selected\' value=\'draft\'>Draft</option>', $output );
$this->assertStringContainsString( '<option value=\'pending\'>Pending Review</option>', $output );

$this->assertMatchesRegularExpression(
'/<select name="post_status" id="post_status">.*value=\'pending\'.*value=\'draft\'.*<\/select>/s',
$output
);
$this->assertMatchesRegularExpression(
'/<\/select>\s*<p class="post-status-actions">\s*<a href="#post_status" class="save-post-status hide-if-no-js button">OK<\/a>\s*<a href="#post_status" class="cancel-post-status hide-if-no-js button-cancel">Cancel<\/a>\s*<\/p>/',
$output
);
}

private function get_post_submit_meta_box_output( WP_Post $post ) {
$GLOBALS['post'] = $post;

ob_start();
post_submit_meta_box( $post );
return ob_get_clean();
}
}
Loading