| 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 |
|