· 8 years ago · Mar 12, 2018, 06:30 PM
1<?php
2 /*
3 Plugin Name: demo
4 Plugin URI: http://www.orangecreative.net
5 Description: Plugin for displaying products from an OSCommerce shopping cart database
6 Author: C. Lupu
7 Version: 1.0
8 Author URI: http://www.orangecreative.net
9 */
10 // register_activation_hook( __FILE__,'Contact_form','creat_tabl','display');
11 register_activation_hook( __FILE__, 'myplugin_activate' );
12
13function myplugin_activate()
14{ global $wpdb;
15$table_name = $wpdb->prefix . 'contact';
16$charset_collate = $wpdb->get_charset_collate();
17$sql = "CREATE TABLE $table_name (
18 id mediumint(9) NOT NULL AUTO_INCREMENT,
19 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
20 name tinytext NOT NULL,
21 text text NOT NULL,
22 url varchar(55) DEFAULT '' NOT NULL,
23 PRIMARY KEY (id)
24 ) $charset_collate;";
25
26 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
27 dbDelta( $sql );
28 }
29 register_deactivation_hook(__FILE__,'deactivate_table');
30 function deactivate_table() {
31 global $wpdb;
32 $table_name = $wpdb->prefix . 'contact';
33 $sql = "DROP TABLE IF EXISTS $table_name;";
34 $wpdb->query($sql);
35 delete_option("my_plugin_db_version");
36 }
37 add_shortcode('Contact_form','Contact_form');
38
39function Contact_form() {
40
41}
42}
43?>