PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.0.13
Admin Columns v7.0.13
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 3 months ago Promotion.php 3 months ago Review.php 3 months ago
Review.php
166 lines
1 <?php
2
3 namespace AC\Check;
4
5 use AC\Ajax;
6 use AC\Asset\Location;
7 use AC\Asset\Script;
8 use AC\Capabilities;
9 use AC\Message;
10 use AC\Notice\NoticeState;
11 use AC\Registerable;
12 use AC\Screen;
13 use AC\Type\Url\Documentation;
14 use AC\Type\Url\UtmTags;
15
16 final class Review implements Registerable
17 {
18
19 private const SLUG = 'review';
20 private const DELAY_DAYS = 30;
21
22 private Location $location;
23
24 private NoticeState $state;
25
26 public function __construct(Location $location, NoticeState $state)
27 {
28 $this->location = $location;
29 $this->state = $state;
30 }
31
32 public function register(): void
33 {
34 add_action('ac/screen', [$this, 'display']);
35
36 $this->get_ajax_handler()->register();
37 }
38
39 public function display(Screen $screen): void
40 {
41 if ( ! current_user_can(Capabilities::MANAGE)) {
42 return;
43 }
44
45 if ( ! $screen->has_screen()) {
46 return;
47 }
48
49 if ( ! $screen->is_admin_screen()) {
50 return;
51 }
52
53 if ($this->state->is_dismissed(self::SLUG)) {
54 return;
55 }
56
57 $this->state->track_first_seen(self::SLUG);
58
59 if ( ! $this->state->is_delay_met(self::SLUG, self::DELAY_DAYS)) {
60 return;
61 }
62
63 $script = new Script('ac-notice-review', $this->location->with_suffix('assets/js/message-review.js'), ['jquery']
64 );
65 $script->enqueue();
66
67 $notice = new Message\Notice\Dismissible($this->get_message(), $this->get_ajax_handler());
68 $notice
69 ->set_id('review')
70 ->register();
71 }
72
73 protected function get_ajax_handler(): Ajax\Handler
74 {
75 $handler = new Ajax\Handler();
76 $handler
77 ->set_action('ac_check_review_dismiss_notice')
78 ->set_callback([$this, 'ajax_dismiss_notice']);
79
80 return $handler;
81 }
82
83 public function ajax_dismiss_notice(): void
84 {
85 $this->get_ajax_handler()->verify_request();
86 $this->state->dismiss(self::SLUG);
87 }
88
89 private function get_documentation_url(): string
90 {
91 return (new UtmTags(new Documentation(), 'review-notice'))->get_url();
92 }
93
94 protected function get_message(): string
95 {
96 $product = __('Admin Columns', 'codepress-admin-columns');
97
98 ob_start();
99
100 ?>
101
102 <div class="info">
103 <p>
104 <?php
105 printf(
106 __(
107 "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.",
108 'codepress-admin-columns'
109 ),
110 '<strong>' . $product . '</strong>',
111 $product,
112 '<a class="hide-review-notice-soft" href="#">' . __(
113 'click here',
114 'codepress-admin-columns'
115 ) . '</a>'
116 ); ?>
117 </p>
118 <p class="buttons">
119 <a class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/codepress-admin-columns?rate=5#postform" target="_blank"><?php
120 _e('Leave a review!', 'codepress-admin-columns'); ?></a>
121 <a class="button button-secondary hide-review-notice" href='#' data-dismiss=""><?php
122 _e("Permanently hide notice", 'codepress-admin-columns'); ?></a>
123 </p>
124 </div>
125 <div class="help hidden">
126 <a href="#" class="hide-notice hide-review-notice"></a>
127 <p>
128 <?php
129
130 printf(
131 __(
132 "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.",
133 'codepress-admin-columns'
134 ),
135 $product,
136 '<a href="' . esc_url(
137 $this->get_documentation_url()
138 ) . '" target="_blank">' . __(
139 'documentation page',
140 'codepress-admin-columns'
141 ) . '</a>'
142 );
143
144 printf(
145 __('You can also find help on the %s, and %s.', 'codepress-admin-columns'),
146 '<a href="https://wordpress.org/support/plugin/codepress-admin-columns#postform" target="_blank">' . __(
147 'Admin Columns forum on WordPress.org',
148 'codepress-admin-columns'
149 ) . '</a>',
150 '<a href="https://wordpress.org/plugins/codepress-admin-columns/#faq" target="_blank">' . __(
151 'find answers to frequently asked questions',
152 'codepress-admin-columns'
153 ) . '</a>'
154 );
155
156 ?>
157 </p>
158 </div>
159
160 <?php
161
162 return ob_get_clean();
163 }
164
165 }
166