jealous

Warning: call_user_func_array()

Feb 23rd, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: test system
  4. Plugin URI:
  5. Description:
  6. Author:
  7. Version: 1.0
  8. Author URI:
  9. */
  10.  
  11. /* Instantiate new class */
  12. $test_system = new test_system();
  13.  
  14. /* Visual Form Builder class */
  15. class test_system {
  16.  
  17. function __construct(){
  18. global $wpdb;
  19.  
  20. /* Setup global database table names */
  21. $this->testing_table_name = $wpdb->prefix . 'test_system_testing';
  22.  
  23. /* Add a database version to help with upgrades and run SQL install */
  24. if ( !get_option( 'test_system_db_version' ) ) {
  25. update_option( 'test_system_version', $this->test_system_version );
  26. $this->install_db();
  27. }
  28.  
  29. /* If database version doesn't match, update and run SQL install */
  30. if ( get_option( 'test_system_db_version' ) != $this->test_system_db_version ) {
  31. update_option( 'test_system_db_version', $this->test_system_db_version );
  32. $this->install_db();
  33. }
  34. }
  35.  
  36. static function install_db() {
  37. global $wpdb;
  38.  
  39. $testing_table_name = $wpdb->prefix . 'test_system_testing';
  40.  
  41. /* Explicitly set the character set and collation when creating the tables */
  42. $charset = ( defined( 'DB_CHARSET' && '' !== DB_CHARSET ) ) ? DB_CHARSET : 'utf8';
  43. $collate = ( defined( 'DB_COLLATE' && '' !== DB_COLLATE ) ) ? DB_COLLATE : 'utf8_general_ci';
  44.  
  45. require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
  46.  
  47. $testing_sql = "CREATE TABLE $testing_table_name (
  48. testing_id BIGINT(20) NOT NULL AUTO_INCREMENT,
  49. user_name VARCHAR(255),
  50. password VARCHAR(255),
  51. title VARCHAR(255),
  52. first_name VARCHAR(255),
  53. surname VARCHAR(255),
  54. country VARCHAR(255),
  55. address_line_1 VARCHAR(255),
  56. address_line_2 VARCHAR(255),
  57. county VARCHAR(255),
  58. post_code VARCHAR(8),
  59. daytime_telephone_number VARCHAR(12),
  60. evening_telephone_number VARCHAR(12),
  61. mobile VARCHAR(11),
  62. email VARCHAR(255),
  63. UNIQUE KEY (testing_id)
  64. ) DEFAULT CHARACTER SET $charset COLLATE $collate;";
  65.  
  66. /* Create or Update database tables */
  67. dbDelta( $testing_sql );
  68. }
  69.  
  70.  
  71. }
  72.  
  73. register_activation_hook( __FILE__, 'test_system','install_db' );
  74.  
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment