• Hi all,

    I am trying to update my plugin for compatibility with WP 2.5 but I still cannot create the tables at activation.

    Here is the code I use to create the tables:

    // Create the main template table
    	$sql = "CREATE TABLE ".$post_templates_templates_table." (
    		template_id BIGINT(20) NOT NULL AUTO_INCREMENT,
    		type ENUM('page', 'post') NOT NULL,
    		title TEXT NOT NULL,
    		slug VARCHAR(200) NOT NULL,
    		content LONGTEXT NOT NULL,
    		excerpt TEXT NOT NULL,
    		categories TEXT NOT NULL,
    		tags TEXT NOT NULL,
    		password VARCHAR(20) NOT NULL,
    		comment_status ENUM('open', 'closed', 'registered_only') NOT NULL,
    		ping_status ENUM('open', 'closed') NOT NULL,
    		to_ping TEXT NOT NULL,
    		parent BIGINT(20) NOT NULL,
    		PRIMARY KEY  (template_id)
    	); ";
    
    	require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);

    This was working fine with WP 2.3.

    I tried as well to create the tables manually with a $wpdb->query but I have the same effect.

    I got no output message, no way to know why it does not get created. Do I have to commit such a DB modification? If so, how?

    Vincent

Viewing 4 replies - 1 through 4 (of 4 total)
  • Are you using any global variables in your activation function? if so you need to declare them as global *outside* of the function. They made any variables that exist in the activation function non-global (even if you call them as global) unles you specifically declared them as global in the main context of your file.

    So at the start of my plugin I globalize all of my global variables I use in my activation function.

    that was the problem indeed. I should have read more carefully the plugin upgrade document.

    Thanks a lot!

    I had a working version of ver. 1.2.1 prior to upgrading to WP 2.5; but after, went to post template 2.1.1, and it shows up; but when hitting “templatize” on a post, it takes me to the management page, with no template post. Any ideas?

    An idea: make my life easyer and go to the support forum on https://post-template.vincentprat.info

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Not able to create plugin tables since WP 2.5’ is closed to new replies.