PluginProbe
CBX Map for Google Map & OpenStreetMap / 1.1.11
CBX Map for Google Map & OpenStreetMap v1.1.11
trunk 1.1.10 1.1.11 1.1.12 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5
cbxgooglemap / includes / class-cbxgooglemap.php

class-cbxgooglemap.php in CBX Map for Google Map & OpenStreetMap 1.1.11, at includes/class-cbxgooglemap.php

288 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used across both the
7 * public-facing side of the site and the admin area.
8 *
9 * @link https://codeboxr.com
10 * @since 1.0.0
11 *
12 * @package Cbxgooglemap
13 * @subpackage Cbxgooglemap/includes
14 */
15
16 /**
17 * The core plugin class.
18 *
19 * This is used to define internationalization, admin-specific hooks, and
20 * public-facing site hooks.
21 *
22 * Also maintains the unique identifier of this plugin as well as the current
23 * version of the plugin.
24 *
25 * @since 1.0.0
26 * @package Cbxgooglemap
27 * @subpackage Cbxgooglemap/includes
28 * @author Codeboxr <info@codeboxr.com>
29 */
30 class Cbxgooglemap {
31
32 /**
33 * The loader that's responsible for maintaining and registering all hooks that power
34 * the plugin.
35 *
36 * @since 1.0.0
37 * @access protected
38 * @var CBXGoogleMap_Loader $loader Maintains and registers all hooks for the plugin.
39 */
40 protected $loader;
41
42 /**
43 * The unique identifier of this plugin.
44 *
45 * @since 1.0.0
46 * @access protected
47 * @var string $plugin_name The string used to uniquely identify this plugin.
48 */
49 protected $plugin_name;
50
51 /**
52 * The current version of the plugin.
53 *
54 * @since 1.0.0
55 * @access protected
56 * @var string $version The current version of the plugin.
57 */
58 protected $version;
59
60 /**
61 * Define the core functionality of the plugin.
62 *
63 * Set the plugin name and the plugin version that can be used throughout the plugin.
64 * Load the dependencies, define the locale, and set the hooks for the admin area and
65 * the public-facing side of the site.
66 *
67 * @since 1.0.0
68 */
69 public function __construct() {
70
71 $this->plugin_name = CBXGOOGLEMAP_PLUGIN_NAME;
72 $this->version = CBXGOOGLEMAP_PLUGIN_VERSION;
73
74 $this->load_dependencies();
75 $this->set_locale();
76 $this->define_admin_hooks();
77 $this->define_public_hooks();
78
79 }
80
81 /**
82 * Load the required dependencies for this plugin.
83 *
84 * Include the following files that make up the plugin:
85 *
86 * - CBXGoogleMap_Loader. Orchestrates the hooks of the plugin.
87 * - CBXGoogleMap_i18n. Defines internationalization functionality.
88 * - CBXGoogleMap_Admin. Defines all hooks for the admin area.
89 * - CBXGoogleMap_Public. Defines all hooks for the public side of the site.
90 *
91 * Create an instance of the loader which will be used to register the hooks
92 * with WordPress.
93 *
94 * @since 1.0.0
95 * @access private
96 */
97 private function load_dependencies() {
98
99 /**
100 * The class responsible for orchestrating the actions and filters of the
101 * core plugin.
102 */
103 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-cbxgooglemap-loader.php';
104
105 /**
106 * The class responsible for defining internationalization functionality
107 * of the plugin.
108 */
109 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-cbxgooglemap-i18n.php';
110
111 /**
112 * The class responsible for defining settings functionality of the plugin.
113 */
114 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-cbxgooglemap-settings.php';
115
116 require plugin_dir_path(dirname(__FILE__)) . 'includes/cbxgooglemap-tpl-loader.php';
117 require plugin_dir_path(dirname(__FILE__)) . 'includes/class-cbxgooglemap-helper.php';
118
119 /**
120 * The class responsible for defining all actions that occur in the admin area.
121 */
122 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-cbxgooglemap-admin.php';
123
124 /**
125 * The class responsible for defining all actions that occur in the public-facing
126 * side of the site.
127 */
128 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-cbxgooglemap-public.php';
129
130 require plugin_dir_path(dirname(__FILE__)) . 'includes/cbxgooglemap-functions.php';
131
132
133
134 $this->loader = new CBXGoogleMap_Loader();
135
136 }
137
138 /**
139 * Define the locale for this plugin for internationalization.
140 *
141 * Uses the CBXGoogleMap_i18n class in order to set the domain and to register the hook
142 * with WordPress.
143 *
144 * @since 1.0.0
145 * @access private
146 */
147 private function set_locale() {
148
149 $plugin_i18n = new CBXGoogleMap_i18n();
150
151 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
152
153 }
154
155 /**
156 * Register all of the hooks related to the admin area functionality
157 * of the plugin.
158 *
159 * @since 1.0.0
160 * @access private
161 */
162 private function define_admin_hooks() {
163 global $wp_version;
164
165 $plugin_admin = new CBXGoogleMap_Admin( $this->get_plugin_name(), $this->get_version() );
166
167 //adding the setting action
168 $this->loader->add_action('admin_init', $plugin_admin, 'setting_init');
169
170
171 //add new post type
172 $this->loader->add_action('init', $plugin_admin, 'create_post_type', 0);
173
174
175
176 //create opverview menu page
177 $this->loader->add_action( 'admin_menu', $plugin_admin, 'admin_overview_menu_page' );
178
179
180 //display meta fields
181 $this->loader->add_action('add_meta_boxes', $plugin_admin, 'add_meta_boxes_form');
182
183
184 //save meta fields
185 $this->loader->add_action('save_post', $plugin_admin, 'metabox_save', 10, 3); //save meta
186
187
188
189 $this->loader->add_filter('manage_edit-cbxgooglemap_columns', $plugin_admin, 'cbxgooglemap_add_new_columns');
190 $this->loader->add_action('manage_cbxgooglemap_posts_custom_column', $plugin_admin, 'cbxgooglemap_manage_columns');
191
192 //js and css
193 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
194 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
195
196
197 //add plugin row meta and actions links
198 $this->loader->add_filter( 'plugin_action_links_' . CBXGOOGLEMAP_BASE_NAME, $plugin_admin, 'plugin_listing_setting_link' );
199 $this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'custom_plugin_row_meta', 10, 2 );
200
201 //gutenberg
202 $this->loader->add_action( 'init', $plugin_admin, 'gutenberg_blocks' );
203 //gutenberg blocks
204 if ( version_compare($wp_version,'5.8') >= 0) {
205 $this->loader->add_filter( 'block_categories_all', $plugin_admin, 'gutenberg_block_categories', 10, 2 );
206 }
207 else{
208 $this->loader->add_filter( 'block_categories', $plugin_admin, 'gutenberg_block_categories', 10, 2 );
209 }
210
211 //$this->loader->add_filter( 'block_categories', $plugin_admin, 'gutenberg_block_categories', 10, 2 );
212 $this->loader->add_action( 'enqueue_block_editor_assets', $plugin_admin,'enqueue_block_editor_assets' );
213 }//end define_admin_hooks
214
215 /**
216 * Register all of the hooks related to the public-facing functionality
217 * of the plugin.
218 *
219 * @since 1.0.0
220 * @access private
221 */
222 private function define_public_hooks() {
223 global $wp_version;
224
225 $plugin_public = new CBXGoogleMap_Public( $this->get_plugin_name(), $this->get_version() );
226
227
228
229 $this->loader->add_action('init', $plugin_public, 'init_shortcodes');
230
231 $this->loader->add_action( 'widgets_init', $plugin_public, 'register_widget' );
232 //elementor
233 //$this->loader->add_action( 'elementor/init',$plugin_public, 'init_elementor_widgets' );
234 $this->loader->add_action( 'elementor/widgets/widgets_registered',$plugin_public, 'init_elementor_widgets' );
235 $this->loader->add_action( 'elementor/elements/categories_registered', $plugin_public,'add_elementor_widget_categories' );
236 $this->loader->add_action('elementor/editor/before_enqueue_scripts', $plugin_public, 'elementor_icon_loader', 99999);
237
238 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
239 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
240
241
242 $this->loader->add_action( 'vc_before_init', $plugin_public, 'vc_before_init_actions' );
243
244
245 }
246
247 /**
248 * Run the loader to execute all of the hooks with WordPress.
249 *
250 * @since 1.0.0
251 */
252 public function run() {
253 $this->loader->run();
254 }
255
256 /**
257 * The name of the plugin used to uniquely identify it within the context of
258 * WordPress and to define internationalization functionality.
259 *
260 * @since 1.0.0
261 * @return string The name of the plugin.
262 */
263 public function get_plugin_name() {
264 return $this->plugin_name;
265 }
266
267 /**
268 * The reference to the class that orchestrates the hooks with the plugin.
269 *
270 * @since 1.0.0
271 * @return CBXGoogleMap_Loader Orchestrates the hooks of the plugin.
272 */
273 public function get_loader() {
274 return $this->loader;
275 }
276
277 /**
278 * Retrieve the version number of the plugin.
279 *
280 * @since 1.0.0
281 * @return string The version number of the plugin.
282 */
283 public function get_version() {
284 return $this->version;
285 }
286
287 }
288