Make WordPress Core

Changeset 33738


Ignore:
Timestamp:
08/25/2015 09:41:53 PM (11 years ago)
Author:
wonderboymusic
Message:

Pass option name to option and transient filters with dynamic names.

Props Viper007Bond, SergeyBiryukov, MikeHansenMe.
Fixes #28402.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r33110 r33738  
    4444         * @param bool|mixed $pre_option Value to return instead of the option value.
    4545         *                               Default false to skip it.
    46          */
    47         $pre = apply_filters( 'pre_option_' . $option, false );
     46         * @param string     $option     Option name.
     47         */
     48        $pre = apply_filters( 'pre_option_' . $option, false, $option );
    4849        if ( false !== $pre )
    4950                return $pre;
    … …  
    6364                         * @since 3.4.0
    6465                         *
    65                          * @param mixed $default The default value to return if the option does not exist
    66                          *                       in the database.
     66                         * @param mixed  $default The default value to return if the option does not exist
     67                         *                        in the database.
     68                         * @param string $option  Option name.
    6769                         */
    68                         return apply_filters( 'default_option_' . $option, $default );
     70                        return apply_filters( 'default_option_' . $option, $default, $option );
    6971                }
    7072
    … …  
    9193
    9294                                        /** This filter is documented in wp-includes/option.php */
    93                                         return apply_filters( 'default_option_' . $option, $default );
     95                                        return apply_filters( 'default_option_' . $option, $default, $option );
    9496                                }
    9597                        }
    … …  
    103105                } else {
    104106                        /** This filter is documented in wp-includes/option.php */
    105                         return apply_filters( 'default_option_' . $option, $default );
     107                        return apply_filters( 'default_option_' . $option, $default, $option );
    106108                }
    107109        }
    … …  
    122124         * @since 3.0.0
    123125         *
    124          * @param mixed $value Value of the option. If stored serialized, it will be
    125          *                     unserialized prior to being returned.
    126          */
    127         return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );
     126         * @param mixed  $value  Value of the option. If stored serialized, it will be
     127         *                       unserialized prior to being returned.
     128         * @param string $option Option name.
     129         */
     130        return apply_filters( 'option_' . $option, maybe_unserialize( $value ), $option );
    128131}
    129132
    … …  
    264267         * @since 2.6.0
    265268         *
    266          * @param mixed $value     The new, unserialized option value.
    267          * @param mixed $old_value The old option value.
    268          */
    269         $value = apply_filters( 'pre_update_option_' . $option, $value, $old_value );
     269         * @param mixed  $value     The new, unserialized option value.
     270         * @param mixed  $old_value The old option value.
     271         * @param string $option    Option name.
     272         */
     273        $value = apply_filters( 'pre_update_option_' . $option, $value, $old_value, $option );
    270274
    271275        /**
    … …  
    342346         * @since 2.0.1
    343347         *
    344          * @param mixed $old_value The old option value.
    345          * @param mixed $value     The new option value.
    346          */
    347         do_action( "update_option_{$option}", $old_value, $value );
     348         * @param mixed  $old_value The old option value.
     349         * @param mixed  $value     The new option value.
     350         * @param string $option    Option name.
     351         */
     352        do_action( "update_option_{$option}", $old_value, $value, $option );
    348353
    349354        /**
    … …  
    596601function get_transient( $transient ) {
    597602
    598         /**
     603        /**
    599604         * Filter the value of an existing transient.
    600605         *
    … …  
    606611         * @since 2.8.0
    607612         *
    608          * @param mixed $pre_transient The default value to return if the transient does not exist.
    609          *                             Any value other than false will short-circuit the retrieval
    610          *                             of the transient, and return the returned value.
    611          */
    612         $pre = apply_filters( 'pre_transient_' . $transient, false );
     613         * @param mixed  $pre_transient The default value to return if the transient does not exist.
     614         *                              Any value other than false will short-circuit the retrieval
     615         *                              of the transient, and return the returned value.
     616         * @param string $transient     Transient name.
     617         */
     618        $pre = apply_filters( 'pre_transient_' . $transient, false, $transient );
    613619        if ( false !== $pre )
    614620                return $pre;
    … …  
    643649         * @since 2.8.0
    644650         *
    645          * @param mixed $value Value of transient.
    646          */
    647         return apply_filters( 'transient_' . $transient, $value );
     651         * @param mixed  $value     Value of transient.
     652         * @param string $transient Transient name.
     653         */
     654        return apply_filters( 'transient_' . $transient, $value, $transient );
    648655}
    649656
    … …  
    675682         * @since 4.2.0 Added `$expiration` parameter.
    676683         *
    677          * @param mixed $value      New value of transient.
    678          * @param int   $expiration Time until expiration in seconds.
    679          */
    680         $value = apply_filters( 'pre_set_transient_' . $transient, $value, $expiration );
     684         * @param mixed  $value      New value of transient.
     685         * @param int    $expiration Time until expiration in seconds.
     686         * @param string $transient  Transient name.
     687         */
     688        $value = apply_filters( 'pre_set_transient_' . $transient, $value, $expiration, $transient );
    681689
    682690        if ( wp_using_ext_object_cache() ) {
    … …  
    984992         * @since 3.0.0
    985993         *
    986          * @param mixed $pre_option The default value to return if the option does not exist.
    987          */
    988         $pre = apply_filters( 'pre_site_option_' . $option, false );
     994         * @param mixed  $pre_option The default value to return if the option does not exist.
     995         * @param string $option     Option name.
     996         */
     997        $pre = apply_filters( 'pre_site_option_' . $option, false, $option );
    989998
    990999        if ( false !== $pre )
    … …  
    10041013                 * @since 3.4.0
    10051014                 *
    1006                  * @param mixed $default The value to return if the site option does not exist
    1007                  *                       in the database.
     1015                 * @param mixed  $default The value to return if the site option does not exist
     1016                 *                        in the database.
     1017                 * @param string $option  Option name.
    10081018                 */
    1009                 return apply_filters( 'default_site_option_' . $option, $default );
     1019                return apply_filters( 'default_site_option_' . $option, $default, $option );
    10101020        }
    10111021
    … …  
    10131023
    10141024                /** This filter is documented in wp-includes/option.php */
    1015                 $default = apply_filters( 'default_site_option_' . $option, $default );
     1025                $default = apply_filters( 'default_site_option_' . $option, $default, $option );
    10161026                $value = get_option($option, $default);
    10171027        } else {
    … …  
    10361046
    10371047                                /** This filter is documented in wp-includes/option.php */
    1038                                 $value = apply_filters( 'default_site_option_' . $option, $default );
     1048                                $value = apply_filters( 'default_site_option_' . $option, $default, $option );
    10391049                        }
    10401050                }
    … …  
    10491059         * @since 3.0.0
    10501060         *
    1051          * @param mixed $value Value of site option.
    1052          */
    1053         return apply_filters( 'site_option_' . $option, $value );
     1061         * @param mixed  $value  Value of site option.
     1062         * @param string $option Option name.
     1063         */
     1064        return apply_filters( 'site_option_' . $option, $value, $option );
    10541065}
    10551066
    … …  
    10821093         * @since 3.0.0
    10831094         *
    1084          * @param mixed $value Value of site option.
    1085          */
    1086         $value = apply_filters( 'pre_add_site_option_' . $option, $value );
     1095         * @param mixed  $value  Value of site option.
     1096         * @param string $option Option name.
     1097         */
     1098        $value = apply_filters( 'pre_add_site_option_' . $option, $value, $option );
    10871099
    10881100        $notoptions_key = "{$wpdb->siteid}:notoptions";
    … …  
    11701182         *
    11711183         * @since 3.0.0
    1172          */
    1173         do_action( 'pre_delete_site_option_' . $option );
     1184         *
     1185         * @param string $option Option name.
     1186         */
     1187        do_action( 'pre_delete_site_option_' . $option, $option );
    11741188
    11751189        if ( !is_multisite() ) {
    … …  
    12411255         * @since 3.0.0
    12421256         *
    1243          * @param mixed $value     New value of site option.
    1244          * @param mixed $old_value Old value of site option.
    1245          */
    1246         $value = apply_filters( 'pre_update_site_option_' . $option, $value, $old_value );
     1257         * @param mixed  $value     New value of site option.
     1258         * @param mixed  $old_value Old value of site option.
     1259         * @param string $option    Option name.
     1260         */
     1261        $value = apply_filters( 'pre_update_site_option_' . $option, $value, $old_value, $option );
    12471262
    12481263        if ( $value === $old_value )
    … …  
    13751390         * @since 2.9.0
    13761391         *
    1377          * @param mixed $pre_site_transient The default value to return if the site transient does not exist.
    1378          *                                  Any value other than false will short-circuit the retrieval
    1379          *                                  of the transient, and return the returned value.
    1380          */
    1381         $pre = apply_filters( 'pre_site_transient_' . $transient, false );
     1392         * @param mixed  $pre_site_transient The default value to return if the site transient does not exist.
     1393         *                                   Any value other than false will short-circuit the retrieval
     1394         *                                   of the transient, and return the returned value.
     1395         * @param string $transient          Transient name.
     1396         */
     1397        $pre = apply_filters( 'pre_site_transient_' . $transient, false, $transient );
    13821398
    13831399        if ( false !== $pre )
    … …  
    14111427         * @since 2.9.0
    14121428         *
    1413          * @param mixed $value Value of site transient.
    1414          */
    1415         return apply_filters( 'site_transient_' . $transient, $value );
     1429         * @param mixed  $value     Value of site transient.
     1430         * @param string $transient Transient name.
     1431         */
     1432        return apply_filters( 'site_transient_' . $transient, $value, $transient );
    14161433}
    14171434
    … …  
    14411458         * @since 3.0.0
    14421459         *
    1443          * @param mixed $value Value of site transient.
    1444          */
    1445         $value = apply_filters( 'pre_set_site_transient_' . $transient, $value );
     1460         * @param mixed  $value     Value of site transient.
     1461         * @param string $transient Transient name.
     1462         */
     1463        $value = apply_filters( 'pre_set_site_transient_' . $transient, $value, $transient );
    14461464
    14471465        $expiration = (int) $expiration;
    … …  
    14711489                 * @since 3.0.0
    14721490                 *
    1473                  * @param mixed $value      Site transient value.
    1474                  * @param int   $expiration Time until expiration in seconds. Default 0.
     1491                 * @param mixed  $value      Site transient value.
     1492                 * @param int    $expiration Time until expiration in seconds. Default 0.
     1493                 * @param string $transient  Transient name.
    14751494                 */
    1476                 do_action( 'set_site_transient_' . $transient, $value, $expiration );
     1495                do_action( 'set_site_transient_' . $transient, $value, $expiration, $transient );
    14771496
    14781497                /**
Note: See TracChangeset for help on using the changeset viewer.