WordPress.org

Make WordPress Core

Changeset 41013


Ignore:
Timestamp:
07/06/2017 03:11:32 PM (4 years ago)
Author:
DrewAPicture
Message:

Options: Pass $default as a new parameter to the pre_option_{$option} and pre_site_option_{$option} filters.

This change standardizes some language in the parameter descriptions between the two hook docs in an effort to reduce confusion between the $pre_option pseudo-parameters and the new $default ones. $pre_option is the truthy value used to short-circuit the get_*option() call, $default is the value passed to the get_*option() returned in the event that 1) a short circuit isn't performed, 2) the option doesn't exist.

Props sc0ttkclark.
Fixes #41254.

File:
1 edited

Legend:

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

    r40603 r41013  
    4545     * @since 1.5.0
    4646     * @since 4.4.0 The `$option` parameter was added.
    47      *
    48      * @param bool|mixed $pre_option Value to return instead of the option value.
    49      *                               Default false to skip it.
     47     * @since 4.9.0 The `$default` parameter was added.
     48     *
     49     *
     50     * @param bool|mixed $pre_option The value to return instead of the option value. This differs from
     51     *                               `$default`, which is used as the fallback value in the event the option
     52     *                               doesn't exist elsewhere in get_option(). Default false (to skip past the
     53     *                               short-circuit).
    5054     * @param string     $option     Option name.
    51      */
    52     $pre = apply_filters( "pre_option_{$option}", false, $option );
     55     * @param mixed      $default    The fallback value to return if the option does not exist.
     56     *                               Default is false.
     57     */
     58    $pre = apply_filters( "pre_option_{$option}", false, $option, $default );
     59
    5360    if ( false !== $pre )
    5461        return $pre;
     
    11171124     * @since 4.4.0 The `$option` parameter was added.
    11181125     * @since 4.7.0 The `$network_id` parameter was added.
    1119      *
    1120      * @param mixed  $pre_option The default value to return if the option does not exist.
     1126     * @since 4.9.0 The `$default` parameter was added.
     1127     *
     1128     * @param mixed  $pre_option The value to return instead of the option value. This differs from
     1129     *                           `$default`, which is used as the fallback value in the event the
     1130     *                           option doesn't exist elsewhere in get_network_option(). Default
     1131     *                           is false (to skip past the short-circuit).
    11211132     * @param string $option     Option name.
    11221133     * @param int    $network_id ID of the network.
    1123      */
    1124     $pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id );
     1134     * @param mixed  $default    The fallback value to return if the option does not exist.
     1135     *                           Default is false.
     1136     */
     1137    $pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id, $default );
    11251138
    11261139    if ( false !== $pre ) {
Note: See TracChangeset for help on using the changeset viewer.