| 1 |
<?php |
| 2 |
/** |
| 3 |
* Trait OptionTrait. |
| 4 |
* |
| 5 |
* @package Packetery |
| 6 |
*/ |
| 7 |
|
| 8 |
declare( strict_types=1 ); |
| 9 |
|
| 10 |
namespace Packetery\Module\Framework; |
| 11 |
|
| 12 |
/** |
| 13 |
* Trait OptionTrait. |
| 14 |
* |
| 15 |
* @package Packetery |
| 16 |
*/ |
| 17 |
trait OptionTrait { |
| 18 |
/** |
| 19 |
* WP get_option adapter. |
| 20 |
* |
| 21 |
* @param string $optionId Option id. |
| 22 |
* @param mixed $defaultValue Default value. |
| 23 |
* |
| 24 |
* @return mixed |
| 25 |
*/ |
| 26 |
public function getOption( string $optionId, $defaultValue = false ) { |
| 27 |
return get_option( $optionId, $defaultValue ); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* WP update_option adapter. |
| 32 |
* |
| 33 |
* @param string $optionId Option id. |
| 34 |
* @param mixed $newValue New value. |
| 35 |
* |
| 36 |
* @return bool |
| 37 |
*/ |
| 38 |
public function updateOption( string $optionId, $newValue ): bool { |
| 39 |
return update_option( $optionId, $newValue ); |
| 40 |
} |
| 41 |
|
| 42 |
public function deleteOption( string $optionName ): bool { |
| 43 |
return delete_option( $optionName ); |
| 44 |
} |
| 45 |
} |
| 46 |
|