PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 1.0
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v1.0
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 1.6.1 All 66 releases
logtivity / Admin / Logtivity_Admin.php

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

83 lines 1.6 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 add_management_page( 'Logtivity', 'Logtivity', 'manage_options', 'logtivity', [$this, 'content'] );
23 }
24
25 /**
26 * Show the admin settings template
27 *
28 * @return void
29 */
30 public function content()
31 {
32 if ( !current_user_can( 'manage_options' ) ) {
33 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
34 }
35
36 $options = $this->options->getOptions();
37
38 echo logtivity_view('admin', compact('options'));
39 }
40
41 /**
42 * Update the settings
43 *
44 * @return WP_Redirect
45 */
46 public function update()
47 {
48 if (!wp_verify_nonce( $_POST['logtivity_update_settings'], 'logtivity_update_settings' ))
49 {
50 wp_safe_redirect( $this->settingsPageUrl() );
51 exit;
52 return;
53 }
54
55 $user = new Logtivity_Wp_User;
56
57 if (!$user->hasRole('administrator')) {
58 wp_safe_redirect( $this->settingsPageUrl() );
59 exit;
60 return;
61 }
62
63 $this->options->update();
64
65 wp_safe_redirect( $this->settingsPageUrl() );
66 exit;
67 }
68
69 /**
70 * Get the url to the settings page
71 *
72 * @return string
73 */
74 public function settingsPageUrl()
75 {
76 return admin_url('tools.php?page=logtivity');
77 }
78
79 }
80
81 $Logtivity_Admin = new Logtivity_Admin;
82
83