PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.1.4
Admin Columns v7.1.4
7.1.4 7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Check / Review.php
codepress-admin-columns / classes / Check Last commit date
Integration 2 days ago Promotion.php 2 days ago Review.php 2 days ago
Review.php
170 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AC\Check;
6
7 use AC\Ajax;
8 use AC\Asset\Location;
9 use AC\Asset\Script;
10 use AC\Capabilities;
11 use AC\Message;
12 use AC\Notice\NoticeState;
13 use AC\Registerable;
14 use AC\Screen;
15 use AC\Type\Url\Documentation;
16 use AC\Type\Url\UtmTags;
17
18 final class Review implements Registerable
19 {
20 private const SLUG = 'review';
21 private const DELAY_DAYS = 30;
22
23 private Location $location;
24
25 private NoticeState $state;
26
27 public function __construct(Location $location, NoticeState $state)
28 {
29 $this->location = $location;
30 $this->state = $state;
31 }
32
33 public function register(): void
34 {
35 add_action('ac/screen', [$this, 'display']);
36
37 $this->get_ajax_handler()->register();
38 }
39
40 public function display(Screen $screen): void
41 {
42 if (! current_user_can(Capabilities::MANAGE)) {
43 return;
44 }
45
46 if (! $screen->has_screen()) {
47 return;
48 }
49
50 if (! $screen->is_admin_screen()) {
51 return;
52 }
53
54 if ($this->state->is_dismissed(self::SLUG)) {
55 return;
56 }
57
58 $this->state->track_first_seen(self::SLUG);
59
60 if (! $this->state->is_delay_met(self::SLUG, self::DELAY_DAYS)) {
61 return;
62 }
63
64 $script = new Script(
65 'ac-notice-review',
66 $this->location->with_suffix('assets/js/message-review.js'),
67 ['jquery']
68 );
69 $script->enqueue();
70
71 $notice = new Message\Notice\Dismissible($this->get_message(), $this->get_ajax_handler());
72 $notice
73 ->set_id('review')
74 ->register();
75 }
76
77 protected function get_ajax_handler(): Ajax\Handler
78 {
79 $handler = new Ajax\Handler();
80 $handler
81 ->set_action('ac_check_review_dismiss_notice')
82 ->set_callback([$this, 'ajax_dismiss_notice']);
83
84 return $handler;
85 }
86
87 public function ajax_dismiss_notice(): void
88 {
89 $this->get_ajax_handler()->verify_request();
90 $this->state->dismiss(self::SLUG);
91 }
92
93 private function get_documentation_url(): string
94 {
95 return (new UtmTags(new Documentation(), 'review-notice'))->get_url();
96 }
97
98 protected function get_message(): string
99 {
100 $product = __('Admin Columns', 'codepress-admin-columns');
101
102 ob_start();
103
104 ?>
105
106 <div class="info">
107 <p>
108 <?php
109 printf(
110 __(
111 "We don't mean to bug you, but you've been using %s for some time now, and we were wondering if you're happy with the plugin. If so, could you please leave a review at wordpress.org? If you're not happy with %s, please %s.",
112 'codepress-admin-columns'
113 ),
114 '<strong>' . $product . '</strong>',
115 $product,
116 '<a class="hide-review-notice-soft" href="#">' . __(
117 'click here',
118 'codepress-admin-columns'
119 ) . '</a>'
120 ); ?>
121 </p>
122 <p class="buttons">
123 <a class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/codepress-admin-columns?rate=5#postform" target="_blank"><?php
124 _e('Leave a review!', 'codepress-admin-columns'); ?></a>
125 <a class="button button-secondary hide-review-notice" href='#' data-dismiss=""><?php
126 _e("Permanently hide notice", 'codepress-admin-columns'); ?></a>
127 </p>
128 </div>
129 <div class="help hidden">
130 <a href="#" class="hide-notice hide-review-notice"></a>
131 <p>
132 <?php
133
134 printf(
135 __(
136 "We're sorry to hear that; maybe we can help! If you're having problems properly setting up %s or if you would like help with some more advanced features, please visit our %s.",
137 'codepress-admin-columns'
138 ),
139 $product,
140 '<a href="' . esc_url(
141 $this->get_documentation_url()
142 ) . '" target="_blank">' . __(
143 'documentation page',
144 'codepress-admin-columns'
145 ) . '</a>'
146 );
147
148 printf(
149 __('You can also find help on the %s, and %s.', 'codepress-admin-columns'),
150 '<a href="https://wordpress.org/support/plugin/codepress-admin-columns#postform" target="_blank">' . __(
151 'Admin Columns forum on WordPress.org',
152 'codepress-admin-columns'
153 ) . '</a>',
154 '<a href="https://wordpress.org/plugins/codepress-admin-columns/#faq" target="_blank">' . __(
155 'find answers to frequently asked questions',
156 'codepress-admin-columns'
157 ) . '</a>'
158 );
159
160 ?>
161 </p>
162 </div>
163
164 <?php
165
166 return (string)ob_get_clean();
167 }
168
169 }
170