* WordPress Ajax Process Execution
* @subpackage Administration
* @link https://codex.wordpress.org/AJAX_in_Plugins
* Executing Ajax process.
define( 'DOING_AJAX', true );
if ( ! defined( 'WP_ADMIN' ) ) {
define( 'WP_ADMIN', true );
/** Load WordPress Bootstrap */
require_once dirname( __DIR__ ) . '/wp-load.php';
/** Allow for cross-domain requests (from the front end). */
header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
header( 'X-Robots-Tag: noindex' );
// Require an action parameter.
if ( empty( $_REQUEST['action'] ) ) {
/** Load WordPress Administration APIs */
require_once ABSPATH . 'wp-admin/includes/admin.php';
/** Load Ajax Handlers for WordPress Core */
require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/** This action is documented in wp-admin/admin.php */
do_action( 'admin_init' );
$core_actions_get = array(
$core_actions_post = array(
'delete-inactive-widgets',
'save-attachment-compat',
'send-attachment-to-editor',
'media-create-image-subsizes',
'save-user-color-scheme',
'set-attachment-thumbnail',
'search-install-plugins',
'get-post-thumbnail-html',
'edit-theme-plugin-file',
'wp-privacy-export-personal-data',
'wp-privacy-erase-personal-data',
'health-check-site-status-result',
'health-check-dotorg-communication',
'health-check-is-in-debug-mode',
'health-check-background-updates',
'health-check-loopback-requests',
'health-check-get-sizes',
$core_actions_post_deprecated = array(
'wp-fullscreen-save-post',
'press-this-add-category',
'health-check-dotorg-communication',
'health-check-is-in-debug-mode',
'health-check-background-updates',
'health-check-loopback-requests',
$core_actions_post = array_merge( $core_actions_post, $core_actions_post_deprecated );
// Register core Ajax calls.
if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get, true ) ) {
add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );
if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post, true ) ) {
add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
add_action( 'wp_ajax_nopriv_generate-password', 'wp_ajax_nopriv_generate_password' );
add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );
$action = ( isset( $_REQUEST['action'] ) ) ? $_REQUEST['action'] : '';
if ( is_user_logged_in() ) {
// If no action is registered, return a Bad Request response.
if ( ! has_action( "wp_ajax_{$action}" ) ) {
* Fires authenticated Ajax actions for logged-in users.
* The dynamic portion of the hook name, `$action`, refers
* to the name of the Ajax action callback being fired.
do_action( "wp_ajax_{$action}" );
// If no action is registered, return a Bad Request response.
if ( ! has_action( "wp_ajax_nopriv_{$action}" ) ) {
* Fires non-authenticated Ajax actions for logged-out users.
* The dynamic portion of the hook name, `$action`, refers
* to the name of the Ajax action callback being fired.
do_action( "wp_ajax_nopriv_{$action}" );