PluginProbe
CBX Map for Google Map & OpenStreetMap / 1.1.7
CBX Map for Google Map & OpenStreetMap v1.1.7
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.7, at includes/class-cbxgooglemap.php

273 lines 8.0 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 /**
117 * The class responsible for defining all actions that occur in the admin area.
118 */
119 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-cbxgooglemap-admin.php';
120
121 /**
122 * The class responsible for defining all actions that occur in the public-facing
123 * side of the site.
124 */
125 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-cbxgooglemap-public.php';
126
127
128
129 $this->loader = new CBXGoogleMap_Loader();
130
131 }
132
133 /**
134 * Define the locale for this plugin for internationalization.
135 *
136 * Uses the CBXGoogleMap_i18n class in order to set the domain and to register the hook
137 * with WordPress.
138 *
139 * @since 1.0.0
140 * @access private
141 */
142 private function set_locale() {
143
144 $plugin_i18n = new CBXGoogleMap_i18n();
145
146 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
147
148 }
149
150 /**
151 * Register all of the hooks related to the admin area functionality
152 * of the plugin.
153 *
154 * @since 1.0.0
155 * @access private
156 */
157 private function define_admin_hooks() {
158
159 $plugin_admin = new CBXGoogleMap_Admin( $this->get_plugin_name(), $this->get_version() );
160
161 //adding the setting action
162 $this->loader->add_action('admin_init', $plugin_admin, 'setting_init');
163
164
165 //add new post type
166 $this->loader->add_action('init', $plugin_admin, 'create_post_type', 0);
167
168
169
170 //create opverview menu page
171 $this->loader->add_action( 'admin_menu', $plugin_admin, 'admin_overview_menu_page' );
172
173
174
175 $this->loader->add_action('add_meta_boxes', $plugin_admin, 'add_meta_boxes_form');
176
177
178 //meta save
179 $this->loader->add_action('save_post', $plugin_admin, 'metabox_save', 10, 3); //save meta
180
181
182
183 $this->loader->add_filter('manage_edit-cbxgooglemap_columns', $plugin_admin, 'cbxgooglemap_add_new_columns');
184 $this->loader->add_action('manage_cbxgooglemap_posts_custom_column', $plugin_admin, 'cbxgooglemap_manage_columns');
185
186 //js and css
187 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
188 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
189
190
191 //add plugin row meta and actions links
192 $this->loader->add_filter( 'plugin_action_links_' . CBXGOOGLEMAP_BASE_NAME, $plugin_admin, 'plugin_listing_setting_link' );
193 $this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'custom_plugin_row_meta', 10, 2 );
194
195 //gutenberg
196 $this->loader->add_action( 'init', $plugin_admin, 'gutenberg_blocks' );
197 $this->loader->add_filter( 'block_categories', $plugin_admin, 'gutenberg_block_categories', 10, 2 );
198 $this->loader->add_action( 'enqueue_block_editor_assets', $plugin_admin,'enqueue_block_editor_assets' );
199 }//end define_admin_hooks
200
201 /**
202 * Register all of the hooks related to the public-facing functionality
203 * of the plugin.
204 *
205 * @since 1.0.0
206 * @access private
207 */
208 private function define_public_hooks() {
209
210 $plugin_public = new CBXGoogleMap_Public( $this->get_plugin_name(), $this->get_version() );
211
212
213
214 $this->loader->add_action('init', $plugin_public, 'init_shortcodes');
215
216 $this->loader->add_action( 'widgets_init', $plugin_public, 'register_widget' );
217 //elementor
218 //$this->loader->add_action( 'elementor/init',$plugin_public, 'init_elementor_widgets' );
219 $this->loader->add_action( 'elementor/widgets/widgets_registered',$plugin_public, 'init_elementor_widgets' );
220 $this->loader->add_action( 'elementor/elements/categories_registered', $plugin_public,'add_elementor_widget_categories' );
221 $this->loader->add_action('elementor/editor/before_enqueue_scripts', $plugin_public, 'elementor_icon_loader', 99999);
222
223 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
224 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
225
226
227 $this->loader->add_action( 'vc_before_init', $plugin_public, 'vc_before_init_actions' );
228
229
230 }
231
232 /**
233 * Run the loader to execute all of the hooks with WordPress.
234 *
235 * @since 1.0.0
236 */
237 public function run() {
238 $this->loader->run();
239 }
240
241 /**
242 * The name of the plugin used to uniquely identify it within the context of
243 * WordPress and to define internationalization functionality.
244 *
245 * @since 1.0.0
246 * @return string The name of the plugin.
247 */
248 public function get_plugin_name() {
249 return $this->plugin_name;
250 }
251
252 /**
253 * The reference to the class that orchestrates the hooks with the plugin.
254 *
255 * @since 1.0.0
256 * @return CBXGoogleMap_Loader Orchestrates the hooks of the plugin.
257 */
258 public function get_loader() {
259 return $this->loader;
260 }
261
262 /**
263 * Retrieve the version number of the plugin.
264 *
265 * @since 1.0.0
266 * @return string The version number of the plugin.
267 */
268 public function get_version() {
269 return $this->version;
270 }
271
272 }
273