WordPress.org

Make WordPress Core

Ticket #22589: 22589.diff

File 22589.diff, 1.9 KB (added by thomaswm, 4 years ago)

Adds a wp-admin/network/admin-ajax.php file

  • wp-admin/network/admin-ajax.php

     
     1<?php
     2/**
     3 * WordPress AJAX Process Execution.
     4 *
     5 * @package WordPress
     6 * @subpackage Administration
     7 *
     8 * @link https://codex.wordpress.org/AJAX_in_Plugins
     9 */
     10
     11/**
     12 * Executing AJAX process.
     13 *
     14 * @since 2.1.0
     15 */
     16define( 'DOING_AJAX', true );
     17if ( ! defined( 'WP_NETWORK_ADMIN' ) ) {
     18        define( 'WP_NETWORK_ADMIN', true );
     19}
     20
     21/** Load WordPress Bootstrap */
     22require_once( dirname( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ) );
     23
     24/** Allow for cross-domain requests (from the front end). */
     25send_origin_headers();
     26
     27// Require an action parameter
     28if ( empty( $_REQUEST['action'] ) )
     29        die( '0' );
     30
     31/** Load WordPress Administration APIs */
     32require_once( ABSPATH . 'wp-admin/includes/admin.php' );
     33
     34/** Load Ajax Handlers for WordPress Core */
     35require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' );
     36
     37@header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
     38@header( 'X-Robots-Tag: noindex' );
     39
     40send_nosniff_header();
     41nocache_headers();
     42
     43/** This action is documented in wp-admin/admin.php */
     44do_action( 'admin_init' );
     45
     46if ( is_user_logged_in() ) {
     47        /**
     48         * Fires authenticated AJAX actions for logged-in users.
     49         *
     50         * The dynamic portion of the hook name, `$_REQUEST['action']`,
     51         * refers to the name of the AJAX action callback being fired.
     52         *
     53         * @since 2.1.0
     54         */
     55        do_action( 'wp_network_ajax_' . $_REQUEST['action'] );
     56} else {
     57        /**
     58         * Fires non-authenticated AJAX actions for logged-out users.
     59         *
     60         * The dynamic portion of the hook name, `$_REQUEST['action']`,
     61         * refers to the name of the AJAX action callback being fired.
     62         *
     63         * @since 2.8.0
     64         */
     65        do_action( 'wp_network_ajax_nopriv_' . $_REQUEST['action'] );
     66}
     67// Default status
     68die( '0' );