PluginProbe
UpdraftCentral Dashboard / 0.7.0
UpdraftCentral Dashboard v0.7.0
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 / notices / loader.php

loader.php in UpdraftCentral Dashboard 0.7.0, at modules/notices/loader.php

122 lines 4.3 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 /**
6 * This class handles Notices
7 */
8 class UpdraftCentral_Module_Notices {
9
10 const MODULE_NAME = 'notices';
11
12 /**
13 * UpdraftCentral_Module_Notices constructor.
14 *
15 * Adds required actions and filter hooks
16 */
17 public function __construct() {
18 add_action('updraftcentral_load_dashboard_css', array($this, 'load_dashboard_css'));
19 add_action('updraftcentral_dashboard_post_navigation', array($this, 'dashboard_post_navigation'));
20 add_action('updraftcentral_dashboard_pre_header', array($this, 'dashboard_pre_header'));
21 add_action('updraftcentral_dashboard_post_content', array($this, 'dashboard_post_content'));
22 add_filter('updraftcentral_main_navigation_items', array($this, 'main_navigation_items'));
23 add_filter('updraftcentral_template_directories', array($this, 'template_directories'));
24 add_action('updraftcentral_dashboard_ajaxaction_dismiss_notice', array($this, 'dashboard_ajaxaction_dismiss_notice'), 10, 2);
25
26 // Add available shortcuts for this module
27 add_filter('updraftcentral_keyboard_shortcuts', array($this, 'keyboard_shortcuts'));
28 }
29
30 /**
31 * Adds keyboard shortcut(s) available for this module
32 *
33 * @param array $shortcuts UpdraftCentral keyboard shortcuts
34 * @return array Updated UpdraftCentral keyboard shortcuts
35 */
36 public function keyboard_shortcuts($shortcuts) {
37 $shortcuts['upgrade'] = array(
38 'key' => 'L',
39 'description' => __('Upgrade license', 'updraftcentral'),
40 'action' => '', /* 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. In this case, this shortcut does not need any element to display its content since it automatically displays them. */
41 'menu' => self::MODULE_NAME, /* Name of the navigation item or menu. */
42 'site_required' => false /* Content is not associated or linked to a site. */
43 );
44
45 return $shortcuts;
46 }
47
48 /**
49 * Loads Notices module's template directory
50 *
51 * @param array $template_directories The array with all modules template directories
52 * @return array The updated array with this module's template directory in it.
53 */
54 public function template_directories($template_directories) {
55 $template_directories[self::MODULE_NAME] = __DIR__.'/templates';
56 return $template_directories;
57 }
58
59 /**
60 * Enqueues Notices module's css files
61 *
62 * @param string $enqueue_version The version number
63 * @return void
64 */
65 public function load_dashboard_css($enqueue_version) {
66 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);
67 }
68
69 /**
70 * Adds 'Upgrade' menu to main navigation
71 *
72 * @param array $items An array of module names as navigation items
73 * @return array Updated array with 'Upgrade' menu, if premium version of plugin not installed
74 */
75 public function main_navigation_items($items) {
76
77 if (!UpdraftCentral()->is_premium_installed() || (defined('UPDRAFTCENTRAL_NOTICES_SHOW_ALWAYS') && UPDRAFTCENTRAL_NOTICES_SHOW_ALWAYS)) {
78
79 $items[self::MODULE_NAME] = array('label' => __('Upgrade', 'updraftcentral'), 'sort_order' => 1000);
80
81 }
82
83 return $items;
84 }
85
86 /**
87 * Adds site management buttons at the top
88 */
89 public function dashboard_post_navigation() {
90 UpdraftCentral()->include_template(self::MODULE_NAME.'/management-actions.php');
91 }
92
93 /**
94 * Includes upgrade notice template
95 *
96 * @return void
97 */
98 public function dashboard_post_content() {
99 UpdraftCentral()->include_template(self::MODULE_NAME.'/notice-upgrade.php');
100 }
101
102 public function dashboard_pre_header() {
103 if (!class_exists('UpdraftCentral_Notices')) include_once(__DIR__.'/updraftcentral-notices.php');
104 global $updraftcentral_notices;
105 $notice = $updraftcentral_notices->do_notice(false, 'top', true);
106 if (!empty($notice)) {
107 UpdraftCentral()->log_notice($notice, 'info', 'updraftcentral_notice', array('extra_classes' => array('remove_after_load'), 'show_dismiss' => false));
108 }
109 }
110
111 /**
112 * Dismisses notice and updates option with time duration
113 *
114 * @return void
115 */
116 public function dashboard_ajaxaction_dismiss_notice() {
117 UpdraftCentral_Options::update_option('dismissed_general_notices_until', time() + 84*86400);
118 }
119 }
120
121 new UpdraftCentral_Module_Notices();
122