PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 3.0.2
Admin Columns v3.0.2
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 / Addon.php
codepress-admin-columns / classes Last commit date
Addon 8 years ago Admin 8 years ago Column 8 years ago Helper 8 years ago ListScreen 8 years ago Meta 8 years ago Notice 8 years ago Settings 8 years ago ThirdParty 8 years ago API.php 8 years ago Addon.php 8 years ago Addons.php 8 years ago Admin.php 8 years ago Autoloader.php 8 years ago Collection.php 8 years ago Column.php 8 years ago Groups.php 8 years ago Helper.php 8 years ago ListScreen.php 8 years ago ListScreenPost.php 8 years ago PluginInformation.php 8 years ago TableScreen.php 8 years ago View.php 8 years ago ViewInterface.php 8 years ago
Addon.php
350 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class AC_Addon {
8
9 /**
10 * @var string
11 */
12 private $title;
13
14 /**
15 * @var string
16 */
17 private $description;
18
19 /**
20 * @var string
21 */
22 private $logo;
23
24 /**
25 * Icon is a small version of the logo. Mainly used on the promo banner.
26 *
27 * @var string
28 */
29 private $icon;
30
31 /**
32 * Plugin folder name
33 *
34 * @var AC_PluginInformation
35 */
36 private $addon;
37
38 /**
39 * Plugin basename. Example: plugin/plugin.php
40 *
41 * @var AC_PluginInformation[]
42 */
43 private $plugins;
44
45 /**
46 * External website link
47 *
48 * @var string
49 */
50 private $link;
51
52 /**
53 * Plugin URL. Place where the plugin can be downloaded from. Default is install plugin screen.
54 *
55 * @var string Url
56 */
57 private $plugin_url;
58
59 public function __construct( $addon_dirname ) {
60 $this->addon = new AC_PluginInformation( $addon_dirname );
61 }
62
63 /**
64 * @return string
65 */
66 public function get_title() {
67 return $this->title;
68 }
69
70 /**
71 * @param string $title
72 */
73 protected function set_title( $title ) {
74 $this->title = $title;
75
76 return $this;
77 }
78
79 /**
80 * Plugin folder name
81 *
82 * @return AC_PluginInformation[]
83 */
84 public function get_plugins() {
85 return $this->plugins;
86 }
87
88 /**
89 * @param string $slug Plugin folder name. Example: 'plugin/init.php' then directory name is 'plugin'.
90 */
91 protected function add_plugin( $plugin ) {
92 $this->plugins[] = new AC_PluginInformation( $plugin );
93
94 return $this;
95 }
96
97 /**
98 * @return AC_PluginInformation
99 */
100 public function get_plugin() {
101 return $this->plugins[0];
102 }
103
104 /**
105 * @return string
106 */
107 public function get_link() {
108 if ( null === $this->link ) {
109 $this->set_link( ac_get_site_utm_url( 'pricing-purchase', 'addon' ) );
110 }
111
112 return $this->link;
113 }
114
115 /**
116 * @param string $link
117 */
118 protected function set_link( $url ) {
119 if ( ac_helper()->string->is_valid_url( $url ) ) {
120 $this->link = $url;
121 }
122
123 return $this;
124 }
125
126 /**
127 * @return string
128 */
129 public function get_description() {
130 return $this->description;
131 }
132
133 /**
134 * @param string $description
135 */
136 protected function set_description( $description ) {
137 $this->description = $description;
138
139 return $this;
140 }
141
142 /**
143 * @return string
144 */
145 public function get_logo() {
146 return $this->logo;
147 }
148
149 /**
150 * @param string $logo
151 */
152 protected function set_logo( $logo ) {
153 $this->logo = $logo;
154
155 return $this;
156 }
157
158 /**
159 * @return string
160 */
161 public function get_icon() {
162 return $this->icon;
163 }
164
165 /**
166 * @param string $icon
167 */
168 protected function set_icon( $icon ) {
169 $this->icon = $icon;
170
171 return $this;
172 }
173
174 /**
175 * Plugin folder name
176 *
177 * @return string
178 */
179 public function get_slug() {
180 return $this->addon->get_dirname();
181 }
182
183 /**
184 * @return bool
185 */
186 public function is_installed() {
187 return $this->addon->is_installed();
188 }
189
190 /**
191 * @return bool
192 */
193 public function is_active() {
194 return $this->addon->is_active();
195 }
196
197 /**
198 * @return string|false Returns the plugin version if the plugin is installed, false otherwise
199 */
200 public function get_version() {
201 return $this->addon->get_version();
202 }
203
204 /**
205 * @return string Basename
206 */
207 public function get_basename() {
208 return $this->addon->get_basename();
209 }
210
211 /**
212 * @return bool
213 */
214 public function is_plugin_installed() {
215 return $this->get_plugin()->is_installed();
216 }
217
218 /**
219 * @return bool
220 */
221 public function is_plugin_active() {
222 return $this->get_plugin()->is_active();
223 }
224
225 /**
226 * @return string Basename
227 */
228 public function get_plugin_basename() {
229 return $this->get_plugin()->get_basename();
230 }
231
232 /**
233 * @return string
234 */
235 public function get_plugin_activation_url() {
236 return $this->get_activation_url( $this->get_plugin_basename() );
237 }
238
239 /**
240 * Icon
241 */
242 public function display_icon() {
243 if ( $this->get_icon() ) : ?>
244 <img class="icon <?php echo esc_attr( $this->get_slug() ); ?>" src="<?php echo esc_attr( $this->get_icon() ); ?>" alt="<?php echo esc_attr( $this->get_title() ); ?>">
245 <?php endif;
246 }
247
248 public function display_promo() {
249 if ( $this->get_icon() ) {
250 $this->display_icon();
251
252 return;
253 }
254
255 echo $this->get_title();
256 }
257
258 /**
259 * @return AC_Column_Placeholder
260 */
261 public function get_placeholder_column() {
262 $column = new AC_Column_Placeholder();
263 $column->set_addon( $this );
264
265 return $column;
266 }
267
268 /**
269 * @param string $title
270 *
271 * @return string
272 */
273 protected function get_fields_description( $title ) {
274 return sprintf( __( 'Display and edit %s fields in the posts overview in seconds!', 'codepress-admin-columns' ), $title );
275 }
276
277 /**
278 * Activate plugin
279 *
280 * @return string
281 */
282 public function get_activation_url( $basename ) {
283 return $this->get_plugin_action_url( 'activate', $basename );
284 }
285
286 /**
287 * Deactivate plugin
288 *
289 * @return string
290 */
291 public function get_deactivation_url( $basename ) {
292 return $this->get_plugin_action_url( 'deactivate', $basename );
293 }
294
295 /**
296 * Activate or Deactivate plugin
297 *
298 * @param string $action
299 *
300 * @return string
301 */
302 private function get_plugin_action_url( $action = 'activate', $basename ) {
303 $plugin_url = add_query_arg( array(
304 'action' => $action,
305 'plugin' => $basename,
306 'ac-redirect' => true,
307 ), admin_url( 'plugins.php' ) );
308
309 return wp_nonce_url( $plugin_url, $action . '-plugin_' . $basename );
310 }
311
312 /**
313 * @param string $plugin_url
314 *
315 * @return $this
316 */
317 public function set_plugin_url( $plugin_url ) {
318 $this->plugin_url = $plugin_url;
319
320 return $this;
321 }
322
323 /**
324 * @param string $search_term
325 *
326 * @return string
327 */
328 public function get_plugin_url() {
329 if ( null === $this->plugin_url ) {
330 $this->set_plugin_url( add_query_arg( array(
331 'tab' => 'search',
332 'type' => 'term',
333 's' => $this->get_title(),
334 ), admin_url( 'plugin-install.php' ) ) );
335 }
336
337 return $this->plugin_url;
338 }
339
340 /**
341 * Show notice on admin page only
342 *
343 * @return bool
344 */
345 public function show_missing_notice_on_current_page() {
346 return AC()->admin()->is_admin_screen() || AC()->table_screen()->get_current_list_screen();
347 }
348
349 }
350