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 / pages / dashboard.php

dashboard.php in UpdraftCentral Dashboard trunk, at pages/dashboard.php

105 lines 3.6 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 file bootstraps the loading of the 'dashboard' (i.e. main) page.
7 * By this stage, it has already been verified that the user is logged in, and has a user role allowed to view pages
8 */
9
10 $action_command = !empty($_REQUEST['action']) ? $_REQUEST['action'] : 'showmain'; //phpcs:ignore WordPress.Security - sanity checking happens immediately below
11
12 if (!preg_match('/^[_a-z]+$/', $action_command) || !file_exists(UD_CENTRAL_DIR.'/actions/'.$action_command.'.php')) {
13 error_log('UDRC: security check failed: unknown action ('.serialize($action_command).')');
14 die('Security check');
15 }
16
17 require_once UD_CENTRAL_DIR.'/actions/0abstract.php';
18 require_once UD_CENTRAL_DIR.'/actions/'.$action_command.'.php';
19
20 $action_class = 'UpdraftRC_Action_'.$action_command;
21
22 if (!class_exists($action_class)) {
23 error_log("Action class $action_class not found");
24
25 return;
26 }
27
28 $updraft_central = UpdraftCentral();
29
30 $action = new $action_class();
31
32 // Nonce checks: required by default
33 if (false !== $action->check_nonce && isset($_REQUEST['nonce']) && !wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['nonce'])), $action->check_nonce)) die('Security check');
34
35 // Enqueue JavaScript and CSS
36 $updraft_central->load_dashboard_js();
37 $updraft_central->load_dashboard_css();
38
39 // 'container' or 'container-fluid' class needed by Bootstrap
40 echo '<div id="updraftcentral_dashboard_wrapper"><div id="updraftcentral_dashboard" class="updraftcentral_dashboard container-fluid">';
41
42 // A fixed page header? e.g. Show them how many licences they've got spare, and how to buy more.
43
44 // User entitlement checks (N.B. user logged in and user role has already been checked)
45 if (!$action->auth_check()) {
46 if ($action->show_header) $updraft_central->include_template('dashboard/header.php');
47 $updraft_central->include_template('dashboard/not-authorised.php');
48
49 return;
50 }
51
52 update_user_meta(get_current_user_id(), 'updraftcentral_dashboard_last_loaded', time());
53
54 // Get the items for the main menu
55 $main_navigation_items = apply_filters('updraftcentral_main_navigation_items', array(
56 'sites' => array('label' => __('Sites', 'updraftcentral'), 'sort_order' => 10)
57 ));
58 uasort($main_navigation_items, array($updraft_central, 'sort_navigation_items'));
59
60 $licence_manager = $updraft_central->user->get_licence_manager();
61
62 $updraft_central->include_template('dashboard/navigation.php', false, array(
63 'how_many_licences_available' => $licence_manager->how_many_licences_available(),
64 'how_many_licences_in_use' => $licence_manager->how_many_licences_in_use(),
65 'common_urls' => $updraft_central->get_common_urls(),
66 ));
67
68 // Start dashboard layout here open container
69 echo '<div id="updraft-central-content-container">';
70
71 // Include the sidebar
72 $updraft_central->include_template('dashboard/sidebar-navigation.php', false, array(
73 'main_navigation_items' => $main_navigation_items,
74 ));
75
76 // Open the content area
77 echo '<div id="updraft-central-content">';
78
79 do_action('updraftcentral_dashboard_post_navigation');
80
81 $updraft_central->include_template('sites/management-actions.php');
82
83 do_action('updraftcentral_dashboard_pre_header');
84
85 if ($action->show_header) $updraft_central->include_template('dashboard/header.php');
86
87 do_action('updraftcentral_dashboard_pre_content');
88
89 if (method_exists($action, 'render')) {
90 $action->render();
91 }
92
93 do_action('updraftcentral_dashboard_post_content');
94
95 // close content area here
96 echo '</div>';
97 // close container here and end dashboard layout
98 echo '</div>';
99
100 // Include modal dialog
101 $updraft_central->include_template('dashboard/modal.php');
102
103 // Close updraftcentral_dashboard div
104 echo '</div></div>';
105