Support » Plugin: MultiSite Clone Duplicator » Original site to copy only showing first 100 sites

  • Resolved tmoreno17

    (@tmoreno17)


    Thanks for the great plugin, been using it for awhile now. Came across this issue: when attempting to clone a site, the dropdown list is showing only the first 100 sites.

    Running version 1.3.3 on WP 4.6.1.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Same problem.

    Any solution?

    Running version 1.3.3 on WP 4.7

    This is due to the wp_get_sites function being deprecated (I think the breaking change may have happened in 4.7?). There are 4 calls to this function in the plugin – one in include/functions.php and three in lib/option.php. The code needs to be edited so it uses the new get_sites function, which has a different parameter for the maximum number of sites to get (number rather than limit). It also needs to be changed so the list of sites are treated as objects instead of associative arrays. These are the edits which are working on my installs:

    in functions.php

    
            /**
             * Get all duplicable sites
             * @since 0.2.0
             * @return array of blog data
             */
            public static function get_site_list() {
                $site_list = array();
    
                $network_blogs = get_sites(array('number' => MUCD_MAX_NUMBER_OF_SITE));
                foreach( $network_blogs as $blogobj ){
                    $blog = (array) $blogobj;
                    if (MUCD_Functions::is_duplicable($blog['blog_id']) && MUCD_SITE_DUPLICATION_EXCLUDE != $blog['blog_id']) {
                        $site_list[] = $blog;
                    }
    
                }
    
                return $site_list;
            }
    

    in option.php

    
            /**
             * Init 'mucd_duplicable' options
             * @param string $blogs_value the value for blogs options
             * @param string $network_value the value for site option
             * @since 0.2.0
             */
            public static function init_duplicable_option($blogs_value = "no", $network_value = "all") {
                $network_blogs = get_sites(array('number' => MUCD_MAX_NUMBER_OF_SITE));
                foreach( $network_blogs as $blog ){
                    $blog_id = $blog->blog_id;
                    add_blog_option( $blog_id, 'mucd_duplicable', $blogs_value);
                }
                add_site_option( 'mucd_duplicables', $network_value );
            }
    
            /**
             * Delete 'mucd_duplicable' option for all sites
             * @since 0.2.0
             */
            public static function delete_duplicable_option() {
                $network_blogs = get_sites(array('number' => MUCD_MAX_NUMBER_OF_SITE));
                foreach( $network_blogs as $blog ){
                    $blog_id = $blog->blog_id;
                    delete_blog_option( $blog_id, 'mucd_duplicable');
                }
                delete_site_option( 'mucd_duplicables');
            }
    
            /**
             * Set 'mucd_duplicable' option to "yes" for the list of blogs, other to "no"
             * @since 0.2.0
             * @param array $blogs list of blogs we want the option set to "yes"
             */
            public static function set_duplicable_option($blogs) {
                $network_blogs = get_sites(array('number' => MUCD_MAX_NUMBER_OF_SITE));
                foreach( $network_blogs as $blog ){
                    if(in_array($blog->blog_id, $blogs)) {
                        update_blog_option( $blog->blog_id, 'mucd_duplicable', "yes");
                    }
                    else {
                        update_blog_option($blog->blog_id, 'mucd_duplicable', "no");
                    }
                }
            }
    
    

    Hope this helps…

    Missed one more edit in template/network_admin_network_settings.php to generate the multiselect list:

    
                $network_blogs = get_sites(array('number' => MUCD_MAX_NUMBER_OF_SITE));
                echo '<div class="multiselect" id="site-select-box">';
                foreach( $network_blogs as $blog ) {
                    echo '    <label><input ' . checked(get_blog_option( $blog->blog_id, 'mucd_duplicable', "no"), 'yes', false) . ' class="duplicables-list" type="checkbox" name="duplicables-list[]" value="'.$blog->blog_id.'" />' . substr($blog->domain . $blog->path, 0, -1) . '</label>';
                }
                echo '</div>';
    
    Plugin Author Pierre Dargham

    (@pdargham)

    Hello,

    Problem was :

    – we changed the use of the deprecated wp_get_sites to get_sites, but we missed that the argument key for the max limit of sites was no more limit but number.

    -> we fixed it on our development branch on github, and the bugfix will be release within two weeks as part of the release 1.4.0

    Feel free to test the develop version https://github.com/pierre-dargham/multisite-clone-duplicator but please be careful : it is not stable yet, and for production sites you should wait next versions on wordpress.org

    Bests regards,

    Pierre

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Original site to copy only showing first 100 sites’ is closed to new replies.