PluginProbe
JCH Optimize / trunk
JCH Optimize vtrunk
6.0.2 6.0.1 trunk 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.10.0 2.2.0 2.2.1 All 58 releases
jch-optimize / src / Model / NotificationIcons.php

NotificationIcons.php in JCH Optimize trunk, at src/Model/NotificationIcons.php

79 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * JCH Optimize - Performs several front-end optimizations for fast downloads
5 *
6 * @package jchoptimize/wordpress-platform
7 * @author Samuel Marshall <samuel@jch-optimize.net>
8 * @copyright Copyright (c) 2025 Samuel Marshall / JCH Optimize
9 * @license GNU/GPLv3, or later. See LICENSE file
10 *
11 * If LICENSE file missing, see <http://www.gnu.org/licenses/>.
12 */
13
14 namespace JchOptimize\WordPress\Model;
15
16 use JchOptimize\Core\Registry;
17 use JchOptimize\WordPress\Plugin\Updater;
18
19 use function add_query_arg;
20 use function admin_url;
21 use function strlen;
22
23 class NotificationIcons
24 {
25 public function __construct(private Registry $params, private Updater $updater)
26 {
27 }
28
29 public function getNotificationIcons(): array
30 {
31 $buttons = [];
32
33 $buttons[0]['link'] = admin_url('update-core.php');
34 $buttons[0]['icon'] = 'fa fa-plug';
35 $buttons[0]['id'] = 'plugin-status';
36
37 if($this->updater->updateAvailable()) {
38 $buttons[0]['class'] = ['danger'];
39 $buttons[0]['name'] = __('Plugin update available', 'jch-optimize');
40 } else {
41 $buttons[0]['class'] = ['success'];
42 $buttons[0]['name'] = __('Plugin is up to date', 'jch-optimize');
43 }
44
45 $configurationsUrl = add_query_arg(
46 ['page' => 'jch_optimize', 'tab' => 'configurations'],
47 admin_url('options-general.php')
48 );
49
50 if (JCH_PRO) {
51 $buttons[1]['id'] = 'download-id-status';
52 $buttons[1]['link'] = "{$configurationsUrl}#general";
53 $buttons[1]['icon'] = 'fa fa-id-badge';
54
55 if (strlen($this->params->get('pro_downloadid', '')) < 32) {
56 $buttons[1]['class'] = ['danger'];
57 $buttons[1]['name'] = __('Download ID missing', 'jch-optimize');
58 } else {
59 $buttons[1]['class'] = ['success'];
60 $buttons[1]['name'] = __('Download ID entered', 'jch-optimize');
61 }
62 }
63
64 $buttons[2]['id'] = 'page-cache-status';
65 $buttons[2]['link'] = "{$configurationsUrl}#page-cache";
66 $buttons[2]['icon'] = 'fa fa-archive';
67
68 if ($this->params->get('cache_enable')) {
69 $buttons[2]['class' ] = ['success'];
70 $buttons[2]['name'] = __('Page Cache enabled', 'jch-optimize');
71 } else {
72 $buttons[2]['class'] = ['danger'];
73 $buttons[2]['name'] = __('Page Cache disabled', 'jch-optimize');
74 }
75
76 return $buttons;
77 }
78 }
79