Created
May 21, 2014 17:30
-
-
Save Kevinlearynet/b4203d09e7a8d605725e to your computer and use it in GitHub Desktop.
Faster admin-ajax.php for WordPress AJAX actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('DOING_AJAX', true); | |
if ( ! isset( $_POST['action'] ) ) | |
die('-1'); | |
require_once('../../../../wp-load.php'); | |
// headers for JSON | |
header('Content-Type: application/json'); | |
send_nosniff_header(); | |
// no cache | |
header('Cache-Control: no-cache'); | |
header('Pragma: no-cache'); | |
$action = esc_attr( trim( $_POST['action'] ) ); | |
// security | |
$allowed_actions = array( | |
'rapid_generate_license', | |
); | |
if ( in_array( $action, $allowed_actions ) ) { | |
if ( is_user_logged_in() ) | |
do_action( 'wp_fast_ajax_' . $action ); | |
else | |
do_action( 'wp_fast_ajax_nopriv_' . $action ); | |
} else { | |
die('-1'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment