Define new `WC_DOING_AJAX` constant

This constant will allow extensions to selectively load files etc.
during a WC AJAX request.
This commit is contained in:
Tamara Zuk 2015-07-24 15:50:50 -04:00
parent c840fef3af
commit 1bd4cf8fad
1 changed files with 4 additions and 1 deletions

View File

@ -59,13 +59,16 @@ class WC_AJAX {
global $wp_query;
if ( ! empty( $_GET['wc-ajax'] ) ) {
$wp_query->set( 'wc-ajax', sanitize_text_field( $_GET['wc-ajax'] ) );
$wp_query->set( 'wc-ajax', sanitize_text_field( $_GET['wc-ajax'] ) );
}
if ( $action = $wp_query->get( 'wc-ajax' ) ) {
if ( ! defined( 'DOING_AJAX' ) ) {
define( 'DOING_AJAX', true );
}
if ( ! defined( 'WC_DOING_AJAX' ) ) {
define( 'WC_DOING_AJAX', true );
}
do_action( 'wc_ajax_' . sanitize_text_field( $action ) );
die();
}