Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Initialization and Hooks
- global $wpdb;
- global $wp_version;
- global $wpmyfirstplugin_version;
- global $wpmyfirstplugin_db_version;
- global $wpmyfirstplugin_table_name;
- global $wp_version;
- $wpmyfirstplugin_version = '1.0.1';
- $wpmyfirstplugin_db_version = '0.0.1';
- $wpmyfirstplugin_table_name = $wpdb->prefix.'imart_setting';
- function wpmyfirstplugin_install()
- {
- global $wpdb;
- global $wpmyfirstplugin_table_name;
- global $wpmyfirstplugin_db_version;
- // create table on first install
- if($wpdb->get_var("show tables like '$wpmyfirstplugin_table_name'") != $wpmyfirstplugin_table_name) {
- wpmyfirstplugin_createTable($wpdb, $wpmyfirstplugin_table_name);
- //add_option("wpmyfirstplugin_db_version", $wpmyfirstplugin_db_version);
- //add_option("wpmyfirstplugin_configuration", '');
- }
- }
- function wpmyfirstplugin_createTable($wpdb, $table_name)
- {
- $sql = "CREATE TABLE ".$table_name." (
- main_id bigint(20) NOT NULL auto_increment,
- main_key varchar(255) default NULL,
- main_value longtext,
- PRIMARY KEY (`imart_id`)
- ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
- $results = $wpdb->query($sql);
- }
- register_activation_hook(__FILE__,'wpmyfirstplugin_createTable');
- wpmyfirstplugin_createTable($wpdb, $wpmyfirstplugin_table_name);
- $results = $wpdb->query($sql);
- function test_db_install()
- {
- global $wpdb;
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- $sql="
- CREATE TABLE IF NOT EXISTS `".$wpdb->prefix."imart_setting`
- (
- main_id bigint(20) NOT NULL auto_increment,
- main_key varchar(255) default NULL,
- main_value longtext,
- PRIMARY KEY (`main_id`)
- );";
- dbDelta($sql);
- $insert_sql ="
- INSERT INTO `wp_posts`(`post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES ('admin','','','[Alumini Dashboard]','Dashbord','','publish','','','','dashbord','','','','','','','','','page','','')";
- dbDelta($insert_sql);
Add Comment
Please, Sign In to add comment