Skip to content

Commit 9ec9604

Browse files
Editor: Remove the unsupported single action context.
Removes `single` from the `context` values the entity actions registry supports, leaving `list`. No screen shows the actions of the `single` context, so an action registered with it showed nowhere. Removing it before 7.2 ships keeps the option to add it later with a defined meaning. An action registered with `single` is now reported with `_doing_it_wrong()`, like any other unsupported value, and `single` is no longer in the `context` enum of the `/wp/v2/entity-actions` schema. Developed in #14545. Synced from WordPress/gutenberg#85186. Follow-up to [64517]. Props jorgefilipecosta, oandregal. See #66343. git-svn-id: https://develop.svn.wordpress.org/trunk@64601 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 43f60f4 commit 9ec9604

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎src/wp-includes/class-wp-entity-actions-registry.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class WP_Entity_Actions_Registry {
4848
* @var array<string, string[]>
4949
*/
5050
const SUPPORTED_VALUES = array(
51-
'context' => array( 'list', 'single' ),
51+
'context' => array( 'list' ),
5252
'modalSize' => array( 'small', 'medium', 'large', 'fill' ),
5353
);
5454

@@ -230,8 +230,8 @@ public function register( $origin, $kind, $name, $actions, $script_module = null
230230
* _doing_it_wrong().
231231
*
232232
* A value DataViews does not support is otherwise silent: an action
233-
* whose `context` is not `list` or `single` shows on no screen. Such a
234-
* value is kept, like the field types the fields registry reports.
233+
* whose `context` is not `list` shows on no screen. Such a value is
234+
* kept, like the field types the fields registry reports.
235235
* `callback`, `RenderModal`, and `isEligible` are functions and
236236
* components, which only a script module can provide: a value set on
237237
* the server would be called on the client and fail, so it is removed.

‎tests/phpunit/tests/entity-actions.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ public function test_registering_an_action_with_invalid_values_is_reported() {
741741
array(
742742
'id' => 'archive',
743743
'label' => 'Archive',
744-
'context' => 'lists',
744+
'context' => 'single',
745745
'isEligible' => true,
746746
),
747747
array(
@@ -754,12 +754,12 @@ public function test_registering_an_action_with_invalid_values_is_reported() {
754754

755755
$this->assertSame( array( 'feature', 'archive', 'export' ), $registered, 'The actions are registered anyway.' );
756756
$actions = array_column( wp_get_registered_entity_actions( 'postType', 'page' ), null, 'id' );
757-
$this->assertSame( 'lists', $actions['archive']['context'], 'A value DataViews does not support is kept.' );
757+
$this->assertSame( 'single', $actions['archive']['context'], 'A value DataViews does not support is kept.' );
758758
$this->assertSame( 'huge', $actions['export']['modalSize'], 'A value DataViews does not support is kept.' );
759759
$this->assertArrayNotHasKey( 'isEligible', $actions['archive'], 'A property only a script module can provide is removed.' );
760760
$this->assertCount( 1, $reported );
761761
$this->assertStringContainsString( 'postType "page"', $reported[0], 'The notice names the entity.' );
762-
$this->assertStringContainsString( ': archive (context is not one of list and single.)', $reported[0], 'The notice names the action and its value DataViews does not support.' );
762+
$this->assertStringContainsString( ': archive (context is not one of list.)', $reported[0], 'The notice names the action and its value DataViews does not support.' );
763763
$this->assertStringContainsString( 'archive (isEligible can only come from a script module', $reported[0], 'The notice names the property that is removed.' );
764764
$this->assertStringContainsString( 'export (modalSize is not one of small, medium, large, and fill.)', $reported[0], 'The notice names every value DataViews does not support.' );
765765
$this->assertStringNotContainsString( 'feature', $reported[0], 'The other actions of the call are not reported.' );

0 commit comments

Comments
 (0)