WordPress.org

Plugin Directory

Changeset 1666855


Ignore:
Timestamp:
05/30/17 06:04:51 (6 months ago)
Author:
neversettle
Message:

replaced deprecated wp_get_sites() with get_sites()

Location:
ns-cloner-site-copier
Files:
123 added
5 edited

Legend:

Unmodified
Added
Removed
  • ns-cloner-site-copier/trunk/lib/ns-file-utils.php

    r1078714 r1666855  
    182182function ns_get_multisite_upload_paths( $args=array('limit'=>9999) ){ 
    183183    $upload_paths = array(); 
    184     $sites = function_exists('wp_get_sites')? wp_get_sites($args) : get_blog_list(0,'all'); 
    185     foreach( $sites as $site ){ 
    186         switch_to_blog($site['blog_id']); 
    187         $wp_upload_dir = wp_upload_dir(); 
    188         $upload_paths[ $site['blog_id'] ] = $wp_upload_dir['basedir']; 
    189         restore_current_blog(); 
     184    // update for WP 4.6+ and deprecated wp_get_sites() use get_sites() instead 
     185    if ( function_exists( 'get_sites' ) && class_exists( 'WP_Site_Query' ) ) { 
     186        $args['number'] = 9999; 
     187        $sites = get_sites(); 
     188        foreach ( $sites as $site ) { 
     189            switch_to_blog( $site->blog_id ); 
     190            $wp_upload_dir = wp_upload_dir(); 
     191            $upload_paths[ $site->blog_id ] = $wp_upload_dir['basedir']; 
     192            restore_current_blog(); 
     193        } 
     194    } else { 
     195    // handle WP 4.5 and earlier 
     196        $args['limit'] = 9999; 
     197        $sites = function_exists('wp_get_sites')? wp_get_sites($args) : get_blog_list(0,'all'); 
     198        foreach( $sites as $site ){ 
     199            switch_to_blog($site['blog_id']); 
     200            $wp_upload_dir = wp_upload_dir(); 
     201            $upload_paths[ $site['blog_id'] ] = $wp_upload_dir['basedir']; 
     202            restore_current_blog(); 
     203        } 
    190204    } 
    191205    return $upload_paths; 
  • ns-cloner-site-copier/trunk/lib/ns-utils.php

    r1558945 r1666855  
    7575        $data = unserialize($data); 
    7676    } 
    77     // run through replacements for strings, arrays - other types are unsupported to vaoid 
     77 
     78    // run through replacements for strings, arrays - other types are unsupported to avoid 
    7879    if( is_array($data) ){ 
    7980        foreach ($data as $key => $value) { 
     
    8182        } 
    8283    } 
     84     
     85    // run through replacements for strings, objects - other types are unsupported to avoid 
     86    elseif ( is_object($data) ) { 
     87        foreach ( $data as $key => $value) { 
     88            ns_recursive_search_replace( $data->$key, $search, $replace, $regex_search, $regex_replace, $case_sensitive ); 
     89        } 
     90    } 
    8391    elseif( is_string($data) ){ 
    8492        // simple string replacment - most of the time this is all that is needed 
    8593        $replace_func = $case_sensitive? 'str_replace' : 'str_ireplace'; 
     94        // not sure why ns_log_write does not work here... nothing happens 
     95        //ns_log_write( "DATA BEFORE replace: ".$data, $logfile ); 
    8696        $data = $replace_func( $search, $replace, $data, $string_replacements_made ); 
     97        // not sure why ns_log_write does not work here... nothing happens 
     98        //ns_log_write( "DATA  AFTER replace: ".$data, $logfile ); 
    8799        // advanced regex replacement - this will be skipped most of the time 
    88100        if( !empty($regex_search) && !empty($regex_replace) ){ 
  • ns-cloner-site-copier/trunk/ns-cloner.php

    r1593464 r1666855  
    55Description: The amazing NS Cloner creates a new site as an exact clone / duplicate / copy of an existing site with theme and all plugins and settings intact in just a few steps. Check out the add-ons for additional powerful features! 
    66Author: Never Settle 
    7 Version: 3.0.6.0 
     7Version: 3.0.7 
    88Network: true 
    99Text Domain: ns-cloner 
     
    1212*/ 
    1313/* 
    14 Copyright 2012-2016 Never Settle (email : dev@neversettle.it) 
     14Copyright 2012-2017 Never Settle (email : dev@neversettle.it) 
    1515 
    1616This program is free software; you can redistribute it and/or  
     
    7676     * Class Globals 
    7777     */ 
    78     var $version = '3.0.6.0'; 
     78    var $version = '3.0.6.1'; 
    7979    var $menu_slug = 'ns-cloner'; 
    8080    var $capability = 'manage_network_options'; 
  • ns-cloner-site-copier/trunk/readme.txt

    r1593464 r1666855  
    44Tags: automate, duplicate, copy, copy site, copier, clone, clone site, cloner, multisite, network, subdomain, subdirectory, subfolder, template 
    55Requires at least: 3.0.1 
    6 Tested up to: 4.7 
     6Tested up to: 4.7.5 
    77Stable tag: trunk 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
    1010 
    11 NS Cloner saves multisite admins and developers TONS of time by cloning existing sites to new sites in the same network within a few seconds. 
     11The NS Cloner saves multisite admins and developers TONS of time by cloning existing sites in a multisite network to a completely new site in a few seconds. 
    1212 
    1313== Description == 
    1414 
    15 This plugin ONLY works with WordPress Multisite, will NOT work in single site mode, and MUST be Network Activated. You will find it's menu in your network administration dashboard (wp-content/network) 
     15This plugin ONLY works with WordPress Multisite, will NOT work in single site mode, and MUST be Network Activated. You will find its menu in your network administration dashboard (wp-content/network) 
    1616 
    1717This is by far the easiest, fastest, and most user-friendly way you will ever create fully configured sites on your multisite networks. As with everything we do, Never Settle is fanatical about simplifying user tasks to an absolute bare and joyful minimum without sacrificing the complex functionality going on behind the scenes. You will not find another site cloner that comes anywhere close to how easy this is to use. 
     
    2929 
    3030= Standard Precautions and Notes = 
    31 * Unlike other similar tools, the NS Cloner supports cloning the main root site at ID=1! But please be especially careful with this feature. Multisite plugins like BuddyPress add tables at the main (wp_) level of the database. There are also several global tables that apply to the network and NOT to the core site. The Cloner automatically excludes these global tables out of the gate so that they don't get cloned to all your new sites which will have wp_ID_ as a prefix instead of wp_. But tables for other network level plugins that don't apply to the clone could still get coppied by the Cloner due to its automation and inability to be aware of the table structure of every plugin out there. Our Table Manager add-on is perfect for unique scenarios where you need total table-level cloning control. 
     31* Unlike other similar tools, the NS Cloner supports cloning the main root site at ID=1! But please be especially careful with this feature. Multisite plugins like BuddyPress add tables at the main (wp_) level of the database. There are also several global tables that apply to the network and NOT to the core site. The Cloner automatically excludes these global tables out of the gate so that they don't get cloned to all your new sites which will have wp_ID_ as a prefix instead of wp_. But tables for other network level plugins that don't apply to the clone could still get copied by the Cloner due to its automation and inability to be aware of the table structure of every plugin out there. Our Table Manager add-on is perfect for unique scenarios where you need total table-level cloning control. 
    3232* We always try to help, but we cannot promise support to users for this Free version, especially related to cloning the root site do to the potential complexities involved from environment to environment. 
    3333* We have used the NS Cloner on production systems for years without issues. That doesn't mean your scenario won't find some new condition that could cause you some headaches. Unlikely, but always possible. We recommend getting familiar with it on a test system before you deploy it to a critical network. 
     
    37371. Set up 1 or more "template" sites exactly the way you want your clones to start out 
    38381. Go to your Network Dashboard > NS Cloner 
    39 1. Select the "template" site you that want to clone, type the name of the new site, and put in it's Title 
     391. Select the "template" site you that want to clone, type the name of the new site, and put in its Title 
    40401. Clone Away! 
    4141 
     
    6868 
    69691. Log in to your WordPress network as a multisite super admin and go to /wp-admin/network 
    70 1. Use the Dashboard > Plugins > Add New tools to install NS Cloner from the WP.org repository or install by uploading the zip file 
     701. Use the Dashboard > Plugins > Add New tools to install NS Cloner from the WordPress.org repository or install by uploading the zip file 
    71711. Network Activate the NS Cloner through the 'Plugins' menu in WordPress 
    72721. Access the NS Cloner from its main menu on the Network Dashboard (/wp-admin/network) 
     
    8181 
    8282= Why do I get a white screen after cloning a site? =  
    83 Usually this means that the clone operation did not complete successfully. The most common cause for this is a script timeout. By default, PHP script execution for a single script is set to 30 seconds. This might not be enough time for larger sites with numerous posts, pages, and users to complete cloning - especially since the Cloner runs advanced search and replace operations against every table cloned to the new site to make sure that it reflects the new site url and title throughout all its data. Try increasing the max_execution_time in php.ini or wherever your host supports updating PHP configuration settings. You can <a title="Cloning White Screen Issue" href="http://support.neversettle.it/knowledgebase/articles/379601-white-screen-or-404-and-blank-site-after-cloning" target="_blank">read more detailed troubleshooting tips for this issue</a> on our support site. 
     83Usually this means that the clone operation did not complete successfully. The most common cause for this is a script timeout. By default, PHP script execution for a single script is set to 30 seconds. This might not be enough time for larger sites with numerous posts, pages, and users to complete cloning - especially since the Cloner runs advanced search and replace operations against every table cloned to the new site to make sure that it reflects the new site url and title throughout all its data. Try increasing the max_execution_time in php.ini or wherever your host supports updating PHP configuration settings. You can <a title="Cloning White Screen Issue" href="https://neversettle.it/documentation/ns-cloner/white-screen-404-blank-site-cloning/" target="_blank">read more detailed troubleshooting tips for this issue</a> on our support site. 
    8484 
    8585= Are there other troubleshooting guides? = 
    86 [See these articles](http://support.neversettle.it/knowledgebase/topics/56303-ns-cloner-troubleshooting) for additional help on cloning issues. 
     86[See these articles](https://neversettle.it/documentation/ns-cloner/) for additional help on cloning issues. 
    8787 
    8888== Screenshots == 
     
    9393== Changelog == 
    9494 
     95= 3.0.7 = 
     96* Replaced deprecated wp_get_sites() with get_sites() 
     97 
    9598= 3.0.6.0 = 
     99* Fixed an issue where some serial arrays get treated as objects instead of arrays and search/replace was getting missed 
    96100* Updated Kint library to resolve issues on some rare environments running OPCache and XCache 
    97101 
  • ns-cloner-site-copier/trunk/sections/ns-cloner-section-select-source.php

    r1429654 r1666855  
    1414        <label class="ns-cloner-site-select-label">Or select</label> 
    1515        <select name="source_id" class="ns-cloner-site-select"> 
    16             <?php $sites = function_exists('wp_get_sites')? wp_get_sites(array('limit'=>9999)) : get_blog_list(0,'all'); ?> 
    17             <?php foreach( $sites as $site ): ?> 
    18             <option value="<?php echo $site['blog_id']; ?>" <?php echo ( $site['blog_id'] == get_site_option('ns_cloner_default_template') ? 'selected' : '' ) ?> > 
    19                 <?php $title = get_blog_details($site['blog_id'])->blogname; ?> 
    20                 <?php $url = is_subdomain_install()? "$site[domain]" : "$site[domain]$site[path]"; ?> 
    21                 <?php echo "$site[blog_id] - ".substr($title,0,30)." ($url)"; ?> 
     16            <?php 
     17                $sites = array(); 
     18                // update for WP 4.6+ and deprecated wp_get_sites() use get_sites() instead 
     19                if ( function_exists( 'get_sites' ) && class_exists( 'WP_Site_Query' ) ) { 
     20                    $sites = get_sites(array('number'=>9999)); 
     21                } else { 
     22                // handle WP 4.5 and earlier 
     23                    $sites = function_exists('wp_get_sites')? wp_get_sites(array('limit'=>9999)) : get_blog_list(0,'all'); 
     24                }                
     25            ?> 
     26            <?php  
     27                foreach( $sites as $site ): 
     28                    // update for WP 4.6+ and deprecated wp_get_sites() use get_sites() instead 
     29                    if ( function_exists( 'get_sites' ) && class_exists( 'WP_Site_Query' ) ) { 
     30                        $blog_id = $site->blog_id; 
     31                        $blog_domain = $site->domain; 
     32                        $blog_path = $site->path; 
     33                    } else { 
     34                    // handle WP 4.5 and earlier 
     35                        $blog_id = $site['blog_id']; 
     36                        $blog_domain = $site['domain']; 
     37                        $blog_path = $site['path']; 
     38                    }  
     39            ?> 
     40            <option value="<?php echo $blog_id; ?>" <?php echo ( $blog_id == get_site_option('ns_cloner_default_template') ? 'selected' : '' ) ?> > 
     41                <?php $title = get_blog_details($blog_id)->blogname; ?> 
     42                <?php $url = is_subdomain_install()? "$blog_domain" : "$blog_domain$blog_path"; ?> 
     43                <?php echo "$blog_id - ".substr($title,0,30)." ($url)"; ?> 
    2244          <?php endforeach; ?> 
    2345        </select> 
Note: See TracChangeset for help on using the changeset viewer.