| @@ -3,11 +3,13 @@ | ||
| 3 | 3 | * Class LP_Settings |
| 4 | 4 | * |
| 5 | 5 | * @author ThimPress |
| 6 | 6 | * @package LearnPress/Classes |
| 7 | - * @version 1.0.1 | |
| 7 | + * @version 1.0.2 | |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | +use LearnPress\Databases\DataBase; | |
| 11 | + | |
| 10 | 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | 13 | exit; |
| 12 | 14 | } |
| 13 | 15 | |
| @@ -71,9 +73,9 @@ | ||
| 71 | 73 | // Check cache exists |
| 72 | 74 | $lp_settings_cache = new LP_Settings_Cache( true ); |
| 73 | 75 | $lp_options = $lp_settings_cache->get_lp_settings(); |
| 74 | 76 | if ( false !== $lp_options ) { |
| 75 | - $this->_options = LP_Helper::json_decode( $lp_options, true ); | |
| 77 | + $this->_options = $lp_options; | |
| 76 | 78 | |
| 77 | 79 | return; |
| 78 | 80 | } |
| 79 | 81 | |
| @@ -238,8 +240,30 @@ | ||
| 238 | 240 | |
| 239 | 241 | return get_option( $key, $default ); |
| 240 | 242 | } |
| 241 | 243 | |
| 244 | + /** | |
| 245 | + * Get list of dismissed admin notices. | |
| 246 | + * | |
| 247 | + * @return array | |
| 248 | + */ | |
| 249 | + public static function get_admin_notices_dismiss(): array { | |
| 250 | + return get_option( 'lp_admin_notices_dismiss', [] ); | |
| 251 | + } | |
| 252 | + | |
| 253 | + /** | |
| 254 | + * Check if an admin notice has been dismissed. | |
| 255 | + * | |
| 256 | + * @param string $key Notice key. | |
| 257 | + * | |
| 258 | + * @return bool | |
| 259 | + */ | |
| 260 | + public static function is_admin_notice_dismissed( string $key ): bool { | |
| 261 | + $dismissed = self::get_admin_notices_dismiss(); | |
| 262 | + | |
| 263 | + return isset( $dismissed[ $key ] ); | |
| 264 | + } | |
| 265 | + | |
| 242 | 266 | public function get_int( $key ) { |
| 243 | 267 | $value = $this->get( $key ); |
| 244 | 268 | |
| 245 | 269 | return intval( $value ); |
| @@ -386,11 +410,12 @@ | ||
| 386 | 410 | /** |
| 387 | 411 | * Check table learnpress_course is created |
| 388 | 412 | * |
| 389 | 413 | * @return bool |
| 414 | + * @throws Exception | |
| 390 | 415 | */ |
| 391 | 416 | public static function is_created_tb_courses(): bool { |
| 392 | - $lp_db = LP_Database::getInstance(); | |
| 417 | + $lp_db = DataBase::getInstance(); | |
| 393 | 418 | return $lp_db->check_table_exists( $lp_db->tb_lp_courses ); |
| 394 | 419 | } |
| 395 | 420 | |
| 396 | 421 | /** |
| @@ -413,11 +438,12 @@ | ||
| 413 | 438 | |
| 414 | 439 | /** |
| 415 | 440 | * Check table learnpress_files is created |
| 416 | 441 | * @return boolean |
| 442 | + * @throws Exception | |
| 417 | 443 | */ |
| 418 | 444 | public static function is_created_tb_material_files(): bool { |
| 419 | - $lp_db = LP_Database::getInstance(); | |
| 445 | + $lp_db = DataBase::getInstance(); | |
| 420 | 446 | return $lp_db->check_table_exists( $lp_db->tb_lp_files ); |
| 421 | 447 | } |
| 422 | 448 | |
| 423 | 449 | /** |
| @@ -423,11 +449,12 @@ | ||
| 423 | 449 | /** |
| 424 | 450 | * Check table learnpress_mcp_api_keys is created. |
| 425 | 451 | * |
| 426 | 452 | * @return bool |
| 453 | + * @throws Exception | |
| 427 | 454 | */ |
| 428 | 455 | public static function is_created_tb_mcp_api_keys(): bool { |
| 429 | - $lp_db = LP_Database::getInstance(); | |
| 456 | + $lp_db = DataBase::getInstance(); | |
| 430 | 457 | return $lp_db->check_table_exists( $lp_db->tb_lp_mcp_api_keys ); |
| 431 | 458 | } |
| 432 | 459 | |
| 433 | 460 | /** |
| @@ -433,11 +460,12 @@ | ||
| 433 | 460 | /** |
| 434 | 461 | * Check table learnpress_webhooks is created. |
| 435 | 462 | * |
| 436 | 463 | * @return bool |
| 464 | + * @throws Exception | |
| 437 | 465 | */ |
| 438 | 466 | public static function is_created_tb_webhooks(): bool { |
| 439 | - $lp_db = LP_Database::getInstance(); | |
| 467 | + $lp_db = DataBase::getInstance(); | |
| 440 | 468 | return $lp_db->check_table_exists( $lp_db->tb_lp_webhooks ); |
| 441 | 469 | } |
| 442 | 470 | |
| 443 | 471 | public static function lp_material_file_types(): array { |