Make WordPress Core

Ticket #16964: ms-functions.diff

File ms-functions.diff, 1.2 KB (added by philipwalton, 14 years ago)
  • wp-includes/ms-functions.php

     
    10881088        return $blog_id;
    10891089}
    10901090
     1091/**
     1092 * Deletes the option from all options tables
     1093 *
     1094 * @uses delete_option()
     1095 *
     1096 * @param mixed $options a string or array of strings which correspond to the option names to be deleted
     1097 */
     1098function network_delete_option( $options ) {
     1099       
     1100        // convert an option passed as a single string to an array
     1101        if ( is_string( $options ) ) {
     1102                $options = array( $options );
     1103        }
     1104       
     1105        if ( is_multisite() ) {
     1106                global $wpdb;
     1107                $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
     1108                if ( $blogs ) {
     1109                       
     1110                        // loop through each subsite ( blog )
     1111                        foreach( $blogs as $blog ) {
     1112                                switch_to_blog( $blog['blog_id'] );
     1113                               
     1114                                foreach( $options as $option ) {
     1115                                        delete_option( $option );       
     1116                                }
     1117                        }
     1118                }
     1119        } else {
     1120               
     1121                // loop through each subsite ( blog )
     1122                foreach( $options as $option ) {
     1123                        delete_option( $option );       
     1124                }
     1125        }
     1126}
     1127
    10911128/**
    10921129 * Notifies the network admin that a new site has been activated.
    10931130 *