GluePluginData.php
1 month ago
RecommendationsForInstallerPlugins.php
1 month ago
RecommendationsManager.php
1 month ago
Storage.php
1 month ago
Storage.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace OTGS\Installer\Recommendations; |
| 4 | |
| 5 | class Storage { |
| 6 | const ADMIN_NOTICES_OPTION = 'otgs_installer_recommendations_admin_notices_v2'; |
| 7 | |
| 8 | public static function save( $key, $data ) { |
| 9 | $current = get_option( self::ADMIN_NOTICES_OPTION, [] ); |
| 10 | $current[ $data['repository_id'] ][ $key ] = $data; |
| 11 | update_option( self::ADMIN_NOTICES_OPTION, $current, 'no' ); |
| 12 | } |
| 13 | |
| 14 | public static function exists($pluginSlug,$repositoryId){ |
| 15 | $items = self::getAll(); |
| 16 | return isset($items[ $repositoryId ]) && isset($items[ $repositoryId ][ $pluginSlug ] ); |
| 17 | } |
| 18 | |
| 19 | public static function missing($pluginSlug,$repositoryId){ |
| 20 | return !self::exists($pluginSlug,$repositoryId); |
| 21 | } |
| 22 | |
| 23 | public static function dismissNotice( $pluginSlug, $repositoryId ) { |
| 24 | $current = get_option( self::ADMIN_NOTICES_OPTION, [] ); |
| 25 | if ( isset( $current[ $repositoryId ][ $pluginSlug ] ) ) { |
| 26 | $current[ $repositoryId ][ $pluginSlug ]['notice_dismissed'] = true; |
| 27 | update_option( self::ADMIN_NOTICES_OPTION, $current, 'no' ); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | public static function isDismissed( $pluginSlug, $repositoryId ) { |
| 32 | $current = get_option( self::ADMIN_NOTICES_OPTION, [] ); |
| 33 | return isset( $current[ $repositoryId ][ $pluginSlug ]['notice_dismissed'] ) |
| 34 | && $current[ $repositoryId ][ $pluginSlug ]['notice_dismissed'] === true; |
| 35 | } |
| 36 | |
| 37 | public static function delete( $pluginSlug, $repositoryId ) { |
| 38 | $current = get_option( self::ADMIN_NOTICES_OPTION, [] ); |
| 39 | unset( $current[ $repositoryId ][ $pluginSlug ] ); |
| 40 | update_option( self::ADMIN_NOTICES_OPTION, $current, 'no' ); |
| 41 | } |
| 42 | |
| 43 | public static function getAll() { |
| 44 | return get_option( self::ADMIN_NOTICES_OPTION, [] ); |
| 45 | } |
| 46 | } |
| 47 |