| 1 |
<?php |
| 2 |
|
| 3 |
namespace GeminiLabs\SiteReviews\Controllers; |
| 4 |
|
| 5 |
use GeminiLabs\SiteReviews\Defaults\FlyoutItemDefaults; |
| 6 |
use GeminiLabs\SiteReviews\License; |
| 7 |
|
| 8 |
class FlyoutController extends AbstractController |
| 9 |
{ |
| 10 |
/** |
| 11 |
* @action admin_footer |
| 12 |
*/ |
| 13 |
public function renderFlyout(): void |
| 14 |
{ |
| 15 |
$screen = glsr_current_screen(); |
| 16 |
if ('post' === $screen->base) { |
| 17 |
return; |
| 18 |
} |
| 19 |
if (!str_starts_with($screen->post_type, glsr()->post_type)) { |
| 20 |
return; |
| 21 |
} |
| 22 |
if (!glsr()->filterBool('flyoutmenu/enabled', true)) { |
| 23 |
return; |
| 24 |
} |
| 25 |
glsr()->render('views/partials/flyoutmenu', [ |
| 26 |
'items' => $this->menuItems(), |
| 27 |
]); |
| 28 |
} |
| 29 |
|
| 30 |
protected function menuItems(): array |
| 31 |
{ |
| 32 |
$items = [ |
| 33 |
[ |
| 34 |
'class' => 'glsr-flyout-premium', |
| 35 |
'icon' => 'dashicons-star-filled', |
| 36 |
'title' => _x('Upgrade to Premium', 'admin-text', 'site-reviews'), |
| 37 |
'url' => glsr_premium_url('site-reviews-premium'), |
| 38 |
], |
| 39 |
[ |
| 40 |
'icon' => 'dashicons-wordpress-alt', |
| 41 |
'title' => _x('Ask for Help', 'admin-text', 'site-reviews'), |
| 42 |
'url' => 'https://wordpress.org/support/plugin/site-reviews/', |
| 43 |
], |
| 44 |
[ |
| 45 |
'icon' => 'dashicons-youtube', |
| 46 |
'title' => _x('Watch the Tutorial', 'admin-text', 'site-reviews'), |
| 47 |
'url' => 'https://youtu.be/H5HdMCXvuq8', |
| 48 |
], |
| 49 |
[ |
| 50 |
'icon' => 'dashicons-editor-help', |
| 51 |
'title' => _x('Read the Documentation', 'admin-text', 'site-reviews'), |
| 52 |
'url' => glsr_admin_url('documentation'), |
| 53 |
], |
| 54 |
[ |
| 55 |
'icon' => 'dashicons-book', |
| 56 |
'title' => _x('Read a Quick Guide to Site Reviews', 'admin-text', 'site-reviews'), |
| 57 |
'url' => glsr_admin_url('welcome'), |
| 58 |
], |
| 59 |
[ |
| 60 |
'class' => 'glsr-flyout-write-review', |
| 61 |
'icon' => 'dashicons-testimonial', |
| 62 |
'title' => _x('Rate Site Reviews � |
| 63 |
� |
| 64 |
� |
| 65 |
� |
| 66 |
� |
| 67 |
on Wordpress', 'admin-text', 'site-reviews'), |
| 68 |
'url' => 'https://wordpress.org/support/plugin/site-reviews/reviews/#new-post', |
| 69 |
], |
| 70 |
]; |
| 71 |
if (glsr(License::class)->isPremium()) { |
| 72 |
array_shift($items); |
| 73 |
} |
| 74 |
$items = glsr()->filterArray('flyoutmenu/items', $items); |
| 75 |
array_walk($items, function (&$item) { |
| 76 |
$item = glsr(FlyoutItemDefaults::class)->restrict($item); |
| 77 |
}); |
| 78 |
return $items; |
| 79 |
} |
| 80 |
} |
| 81 |
|