[], 'version' => PWP_VERSION, ]; } // Plugin activation hook. register_activation_hook(__FILE__, 'patternswp_plugin_activate'); function patternswp_plugin_activate() { global $wpdb; $table_name = $wpdb->prefix . 'patternswp_patterns'; // Check if the table already exists. if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { // Table does not exist, so create it. $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id INT NOT NULL AUTO_INCREMENT, title VARCHAR(255), categories VARCHAR(100), content LONGTEXT, PRIMARY KEY (id) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } } // Plugin deactivation hook. register_deactivation_hook(__FILE__, 'patternswp_plugin_deactivate'); function patternswp_plugin_deactivate() { // Deactivation tasks if any. }