Skip to content

Commit d240152

Browse files
committed
Prefix all filters with wp_
1 parent 58acb2e commit d240152

File tree

10 files changed

+82
-82
lines changed

10 files changed

+82
-82
lines changed

src/wp-includes/abilities-api.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* Registers a new ability using Abilities API.
1616
*
17-
* Note: Should only be used on the {@see 'abilities_api_init'} hook.
17+
* Note: Should only be used on the {@see 'wp_abilities_api_init'} hook.
1818
*
1919
* @since 6.9.0
2020
*
@@ -63,7 +63,7 @@
6363
* } $args
6464
*/
6565
function wp_register_ability( string $name, array $args ): ?WP_Ability {
66-
if ( ! did_action( 'abilities_api_init' ) ) {
66+
if ( ! did_action( 'wp_abilities_api_init' ) ) {
6767
_doing_it_wrong(
6868
__FUNCTION__,
6969
sprintf(

src/wp-includes/abilities-api/class-wp-abilities-category-registry.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ final class WP_Abilities_Category_Registry {
6262
* } $args
6363
*/
6464
public function register( string $slug, array $args ): ?WP_Ability_Category {
65-
if ( ! doing_action( 'abilities_api_categories_init' ) ) {
65+
if ( ! doing_action( 'wp_abilities_api_categories_init' ) ) {
6666
_doing_it_wrong(
6767
__METHOD__,
6868
sprintf(
6969
/* translators: 1: abilities_api_categories_init, 2: category slug. */
7070
__( 'Categories must be registered during the %1$s action. The category %2$s was not registered.' ),
71-
'<code>abilities_api_categories_init</code>',
71+
'<code>wp_abilities_api_categories_init</code>',
7272
'<code>' . esc_html( $slug ) . '</code>'
7373
),
7474
'6.9.0'
@@ -109,7 +109,7 @@ public function register( string $slug, array $args ): ?WP_Ability_Category {
109109
* }
110110
* @param string $slug The slug of the category.
111111
*/
112-
$args = apply_filters( 'register_ability_category_args', $args, $slug );
112+
$args = apply_filters( 'wp_register_ability_category_args', $args, $slug );
113113

114114
try {
115115
// WP_Ability_Category::prepare_properties() will throw an exception if the properties are invalid.
@@ -230,7 +230,7 @@ public static function get_instance(): self {
230230
*
231231
* @param WP_Abilities_Category_Registry $instance Categories registry object.
232232
*/
233-
do_action( 'abilities_api_categories_init', self::$instance );
233+
do_action( 'wp_abilities_api_categories_init', self::$instance );
234234
}
235235

236236
return self::$instance;

src/wp-includes/abilities-api/class-wp-abilities-registry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function register( string $name, array $args ): ?WP_Ability {
134134
* }
135135
* @param string $name The name of the ability, with its namespace.
136136
*/
137-
$args = apply_filters( 'register_ability_args', $args, $name );
137+
$args = apply_filters( 'wp_register_ability_args', $args, $name );
138138

139139
// Validate category exists if provided (will be validated as required in WP_Ability).
140140
if ( isset( $args['category'] ) ) {
@@ -292,7 +292,7 @@ public static function get_instance(): self {
292292
*
293293
* @param WP_Abilities_Registry $instance Abilities registry object.
294294
*/
295-
do_action( 'abilities_api_init', self::$instance );
295+
do_action( 'wp_abilities_api_init', self::$instance );
296296
}
297297

298298
return self::$instance;

src/wp-includes/abilities-api/class-wp-ability.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public function execute( $input = null ) {
586586
* @param string $ability_name The name of the ability.
587587
* @param mixed $input The input data for the ability.
588588
*/
589-
do_action( 'before_execute_ability', $this->name, $input );
589+
do_action( 'wp_before_execute_ability', $this->name, $input );
590590

591591
$result = $this->do_execute( $input );
592592
if ( is_wp_error( $result ) ) {
@@ -607,7 +607,7 @@ public function execute( $input = null ) {
607607
* @param mixed $input The input data for the ability.
608608
* @param mixed $result The result of the ability execution.
609609
*/
610-
do_action( 'after_execute_ability', $this->name, $input, $result );
610+
do_action( 'wp_after_execute_ability', $this->name, $input, $result );
611611

612612
return $result;
613613
}

tests/phpunit/tests/abilities-api/wpAbilitiesRegistry.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ public function set_up(): void {
2727

2828
$this->registry = new WP_Abilities_Registry();
2929

30-
remove_all_filters( 'register_ability_args' );
30+
remove_all_filters( 'wp_register_ability_args' );
3131

3232
// Register category during the hook.
3333
add_action(
34-
'abilities_api_categories_init',
34+
'wp_abilities_api_categories_init',
3535
function () {
3636
if ( ! WP_Abilities_Category_Registry::get_instance()->is_registered( 'math' ) ) {
3737
wp_register_ability_category(
@@ -46,7 +46,7 @@ function () {
4646
);
4747

4848
// Fire the hook to allow category registration.
49-
do_action( 'abilities_api_categories_init' );
49+
do_action( 'wp_abilities_api_categories_init' );
5050

5151
self::$test_ability_args = array(
5252
'label' => 'Add numbers',
@@ -91,7 +91,7 @@ function () {
9191
public function tear_down(): void {
9292
$this->registry = null;
9393

94-
remove_all_filters( 'register_ability_args' );
94+
remove_all_filters( 'wp_register_ability_args' );
9595

9696
// Clean up registered categories.
9797
$category_registry = WP_Abilities_Category_Registry::get_instance();
@@ -551,7 +551,7 @@ public function test_register_ability_args_filter_modifies_args() {
551551

552552
// Define the filter.
553553
add_filter(
554-
'register_ability_args',
554+
'wp_register_ability_args',
555555
static function ( $args ) use ( &$was_filter_callback_fired ) {
556556
$args['label'] = 'Modified label';
557557
$original_execute_callback = $args['execute_callback'];
@@ -593,7 +593,7 @@ static function ( $args ) use ( &$was_filter_callback_fired ) {
593593
public function test_register_ability_args_filter_blocks_registration() {
594594
// Define the filter.
595595
add_filter(
596-
'register_ability_args',
596+
'wp_register_ability_args',
597597
static function ( $args ) {
598598
// Remove the label to make the args invalid.
599599
unset( $args['label'] );
@@ -619,7 +619,7 @@ static function ( $args ) {
619619
public function test_register_ability_args_filter_blocks_invalid_ability_class() {
620620
// Define the filter.
621621
add_filter(
622-
'register_ability_args',
622+
'wp_register_ability_args',
623623
static function ( $args ) {
624624
// Set an invalid ability class.
625625
$args['ability_class'] = 'NonExistentClass';
@@ -641,7 +641,7 @@ static function ( $args ) {
641641
*/
642642
public function test_register_ability_args_filter_only_applies_to_specific_ability() {
643643
add_filter(
644-
'register_ability_args',
644+
'wp_register_ability_args',
645645
static function ( $args, $name ) {
646646
if ( self::$test_ability_name !== $name ) {
647647
// Do not modify args for other abilities.

tests/phpunit/tests/abilities-api/wpAbility.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function set_up(): void {
2020

2121
// Register category during the hook.
2222
add_action(
23-
'abilities_api_categories_init',
23+
'wp_abilities_api_categories_init',
2424
function () {
2525
if ( ! WP_Abilities_Category_Registry::get_instance()->is_registered( 'math' ) ) {
2626
wp_register_ability_category(
@@ -35,7 +35,7 @@ function () {
3535
);
3636

3737
// Fire the hook to allow category registration.
38-
do_action( 'abilities_api_categories_init' );
38+
do_action( 'wp_abilities_api_categories_init' );
3939

4040
self::$test_ability_properties = array(
4141
'label' => 'Calculator',
@@ -533,12 +533,12 @@ public function test_before_execute_ability_action() {
533533
$action_input = $input;
534534
};
535535

536-
add_action( 'before_execute_ability', $callback, 10, 2 );
536+
add_action( 'wp_before_execute_ability', $callback, 10, 2 );
537537

538538
$ability = new WP_Ability( self::$test_ability_name, $args );
539539
$result = $ability->execute( 5 );
540540

541-
remove_action( 'before_execute_ability', $callback );
541+
remove_action( 'wp_before_execute_ability', $callback );
542542

543543
$this->assertSame( self::$test_ability_name, $action_ability_name, 'Action should receive correct ability name' );
544544
$this->assertSame( 5, $action_input, 'Action should receive correct input' );
@@ -568,12 +568,12 @@ public function test_before_execute_ability_action_no_input() {
568568
$action_input = $input;
569569
};
570570

571-
add_action( 'before_execute_ability', $callback, 10, 2 );
571+
add_action( 'wp_before_execute_ability', $callback, 10, 2 );
572572

573573
$ability = new WP_Ability( self::$test_ability_name, $args );
574574
$result = $ability->execute();
575575

576-
remove_action( 'before_execute_ability', $callback );
576+
remove_action( 'wp_before_execute_ability', $callback );
577577

578578
$this->assertSame( self::$test_ability_name, $action_ability_name, 'Action should receive correct ability name' );
579579
$this->assertNull( $action_input, 'Action should receive null input when no input provided' );
@@ -610,12 +610,12 @@ public function test_after_execute_ability_action() {
610610
$action_result = $result;
611611
};
612612

613-
add_action( 'after_execute_ability', $callback, 10, 3 );
613+
add_action( 'wp_after_execute_ability', $callback, 10, 3 );
614614

615615
$ability = new WP_Ability( self::$test_ability_name, $args );
616616
$result = $ability->execute( 7 );
617617

618-
remove_action( 'after_execute_ability', $callback );
618+
remove_action( 'wp_after_execute_ability', $callback );
619619

620620
$this->assertSame( self::$test_ability_name, $action_ability_name, 'Action should receive correct ability name' );
621621
$this->assertSame( 7, $action_input, 'Action should receive correct input' );
@@ -649,12 +649,12 @@ public function test_after_execute_ability_action_no_input() {
649649
$action_result = $result;
650650
};
651651

652-
add_action( 'after_execute_ability', $callback, 10, 3 );
652+
add_action( 'wp_after_execute_ability', $callback, 10, 3 );
653653

654654
$ability = new WP_Ability( self::$test_ability_name, $args );
655655
$result = $ability->execute();
656656

657-
remove_action( 'after_execute_ability', $callback );
657+
remove_action( 'wp_after_execute_ability', $callback );
658658

659659
$this->assertSame( self::$test_ability_name, $action_ability_name, 'Action should receive correct ability name' );
660660
$this->assertNull( $action_input, 'Action should receive null input when no input provided' );
@@ -688,14 +688,14 @@ public function test_actions_not_fired_on_permission_failure() {
688688
$after_action_fired = true;
689689
};
690690

691-
add_action( 'before_execute_ability', $before_callback );
692-
add_action( 'after_execute_ability', $after_callback );
691+
add_action( 'wp_before_execute_ability', $before_callback );
692+
add_action( 'wp_after_execute_ability', $after_callback );
693693

694694
$ability = new WP_Ability( self::$test_ability_name, $args );
695695
$result = $ability->execute();
696696

697-
remove_action( 'before_execute_ability', $before_callback );
698-
remove_action( 'after_execute_ability', $after_callback );
697+
remove_action( 'wp_before_execute_ability', $before_callback );
698+
remove_action( 'wp_after_execute_ability', $after_callback );
699699

700700
$this->assertFalse( $before_action_fired, 'before_execute_ability action should not be fired on permission failure' );
701701
$this->assertFalse( $after_action_fired, 'after_execute_ability action should not be fired on permission failure' );
@@ -728,14 +728,14 @@ public function test_after_action_not_fired_on_execution_error() {
728728
$after_action_fired = true;
729729
};
730730

731-
add_action( 'before_execute_ability', $before_callback );
732-
add_action( 'after_execute_ability', $after_callback );
731+
add_action( 'wp_before_execute_ability', $before_callback );
732+
add_action( 'wp_after_execute_ability', $after_callback );
733733

734734
$ability = new WP_Ability( self::$test_ability_name, $args );
735735
$result = $ability->execute();
736736

737-
remove_action( 'before_execute_ability', $before_callback );
738-
remove_action( 'after_execute_ability', $after_callback );
737+
remove_action( 'wp_before_execute_ability', $before_callback );
738+
remove_action( 'wp_after_execute_ability', $after_callback );
739739

740740
$this->assertTrue( $before_action_fired, 'before_execute_ability action should be fired even if execution fails' );
741741
$this->assertFalse( $after_action_fired, 'after_execute_ability action should not be fired when execution returns WP_Error' );
@@ -773,14 +773,14 @@ public function test_after_action_not_fired_on_output_validation_error() {
773773
$after_action_fired = true;
774774
};
775775

776-
add_action( 'before_execute_ability', $before_callback );
777-
add_action( 'after_execute_ability', $after_callback );
776+
add_action( 'wp_before_execute_ability', $before_callback );
777+
add_action( 'wp_after_execute_ability', $after_callback );
778778

779779
$ability = new WP_Ability( self::$test_ability_name, $args );
780780
$result = $ability->execute();
781781

782-
remove_action( 'before_execute_ability', $before_callback );
783-
remove_action( 'after_execute_ability', $after_callback );
782+
remove_action( 'wp_before_execute_ability', $before_callback );
783+
remove_action( 'wp_after_execute_ability', $after_callback );
784784

785785
$this->assertTrue( $before_action_fired, 'before_execute_ability action should be fired even if output validation fails' );
786786
$this->assertFalse( $after_action_fired, 'after_execute_ability action should not be fired when output validation fails' );

tests/phpunit/tests/abilities-api/wpAbilityCategory.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ private function register_category_during_hook( string $slug, array $args ): ?WP
113113
$result = wp_register_ability_category( $slug, $args );
114114
};
115115

116-
add_action( 'abilities_api_categories_init', $callback );
117-
do_action( 'abilities_api_categories_init', WP_Abilities_Category_Registry::get_instance() );
118-
remove_action( 'abilities_api_categories_init', $callback );
116+
add_action( 'wp_abilities_api_categories_init', $callback );
117+
do_action( 'wp_abilities_api_categories_init', WP_Abilities_Category_Registry::get_instance() );
118+
remove_action( 'wp_abilities_api_categories_init', $callback );
119119

120120
return $result;
121121
}
@@ -230,10 +230,10 @@ public function test_register_category_before_init_hook(): void {
230230
global $wp_actions;
231231

232232
// Store original count.
233-
$original_count = isset( $wp_actions['abilities_api_categories_init'] ) ? $wp_actions['abilities_api_categories_init'] : 0;
233+
$original_count = isset( $wp_actions['wp_abilities_api_categories_init'] ) ? $wp_actions['wp_abilities_api_categories_init'] : 0;
234234

235235
// Reset to simulate hook not fired.
236-
unset( $wp_actions['abilities_api_categories_init'] );
236+
unset( $wp_actions['wp_abilities_api_categories_init'] );
237237

238238
$result = wp_register_ability_category(
239239
'test-math',
@@ -245,11 +245,11 @@ public function test_register_category_before_init_hook(): void {
245245

246246
// Restore original count.
247247
if ( $original_count > 0 ) {
248-
$wp_actions['abilities_api_categories_init'] = $original_count;
248+
$wp_actions['wp_abilities_api_categories_init'] = $original_count;
249249
}
250250

251251
$this->assertNull( $result );
252-
$this->assertDoingItWrongTriggered( 'WP_Abilities_Category_Registry::register', 'abilities_api_categories_init' );
252+
$this->assertDoingItWrongTriggered( 'WP_Abilities_Category_Registry::register', 'wp_abilities_api_categories_init' );
253253
}
254254

255255
/**
@@ -279,9 +279,9 @@ public function test_register_duplicate_category(): void {
279279
);
280280
};
281281

282-
add_action( 'abilities_api_categories_init', $callback );
283-
do_action( 'abilities_api_categories_init', WP_Abilities_Category_Registry::get_instance() );
284-
remove_action( 'abilities_api_categories_init', $callback );
282+
add_action( 'wp_abilities_api_categories_init', $callback );
283+
do_action( 'wp_abilities_api_categories_init', WP_Abilities_Category_Registry::get_instance() );
284+
remove_action( 'wp_abilities_api_categories_init', $callback );
285285

286286
$this->assertNull( $result );
287287
$this->assertDoingItWrongTriggered( 'WP_Abilities_Category_Registry::register', 'already registered' );
@@ -412,7 +412,7 @@ public function test_category_is_registered(): void {
412412
* @expectedIncorrectUsage WP_Abilities_Registry::register
413413
*/
414414
public function test_ability_requires_existing_category(): void {
415-
do_action( 'abilities_api_init' );
415+
do_action( 'wp_abilities_api_init' );
416416

417417
// Ensure category doesn't exist - test should fail if it does.
418418
$this->assertFalse(
@@ -454,10 +454,10 @@ public function test_ability_with_valid_category(): void {
454454
);
455455
};
456456

457-
add_action( 'abilities_api_categories_init', $category_callback );
458-
do_action( 'abilities_api_categories_init', WP_Abilities_Category_Registry::get_instance() );
459-
remove_action( 'abilities_api_categories_init', $category_callback );
460-
do_action( 'abilities_api_init' );
457+
add_action( 'wp_abilities_api_categories_init', $category_callback );
458+
do_action( 'wp_abilities_api_categories_init', WP_Abilities_Category_Registry::get_instance() );
459+
remove_action( 'wp_abilities_api_categories_init', $category_callback );
460+
do_action( 'wp_abilities_api_init' );
461461

462462
$result = wp_register_ability(
463463
'test/calculator',
@@ -674,7 +674,7 @@ public function test_category_constructor_empty_description(): void {
674674
*/
675675
public function test_register_category_args_filter(): void {
676676
add_filter(
677-
'register_ability_category_args',
677+
'wp_register_ability_category_args',
678678
static function ( $args, $slug ) {
679679
if ( 'test-filtered' === $slug ) {
680680
$args['label'] = 'Filtered Label';

0 commit comments

Comments
 (0)