static function create_database_table() { //global $maxbuttons_installed_version; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $table_name = maxUtils::get_buttons_table_name(); $button = new maxButton(); $blocks = $button->getDefinedBlocks(); // IMPORTANT: There MUST be two spaces between the PRIMARY KEY keywords // and the column name, and the column name MUST be in parenthesis. $sql = "CREATE TABLE " . $table_name . " ( \n\t\t\t\t\tid int NOT NULL AUTO_INCREMENT, \n\t\t\t\t\t name varchar(100) NULL, \n\t\t\t\t\t status varchar(10) default 'publish' NOT NULL, \n\t\t\t\t\t cache text, \n\t\t\t\t"; foreach ($blocks as $block) { $sql .= "" . $block . " TEXT NULL, \n "; } $sql .= " PRIMARY KEY (id) )"; if (!static::maxbuttons_database_table_exists($table_name)) { //require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); $result = dbDelta($sql); } if (static::maxbuttons_database_table_exists($table_name) && (get_option(MAXBUTTONS_VERSION_KEY) != MAXBUTTONS_VERSION_NUM || get_option(MAXBUTTONS_VERSION_KEY) == '')) { //require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } // Reset the cache if there were any left from before $button->reset_cache(); // Collection table $collection_table_name = maxUtils::get_collection_table_name(); $sql = "CREATE TABLE " . $collection_table_name . " ( \n\t\t\t\t\tmeta_id int NOT NULL AUTO_INCREMENT, \n\t\t\t\t\tcollection_id int NOT NULL, \n\t\t\t\t\tcollection_key varchar(255), \n\t\t\t\t\tcollection_value text, \n\t\t\t\t\tPRIMARY KEY(meta_id) ) \n\t\t\t\t\t\n\t\t\t\t"; dbDelta($sql); $collection_trans_table = maxUtils::get_coltrans_table_name(); $sql = "CREATE TABLE {$collection_trans_table} ( \n \t\t\t\tname varchar(1000), \n\t\t\t\tvalue varchar(255),\n\t\t\t\texpire int,\n\t\t\t\tKEY(name) ); \n\t\t"; $res = dbDelta($sql); //else exit( __("Something went wrong when creating database table", "maxbuttons") ); }