| 1 |
<?php |
| 2 |
|
| 3 |
namespace GeminiLabs\SiteReviews\Controllers; |
| 4 |
|
| 5 |
use GeminiLabs\SiteReviews\Database\Cache; |
| 6 |
use GeminiLabs\SiteReviews\Metaboxes\DashboardMetabox; |
| 7 |
|
| 8 |
class DashboardController extends AbstractController |
| 9 |
{ |
| 10 |
/** |
| 11 |
* @action transition_post_status:5 |
| 12 |
*/ |
| 13 |
public function flushMonthlyCountCache(string $newStatus, string $oldStatus, ?\WP_Post $post): void |
| 14 |
{ |
| 15 |
if (is_null($post)) { |
| 16 |
return; // This should never happen, but some plugins are bad actors so... |
| 17 |
} |
| 18 |
if (glsr()->post_type !== $post->post_type) { |
| 19 |
return; |
| 20 |
} |
| 21 |
if ($newStatus === $oldStatus) { |
| 22 |
return; |
| 23 |
} |
| 24 |
glsr(Cache::class)->delete('monthly', 'count'); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* @action wp_dashboard_setup |
| 29 |
*/ |
| 30 |
public function registerMetaBoxes(): void |
| 31 |
{ |
| 32 |
glsr(DashboardMetabox::class)->register(); |
| 33 |
} |
| 34 |
} |
| 35 |
|