/** * Adds a ?nocache option for the checkout page * * This ensures the checkout page remains uncached when plugins like WP Super Cache are activated * * @since 1.4.1 * @param array $settings Misc Settings * @return array $settings Updated Misc Settings */ function edd_append_no_cache_param($settings) { if (!edd_is_caching_plugin_active()) { return $settings; } $settings[] = array('id' => 'no_cache_checkout', 'name' => __('No Caching on Checkout?', 'easy-digital-downloads'), 'desc' => __('Check this box in order to append a ?nocache parameter to the checkout URL to prevent caching plugins from caching the page.', 'easy-digital-downloads'), 'type' => 'checkbox'); return $settings; }
/** * Adds the 'nocache' parameter to the provided URL * * @since 2.4.4 * @param string $url The URL being requested * @return string The URL with cache busting added or not */ function edd_add_cache_busting($url = '') { $no_cache_checkout = edd_get_option('no_cache_checkout', false); if (edd_is_caching_plugin_active() || edd_is_checkout() && $no_cache_checkout) { $url = add_query_arg('nocache', 'true', $url); } return $url; }
/** * Get the URL of the Checkout page * * @since 1.0.8 * @param array $args Extra query args to add to the URI * @return mixed Full URL to the checkout page, if present | null if it doesn't exist */ function edd_get_checkout_uri($args = array()) { $uri = edd_get_option('purchase_page', false); $uri = isset($uri) ? get_permalink($uri) : NULL; if (!empty($args)) { // Check for backward compatibility if (is_string($args)) { $args = str_replace('?', '', $args); } $args = wp_parse_args($args); $uri = add_query_arg($args, $uri); } $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; $ajax_url = admin_url('admin-ajax.php', $scheme); if (!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url) && edd_is_ajax_enabled() || edd_is_ssl_enforced()) { $uri = preg_replace('/^http:/', 'https:', $uri); } if (edd_get_option('no_cache_checkout', false) && edd_is_caching_plugin_active()) { $uri = add_query_arg('nocache', 'true', $uri); } return apply_filters('edd_get_checkout_uri', $uri); }