Hi I have this function to install the plugin and create database table:
function sortresult_install()
{
//install sort_search_result options to the database
global $wpdb;
$sortsearchtitle_db_version = '1.0';
$table = $wpdb->prefix."sortsearchresult";
$structure = "CREATE TABLE IF NOT EXISTS $table (id INT(9) NOT NULL AUTO_INCREMENT,order_valuex VARCHAR(5) NOT NULL,UNIQUE KEY id (id));";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($structure);
//Save database version
update_option("sortsearchtitle_db_version", $sortsearchtitle_db_version);
// Insert default sorting setting that is ascending
$wpdb->query("INSERT IGNORE INTO $table(order_valuex) VALUES('ASC')");
}
And this is the construct function:
function __construct()
{
//Register activation hook
register_activation_hook(__FILE__,array(&$this,'sortresult_install'));
//Add menu hook
add_action( 'admin_menu', array(&$this,'sort_searchresults_menu'));
//Update function hook
add_action('plugins_loaded', array(&$this,'sortsearchtitle_update_db_check'));
//Run the search function
add_action('pre_get_posts',array(&$this,'sort_searchresult_by_title'));
}
Any ideas why the above functions won't create the database table? I am updating this plugin for Wordpress 3.5.Thanks.