wp_ajax_search_install_plugins() - WordPress 函数参考中文文档

返回介绍

wp_ajax_search_install_plugins()

发布于 2017-09-11 字数2730 浏览 864 评论 0

wp_ajax_search_install_plugins()

Ajax handler for searching plugins to install.


描述


源代码

File: wp-admin/includes/ajax-actions.php

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 );
}

更新日志

Version 描述
4.6.0 Introduced.

相关函数

Uses

  • wp-admin/includes/screen.php:
    set_current_screen()
  • wp-admin/includes/screen.php:
    get_current_screen()
  • wp-admin/includes/class-wp-list-table.php:
    WP_List_Table::display()
  • wp-admin/includes/class-wp-list-table.php:
    WP_List_Table::ajax_user_can()
  • wp-admin/includes/class-wp-list-table.php:
    WP_List_Table::prepare_items()
  • wp-admin/includes/class-wp-list-table.php:
    WP_List_Table::get_pagination_arg()
  • wp-admin/includes/list-table.php:
    _get_list_table()
  • wp-includes/l10n.php:
    __()
  • wp-includes/formatting.php:
    sanitize_key()
  • wp-includes/pluggable.php:
    check_ajax_referer()
  • wp-includes/functions.php:
    wp_send_json_error()
  • wp-includes/functions.php:
    wp_send_json_success()
  • wp-includes/functions.php:
    add_query_arg()
  • wp-includes/link-template.php:
    network_admin_url()
  • Show 9 more uses
    Hide more uses


User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!