| 1 |
<?php |
| 2 |
/** |
| 3 |
* Represents a standard WordPress cron event. |
| 4 |
*/ |
| 5 |
|
| 6 |
namespace Crontrol\Event; |
| 7 |
|
| 8 |
use Crontrol\Context\UserContext; |
| 9 |
use Crontrol\Context\FeatureContext; |
| 10 |
|
| 11 |
use function Crontrol\json_output; |
| 12 |
|
| 13 |
/** |
| 14 |
* Represents a standard WordPress cron event. |
| 15 |
*/ |
| 16 |
final class StandardEvent extends Event { |
| 17 |
#[\Override] |
| 18 |
public function editable( UserContext $user, FeatureContext $features ): bool { |
| 19 |
return $user->can_edit_standard_cron_events(); |
| 20 |
} |
| 21 |
|
| 22 |
#[\Override] |
| 23 |
public function runnable( UserContext $user, FeatureContext $features ): bool { |
| 24 |
return $user->can_run_standard_cron_events() |
| 25 |
&& ! $this->has_error() |
| 26 |
&& ! $this->is_paused(); |
| 27 |
} |
| 28 |
|
| 29 |
#[\Override] |
| 30 |
public function deletable( UserContext $user, FeatureContext $features ): bool { |
| 31 |
return $user->can_delete_standard_cron_events(); |
| 32 |
} |
| 33 |
|
| 34 |
#[\Override] |
| 35 |
public function pausable(): bool { |
| 36 |
return true; |
| 37 |
} |
| 38 |
|
| 39 |
#[\Override] |
| 40 |
public function get_args_display(): string { |
| 41 |
if ( empty( $this->args ) ) { |
| 42 |
return ''; |
| 43 |
} |
| 44 |
return json_output( $this->args, false ); |
| 45 |
} |
| 46 |
|
| 47 |
#[\Override] |
| 48 |
public function is_enabled( FeatureContext $features ): bool { |
| 49 |
return true; |
| 50 |
} |
| 51 |
} |
| 52 |
|