64892 get_submit_button() should support "compact" button shorthand - #11305
64892 get_submit_button() should support "compact" button shorthand#11305nirav7707 wants to merge 7 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
t-hamano
left a comment
There was a problem hiding this comment.
Thanks for the PR! Can you update the following PHPDocs?
|
Goes in /**
* Ensures the 'compact' button variation is recognized as a shorthand and
* rendered as the `button-compact` CSS class.
*
* @ticket 64892
*
* @covers ::get_submit_button
*/
public function test_get_submit_button_supports_compact_shorthand() {
$button = get_submit_button( 'Save', 'compact', 'submit', false );
$this->assertStringContainsString(
'class="button button-compact"',
$button,
'The "compact" type was not converted to the "button-compact" shorthand class.'
);
}
/**
* Ensures recognized button shorthands are converted to their `button-*`
* classes, while non-shorthand values are passed through verbatim.
*
* @ticket 64892
*
* @covers ::get_submit_button
*
* @dataProvider data_get_submit_button_shorthand_classes
*
* @param string $type The button type passed to get_submit_button().
* @param string $expected_class The expected value of the class attribute.
*/
public function test_get_submit_button_shorthand_classes( $type, $expected_class ) {
$button = get_submit_button( 'Save', $type, 'submit', false );
$this->assertStringContainsString(
'class="' . $expected_class . '"',
$button,
"The button type \"{$type}\" did not produce the expected class attribute."
);
}
/**
* Data provider.
*
* @return array[]
*/
public function data_get_submit_button_shorthand_classes() {
return array(
'primary' => array( 'primary', 'button button-primary' ),
'small' => array( 'small', 'button button-small' ),
'large' => array( 'large', 'button button-large' ),
'compact' => array( 'compact', 'button button-compact' ),
'primary + compact' => array( 'primary compact', 'button button-primary button-compact' ),
'secondary skipped' => array( 'secondary', 'button' ),
'custom passthru' => array( 'my-custom-class', 'button my-custom-class' ),
);
}Happy to push these as a commit if preferred. |
|
@wppoland Thanks for the suggestion! @nirav7707. Could you add some unit tests? Additionally, all instances where diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php
index 71ae2a9eea..d960373dbc 100644
--- a/src/wp-admin/includes/media.php
+++ b/src/wp-admin/includes/media.php
@@ -2905,7 +2905,7 @@ function media_upload_library_form( $errors ) {
</select>
<?php } ?>
- <?php submit_button( __( 'Filter »' ), 'button-compact', 'post-query-submit', false ); ?>
+ <?php submit_button( __( 'Filter »' ), 'compact', 'post-query-submit', false ); ?>
</div> |
|
Hi @nirav7707, Do you have the bandwidth to address the following feedback? Thank you!
|
Now that `get_submit_button()` supports the `compact` shorthand, update all core callers that pass the raw `button-compact` class to use it. This keeps the callers consistent with the other shorthands (`primary`, `small`, `large`) and produces identical markup. Co-Authored-By: Claude <noreply@anthropic.com>
Addressed in be35955 |
Cover the expansion of the `primary`, `small`, `large`, and `compact` type shorthands into their `button-*` classes, including combined, array, and non-shorthand inputs. This guards the newly added `compact` shorthand and documents the existing expansion behavior. Co-Authored-By: Claude <noreply@anthropic.com>
Thank you for your suggestion! I've pushed the unit tests referring to your code. 24c2790 |
Add `compact` to the type shorthands expanded by `get_submit_button()`, so passing `compact` now yields the `button-compact` class. This matches the existing `primary`, `small`, and `large` shorthands. Developed in: #11305 Props motylanogha, niravsherasiya7707, wildworks. Fixes #64892. git-svn-id: https://develop.svn.wordpress.org/trunk@62756 602fd350-edb4-49c9-b593-d223f7449a82
Add `compact` to the type shorthands expanded by `get_submit_button()`, so passing `compact` now yields the `button-compact` class. This matches the existing `primary`, `small`, and `large` shorthands. Developed in: WordPress/wordpress-develop#11305 Props motylanogha, niravsherasiya7707, wildworks. Fixes #64892. Built from https://develop.svn.wordpress.org/trunk@62756 git-svn-id: http://core.svn.wordpress.org/trunk@62040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
|
Verified the unit tests locally on the branch, they pass successfully: OK (35 tests, 119 assertions). |
Core trac: https://core.trac.wordpress.org/ticket/64892
Test:

Large
Compact

Small
