[wp-trac] [WordPress Trac] #44341: Replace _deprecated_function( 'add_filter' ) with apply_filters_deprecated()

WordPress Trac noreply at wordpress.org
Sat Jun 9 11:47:14 UTC 2018


#44341: Replace  _deprecated_function( 'add_filter' ) with
apply_filters_deprecated()
--------------------------+----------------------------------------
 Reporter:  birgire       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Editor        |    Version:  4.3
 Severity:  normal        |   Keywords:  needs-patch good-first-bug
  Focuses:                |
--------------------------+----------------------------------------
 Since 4.6 we have the function
 [https://developer.wordpress.org/reference/functions/apply_filters_deprecated/
 apply_filters_deprecated()] for deprecated filters:

 >When a filter hook is deprecated, the {{{apply_filters()}}} call is
 replaced with >{{{apply_filters_deprecated()}}}, which triggers a
 deprecation notice and then fires the >original filter hook.

 In
 [https://github.com/WordPress/WordPress/blob/6fd8080e7ee7599b36d4528f72a8ced612130b8c
 /wp-includes/class-wp-editor.php#L287 wp-includes/class-wp-editor.php] we
 have:

 {{{
 // Back-compat for the `htmledit_pre` and `richedit_pre` filters
 if ( 'html' === $default_editor && has_filter( 'htmledit_pre' ) ) {
         // TODO: needs _deprecated_filter(), use _deprecated_function() as
 substitute for now
         _deprecated_function( 'add_filter( htmledit_pre )', '4.3.0',
 'add_filter( format_for_editor )' );
         $content = apply_filters( 'htmledit_pre', $content );
 } elseif ( 'tinymce' === $default_editor && has_filter( 'richedit_pre' ) )
 {
         _deprecated_function( 'add_filter( richedit_pre )', '4.3.0',
 'add_filter( format_for_editor )' );
         $content = apply_filters( 'richedit_pre', $content );
 }

 }}}

 I think we can replace it with:

 {{{
 // Back-compat for the `htmledit_pre` and `richedit_pre` filters
 if ( 'html' === $default_editor && has_filter( 'htmledit_pre' ) ) {
         $content = apply_filters_deprecated( 'htmledit_pre', array(
 $content ), '4.3.0', 'format_for_editor' );
 } elseif ( 'tinymce' === $default_editor && has_filter( 'richedit_pre' ) )
 {
         $content = apply_filters_deprecated( 'richedit_pre', array(
 $content ), '4.3.0', 'format_for_editor' );
 }

 }}}

 I also wonder if the missing inline documentation should be added, for
 those deprecated filters.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44341>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list