Admin
2 months ago
Builder
2 months ago
Customizer
2 months ago
Exceptions
2 months ago
Helpers
2 months ago
Integrations
2 months ago
Migrations
2 months ago
ReviewAlerts
2 months ago
Services
2 months ago
Settings
2 months ago
Support
2 months ago
Traits
2 months ago
Utils
2 months ago
AuthorizationStatusCheck.php
2 months ago
BusinessDataCache.php
2 months ago
Clear_Cache.php
2 months ago
Container.php
2 months ago
DisplayElements.php
2 months ago
Email_Notification.php
2 months ago
Error_Reporter.php
2 months ago
Feed.php
2 months ago
FeedCache.php
2 months ago
FeedCacheUpdater.php
2 months ago
FeedDisplay.php
2 months ago
Feed_Locator.php
2 months ago
Parser.php
2 months ago
PostAggregator.php
2 months ago
RemoteRequest.php
2 months ago
SBR_Education.php
2 months ago
SBR_Settings.php
2 months ago
ServiceContainer.php
2 months ago
SinglePostCache.php
2 months ago
TemplateRenderer.php
2 months ago
Tooltip_Wizard.php
2 months ago
Util.php
2 months ago
BusinessDataCache.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Class BusinessDataCache |
| 5 | * |
| 6 | * @since 1.0 |
| 7 | */ |
| 8 | |
| 9 | namespace SmashBalloon\Reviews\Common; |
| 10 | |
| 11 | class BusinessDataCache { |
| 12 | public const CACHE_KEY = 'sbr_business_cache'; |
| 13 | |
| 14 | private $business_cache; |
| 15 | |
| 16 | public function __construct() |
| 17 | { |
| 18 | $raw_cache = get_option(self::CACHE_KEY, '{}'); |
| 19 | |
| 20 | $this->business_cache = json_decode($raw_cache, true); |
| 21 | } |
| 22 | |
| 23 | public function get_data($provider, $business_id) |
| 24 | { |
| 25 | if (! empty($this->business_cache[ $provider ][ $business_id ])) { |
| 26 | return $this->business_cache[ $provider ][ $business_id ]; |
| 27 | } |
| 28 | |
| 29 | return array(); |
| 30 | } |
| 31 | |
| 32 | public function update_single_datum($provider, $business_id, $data_key, $data_value) |
| 33 | { |
| 34 | if (empty($this->business_cache[ $provider ][ $business_id ])) { |
| 35 | return false; |
| 36 | } |
| 37 | $this->business_cache[ $provider ][ $business_id ][ $data_key ] = $data_value; |
| 38 | |
| 39 | return update_option(self::CACHE_KEY, wp_json_encode($this->business_cache), false); |
| 40 | } |
| 41 | |
| 42 | public function update_data($provider, $business_id, $data) |
| 43 | { |
| 44 | $this->business_cache[ $provider ][ $business_id ] = $data; |
| 45 | |
| 46 | return update_option(self::CACHE_KEY, wp_json_encode($this->business_cache), false); |
| 47 | } |
| 48 | |
| 49 | } |
| 50 |