PluginProbe
WP Directory Kit / 1.4.8
WP Directory Kit v1.4.8
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / admin / class-wpdirectorykit-admin.php

class-wpdirectorykit-admin.php in WP Directory Kit 1.4.8, at admin/class-wpdirectorykit-admin.php

365 lines 15.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The admin-specific functionality of the plugin.
5 *
6 * @link listing-themes.com
7 * @since 1.0.0
8 *
9 * @package Wpdirectorykit
10 * @subpackage Wpdirectorykit/admin
11 */
12
13 /**
14 * The admin-specific functionality of the plugin.
15 *
16 * Defines the plugin name, version, and two examples hooks for how to
17 * enqueue the admin-specific stylesheet and JavaScript.
18 *
19 * @package Wpdirectorykit
20 * @subpackage Wpdirectorykit/admin
21 * @author listing-themes.com <dev@listing-themes.com>
22 */
23
24 if ( ! defined( 'ABSPATH' ) ) {
25 exit; // Exit if accessed directly.
26 }
27 class Wpdirectorykit_Admin {
28
29 /**
30 * The ID of this plugin.
31 *
32 * @since 1.0.0
33 * @access private
34 * @var string $plugin_name The ID of this plugin.
35 */
36 private $plugin_name;
37
38 /**
39 * The version of this plugin.
40 *
41 * @since 1.0.0
42 * @access private
43 * @var string $version The current version of this plugin.
44 */
45 private $version;
46
47 /**
48 * Initialize the class and set its properties.
49 *
50 * @since 1.0.0
51 * @param string $plugin_name The name of this plugin.
52 * @param string $version The version of this plugin.
53 */
54 public function __construct( $plugin_name, $version ) {
55
56 $this->plugin_name = $plugin_name;
57 $this->version = $version;
58
59 }
60
61 /**
62 * Register the stylesheets for the admin area.
63 *
64 * @since 1.0.0
65 */
66 public function enqueue_styles() {
67
68 /**
69 * This function is provided for demonstration purposes only.
70 *
71 * An instance of this class should be passed to the run() function
72 * defined in Wpdirectorykit_Loader as all of the hooks are defined
73 * in that particular class.
74 *
75 * The Wpdirectorykit_Loader will then create the relationship
76 * between the defined hooks and the functions defined in this
77 * class.
78 */
79
80 wp_register_style( 'wdk-treefield', WPDIRECTORYKIT_URL . 'public/js/wdk_treefield/treefield.css', array(), '1.0.0' );
81 wp_register_style( 'wdk-modal', WPDIRECTORYKIT_URL. 'public/css/wdk-modal.css', array(), $this->version, 'all');
82 wp_register_style( 'wdk-notify', WPDIRECTORYKIT_URL. 'public/css/wdk-notify.css', array(), $this->version, 'all');
83 wp_register_style( 'leaflet', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/leaflet.css', array(), '1.7.1', 'all' );
84 wp_register_style( 'leaflet-cluster-def', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/MarkerCluster.Default.css', array(), '1.7.1', 'all' );
85 wp_register_style( 'leaflet-cluster', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/MarkerCluster.css', array(), '1.7.1', 'all' );
86
87 wp_register_style( 'select2-select2', WPDIRECTORYKIT_URL. 'public/js/select2/css/select2.min.css', array(), '4.0.13', 'all' );
88 wp_register_style('jquery-confirm', WPDIRECTORYKIT_URL. 'public/js/jquery-confirm/css/jquery-confirm.css', array(), '3.3.4', 'all');
89
90 wp_register_style( 'wdk-treefield-dropdown', WPDIRECTORYKIT_URL. 'public/js/wdk_treefield_dropdown/wdk_treefield_dropdown.css', array(), '1.0', 'all' );
91
92 wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpdirectorykit-admin.css', array(), $this->version, 'all' );
93 wp_enqueue_style( $this->plugin_name.'-responsive', plugin_dir_url( __FILE__ ) . 'css/wpdirectorykit-admin-responsive.css', array(), $this->version, 'all' );
94 wp_register_style('jquery-ui', WPDIRECTORYKIT_URL. 'public/css/jquery-ui.css', array(), null );
95 }
96
97 /**
98 * Register the JavaScript for the admin area.
99 *
100 * @since 1.0.0
101 */
102 public function enqueue_scripts() {
103
104 /**
105 * This function is provided for demonstration purposes only.
106 *
107 * An instance of this class should be passed to the run() function
108 * defined in Wpdirectorykit_Loader as all of the hooks are defined
109 * in that particular class.
110 *
111 * The Wpdirectorykit_Loader will then create the relationship
112 * between the defined hooks and the functions defined in this
113 * class.
114 */
115
116 wp_register_script( 'wdk-treefield', WPDIRECTORYKIT_URL . 'public/js/wdk_treefield/treefield.js', array( 'jquery' ), false, false );
117 wp_register_script( 'wpmediaelement_file', WPDIRECTORYKIT_URL . 'admin/js/jquery.wpmediaelement_file.js', array( 'jquery' ), false, false );
118
119 wp_register_script( 'wdk-modal', WPDIRECTORYKIT_URL. 'public/js/wdk-modal.js', array( 'jquery' ), $this->version, false);
120 wp_register_script( 'wdk-notify', WPDIRECTORYKIT_URL. 'public/js/wdk-notify.js', array( 'jquery' ), $this->version, false);
121 wp_register_script( 'leaflet', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/leaflet.js', array( 'jquery' ), '1.7.1', false );
122
123 wp_register_script( 'leaflet-cluster', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/leaflet.markercluster.js', array( 'jquery' ), '1.7.1', false );
124
125
126 wp_register_script('select2-select2', WPDIRECTORYKIT_URL. 'public/js/select2/js/select2.min.js', array( 'jquery' ), '4.0.13', false );
127 wp_register_script('wdk-select2', WPDIRECTORYKIT_URL. 'public/js/wdk-select2.js', array( 'jquery' ), '4.0.13', false );
128
129 $params = array(
130 'ajax_url' => admin_url( 'admin-ajax.php' ),
131 'text' =>array(
132 'errorLoading' => esc_html__('The results could not be loaded.', 'wpdirectorykit'),
133 'loadingMore' => esc_html__('Loading more results…', 'wpdirectorykit'),
134 'noResults' => esc_html__('No results found', 'wpdirectorykit'),
135 'searching' => esc_html__('Searching…', 'wpdirectorykit'),
136 'removeAllItems' => esc_html__('Remove all items', 'wpdirectorykit'),
137 ),
138 );
139 wp_localize_script('wdk-select2', 'wdk_select2_script_parameters', $params);
140
141 wp_register_script('jquery-confirm', WPDIRECTORYKIT_URL. 'public/js/jquery-confirm/js/jquery-confirm.js', array( 'jquery' ), '3.3.4', false );
142 wp_register_script( 'wdk-dependfields-submitform', WPDIRECTORYKIT_URL. 'public/js/wdk-dependfields-submitform.js', array( 'jquery' ), false, false );
143
144 $params = array(
145 'ajax_url' => admin_url( 'admin-ajax.php' )
146 );
147 wp_register_script('wdk-treefield-dropdown', WPDIRECTORYKIT_URL. 'public/js/wdk_treefield_dropdown/wdk_treefield_dropdown.js', array( 'jquery' ), '1.0', false );
148 wp_localize_script( 'wdk-treefield-dropdown', 'script_parameters', $params);
149
150 wp_register_script( 'wdk-dependfields-edit', plugin_dir_url( __FILE__ ) . 'js/wdk-dependfields-edit.js', array( 'jquery' ), $this->version, false );
151 $params = array(
152 'ajax_url' => admin_url( 'admin-ajax.php' ),
153 );
154
155 wp_localize_script('wdk-dependfields-edit', 'script_dependfields_parameters', $params);
156
157 $params = array(
158 'ajax_url' => admin_url( 'admin-ajax.php' ),
159 'format_date' => wdk_convert_date_format_js(get_option('date_format')),
160 'format_datetime' => wdk_convert_date_format_js(get_option('date_format').' '.get_option('time_format')),
161 'format_date_js' => wdk_convert_date_format_jquery(get_option('date_format')),
162 'format_datetime_js' => wdk_convert_date_format_jquery(get_option('date_format').' '.get_option('time_format')),
163 );
164 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wpdirectorykit-admin.js', array( 'jquery' ), $this->version, false );
165 wp_localize_script( $this->plugin_name, 'script_parameters', $params);
166
167
168 }
169
170 /**
171 * Admin AJAX
172 */
173
174 public function ajax_admin()
175 {
176 global $Winter_MVC_WDK;
177
178 $page = '';
179 $function = '';
180
181 if(isset($_POST['page']))$page = sanitize_text_field($_POST['page']);
182 if(isset($_POST['function']))$function = sanitize_text_field($_POST['function']);
183
184 $Winter_MVC_WDK->load_controller($page, $function, array());
185 }
186
187 /**
188 * Admin Page Display
189 */
190 public function admin_page_display() {
191 global $Winter_MVC_WDK, $submenu, $menu;
192
193 $page = '';
194 $function = '';
195
196 if(isset($_GET['page']))$page = sanitize_text_field($_GET['page']);
197 if(isset($_GET['function']))$function = sanitize_text_field($_GET['function']);
198
199 if(substr($function,0,1) == '_') {
200 exit(esc_html__('blocked for public', 'wpdirectorykit'));
201 }
202
203 $Winter_MVC_WDK->load_controller($page, $function, array());
204 }
205
206 private function multilingual_register_strings()
207 {
208 if (!function_exists('PLL'))return;
209
210 global $Winter_MVC_WDK;
211 $Winter_MVC_WDK->model('field_m');
212 $Winter_MVC_WDK->model('category_m');
213 $Winter_MVC_WDK->model('location_m');
214
215 $fields = $Winter_MVC_WDK->field_m->get();
216
217 foreach($fields as $field)
218 {
219 if(!empty($field->field_label))
220 pll_register_string( 'wpdirectorykit', $field->field_label, 'wdk-fields');
221
222 if(!empty($field->values_list))
223 pll_register_string( 'wpdirectorykit', $field->values_list, 'wdk-fields');
224
225 if(!empty($field->hint))
226 pll_register_string( 'wpdirectorykit', $field->hint, 'wdk-fields');
227 }
228
229 $categories = $Winter_MVC_WDK->category_m->get_tree_table();
230
231 foreach($categories as $category)
232 {
233 pll_register_string( 'wpdirectorykit', $category->category_title, 'wdk-categories');
234 }
235
236 $locations = $Winter_MVC_WDK->location_m->get_tree_table();
237
238 foreach($locations as $location)
239 {
240 pll_register_string( 'wpdirectorykit', $location->location_title, 'wdk-locations');
241 }
242 }
243
244 /**
245 * To add Plugin Menu and Settings page
246 */
247 public function plugin_menu() {
248
249 ob_start();
250
251 $this->multilingual_register_strings();
252
253 //require_once WPDIRECTORYKIT_PATH . 'vendor/boo-settings-helper/class-boo-settings-helper.php';
254
255 add_menu_page(__('Directory Kit','wpdirectorykit'), __('Directory Kit','wpdirectorykit'),
256 'wdk_listings_manage', 'wdk', array($this, 'admin_page_display'),
257 //plugin_dir_url( __FILE__ ) . 'resources/logo.png',
258 'dashicons-category',
259 28 );
260
261 add_submenu_page('wdk',
262 __('Listings','wpdirectorykit'),
263 __('Listings','wpdirectorykit'),
264 'wdk_listings_manage', 'wdk', array($this, 'admin_page_display'));
265
266 add_submenu_page('wdk',
267 __('Add Listing','wpdirectorykit'),
268 __('Add Listing','wpdirectorykit'),
269 'wdk_listings_manage', 'wdk_listing', array($this, 'admin_page_display'));
270
271 add_submenu_page('wdk',
272 __('Fields','wpdirectorykit'),
273 __('Fields','wpdirectorykit'),
274 'wdk_listings_manage', 'wdk_fields', array($this, 'admin_page_display'));
275
276 if(get_option('wdk_is_category_enabled', FALSE))
277 add_submenu_page('wdk',
278 __('Categories','wpdirectorykit'),
279 __('Categories','wpdirectorykit'),
280 'wdk_listings_manage', 'wdk_category', array($this, 'admin_page_display'));
281
282 if(get_option('wdk_is_location_enabled', FALSE))
283 add_submenu_page('wdk',
284 __('Locations','wpdirectorykit'),
285 __('Locations','wpdirectorykit'),
286 'wdk_listings_manage', 'wdk_location', array($this, 'admin_page_display'));
287
288 add_submenu_page('wdk',
289 __('Search Form','wpdirectorykit'),
290 __('Search Form','wpdirectorykit'),
291 'wdk_listings_manage', 'wdk_searchform', array($this, 'admin_page_display'));
292
293 add_submenu_page('wdk',
294 __('Result Card','wpdirectorykit'),
295 __('Result Card','wpdirectorykit'),
296 'wdk_listings_manage', 'wdk_resultitem', array($this, 'admin_page_display'));
297
298 add_submenu_page('wdk',
299 __('Change Currency','wpdirectorykit'),
300 __('Change Currency','wpdirectorykit'),
301 'wdk_listings_manage', 'wdk_change_currency', array($this, 'admin_page_display'));
302
303 add_submenu_page('wdk',
304 __('Messages','wpdirectorykit'),
305 __('Messages','wpdirectorykit'),
306 'wdk_listings_manage', 'wdk_messages', array($this, 'admin_page_display'));
307
308 add_submenu_page('wdk',
309 __('Settings','wpdirectorykit'),
310 __('Settings','wpdirectorykit'),
311 'wdk_listings_manage', 'wdk_settings', array($this, 'admin_page_display'));
312
313 add_submenu_page('wdk',
314 __('Documentation','wpdirectorykit'),
315 __('Documentation','wpdirectorykit'),
316 'wdk_listings_manage', 'https://wpdirectorykit.com/documentation');
317
318 if(!file_exists(WPDIRECTORYKIT_PATH . 'premium_functions.php') || defined('WDK_FS_DISABLE'))
319 {
320
321 if(!file_exists(WP_PLUGIN_DIR.'/wdk-currency-conversion') || !is_plugin_active( 'wdk-currency-conversion/wdk-currency-conversion.php' ))
322 add_submenu_page('wdk',
323 __('Currencies Addon','wpdirectorykit'),
324 __('Currencies Addon','wpdirectorykit'),
325 'wdk_listings_manage', 'wdk_addons_currencies', array($this, 'admin_page_display'));
326
327 if(!file_exists(WP_PLUGIN_DIR.'/wdk-membership') || !is_plugin_active( 'wdk-membership/wdk-membership.php' ))
328 add_submenu_page('wdk',
329 __('Membership Addon','wpdirectorykit'),
330 __('Membership Addon','wpdirectorykit'),
331 'wdk_listings_manage', 'wdk_addons_membership', array($this, 'admin_page_display'));
332
333 if(!file_exists(WP_PLUGIN_DIR.'/wdk-bookings') || !is_plugin_active( 'wdk-bookings/wdk-bookings.php' ))
334 add_submenu_page('wdk',
335 __('Booking Addon','wpdirectorykit'),
336 __('Booking Addon','wpdirectorykit'),
337 'wdk_listings_manage', 'wdk_addons_bookings', array($this, 'admin_page_display'));
338
339 add_submenu_page('wdk',
340 __('More Addons','wpdirectorykit'),
341 __('More Addons','wpdirectorykit'),
342 'wdk_listings_manage', 'wdk_addons', array($this, 'admin_page_display'));
343
344 add_submenu_page('wdk',
345 __('Support Forum','wpdirectorykit'),
346 __('Support Forum','wpdirectorykit'),
347 'wdk_listings_manage', 'https://wordpress.org/support/plugin/wpdirectorykit/');
348
349 add_submenu_page('wdk',
350 __('Contact','wpdirectorykit'),
351 __('Contact','wpdirectorykit'),
352 'wdk_listings_manage', 'https://wpdirectorykit.com/contact.html');
353 }
354
355 $current_theme = wp_get_theme();
356
357 if( defined( 'WP_DEBUG' ) && WP_DEBUG && $current_theme->get( 'AuthorURI' ) == 'https://wpdirectorykit.com')
358 add_submenu_page('tools.php',
359 esc_html__('WDK Demo Import', 'wpdirectorykit'), esc_html__('WDK Demo Import', 'wpdirectorykit'), 'wdk_listings_manage', 'wdk_demo_import', array($this, 'admin_page_display'));
360
361
362 }
363
364 }
365