install

The Google Map Tab install function.

Description

install(); 

Usage

  1. if ( !function_exists( 'install' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-map-tab/inc/db-settings.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = install(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/inc/db-settings.php  
  1. function install() { 
  2. // makes the location table 
  3. global $wpdb; 
  4. global $db_table_version; 
  5.  
  6. $table_name = $wpdb->prefix . "gmt_tab"; 
  7.  
  8. // provide an update 
  9. $installed_ver = get_option( "db_table_version" ); 
  10. if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name || $installed_ver != $db_table_version ) { 
  11. $sql = "CREATE TABLE " . $table_name . " ( 
  12. `id` INT( 9 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,  
  13. `lat` TEXT NOT NULL,  
  14. `lon` TEXT NOT NULL,  
  15. `title` TEXT NOT NULL,  
  16. `content` TEXT NOT NULL,  
  17. `zoom` TEXT NOT NULL,  
  18. UNIQUE KEY id (id) 
  19. )ENGINE=InnoDB DEFAULT CHARSET=utf8;"; 
  20.  
  21. $sql.= "INSERT INTO `" . $table_name . "` (`id`, `lat`, `lon`, `title`, `content`, `zoom`) VALUES 
  22. (1, '52.1', '11.3', 'Title A', 'Lorem Ipsum..', '12'),  
  23. (2, '51.2', '22.2', 'Title B', 'Lorem Ipsum..', '12'),  
  24. (3, '49.4', '35.9', 'Title C', 'Lorem Ipsum..', '12'),  
  25. (4, '47.8', '15.6', 'Title D', 'Lorem Ipsum..', '12');"; 
  26.  
  27. require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 
  28. dbDelta($sql); 
  29.  
  30. update_option( "db_table_version", $db_table_version ); 
  31. add_option("db_table_version", $db_table_version);