-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapbox-post-map.php
More file actions
62 lines (51 loc) · 1.9 KB
/
mapbox-post-map.php
File metadata and controls
62 lines (51 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Plugin Name: Mapbox Post Map
* Plugin URI: http://www.gobigemma.com
* Description: Add a Mapbox post map to your pages.
* Version: 0.3.1
* Author: Sven Chmielewski
* Author URI: http://www.gobigemma.com
* License: GPL3
*/
// for debugging
include 'ChromePhp.php';
global $mb_db_version;
$mb_db_version = '1.0';
global $location_table_name;
$location_table_name = 'mb_locdata';
/**
* Code that runs when the plugin is activated.
* Create database table when the plugin is activated.
*/
function activate_mapbox_post_map() {
global $wpdb;
global $mb_db_version;
global $location_table_name;
$installed_version = get_option('mb_db_version');
if ( $installed_version !== $booking_db_version ) {
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
$table_name = $wpdb->prefix . $location_table_name;
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name text NOT NULL,
loclat text NOT NULL,
loclng text NOT NULL,
type text NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
dbDelta( $sql );
add_option( 'mb_db_version', $mb_db_version );
}
}
register_activation_hook( __FILE__, 'activate_mapbox_post_map' );
// Also run the activation function whenever the plugin loads to check if the database needs upgrading.
add_action( 'plugins_loaded', 'activate_mapbox_post_map' );
require_once plugin_dir_path(__FILE__) . 'admin/class-mapbox-meta-box.php';
require_once plugin_dir_path(__FILE__) . 'admin/class-mapbox-map-settings.php';
require_once plugin_dir_path(__FILE__) . 'public/class-mapbox-post-map.php';
// TODO: add checks if we are on the right page?
$mapbox_map = new Mapbox_Post_Map();
$mapbox_metabox = new Mapbox_Meta_Box();
$mapbox_settings = new Mapbox_Map_Settings();