| 1 |
<?php |
| 2 |
|
| 3 |
namespace Cookiez\Modules\Settings\Classes; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
class Settings { |
| 10 |
public const COOKIEZ_SETTINGS = 'cookiez_settings'; |
| 11 |
public const COOKIEZ_CONTENT = 'cookiez_content'; |
| 12 |
public const IS_VALID_PLAN_DATA = 'cookiez_is_valid_plan_data'; |
| 13 |
public const PLAN_DATA = 'cookiez_plan_data'; |
| 14 |
public const PLAN_SCOPE = 'cookiez_plan_scope'; |
| 15 |
public const PLAN_DATA_REFRESH_TRANSIENT = 'cookiez_plan_data_refresh'; |
| 16 |
public const SUBSCRIPTION_ID = 'cookiez_subscription_id'; |
| 17 |
public const CLIENT_ID = 'cookiez_client_id'; |
| 18 |
public const REVIEW_DATA = 'cookiez_review_data'; |
| 19 |
public const MAXMIND_LICENSE_KEY = 'cookiez_maxmind_license_key'; |
| 20 |
|
| 21 |
/** |
| 22 |
* Returns plugin settings data by option name typecasted to an appropriate data type. |
| 23 |
* |
| 24 |
* @param string $option_name |
| 25 |
* |
| 26 |
* @return mixed |
| 27 |
*/ |
| 28 |
public static function get( string $option_name ) { |
| 29 |
$data = get_option( $option_name, [] ); |
| 30 |
|
| 31 |
return is_array( $data ) ? $data : []; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Update the settings data by option name. |
| 36 |
* |
| 37 |
* @param string $option_name |
| 38 |
* @param $value |
| 39 |
* |
| 40 |
* @return bool |
| 41 |
*/ |
| 42 |
public static function set( string $option_name, $value ): bool { |
| 43 |
return update_option( $option_name, $value, false ); |
| 44 |
} |
| 45 |
} |
| 46 |
|