|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/** |
|
3
|
|
|
* Maps Builder |
|
4
|
|
|
* |
|
5
|
|
|
* Plugin Name: Maps Builder |
|
6
|
|
|
* Plugin URI: http://mapsbuilder.wordimpress.com/ |
|
7
|
|
|
* Description: Create stylish and powerful Google Maps quickly and easily. |
|
8
|
|
|
* Version: 2.1.2 |
|
9
|
|
|
* Author: WordImpress |
|
10
|
|
|
* Author URI: https://wordimpress.com/ |
|
11
|
|
|
* Text Domain: google-maps-builder |
|
12
|
|
|
* License: GPL-2.0+ |
|
13
|
|
|
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
|
14
|
|
|
* Domain Path: /languages |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
// If this file is called directly, abort. |
|
18
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
19
|
|
|
exit; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Define Constants |
|
24
|
|
|
*/ |
|
25
|
|
|
// Plugin Folder Path |
|
26
|
|
|
if ( ! defined( 'GMB_PLUGIN_PATH' ) ) { |
|
27
|
|
|
define( 'GMB_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
|
28
|
|
|
} |
|
29
|
|
|
// Plugin Folder URL |
|
30
|
|
|
if ( ! defined( 'GMB_PLUGIN_URL' ) ) { |
|
31
|
|
|
define( 'GMB_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
32
|
|
|
} |
|
33
|
|
|
// Plugin base |
|
34
|
|
|
if ( ! defined( 'GMB_PLUGIN_BASE' ) ) { |
|
35
|
|
|
define( 'GMB_PLUGIN_BASE', plugin_basename( __FILE__ ) ); |
|
36
|
|
|
} |
|
37
|
|
|
// Plugin version |
|
38
|
|
|
if ( ! defined( 'GMB_VERSION' ) ) { |
|
39
|
|
|
define( 'GMB_VERSION', '2.1.2' ); |
|
40
|
|
|
} |
|
41
|
|
|
// Plugin Root File |
|
42
|
|
|
if ( ! defined( 'GMB_PLUGIN_FILE' ) ) { |
|
43
|
|
|
define( 'GMB_PLUGIN_FILE', __FILE__ ); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
if ( ! class_exists( 'Google_Maps_Builder' ) ) : |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Load plugin if core lib is present |
|
51
|
|
|
*/ |
|
52
|
|
|
if ( ! file_exists( GMB_PLUGIN_PATH . 'vendor/wordimpress/maps-builder-core/core.php' ) ) { |
|
53
|
|
|
add_action( 'admin_notices', 'gmb_no_core_lib' ); |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Print admin notice if no dependencies |
|
57
|
|
|
* |
|
58
|
|
|
* @uses "admin_notice" hook |
|
59
|
|
|
*/ |
|
60
|
|
|
function gmb_no_core_lib() { |
|
61
|
|
|
printf( '<div class="notice notice-error"><p>%s</p></div>', esc_html__( 'Your install of Maps Builder is missing its Composer dependencies and can not load.', 'maps-builder-pro' ) ); |
|
62
|
|
|
} |
|
63
|
|
|
} else { |
|
64
|
|
|
require_once GMB_PLUGIN_PATH . 'vendor/wordimpress/maps-builder-core/core.php'; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Main Maps Builder Class |
|
68
|
|
|
* |
|
69
|
|
|
* @since 2.0 |
|
70
|
|
|
*/ |
|
71
|
|
|
final class Google_Maps_Builder extends Google_Maps_Builder_Core { |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @var Google_Maps_Builder The one true Google Maps Builder instance |
|
76
|
|
|
* @since 2.0 |
|
77
|
|
|
*/ |
|
78
|
|
|
private static $instance; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Prevent new instances |
|
82
|
|
|
*/ |
|
83
|
|
|
private function __construct() { |
|
84
|
|
|
//you can not haz instance |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* User meta key for marking welcome message as dismissed |
|
89
|
|
|
* |
|
90
|
|
|
* @since 2.1.0 |
|
91
|
|
|
* |
|
92
|
|
|
* @var string |
|
93
|
|
|
*/ |
|
94
|
|
|
protected $hide_welcome_key = 'gmb_hide_welcome'; |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Main Google_Maps_Builder Instance |
|
98
|
|
|
* |
|
99
|
|
|
* Insures that only one instance of Google_Maps_Builder exists in memory at any one |
|
100
|
|
|
* time. Also prevents needing to define globals all over the place. |
|
101
|
|
|
* |
|
102
|
|
|
* @since 2.0 |
|
103
|
|
|
* @static |
|
104
|
|
|
* @static var array $instance |
|
105
|
|
|
* @uses Google_Maps_Builder::setup_constants() Setup the constants needed |
|
106
|
|
|
* @uses Google_Maps_Builder::includes() Include the required files |
|
107
|
|
|
* @uses Google_Maps_Builder::load_textdomain() load the language files |
|
108
|
|
|
* @see Google_Maps_Builder() |
|
109
|
|
|
* @return Google_Maps_Builder |
|
110
|
|
|
*/ |
|
111
|
|
|
public static function instance() { |
|
112
|
|
|
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Google_Maps_Builder ) ) { |
|
113
|
|
|
|
|
114
|
|
|
self::$instance = new Google_Maps_Builder(); |
|
115
|
|
|
|
|
116
|
|
|
add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
|
117
|
|
|
|
|
118
|
|
|
self::$instance->includes(); |
|
119
|
|
|
self::$instance->activate = new Google_Maps_Builder_Activate(); |
|
120
|
|
|
self::$instance->scripts = new Google_Maps_Builder_Scripts(); |
|
121
|
|
|
self::$instance->settings = new Google_Maps_Builder_Settings(); |
|
122
|
|
|
self::$instance->engine = new Google_Maps_Builder_Engine(); |
|
123
|
|
|
self::$instance->html = new Google_Maps_Builder_HTML_Elements(); |
|
124
|
|
|
|
|
125
|
|
|
// Read plugin meta |
|
126
|
|
|
// Check that function get_plugin_data exists |
|
127
|
|
|
if ( ! function_exists( 'get_plugin_data' ) ) { |
|
128
|
|
|
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
129
|
|
|
} |
|
130
|
|
|
self::$instance->meta = get_plugin_data( GMB_PLUGIN_FILE, false ); |
|
131
|
|
|
|
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
return self::$instance; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Include required files |
|
140
|
|
|
* |
|
141
|
|
|
* @access protected |
|
142
|
|
|
* @since 2.0 |
|
143
|
|
|
* @return void |
|
144
|
|
|
*/ |
|
145
|
|
|
protected function includes() { |
|
146
|
|
|
$this->include_core_classes(); |
|
147
|
|
|
$this->load_activate(); |
|
148
|
|
|
|
|
149
|
|
|
$this->cmb2_load(); |
|
150
|
|
|
$this->load_files(); |
|
151
|
|
|
require_once GMB_PLUGIN_PATH . 'includes/class-gmb-scripts.php'; |
|
152
|
|
|
require_once GMB_PLUGIN_PATH . 'includes/class-gmb-html-elements.php'; |
|
153
|
|
|
|
|
154
|
|
|
if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
155
|
|
|
|
|
156
|
|
|
$this->load_admin(); |
|
157
|
|
|
//Admin |
|
158
|
|
|
|
|
159
|
|
|
//@TODO only load when needed |
|
160
|
|
|
$this->init_map_editor_admin(); |
|
161
|
|
|
|
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
endif; // End if class_exists check |
|
171
|
|
|
|
|
172
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.