PluginProbe
WP Crontrol / trunk
WP Crontrol vtrunk
1.21.2 trunk 0.1 0.2 0.3 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.1 1.10.0 1.11.0 1.12.0 1.12.1 1.13.0 1.13.1 1.13.2 1.14.0 1.15.0 1.15.1 1.15.2 1.15.3 1.16.0 1.16.1 1.16.2 All 57 releases
wp-crontrol / src / Context / WordPressUserContext.php

WordPressUserContext.php in WP Crontrol trunk, at src/Context/WordPressUserContext.php

78 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WordPress user capability context implementation.
4 *
5 * @package wp-crontrol
6 */
7
8 namespace Crontrol\Context;
9
10 /**
11 * UserContext implementation that checks WordPress user capabilities.
12 *
13 * This is the production implementation that maps to WordPress capabilities.
14 * Currently uses edit_files for PHP cron events and manage_options for
15 * URL and standard cron events. More granular capabilities can be added later.
16 */
17 class WordPressUserContext implements UserContext {
18 #[\Override]
19 public function can_create_php_cron_events(): bool {
20 return current_user_can( 'edit_files' );
21 }
22
23 #[\Override]
24 public function can_edit_php_cron_events(): bool {
25 return current_user_can( 'edit_files' );
26 }
27
28 #[\Override]
29 public function can_delete_php_cron_events(): bool {
30 return current_user_can( 'edit_files' );
31 }
32
33 #[\Override]
34 public function can_run_php_cron_events(): bool {
35 return current_user_can( 'manage_options' );
36 }
37
38 #[\Override]
39 public function can_create_url_cron_events(): bool {
40 return current_user_can( 'manage_options' );
41 }
42
43 #[\Override]
44 public function can_edit_url_cron_events(): bool {
45 return current_user_can( 'manage_options' );
46 }
47
48 #[\Override]
49 public function can_delete_url_cron_events(): bool {
50 return current_user_can( 'manage_options' );
51 }
52
53 #[\Override]
54 public function can_run_url_cron_events(): bool {
55 return current_user_can( 'manage_options' );
56 }
57
58 #[\Override]
59 public function can_create_standard_cron_events(): bool {
60 return current_user_can( 'manage_options' );
61 }
62
63 #[\Override]
64 public function can_edit_standard_cron_events(): bool {
65 return current_user_can( 'manage_options' );
66 }
67
68 #[\Override]
69 public function can_delete_standard_cron_events(): bool {
70 return current_user_can( 'manage_options' );
71 }
72
73 #[\Override]
74 public function can_run_standard_cron_events(): bool {
75 return current_user_can( 'manage_options' );
76 }
77 }
78