Jetpack_Omnisearch_Plugins

The Jetpack by WordPress.com Jetpack Omnisearch Plugins class.

Defined (1)

The class is defined in the following location(s).

/modules/omnisearch/omnisearch-plugins.php  
  1. class Jetpack_Omnisearch_Plugins extends WP_Plugin_Install_List_Table { 
  2. static $instance; 
  3.  
  4. function __construct() { 
  5. self::$instance = $this; 
  6. add_filter( 'omnisearch_results', array( $this, 'search'), 10, 2 ); 
  7. add_action( 'wp_ajax_omnisearch_plugins', array( $this, 'wp_ajax_omnisearch_plugins' ) ); 
  8.  
  9. function search( $results, $search_term ) { 
  10. wp_enqueue_script( 'plugin-install' ); 
  11. add_thickbox(); 
  12.  
  13. $search_url = esc_url( admin_url( sprintf( 'plugin-install.php?tab=search&s=%s', urlencode( $search_term ) ) ) ); 
  14. $search_link = sprintf( ' <a href="%s" class="add-new-h2">%s</a>', $search_url, esc_html__('Search Plugins', 'jetpack') ); 
  15. $html = '<h2>' . esc_html__('Plugins', 'jetpack') . $search_link . '</h2>'; 
  16.  
  17. $html .= '<div id="' . __CLASS__ . '_results">' . esc_html__('Loading …', 'jetpack') . '</div>'; 
  18. $html .= '<script>jQuery("#' . __CLASS__ . '_results").load(ajaxurl, {action:"omnisearch_plugins", search_term:search_term, num_results:num_results});</script>'; 
  19.  
  20. $label = __( 'Plugins', 'jetpack' ); 
  21. $results[ $label ] = $html; 
  22. return $results; 
  23.  
  24. function results_html( $search_term, $num_results = null ) { 
  25. $_GET['tab'] = 'search'; 
  26. $GLOBALS['hook_suffix'] = 'foo'; 
  27. $_REQUEST['s'] = $search_term; 
  28. parent::__construct(); 
  29.  
  30. ob_start(); 
  31. $this->prepare_items(); 
  32. /** This action is documented in modules/omnisearch/omnisearch-core.php */ 
  33. $num_results = intval( $num_results ) ? intval( $num_results ) : apply_filters( 'omnisearch_num_results', 5 ); 
  34. $this->items = array_slice( $this->items, 0, $num_results ); 
  35. remove_action( 'install_plugins_table_header', 'install_search_form' ); 
  36. $this->display(); 
  37. $html = ob_get_clean(); 
  38.  
  39. return $html; 
  40.  
  41. function wp_ajax_omnisearch_plugins() { 
  42. $search_term = $_REQUEST['search_term']; 
  43. $num_results = isset( $_REQUEST['num_results'] ) ? $_REQUEST['num_results'] : null; 
  44. echo $this->results_html( $search_term, $num_results ); 
  45. exit; 
  46.  
  47. function get_bulk_actions() { 
  48. return array(); 
  49.  
  50. function pagination( $which ) {}