wp_ajax_search_install_plugins()
- Since
- 4.6.0
- Source
wp-admin/includes/ajax-actions.php:4849
Compatibility
- WordPress
- since 4.6.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Performance profile
How much work a call to wp_ajax_search_install_plugins() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 60–78
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 79.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
do_action()one call below wp_ajax_search_install_plugins()
Further down the call graph this can also reach option, cache, serialize, transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 8 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_ajax_search_install_plugins() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($value) && $pagenow !== "plugin-install-network" && $pagenow !== "plugin-install" && ->ajax_user_can() | 60 | check_ajax_referer(), get_current_screen(), screen(), ->ajax_user_can(), array_diff_key(), network_admin_url(), add_query_arg(), ->prepare_items(), ob_start(), ->display(), ->get_pagination_arg(), ob_get_clean(), wp_send_json_success() |
!isset($value) && ->ajax_user_can() | 61–63 | check_ajax_referer(), set_current_screen(), get_current_screen(), screen(), ->ajax_user_can(), array_diff_key(), network_admin_url(), add_query_arg(), ->prepare_items(), ob_start(), ->display(), ->get_pagination_arg(), ob_get_clean(), wp_send_json_success() |
isset($value) && $pagenow !== "plugin-install-network" && $pagenow !== "plugin-install" && ->ajax_user_can() | 67 | check_ajax_referer(), sanitize_key(), get_current_screen(), screen(), ->ajax_user_can(), array_diff_key(), network_admin_url(), add_query_arg(), ->prepare_items(), ob_start(), ->display(), ->get_pagination_arg(), ob_get_clean(), wp_send_json_success() |
!isset($value) && $pagenow !== "plugin-install-network" && $pagenow !== "plugin-install" && !->ajax_user_can() | 68 | check_ajax_referer(), get_current_screen(), screen(), ->ajax_user_can(), __(), wp_send_json_error(), array_diff_key(), network_admin_url(), add_query_arg(), ->prepare_items(), ob_start(), ->display(), ->get_pagination_arg(), ob_get_clean(), wp_send_json_success() |
isset($value) && ->ajax_user_can() | 68–70 | check_ajax_referer(), sanitize_key(), set_current_screen(), get_current_screen(), screen(), ->ajax_user_can(), array_diff_key(), network_admin_url(), add_query_arg(), ->prepare_items(), ob_start(), ->display(), ->get_pagination_arg(), ob_get_clean(), wp_send_json_success() |
!isset($value) && !->ajax_user_can() | 69–71 | check_ajax_referer(), set_current_screen(), get_current_screen(), screen(), ->ajax_user_can(), __(), wp_send_json_error(), array_diff_key(), network_admin_url(), add_query_arg(), ->prepare_items(), ob_start(), ->display(), ->get_pagination_arg(), ob_get_clean(), wp_send_json_success() |
isset($value) && $pagenow !== "plugin-install-network" && $pagenow !== "plugin-install" && !->ajax_user_can() | 75 | check_ajax_referer(), sanitize_key(), get_current_screen(), screen(), ->ajax_user_can(), __(), wp_send_json_error(), array_diff_key(), network_admin_url(), add_query_arg(), ->prepare_items(), ob_start(), ->display(), ->get_pagination_arg(), ob_get_clean(), wp_send_json_success() |
isset($value) && !->ajax_user_can() | 76–78 | check_ajax_referer(), sanitize_key(), set_current_screen(), get_current_screen(), screen(), ->ajax_user_can(), __(), wp_send_json_error(), array_diff_key(), network_admin_url(), add_query_arg(), ->prepare_items(), ob_start(), ->display(), ->get_pagination_arg(), ob_get_clean(), wp_send_json_success() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 78 | 60–77 | 4 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 79 | 60–78 | 4 | |
| 8.4 | 79 | 60–78 | 4 | |
| 8.3 | 79 | 60–78 | 4 | |
| 8.2 | 79 | 60–78 | 4 | |
| 8.1 | 79 | 60–78 | 4 | |
| 7.4 | 79 | 60–78 | 4 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 10
- check_ajax_referer()Verifies the Ajax request to prevent processing requests external of the blog.
- sanitize_key()Sanitizes a string key.
- set_current_screen()Set the current screen object
- _get_list_table()Fetches an instance of a WP_List_Table class.
- get_current_screen()Get the current screen object
- __()Retrieves the translation of $text.
- wp_send_json_error()Sends a JSON response back to an Ajax request, indicating failure.
- add_query_arg()Retrieves a modified URL query string.
- network_admin_url()Retrieves the URL to the admin area for the network.
- wp_send_json_success()Sends a JSON response back to an Ajax request, indicating success.
Source code
function wp_ajax_search_install_plugins() { check_ajax_referer( 'updates' ); $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : ''; if ( 'plugin-install-network' === $pagenow || 'plugin-install' === $pagenow ) { set_current_screen( $pagenow ); } /** @var WP_Plugin_Install_List_Table $wp_list_table */ $wp_list_table = _get_list_table( 'WP_Plugin_Install_List_Table', array( 'screen' => get_current_screen(), ) ); $status = array(); if ( ! $wp_list_table->ajax_user_can() ) { $status['errorMessage'] = __( 'Sorry, you are not allowed to manage plugins for this site.' ); wp_send_json_error( $status ); } // Set the correct requester, so pagination works. $_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array( '_ajax_nonce' => null, 'action' => null, ) ), network_admin_url( 'plugin-install.php', 'relative' ) ); $wp_list_table->prepare_items(); ob_start(); $wp_list_table->display(); $status['count'] = (int) $wp_list_table->get_pagination_arg( 'total_items' ); $status['items'] = ob_get_clean(); wp_send_json_success( $status );}Changelog
Introduced in 4.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-admin/includes/ajax-actions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.