PluginProbe
UpdraftCentral Dashboard / 0.8.21
UpdraftCentral Dashboard v0.8.21
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 / updraftplus / loader.php

loader.php in UpdraftCentral Dashboard 0.8.21, at modules/updraftplus/loader.php

180 lines 7.0 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 class UpdraftCentral_Module_UpdraftPlus {
6 const MODULE_NAME = 'updraftplus';
7
8 public function __construct() {
9 add_action('updraftcentral_load_dashboard_js', array($this, 'load_dashboard_js'));
10 add_action('updraftcentral_load_dashboard_css', array($this, 'load_dashboard_css'));
11 add_filter('updraftcentral_udrclion', array($this, 'udrclion'));
12 add_action('updraftcentral_dashboard_post_navigation', array($this, 'dashboard_post_navigation'));
13 add_filter('updraftcentral_main_navigation_items', array($this, 'main_navigation_items'));
14 add_action('updraftcentral_site_row_after_buttons', array($this, 'site_row_after_buttons'));
15 add_filter('updraftcentral_template_directories', array($this, 'template_directories'));
16
17 // Add available shortcuts for this module
18 add_filter('updraftcentral_keyboard_shortcuts', array($this, 'keyboard_shortcuts'));
19 }
20
21 /**
22 * Adds keyboard shortcut(s) available for this module
23 *
24 * @param array $shortcuts UpdraftCentral keyboard shortcuts
25 * @return array Updated UpdraftCentral keyboard shortcuts
26 */
27 public function keyboard_shortcuts($shortcuts) {
28
29 /* Backup */
30 $shortcuts['backup_site'] = array(
31 'key' => 'B',
32 'description' => __('Backup site', 'updraftcentral'),
33 'action' => 'updraftcentral_site_backup_now', // ID or class name or a jQuery selector or a callback function (only applicable when registered from javascript). Element to trigger to load the content.
34 'menu' => 'backups', // Name of the navigation item or menu, since MODULE_NAME name isn't the same with the navigation item name we can't use that.
35 'popup' => true // Indicates whether this action generates a popup window. Will clear the extracontents container before showing the popup to avoid confusion when displaying content to the user.
36 );
37
38 /* Backup Increment */
39 $shortcuts['backup_site_increment'] = array(
40 'key' => 'I',
41 'description' => __('Backup site increment', 'updraftcentral'),
42 'action' => 'updraftcentral_site_backup_now_increment', // ID or class name or a jQuery selector or a callback function (only applicable when registered from javascript). Element to trigger to load the content.
43 'menu' => 'backups', // Name of the navigation item or menu, since MODULE_NAME name isn't the same with the navigation item name we can't use that.
44 'popup' => true // Indicates whether this action generates a popup window. Will clear the extracontents container before showing the popup to avoid confusion when displaying content to the user.
45 );
46
47 /* Existing Backups */
48 $shortcuts['existing_backups'] = array(
49 'key' => 'E',
50 'description' => __('Existing backups', 'updraftcentral'),
51 'action' => 'updraftcentral_site_backups_manage',
52 'menu' => 'backups'
53 );
54
55 /* Settings */
56 $shortcuts['backup_settings'] = array(
57 'key' => 'Z',
58 'description' => __('Backup settings', 'updraftcentral'),
59 'action' => 'updraftcentral_site_backup_settings',
60 'menu' => 'backups'
61 );
62
63 /* Site Configuration and Sites section */
64 $shortcuts['site_configuration'] = array(
65 'key' => 'X',
66 'description' => __('Site configuration', 'updraftcentral'),
67 'action' => 'div.updraft_site_actions span.updraftcentral_site_editdescription > span',
68 'menu' => '' /* If empty, defaults to "Sites" section. Since site configuration runs across all sections/tabs with the same content to load. */
69 );
70
71 $shortcuts['sites'] = array(
72 'key' => 'S',
73 'description' => __('Go back to Sites', 'updraftcentral'),
74 'action' => '',
75 'menu' => 'sites'
76 );
77
78 return $shortcuts;
79 }
80
81 public function template_directories($template_directories) {
82 $template_directories[self::MODULE_NAME] = __DIR__.'/templates';
83
84 return $template_directories;
85 }
86
87 public function site_row_after_buttons() {
88 UpdraftCentral()->include_template(self::MODULE_NAME.'/site-row-buttons.php');
89 }
90
91 public function load_dashboard_css($enqueue_version) {
92 wp_enqueue_style('jquery-labelauty', UD_CENTRAL_URL.'/modules/'.self::MODULE_NAME.'/jquery-labelauty.css', array(), '20160622-ud');
93 wp_enqueue_style('updraftcentral-dashboard-css-'.self::MODULE_NAME, UD_CENTRAL_URL.'/modules/'.self::MODULE_NAME.'/'.self::MODULE_NAME.'.css', array('updraftcentral-dashboard-css'), $enqueue_version);
94 }
95
96 public function load_dashboard_js($enqueue_version) {
97 $min_or_not = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
98
99 // Code on top of the framework for doing actual work
100 wp_register_script('jquery-labelauty', UD_CENTRAL_URL.'/modules/'.self::MODULE_NAME.'/jquery-labelauty.js', array('jquery'), '20150925');
101
102 wp_enqueue_script('updraftcentral-dashboard-activities-'.self::MODULE_NAME, UD_CENTRAL_URL.'/modules/'.self::MODULE_NAME.'/'.self::MODULE_NAME.$min_or_not.'.js', array('updraftcentral-dashboard', 'jquery-labelauty'), $enqueue_version);
103 }
104
105 public function main_navigation_items($items) {
106 $items['backups'] = array('label' => __('Backups', 'updraftcentral'), 'sort_order' => 20);
107
108 return $items;
109 }
110
111 public function udrclion($localize) {
112 $localize['updraftplus'] = include __DIR__.'/translations-dashboard.php';
113 $localize['updraftplus']['conditional_logic'] = array(
114 'day_of_the_week_options' => $this->list_days_of_the_week(),
115 'logic_options' => array(
116 array(
117 'label' => __('on every backup', 'updraftcentral'),
118 'value' => '',
119 ),
120 array(
121 'label' => __('if any of the following conditions are matched:', 'updraftcentral'),
122 'value' => 'any',
123 ),
124 array(
125 'label' => __('if all of the following conditions are matched:', 'updraftcentral'),
126 'value' => 'all',
127 ),
128 ),
129 'operand_options' => array(
130 array(
131 'label' => __('Day of the week', 'updraftcentral'),
132 'value' => 'day_of_the_week',
133 ),
134 array(
135 'label' => __('Day of the month', 'updraftcentral'),
136 'value' => 'day_of_the_month',
137 ),
138 ),
139 'operator_options' => array(
140 array(
141 'label' => __('is', 'updraftcentral'),
142 'value' => 'is',
143 ),
144 array(
145 'label' => __('is not', 'updraftcentral'),
146 'value' => 'is_not',
147 ),
148 ),
149 );
150
151 return $localize;
152 }
153
154 public function dashboard_post_navigation() {
155 global $updraft_central;
156 $updraft_central->include_template(self::MODULE_NAME.'/management-actions.php');
157 }
158
159 /**
160 * Return a listing of days of the week
161 *
162 * @param Boolean $respect_start_of_week whether to use the WordPress's start_of_week setting
163 * @return Array the days of the week
164 */
165 private function list_days_of_the_week($respect_start_of_week = true) {
166 global $wp_locale;
167 $days_of_the_week = array();
168 $start = $respect_start_of_week ? get_option('start_of_week', 1) : 1;
169 for ($i = $start; $i < $start + 7; $i++) {
170 $days_of_the_week[] = array(
171 'index' => $i % 7,
172 'value' => $wp_locale->get_weekday($i % 7),
173 );
174 }
175 return $days_of_the_week;
176 }
177 }
178
179 $updraftcentral_module_updraftplus = new UpdraftCentral_Module_UpdraftPlus();// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- Unused variable $updraftcentral_module_updraftplus
180