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") ); }
static function create_database_table() { //global $maxbuttons_installed_version; $table_name = maxButtonsUtils::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"; /* name VARCHAR(100) NULL, description VARCHAR(500) NULL, url VARCHAR(250) NULL, text VARCHAR(100) NULL, text_font_family VARCHAR(50) NULL, text_font_size VARCHAR(10) NULL, text_font_style VARCHAR(10) NULL, text_font_weight VARCHAR(10) NULL, text_color VARCHAR(10) NULL, text_color_hover VARCHAR(10) NULL, text_shadow_offset_left VARCHAR(10) NULL, text_shadow_offset_top VARCHAR(10) NULL, text_shadow_width VARCHAR(10) NULL, text_shadow_color VARCHAR(10) NULL, text_shadow_color_hover VARCHAR(10) NULL, text_padding_top VARCHAR(10) NULL, text_padding_bottom VARCHAR(10) NULL, text_padding_left VARCHAR(10) NULL, text_padding_right VARCHAR(10) NULL, border_radius_top_left VARCHAR(10) NULL, border_radius_top_right VARCHAR(10) NULL, border_radius_bottom_left VARCHAR(10) NULL, border_radius_bottom_right VARCHAR(10) NULL, border_style VARCHAR(10) NULL, border_width VARCHAR(10) NULL, border_color VARCHAR(10) NULL, border_color_hover VARCHAR(10) NULL, box_shadow_offset_left VARCHAR(10) NULL, box_shadow_offset_top VARCHAR(10) NULL, box_shadow_width VARCHAR(10) NULL, box_shadow_color VARCHAR(10) NULL, box_shadow_color_hover VARCHAR(10) NULL, gradient_start_color VARCHAR(10) NULL, gradient_start_color_hover VARCHAR(10) NULL, gradient_end_color VARCHAR(10) NULL, gradient_end_color_hover VARCHAR(10) NULL, gradient_stop VARCHAR(2) NULL, gradient_start_opacity VARCHAR(3) NULL, gradient_end_opacity VARCHAR(3) NULL, gradient_start_opacity_hover VARCHAR(3), gradient_end_opacity_hover VARCHAR(3), new_window VARCHAR(10) NULL, container_enabled VARCHAR(5) NULL, container_width VARCHAR(7) NULL, container_margin_top VARCHAR(7) NULL, container_margin_right VARCHAR(7) NULL, container_margin_bottom VARCHAR(7) NULL, container_margin_left VARCHAR(7) NULL, container_alignment VARCHAR(25) NULL, container_center_div_wrap_enabled VARCHAR(5) NULL, nofollow VARCHAR(5) NULL, status VARCHAR(10) DEFAULT 'publish' NOT NULL, external_css VARCHAR(5) NULL, important_css VARCHAR(5) NULL, );"; */ 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'; 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); } //else exit( __("Something went wrong when creating database table", "maxbuttons") ); }