Ejemplo n.º 1
0
 /**
  * Gathers and renames all of our plugin information to be used by WP_List_Table to create our table.
  *
  * @since 2.2.0
  *
  * @return array $table_data Information for use in table.
  */
 protected function _gather_plugin_data()
 {
     // Load thickbox for plugin links.
     $this->tgmpa->admin_init();
     $this->tgmpa->thickbox();
     // Categorize the plugins which have open actions.
     $plugins = $this->categorize_plugins_to_views();
     // Set the counts for the view links.
     $this->set_view_totals($plugins);
     // Prep variables for use and grab list of all installed plugins.
     $table_data = array();
     $i = 0;
     // Redirect to the 'all' view if no plugins were found for the selected view context.
     if (empty($plugins[$this->view_context])) {
         $this->view_context = 'all';
     }
     foreach ($plugins[$this->view_context] as $slug => $plugin) {
         $table_data[$i]['sanitized_plugin'] = $plugin['name'];
         $table_data[$i]['slug'] = $slug;
         $table_data[$i]['plugin'] = '<strong>' . $this->tgmpa->get_info_link($slug) . '</strong>';
         $table_data[$i]['source'] = $this->get_plugin_source_type_text($plugin['source_type']);
         $table_data[$i]['type'] = $this->get_plugin_advise_type_text($plugin['required']);
         $table_data[$i]['status'] = $this->get_plugin_status_text($slug);
         $table_data[$i]['installed_version'] = $this->tgmpa->get_installed_version($slug);
         $table_data[$i]['minimum_version'] = $plugin['version'];
         $table_data[$i]['available_version'] = $this->tgmpa->does_plugin_have_update($slug);
         if (!empty($plugin['description'])) {
             $table_data[$i]['description'] = $plugin['description'];
         }
         // Prep the upgrade notice info.
         $upgrade_notice = $this->tgmpa->get_upgrade_notice($slug);
         if (!empty($upgrade_notice)) {
             $table_data[$i]['upgrade_notice'] = $upgrade_notice;
             add_action("tgmpa_after_plugin_row_{$slug}", array($this, 'wp_plugin_update_row'), 10, 2);
         }
         $table_data[$i] = apply_filters('tgmpa_table_data_item', $table_data[$i], $plugin);
         $i++;
     }
     return $table_data;
 }