| | 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 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 | // Require an action parameter |
| | 31 | if ( empty( $_REQUEST['action'] ) ) |
| | 32 | die( '0' ); |
| | 33 | |
| | 34 | /** Load WordPress Administration APIs */ |
| | 35 | require_once( ABSPATH . 'wp-admin/includes/admin.php' ); |
| | 36 | |
| | 37 | @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
| | 38 | @header( 'X-Robots-Tag: noindex' ); |
| | 39 | |
| | 40 | send_nosniff_header(); |
| | 41 | nocache_headers(); |
| | 42 | |
| | 43 | /** This action is documented in wp-admin/admin.php */ |
| | 44 | do_action( 'admin_init' ); |
| | 45 | |
| | 46 | if ( is_user_logged_in() ) { |
| | 47 | /** |
| | 48 | * Fires authenticated network 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 4.6.0 |
| | 54 | */ |
| | 55 | do_action( 'wp_network_ajax_' . $_REQUEST['action'] ); |
| | 56 | } else { |
| | 57 | /** |
| | 58 | * Fires non-authenticated network 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 4.6.0 |
| | 64 | */ |
| | 65 | do_action( 'wp_network_ajax_nopriv_' . $_REQUEST['action'] ); |
| | 66 | } |
| | 67 | // Default status |
| | 68 | die( '0' ); |