Make WordPress Core

Changeset 48193


Ignore:
Timestamp:
06/27/2020 04:54:29 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Docs: Synchronize some documentation for functions in wp-includes/option.php.

See #49572.

File:
1 edited

Legend:

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

    r48185 r48193  
    4141     * The dynamic portion of the hook name, `$option`, refers to the option name.
    4242     *
    43      * Returning a truthy value from the filter will short-circuit retrieving
    44      * the option value, returning the passed value instead.
     43     * Returning a truthy value from the filter will effectively short-circuit retrieval
     44     * and return the passed value instead.
    4545     *
    4646     * @since 1.5.0
     
    4848     * @since 4.9.0 The `$default` parameter was added.
    4949     *
    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).
    54      * @param string     $option     Option name.
    55      * @param mixed      $default    The fallback value to return if the option does not exist.
    56      *                               Default is false.
     50     * @param mixed  $pre_option The value to return instead of the option value. This differs
     51     *                           from `$default`, which is used as the fallback value in the event
     52     *                           the option doesn't exist elsewhere in get_option().
     53     *                           Default false (to skip past the short-circuit).
     54     * @param string $option     Option name.
     55     * @param mixed  $default    The fallback value to return if the option does not exist.
     56     *                           Default false.
    5757     */
    5858    $pre = apply_filters( "pre_option_{$option}", false, $option, $default );
     
    7272        // Prevent non-existent options from triggering multiple queries.
    7373        $notoptions = wp_cache_get( 'notoptions', 'options' );
     74
    7475        if ( isset( $notoptions[ $option ] ) ) {
    7576            /**
     
    108109                        $notoptions = array();
    109110                    }
     111
    110112                    $notoptions[ $option ] = true;
    111113                    wp_cache_set( 'notoptions', $notoptions, 'options' );
     
    120122        $row      = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
    121123        $wpdb->suppress_errors( $suppress );
     124
    122125        if ( is_object( $row ) ) {
    123126            $value = $row->option_value;
     
    229232             */
    230233            $alloptions = apply_filters( 'pre_cache_alloptions', $alloptions );
     234
    231235            wp_cache_add( 'alloptions', $alloptions, 'options' );
    232236        }
     
    394398
    395399    $notoptions = wp_cache_get( 'notoptions', 'options' );
     400
    396401    if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
    397402        unset( $notoptions[ $option ] );
     
    433438     */
    434439    do_action( 'updated_option', $option, $old_value, $value );
     440
    435441    return true;
    436442}
     
    483489    // We can check the 'notoptions' cache before we ask for a DB query.
    484490    $notoptions = wp_cache_get( 'notoptions', 'options' );
     491
    485492    if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
    486493        /** This filter is documented in wp-includes/option.php */
     
    520527    // This option exists now.
    521528    $notoptions = wp_cache_get( 'notoptions', 'options' ); // Yes, again... we need it to be fresh.
     529
    522530    if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
    523531        unset( $notoptions[ $option ] );
     
    547555     */
    548556    do_action( 'added_option', $option, $value );
     557
    549558    return true;
    550559}
     
    586595
    587596    $result = $wpdb->delete( $wpdb->options, array( 'option_name' => $option ) );
     597
    588598    if ( ! wp_installing() ) {
    589599        if ( 'yes' === $row->autoload ) {
     
    597607        }
    598608    }
     609
    599610    if ( $result ) {
    600611
     
    618629         */
    619630        do_action( 'deleted_option', $option );
     631
    620632        return true;
    621633    }
     634
    622635    return false;
    623636}
     
    650663        $option         = '_transient_' . $transient;
    651664        $result         = delete_option( $option );
     665
    652666        if ( $result ) {
    653667            delete_option( $option_timeout );
     
    684698
    685699    /**
    686      * Filters the value of an existing transient.
     700     * Filters the value of an existing transient before it is retrieved.
    687701     *
    688702     * The dynamic portion of the hook name, `$transient`, refers to the transient name.
    689703     *
    690704     * Returning a truthy value from the filter will effectively short-circuit retrieval
    691      * of the transient, returning the passed value instead.
     705     * and return the passed value instead.
    692706     *
    693707     * @since 2.8.0
     
    696710     * @param mixed  $pre_transient The default value to return if the transient does not exist.
    697711     *                              Any value other than false will short-circuit the retrieval
    698      *                              of the transient, and return the returned value.
     712     *                              of the transient, and return that value.
    699713     * @param string $transient     Transient name.
    700714     */
    701715    $pre = apply_filters( "pre_transient_{$transient}", false, $transient );
     716
    702717    if ( false !== $pre ) {
    703718        return $pre;
     
    793808        $transient_timeout = '_transient_timeout_' . $transient;
    794809        $transient_option  = '_transient_' . $transient;
     810
    795811        if ( false === get_option( $transient_option ) ) {
    796812            $autoload = 'yes';
     
    804820            // delete, then re-create transient rather than update.
    805821            $update = true;
     822
    806823            if ( $expiration ) {
    807824                if ( false === get_option( $transient_timeout ) ) {
     
    814831                }
    815832            }
     833
    816834            if ( $update ) {
    817835                $result = update_option( $transient_option, $value );
     
    849867        do_action( 'setted_transient', $transient, $value, $expiration );
    850868    }
     869
    851870    return $result;
    852871}
     
    12341253
    12351254    /**
    1236      * Filters an existing network option before it is retrieved.
     1255     * Filters the value of an existing network option before it is retrieved.
    12371256     *
    12381257     * The dynamic portion of the hook name, `$option`, refers to the option name.
     
    12471266     * @since 4.9.0 The `$default` parameter was added.
    12481267     *
    1249      * @param mixed  $pre_option The value to return instead of the option value. This differs from
    1250      *                           `$default`, which is used as the fallback value in the event the
    1251      *                           option doesn't exist elsewhere in get_network_option(). Default
    1252      *                           is false (to skip past the short-circuit).
     1268     * @param mixed  $pre_option The value to return instead of the option value. This differs
     1269     *                           from `$default`, which is used as the fallback value in the event
     1270     *                           the option doesn't exist elsewhere in get_network_option().
     1271     *                           Default false (to skip past the short-circuit).
    12531272     * @param string $option     Option name.
    12541273     * @param int    $network_id ID of the network.
    12551274     * @param mixed  $default    The fallback value to return if the option does not exist.
    1256      *                           Default is false.
     1275     *                           Default false.
    12571276     */
    12581277    $pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id, $default );
     
    13051324                    $notoptions = array();
    13061325                }
     1326
    13071327                $notoptions[ $option ] = true;
    13081328                wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
     
    13941414        // We can check the 'notoptions' cache before we ask for a DB query.
    13951415        $notoptions = wp_cache_get( $notoptions_key, 'site-options' );
     1416
    13961417        if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
    13971418            if ( false !== get_network_option( $network_id, $option, false ) ) {
     
    14201441        // This option exists now.
    14211442        $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // Yes, again... we need it to be fresh.
     1443
    14221444        if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
    14231445            unset( $notoptions[ $option ] );
     
    16221644    $notoptions_key = "$network_id:notoptions";
    16231645    $notoptions     = wp_cache_get( $notoptions_key, 'site-options' );
     1646
    16241647    if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
    16251648        unset( $notoptions[ $option ] );
     
    17121735        $option         = '_site_transient_' . $transient;
    17131736        $result         = delete_site_option( $option );
     1737
    17141738        if ( $result ) {
    17151739            delete_site_option( $option_timeout );
    17161740        }
    17171741    }
     1742
    17181743    if ( $result ) {
    17191744
     
    17471772
    17481773    /**
    1749      * Filters the value of an existing site transient.
     1774     * Filters the value of an existing site transient before it is retrieved.
    17501775     *
    17511776     * The dynamic portion of the hook name, `$transient`, refers to the transient name.
     
    17591784     * @param mixed  $pre_site_transient The default value to return if the site transient does not exist.
    17601785     *                                   Any value other than false will short-circuit the retrieval
    1761      *                                   of the transient, and return the returned value.
     1786     *                                   of the transient, and return that value.
    17621787     * @param string $transient          Transient name.
    17631788     */
     
    18541879        $transient_timeout = '_site_transient_timeout_' . $transient;
    18551880        $option            = '_site_transient_' . $transient;
     1881
    18561882        if ( false === get_site_option( $option ) ) {
    18571883            if ( $expiration ) {
     
    18661892        }
    18671893    }
     1894
    18681895    if ( $result ) {
    18691896
     
    18931920        do_action( 'setted_site_transient', $transient, $value, $expiration );
    18941921    }
     1922
    18951923    return $result;
    18961924}
     
    21442172     */
    21452173    $args = apply_filters( 'register_setting_args', $args, $defaults, $option_group, $option_name );
     2174
    21462175    $args = wp_parse_args( $args, $defaults );
    21472176
Note: See TracChangeset for help on using the changeset viewer.