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