/** * Returns the URL to remove an item from the cart * * @since 1.0 * @global $post * @param int $cart_key Cart item key * @return string $remove_url URL to remove the cart item */ function edd_remove_item_url($cart_key) { global $wp_query; if (defined('DOING_AJAX')) { $current_page = edd_get_checkout_uri(); } else { $current_page = edd_get_current_page_url(); } $remove_url = edd_add_cache_busting(add_query_arg(array('cart_item' => $cart_key, 'edd_action' => 'remove'), $current_page)); return apply_filters('edd_remove_item_url', $remove_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)) { $uri = edd_add_cache_busting($uri); } return apply_filters('edd_get_checkout_uri', $uri); }
/** * Get the current page URL * * @since 1.3 * @param bool $nocache If we should bust cache on the returned URL * @return string $page_url Current page URL */ function edd_get_current_page_url($nocache = false) { global $wp; if (get_option('permalink_structure')) { $base = trailingslashit(home_url($wp->request)); } else { $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); $base = remove_query_arg(array('post_type', 'name'), $base); } $scheme = is_ssl() ? 'https' : 'http'; $uri = set_url_scheme($base, $scheme); if (is_front_page()) { $uri = home_url('/'); } elseif (edd_is_checkout()) { $uri = edd_get_checkout_uri(); } $uri = apply_filters('edd_get_current_page_url', $uri); if ($nocache) { $uri = edd_add_cache_busting($uri); } return $uri; }
/** * Get the current page URL * * @since 1.3 * @param bool $nocache If we should bust cache on the returned URL * @return string $page_url Current page URL */ function edd_get_current_page_url($nocache = false) { $scheme = is_ssl() ? 'https' : 'http'; $uri = esc_url(site_url($_SERVER['REQUEST_URI'], $scheme)); if (is_front_page()) { $uri = home_url(); } elseif (edd_is_checkout(array(), false)) { $uri = edd_get_checkout_uri(); } $uri = apply_filters('edd_get_current_page_url', $uri); if ($nocache) { $uri = edd_add_cache_busting($uri); } return $uri; }