Plugin Directory

Changeset 786163


Ignore:
Timestamp:
10/11/2013 12:13:56 AM (12 years ago)
Author:
ddean
Message:

Update and fixes from github

File:
1 edited

Legend:

Unmodified
Added
Removed
  • networks-for-wordpress/trunk/networks-functions.php

    r745301 r786163  
    319319        }
    320320
     321        $domain = untrailingslashit($domain);
    321322        $update = array('domain'    => $domain);
     323
    322324        if($path != '') {
     325            $path = trim( $path, '/' );
     326            $path = trailingslashit( '/' . $path );
    323327            $update['path'] = $path;
    324328        }
     
    353357       
    354358        $path = (($path != '') ? $path : $site->path );
    355         $fullPath = $domain . $path;
    356         $oldPath = $site->domain . $site->path;
     359        $fullPath = untrailingslashit( $domain . $path );
     360        $oldPath = untrailingslashit( $site->domain . $site->path );
    357361
    358362        /** also updated any associated blogs */
     
    361365        if($blogs) {
    362366            foreach($blogs as $blog) {
    363                 $domain = str_replace($site->domain,$domain,$blog->domain);
    364                
     367                $update = array();
     368
     369                if($site->domain !== $domain) {
     370                    $update['domain'] = str_replace($site->domain,$domain,$blog->domain);
     371                }
     372
     373                if($site->path !== $path) {
     374                    $search = sprintf('|^%s|', preg_quote($site->path, '|'));
     375                    $update['path'] = preg_replace($search, $path, $blog->path, 1);
     376                }
     377
     378                if(empty($update))
     379                    continue;
     380
     381                $blog_id = (int) $blog->blog_id;
     382                switch_to_blog($blog_id);
     383
    365384                $wpdb->update(
    366385                    $wpdb->blogs,
    367                     array(  'domain'    => $domain,
    368                             'path'      => $path
    369                         ),
    370                     array(  'blog_id'   => (int)$blog->blog_id  )
     386                    $update,
     387                    array(  'blog_id'   => $blog_id )
    371388                );
    372 
    373                 /** fix options table values */
    374                 $optionTable = $wpdb->get_blog_prefix( $blog->blog_id ) . 'options';
    375389
    376390                foreach($url_dependent_blog_options as $option_name) {
    377391                    // TODO: pop upload_url_path off list if ms_files_rewriting is disabled
    378                     $option_value = $wpdb->get_row("SELECT * FROM $optionTable WHERE option_name='$option_name'");
     392                    $option_value = $wpdb->get_row("SELECT * FROM {$wpdb->options} WHERE option_name='$option_name'");
    379393                    if($option_value) {
    380394                        $newValue = str_replace($oldPath,$fullPath,$option_value->option_value);
    381                         update_blog_option($blog->blog_id,$option_name,$newValue);
    382 //                      $wpdb->query("UPDATE $optionTable SET option_value='$newValue' WHERE option_name='$option_name'");
     395                        update_option($option_name,$newValue);
    383396                    }
    384397                }
     398                restore_current_blog();
     399
     400                refresh_blog_details($blog_id);
    385401            }
    386402        }
Note: See TracChangeset for help on using the changeset viewer.