| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class Conditions |
| 5 |
* |
| 6 |
* Provides methods to check conditions for displaying item |
| 7 |
* |
| 8 |
* @package WowPlugin |
| 9 |
* @subpackage Publish |
| 10 |
* @author Dmytro Lobov <dev@wow-company.com>, Wow-Company |
| 11 |
* @copyright 2024 Dmytro Lobov |
| 12 |
* @license GPL-2.0+ |
| 13 |
*/ |
| 14 |
|
| 15 |
namespace FloatMenuLite\Publish; |
| 16 |
|
| 17 |
use FloatMenuLite\WOWP_Plugin; |
| 18 |
use FloatMenuLite\WOWP_Public; |
| 19 |
|
| 20 |
defined( 'ABSPATH' ) || exit; |
| 21 |
|
| 22 |
class Conditions { |
| 23 |
|
| 24 |
public static function init( $result ): bool { |
| 25 |
$param = ! empty( $result->param ) ? maybe_unserialize( $result->param ) : []; |
| 26 |
|
| 27 |
$check = [ |
| 28 |
'status' => self::status( $result->status ), |
| 29 |
'mode' => self::mode( $result->mode ), |
| 30 |
]; |
| 31 |
|
| 32 |
$check = apply_filters(WOWP_Plugin::PREFIX . '_conditions', $check); |
| 33 |
|
| 34 |
if ( in_array( false, $check, true ) ) { |
| 35 |
return false; |
| 36 |
} |
| 37 |
|
| 38 |
return true; |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
private static function status( $status ): bool { |
| 43 |
return empty( $status ); |
| 44 |
} |
| 45 |
|
| 46 |
private static function mode( $mode ): bool { |
| 47 |
return empty( $mode ) || current_user_can( 'manage_options' ); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
} |