edd_ajax_script_vars

The Easy Digital Downloads edd ajax script vars hook.

Description

apply_filters( 'edd_ajax_script_vars', (callback) $position ); 

Parameters (1)

0. $position — Optional. (callback) => array( 'ajaxurl' => edd_get_ajax_url(), 'position_in_cart' => isset( $position ) ? $position : -1, 'has_purchase_links' => $has_purchase_links, 'already_in_cart_message' => __('You have already added this item to your cart', 'easy-digital-downloads' ), 'empty_cart_message' => __('Your cart is empty', 'easy-digital-downloads' ), 'loading' => __('Loading', 'easy-digital-downloads' ) , 'select_option' => __('Please select an option', 'easy-digital-downloads' ) , 'is_checkout' => edd_is_checkout() ? '1' : '0', 'default_gateway' => edd_get_default_gateway(), 'redirect_to_checkout' => ( edd_straight_to_checkout() || edd_is_checkout() ) ? '1' : '0', 'checkout_page' => edd_get_checkout_uri(), 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', 'quantities_enabled' => edd_item_quantities_enabled(), 'taxes_enabled' => edd_use_taxes() ? '1' : '0', )
The array.

Usage

To run the hook, copy the example below.
  1. $position = apply_filters( 'edd_ajax_script_vars', $position ); 
  2.  
  3. if ( !empty( $position ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the edd_ajax_script_vars callback 
  2. function filter_edd_ajax_script_vars( $position ) { 
  3. // make filter magic happen here... 
  4. return $position
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'edd_ajax_script_vars', 'filter_edd_ajax_script_vars', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'edd_ajax_script_vars', 'filter_edd_ajax_script_vars', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/includes/scripts.php  
  1. wp_localize_script( 'edd-ajax', 'edd_scripts', apply_filters( 'edd_ajax_script_vars', array(