• Resolved matteo.boria

    (@matteoboria)


    Thank you for the plugin (and I’m sorry to bother you again ?? I’m not really a developers stalker).
    The plugin activation function is not “network compliant”.
    The SQL is done only for first blog. In other blogs, the additional column “term_order” is not created during the activation and the plugin simply doesn’t work.

    The function:

    function customtaxorder_activate() {
    	global $wpdb;
    	$init_query = $wpdb->query("SHOW COLUMNS FROM $wpdb->terms LIKE 'term_order'");
    	if ($init_query == 0) {	$wpdb->query("ALTER TABLE $wpdb->terms ADD <code>term_order</code> INT( 4 ) NULL DEFAULT '0'"); }
    }

    can be something like:

    function _customtaxorder_activate() {
    	global $wpdb;
    	$init_query = $wpdb->query("SHOW COLUMNS FROM $wpdb->terms LIKE 'term_order'");
    	if ($init_query == 0) {	$wpdb->query("ALTER TABLE $wpdb->terms ADD <code>term_order</code> INT( 4 ) NULL DEFAULT '0'"); }
    }
    function customtaxorder_activate($networkwide) {
    	global $wpdb;
    	if (function_exists('is_multisite') && is_multisite()) {
    		if ($networkwide) {
    			$curr_blog = $wpdb->blogid;
    			$blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
    			foreach ($blogids as $blog_id) {
    				switch_to_blog($blog_id);
    				_customtaxorder_activate();
    			}
    			switch_to_blog($curr_blog);
    		}
    	} else {
    		_customtaxorder_activate();
    	}
    }

    Ciao;
    Matteo

    https://www.ads-software.com/plugins/custom-taxonomy-order-ne/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Marcel Pol

    (@mpol)

    Thank you.
    It’s now part of 2.3.7

    Multisite activation doesn’t work if it isn’t done network wide.

    This:

    function customtaxorder_activate($networkwide) {
    	global $wpdb;
    	if (function_exists('is_multisite') && is_multisite()) {
    		if ($networkwide) {
    			$curr_blog = $wpdb->blogid;
    			$blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
    			foreach ($blogids as $blog_id) {
    				switch_to_blog($blog_id);
    				_customtaxorder_activate();
    			}
    			switch_to_blog($curr_blog);
    		}
    	} else {
    		_customtaxorder_activate();
    	}
    }

    Should be:

    function customtaxorder_activate($networkwide) {
    	global $wpdb;
    	if (function_exists('is_multisite') && is_multisite() && $networkwide) {
    		$curr_blog = $wpdb->blogid;
    		$blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
    		foreach ($blogids as $blog_id) {
    			switch_to_blog($blog_id);
    			_customtaxorder_activate();
    		}
    		switch_to_blog($curr_blog);
    	} else {
    		_customtaxorder_activate();
    	}
    }
    Plugin Author Marcel Pol

    (@mpol)

    Thank you.
    I’m not familiar with multisite, but I trust you on this.
    It’s in 2.4.9.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multisite activation plugin fails on additional blogs (missing column)’ is closed to new replies.