Ticket #607: various_tweak.patch

File various_tweak.patch, 6.1 kB (added by momo360modena, 4 months ago)
  • .

    old new  
    233233        $safe_key = $wpdb->escape( $key ); 
    234234 
    235235        if ( $value == get_site_option( $key ) ) 
    236                 return
     236                return false
    237237 
    238238        $exists = $wpdb->get_row("SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = '$safe_key' AND site_id = '{$wpdb->siteid}'"); 
    239239 
     
    245245 
    246246        $wpdb->query( "UPDATE $wpdb->sitemeta SET meta_value = '" . $wpdb->escape( $value ) . "' WHERE site_id='{$wpdb->siteid}' AND meta_key = '$safe_key'" ); 
    247247        wp_cache_delete( $wpdb->siteid . $key, 'site-options' ); 
     248        return true; 
    248249} 
    249250 
    250251/* 
     
    311312 
    312313function update_blog_option( $id, $key, $value, $refresh = true ) { 
    313314        switch_to_blog($id); 
    314         $opt = update_option( $key, $value ); 
     315        update_option( $key, $value ); 
    315316        restore_current_blog(); 
    316         if( $refresh == true ) 
     317         
     318        if( $refresh == true ) { 
    317319                refresh_blog_details( $id ); 
    318         $opt = $id."-".$key."-blog_option"; 
    319         wp_cache_set($opt, $value, 'site-options'); 
     320        } 
     321        wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options'); 
    320322} 
    321323 
    322324function switch_to_blog( $new_blog ) { 
     
    430432        if ( !$user ) 
    431433                return false; 
    432434 
    433         $blogs = array(); 
    434  
    435         $i = 0; 
     435        $blogs = $match = array(); 
    436436        foreach ( (array) $user as $key => $value ) { 
    437437                if ( strstr( $key, '_capabilities') && strstr( $key, 'wp_') ) { 
    438438                        preg_match('/' . $wpdb->base_prefix . '(\d+)_capabilities/', $key, $match); 
     
    536536} 
    537537 
    538538function get_most_active_blogs( $num = 10, $display = true ) { 
    539         global $wpdb; 
    540539        $most_active = get_site_option( "most_active" ); 
    541540        $update = false; 
    542541        if( is_array( $most_active ) ) { 
     
    596595                unset( $blogs ); 
    597596                $blogs = $wpdb->get_results( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = '$wpdb->siteid' AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", ARRAY_A ); 
    598597 
    599                 foreach ( (array) $blogs as $key => $details ) { 
     598                foreach ( (array) $blogs as $details ) { 
    600599                        $blog_list[ $details['blog_id'] ] = $details; 
    601600                        $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT count(*) FROM " . $wpdb->base_prefix . $details['blog_id'] . "_posts WHERE post_status='publish' AND post_type='post'" ); 
    602601                } 
     
    663662        do_action('add_user_to_blog', $user_id, $role, $blog_id); 
    664663        wp_cache_delete( $user_id, 'users' ); 
    665664        restore_current_blog(); 
     665        return true; 
    666666} 
    667667 
    668668function remove_user_from_blog($user_id, $blog_id = '') { 
    669         global $wpdb; 
    670  
    671669        switch_to_blog($blog_id); 
    672  
    673670        $user_id = (int) $user_id; 
    674  
    675671        do_action('remove_user_from_blog', $user_id, $blog_id); 
    676672 
    677673        // If being removed from the primary blog, set a new primary if the user is assigned 
     
    705701} 
    706702 
    707703function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) { 
    708         global $wpdb; 
    709  
    710704        $domain       = addslashes( $domain ); 
    711705        $weblog_title = addslashes( $weblog_title ); 
    712706 
     
    844838} 
    845839 
    846840function wpmu_validate_user_signup($user_name, $user_email) { 
    847         global $wpdb, $current_site
     841        global $wpdb
    848842 
    849843        $errors = new WP_Error(); 
    850844 
     
    854848        if ( empty( $user_name ) ) 
    855849                $errors->add('user_name', __("Please enter a username")); 
    856850 
     851        $maybe = array(); 
    857852        preg_match( "/[a-z0-9]+/", $user_name, $maybe ); 
    858853 
    859854        if( $user_name != $maybe[0] ) { 
     
    880875                $errors->add('user_name', __("Sorry, usernames may not contain the character '_'!")); 
    881876 
    882877        // all numeric? 
     878        $match = array(); 
    883879        preg_match( '/[0-9]*/', $user_name, $match ); 
    884880        if ( $match[0] == $user_name ) 
    885881                $errors->add('user_name', __("Sorry, usernames must have letters too!")); 
     
    957953        if ( empty( $blog_id ) ) 
    958954            $errors->add('blog_id', __("Please enter a blog name")); 
    959955 
     956        $maybe = array(); 
    960957        preg_match( "/[a-z0-9]+/", $blog_id, $maybe ); 
    961958        if( $blog_id != $maybe[0] ) { 
    962959            $errors->add('blog_id', __("Only lowercase letters and numbers allowed")); 
     
    972969                $errors->add('blog_id', __("Sorry, blog names may not contain the character '_'!")); 
    973970 
    974971        // all numeric? 
     972        $match = array(); 
    975973        preg_match( '/[0-9]*/', $blog_id, $match ); 
    976974        if ( $match[0] == $blog_id ) 
    977975                $errors->add('blog_id', __("Sorry, blog names must have letters too!")); 
     
    10981096function wpmu_activate_signup($key) { 
    10991097        global $wpdb; 
    11001098 
    1101         $result = array(); 
    11021099        $signup = $wpdb->get_row("SELECT * FROM $wpdb->signups WHERE activation_key = '$key'"); 
    11031100 
    11041101        if ( empty($signup) ) 
     
    12561253function newuser_notify_siteadmin( $user_id ) { 
    12571254        global $current_site; 
    12581255        if( get_site_option( 'registrationnotification' ) != 'yes' ) 
    1259                 return
     1256                return false
    12601257                 
    12611258        $email = get_site_option( 'admin_email' ); 
    12621259        if( is_email($email) == false ) 
     
    12711268         
    12721269        $msg = apply_filters( 'newuser_notify_siteadmin', $msg ); 
    12731270        wp_mail( $email, sprintf(__("New User Registration: %s"), $user->user_login), $msg ); 
     1271        return true; 
    12741272} 
    12751273add_action( "wpmu_new_user", "newuser_notify_siteadmin" ); 
    12761274 
     
    15681566} 
    15691567 
    15701568function upload_is_user_over_quota( $echo = true ) { 
    1571         global $wpdb; 
    1572          
    15731569        // Default space allowed is 10 MB  
    15741570        $spaceAllowed = get_space_allowed(); 
    15751571        if(empty($spaceAllowed) || !is_numeric($spaceAllowed)) $spaceAllowed = 10; 
     
    16881684        } 
    16891685 
    16901686        function plugin_content() { 
    1691                 global $wpdb, $current_blog, $current_site; 
     1687                global $current_blog, $current_site; 
    16921688                $this->delete_blog_hash = get_settings('delete_blog_hash'); 
    16931689                echo '<div class="wrap"><h2>' . __('Delete Blog') . '</h2>'; 
    16941690                if( $_POST['action'] == "deleteblog" && $_POST['confirmdelete'] == '1' ) { 
     
    18691865XMLRPC getUsersBlogs() for a multiblog environment 
    18701866http://trac.mu.wordpress.org/attachment/ticket/551/xmlrpc-mu.php 
    18711867*/ 
    1872  
    18731868function wpmu_blogger_getUsersBlogs($args) { 
    18741869        $site_details = get_blog_details( 1, true ); 
    18751870        $domain = $site_details->domain; 
     
    18861881        if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) { 
    18871882                return $blogs; 
    18881883        } else { 
    1889                 foreach ( (array) $blogs as $blog_num => $blog ) { 
     1884                foreach ( (array) $blogs as $blog ) { 
    18901885                        if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) ) 
    18911886                                return array($blog); 
    18921887                }