Make WordPress Core


Ignore:
Timestamp:
10/11/2015 10:43:59 PM (6 years ago)
Author:
jeremyfelt
Message:

MS: Adjust _network_option() parameter order, $network_id is first.

This better aligns with expectations and matches the structure used by _blog_option(). The _site_option() functions remain as an appropriate method for working with the current network.

See #28290.

File:
1 edited

Legend:

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

    r34931 r35024  
    10001000 */
    10011001function get_site_option( $option, $default = false, $deprecated = true ) {
    1002     return get_network_option( $option, $default );
     1002    return get_network_option( null, $option, $default );
    10031003}
    10041004
     
    10181018 */
    10191019function add_site_option( $option, $value ) {
    1020     return add_network_option( $option, $value );
     1020    return add_network_option( null, $option, $value );
    10211021}
    10221022
     
    10331033 */
    10341034function delete_site_option( $option ) {
    1035     return delete_network_option( $option );
     1035    return delete_network_option( null, $option );
    10361036}
    10371037
     
    10491049 */
    10501050function update_site_option( $option, $value ) {
    1051     return update_network_option( $option, $value );
     1051    return update_network_option( null, $option, $value );
    10521052}
    10531053
     
    10621062 * @global object $current_site
    10631063 *
     1064 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
    10641065 * @param string   $option     Name of option to retrieve. Expected to not be SQL-escaped.
    10651066 * @param mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
    1066  * @param int|bool $network_id Optional. ID of the network. Defaults to current network ID.
    10671067 * @return mixed Value set for the option.
    10681068 */
    1069 function get_network_option( $option, $default = false, $network_id = false ) {
     1069function get_network_option( $network_id, $option, $default = false ) {
    10701070    global $wpdb, $current_site;
    10711071
     
    11751175 * @global object $current_site
    11761176 *
    1177  * @param  string   $option     Name of option to add. Expected to not be SQL-escaped.
    1178  * @param  mixed    $value      Option value, can be anything. Expected to not be SQL-escaped.
    1179  * @param  int|bool $network_id Optional. ID of the network. Defaults to current network ID.
     1177 * @param int    $network_id ID of the network. Can be null to default to the current network ID.
     1178 * @param string $option     Name of option to add. Expected to not be SQL-escaped.
     1179 * @param mixed  $value      Option value, can be anything. Expected to not be SQL-escaped.
    11801180 * @return bool False if option was not added and true if option was added.
    11811181 */
    1182 function add_network_option( $option, $value, $network_id = false ) {
     1182function add_network_option( $network_id, $option, $value ) {
    11831183    global $wpdb, $current_site;
    11841184
     
    12161216        $notoptions = wp_cache_get( $notoptions_key, 'site-options' );
    12171217        if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) {
    1218             if ( false !== get_network_option( $option, false, $network_id ) ) {
     1218            if ( false !== get_network_option( $network_id, $option, false ) ) {
    12191219                return false;
    12201220            }
     
    12811281 * @global object $current_site
    12821282 *
    1283  * @param  string   $option     Name of option to remove. Expected to not be SQL-escaped.
    1284  * @param  int|bool $network_id Optional. ID of the network. Defaults to current network ID.
     1283 * @param int    $network_id ID of the network. Can be null to default to the current network ID.
     1284 * @param string $option     Name of option to remove. Expected to not be SQL-escaped.
    12851285 * @return bool True, if succeed. False, if failure.
    12861286 */
    1287 function delete_network_option( $option, $network_id = false ) {
     1287function delete_network_option( $network_id, $option ) {
    12881288    global $wpdb, $current_site;
    12891289
     
    13591359 * @global object $current_site
    13601360 *
     1361 * @param int      $network_id ID of the network. Can be null to default to the current network ID.
    13611362 * @param string   $option     Name of option. Expected to not be SQL-escaped.
    13621363 * @param mixed    $value      Option value. Expected to not be SQL-escaped.
    1363  * @param int|bool $network_id Optional. ID of the network. Defaults to current network ID.
    13641364 * @return bool False if value was not updated and true if value was updated.
    13651365 */
    1366 function update_network_option( $option, $value, $network_id = false ) {
     1366function update_network_option( $network_id, $option, $value ) {
    13671367    global $wpdb, $current_site;
    13681368
     
    13761376    wp_protect_special_option( $option );
    13771377
    1378     $old_value = get_network_option( $option, false, $network_id );
     1378    $old_value = get_network_option( $network_id, $option, false );
    13791379
    13801380    /**
     
    13981398
    13991399    if ( false === $old_value ) {
    1400         return add_network_option( $option, $value, $network_id );
     1400        return add_network_option( $network_id, $option, $value );
    14011401    }
    14021402
Note: See TracChangeset for help on using the changeset viewer.