MPSUM_Admin.php
7 years ago
MPSUM_Admin_Advanced.php
7 years ago
MPSUM_Admin_Advanced_Preview.php
7 years ago
MPSUM_Admin_Ajax.php
7 years ago
MPSUM_Admin_Bar.php
7 years ago
MPSUM_Admin_Core.php
7 years ago
MPSUM_Admin_Dashboard.php
7 years ago
MPSUM_Admin_Help.php
7 years ago
MPSUM_Admin_Logs.php
7 years ago
MPSUM_Admin_Plugins.php
7 years ago
MPSUM_Admin_Screen_Options.php
7 years ago
MPSUM_Admin_Themes.php
7 years ago
MPSUM_Advanced_Premium.php
7 years ago
MPSUM_Check_Plugin_Install_Status.php
7 years ago
MPSUM_Check_Theme_Install_Status.php
7 years ago
MPSUM_Commands.php
7 years ago
MPSUM_Disable_Updates.php
7 years ago
MPSUM_Disable_Updates_All.php
7 years ago
MPSUM_Disable_Updates_Plugins.php
7 years ago
MPSUM_Disable_Updates_Themes.php
7 years ago
MPSUM_Disable_Updates_Translations.php
7 years ago
MPSUM_Disable_Updates_WordPress.php
7 years ago
MPSUM_Exclude_Users.php
7 years ago
MPSUM_Force_Updates.php
7 years ago
MPSUM_List_Table.php
7 years ago
MPSUM_Logs.php
7 years ago
MPSUM_Logs_List_Table.php
7 years ago
MPSUM_Plugins_List_Table.php
7 years ago
MPSUM_Reset_Options.php
7 years ago
MPSUM_Themes_List_Table.php
7 years ago
MPSUM_UpdraftCentral.php
7 years ago
MPSUM_UpdraftCentral_EUM_Commands.php
7 years ago
MPSUM_Utils.php
7 years ago
easy-updates-manager-notices.php
7 years ago
updraft-notices.php
7 years ago
MPSUM_Plugins_List_Table.php
698 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) die('No direct access.'); |
| 3 | /** |
| 4 | * Easy Updates Manager Plugins List Table class. |
| 5 | * |
| 6 | * @package WordPress |
| 7 | * @subpackage MPSUM_List_Table |
| 8 | * @since 5.0.0 |
| 9 | * @access private |
| 10 | */ |
| 11 | class MPSUM_Plugins_List_Table extends MPSUM_List_Table { |
| 12 | |
| 13 | private $tab = 'plugins'; |
| 14 | |
| 15 | private $status = 'all'; |
| 16 | |
| 17 | private $page = '1'; |
| 18 | |
| 19 | /** |
| 20 | * Constructor. |
| 21 | * |
| 22 | * @since 3.1.0 |
| 23 | * @access public |
| 24 | * |
| 25 | * @see WP_List_Table::__construct() for more information on default arguments. |
| 26 | * |
| 27 | * @param array $args An associative array of arguments. |
| 28 | */ |
| 29 | public function __construct($args = array()) { |
| 30 | |
| 31 | parent::__construct(array( |
| 32 | 'singular' => 'plugin', |
| 33 | 'plural' => 'plugins', |
| 34 | 'screen' => isset($args['screen']) ? $args['screen'] : 'eum_plugins_tab', |
| 35 | 'ajax' => true |
| 36 | )); |
| 37 | |
| 38 | // Get plugins transient |
| 39 | $this->plugins_transient = get_site_transient('update_plugins'); |
| 40 | |
| 41 | if (isset($_REQUEST['action']) && 'eum_ajax' === $_REQUEST['action']) { |
| 42 | $this->status = 'all'; |
| 43 | if (isset($_REQUEST['view']) && in_array($_REQUEST['view'], array('update_disabled', 'update_enabled', 'automatic'))) { |
| 44 | $this->status = $_REQUEST['view']; |
| 45 | } |
| 46 | |
| 47 | if (isset($_REQUEST['s'])) |
| 48 | $_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s'])); |
| 49 | |
| 50 | $this->page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : '1'; |
| 51 | } else { |
| 52 | $this->status = 'all'; |
| 53 | if (isset($args['view']) && in_array($args['view'], array('update_disabled', 'update_enabled', 'automatic'))) { |
| 54 | $this->status = $args['view']; |
| 55 | } |
| 56 | |
| 57 | $this->page = isset($args['paged']) ? $args['paged'] : '1'; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Get table classes |
| 63 | * |
| 64 | * @return array |
| 65 | */ |
| 66 | protected function get_table_classes() { |
| 67 | return array('widefat', $this->_args['plural']); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Ajax user capability check |
| 72 | * |
| 73 | * @return boolean |
| 74 | */ |
| 75 | public function ajax_user_can() { |
| 76 | return current_user_can('activate_plugins'); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Prepares plugin items to display |
| 81 | * |
| 82 | * Prepares plugin items by setting pagination variables, order, filter |
| 83 | */ |
| 84 | public function prepare_items() { |
| 85 | |
| 86 | global $orderby, $order, $totals; |
| 87 | $order = 'DESC'; |
| 88 | $orderby = 'Name'; |
| 89 | |
| 90 | /** |
| 91 | * Filter the full array of plugins to list in the Plugins list table. |
| 92 | * |
| 93 | * @since 3.0.0 |
| 94 | * |
| 95 | * @see get_plugins() |
| 96 | * |
| 97 | * @param array $plugins An array of plugins to display in the list table. |
| 98 | */ |
| 99 | if (!function_exists('get_plugins')) { |
| 100 | include_once ABSPATH . "wp-admin/includes/plugin.php"; |
| 101 | } |
| 102 | |
| 103 | $plugins = array( |
| 104 | 'all' => apply_filters('all_plugins', get_plugins()), |
| 105 | 'update_enabled' => array(), |
| 106 | 'update_disabled' => array(), |
| 107 | 'automatic' => array() |
| 108 | ); |
| 109 | |
| 110 | $screen = $this->screen; |
| 111 | |
| 112 | |
| 113 | $plugin_info = get_site_transient('update_plugins'); |
| 114 | |
| 115 | $plugin_options = MPSUM_Updates_Manager::get_options('plugins'); |
| 116 | $plugin_automatic_options = MPSUM_Updates_Manager::get_options('plugins_automatic'); |
| 117 | foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) { |
| 118 | // Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide. |
| 119 | if (isset($plugin_info->response[$plugin_file])) { |
| 120 | $plugins['all'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->response[$plugin_file], $plugin_data); |
| 121 | } elseif (isset($plugin_info->no_update[$plugin_file])) { |
| 122 | $plugins['all'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->no_update[$plugin_file], $plugin_data); |
| 123 | } |
| 124 | |
| 125 | |
| 126 | if (false !== $key = array_search($plugin_file, $plugin_options)) { |
| 127 | $plugins['update_disabled'][$plugin_file] = $plugin_data; |
| 128 | } else { |
| 129 | $plugins['update_enabled'][$plugin_file] = $plugin_data; |
| 130 | if (in_array($plugin_file, $plugin_automatic_options)) { |
| 131 | $plugins['automatic'][$plugin_file] = $plugin_data; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | $totals = array(); |
| 137 | foreach ($plugins as $type => $list) |
| 138 | $totals[$type] = count($list); |
| 139 | |
| 140 | // Disable the automatic updates view |
| 141 | $core_options = MPSUM_Updates_Manager::get_options('core'); |
| 142 | if (isset($core_options['automatic_plugin_updates']) && 'individual' !== $core_options['automatic_plugin_updates']) { |
| 143 | unset($totals['automatic']); |
| 144 | $plugins['automatic'] = array(); |
| 145 | } |
| 146 | |
| 147 | if (empty($plugins[$this->status])) |
| 148 | $this->status = 'all'; |
| 149 | |
| 150 | $this->items = array(); |
| 151 | foreach ($plugins[$this->status] as $plugin_file => $plugin_data) { |
| 152 | // Translate, Don't Apply Markup, Sanitize HTML |
| 153 | remove_action("after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2); |
| 154 | $this->items[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true); |
| 155 | } |
| 156 | |
| 157 | $total_this_page = $totals[$this->status]; |
| 158 | |
| 159 | // Get plugins per page |
| 160 | $user_id = get_current_user_id(); |
| 161 | $plugins_per_page = get_user_meta($user_id, 'mpsum_items_per_page', true); |
| 162 | if (! is_numeric($plugins_per_page)) { |
| 163 | $plugins_per_page = 100; |
| 164 | } |
| 165 | |
| 166 | $start = ($this->page - 1) * $plugins_per_page; |
| 167 | |
| 168 | if ($total_this_page > $plugins_per_page) |
| 169 | $this->items = array_slice($this->items, $start, $plugins_per_page); |
| 170 | |
| 171 | $this->set_pagination_args(array( |
| 172 | 'total_items' => $total_this_page, |
| 173 | 'per_page' => $plugins_per_page, |
| 174 | 'total_pages' => ceil($total_this_page / $plugins_per_page), |
| 175 | // Set plugin status value (useful for AJAX) |
| 176 | 'view' => $this->status, |
| 177 | 'tab' => $this->tab, |
| 178 | 'paged' => $this->page |
| 179 | )); |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Captures response content of ajax call and returns it |
| 184 | */ |
| 185 | public function ajax_response() { |
| 186 | |
| 187 | $this->prepare_items(); |
| 188 | extract($this->_args); |
| 189 | extract($this->_pagination_args, EXTR_SKIP); |
| 190 | |
| 191 | ob_start(); |
| 192 | $this->views(); |
| 193 | $views = ob_get_clean(); |
| 194 | |
| 195 | ob_start(); |
| 196 | if (!empty($_REQUEST['no_placeholder'])) { |
| 197 | $this->display_rows(); |
| 198 | } else { |
| 199 | $this->display_rows_or_placeholder(); |
| 200 | } |
| 201 | $rows = ob_get_clean(); |
| 202 | |
| 203 | // We don't have to update column header, but may be needed later, if sorting is introduced |
| 204 | ob_start(); |
| 205 | $this->print_column_headers(); |
| 206 | $headers = ob_get_clean(); |
| 207 | |
| 208 | ob_start(); |
| 209 | $this->pagination('top'); |
| 210 | $pagination_top = ob_get_clean(); |
| 211 | |
| 212 | ob_start(); |
| 213 | $this->pagination('bottom'); |
| 214 | $pagination_bottom = ob_get_clean(); |
| 215 | |
| 216 | $response['views'] = array($views); |
| 217 | $response['rows'] = array($rows); |
| 218 | $response['pagination']['top'] = $pagination_top; |
| 219 | $response['pagination']['bottom'] = $pagination_bottom; |
| 220 | $response['headers'] = $headers; |
| 221 | |
| 222 | if (isset($total_items)) { |
| 223 | $response['total_items_i18n'] = sprintf(_n('1 plugin', '%s plugins', $total_items), number_format_i18n($total_items)); |
| 224 | } |
| 225 | |
| 226 | if (isset($total_pages)) { |
| 227 | $response['total_pages'] = $total_pages; |
| 228 | $response['total_pages_i18n'] = number_format_i18n($total_pages); |
| 229 | } |
| 230 | |
| 231 | wp_send_json($response); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Call back function for search functionality |
| 236 | * |
| 237 | * @static string $term Term to search |
| 238 | * @param array $plugin Plugin name |
| 239 | * @return boolean Returns true if term found, otherwise false |
| 240 | */ |
| 241 | public function _search_callback($plugin) { |
| 242 | static $term; |
| 243 | if (is_null($term)) |
| 244 | $term = wp_unslash($_REQUEST['s']); |
| 245 | |
| 246 | foreach ($plugin as $value) { |
| 247 | if (false !== stripos(strip_tags($value), $term)) { |
| 248 | return true; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | return false; |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * Callback order |
| 257 | * |
| 258 | * @global string $orderby |
| 259 | * @global string $order |
| 260 | * @param array $plugin_a Plugin A |
| 261 | * @param array $plugin_b Plugin B |
| 262 | * @return int |
| 263 | */ |
| 264 | public function _order_callback($plugin_a, $plugin_b) { |
| 265 | global $orderby, $order; |
| 266 | |
| 267 | $a = $plugin_a[$orderby]; |
| 268 | $b = $plugin_b[$orderby]; |
| 269 | |
| 270 | if ($a == $b) |
| 271 | return 0; |
| 272 | |
| 273 | if ('DESC' == $order) { |
| 274 | return ($a < $b) ? 1 : -1; |
| 275 | } else { |
| 276 | return ($a < $b) ? -1 : 1; |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * No items |
| 282 | * |
| 283 | * @return void |
| 284 | */ |
| 285 | public function no_items() { |
| 286 | global $plugins; |
| 287 | |
| 288 | if (!empty($plugins['all'])) { |
| 289 | _e('No plugins found.', 'stops-core-theme-and-plugin-updates'); |
| 290 | } else { |
| 291 | _e('You do not appear to have any plugins available at this time.', 'stops-core-theme-and-plugin-updates'); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * Get columns |
| 297 | * |
| 298 | * @return array |
| 299 | */ |
| 300 | public function get_columns() { |
| 301 | return array( |
| 302 | 'cb' => !in_array($this->status, array('mustuse', 'dropins')) ? '<input type="checkbox" />' : '', |
| 303 | 'name' => __('Plugin', 'stops-core-theme-and-plugin-updates'), |
| 304 | 'description' => __('Description', 'stops-core-theme-and-plugin-updates'), |
| 305 | ); |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * Get sotable columns |
| 310 | * |
| 311 | * @return array |
| 312 | */ |
| 313 | protected function get_sortable_columns() { |
| 314 | return array(); |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * Get views |
| 319 | * |
| 320 | * @return array |
| 321 | */ |
| 322 | protected function get_views() { |
| 323 | global $totals; |
| 324 | |
| 325 | $status_links = array(); |
| 326 | foreach ($totals as $type => $count) { |
| 327 | if (!$count) |
| 328 | continue; |
| 329 | |
| 330 | switch ($type) { |
| 331 | case 'all': |
| 332 | $text = _nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins'); |
| 333 | break; |
| 334 | case 'update_enabled': |
| 335 | $text = _n('Updates Enabled <span class="count">(%s)</span>', 'Updates Enabled <span class="count">(%s)</span>', $count, 'stops-core-theme-and-plugin-updates'); |
| 336 | break; |
| 337 | case 'update_disabled': |
| 338 | $text = _n('Updates Disabled <span class="count">(%s)</span>', 'Updates Disabled <span class="count">(%s)</span>', $count, 'stops-core-theme-and-plugin-updates'); |
| 339 | break; |
| 340 | case 'automatic': |
| 341 | $text = _n('Automatic Updates <span class="count">(%s)</span>', 'Automatic Updates <span class="count">(%s)</span>', $count, 'stops-core-theme-and-plugin-updates'); |
| 342 | break; |
| 343 | } |
| 344 | |
| 345 | if ('search' != $type) { |
| 346 | $plugin_url = MPSUM_Admin::get_url(); |
| 347 | $query_args = array( |
| 348 | 'tab' => $this->tab, |
| 349 | 'view' => $type |
| 350 | ); |
| 351 | $status_links[$type] = sprintf("<a href='%s' data-view='%s' %s>%s</a>", |
| 352 | add_query_arg($query_args, $plugin_url), |
| 353 | $this->status, |
| 354 | ($type == $this->status) ? ' class="current"' : '', |
| 355 | sprintf($text, number_format_i18n($count)) |
| 356 | ); |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | return $status_links; |
| 361 | } |
| 362 | |
| 363 | /** |
| 364 | * Get bulk actions |
| 365 | * |
| 366 | * @return array |
| 367 | */ |
| 368 | protected function get_bulk_actions() { |
| 369 | $actions = array(); |
| 370 | |
| 371 | $actions['allow-update-selected'] = esc_html__('Plugin Updates On', 'stops-core-theme-and-plugin-updates'); |
| 372 | $actions['disallow-update-selected'] = esc_html__('Plugin Updates Off', 'stops-core-theme-and-plugin-updates'); |
| 373 | $core_options = MPSUM_Updates_Manager::get_options('core'); |
| 374 | if (isset($core_options['automatic_plugin_updates']) && 'individual' == $core_options['automatic_plugin_updates']) { |
| 375 | $actions['allow-automatic-selected'] = esc_html__('Automatic Updates On', 'stops-core-theme-and-plugin-updates'); |
| 376 | $actions['disallow-automatic-selected'] = esc_html__('Automatic Updates Off', 'stops-core-theme-and-plugin-updates'); |
| 377 | } |
| 378 | |
| 379 | return $actions; |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * Bulk action |
| 384 | * |
| 385 | * @param string $which Specify which bulk action |
| 386 | * @return null |
| 387 | */ |
| 388 | public function bulk_actions($which = '') { |
| 389 | |
| 390 | if (in_array($this->status, array('mustuse', 'dropins'))) |
| 391 | return; |
| 392 | |
| 393 | parent::bulk_actions($which); |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Extra table Nav |
| 398 | * |
| 399 | * @param string $which Specify which table nav |
| 400 | * @return null |
| 401 | */ |
| 402 | protected function extra_tablenav($which) { |
| 403 | |
| 404 | if (! in_array($this->status, array('recently_activated', 'mustuse', 'dropins'))) |
| 405 | return; |
| 406 | |
| 407 | echo '<div class="alignleft actions">'; |
| 408 | |
| 409 | if (! $this->screen->in_admin('network') && 'recently_activated' == $this->status) { |
| 410 | submit_button(__('Clear List', 'stops-core-theme-and-plugin-updates'), 'button', 'clear-recent-list', false); |
| 411 | } elseif ('top' == $which && 'mustuse' == $this->status) { |
| 412 | echo '<p>' . |
| 413 | sprintf( |
| 414 | __('Files in the %s directory are executed automatically.', 'stops-core-theme-and-plugin-updates'), |
| 415 | '<code>' . str_replace(ABSPATH, '/', WPMU_PLUGIN_DIR) . '</code>' |
| 416 | ) . |
| 417 | '</p>'; |
| 418 | } elseif ('top' == $which && 'dropins' == $this->status) { |
| 419 | echo '<p>' . |
| 420 | sprintf( |
| 421 | __('Drop-ins are advanced plugins in the %s directory that replace WordPress functionality when present.', 'stops-core-theme-and-plugin-updates'), |
| 422 | '<code>' . str_replace(ABSPATH, '', WP_CONTENT_DIR) . '</code>' |
| 423 | ) . |
| 424 | '</p>'; |
| 425 | } |
| 426 | |
| 427 | echo '</div>'; |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * Currect action |
| 432 | * |
| 433 | * @return string |
| 434 | */ |
| 435 | public function current_action() { |
| 436 | if (isset($_POST['clear-recent-list'])) |
| 437 | return 'clear-recent-list'; |
| 438 | |
| 439 | return parent::current_action(); |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * Display rows |
| 444 | * |
| 445 | * @return void |
| 446 | */ |
| 447 | public function display_rows() { |
| 448 | |
| 449 | if (is_multisite() && ! $this->screen->in_admin('network') && in_array($this->status, array('mustuse', 'dropins'))) |
| 450 | return; |
| 451 | |
| 452 | foreach ($this->items as $plugin_file => $plugin_data) |
| 453 | $this->single_row(array($plugin_file, $plugin_data)); |
| 454 | } |
| 455 | |
| 456 | /** |
| 457 | * Single row |
| 458 | * |
| 459 | * @global string $s |
| 460 | * @global array $totals |
| 461 | * @param array $item Single row item |
| 462 | */ |
| 463 | public function single_row($item) { |
| 464 | global $s, $totals; |
| 465 | |
| 466 | list($plugin_file, $plugin_data) = $item; |
| 467 | $context = 'all'; |
| 468 | $screen = $this->screen; |
| 469 | |
| 470 | /** |
| 471 | * Filter the action links that show up under each plugin row. |
| 472 | * |
| 473 | * @since 5.0.0 |
| 474 | * |
| 475 | * @param string Relative plugin file path |
| 476 | * @param array $plugin_data An array of plugin data. |
| 477 | * @param string $this->status Status of the plugin. |
| 478 | */ |
| 479 | $actions = apply_filters('mpsum_plugin_action_links', array(), $plugin_file, $plugin_data, $this->status); |
| 480 | |
| 481 | $class = 'active'; |
| 482 | $plugin_options = MPSUM_Updates_Manager::get_options('plugins'); |
| 483 | if (false !== $key = array_search($plugin_file, $plugin_options)) { |
| 484 | $class = 'inactive'; |
| 485 | } |
| 486 | $checkbox_id = "checkbox_" . md5($plugin_data['Name']); |
| 487 | $checkbox = "<label class='screen-reader-text' for='" . $checkbox_id . "' >" . sprintf(__('Select %s', 'stops-core-theme-and-plugin-updates'), $plugin_data['Name']) . "</label>" |
| 488 | . "<input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' id='" . $checkbox_id . "' />"; |
| 489 | $description = '<p>' . ($plugin_data['Description'] ? $plugin_data['Description'] : ' ') . '</p>'; |
| 490 | $plugin_name = $plugin_data['Name']; |
| 491 | $plugin_slug = $item[0]; |
| 492 | |
| 493 | $id = sanitize_title($plugin_name); |
| 494 | |
| 495 | echo "<tr id='$id' class='$class'>"; |
| 496 | |
| 497 | list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
| 498 | |
| 499 | foreach ($columns as $column_name => $column_display_name) { |
| 500 | $style = ''; |
| 501 | if (in_array($column_name, $hidden)) |
| 502 | $style = ' style="display:none;"'; |
| 503 | |
| 504 | switch ($column_name) { |
| 505 | case 'cb': |
| 506 | echo "<th scope='row' class='check-column'>$checkbox</th>"; |
| 507 | break; |
| 508 | case 'name': |
| 509 | echo "<td class='plugin-title'$style>"; |
| 510 | $icon = '<span class="dashicons dashicons-admin-plugins"></span>'; |
| 511 | $preferred_icons = array('svg', '1x', '2x', 'default'); |
| 512 | foreach ($preferred_icons as $preferred_icon) { |
| 513 | if (isset($plugin_data['icons'][$preferred_icon]) && ! empty($plugin_data['icons'][$preferred_icon])) { |
| 514 | $icon = '<img src="' . esc_url($plugin_data['icons'][$preferred_icon]) . '" alt="" />'; |
| 515 | break; |
| 516 | } |
| 517 | } |
| 518 | echo $icon; |
| 519 | echo '<div class="eum-plugins-name-actions">'; |
| 520 | echo "<h3 class='eum-plugins-name'>$plugin_name</h3>"; |
| 521 | echo '<div class="eum-plugins-wrapper">'; |
| 522 | printf('<h4>%s</h4>', esc_html__('Plugin Updates', 'stops-core-theme-and-plugin-updates')); |
| 523 | |
| 524 | echo '<div class="toggle-wrapper toggle-wrapper-plugins">'; |
| 525 | |
| 526 | $enable_class = $disable_class = ''; |
| 527 | $checked = 'false'; |
| 528 | $key = in_array($plugin_slug, $plugin_options); |
| 529 | if (! $key) { |
| 530 | $enable_class = 'eum-enabled eum-active'; |
| 531 | $checked = 'true'; |
| 532 | } else { |
| 533 | $disable_class = 'eum-disabled eum-active'; |
| 534 | } |
| 535 | |
| 536 | printf('<input type="hidden" name="plugins[%s]" value="%s">', |
| 537 | $plugin_slug, |
| 538 | $checked |
| 539 | ); |
| 540 | |
| 541 | printf('<button aria-label="%s" class="eum-toggle-button eum-enabled %s" data-checked="%s" value="on">%s</button>', |
| 542 | esc_attr__('Allow Updates', 'stops-core-theme-and-plugin-updates'), |
| 543 | esc_attr($enable_class), |
| 544 | $plugin_slug, |
| 545 | esc_html__('Allowed', 'stops-core-theme-and-plugin-updates') |
| 546 | ); |
| 547 | |
| 548 | printf('<button aria-label="%s" class="eum-toggle-button eum-disabled %s" data-checked="%s value="off">%s</button>', |
| 549 | esc_attr__('Disallow Updates', 'stops-core-theme-and-plugin-updates'), |
| 550 | esc_attr($disable_class), |
| 551 | $plugin_slug, |
| 552 | esc_html__('Blocked', 'stops-core-theme-and-plugin-updates') |
| 553 | ); |
| 554 | |
| 555 | echo '</div></div>'; |
| 556 | |
| 557 | // Automatic Link |
| 558 | $plugin_automatic_options = MPSUM_Updates_Manager::get_options('plugins_automatic'); |
| 559 | $core_options = MPSUM_Updates_Manager::get_options('core'); |
| 560 | if (isset($core_options['automatic_plugin_updates']) && 'individual' == $core_options['automatic_plugin_updates']) { |
| 561 | printf('<div class="eum-plugins-automatic-wrapper" %s>', ($key) ? 'style="display: none;"' : ''); |
| 562 | printf('<h4>%s</h4>', esc_html__('Automatic Updates', 'stops-core-theme-and-plugin-updates')); |
| 563 | echo '<div class="toggle-wrapper toggle-wrapper-plugins-automatic">'; |
| 564 | $enable_class = $disable_class = ''; |
| 565 | $checked = 'false'; |
| 566 | if (in_array($plugin_slug, $plugin_automatic_options)) { |
| 567 | $enable_class = 'eum-active'; |
| 568 | $checked = 'true'; |
| 569 | } else { |
| 570 | $disable_class = 'eum-active'; |
| 571 | } |
| 572 | |
| 573 | printf('<input type="hidden" name="plugins_automatic[%s]" value="%s">', |
| 574 | $plugin_slug, |
| 575 | $checked |
| 576 | ); |
| 577 | |
| 578 | printf('<button aria-label="%s" class="eum-toggle-button eum-enabled %s" data-checked="%s" value="on">%s</button>', |
| 579 | esc_html__('Enable Automatic Updates', 'stops-core-theme-and-plugin-updates'), |
| 580 | esc_attr($enable_class), |
| 581 | $plugin_slug, |
| 582 | esc_html__('On', 'stops-core-theme-and-plugin-updates') |
| 583 | ); |
| 584 | |
| 585 | printf('<button aria-label="%s" class="eum-toggle-button eum-disabled %s" data-checked="%s" value="off">%s</button>', |
| 586 | esc_attr__('Enable Automatic Updates', 'stops-core-theme-and-plugin-updates'), |
| 587 | esc_attr($disable_class), |
| 588 | $plugin_slug, |
| 589 | esc_html__('Off', 'stops-core-theme-and-plugin-updates') |
| 590 | ); |
| 591 | |
| 592 | echo '</div></div>'; |
| 593 | } |
| 594 | echo '</div>'; |
| 595 | echo "</td>"; |
| 596 | break; |
| 597 | case 'description': |
| 598 | echo "<td class='column-description desc'$style> |
| 599 | <div class='plugin-description'>$description</div> |
| 600 | <div class='$class second plugin-version-author-uri'>"; |
| 601 | |
| 602 | $plugin_meta = array(); |
| 603 | if (!empty($plugin_data['Version'])) |
| 604 | $plugin_meta[] = sprintf(__('Version %s', 'stops-core-theme-and-plugin-updates'), $plugin_data['Version']); |
| 605 | if (!empty($plugin_data['Author'])) { |
| 606 | $author = $plugin_data['Author']; |
| 607 | if (!empty($plugin_data['AuthorURI'])) |
| 608 | $author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; |
| 609 | $plugin_meta[] = sprintf(__('By %s', 'stops-core-theme-and-plugin-updates'), $author); |
| 610 | } |
| 611 | |
| 612 | // Details link using API info, if available |
| 613 | if (isset($plugin_data['slug']) && current_user_can('install_plugins')) { |
| 614 | $plugin_meta[] = sprintf('<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>', |
| 615 | esc_url(network_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] . |
| 616 | '&eum_action=EUM_modal&TB_iframe=true&width=600&height=550')), |
| 617 | esc_attr(sprintf(__('More information about %s', 'stops-core-theme-and-plugin-updates'), $plugin_name)), |
| 618 | esc_attr($plugin_name), |
| 619 | __('View details', 'stops-core-theme-and-plugin-updates') |
| 620 | ); |
| 621 | } elseif (! empty($plugin_data['PluginURI'])) { |
| 622 | $plugin_meta[] = sprintf('<a href="%s">%s</a>', |
| 623 | esc_url($plugin_data['PluginURI']), |
| 624 | __('Visit plugin site', 'stops-core-theme-and-plugin-updates') |
| 625 | ); |
| 626 | } |
| 627 | |
| 628 | |
| 629 | /** |
| 630 | * Filter the array of row meta for each plugin in the Plugins list table. |
| 631 | * |
| 632 | * @since 2.8.0 |
| 633 | * |
| 634 | * @param array $plugin_meta An array of the plugin's metadata, |
| 635 | * including the version, author, |
| 636 | * author URI, and plugin URI. |
| 637 | * @param string $plugin_file Path to the plugin file, relative to the plugins directory. |
| 638 | * @param array $plugin_data An array of plugin data. |
| 639 | * @param string $this->status Status of the plugin. Defaults are 'All', 'Active', |
| 640 | * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', |
| 641 | * 'Drop-ins', 'Search'. |
| 642 | */ |
| 643 | $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $this->status); |
| 644 | echo implode(' | ', $plugin_meta); |
| 645 | |
| 646 | // Premium only - Check if plugin has been removed from the repo |
| 647 | if (MPSUM_Updates_Manager::get_instance()->is_premium()) { |
| 648 | MPSUM_Check_Plugins_Removed::get_instance()->check_if_plugin_removed($plugin_file); |
| 649 | } |
| 650 | |
| 651 | // Show active status for blogs |
| 652 | if (is_multisite()) { |
| 653 | if (is_plugin_active_for_network($plugin_file)) { |
| 654 | printf('<div class="mpsum-success mpsum-bold">%s</div>', esc_html__('This plugin is active for your network.', 'stops-core-theme-and-plugin-updates')); |
| 655 | } else { |
| 656 | printf('<div class="mpsum-notice mpsum-regular"><a href="#" data-plugin-file="%s" class="eum-list-plugins-action">%s</a><div class="eum-list-plugins"></div></div>', esc_attr($plugin_file), esc_html__('View all sites that have this plugin installed.', 'stops-core-theme-and-plugin-updates')); |
| 657 | } |
| 658 | } else { |
| 659 | if (is_plugin_active($plugin_file)) { |
| 660 | printf('<div class="mpsum-success mpsum-bold">%s</div>', esc_html__('This plugin is active for your site.', 'stops-core-theme-and-plugin-updates')); |
| 661 | } else { |
| 662 | printf('<div class="mpsum-error mpsum-bold">%s</div>', esc_html__('This plugin is inactive for your site. Consider removing it.', 'stops-core-theme-and-plugin-updates')); |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | // Show safe mode options if enabled |
| 667 | if (MPSUM_Updates_Manager::get_instance()->is_premium()) { |
| 668 | $core_options = MPSUM_Updates_Manager::get_options('core'); |
| 669 | if (isset($core_options['safe_mode']) && 'on' === $core_options['safe_mode']) { |
| 670 | $safe_mode_instance = MPSUM_Safe_Mode::get_instance(); |
| 671 | $plugin_object = $safe_mode_instance->perform_api_check($plugin_file); |
| 672 | $safe_mode_instance->maybe_output_check_safe_mode($plugin_object); |
| 673 | } |
| 674 | } |
| 675 | echo "</div></td>"; |
| 676 | break; |
| 677 | default: |
| 678 | echo "<td class='$column_name column-$column_name'$style>"; |
| 679 | |
| 680 | /** |
| 681 | * Fires inside each custom column of the Plugins list table. |
| 682 | * |
| 683 | * @since 3.1.0 |
| 684 | * |
| 685 | * @param string $column_name Name of the column. |
| 686 | * @param string $plugin_file Path to the plugin file. |
| 687 | * @param array $plugin_data An array of plugin data. |
| 688 | */ |
| 689 | do_action('manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data); |
| 690 | echo "</td>"; |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | echo "</tr>"; |
| 695 | |
| 696 | } |
| 697 | } |
| 698 |