-
Notifications
You must be signed in to change notification settings - Fork 8
/
client-dash.php
450 lines (383 loc) · 11.5 KB
/
client-dash.php
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
<?php
/**
* Client Dash
*
* @package ClientDash
* @author Real Big Plugins
* @license GPL2
*
* Plugin Name: Client Dash
* Description: Creating a more intuitive admin interface for clients.
* Version: 2.2.1
* Requires at least: 4.8.0
* Requires PHP: 5.3.0
* Author: Real Big Plugins
* Author URI: https://realbigplugins.com
* Text Domain: client-dash
* Domain Path: /languages
* License: GPL2
* License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* @package ClientDash
*/
defined( 'ABSPATH' ) || die;
if ( ! class_exists( 'ClientDash' ) ) {
define( 'CLIENTDASH_VERSION', '2.2.1' );
define( 'CLIENTDASH_DIR', plugin_dir_path( __FILE__ ) );
define( 'CLIENTDASH_URI', plugins_url( '', __FILE__ ) );
/**
* Class ClientDash
*
* The main plugin class.
*
* @since 2.0.0
*/
class ClientDash {
/**
* Database functions.
*
* @since 2.0.0
*
* @var ClientDash_DB
*/
public $db;
/**
* api functions.
*
* @since 2.0.0
*
* @var ClientDash_API
*/
public $api;
/**
* RBM Field Helpers instance.
*
* @since 2.0.0
*
* @var RBM_FieldHelpers
*/
public $field_helpers;
/**
* RBP Support instance.
*
* @since 2.0.0
*
* @var RBP_Support
*/
public $support;
/**
* Handles the plugin upgrades.
*
* @since 2.0.0
*
* @var ClientDash_Upgrade
*/
public $upgrade;
/**
* Handles the plugin pages.
*
* @since 2.0.0
*
* @var ClientDash_PluginPages
*/
public $pluginpages;
/**
* Handles the plugin settings.
*
* @since 2.0.0
*
* @var ClientDash_Settings
*/
public $settings;
/**
* Loads the Client Dash Customizer.
*
* @since 2.0.0
*
* @var ClientDash_Customize
*/
public $customize;
/**
* Modifies the admin from customizations.
*
* @since 2.0.0
*
* @var ClientDash_Modify
*/
public $modify;
/**
* Handles Helper Pages.
*
* @since 2.0.0
*
* @var ClientDash_Helper_Pages
*/
public $helper_pages;
public function __wakeup() {
}
public function __clone() {
}
/**
* Call this method to get singleton
*
* @since 2.0.0
*
* @return ClientDash()
*/
public static function instance() {
static $instance = null;
if ( $instance === null ) {
$instance = new ClientDash();
}
return $instance;
}
/**
* ClientDash constructor.
*
* @since 2.0.0
*/
function __construct() {
$this->require_necessities();
$this->legacy_apis();
$this->setup_fieldhelpers();
add_action( 'init', array( $this, 'register_assets' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'action_links' ) );
}
/**
* Requires and loads required files.
*
* @since 2.0.0
* @access private
*/
private function require_necessities() {
require_once CLIENTDASH_DIR . 'core/clientdash-functions.php';
require_once CLIENTDASH_DIR . 'core/class-clientdash-upgrade.php';
require_once CLIENTDASH_DIR . 'core/class-clientdash-db.php';
require_once CLIENTDASH_DIR . 'core/api/class-clientdash-api.php';
require_once CLIENTDASH_DIR . 'core/customize/class-clientdash-customize.php';
require_once CLIENTDASH_DIR . 'core/helper-pages/class-clientdash-helper-pages.php';
$this->upgrade = new ClientDash_Upgrade();
// Don't load Client Dash unless fully upgraded
if ( $this->upgrade->needs_update() ) {
return;
}
$this->db = new ClientDash_DB();
$this->api = new ClientDash_API();
$this->customize = new ClientDash_Customize();
$this->helper_pages = new ClientDash_Helper_Pages();
if ( is_admin() ) {
require_once CLIENTDASH_DIR . 'core/plugin-pages/class-clientdash-pluginpages.php';
require_once CLIENTDASH_DIR . 'core/plugin-pages/class-clientdash-settings.php';
require_once CLIENTDASH_DIR . 'core/class-clientdash-modify.php';
$this->pluginpages = new ClientDash_PluginPages();
$this->settings = new ClientDash_Settings();
$this->modify = new ClientDash_Modify();
}
}
/**
* Includes and sets up everything required to maintain rough support for legacy extension APIs.
*
* @since 2.0.0
* @access private
*/
private function legacy_apis() {
global $ClientDash_Core_Page_Settings_Tab_Widgets;
require_once CLIENTDASH_DIR . 'core/legacy-extension-apis/clientdash-menus-api.php';
require_once CLIENTDASH_DIR . 'core/legacy-extension-apis/clientdash-widgets-api.php';
require_once CLIENTDASH_DIR . 'core/legacy-extension-apis/clientdash-settings-api.php';
require_once CLIENTDASH_DIR . 'core/legacy-extension-apis/class-clientdash-core-page-settings-tab-widgets.php';
$ClientDash_Core_Page_Settings_Tab_Widgets = new ClientDash_Core_Page_Settings_Tab_Widgets();
}
/**
* Initializes Field Helpers.
*
* @since 2.0.0
* @access private
*/
private function setup_fieldhelpers() {
require_once CLIENTDASH_DIR . 'core/clientdash-fieldhelper-functions.php';
require_once CLIENTDASH_DIR . 'core/library/rbm-field-helpers/rbm-field-helpers.php';
$this->field_helpers = new RBM_FieldHelpers( array(
'ID' => 'cd',
'l10n' => array(
'field_table' => array(
'delete_row' => __( 'Delete Row', 'client-dash' ),
'delete_column' => __( 'Delete Column', 'client-dash' ),
),
'field_select' => array(
'no_options' => __( 'No select options.', 'client-dash' ),
'error_loading' => __( 'The results could not be loaded', 'client-dash' ),
/* translators: %d is number of characters over input limit */
'input_too_long' => __( 'Please delete %d character(s)', 'client-dash' ),
/* translators: %d is number of characters under input limit */
'input_too_short' => __( 'Please enter %d or more characters', 'client-dash' ),
'loading_more' => __( 'Loading more results...', 'client-dash' ),
/* translators: %d is maximum number items selectable */
'maximum_selected' => __( 'You can only select %d item(s)', 'client-dash' ),
'no_results' => __( 'No results found', 'client-dash' ),
'searching' => __( 'Searching...', 'client-dash' ),
),
'field_repeater' => array(
'collapsable_title' => __( 'New Row', 'client-dash' ),
'confirm_delete' => __( 'Are you sure you want to delete this element?', 'client-dash' ),
'delete_item' => __( 'Delete', 'client-dash' ),
'add_item' => __( 'Add', 'client-dash' ),
),
'field_media' => array(
'button_text' => __( 'Upload / Choose Media', 'client-dash' ),
'button_remove_text' => __( 'Remove Media', 'client-dash' ),
'window_title' => __( 'Choose Media', 'client-dash' ),
),
'field_checkbox' => array(
'no_options_text' => __( 'No options available.', 'client-dash' ),
),
),
) );
}
/**
* Registers plugin assets.
*
* @since 2.0.0
* @access private
*/
function register_assets() {
wp_register_style(
'clientdash-admin',
CLIENTDASH_URI . '/assets/dist/css/clientdash-admin.min.css',
array(),
defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : CLIENTDASH_VERSION
);
wp_register_script(
'clientdash-admin',
CLIENTDASH_URI . '/assets/dist/js/clientdash-admin.min.js',
array( 'jquery' ),
defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : CLIENTDASH_VERSION,
true
);
// Customize assets
wp_register_style(
'clientdash-customize',
CLIENTDASH_URI . '/assets/dist/css/clientdash-customize.min.css',
array(),
defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : CLIENTDASH_VERSION
);
wp_register_style(
'clientdash-customize-inpreview',
CLIENTDASH_URI . '/assets/dist/css/clientdash-customize-inpreview.min.css',
array(),
defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : CLIENTDASH_VERSION
);
wp_register_script(
'clientdash-customize',
CLIENTDASH_URI . '/assets/dist/js/clientdash-customize.min.js',
array(),
defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : CLIENTDASH_VERSION,
true
);
wp_register_script(
'clientdash-customize-inpreview',
CLIENTDASH_URI . '/assets/dist/js/clientdash-customize-inpreview.min.js',
array(),
defined( 'WP_DEBUG' ) && WP_DEBUG ? time() : CLIENTDASH_VERSION
);
wp_localize_script( 'clientdash-admin', 'ClientDash_Data', array(
'nonce' => wp_create_nonce( 'clientdash_nonce' ),
'l10n' => array(
'reset_settings_confirm' => __( 'This will reset ALL Client Dash settings permanently. This can NOT be undone. Are you sure you want to proceed?', 'client-dash' ),
'change' => __( 'Change', 'client-dash' ),
'close' => __( 'Close', 'client-dash' ),
'saving' => __( 'Saving...', 'client-dash' ),
),
) );
wp_localize_script( 'clientdash-customize-inpreview', 'ClientDashCustomizeInPreview_Data', array(
'domain' => get_bloginfo( 'url' ),
'l10n' => array(
'preview_only' => __( 'Preview Only', 'clientdash' ),
),
) );
}
/**
* Enqueues plugin assets.
*
* @since 2.0.0
* @access private
*/
function enqueue_assets() {
wp_enqueue_style( 'clientdash-select2' );
wp_enqueue_script( 'clientdash-select2' );
wp_enqueue_style( 'clientdash-admin' );
wp_enqueue_script( 'clientdash-admin' );
}
/**
* Adds more action links to the plugin row.
*
* @since 2.0.0
* @access private
*
* @param array $links
*
* @return array
*/
function action_links( $links ) {
$links['settings'] = '<a href="' . admin_url( 'admin.php?page=clientdash_settings' ) . '">' .
__( 'Settings', 'client-dash' ) . '</a>';
$links['more'] = '<a href="http://realbigplugins.com/?utm_source=Client%20Dash&utm_medium=Plugins%20list%20link&utm' .
'_campaign=Client%20Dash%20Plugin" target="_blank">' . __( 'More Real Big Plugins', 'client-dash' ) .
'</a>';
$links['subscribe'] = '<a href="http://realbigplugins.com/subscribe/?utm_source=Client%20Dash&utm_medium=Plugins%20list%' .
'20link&utm_campaign=Client%20Dash%20Plugin" target="_blank">' . __( 'Subscribe', 'client-dash' ) .
'</a>';
return $links;
}
/**
* Adds a content section.
*
* @deprecated
*/
public function add_content_section( $section ) {
}
/**
* Strips out spaces and dashes and replaces them with underscores. Also
* translates to lowercase.
*
* @deprecated
*
* @param string $name The name to be translated.
*
* @return string Translated ID.
*/
public static function translate_name_to_id( $name ) {
return strtolower( str_replace( array( ' ', '-' ), '_', $name ) );
}
/**
* Checks to see if we're on a specific page and tab.
*
* @deprecated
*
* @param string $page The page to check.
* @param bool /string $tab If supplied, will also check that the given tab is active.
*
* @return bool True of on the page (and tab), false otherwise.
*/
public static function is_cd_page( $page, $tab = false ) {
return false;
}
}
// Load the bootstrapper
require_once CLIENTDASH_DIR . 'client-dash-bootstrapper.php';
new ClientDash_BootStrapper();
// Installation
require_once CLIENTDASH_DIR . 'core/class-clientdash-install.php';
register_activation_hook( __FILE__, array( 'ClientDash_Install', 'install' ) );
/**
* Gets/loads the main plugin class.
*
* @since 2.0.0
*
* @return ClientDash
*/
function ClientDash() {
return ClientDash::instance();
}
}