/** * Load Scripts * * Enqueues the required scripts. * * @since 1.0 * @global $post * @return void */ function edd_load_scripts() { global $post; $js_dir = EDD_PLUGIN_URL . 'assets/js/'; // Use minified libraries if SCRIPT_DEBUG is turned off $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; // Get position in cart of current download if (isset($post->ID)) { $position = edd_get_item_position_in_cart($post->ID); } if (edd_is_checkout()) { if (edd_is_cc_verify_enabled()) { wp_register_script('creditCardValidator', $js_dir . 'jquery.creditCardValidator' . $suffix . '.js', array('jquery'), EDD_VERSION); wp_enqueue_script('creditCardValidator'); } wp_register_script('edd-checkout-global', $js_dir . 'edd-checkout-global' . $suffix . '.js', array('jquery'), EDD_VERSION); wp_enqueue_script('edd-checkout-global'); wp_localize_script('edd-checkout-global', 'edd_global_vars', apply_filters('edd_global_checkout_script_vars', array('ajaxurl' => edd_get_ajax_url(), 'checkout_nonce' => wp_create_nonce('edd_checkout_nonce'), 'currency_sign' => edd_currency_filter(''), 'currency_pos' => edd_get_option('currency_position', 'before'), 'no_gateway' => __('Please select a payment method', 'edd'), 'no_discount' => __('Please enter a discount code', 'edd'), 'enter_discount' => __('Enter discount', 'edd'), 'discount_applied' => __('Discount Applied', 'edd'), 'no_email' => __('Please enter an email address before applying a discount code', 'edd'), 'no_username' => __('Please enter a username before applying a discount code', 'edd'), 'purchase_loading' => __('Please Wait...', 'edd'), 'complete_purchase' => __('Purchase', 'edd'), 'taxes_enabled' => edd_use_taxes() ? '1' : '0', 'edd_version' => EDD_VERSION))); } // Load AJAX scripts, if enabled if (!edd_is_ajax_disabled()) { wp_register_script('edd-ajax', $js_dir . 'edd-ajax' . $suffix . '.js', array('jquery'), EDD_VERSION); wp_enqueue_script('edd-ajax'); wp_localize_script('edd-ajax', 'edd_scripts', apply_filters('edd_ajax_script_vars', array('ajaxurl' => edd_get_ajax_url(), 'position_in_cart' => isset($position) ? $position : -1, 'already_in_cart_message' => __('You have already added this item to your cart', 'edd'), 'empty_cart_message' => __('Your cart is empty', 'edd'), 'loading' => __('Loading', 'edd'), 'select_option' => __('Please select an option', 'edd'), 'ajax_loader' => set_url_scheme(EDD_PLUGIN_URL . 'assets/images/loading.gif', 'relative'), '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'))); } }
/** * Load Scripts * * Enqueues the required scripts. * * @access private * @since 1.0 * @return void */ function edd_load_scripts() { global $edd_options, $post; wp_enqueue_script('jquery'); // Get position in cart of current download if (isset($post->ID)) { $position = edd_get_item_position_in_cart($post->ID); } // Load AJAX scripts, if enabled if (edd_is_ajax_enabled()) { wp_enqueue_script('edd-ajax', EDD_PLUGIN_URL . 'assets/js/edd-ajax.js', array('jquery'), EDD_VERSION); wp_localize_script('edd-ajax', 'edd_scripts', array('ajaxurl' => edd_get_ajax_url(), 'ajax_nonce' => wp_create_nonce('edd_ajax_nonce'), 'no_discount' => __('Please enter a discount code', 'edd'), 'discount_applied' => __('Discount Applied', 'edd'), 'no_email' => __('Please enter an email address before applying a discount code', 'edd'), 'no_username' => __('Please enter a username before applying a discount code', 'edd'), 'position_in_cart' => isset($position) ? $position : -1, 'already_in_cart_message' => __('You have already added this item to your cart', 'edd'), 'empty_cart_message' => __('Your cart is empty', 'edd'), 'loading' => __('Loading', 'edd'), 'ajax_loader' => EDD_PLUGIN_URL . 'assets/images/loading.gif', 'checkout_page' => edd_get_checkout_uri(), 'permalinks' => get_option('permalink_structure') ? '1' : '0')); } // Load jQuery validation if (isset($edd_options['jquery_validation']) && edd_is_checkout()) { wp_enqueue_script('jquery-validation', EDD_PLUGIN_URL . 'assets/js/jquery.validate.min.js'); wp_enqueue_script('edd-validation', EDD_PLUGIN_URL . 'assets/js/form-validation.js', array('jquery', 'jquery-validation'), EDD_VERSION); $required = array('firstname' => true, 'lastname' => true); wp_localize_script('edd-validation', 'edd_scripts_validation', apply_filters('edd_scripts_validation', $required)); } if (edd_is_checkout()) { if (edd_is_cc_verify_enabled()) { wp_enqueue_script('creditCardValidator', EDD_PLUGIN_URL . 'assets/js/jquery.creditCardValidator.js', array('jquery'), EDD_VERSION); } wp_enqueue_script('edd-checkout-global', EDD_PLUGIN_URL . 'assets/js/edd-checkout-global.js', array('jquery'), EDD_VERSION); wp_localize_script('edd-checkout-global', 'edd_global_vars', array('currency_sign' => edd_currency_filter(''), 'currency_pos' => isset($edd_options['currency_position']) ? $edd_options['currency_position'] : 'before', 'no_gateway' => __('Please select a payment method', 'edd'))); } }