Skip to content
Closed
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: 1 addition & 1 deletion src/wp-admin/customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
<?php if ( $compatible_wp && $compatible_php ) : ?>
<?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate &amp; Publish' ); ?>
<div id="customize-save-button-wrapper" class="customize-save-button-wrapper" >
<?php submit_button( $save_text, 'primary button-compact save', 'save', false ); ?>
<?php submit_button( $save_text, 'primary compact save', 'save', false ); ?>
<button id="publish-settings" class="publish-settings button-primary button-compact button dashicons dashicons-admin-generic" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled></button>
</div>
<?php else : ?>
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-comments-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ protected function extra_tablenav( $which ) {

if ( ! empty( $output ) && $this->has_items() ) {
echo $output;
submit_button( __( 'Filter' ), 'button-compact', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
submit_button( __( 'Filter' ), 'compact', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-links-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected function extra_tablenav( $which ) {

wp_dropdown_categories( $dropdown_options );

submit_button( __( 'Filter' ), 'button-compact', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
submit_button( __( 'Filter' ), 'compact', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
?>
</div>
<?php
Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/class-wp-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public function search_box( $text, $input_id ) {
<p class="search-box">
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
<input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" />
<?php submit_button( $text, 'button-compact', '', false, array( 'id' => 'search-submit' ) ); ?>
<?php submit_button( $text, 'compact', '', false, array( 'id' => 'search-submit' ) ); ?>
</p>
<?php
}
Expand Down Expand Up @@ -632,7 +632,7 @@ protected function bulk_actions( $which = '' ) {

echo "</select>\n";

submit_button( __( 'Apply' ), 'action button-compact', 'bulk_action', false, array( 'id' => "doaction$two" ) );
submit_button( __( 'Apply' ), 'action compact', 'bulk_action', false, array( 'id' => "doaction$two" ) );
echo "\n";
}

Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/class-wp-media-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ protected function extra_tablenav( $which ) {
/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
do_action( 'restrict_manage_posts', $this->screen->post_type, $which );

submit_button( __( 'Filter' ), 'button-compact', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
submit_button( __( 'Filter' ), 'compact', 'filter_action', false, array( 'id' => 'post-query-submit' ) );

if ( $this->is_trash && $this->has_items()
&& current_user_can( 'edit_others_posts' )
) {
submit_button( __( 'Empty Trash' ), 'apply button-compact', 'delete_all', false );
submit_button( __( 'Empty Trash' ), 'apply compact', 'delete_all', false );
}
?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-posts-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ protected function extra_tablenav( $which ) {

if ( ! empty( $output ) ) {
echo $output;
submit_button( __( 'Filter' ), 'button-compact', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
submit_button( __( 'Filter' ), 'compact', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -2905,7 +2905,7 @@ function media_upload_library_form( $errors ) {
</select>
<?php } ?>

<?php submit_button( __( 'Filter &#187;' ), 'button-compact', 'post-query-submit', false ); ?>
<?php submit_button( __( 'Filter &#187;' ), 'compact', 'post-query-submit', false ); ?>

</div>

Expand Down
6 changes: 3 additions & 3 deletions src/wp-admin/includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -2562,7 +2562,7 @@ function compression_test() {
*
* @param string $text Optional. The text of the button. Defaults to 'Save Changes'.
* @param string $type Optional. The type and CSS class(es) of the button. Core values
* include 'primary', 'small', and 'large'. Default 'primary'.
* include 'primary', 'small', 'compact' and 'large'. Default 'primary'.
* @param string $name Optional. The HTML name of the submit button. If no `id` attribute
* is given in the `$other_attributes` parameter, `$name` will be used
* as the button's `id`. Default 'submit'.
Expand All @@ -2586,7 +2586,7 @@ function submit_button( $text = '', $type = 'primary', $name = 'submit', $wrap =
*
* @param string $text Optional. The text of the button. Defaults to 'Save Changes'.
* @param string $type Optional. The type and CSS class(es) of the button. Core values
* include 'primary', 'small', and 'large'. Default 'primary large'.
* include 'primary', 'small', 'compact' and 'large'. Default 'primary large'.
* @param string $name Optional. The HTML name of the submit button. If no `id` attribute
* is given in the `$other_attributes` parameter, `$name` will be used
* as the button's `id`. Default 'submit'.
Expand All @@ -2605,7 +2605,7 @@ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit
$type = explode( ' ', $type );
}

$button_shorthand = array( 'primary', 'small', 'large' );
$button_shorthand = array( 'primary', 'small', 'large', 'compact' );
$classes = array( 'button' );

foreach ( $type as $t ) {
Expand Down
37 changes: 37 additions & 0 deletions tests/phpunit/tests/admin/includesTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,41 @@ public function test_get_post_states_with_null_returns_empty_array() {
$result = get_post_states( null );
$this->assertSame( array(), $result, 'get_post_states() should return an empty array when WP_Post is not supplied.' );
}

/**
* Tests that get_submit_button() expands the type shorthands into their
* `button-*` classes.
*
* @ticket 64892
*
* @covers ::get_submit_button
*
* @dataProvider data_get_submit_button_shorthand
*
* @param string|array $type The type argument passed to get_submit_button().
* @param string $expected The expected class attribute value.
*/
public function test_get_submit_button_expands_type_shorthands( $type, $expected ) {
$button = get_submit_button( 'Save', $type, 'submit', false );

$this->assertStringContainsString( 'class="' . $expected . '"', $button );
}

/**
* Data provider.
*
* @return array[]
*/
public function data_get_submit_button_shorthand() {
return array(
'primary shorthand' => array( 'primary', 'button button-primary' ),
'small shorthand' => array( 'small', 'button button-small' ),
'large shorthand' => array( 'large', 'button button-large' ),
'compact shorthand' => array( 'compact', 'button button-compact' ),
'multiple shorthands' => array( 'primary compact', 'button button-primary button-compact' ),
'non-shorthand with compact' => array( 'action compact', 'button action button-compact' ),
'array type with compact' => array( array( 'primary', 'compact' ), 'button button-primary button-compact' ),
'raw button-compact unchanged' => array( 'button-compact', 'button button-compact' ),
);
}
}
Loading