wp_ajax_search_plugins

Ajax handler for searching plugins.

Description

wp_ajax_search_plugins(); 

Usage

  1. if ( !function_exists( 'wp_ajax_search_plugins' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_search_plugins(); 
  7.  

Defined (1)

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

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_search_plugins() { 
  2. check_ajax_referer( 'updates' ); 
  3.  
  4. $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; 
  5. if ( 'plugins-network' === $pagenow || 'plugins' === $pagenow ) { 
  6. set_current_screen( $pagenow ); 
  7.  
  8. /** @var WP_Plugins_List_Table $wp_list_table */ 
  9. $wp_list_table = _get_list_table( 'WP_Plugins_List_Table', array( 
  10. 'screen' => get_current_screen(),  
  11. ) ); 
  12.  
  13. $status = array(); 
  14.  
  15. if ( ! $wp_list_table->ajax_user_can() ) { 
  16. $status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site.' ); 
  17. wp_send_json_error( $status ); 
  18.  
  19. // Set the correct requester, so pagination works. 
  20. $_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array( 
  21. '_ajax_nonce' => null,  
  22. 'action' => null,  
  23. ) ), network_admin_url( 'plugins.php', 'relative' ) ); 
  24.  
  25. $GLOBALS['s'] = wp_unslash( $_POST['s'] ); 
  26.  
  27. $wp_list_table->prepare_items(); 
  28.  
  29. ob_start(); 
  30. $wp_list_table->display(); 
  31. $status['count'] = count( $wp_list_table->items ); 
  32. $status['items'] = ob_get_clean(); 
  33.  
  34. wp_send_json_success( $status );