[wp-trac] [WordPress Trac] #55584: Settings API autoload hook

WordPress Trac noreply at wordpress.org
Wed Apr 27 15:13:54 UTC 2022


#55584: Settings API autoload hook
--------------------------------+------------------------------
 Reporter:  hir88en             |       Owner:  (none)
     Type:  enhancement         |      Status:  new
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Options, Meta APIs  |     Version:
 Severity:  normal              |  Resolution:
 Keywords:                      |     Focuses:  performance
--------------------------------+------------------------------

Comment (by SergeyBiryukov):

 An example by @apermo from #55584:
 {{{
 Index: public/wp-includes/option.php
 IDEA additional info:
 Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
 <+>UTF-8
 ===================================================================
 diff --git a/public/wp-includes/option.php b/public/wp-includes/option.php
 --- a/public/wp-includes/option.php
 +++ b/public/wp-includes/option.php     (date 1651054674847)
 @@ -461,7 +461,16 @@

         /** This filter is documented in wp-includes/option.php */
         if ( apply_filters( "default_option_{$option}", false, $option,
 false ) === $old_value ) {
 -               // Default setting for new options is 'yes'.
 +               /**
 +                * Filter autoload for an option.
 +                *
 +                * @since tbd
 +                *
 +                * @param string|null $autoload Current value of autoload,
 can be "yes", "no" or null.
 +                */
 +               $autoload = apply_filters( "autoload_option_{$option}",
 $autoload );
 +
 +               // Default setting for options is 'yes'.
                 if ( null === $autoload ) {
                         $autoload = 'yes';
                 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55584#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list