1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TGM; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* List table class for handling plugins. |
7
|
|
|
* |
8
|
|
|
* Extends the WP_List_Table class to provide a future-compatible |
9
|
|
|
* way of listing out all required/recommended plugins. |
10
|
|
|
* |
11
|
|
|
* Gives users an interface similar to the Plugin Administration |
12
|
|
|
* area with similar (albeit stripped down) capabilities. |
13
|
|
|
* |
14
|
|
|
* This class also allows for the bulk install of plugins. |
15
|
|
|
* |
16
|
|
|
* @since 2.2.0 |
17
|
|
|
* |
18
|
|
|
* @package TGM-Plugin-Activation |
19
|
|
|
* @author Thomas Griffin |
20
|
|
|
* @author Gary Jones |
21
|
|
|
*/ |
22
|
|
|
class TGMPA_List_Table extends WP_List_Table { |
23
|
|
|
/** |
24
|
|
|
* TGMPA instance. |
25
|
|
|
* |
26
|
|
|
* @since 2.5.0 |
27
|
|
|
* |
28
|
|
|
* @var object |
29
|
|
|
*/ |
30
|
|
|
protected $tgmpa; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The currently chosen view. |
34
|
|
|
* |
35
|
|
|
* @since 2.5.0 |
36
|
|
|
* |
37
|
|
|
* @var string One of: 'all', 'install', 'update', 'activate' |
38
|
|
|
*/ |
39
|
|
|
public $view_context = 'all'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* The plugin counts for the various views. |
43
|
|
|
* |
44
|
|
|
* @since 2.5.0 |
45
|
|
|
* |
46
|
|
|
* @var array |
47
|
|
|
*/ |
48
|
|
|
protected $view_totals = array( |
49
|
|
|
'all' => 0, |
50
|
|
|
'install' => 0, |
51
|
|
|
'update' => 0, |
52
|
|
|
'activate' => 0, |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* References parent constructor and sets defaults for class. |
57
|
|
|
* |
58
|
|
|
* @since 2.2.0 |
59
|
|
|
*/ |
60
|
|
|
public function __construct() { |
61
|
|
|
$this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); |
62
|
|
|
|
63
|
|
|
parent::__construct( |
64
|
|
|
array( |
65
|
|
|
'singular' => 'plugin', |
66
|
|
|
'plural' => 'plugins', |
67
|
|
|
'ajax' => false, |
68
|
|
|
) |
69
|
|
|
); |
70
|
|
|
|
71
|
|
|
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) { |
72
|
|
|
$this->view_context = sanitize_key( $_REQUEST['plugin_status'] ); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) ); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Get a list of CSS classes for the <table> tag. |
80
|
|
|
* |
81
|
|
|
* Overruled to prevent the 'plural' argument from being added. |
82
|
|
|
* |
83
|
|
|
* @since 2.5.0 |
84
|
|
|
* |
85
|
|
|
* @return array CSS classnames. |
86
|
|
|
*/ |
87
|
|
|
public function get_table_classes() { |
88
|
|
|
return array( 'widefat', 'fixed' ); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Gathers and renames all of our plugin information to be used by WP_List_Table to create our table. |
93
|
|
|
* |
94
|
|
|
* @since 2.2.0 |
95
|
|
|
* |
96
|
|
|
* @return array $table_data Information for use in table. |
97
|
|
|
*/ |
98
|
|
|
protected function _gather_plugin_data() { |
|
|
|
|
99
|
|
|
// Load thickbox for plugin links. |
100
|
|
|
$this->tgmpa->admin_init(); |
101
|
|
|
$this->tgmpa->thickbox(); |
102
|
|
|
|
103
|
|
|
// Categorize the plugins which have open actions. |
104
|
|
|
$plugins = $this->categorize_plugins_to_views(); |
105
|
|
|
|
106
|
|
|
// Set the counts for the view links. |
107
|
|
|
$this->set_view_totals( $plugins ); |
108
|
|
|
|
109
|
|
|
// Prep variables for use and grab list of all installed plugins. |
110
|
|
|
$table_data = array(); |
111
|
|
|
$i = 0; |
112
|
|
|
|
113
|
|
|
// Redirect to the 'all' view if no plugins were found for the selected view context. |
114
|
|
|
if ( empty( $plugins[ $this->view_context ] ) ) { |
115
|
|
|
$this->view_context = 'all'; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { |
119
|
|
|
$table_data[ $i ]['sanitized_plugin'] = $plugin['name']; |
120
|
|
|
$table_data[ $i ]['slug'] = $slug; |
121
|
|
|
$table_data[ $i ]['plugin'] = '<strong>' . $this->tgmpa->get_info_link( $slug ) . '</strong>'; |
122
|
|
|
$table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); |
123
|
|
|
$table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); |
124
|
|
|
$table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); |
125
|
|
|
$table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); |
126
|
|
|
$table_data[ $i ]['minimum_version'] = $plugin['version']; |
127
|
|
|
$table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); |
128
|
|
|
|
129
|
|
|
// Prep the upgrade notice info. |
130
|
|
|
$upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); |
131
|
|
|
if ( ! empty( $upgrade_notice ) ) { |
132
|
|
|
$table_data[ $i ]['upgrade_notice'] = $upgrade_notice; |
133
|
|
|
|
134
|
|
|
add_action( "tgmpa_after_plugin_row_{$slug}", array( $this, 'wp_plugin_update_row' ), 10, 2 ); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
$table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin ); |
138
|
|
|
|
139
|
|
|
$i++; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
return $table_data; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Categorize the plugins which have open actions into views for the TGMPA page. |
147
|
|
|
* |
148
|
|
|
* @since 2.5.0 |
149
|
|
|
*/ |
150
|
|
|
protected function categorize_plugins_to_views() { |
151
|
|
|
$plugins = array( |
152
|
|
|
'all' => array(), // Meaning: all plugins which still have open actions. |
153
|
|
|
'install' => array(), |
154
|
|
|
'update' => array(), |
155
|
|
|
'activate' => array(), |
156
|
|
|
); |
157
|
|
|
|
158
|
|
|
foreach ( $this->tgmpa->plugins as $slug => $plugin ) { |
159
|
|
|
if ( $this->tgmpa->is_plugin_active( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) { |
160
|
|
|
// No need to display plugins if they are installed, up-to-date and active. |
161
|
|
|
continue; |
162
|
|
|
} else { |
163
|
|
|
$plugins['all'][ $slug ] = $plugin; |
164
|
|
|
|
165
|
|
|
if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
166
|
|
|
$plugins['install'][ $slug ] = $plugin; |
167
|
|
|
} else { |
168
|
|
|
if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
169
|
|
|
$plugins['update'][ $slug ] = $plugin; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
173
|
|
|
$plugins['activate'][ $slug ] = $plugin; |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
return $plugins; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Set the counts for the view links. |
184
|
|
|
* |
185
|
|
|
* @since 2.5.0 |
186
|
|
|
* |
187
|
|
|
* @param array $plugins Plugins order by view. |
188
|
|
|
*/ |
189
|
|
|
protected function set_view_totals( $plugins ) { |
190
|
|
|
foreach ( $plugins as $type => $list ) { |
191
|
|
|
$this->view_totals[ $type ] = count( $list ); |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Get the plugin required/recommended text string. |
197
|
|
|
* |
198
|
|
|
* @since 2.5.0 |
199
|
|
|
* |
200
|
|
|
* @param string $required Plugin required setting. |
201
|
|
|
* @return string |
202
|
|
|
*/ |
203
|
|
|
protected function get_plugin_advise_type_text( $required ) { |
204
|
|
|
if ( true === $required ) { |
205
|
|
|
return __( 'Required', 'tgmpa' ); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
return __( 'Recommended', 'tgmpa' ); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Get the plugin source type text string. |
213
|
|
|
* |
214
|
|
|
* @since 2.5.0 |
215
|
|
|
* |
216
|
|
|
* @param string $type Plugin type. |
217
|
|
|
* @return string |
218
|
|
|
*/ |
219
|
|
|
protected function get_plugin_source_type_text( $type ) { |
220
|
|
|
$string = ''; |
221
|
|
|
|
222
|
|
|
switch ( $type ) { |
223
|
|
|
case 'repo': |
224
|
|
|
$string = __( 'WordPress Repository', 'tgmpa' ); |
225
|
|
|
break; |
226
|
|
|
case 'external': |
227
|
|
|
$string = __( 'External Source', 'tgmpa' ); |
228
|
|
|
break; |
229
|
|
|
case 'bundled': |
230
|
|
|
$string = __( 'Pre-Packaged', 'tgmpa' ); |
231
|
|
|
break; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
return $string; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Determine the plugin status message. |
239
|
|
|
* |
240
|
|
|
* @since 2.5.0 |
241
|
|
|
* |
242
|
|
|
* @param string $slug Plugin slug. |
243
|
|
|
* @return string |
244
|
|
|
*/ |
245
|
|
|
protected function get_plugin_status_text( $slug ) { |
246
|
|
|
if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { |
247
|
|
|
return __( 'Not Installed', 'tgmpa' ); |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
if ( ! $this->tgmpa->is_plugin_active( $slug ) ) { |
251
|
|
|
$install_status = __( 'Installed But Not Activated', 'tgmpa' ); |
252
|
|
|
} else { |
253
|
|
|
$install_status = __( 'Active', 'tgmpa' ); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
$update_status = ''; |
257
|
|
|
|
258
|
|
|
if ( $this->tgmpa->does_plugin_require_update( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) { |
259
|
|
|
$update_status = __( 'Required Update not Available', 'tgmpa' ); |
260
|
|
|
|
261
|
|
|
} elseif ( $this->tgmpa->does_plugin_require_update( $slug ) ) { |
262
|
|
|
$update_status = __( 'Requires Update', 'tgmpa' ); |
263
|
|
|
|
264
|
|
|
} elseif ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { |
265
|
|
|
$update_status = __( 'Update recommended', 'tgmpa' ); |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
if ( '' === $update_status ) { |
269
|
|
|
return $install_status; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
return sprintf( |
273
|
|
|
/* translators: 1: install status, 2: update status */ |
274
|
|
|
_x( '%1$s, %2$s', 'Install/Update Status', 'tgmpa' ), |
275
|
|
|
$install_status, |
276
|
|
|
$update_status |
277
|
|
|
); |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* Sort plugins by Required/Recommended type and by alphabetical plugin name within each type. |
282
|
|
|
* |
283
|
|
|
* @since 2.5.0 |
284
|
|
|
* |
285
|
|
|
* @param array $items Prepared table items. |
286
|
|
|
* @return array Sorted table items. |
287
|
|
|
*/ |
288
|
|
|
public function sort_table_items( $items ) { |
289
|
|
|
$type = array(); |
290
|
|
|
$name = array(); |
291
|
|
|
|
292
|
|
|
foreach ( $items as $i => $plugin ) { |
293
|
|
|
$type[ $i ] = $plugin['type']; // Required / recommended. |
294
|
|
|
$name[ $i ] = $plugin['sanitized_plugin']; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); |
298
|
|
|
|
299
|
|
|
return $items; |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* Get an associative array ( id => link ) of the views available on this table. |
304
|
|
|
* |
305
|
|
|
* @since 2.5.0 |
306
|
|
|
* |
307
|
|
|
* @return array |
308
|
|
|
*/ |
309
|
|
|
public function get_views() { |
310
|
|
|
$status_links = array(); |
311
|
|
|
|
312
|
|
|
foreach ( $this->view_totals as $type => $count ) { |
313
|
|
|
if ( $count < 1 ) { |
314
|
|
|
continue; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
switch ( $type ) { |
318
|
|
|
case 'all': |
319
|
|
|
/* translators: 1: number of plugins. */ |
320
|
|
|
$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins', 'tgmpa' ); |
321
|
|
|
break; |
322
|
|
|
case 'install': |
323
|
|
|
/* translators: 1: number of plugins. */ |
324
|
|
|
$text = _n( 'To Install <span class="count">(%s)</span>', 'To Install <span class="count">(%s)</span>', $count, 'tgmpa' ); |
325
|
|
|
break; |
326
|
|
|
case 'update': |
327
|
|
|
/* translators: 1: number of plugins. */ |
328
|
|
|
$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count, 'tgmpa' ); |
329
|
|
|
break; |
330
|
|
|
case 'activate': |
331
|
|
|
/* translators: 1: number of plugins. */ |
332
|
|
|
$text = _n( 'To Activate <span class="count">(%s)</span>', 'To Activate <span class="count">(%s)</span>', $count, 'tgmpa' ); |
333
|
|
|
break; |
334
|
|
|
default: |
335
|
|
|
$text = ''; |
336
|
|
|
break; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
if ( ! empty( $text ) ) { |
340
|
|
|
|
341
|
|
|
$status_links[ $type ] = sprintf( |
342
|
|
|
'<a href="%s"%s>%s</a>', |
343
|
|
|
esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ), |
344
|
|
|
( $type === $this->view_context ) ? ' class="current"' : '', |
345
|
|
|
sprintf( $text, number_format_i18n( $count ) ) |
346
|
|
|
); |
347
|
|
|
} |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
return $status_links; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* Create default columns to display important plugin information |
355
|
|
|
* like type, action and status. |
356
|
|
|
* |
357
|
|
|
* @since 2.2.0 |
358
|
|
|
* |
359
|
|
|
* @param array $item Array of item data. |
360
|
|
|
* @param string $column_name The name of the column. |
361
|
|
|
* @return string |
362
|
|
|
*/ |
363
|
|
|
public function column_default( $item, $column_name ) { |
364
|
|
|
return $item[ $column_name ]; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* Required for bulk installing. |
369
|
|
|
* |
370
|
|
|
* Adds a checkbox for each plugin. |
371
|
|
|
* |
372
|
|
|
* @since 2.2.0 |
373
|
|
|
* |
374
|
|
|
* @param array $item Array of item data. |
375
|
|
|
* @return string The input checkbox with all necessary info. |
376
|
|
|
*/ |
377
|
|
|
public function column_cb( $item ) { |
378
|
|
|
return sprintf( |
379
|
|
|
'<input type="checkbox" name="%1$s[]" value="%2$s" id="%3$s" />', |
380
|
|
|
esc_attr( $this->_args['singular'] ), |
381
|
|
|
esc_attr( $item['slug'] ), |
382
|
|
|
esc_attr( $item['sanitized_plugin'] ) |
383
|
|
|
); |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* Create default title column along with the action links. |
388
|
|
|
* |
389
|
|
|
* @since 2.2.0 |
390
|
|
|
* |
391
|
|
|
* @param array $item Array of item data. |
392
|
|
|
* @return string The plugin name and action links. |
393
|
|
|
*/ |
394
|
|
|
public function column_plugin( $item ) { |
395
|
|
|
return sprintf( |
396
|
|
|
'%1$s %2$s', |
397
|
|
|
$item['plugin'], |
398
|
|
|
$this->row_actions( $this->get_row_actions( $item ), true ) |
399
|
|
|
); |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
/** |
403
|
|
|
* Create version information column. |
404
|
|
|
* |
405
|
|
|
* @since 2.5.0 |
406
|
|
|
* |
407
|
|
|
* @param array $item Array of item data. |
408
|
|
|
* @return string HTML-formatted version information. |
409
|
|
|
*/ |
410
|
|
|
public function column_version( $item ) { |
411
|
|
|
$output = array(); |
412
|
|
|
|
413
|
|
|
if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
414
|
|
|
$installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); |
415
|
|
|
|
416
|
|
|
$color = ''; |
417
|
|
|
if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) { |
418
|
|
|
$color = ' color: #ff0000; font-weight: bold;'; |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
$output[] = sprintf( |
422
|
|
|
'<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Installed version:', 'tgmpa' ) . '</p>', |
423
|
|
|
$color, |
424
|
|
|
$installed |
425
|
|
|
); |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
if ( ! empty( $item['minimum_version'] ) ) { |
429
|
|
|
$output[] = sprintf( |
430
|
|
|
'<p><span style="min-width: 32px; text-align: right; float: right;">%1$s</span>' . __( 'Minimum required version:', 'tgmpa' ) . '</p>', |
431
|
|
|
$item['minimum_version'] |
432
|
|
|
); |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
if ( ! empty( $item['available_version'] ) ) { |
436
|
|
|
$color = ''; |
437
|
|
|
if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) { |
438
|
|
|
$color = ' color: #71C671; font-weight: bold;'; |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
$output[] = sprintf( |
442
|
|
|
'<p><span style="min-width: 32px; text-align: right; float: right;%1$s">%2$s</span>' . __( 'Available version:', 'tgmpa' ) . '</p>', |
443
|
|
|
$color, |
444
|
|
|
$item['available_version'] |
445
|
|
|
); |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
if ( empty( $output ) ) { |
449
|
|
|
return ' '; // Let's not break the table layout. |
450
|
|
|
} else { |
451
|
|
|
return implode( "\n", $output ); |
452
|
|
|
} |
453
|
|
|
} |
454
|
|
|
|
455
|
|
|
/** |
456
|
|
|
* Sets default message within the plugins table if no plugins |
457
|
|
|
* are left for interaction. |
458
|
|
|
* |
459
|
|
|
* Hides the menu item to prevent the user from clicking and |
460
|
|
|
* getting a permissions error. |
461
|
|
|
* |
462
|
|
|
* @since 2.2.0 |
463
|
|
|
*/ |
464
|
|
|
public function no_items() { |
465
|
|
|
echo esc_html__( 'No plugins to install, update or activate.', 'tgmpa' ) . ' <a href="' . esc_url( self_admin_url() ) . '"> ' . esc_html( $this->tgmpa->strings['dashboard'] ) . '</a>'; |
466
|
|
|
echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>'; |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* Output all the column information within the table. |
471
|
|
|
* |
472
|
|
|
* @since 2.2.0 |
473
|
|
|
* |
474
|
|
|
* @return array $columns The column names. |
475
|
|
|
*/ |
476
|
|
|
public function get_columns() { |
477
|
|
|
$columns = array( |
478
|
|
|
'cb' => '<input type="checkbox" />', |
479
|
|
|
'plugin' => __( 'Plugin', 'tgmpa' ), |
480
|
|
|
'source' => __( 'Source', 'tgmpa' ), |
481
|
|
|
'type' => __( 'Type', 'tgmpa' ), |
482
|
|
|
); |
483
|
|
|
|
484
|
|
|
if ( 'all' === $this->view_context || 'update' === $this->view_context ) { |
485
|
|
|
$columns['version'] = __( 'Version', 'tgmpa' ); |
486
|
|
|
$columns['status'] = __( 'Status', 'tgmpa' ); |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
return apply_filters( 'tgmpa_table_columns', $columns ); |
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
/** |
493
|
|
|
* Get name of default primary column |
494
|
|
|
* |
495
|
|
|
* @since 2.5.0 / WP 4.3+ compatibility |
496
|
|
|
* @access protected |
497
|
|
|
* |
498
|
|
|
* @return string |
499
|
|
|
*/ |
500
|
|
|
protected function get_default_primary_column_name() { |
501
|
|
|
return 'plugin'; |
502
|
|
|
} |
503
|
|
|
|
504
|
|
|
/** |
505
|
|
|
* Get the name of the primary column. |
506
|
|
|
* |
507
|
|
|
* @since 2.5.0 / WP 4.3+ compatibility |
508
|
|
|
* @access protected |
509
|
|
|
* |
510
|
|
|
* @return string The name of the primary column. |
511
|
|
|
*/ |
512
|
|
|
protected function get_primary_column_name() { |
513
|
|
|
if ( method_exists( 'WP_List_Table', 'get_primary_column_name' ) ) { |
514
|
|
|
return parent::get_primary_column_name(); |
515
|
|
|
} else { |
516
|
|
|
return $this->get_default_primary_column_name(); |
517
|
|
|
} |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
/** |
521
|
|
|
* Get the actions which are relevant for a specific plugin row. |
522
|
|
|
* |
523
|
|
|
* @since 2.5.0 |
524
|
|
|
* |
525
|
|
|
* @param array $item Array of item data. |
526
|
|
|
* @return array Array with relevant action links. |
527
|
|
|
*/ |
528
|
|
|
protected function get_row_actions( $item ) { |
529
|
|
|
$actions = array(); |
530
|
|
|
$action_links = array(); |
531
|
|
|
|
532
|
|
|
// Display the 'Install' action link if the plugin is not yet available. |
533
|
|
|
if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { |
534
|
|
|
/* translators: %2$s: plugin name in screen reader markup */ |
535
|
|
|
$actions['install'] = __( 'Install %2$s', 'tgmpa' ); |
536
|
|
|
} else { |
537
|
|
|
// Display the 'Update' action link if an update is available and WP complies with plugin minimum. |
538
|
|
|
if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) { |
539
|
|
|
/* translators: %2$s: plugin name in screen reader markup */ |
540
|
|
|
$actions['update'] = __( 'Update %2$s', 'tgmpa' ); |
541
|
|
|
} |
542
|
|
|
|
543
|
|
|
// Display the 'Activate' action link, but only if the plugin meets the minimum version. |
544
|
|
|
if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) { |
545
|
|
|
/* translators: %2$s: plugin name in screen reader markup */ |
546
|
|
|
$actions['activate'] = __( 'Activate %2$s', 'tgmpa' ); |
547
|
|
|
} |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
// Create the actual links. |
551
|
|
|
foreach ( $actions as $action => $text ) { |
552
|
|
|
$nonce_url = wp_nonce_url( |
553
|
|
|
add_query_arg( |
554
|
|
|
array( |
555
|
|
|
'plugin' => urlencode( $item['slug'] ), |
556
|
|
|
'tgmpa-' . $action => $action . '-plugin', |
557
|
|
|
), |
558
|
|
|
$this->tgmpa->get_tgmpa_url() |
559
|
|
|
), |
560
|
|
|
'tgmpa-' . $action, |
561
|
|
|
'tgmpa-nonce' |
562
|
|
|
); |
563
|
|
|
|
564
|
|
|
$action_links[ $action ] = sprintf( |
565
|
|
|
'<a href="%1$s">' . esc_html( $text ) . '</a>', // $text contains the second placeholder. |
566
|
|
|
esc_url( $nonce_url ), |
567
|
|
|
'<span class="screen-reader-text">' . esc_html( $item['sanitized_plugin'] ) . '</span>' |
568
|
|
|
); |
569
|
|
|
} |
570
|
|
|
|
571
|
|
|
$prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : ''; |
572
|
|
|
return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context ); |
573
|
|
|
} |
574
|
|
|
|
575
|
|
|
/** |
576
|
|
|
* Generates content for a single row of the table. |
577
|
|
|
* |
578
|
|
|
* @since 2.5.0 |
579
|
|
|
* |
580
|
|
|
* @param object $item The current item. |
581
|
|
|
*/ |
582
|
|
|
public function single_row( $item ) { |
583
|
|
|
echo '<tr class="' . esc_attr( 'tgmpa-type-' . strtolower( $item['type'] ) ) . '">'; |
584
|
|
|
$this->single_row_columns( $item ); |
585
|
|
|
echo '</tr>'; |
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* Fires after each specific row in the TGMPA Plugins list table. |
589
|
|
|
* |
590
|
|
|
* The dynamic portion of the hook name, `$item['slug']`, refers to the slug |
591
|
|
|
* for the plugin. |
592
|
|
|
* |
593
|
|
|
* @since 2.5.0 |
594
|
|
|
*/ |
595
|
|
|
do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context ); |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
/** |
599
|
|
|
* Show the upgrade notice below a plugin row if there is one. |
600
|
|
|
* |
601
|
|
|
* @since 2.5.0 |
602
|
|
|
* |
603
|
|
|
* @see /wp-admin/includes/update.php |
604
|
|
|
* |
605
|
|
|
* @param string $slug Plugin slug. |
606
|
|
|
* @param array $item The information available in this table row. |
607
|
|
|
* @return null Return early if upgrade notice is empty. |
608
|
|
|
*/ |
609
|
|
|
public function wp_plugin_update_row( $slug, $item ) { |
610
|
|
|
if ( empty( $item['upgrade_notice'] ) ) { |
611
|
|
|
return; |
612
|
|
|
} |
613
|
|
|
|
614
|
|
|
echo ' |
615
|
|
|
<tr class="plugin-update-tr"> |
616
|
|
|
<td colspan="', absint( $this->get_column_count() ), '" class="plugin-update colspanchange"> |
617
|
|
|
<div class="update-message">', |
618
|
|
|
esc_html__( 'Upgrade message from the plugin author:', 'tgmpa' ), |
619
|
|
|
' <strong>', wp_kses_data( $item['upgrade_notice'] ), '</strong> |
620
|
|
|
</div> |
621
|
|
|
</td> |
622
|
|
|
</tr>'; |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
/** |
626
|
|
|
* Extra controls to be displayed between bulk actions and pagination. |
627
|
|
|
* |
628
|
|
|
* @since 2.5.0 |
629
|
|
|
* |
630
|
|
|
* @param string $which 'top' or 'bottom' table navigation. |
631
|
|
|
*/ |
632
|
|
|
public function extra_tablenav( $which ) { |
633
|
|
|
if ( 'bottom' === $which ) { |
634
|
|
|
$this->tgmpa->show_tgmpa_version(); |
635
|
|
|
} |
636
|
|
|
} |
637
|
|
|
|
638
|
|
|
/** |
639
|
|
|
* Defines the bulk actions for handling registered plugins. |
640
|
|
|
* |
641
|
|
|
* @since 2.2.0 |
642
|
|
|
* |
643
|
|
|
* @return array $actions The bulk actions for the plugin install table. |
644
|
|
|
*/ |
645
|
|
|
public function get_bulk_actions() { |
646
|
|
|
|
647
|
|
|
$actions = array(); |
648
|
|
|
|
649
|
|
|
if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) { |
650
|
|
|
if ( current_user_can( 'install_plugins' ) ) { |
651
|
|
|
$actions['tgmpa-bulk-install'] = __( 'Install', 'tgmpa' ); |
652
|
|
|
} |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
if ( 'install' !== $this->view_context ) { |
656
|
|
|
if ( current_user_can( 'update_plugins' ) ) { |
657
|
|
|
$actions['tgmpa-bulk-update'] = __( 'Update', 'tgmpa' ); |
658
|
|
|
} |
659
|
|
|
if ( current_user_can( 'activate_plugins' ) ) { |
660
|
|
|
$actions['tgmpa-bulk-activate'] = __( 'Activate', 'tgmpa' ); |
661
|
|
|
} |
662
|
|
|
} |
663
|
|
|
|
664
|
|
|
return $actions; |
665
|
|
|
} |
666
|
|
|
|
667
|
|
|
/** |
668
|
|
|
* Processes bulk installation and activation actions. |
669
|
|
|
* |
670
|
|
|
* The bulk installation process looks for the $_POST information and passes that |
671
|
|
|
* through if a user has to use WP_Filesystem to enter their credentials. |
672
|
|
|
* |
673
|
|
|
* @since 2.2.0 |
674
|
|
|
*/ |
675
|
|
|
public function process_bulk_actions() { |
|
|
|
|
676
|
|
|
// Bulk installation process. |
677
|
|
|
if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) { |
678
|
|
|
|
679
|
|
|
check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
680
|
|
|
|
681
|
|
|
$install_type = 'install'; |
682
|
|
|
if ( 'tgmpa-bulk-update' === $this->current_action() ) { |
683
|
|
|
$install_type = 'update'; |
684
|
|
|
} |
685
|
|
|
|
686
|
|
|
$plugins_to_install = array(); |
687
|
|
|
|
688
|
|
|
// Did user actually select any plugins to install/update ? |
689
|
|
View Code Duplication |
if ( empty( $_POST['plugin'] ) ) { |
690
|
|
|
if ( 'install' === $install_type ) { |
691
|
|
|
$message = __( 'No plugins were selected to be installed. No action taken.', 'tgmpa' ); |
692
|
|
|
} else { |
693
|
|
|
$message = __( 'No plugins were selected to be updated. No action taken.', 'tgmpa' ); |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
echo '<div id="message" class="error"><p>', esc_html( $message ), '</p></div>'; |
697
|
|
|
|
698
|
|
|
return false; |
699
|
|
|
} |
700
|
|
|
|
701
|
|
|
if ( is_array( $_POST['plugin'] ) ) { |
702
|
|
|
$plugins_to_install = (array) $_POST['plugin']; |
703
|
|
|
} elseif ( is_string( $_POST['plugin'] ) ) { |
704
|
|
|
// Received via Filesystem page - un-flatten array (WP bug #19643). |
705
|
|
|
$plugins_to_install = explode( ',', $_POST['plugin'] ); |
706
|
|
|
} |
707
|
|
|
|
708
|
|
|
// Sanitize the received input. |
709
|
|
|
$plugins_to_install = array_map( 'urldecode', $plugins_to_install ); |
710
|
|
|
$plugins_to_install = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins_to_install ); |
711
|
|
|
|
712
|
|
|
// Validate the received input. |
713
|
|
|
foreach ( $plugins_to_install as $key => $slug ) { |
714
|
|
|
// Check if the plugin was registered with TGMPA and remove if not. |
715
|
|
|
if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) { |
716
|
|
|
unset( $plugins_to_install[ $key ] ); |
717
|
|
|
continue; |
718
|
|
|
} |
719
|
|
|
|
720
|
|
|
// For install: make sure this is a plugin we *can* install and not one already installed. |
721
|
|
|
if ( 'install' === $install_type && true === $this->tgmpa->is_plugin_installed( $slug ) ) { |
722
|
|
|
unset( $plugins_to_install[ $key ] ); |
723
|
|
|
} |
724
|
|
|
|
725
|
|
|
// For updates: make sure this is a plugin we *can* update (update available and WP version ok). |
726
|
|
|
if ( 'update' === $install_type && false === $this->tgmpa->is_plugin_updatetable( $slug ) ) { |
727
|
|
|
unset( $plugins_to_install[ $key ] ); |
728
|
|
|
} |
729
|
|
|
} |
730
|
|
|
|
731
|
|
|
// No need to proceed further if we have no plugins to handle. |
732
|
|
View Code Duplication |
if ( empty( $plugins_to_install ) ) { |
733
|
|
|
if ( 'install' === $install_type ) { |
734
|
|
|
$message = __( 'No plugins are available to be installed at this time.', 'tgmpa' ); |
735
|
|
|
} else { |
736
|
|
|
$message = __( 'No plugins are available to be updated at this time.', 'tgmpa' ); |
737
|
|
|
} |
738
|
|
|
|
739
|
|
|
echo '<div id="message" class="error"><p>', esc_html( $message ), '</p></div>'; |
740
|
|
|
|
741
|
|
|
return false; |
742
|
|
|
} |
743
|
|
|
|
744
|
|
|
// Pass all necessary information if WP_Filesystem is needed. |
745
|
|
|
$url = wp_nonce_url( |
746
|
|
|
$this->tgmpa->get_tgmpa_url(), |
747
|
|
|
'bulk-' . $this->_args['plural'] |
748
|
|
|
); |
749
|
|
|
|
750
|
|
|
// Give validated data back to $_POST which is the only place the filesystem looks for extra fields. |
751
|
|
|
$_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. |
752
|
|
|
|
753
|
|
|
$method = ''; // Leave blank so WP_Filesystem can populate it as necessary. |
754
|
|
|
$fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem. |
755
|
|
|
|
756
|
|
|
$creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, $fields ); |
757
|
|
|
if ( false === $creds ) { |
758
|
|
|
return true; // Stop the normal page form from displaying, credential request form will be shown. |
759
|
|
|
} |
760
|
|
|
|
761
|
|
|
// Now we have some credentials, setup WP_Filesystem. |
762
|
|
|
if ( ! WP_Filesystem( $creds ) ) { |
|
|
|
|
763
|
|
|
// Our credentials were no good, ask the user for them again. |
764
|
|
|
request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, $fields ); |
765
|
|
|
|
766
|
|
|
return true; |
767
|
|
|
} |
768
|
|
|
|
769
|
|
|
/* If we arrive here, we have the filesystem */ |
770
|
|
|
|
771
|
|
|
// Store all information in arrays since we are processing a bulk installation. |
772
|
|
|
$names = array(); |
773
|
|
|
$sources = array(); // Needed for installs. |
774
|
|
|
$file_paths = array(); // Needed for upgrades. |
775
|
|
|
$to_inject = array(); // Information to inject into the update_plugins transient. |
776
|
|
|
|
777
|
|
|
// Prepare the data for validated plugins for the install/upgrade. |
778
|
|
|
foreach ( $plugins_to_install as $slug ) { |
779
|
|
|
$name = $this->tgmpa->plugins[ $slug ]['name']; |
780
|
|
|
$source = $this->tgmpa->get_download_url( $slug ); |
781
|
|
|
|
782
|
|
|
if ( ! empty( $name ) && ! empty( $source ) ) { |
783
|
|
|
$names[] = $name; |
784
|
|
|
|
785
|
|
|
switch ( $install_type ) { |
786
|
|
|
|
787
|
|
|
case 'install': |
788
|
|
|
$sources[] = $source; |
789
|
|
|
break; |
790
|
|
|
|
791
|
|
|
case 'update': |
792
|
|
|
$file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
793
|
|
|
$to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; |
794
|
|
|
$to_inject[ $slug ]['source'] = $source; |
795
|
|
|
break; |
796
|
|
|
} |
797
|
|
|
} |
798
|
|
|
} |
799
|
|
|
unset( $slug, $name, $source ); |
800
|
|
|
|
801
|
|
|
if ( ! class_exists( 'Plugin_Upgrader', false ) ) { |
802
|
|
|
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
803
|
|
|
} |
804
|
|
|
|
805
|
|
|
// Create a new instance of TGMPA_Bulk_Installer. |
806
|
|
|
$installer = new TGMPA_Bulk_Installer( |
807
|
|
|
new TGMPA_Bulk_Installer_Skin( |
808
|
|
|
array( |
809
|
|
|
'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ), |
810
|
|
|
'nonce' => 'bulk-' . $this->_args['plural'], |
811
|
|
|
'names' => $names, |
812
|
|
|
'install_type' => $install_type, |
813
|
|
|
) |
814
|
|
|
) |
815
|
|
|
); |
816
|
|
|
|
817
|
|
|
// Wrap the install process with the appropriate HTML. |
818
|
|
|
echo '<div class="tgmpa">', |
819
|
|
|
'<h2 style="font-size: 23px; font-weight: 400; line-height: 29px; margin: 0; padding: 9px 15px 4px 0;">', esc_html( get_admin_page_title() ), '</h2> |
820
|
|
|
<div class="update-php" style="width: 100%; height: 98%; min-height: 850px; padding-top: 1px;">'; |
821
|
|
|
|
822
|
|
|
// Process the bulk installation submissions. |
823
|
|
|
add_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 ); |
824
|
|
|
|
825
|
|
|
if ( 'tgmpa-bulk-update' === $this->current_action() ) { |
826
|
|
|
// Inject our info into the update transient. |
827
|
|
|
$this->tgmpa->inject_update_info( $to_inject ); |
828
|
|
|
|
829
|
|
|
$installer->bulk_upgrade( $file_paths ); |
830
|
|
|
} else { |
831
|
|
|
$installer->bulk_install( $sources ); |
832
|
|
|
} |
833
|
|
|
|
834
|
|
|
remove_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1 ); |
835
|
|
|
|
836
|
|
|
echo '</div></div>'; |
837
|
|
|
|
838
|
|
|
return true; |
839
|
|
|
} |
840
|
|
|
|
841
|
|
|
// Bulk activation process. |
842
|
|
|
if ( 'tgmpa-bulk-activate' === $this->current_action() ) { |
843
|
|
|
check_admin_referer( 'bulk-' . $this->_args['plural'] ); |
844
|
|
|
|
845
|
|
|
// Did user actually select any plugins to activate ? |
846
|
|
|
if ( empty( $_POST['plugin'] ) ) { |
847
|
|
|
echo '<div id="message" class="error"><p>', esc_html__( 'No plugins were selected to be activated. No action taken.', 'tgmpa' ), '</p></div>'; |
848
|
|
|
|
849
|
|
|
return false; |
850
|
|
|
} |
851
|
|
|
|
852
|
|
|
// Grab plugin data from $_POST. |
853
|
|
|
$plugins = array(); |
854
|
|
|
if ( isset( $_POST['plugin'] ) ) { |
855
|
|
|
$plugins = array_map( 'urldecode', (array) $_POST['plugin'] ); |
856
|
|
|
$plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins ); |
857
|
|
|
} |
858
|
|
|
|
859
|
|
|
$plugins_to_activate = array(); |
860
|
|
|
$plugin_names = array(); |
861
|
|
|
|
862
|
|
|
// Grab the file paths for the selected & inactive plugins from the registration array. |
863
|
|
|
foreach ( $plugins as $slug ) { |
864
|
|
|
if ( $this->tgmpa->can_plugin_activate( $slug ) ) { |
865
|
|
|
$plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; |
866
|
|
|
$plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; |
867
|
|
|
} |
868
|
|
|
} |
869
|
|
|
unset( $slug ); |
870
|
|
|
|
871
|
|
|
// Return early if there are no plugins to activate. |
872
|
|
|
if ( empty( $plugins_to_activate ) ) { |
873
|
|
|
echo '<div id="message" class="error"><p>', esc_html__( 'No plugins are available to be activated at this time.', 'tgmpa' ), '</p></div>'; |
874
|
|
|
|
875
|
|
|
return false; |
876
|
|
|
} |
877
|
|
|
|
878
|
|
|
// Now we are good to go - let's start activating plugins. |
879
|
|
|
$activate = activate_plugins( $plugins_to_activate ); |
880
|
|
|
|
881
|
|
|
if ( is_wp_error( $activate ) ) { |
882
|
|
|
echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>'; |
883
|
|
|
} else { |
884
|
|
|
$count = count( $plugin_names ); // Count so we can use _n function. |
885
|
|
|
$plugin_names = array_map( array( TGMPA_Utils::class, 'wrap_in_strong' ), $plugin_names ); |
886
|
|
|
$last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability. |
887
|
|
|
$imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); |
888
|
|
|
|
889
|
|
|
printf( // WPCS: xss ok. |
890
|
|
|
'<div id="message" class="updated"><p>%1$s %2$s.</p></div>', |
891
|
|
|
esc_html( _n( 'The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'tgmpa' ) ), |
892
|
|
|
$imploded |
893
|
|
|
); |
894
|
|
|
|
895
|
|
|
// Update recently activated plugins option. |
896
|
|
|
$recent = (array) get_option( 'recently_activated' ); |
897
|
|
|
foreach ( $plugins_to_activate as $plugin => $time ) { |
898
|
|
|
if ( isset( $recent[ $plugin ] ) ) { |
899
|
|
|
unset( $recent[ $plugin ] ); |
900
|
|
|
} |
901
|
|
|
} |
902
|
|
|
update_option( 'recently_activated', $recent ); |
903
|
|
|
} |
904
|
|
|
|
905
|
|
|
unset( $_POST ); // Reset the $_POST variable in case user wants to perform one action after another. |
906
|
|
|
|
907
|
|
|
return true; |
908
|
|
|
} |
909
|
|
|
|
910
|
|
|
return false; |
911
|
|
|
} |
912
|
|
|
|
913
|
|
|
/** |
914
|
|
|
* Prepares all of our information to be outputted into a usable table. |
915
|
|
|
* |
916
|
|
|
* @since 2.2.0 |
917
|
|
|
*/ |
918
|
|
|
public function prepare_items() { |
919
|
|
|
$columns = $this->get_columns(); // Get all necessary column information. |
920
|
|
|
$hidden = array(); // No columns to hide, but we must set as an array. |
921
|
|
|
$sortable = array(); // No reason to make sortable columns. |
922
|
|
|
$primary = $this->get_primary_column_name(); // Column which has the row actions. |
923
|
|
|
$this->_column_headers = array( $columns, $hidden, $sortable, $primary ); // Get all necessary column headers. |
924
|
|
|
|
925
|
|
|
// Process our bulk activations here. |
926
|
|
|
if ( 'tgmpa-bulk-activate' === $this->current_action() ) { |
927
|
|
|
$this->process_bulk_actions(); |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
// Store all of our plugin data into $items array so WP_List_Table can use it. |
931
|
|
|
$this->items = apply_filters( 'tgmpa_table_data_items', $this->_gather_plugin_data() ); |
932
|
|
|
} |
933
|
|
|
|
934
|
|
|
/* *********** DEPRECATED METHODS *********** */ |
935
|
|
|
|
936
|
|
|
/** |
937
|
|
|
* Retrieve plugin data, given the plugin name. |
938
|
|
|
* |
939
|
|
|
* @since 2.2.0 |
940
|
|
|
* @deprecated 2.5.0 use {@see TGM_Plugin_Activation::_get_plugin_data_from_name()} instead. |
941
|
|
|
* @see TGM_Plugin_Activation::_get_plugin_data_from_name() |
942
|
|
|
* |
943
|
|
|
* @param string $name Name of the plugin, as it was registered. |
944
|
|
|
* @param string $data Optional. Array key of plugin data to return. Default is slug. |
945
|
|
|
* @return string|boolean Plugin slug if found, false otherwise. |
946
|
|
|
*/ |
947
|
|
|
protected function _get_plugin_data_from_name( $name, $data = 'slug' ) { |
|
|
|
|
948
|
|
|
_deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'TGM_Plugin_Activation::_get_plugin_data_from_name()' ); |
949
|
|
|
|
950
|
|
|
return $this->tgmpa->_get_plugin_data_from_name( $name, $data ); |
951
|
|
|
} |
952
|
|
|
} |
953
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.