| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPCoder\Publisher; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) || exit; |
| 6 |
|
| 7 |
class Conditions { |
| 8 |
|
| 9 |
public static function init( $result ): bool { |
| 10 |
$param = ! empty( $result->param ) ? maybe_unserialize( $result->param ) : []; |
| 11 |
$check = [ |
| 12 |
'status' => self::status( $result->status ), |
| 13 |
'mode' => self::mode( $result->mode ), |
| 14 |
]; |
| 15 |
|
| 16 |
if ( in_array( false, $check, true ) ) { |
| 17 |
return false; |
| 18 |
} |
| 19 |
|
| 20 |
return true; |
| 21 |
|
| 22 |
} |
| 23 |
|
| 24 |
private static function status( $status ): bool { |
| 25 |
return empty( $status ); |
| 26 |
} |
| 27 |
|
| 28 |
private static function mode( $mode ): bool { |
| 29 |
return empty( $mode ) || current_user_can( 'administrator' ); |
| 30 |
} |
| 31 |
|
| 32 |
} |