Make WordPress Core

Ticket #35379: 35379.diff

File 35379.diff, 2.4 KB (added by codex-m, 9 years ago)

Patch

  • src/wp-includes/formatting.php

     
    36373637 *
    36383638 * @param string $option The name of the option.
    36393639 * @param string $value  The unsanitised value.
     3640 * @param string|boolean  $network_id     Optional.
     3641 *                                                        Used when sanitizing a network option on a specific network ID.
     3642 *                                                        Otherwise if is set to boolean TRUE, it will use the current site network ID
     3643 *                                                        Defaults to FALSE
     3644 *
    36403645 * @return string Sanitized value.
    36413646 */
    3642 function sanitize_option( $option, $value ) {
     3647function sanitize_option( $option, $value,$network_id=false) {
    36433648        global $wpdb;
    36443649
    36453650        $original_value = $value;
    36463651        $error = '';
    3647 
     3652       
     3653        $network_called=false;
     3654        if (( is_multisite() ) && ($network_id)) {
     3655                global $current_site;
     3656                if ((isset($current_site->id)) && (true === $network_id )) {                   
     3657                        $network_id = $current_site->id;       
     3658                }
     3659               
     3660                $network_id = (int) $network_id;               
     3661                if ($network_id > 0) {
     3662                        $network_called=true;
     3663                }
     3664        }
     3665       
    36483666        switch ( $option ) {
    36493667                case 'admin_email' :
    36503668                case 'new_admin_email' :
     
    37803798                                $allowed[] = WPLANG;
    37813799                        }
    37823800                        if ( ! in_array( $value, $allowed ) && ! empty( $value ) ) {
    3783                                 $value = get_option( $option );
     3801                                if ($network_called) {
     3802                                        $value = get_network_option( $network_id, $option, false );
     3803                                } else {
     3804                                        $value = get_option( $option );
     3805                                }
     3806                               
    37843807                        }
    37853808                        break;
    37863809
     
    38603883        }
    38613884
    38623885        if ( ! empty( $error ) ) {
    3863                 $value = get_option( $option );
     3886                if ($network_called) {
     3887                        $value = get_network_option( $network_id, $option, false );
     3888                } else {
     3889                        $value = get_option( $option );
     3890                }
    38643891                if ( function_exists( 'add_settings_error' ) ) {
    38653892                        add_settings_error( $option, "invalid_{$option}", $error );
    38663893                }
  • src/wp-includes/option.php

     
    14331433        if ( ! is_multisite() ) {
    14341434                $result = update_option( $option, $value );
    14351435        } else {
    1436                 $value = sanitize_option( $option, $value );
     1436                $value = sanitize_option( $option, $value, $network_id);
    14371437
    14381438                $serialized_value = maybe_serialize( $value );
    14391439                $result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $serialized_value ), array( 'site_id' => $network_id, 'meta_key' => $option ) );