Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: test system
- Plugin URI:
- Description:
- Author:
- Version: 1.0
- Author URI:
- */
- /* Instantiate new class */
- $test_system = new test_system();
- /* Visual Form Builder class */
- class test_system {
- function __construct(){
- global $wpdb;
- /* Setup global database table names */
- $this->testing_table_name = $wpdb->prefix . 'test_system_testing';
- /* Add a database version to help with upgrades and run SQL install */
- if ( !get_option( 'test_system_db_version' ) ) {
- update_option( 'test_system_version', $this->test_system_version );
- $this->install_db();
- }
- /* If database version doesn't match, update and run SQL install */
- if ( get_option( 'test_system_db_version' ) != $this->test_system_db_version ) {
- update_option( 'test_system_db_version', $this->test_system_db_version );
- $this->install_db();
- }
- }
- static function install_db() {
- global $wpdb;
- $testing_table_name = $wpdb->prefix . 'test_system_testing';
- /* Explicitly set the character set and collation when creating the tables */
- $charset = ( defined( 'DB_CHARSET' && '' !== DB_CHARSET ) ) ? DB_CHARSET : 'utf8';
- $collate = ( defined( 'DB_COLLATE' && '' !== DB_COLLATE ) ) ? DB_COLLATE : 'utf8_general_ci';
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
- $testing_sql = "CREATE TABLE $testing_table_name (
- testing_id BIGINT(20) NOT NULL AUTO_INCREMENT,
- user_name VARCHAR(255),
- password VARCHAR(255),
- title VARCHAR(255),
- first_name VARCHAR(255),
- surname VARCHAR(255),
- country VARCHAR(255),
- address_line_1 VARCHAR(255),
- address_line_2 VARCHAR(255),
- county VARCHAR(255),
- post_code VARCHAR(8),
- daytime_telephone_number VARCHAR(12),
- evening_telephone_number VARCHAR(12),
- mobile VARCHAR(11),
- email VARCHAR(255),
- UNIQUE KEY (testing_id)
- ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
- /* Create or Update database tables */
- dbDelta( $testing_sql );
- }
- }
- register_activation_hook( __FILE__, 'test_system','install_db' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment