prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d LIMIT 1", $option, $network_id ); $index = 'meta_value'; } else { $query = $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ); $index = 'option_value'; } $result = $wpdb->query( $query ); if ( false === $result ) { // Something went wrong with the DB. return false; } if ( empty( $wpdb->last_result[0] ) || empty( $wpdb->last_result[0]->$index ) ) { // The value has not been set yet, return the default value. return null; } $value = $wpdb->last_result[0]->$index; $options = @unserialize( $value ); if ( is_array( $options ) ) { return $options; } // Seems that we have some bad data. // TODO: Attempt data restoration. return null; } }