refactor(Core): optimize admin panel and refactor
This commit is contained in:
@@ -46,12 +46,20 @@ class BannerRepository {
|
||||
unset($data['id'], $data['created_at']);
|
||||
|
||||
if ($banner->id) {
|
||||
$wpdb->update($this->table_name, $data, ['id' => $banner->id]);
|
||||
$result = $wpdb->update($this->table_name, $data, ['id' => $banner->id]);
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->clearCache();
|
||||
return $banner->id;
|
||||
}
|
||||
|
||||
$wpdb->insert($this->table_name, $data);
|
||||
$result = $wpdb->insert($this->table_name, $data);
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->clearCache();
|
||||
return $wpdb->insert_id;
|
||||
}
|
||||
@@ -76,6 +84,12 @@ class BannerRepository {
|
||||
}
|
||||
|
||||
public function clearCache() {
|
||||
wp_cache_flush();
|
||||
$version = microtime(true);
|
||||
update_option('sodino_banners_cache_version', $version, false);
|
||||
wp_cache_set('version', $version, 'sodino_banners');
|
||||
|
||||
if (function_exists('wp_cache_flush_group')) {
|
||||
wp_cache_flush_group('sodino_banners');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user