PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 1.10.0
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v1.10.0
3.3.9 3.3.8 trunk 1.0 1.1.0 1.10.0 1.11.0 1.11.1 1.12.0 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.2.0 1.20.0 1.20.1 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 All 67 releases
logtivity / Admin / Logtivity_Admin.php

Logtivity_Admin.php in Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity 1.10.0, at Admin/Logtivity_Admin.php

120 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Logtivity_Admin
4 {
5 protected $options;
6
7 public function __construct()
8 {
9 add_action( 'admin_menu', [$this, 'registerOptionsPage'] );
10
11 add_action( 'wp_ajax_logtivity_update_settings', [$this, 'update']);
12 add_action( 'wp_ajax_nopriv_logtivity_update_settings', [$this, 'update']);
13
14 $this->options = new Logtivity_Options;
15 }
16
17 /**
18 * Register the settings page
19 */
20 public function registerOptionsPage()
21 {
22 if (!apply_filters('logtivity_hide_from_menu', false)) {
23 add_menu_page(
24 'Logtivity',
25 'Logtivity',
26 'manage_options',
27 'logtivity',
28 [$this, 'showLogIndexPage'],
29 'dashicons-chart-area',
30 26
31 );
32 }
33
34 if (!apply_filters('logtivity_hide_settings_page', false)) {
35 add_submenu_page(
36 'logtivity',
37 'Logtivity Settings',
38 'Settings',
39 'manage_options',
40 'logtivity'.'-settings',
41 [$this, 'showLogtivitySettingsPage']
42 );
43 }
44 }
45
46 /**
47 * Show the admin log index
48 *
49 * @return void
50 */
51 public function showLogIndexPage()
52 {
53 if ( !current_user_can( 'manage_options' ) ) {
54 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
55 }
56
57 $options = $this->options->getOptions();
58
59 echo logtivity_view('log-index', compact('options'));
60 }
61
62 /**
63 * Show the admin settings template
64 *
65 * @return void
66 */
67 public function showLogtivitySettingsPage()
68 {
69 if ( !current_user_can( 'manage_options' ) ) {
70 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
71 }
72
73 $options = $this->options->getOptions();
74
75 echo logtivity_view('settings', compact('options'));
76 }
77
78 /**
79 * Update the settings
80 *
81 * @return WP_Redirect
82 */
83 public function update()
84 {
85 if (!wp_verify_nonce( $_POST['logtivity_update_settings'], 'logtivity_update_settings' ))
86 {
87 wp_safe_redirect( $this->settingsPageUrl() );
88 exit;
89 return;
90 }
91
92 $user = new Logtivity_Wp_User;
93
94 if (!$user->hasRole('administrator')) {
95 wp_safe_redirect( $this->settingsPageUrl() );
96 exit;
97 return;
98 }
99
100 $this->options->update();
101
102 wp_safe_redirect( $this->settingsPageUrl() );
103 exit;
104 }
105
106 /**
107 * Get the url to the settings page
108 *
109 * @return string
110 */
111 public function settingsPageUrl()
112 {
113 return admin_url('admin.php?page=logtivity-settings');
114 }
115
116 }
117
118 $Logtivity_Admin = new Logtivity_Admin;
119
120