Skip to content

Instantly share code, notes, and snippets.

@hawkidoki
Last active April 22, 2018 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hawkidoki/825b5b5951d83b5c8eeacd71e14f255f to your computer and use it in GitHub Desktop.
Save hawkidoki/825b5b5951d83b5c8eeacd71e14f255f to your computer and use it in GitHub Desktop.
<?php
// File: ajax.php (Root WP Install)
// Init
// -----------------------------------------------------------------------
define('DOING_AJAX', true);
define('SHORTINIT', true);
// WP Load
// -----------------------------------------------------------------------
require('wp-load.php');
$ajax_actions = '/includes/ajax-actions.php';
// Ajax Check
// -----------------------------------------------------------------------
@header('X-Robots-Tag: noindex');
send_nosniff_header();
nocache_headers();
if(empty($_REQUEST['action']))
wp_die('0', 400);
// Ajax Requirements & Actions
// -----------------------------------------------------------------------
require(ABSPATH . WPINC . '/theme.php');
require(get_stylesheet_directory() . $ajax_actions);
// Ajax Apply Hooks
// -----------------------------------------------------------------------
if(!has_action('wp_ajax_' . $_REQUEST['action']))
wp_die('0', 400);
do_action('wp_ajax_' . $_REQUEST['action']);
wp_die('0');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment