PluginProbe
UpdraftCentral Dashboard / 0.8.26
UpdraftCentral Dashboard v0.8.26
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 / events / loader.php

loader.php in UpdraftCentral Dashboard 0.8.26, at modules/events/loader.php

123 lines 4.2 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 displays recorded Events
7 */
8 class UpdraftCentral_Module_Events {
9
10 const MODULE_NAME = 'events';
11
12 private $min_or_not;
13
14 /**
15 * UpdraftCentral_Module_Events constructor.
16 *
17 * Adds required actions and filter hooks
18 */
19 public function __construct() {
20 add_action('updraftcentral_load_dashboard_css', array($this, 'load_dashboard_css'));
21 add_action('updraftcentral_dashboard_post_navigation', array($this, 'dashboard_post_navigation'));
22 add_action('updraftcentral_dashboard_post_content', array($this, 'dashboard_post_content'));
23 add_filter('updraftcentral_main_navigation_items', array($this, 'main_navigation_items'));
24 add_filter('updraftcentral_template_directories', array($this, 'template_directories'));
25 add_action('updraftcentral_load_dashboard_js', array($this, 'load_dashboard_js'));
26 add_filter('updraftcentral_udrclion', array($this, 'udrclion'));
27
28 // Add available shortcuts for this module
29 add_filter('updraftcentral_keyboard_shortcuts', array($this, 'keyboard_shortcuts'));
30
31 $this->min_or_not = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
32 }
33
34 /**
35 * Adds keyboard shortcut(s) available for this module
36 *
37 * @param array $shortcuts UpdraftCentral keyboard shortcuts
38 * @return array Updated UpdraftCentral keyboard shortcuts
39 */
40 public function keyboard_shortcuts($shortcuts) {
41 $shortcuts['events'] = array(
42 'key' => 'E',
43 'description' => __('Events', 'updraftcentral'),
44 '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. */
45 'menu' => self::MODULE_NAME, /* Name of the navigation item or menu. */
46 'site_required' => false /* Content is not associated or linked to a site. */
47 );
48
49 return $shortcuts;
50 }
51
52 /**
53 * Loads Events module's template directory
54 *
55 * @param array $template_directories The array with all modules template directories
56 * @return array The updated array with this module's template directory in it.
57 */
58 public function template_directories($template_directories) {
59 $template_directories[self::MODULE_NAME] = __DIR__.'/templates';
60 return $template_directories;
61 }
62
63 /**
64 * Enqueues Events module's js files
65 *
66 * @param string $enqueue_version The version number
67 * @return void
68 */
69 public function load_dashboard_js($enqueue_version) {
70 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);
71 }
72
73 /**
74 * Enqueues Events module's css files
75 *
76 * @param string $enqueue_version The version number
77 * @return void
78 */
79 public function load_dashboard_css($enqueue_version) {
80 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);
81 }
82
83 /**
84 * Loads Events module's translations file
85 *
86 * @param array $localize The array with all the modules translations files
87 * @return array The updated array with translations
88 */
89 public function udrclion($localize) {
90 $localize[self::MODULE_NAME] = include(__DIR__.'/translations-dashboard.php');
91 return $localize;
92 }
93
94 /**
95 * Adds 'Events' menu to main navigation
96 *
97 * @param array $items An array of module names as navigation items
98 * @return array Updated array with 'Upgrade' menu, if premium version of plugin not installed
99 */
100 public function main_navigation_items($items) {
101 $items[self::MODULE_NAME] = array('label' => __('Events', 'updraftcentral'), 'sort_order' => 999);
102 return $items;
103 }
104
105 /**
106 * Adds site management buttons at the top
107 */
108 public function dashboard_post_navigation() {
109 UpdraftCentral()->include_template(self::MODULE_NAME.'/management-actions.php');
110 }
111
112 /**
113 * Includes events table template
114 *
115 * @return void
116 */
117 public function dashboard_post_content() {
118 UpdraftCentral()->include_template(self::MODULE_NAME.'/events-table.php');
119 }
120 }
121
122 new UpdraftCentral_Module_Events();
123