Skip to content

Commit ae2ebb8

Browse files
Coding Standards: Consistently use do_action_deprecated() and apply_filters_deprecated() for deprecated hooks.
Props jrf. See #48255. git-svn-id: https://develop.svn.wordpress.org/trunk@46684 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 243d1a2 commit ae2ebb8

14 files changed

Lines changed: 57 additions & 37 deletions

src/wp-admin/edit-tag-form.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
* @param WP_Term $tag Current category term object.
2323
*/
24-
do_action( 'edit_category_form_pre', $tag );
24+
do_action_deprecated( 'edit_category_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' );
2525
} elseif ( 'link_category' == $taxonomy ) {
2626
/**
2727
* Fires before the Edit Link Category form.
@@ -31,7 +31,7 @@
3131
*
3232
* @param WP_Term $tag Current link category term object.
3333
*/
34-
do_action( 'edit_link_category_form_pre', $tag );
34+
do_action_deprecated( 'edit_link_category_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' );
3535
} else {
3636
/**
3737
* Fires before the Edit Tag form.
@@ -41,7 +41,7 @@
4141
*
4242
* @param WP_Term $tag Current tag term object.
4343
*/
44-
do_action( 'edit_tag_form_pre', $tag );
44+
do_action_deprecated( 'edit_tag_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' );
4545
}
4646

4747
/**
@@ -201,7 +201,7 @@
201201
*
202202
* @param WP_Term $tag Current category term object.
203203
*/
204-
do_action( 'edit_category_form_fields', $tag );
204+
do_action_deprecated( 'edit_category_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' );
205205
} elseif ( 'link_category' == $taxonomy ) {
206206
/**
207207
* Fires after the Edit Link Category form fields are displayed.
@@ -211,7 +211,7 @@
211211
*
212212
* @param WP_Term $tag Current link category term object.
213213
*/
214-
do_action( 'edit_link_category_form_fields', $tag );
214+
do_action_deprecated( 'edit_link_category_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' );
215215
} else {
216216
/**
217217
* Fires after the Edit Tag form fields are displayed.
@@ -221,7 +221,7 @@
221221
*
222222
* @param WP_Term $tag Current tag term object.
223223
*/
224-
do_action( 'edit_tag_form_fields', $tag );
224+
do_action_deprecated( 'edit_tag_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' );
225225
}
226226
/**
227227
* Fires after the Edit Term form fields are displayed.
@@ -241,10 +241,10 @@
241241
// Back compat hooks
242242
if ( 'category' == $taxonomy ) {
243243
/** This action is documented in wp-admin/edit-tags.php */
244-
do_action( 'edit_category_form', $tag );
244+
do_action_deprecated( 'edit_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' );
245245
} elseif ( 'link_category' == $taxonomy ) {
246246
/** This action is documented in wp-admin/edit-tags.php */
247-
do_action( 'edit_link_category_form', $tag );
247+
do_action_deprecated( 'edit_link_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' );
248248
} else {
249249
/**
250250
* Fires at the end of the Edit Term form.
@@ -254,7 +254,7 @@
254254
*
255255
* @param WP_Term $tag Current taxonomy term object.
256256
*/
257-
do_action( 'edit_tag_form', $tag );
257+
do_action_deprecated( 'edit_tag_form', array( $tag ), '3.0.0', '{$taxonomy}_edit_form' );
258258
}
259259
/**
260260
* Fires at the end of the Edit Term form for all taxonomies.

src/wp-admin/edit-tags.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@
378378
*
379379
* @param object $arg Optional arguments cast to an object.
380380
*/
381-
do_action( 'add_category_form_pre', (object) array( 'parent' => 0 ) );
381+
do_action_deprecated( 'add_category_form_pre', array( (object) array( 'parent' => 0 ) ), '3.0.0', '{$taxonomy}_pre_add_form' );
382382
} elseif ( 'link_category' == $taxonomy ) {
383383
/**
384384
* Fires before the link category form.
@@ -388,7 +388,7 @@
388388
*
389389
* @param object $arg Optional arguments cast to an object.
390390
*/
391-
do_action( 'add_link_category_form_pre', (object) array( 'parent' => 0 ) );
391+
do_action_deprecated( 'add_link_category_form_pre', array( (object) array( 'parent' => 0 ) ), '3.0.0', '{$taxonomy}_pre_add_form' );
392392
} else {
393393
/**
394394
* Fires before the Add Tag form.
@@ -398,7 +398,7 @@
398398
*
399399
* @param string $taxonomy The taxonomy slug.
400400
*/
401-
do_action( 'add_tag_form_pre', $taxonomy );
401+
do_action_deprecated( 'add_tag_form_pre', array( $taxonomy ), '3.0.0', '{$taxonomy}_pre_add_form' );
402402
}
403403

404404
/**
@@ -534,7 +534,7 @@
534534
*
535535
* @param object $arg Optional arguments cast to an object.
536536
*/
537-
do_action( 'edit_category_form', (object) array( 'parent' => 0 ) );
537+
do_action_deprecated( 'edit_category_form', array( (object) array( 'parent' => 0 ) ), '3.0.0', '{$taxonomy}_add_form' );
538538
} elseif ( 'link_category' == $taxonomy ) {
539539
/**
540540
* Fires at the end of the Edit Link form.
@@ -544,7 +544,7 @@
544544
*
545545
* @param object $arg Optional arguments cast to an object.
546546
*/
547-
do_action( 'edit_link_category_form', (object) array( 'parent' => 0 ) );
547+
do_action_deprecated( 'edit_link_category_form', array( (object) array( 'parent' => 0 ) ), '3.0.0', '{$taxonomy}_add_form' );
548548
} else {
549549
/**
550550
* Fires at the end of the Add Tag form.
@@ -554,7 +554,7 @@
554554
*
555555
* @param string $taxonomy The taxonomy slug.
556556
*/
557-
do_action( 'add_tag_form', $taxonomy );
557+
do_action_deprecated( 'add_tag_form', array( $taxonomy ), '3.0.0', '{$taxonomy}_add_form' );
558558
}
559559

560560
/**

src/wp-admin/includes/class-wp-screen.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,12 @@ public function render_screen_meta() {
796796
* @param array $old_compat_help Old contextual help.
797797
* @param WP_Screen $this Current WP_Screen instance.
798798
*/
799-
self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this );
799+
self::$_old_compat_help = apply_filters_deprecated(
800+
'contextual_help_list',
801+
array( self::$_old_compat_help, $this ),
802+
'3.3.0',
803+
'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
804+
);
800805

801806
$old_help = isset( self::$_old_compat_help[ $this->id ] ) ? self::$_old_compat_help[ $this->id ] : '';
802807

@@ -811,7 +816,12 @@ public function render_screen_meta() {
811816
* @param string $screen_id Screen ID.
812817
* @param WP_Screen $this Current WP_Screen instance.
813818
*/
814-
$old_help = apply_filters( 'contextual_help', $old_help, $this->id, $this );
819+
$old_help = apply_filters_deprecated(
820+
'contextual_help',
821+
array( $old_help, $this->id, $this ),
822+
'3.3.0',
823+
'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
824+
);
815825

816826
// Default help only if there is no old-style block of text and no new-style help tabs.
817827
if ( empty( $old_help ) && ! $this->get_help_tabs() ) {
@@ -825,7 +835,12 @@ public function render_screen_meta() {
825835
*
826836
* @param string $old_help_default Default contextual help text.
827837
*/
828-
$default_help = apply_filters( 'default_contextual_help', '' );
838+
$default_help = apply_filters_deprecated(
839+
'default_contextual_help',
840+
array( '' ),
841+
'3.3.0',
842+
'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
843+
);
829844
if ( $default_help ) {
830845
$old_help = '<p>' . $default_help . '</p>';
831846
}

src/wp-admin/includes/class-wp-terms-list-table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function prepare_items() {
9797
*
9898
* @param int $tags_per_page Number of tags to be displayed. Default 20.
9999
*/
100-
$tags_per_page = apply_filters( 'tagsperpage', $tags_per_page );
100+
$tags_per_page = apply_filters_deprecated( 'tagsperpage', array( $tags_per_page ), '2.8.0', 'edit_tags_per_page' );
101101
} elseif ( 'category' === $this->screen->taxonomy ) {
102102
/**
103103
* Filters the number of terms displayed per page for the Categories list table.
@@ -508,7 +508,7 @@ protected function handle_row_actions( $tag, $column_name, $primary ) {
508508
* 'Edit', 'Quick Edit', 'Delete', and 'View'.
509509
* @param WP_Term $tag Term object.
510510
*/
511-
$actions = apply_filters( 'tag_row_actions', $actions, $tag );
511+
$actions = apply_filters_deprecated( 'tag_row_actions', array( $actions, $tag ), '3.0.0', '{$taxonomy}_row_actions' );
512512

513513
/**
514514
* Filters the action links displayed for each term in the terms list table.

src/wp-admin/includes/image-edit.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function wp_stream_image( $image, $mime_type, $attachment_id ) {
292292
* @param resource $image Image resource to be streamed.
293293
* @param int $attachment_id The attachment post ID.
294294
*/
295-
$image = apply_filters( 'image_save_pre', $image, $attachment_id );
295+
$image = apply_filters_deprecated( 'image_save_pre', array( $image, $attachment_id ), '3.5.0', 'image_editor_save_pre' );
296296

297297
switch ( $mime_type ) {
298298
case 'image/jpeg':
@@ -353,7 +353,7 @@ function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
353353
_deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( '%1$s needs to be a %2$s object.' ), '$image', 'WP_Image_Editor' ) );
354354

355355
/** This filter is documented in wp-admin/includes/image-edit.php */
356-
$image = apply_filters( 'image_save_pre', $image, $post_id );
356+
$image = apply_filters_deprecated( 'image_save_pre', array( $image, $post_id ), '3.5.0', 'image_editor_save_pre' );;
357357

358358
/**
359359
* Filters whether to skip saving the image file.
@@ -370,7 +370,7 @@ function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
370370
* @param string $mime_type Image mime type.
371371
* @param int $post_id Post ID.
372372
*/
373-
$saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id );
373+
$saved = apply_filters_deprecated( 'wp_save_image_file', array( null, $filename, $image, $mime_type, $post_id ), '3.5.0', 'wp_save_image_editor_file' );
374374

375375
if ( null !== $saved ) {
376376
return $saved;
@@ -570,7 +570,7 @@ function image_edit_apply_changes( $image, $changes ) {
570570
* @param resource $image GD image resource.
571571
* @param array $changes Array of change operations.
572572
*/
573-
$image = apply_filters( 'image_edit_before_change', $image, $changes );
573+
$image = apply_filters_deprecated( 'image_edit_before_change', array( $image, $changes ), '3.5.0', 'wp_image_editor_before_change' );
574574
}
575575

576576
foreach ( $changes as $operation ) {

src/wp-admin/includes/media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ function media_buttons( $editor_id = 'content' ) {
654654
*
655655
* @param string $string Media buttons context. Default empty.
656656
*/
657-
$legacy_filter = apply_filters( 'media_buttons_context', '' );
657+
$legacy_filter = apply_filters_deprecated( 'media_buttons_context', array( '' ), '3.5.0', 'media_buttons' );
658658

659659
if ( $legacy_filter ) {
660660
// #WP22559. Close <a> if a plugin started by closing <a> to open their own <a> tag.

src/wp-admin/includes/meta-boxes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ function register_and_do_post_meta_boxes( $post ) {
15081508
*
15091509
* @param WP_Post $post Post object.
15101510
*/
1511-
do_action( 'dbx_post_advanced', $post );
1511+
do_action_deprecated( 'dbx_post_advanced', array( $post ), '3.7.0', 'add_meta_boxes' );
15121512

15131513
// Allow the Discussion meta box to show up if the post type supports comments,
15141514
// or if comments or pings are open.

src/wp-includes/class-wp-rewrite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ public function rewrite_rules() {
14111411
*
14121412
* @param string[] $rules Array of rewrite rules generated for tags, keyed by their regex pattern.
14131413
*/
1414-
$rules = apply_filters( 'tag_rewrite_rules', $rules );
1414+
$rules = apply_filters_deprecated( 'tag_rewrite_rules', array( $rules ), '3.1.0', 'post_tag_rewrite_rules' );
14151415
}
14161416

14171417
$this->extra_rules_top = array_merge( $this->extra_rules_top, $rules );
@@ -1560,7 +1560,7 @@ public function mod_rewrite_rules() {
15601560
*
15611561
* @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
15621562
*/
1563-
return apply_filters( 'rewrite_rules', $rules );
1563+
return apply_filters_deprecated( 'rewrite_rules', array( $rules ), '1.5.0', 'mod_rewrite_rules' );
15641564
}
15651565

15661566
/**

src/wp-includes/class-wp-xmlrpc-server.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ public function login( $username, $password ) {
235235
* Respect old get_option() filters left for back-compat when the 'enable_xmlrpc'
236236
* option was deprecated in 3.5.0. Use the 'xmlrpc_enabled' hook instead.
237237
*/
238-
$enabled = apply_filters( 'pre_option_enable_xmlrpc', false );
238+
$enabled = apply_filters_deprecated( 'pre_option_enable_xmlrpc', array( false ), '3.5.0', 'xmlrpc_enabled' );
239239
if ( false === $enabled ) {
240-
$enabled = apply_filters( 'option_enable_xmlrpc', true );
240+
$enabled = apply_filters_deprecated( 'option_enable_xmlrpc', array( true ), '3.5.0', 'xmlrpc_enabled' );
241241
}
242242

243243
/**

src/wp-includes/class-wp.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,12 @@ public function build_query_string() {
546546
*
547547
* @param string $query_string The query string to modify.
548548
*/
549-
$this->query_string = apply_filters( 'query_string', $this->query_string );
549+
$this->query_string = apply_filters_deprecated(
550+
'query_string',
551+
array( $this->query_string ),
552+
'2.1.0',
553+
'query_vars, request'
554+
);
550555
parse_str( $this->query_string, $this->query_vars );
551556
}
552557
}

0 commit comments

Comments
 (0)