| 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 |
|
| 114 |
return $localize; |
| 115 |
} |
| 116 |
|
| 117 |
public function dashboard_post_navigation() { |
| 118 |
global $updraft_central; |
| 119 |
$updraft_central->include_template(self::MODULE_NAME.'/management-actions.php'); |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
$updraftcentral_module_updraftplus = new UpdraftCentral_Module_UpdraftPlus(); |
| 124 |
|