PluginProbe
UpdraftCentral Dashboard / trunk
UpdraftCentral Dashboard vtrunk
0.8.33 0.7.2 0.7.3 0.7.4 0.8.0 0.8.1 0.8.10 0.8.11 0.8.12 0.8.13 0.8.14 0.8.15 0.8.16 0.8.17 0.8.18 0.8.19 0.8.2 0.8.20 0.8.21 0.8.22 0.8.23 0.8.24 0.8.25 0.8.26 0.8.27 All 51 releases
updraftcentral / modules / wpo / loader.php

loader.php in UpdraftCentral Dashboard trunk, at modules/wpo/loader.php

129 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('UD_CENTRAL_DIR')) die('Security check');
4
5 if (defined('UPDRAFTCENTRAL_ENABLE_WPO') && !UPDRAFTCENTRAL_ENABLE_WPO) return;
6
7 /**
8 * This class handles WP-Optimize management remotely
9 *
10 * Provides a way to access and update `WP-Optimize`, `Table Information` and `Settings` tabs
11 * of WP-Optimize plugin
12 */
13 class UpdraftCentral_Module_WPO {
14
15 const MODULE_NAME = 'wpo';
16
17 private $min_or_not;
18
19 /**
20 * UpdraftCentral_Module_WPO constructor.
21 *
22 * Adds required actions and filter hooks
23 */
24 public function __construct() {
25 add_action('updraftcentral_load_dashboard_js', array($this, 'load_dashboard_js'));
26 add_action('updraftcentral_load_dashboard_css', array($this, 'load_dashboard_css'));
27 add_action('updraftcentral_dashboard_post_navigation', array($this, 'dashboard_post_navigation'));
28 add_action('updraftcentral_site_row_after_buttons', array($this, 'site_row_after_buttons'));
29 add_filter('updraftcentral_main_navigation_items', array($this, 'main_navigation_items'));
30 add_filter('updraftcentral_udrclion', array($this, 'udrclion'));
31 add_filter('updraftcentral_template_directories', array($this, 'template_directories'));
32
33 $this->min_or_not = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
34 }
35
36 /**
37 * Enqueues WP-Optimize module's js files
38 *
39 * @param string $enqueue_version The version number
40 * @return void
41 */
42 public function load_dashboard_js($enqueue_version) {
43 wp_enqueue_script('updraftcentral-dashboard-activities-'.self::MODULE_NAME, UD_CENTRAL_URL.'/modules/'.self::MODULE_NAME.'/'.self::MODULE_NAME.$this->min_or_not.'.js', array('updraftcentral-dashboard', 'jquery'), $enqueue_version);
44
45 // Using tablesorter to help with organising the DB size on Table Information
46 // https://github.com/Mottie/tablesorter
47 wp_enqueue_script('tablesorter-js', UD_CENTRAL_URL.'/js/tablesorter/jquery.tablesorter'.$this->min_or_not.'.js', array('jquery'), $enqueue_version);
48
49 wp_enqueue_script('tablesorter-widgets-js', UD_CENTRAL_URL.'/js/tablesorter/jquery.tablesorter.widgets'.$this->min_or_not.'.js', array('jquery'), $enqueue_version);
50
51 wp_enqueue_script('jquery-serialize-json', UD_CENTRAL_URL.'/js/serialize-json/jquery.serializejson'.$this->min_or_not.'.js', array('jquery'), $enqueue_version);
52
53 // De-register to defeat any plugins that may have registered incompatible versions (e.g. WooCommerce 2.5 beta1 still has the Select 2 3.5 series)
54 wp_deregister_script('select2');
55 wp_deregister_style('select2');
56
57 $select2_version = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '4.0.3'.'.'.time() : '4.0.3';
58
59 wp_enqueue_script('select2', UD_CENTRAL_URL."/js/select2/select2".$this->min_or_not.".js", array('jquery'), $select2_version);
60 wp_enqueue_style('select2', UD_CENTRAL_URL."/css/select2/select2".$this->min_or_not.".css", array(), $select2_version);
61 }
62
63 /**
64 * Enqueues WP-Optimize module's css files
65 *
66 * @param string $enqueue_version The version number
67 * @return void
68 */
69 public function load_dashboard_css($enqueue_version) {
70 wp_enqueue_style('updraftcentral-dashboard-css-'.self::MODULE_NAME, UD_CENTRAL_URL.'/modules/'.self::MODULE_NAME.'/'.self::MODULE_NAME.$this->min_or_not.'.css', array('updraftcentral-dashboard-css'), $enqueue_version);
71
72 wp_enqueue_style('tablesorter-css', UD_CENTRAL_URL.'/css/tablesorter/theme.default.min.css', array(), $enqueue_version);
73 }
74
75 /**
76 * Loads WP-Optimize module's translations file
77 *
78 * @param array $localize The array with all the modules translations files
79 * @return array The updated array with translations
80 */
81 public function udrclion($localize) {
82 $localize[self::MODULE_NAME] = include(__DIR__.'/translations-dashboard.php');
83 $localize[self::MODULE_NAME]['images'] = trailingslashit(plugins_url('images', __FILE__));
84 return $localize;
85 }
86
87 /**
88 * Adds the buttons in the site row for WP-Optimize module
89 *
90 * @return void
91 */
92 public function site_row_after_buttons() {
93 UpdraftCentral()->include_template(self::MODULE_NAME.'/site-row-buttons.php');
94 }
95
96 /**
97 * Adds 'WP-Optimize' navigation item to main navigation
98 *
99 * @param array $items An array of module names as navigation items
100 * @return array Updated array with this module's name
101 */
102 public function main_navigation_items($items) {
103
104 $items[self::MODULE_NAME] = array('label' => __('WP-Optimize', 'updraftcentral'), 'sort_order' => 35);
105
106 return $items;
107 }
108
109 /**
110 * Adds site management buttons at the top
111 */
112 public function dashboard_post_navigation() {
113 UpdraftCentral()->include_template(self::MODULE_NAME.'/management-actions.php');
114 }
115
116 /**
117 * Adds WP-Optimize module's template directory
118 *
119 * @param array $template_directories The array with all modules template directories
120 * @return array The updated array with this module's template directory in it.
121 */
122 public function template_directories($template_directories) {
123 $template_directories[self::MODULE_NAME] = __DIR__.'/templates';
124 return $template_directories;
125 }
126 }
127
128 new UpdraftCentral_Module_WPO();
129