From aba310f321ba83088e37ff802f97495b3f2b836d Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 6 Jan 2012 17:14:31 +0000 Subject: [PATCH] WPML filters #244 --- admin/woocommerce-admin-functions.php | 2 +- admin/woocommerce-admin-install.php | 10 +++++----- admin/woocommerce-admin-settings.php | 6 +++--- classes/cart.class.php | 12 ++++++------ classes/checkout.class.php | 12 +++++++----- classes/gateways/gateway-banktransfer.php | 2 +- classes/gateways/gateway-cheque.php | 2 +- classes/gateways/gateway-paypal.php | 2 +- classes/gateways/gateway.class.php | 4 ++-- classes/order.class.php | 6 +++--- shortcodes/shortcode-checkout.php | 2 +- shortcodes/shortcode-my_account.php | 12 ++++++------ shortcodes/shortcode-pay.php | 6 +++--- templates/cart/cart.php | 4 ++-- templates/cart/empty.php | 2 +- templates/checkout/login-form.php | 2 +- templates/checkout/review_order.php | 4 ++-- templates/checkout/thankyou.php | 2 +- templates/emails/customer_new_account.php | 2 +- templates/myaccount/change-password.php | 2 +- templates/myaccount/edit-address.php | 2 +- templates/myaccount/my-account.php | 8 ++++---- templates/shop/breadcrumb.php | 10 +++++----- uninstall.php | 20 ++++++++++---------- widgets/widget-layered_nav.php | 2 +- widgets/widget-login.php | 8 ++++---- woocommerce-ajax.php | 2 +- woocommerce-core-functions.php | 21 ++++++++++++++++----- woocommerce-functions.php | 22 +++++++++++----------- woocommerce-template.php | 2 +- woocommerce.php | 18 +++++++++--------- 31 files changed, 112 insertions(+), 99 deletions(-) diff --git a/admin/woocommerce-admin-functions.php b/admin/woocommerce-admin-functions.php index 101847eecb6..f82ed1ed15a 100644 --- a/admin/woocommerce-admin-functions.php +++ b/admin/woocommerce-admin-functions.php @@ -99,7 +99,7 @@ Gothica minim lectores demonstraverunt ut soluta. Sequitur quam exerci veniam al */ function woocommerce_prevent_admin_access() { if ( get_option('woocommerce_lock_down_admin')=='yes' && !is_ajax() && !current_user_can('edit_posts') ) : - wp_safe_redirect(get_permalink(get_option('woocommerce_myaccount_page_id'))); + wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount'))); exit; endif; } diff --git a/admin/woocommerce-admin-install.php b/admin/woocommerce-admin-install.php index e197a3c420c..38c88c945e1 100644 --- a/admin/woocommerce-admin-install.php +++ b/admin/woocommerce-admin-install.php @@ -162,19 +162,19 @@ function woocommerce_create_pages() { woocommerce_create_page( esc_sql( _x('my-account', 'page_slug', 'woocommerce') ), 'woocommerce_myaccount_page_id', __('My Account', 'woocommerce'), '[woocommerce_my_account]' ); // Edit address page - woocommerce_create_page( esc_sql( _x('edit-address', 'page_slug', 'woocommerce') ), 'woocommerce_edit_address_page_id', __('Edit My Address', 'woocommerce'), '[woocommerce_edit_address]', get_option('woocommerce_myaccount_page_id') ); + woocommerce_create_page( esc_sql( _x('edit-address', 'page_slug', 'woocommerce') ), 'woocommerce_edit_address_page_id', __('Edit My Address', 'woocommerce'), '[woocommerce_edit_address]', woocommerce_get_page_id('myaccount') ); // View order page - woocommerce_create_page( esc_sql( _x('view-order', 'page_slug', 'woocommerce') ), 'woocommerce_view_order_page_id', __('View Order', 'woocommerce'), '[woocommerce_view_order]', get_option('woocommerce_myaccount_page_id') ); + woocommerce_create_page( esc_sql( _x('view-order', 'page_slug', 'woocommerce') ), 'woocommerce_view_order_page_id', __('View Order', 'woocommerce'), '[woocommerce_view_order]', woocommerce_get_page_id('myaccount') ); // Change password page - woocommerce_create_page( esc_sql( _x('change-password', 'page_slug', 'woocommerce') ), 'woocommerce_change_password_page_id', __('Change Password', 'woocommerce'), '[woocommerce_change_password]', get_option('woocommerce_myaccount_page_id') ); + woocommerce_create_page( esc_sql( _x('change-password', 'page_slug', 'woocommerce') ), 'woocommerce_change_password_page_id', __('Change Password', 'woocommerce'), '[woocommerce_change_password]', woocommerce_get_page_id('myaccount') ); // Pay page - woocommerce_create_page( esc_sql( _x('pay', 'page_slug', 'woocommerce') ), 'woocommerce_pay_page_id', __('Checkout → Pay', 'woocommerce'), '[woocommerce_pay]', get_option('woocommerce_checkout_page_id') ); + woocommerce_create_page( esc_sql( _x('pay', 'page_slug', 'woocommerce') ), 'woocommerce_pay_page_id', __('Checkout → Pay', 'woocommerce'), '[woocommerce_pay]', woocommerce_get_page_id('checkout') ); // Thanks page - woocommerce_create_page( esc_sql( _x('order-received', 'page_slug', 'woocommerce') ), 'woocommerce_thanks_page_id', __('Order Received', 'woocommerce'), '[woocommerce_thankyou]', get_option('woocommerce_checkout_page_id') ); + woocommerce_create_page( esc_sql( _x('order-received', 'page_slug', 'woocommerce') ), 'woocommerce_thanks_page_id', __('Order Received', 'woocommerce'), '[woocommerce_thankyou]', woocommerce_get_page_id('checkout') ); } diff --git a/admin/woocommerce-admin-settings.php b/admin/woocommerce-admin-settings.php index 9a88857a0a4..0e2376a4c36 100644 --- a/admin/woocommerce-admin-settings.php +++ b/admin/woocommerce-admin-settings.php @@ -253,7 +253,7 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', )); // End general settings -$shop_page_id = get_option('woocommerce_shop_page_id'); +$shop_page_id = woocommerce_get_page_id('shop'); $base_slug = ($shop_page_id > 0 && get_page( $shop_page_id )) ? get_page_uri( $shop_page_id ) : 'shop'; $woocommerce_settings['pages'] = apply_filters('woocommerce_page_settings', array( @@ -1021,14 +1021,14 @@ function woocommerce_settings() { flush_rewrite_rules( false ); - if (get_option('woocommerce_shop_page_id')) : + if (woocommerce_get_page_id('shop')) : $install_complete = true; else : $show_page_installer = true; endif; // If we havn't just installed, but page installed has not been skipped and shop page does not exist... - elseif (!get_option('skip_install_woocommerce_pages') && !get_option('woocommerce_shop_page_id')) : + elseif (!get_option('skip_install_woocommerce_pages') && !woocommerce_get_page_id('shop')) : $show_page_installer = true; diff --git a/classes/cart.class.php b/classes/cart.class.php index 7937aed5167..7503e7607dd 100644 --- a/classes/cart.class.php +++ b/classes/cart.class.php @@ -261,24 +261,24 @@ class woocommerce_cart { /** gets the url to the cart page */ function get_cart_url() { - $cart_page_id = get_option('woocommerce_cart_page_id'); - if ($cart_page_id) return get_permalink($cart_page_id); + $cart_page_id = woocommerce_get_page_id('cart'); + if ($cart_page_id) return apply_filters('woocommerce_get_cart_url', get_permalink($cart_page_id)); } /** gets the url to the checkout page */ function get_checkout_url() { - $checkout_page_id = get_option('woocommerce_checkout_page_id'); + $checkout_page_id = woocommerce_get_page_id('checkout'); if ($checkout_page_id) : if (is_ssl()) return str_replace('http:', 'https:', get_permalink($checkout_page_id)); - return get_permalink($checkout_page_id); + return apply_filters('woocommerce_get_checkout_url', get_permalink($checkout_page_id)); endif; } /** gets the url to remove an item from the cart */ function get_remove_url( $cart_item_key ) { global $woocommerce; - $cart_page_id = get_option('woocommerce_cart_page_id'); - if ($cart_page_id) return $woocommerce->nonce_url( 'cart', add_query_arg('remove_item', $cart_item_key, get_permalink($cart_page_id))); + $cart_page_id = woocommerce_get_page_id('cart'); + if ($cart_page_id) return apply_filters('woocommerce_get_remove_url', $woocommerce->nonce_url( 'cart', add_query_arg('remove_item', $cart_item_key, get_permalink($cart_page_id)))); } /** diff --git a/classes/checkout.class.php b/classes/checkout.class.php index b2d5ac8b7a1..fe1d1a4bd6a 100644 --- a/classes/checkout.class.php +++ b/classes/checkout.class.php @@ -299,7 +299,7 @@ class woocommerce_checkout { endif; // Terms - if (!isset($_POST['update_totals']) && empty($this->posted['terms']) && get_option('woocommerce_terms_page_id')>0 ) $woocommerce->add_error( __('You must accept our Terms & Conditions.', 'woocommerce') ); + if (!isset($_POST['update_totals']) && empty($this->posted['terms']) && woocommerce_get_page_id('terms')>0 ) $woocommerce->add_error( __('You must accept our Terms & Conditions.', 'woocommerce') ); if ($woocommerce->cart->needs_shipping()) : @@ -565,10 +565,12 @@ class woocommerce_checkout { // Redirect to success/confirmation/payment page if ($result['result']=='success') : - + + $result = apply_filters('woocommerce_payment_successful_result', $result ); + if (is_ajax()) : ob_clean(); - echo json_encode($result); + echo json_encode( $result ); exit; else : wp_safe_redirect( $result['redirect'] ); @@ -588,10 +590,10 @@ class woocommerce_checkout { // Redirect to success/confirmation/payment page if (is_ajax()) : ob_clean(); - echo json_encode( array('redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', get_permalink(get_option('woocommerce_thanks_page_id')))) ); + echo json_encode( array('redirect' => apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', get_permalink(woocommerce_get_page_id('thanks')))) ); exit; else : - wp_safe_redirect( apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', get_permalink(get_option('woocommerce_thanks_page_id'))) ); + wp_safe_redirect( apply_filters( 'woocommerce_checkout_no_payment_needed_redirect', get_permalink(woocommerce_get_page_id('thanks'))) ); exit; endif; diff --git a/classes/gateways/gateway-banktransfer.php b/classes/gateways/gateway-banktransfer.php index 3a48a7b7e93..50509265ff7 100644 --- a/classes/gateways/gateway-banktransfer.php +++ b/classes/gateways/gateway-banktransfer.php @@ -211,7 +211,7 @@ class woocommerce_bacs extends woocommerce_payment_gateway { // Return thankyou redirect return array( 'result' => 'success', - 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('woocommerce_thanks_page_id')))) + 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks')))) ); } diff --git a/classes/gateways/gateway-cheque.php b/classes/gateways/gateway-cheque.php index 26f2176db7e..7c8ee337477 100755 --- a/classes/gateways/gateway-cheque.php +++ b/classes/gateways/gateway-cheque.php @@ -126,7 +126,7 @@ class woocommerce_cheque extends woocommerce_payment_gateway { // Return thankyou redirect return array( 'result' => 'success', - 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('woocommerce_thanks_page_id')))) + 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks')))) ); } diff --git a/classes/gateways/gateway-paypal.php b/classes/gateways/gateway-paypal.php index ee75cd43b90..c39ca6ec322 100644 --- a/classes/gateways/gateway-paypal.php +++ b/classes/gateways/gateway-paypal.php @@ -317,7 +317,7 @@ class woocommerce_paypal extends woocommerce_payment_gateway { return array( 'result' => 'success', - 'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(get_option('woocommerce_pay_page_id')))) + 'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(woocommerce_get_page_id('pay')))) ); } diff --git a/classes/gateways/gateway.class.php b/classes/gateways/gateway.class.php index 05a5b2c32c4..8b5c8164033 100644 --- a/classes/gateways/gateway.class.php +++ b/classes/gateways/gateway.class.php @@ -28,7 +28,7 @@ class woocommerce_payment_gateway extends woocommerce_settings_api { */ function get_return_url( $order = '' ) { - $thanks_page_id = get_option('woocommerce_thanks_page_id'); + $thanks_page_id = woocommerce_get_page_id('thanks'); if ($thanks_page_id) : $return_url = get_permalink($thanks_page_id); else : @@ -41,7 +41,7 @@ class woocommerce_payment_gateway extends woocommerce_settings_api { if (is_ssl() || get_option('woocommerce_force_ssl_checkout')=='yes') $return_url = str_replace('http:', 'https:', $return_url); - return $return_url; + return apply_filters('woocommerce_get_return_url', $return_url); } /** diff --git a/classes/order.class.php b/classes/order.class.php index 29b867a25f0..c7a5aee9fff 100644 --- a/classes/order.class.php +++ b/classes/order.class.php @@ -470,18 +470,18 @@ class woocommerce_order { /** Generates a URL so that a customer can checkout/pay for their (unpaid - pending) order via a link */ function get_checkout_payment_url() { - $payment_page = get_permalink(get_option('woocommerce_pay_page_id')); + $payment_page = get_permalink(woocommerce_get_page_id('pay')); if (get_option('woocommerce_force_ssl_checkout')=='yes' || is_ssl()) $payment_page = str_replace('http:', 'https:', $payment_page); - return add_query_arg('pay_for_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, $payment_page))); + return apply_filters('woocommerce_get_checkout_payment_url', add_query_arg('pay_for_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, $payment_page)))); } /** Generates a URL so that a customer can cancel their (unpaid - pending) order */ function get_cancel_order_url() { global $woocommerce; - return $woocommerce->nonce_url( 'cancel_order', add_query_arg('cancel_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, trailingslashit( home_url() ))))); + return apply_filters('woocommerce_get_cancel_order_url', $woocommerce->nonce_url( 'cancel_order', add_query_arg('cancel_order', 'true', add_query_arg('order', $this->order_key, add_query_arg('order_id', $this->id, trailingslashit( home_url() )))))); } diff --git a/shortcodes/shortcode-checkout.php b/shortcodes/shortcode-checkout.php index 0dab630fba9..029cea8b38f 100644 --- a/shortcodes/shortcode-checkout.php +++ b/shortcodes/shortcode-checkout.php @@ -20,7 +20,7 @@ function woocommerce_checkout( $atts ) { if (!defined('WOOCOMMERCE_CHECKOUT')) define('WOOCOMMERCE_CHECKOUT', true); if (sizeof($woocommerce->cart->get_cart())==0) : - wp_redirect(get_permalink(get_option('woocommerce_cart_page_id'))); + wp_redirect(get_permalink(woocommerce_get_page_id('cart'))); exit; endif; diff --git a/shortcodes/shortcode-my_account.php b/shortcodes/shortcode-my_account.php index 2982a33cdc5..8e0d72171c7 100644 --- a/shortcodes/shortcode-my_account.php +++ b/shortcodes/shortcode-my_account.php @@ -73,7 +73,7 @@ function woocommerce_edit_address() { global $woocommerce, $load_address, $address; if ( ! is_user_logged_in() ) : - wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ); + wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) ); exit; endif; @@ -152,7 +152,7 @@ function woocommerce_save_address() { do_action( 'woocommerce_customer_save_address', $user_id ); - wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ); + wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) ); exit; } } @@ -188,7 +188,7 @@ function woocommerce_change_password() { global $woocommerce; if ( ! is_user_logged_in() ) : - wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ); + wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) ); exit; endif; @@ -231,7 +231,7 @@ function woocommerce_save_password() { do_action( 'woocommerce_customer_change_password', $user_id ); - wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ); + wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) ); exit; } } @@ -247,7 +247,7 @@ function woocommerce_view_order() { global $woocommerce; if ( ! is_user_logged_in() ) : - wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ); + wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) ); exit; endif; @@ -256,7 +256,7 @@ function woocommerce_view_order() { $order = &new woocommerce_order( $order_id ); if ( $order_id==0 || $order->user_id != $user_id ) : - wp_safe_redirect( get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ) ); + wp_safe_redirect( get_permalink( woocommerce_get_page_id('myaccount') ) ); exit; endif; diff --git a/shortcodes/shortcode-pay.php b/shortcodes/shortcode-pay.php index 602274a3e9a..58d03471823 100644 --- a/shortcodes/shortcode-pay.php +++ b/shortcodes/shortcode-pay.php @@ -61,7 +61,7 @@ function woocommerce_pay() { // No payment was required for order $order->payment_complete(); - wp_safe_redirect( get_permalink(get_option('woocommerce_thanks_page_id')) ); + wp_safe_redirect( get_permalink(woocommerce_get_page_id('thanks')) ); exit; endif; @@ -124,14 +124,14 @@ function woocommerce_pay() { else : - wp_safe_redirect( get_permalink(get_option('woocommerce_myaccount_page_id')) ); + wp_safe_redirect( get_permalink(woocommerce_get_page_id('myaccount')) ); exit; endif; else : - wp_safe_redirect( get_permalink(get_option('woocommerce_myaccount_page_id')) ); + wp_safe_redirect( get_permalink(woocommerce_get_page_id('myaccount')) ); exit; endif; diff --git a/templates/cart/cart.php b/templates/cart/cart.php index 14187804c62..6792c2cc5cb 100644 --- a/templates/cart/cart.php +++ b/templates/cart/cart.php @@ -31,14 +31,14 @@ global $woocommerce; × - + get_image(); ?> - get_title(); ?> + get_title(); ?> cart->get_item_data( $values ); diff --git a/templates/cart/empty.php b/templates/cart/empty.php index 6b2103e384e..77316ca068f 100644 --- a/templates/cart/empty.php +++ b/templates/cart/empty.php @@ -8,4 +8,4 @@ -

\ No newline at end of file +

\ No newline at end of file diff --git a/templates/checkout/login-form.php b/templates/checkout/login-form.php index fd6625a749f..ab3d6b7258a 100644 --- a/templates/checkout/login-form.php +++ b/templates/checkout/login-form.php @@ -10,4 +10,4 @@ $info_message = apply_filters('woocommerce_checkout_login_message', __('Already

- __('If you have shopped with us before, please enter your username and password in the boxes below. If you are a new customer please proceed to the Billing & Shipping section.', 'woocommerce'), 'redirect' => get_permalink(get_option('woocommerce_checkout_page_id')) ) ); ?> \ No newline at end of file + __('If you have shopped with us before, please enter your username and password in the boxes below. If you are a new customer please proceed to the Billing & Shipping section.', 'woocommerce'), 'redirect' => get_permalink(woocommerce_get_page_id('checkout')) ) ); ?> \ No newline at end of file diff --git a/templates/checkout/review_order.php b/templates/checkout/review_order.php index 0c0acd05430..ead832c6e4d 100755 --- a/templates/checkout/review_order.php +++ b/templates/checkout/review_order.php @@ -234,9 +234,9 @@ - 0) : ?> + 0) : ?>

- + id="terms" />

diff --git a/templates/checkout/thankyou.php b/templates/checkout/thankyou.php index 7024383c8d2..15cb6d6e30a 100644 --- a/templates/checkout/thankyou.php +++ b/templates/checkout/thankyou.php @@ -23,7 +23,7 @@ global $woocommerce, $order;

- +

diff --git a/templates/emails/customer_new_account.php b/templates/emails/customer_new_account.php index 2e3b1a5346f..e74268b15ee 100644 --- a/templates/emails/customer_new_account.php +++ b/templates/emails/customer_new_account.php @@ -11,7 +11,7 @@
  • -

    +

    diff --git a/templates/myaccount/change-password.php b/templates/myaccount/change-password.php index dee2d260a1d..b3b7737fa60 100644 --- a/templates/myaccount/change-password.php +++ b/templates/myaccount/change-password.php @@ -8,7 +8,7 @@ global $woocommerce; show_messages(); ?> -
    +

    diff --git a/templates/myaccount/edit-address.php b/templates/myaccount/edit-address.php index 05b6bc12cb5..8734b7c5871 100644 --- a/templates/myaccount/edit-address.php +++ b/templates/myaccount/edit-address.php @@ -8,7 +8,7 @@ global $woocommerce, $load_address, $address; show_messages(); ?> - +

    diff --git a/templates/myaccount/my-account.php b/templates/myaccount/my-account.php index 184036ec793..634dfb4e07a 100644 --- a/templates/myaccount/my-account.php +++ b/templates/myaccount/my-account.php @@ -8,7 +8,7 @@ global $woocommerce, $current_user, $recent_orders; show_messages(); ?> -

    %s. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and change your password.', 'woocommerce'), $current_user->display_name, get_permalink(get_option('woocommerce_change_password_page_id'))); ?>

    +

    %s. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and change your password.', 'woocommerce'), $current_user->display_name, get_permalink(woocommerce_get_page_id('change_password'))); ?>

    @@ -65,7 +65,7 @@ if ($customer_orders) : - +

    - +

    - +
    ' . get_the_title( get_option('woocommerce_shop_page_id') ) . ' ' . $after . $delimiter; +if ( get_option('woocommerce_prepend_shop_page_to_urls')=="yes" && woocommerce_get_page_id('shop') && get_option('page_on_front') !== woocommerce_get_page_id('shop') ) + $prepend = $before . '' . get_the_title( woocommerce_get_page_id('shop') ) . ' ' . $after . $delimiter; -if ( (!is_home() && !is_front_page() && !(is_post_type_archive() && get_option('page_on_front')==get_option('woocommerce_shop_page_id'))) || is_paged() ) : +if ( (!is_home() && !is_front_page() && !(is_post_type_archive() && get_option('page_on_front')==woocommerce_get_page_id('shop'))) || is_paged() ) : echo $wrap_before; @@ -74,9 +74,9 @@ if ( (!is_home() && !is_front_page() && !(is_post_type_archive() && get_option(' echo $before . get_the_time('Y') . $after; - elseif ( is_post_type_archive('product') && get_option('page_on_front') !== get_option('woocommerce_shop_page_id') ) : + elseif ( is_post_type_archive('product') && get_option('page_on_front') !== woocommerce_get_page_id('shop') ) : - $_name = get_option('woocommerce_shop_page_id') ? get_the_title( get_option('woocommerce_shop_page_id') ) : ucwords(get_option('woocommerce_shop_slug')); + $_name = woocommerce_get_page_id('shop') ? get_the_title( woocommerce_get_page_id('shop') ) : ucwords(get_option('woocommerce_shop_slug')); if (is_search()) : diff --git a/uninstall.php b/uninstall.php index cb460866d0f..2034c804b9f 100644 --- a/uninstall.php +++ b/uninstall.php @@ -21,16 +21,16 @@ remove_role( 'shop_manager' ); $wp_roles->remove_cap( 'administrator', 'manage_woocommerce' ); // Pages -wp_delete_post( get_option('woocommerce_shop_page_id'), true ); -wp_delete_post( get_option('woocommerce_cart_page_id'), true ); -wp_delete_post( get_option('woocommerce_checkout_page_id'), true ); -wp_delete_post( get_option('woocommerce_order_tracking_page_id'), true ); -wp_delete_post( get_option('woocommerce_myaccount_page_id'), true ); -wp_delete_post( get_option('woocommerce_edit_address_page_id'), true ); -wp_delete_post( get_option('woocommerce_view_order_page_id'), true ); -wp_delete_post( get_option('woocommerce_change_password_page_id'), true ); -wp_delete_post( get_option('woocommerce_pay_page_id'), true ); -wp_delete_post( get_option('woocommerce_thanks_page_id'), true ); +wp_delete_post( woocommerce_get_page_id('shop'), true ); +wp_delete_post( woocommerce_get_page_id('cart'), true ); +wp_delete_post( woocommerce_get_page_id('checkout'), true ); +wp_delete_post( woocommerce_get_page_id('order_tracking'), true ); +wp_delete_post( woocommerce_get_page_id('myaccount'), true ); +wp_delete_post( woocommerce_get_page_id('edit_address'), true ); +wp_delete_post( woocommerce_get_page_id('view_order'), true ); +wp_delete_post( woocommerce_get_page_id('change_password'), true ); +wp_delete_post( woocommerce_get_page_id('pay'), true ); +wp_delete_post( woocommerce_get_page_id('thanks'), true ); // Tables $wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."woocommerce_attribute_taxonomies"); diff --git a/widgets/widget-layered_nav.php b/widgets/widget-layered_nav.php index 5fb7b0479bb..50c922cd729 100644 --- a/widgets/widget-layered_nav.php +++ b/widgets/widget-layered_nav.php @@ -222,7 +222,7 @@ class WooCommerce_Widget_Layered_Nav extends WP_Widget { // Base Link decided by current page if (defined('SHOP_IS_ON_FRONT')) : $link = home_url(); - elseif (is_post_type_archive('product') || is_page( get_option('woocommerce_shop_page_id') )) : + elseif (is_post_type_archive('product') || is_page( woocommerce_get_page_id('shop') )) : $link = get_post_type_archive_link('product'); else : $link = get_term_link( get_query_var('term'), get_query_var('taxonomy') ); diff --git a/widgets/widget-login.php b/widgets/widget-login.php index fd1949fefeb..93b6a466923 100644 --- a/widgets/widget-login.php +++ b/widgets/widget-login.php @@ -53,8 +53,8 @@ class WooCommerce_Widget_Login extends WP_Widget { do_action('woocommerce_login_widget_logged_in_before_links'); $links = apply_filters( 'woocommerce_login_widget_logged_in_links', array( - __('My account', 'woocommerce') => get_permalink(get_option('woocommerce_myaccount_page_id')), - __('Change my password', 'woocommerce') => get_permalink(get_option('woocommerce_change_password_page_id')), + __('My account', 'woocommerce') => get_permalink(woocommerce_get_page_id('myaccount')), + __('Change my password', 'woocommerce') => get_permalink(woocommerce_get_page_id('change_password')), __('Logout', 'woocommerce') => wp_logout_url(home_url()) )); @@ -86,7 +86,7 @@ class WooCommerce_Widget_Login extends WP_Widget { endforeach; // Get redirect URL - $redirect_to = apply_filters( 'woocommerce_login_widget_redirect', get_permalink(get_option('woocommerce_myaccount_page_id')) ); + $redirect_to = apply_filters( 'woocommerce_login_widget_redirect', get_permalink(woocommerce_get_page_id('myaccount')) ); ?> @@ -196,7 +196,7 @@ function woocommerce_sidebar_login_process() { global $login_errors; // Get redirect URL - $redirect_to = apply_filters( 'woocommerce_login_widget_redirect', get_permalink(get_option('woocommerce_myaccount_page_id')) ); + $redirect_to = apply_filters( 'woocommerce_login_widget_redirect', get_permalink(woocommerce_get_page_id('myaccount')) ); // Check for Secure Cookie $secure_cookie = ''; diff --git a/woocommerce-ajax.php b/woocommerce-ajax.php index 2547d7b89b9..ee083ffc1d8 100644 --- a/woocommerce-ajax.php +++ b/woocommerce-ajax.php @@ -137,7 +137,7 @@ function woocommerce_ajax_add_to_cart() { check_ajax_referer( 'add-to-cart', 'security' ); - $product_id = (int) $_POST['product_id']; + $product_id = (int) apply_filters('woocommerce_add_to_cart_product_id', $_POST['product_id']); if ($woocommerce->cart->add_to_cart($product_id, 1)) : // Return html fragments diff --git a/woocommerce-core-functions.php b/woocommerce-core-functions.php index b4003b0f99f..5128bbfd725 100644 --- a/woocommerce-core-functions.php +++ b/woocommerce-core-functions.php @@ -20,6 +20,17 @@ function woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: te $mailer->send( $to, $subject, $message, $headers, $attachments ); } +/** + * WooCommerce page IDs + * + * retrieve page ids - used for myaccount, edit_address, change_password, shop, cart, checkout, pay, view_order, thanks, terms, order_tracking + **/ +if (!function_exists('woocommerce_get_page_id')) { + function woocommerce_get_page_id( $page ) { + return apply_filters('woocommerce_get_' . $page . '_page_id', get_option('woocommerce_' . $page . '_page_id')); + } +} + /** * WooCommerce conditionals * @@ -30,7 +41,7 @@ function is_woocommerce() { } if (!function_exists('is_shop')) { function is_shop() { - if (is_post_type_archive( 'product' ) || is_page(get_option('woocommerce_shop_page_id'))) return true; else return false; + if (is_post_type_archive( 'product' ) || is_page(woocommerce_get_page_id('shop'))) return true; else return false; } } if (!function_exists('is_product_category')) { @@ -50,18 +61,18 @@ if (!function_exists('is_product')) { } if (!function_exists('is_cart')) { function is_cart() { - return is_page(get_option('woocommerce_cart_page_id')); + return is_page(woocommerce_get_page_id('cart')); } } if (!function_exists('is_checkout')) { function is_checkout() { - if (is_page(get_option('woocommerce_checkout_page_id')) || is_page(get_option('woocommerce_pay_page_id'))) return true; else return false; + if (is_page(woocommerce_get_page_id('checkout')) || is_page(woocommerce_get_page_id('pay'))) return true; else return false; } } if (!function_exists('is_account_page')) { function is_account_page() { - if ( is_page(get_option('woocommerce_myaccount_page_id')) || is_page(get_option('woocommerce_edit_address_page_id')) || is_page(get_option('woocommerce_view_order_page_id')) || is_page(get_option('woocommerce_change_password_page_id')) ) return true; else return false; - return is_page(get_option('woocommerce_myaccount_page_id')); + if ( is_page(woocommerce_get_page_id('myaccount')) || is_page(woocommerce_get_page_id('edit_address')) || is_page(woocommerce_get_page_id('view_order')) || is_page(woocommerce_get_page_id('change_password')) ) return true; else return false; + return is_page(woocommerce_get_page_id('myaccount')); } } if (!function_exists('is_ajax')) { diff --git a/woocommerce-functions.php b/woocommerce-functions.php index a6306be3979..c52b8df9e28 100644 --- a/woocommerce-functions.php +++ b/woocommerce-functions.php @@ -13,7 +13,7 @@ * When default permalinks are enabled, redirect shop page to post type archive url **/ function woocommerce_shop_page_archive_redirect() { - if ( isset($_GET['page_id']) && get_option( 'permalink_structure' )=="" && $_GET['page_id'] == get_option('woocommerce_shop_page_id') ) : + if ( isset($_GET['page_id']) && get_option( 'permalink_structure' )=="" && $_GET['page_id'] == woocommerce_get_page_id('shop') ) : wp_safe_redirect( get_post_type_archive_link('product') ); exit; endif; @@ -26,7 +26,7 @@ function woocommerce_nav_menu_item_classes( $menu_items, $args ) { if (!is_woocommerce()) return $menu_items; - $shop_page = (int) get_option('woocommerce_shop_page_id'); + $shop_page = (int) woocommerce_get_page_id('shop'); $page_for_posts = (int) get_option( 'page_for_posts' ); foreach ( (array) $menu_items as $key => $menu_item ) : @@ -59,7 +59,7 @@ function woocommerce_nav_menu_item_classes( $menu_items, $args ) { **/ function woocommerce_front_page_archive_paging_fix() { - if ( is_front_page() && is_page( get_option('woocommerce_shop_page_id') )) : + if ( is_front_page() && is_page( woocommerce_get_page_id('shop') )) : if (get_query_var('paged')) : $paged = get_query_var('paged'); @@ -69,7 +69,7 @@ function woocommerce_front_page_archive_paging_fix() { global $wp_query; - $wp_query->query( array( 'page_id' => get_option('woocommerce_shop_page_id'), 'is_paged' => true, 'paged' => $paged ) ); + $wp_query->query( array( 'page_id' => woocommerce_get_page_id('shop'), 'is_paged' => true, 'paged' => $paged ) ); define('SHOP_IS_ON_FRONT', true); @@ -119,7 +119,7 @@ function woocommerce_list_pages($pages){ if (is_woocommerce()) { $pages = str_replace( 'current_page_parent', '', $pages); // remove current_page_parent class from any item - $shop_page = 'page-item-' . get_option('woocommerce_shop_page_id'); // find shop_page_id through woocommerce options + $shop_page = 'page-item-' . woocommerce_get_page_id('shop'); // find shop_page_id through woocommerce options if (is_shop()) : $pages = str_replace($shop_page, $shop_page . ' current_page_item', $pages); // add current_page_item class to shop page @@ -134,7 +134,7 @@ function woocommerce_list_pages($pages){ * Add logout link to my account menu **/ function woocommerce_nav_menu_items( $items, $args ) { - if ( get_option('woocommerce_menu_logout_link')=='yes' && strstr($items, get_permalink(get_option('woocommerce_myaccount_page_id'))) && is_user_logged_in() ) : + if ( get_option('woocommerce_menu_logout_link')=='yes' && strstr($items, get_permalink(woocommerce_get_page_id('myaccount'))) && is_user_logged_in() ) : $items .= '
  • '.__('Logout', 'woocommerce').'
  • '; endif; @@ -220,12 +220,12 @@ function woocommerce_add_to_cart_action( $url = false ) { if (empty($_POST['variation_id']) || !is_numeric($_POST['variation_id'])) : $woocommerce->add_error( __('Please choose product options…', 'woocommerce') ); - wp_safe_redirect(get_permalink($_GET['product'])); + wp_safe_redirect(apply_filters('woocommerce_add_to_cart_product_id', get_permalink($_GET['product']))); exit; else : - $product_id = (int) $_GET['product']; + $product_id = (int) apply_filters('woocommerce_add_to_cart_product_id', $_GET['product']); $variation_id = (int) $_POST['variation_id']; $quantity = (isset($_POST['quantity'])) ? (int) $_POST['quantity'] : 1; @@ -348,7 +348,7 @@ function woocommerce_add_to_cart_message() { function woocommerce_clear_cart_after_payment() { global $woocommerce; - if (is_page(get_option('woocommerce_thanks_page_id'))) : + if (is_page(woocommerce_get_page_id('thanks'))) : if (isset($_GET['order'])) $order_id = $_GET['order']; else $order_id = 0; if (isset($_GET['key'])) $order_key = $_GET['key']; else $order_key = ''; @@ -416,7 +416,7 @@ function woocommerce_process_login() { exit; endif; - wp_redirect(get_permalink(get_option('woocommerce_myaccount_page_id'))); + wp_redirect(get_permalink(woocommerce_get_page_id('myaccount'))); exit; endif; @@ -523,7 +523,7 @@ function woocommerce_process_registration() { wp_safe_redirect( wp_get_referer() ); exit; endif; - wp_redirect(get_permalink(get_option('woocommerce_myaccount_page_id'))); + wp_redirect(get_permalink(woocommerce_get_page_id('myaccount'))); exit; else : diff --git a/woocommerce-template.php b/woocommerce-template.php index 33930b29f18..2aeff952c7e 100644 --- a/woocommerce-template.php +++ b/woocommerce-template.php @@ -31,7 +31,7 @@ if (!function_exists('woocommerce_archive_product_content')) { function woocommerce_archive_product_content() { ?> post_title; ?> diff --git a/woocommerce.php b/woocommerce.php index bf4ba3b9488..b9ccc959901 100644 --- a/woocommerce.php +++ b/woocommerce.php @@ -239,7 +239,7 @@ class woocommerce { $find = 'taxonomy-product_cat.php'; elseif ( is_tax('product_tag') ) $find = 'taxonomy-product_tag.php'; - elseif ( is_post_type_archive('product') || is_page( get_option('woocommerce_shop_page_id') )) + elseif ( is_post_type_archive('product') || is_page( woocommerce_get_page_id('shop') )) $find = 'archive-product.php'; else $find = false; @@ -334,10 +334,10 @@ class woocommerce { **/ function ssl_redirect() { if (!is_ssl() && get_option('woocommerce_force_ssl_checkout')=='yes' && is_checkout()) : - wp_safe_redirect( str_replace('http:', 'https:', get_permalink(get_option('woocommerce_checkout_page_id'))), 301 ); + wp_safe_redirect( str_replace('http:', 'https:', get_permalink(woocommerce_get_page_id('checkout'))), 301 ); exit; // Break out of SSL if we leave the checkout (anywhere but thanks page) - elseif (is_ssl() && get_option('woocommerce_force_ssl_checkout')=='yes' && get_option('woocommerce_unforce_ssl_checkout')=='yes' && $_SERVER['REQUEST_URI'] && !is_checkout() && !is_page(get_option('woocommerce_thanks_page_id')) && !is_ajax()) : + elseif (is_ssl() && get_option('woocommerce_force_ssl_checkout')=='yes' && get_option('woocommerce_unforce_ssl_checkout')=='yes' && $_SERVER['REQUEST_URI'] && !is_checkout() && !is_page(woocommerce_get_page_id('thanks')) && !is_ajax()) : wp_safe_redirect( str_replace('https:', 'http:', home_url($_SERVER['REQUEST_URI']) ) ); exit; endif; @@ -359,7 +359,7 @@ class woocommerce { if (is_account_page()) $this->add_body_class('woocommerce-account'); - if (is_woocommerce() || is_checkout() || is_cart() || is_account_page() || is_page(get_option('woocommerce_order_tracking_page_id')) || is_page(get_option('woocommerce_thanks_page_id'))) $this->add_body_class('woocommerce-page'); + if (is_woocommerce() || is_checkout() || is_cart() || is_account_page() || is_page(woocommerce_get_page_id('order_tracking')) || is_page(woocommerce_get_page_id('thanks'))) $this->add_body_class('woocommerce-page'); } /** @@ -425,7 +425,7 @@ class woocommerce { /** * Slugs **/ - $shop_page_id = get_option('woocommerce_shop_page_id'); + $shop_page_id = woocommerce_get_page_id('shop'); $base_slug = ($shop_page_id > 0 && get_page( $shop_page_id )) ? get_page_uri( $shop_page_id ) : 'shop'; @@ -842,15 +842,15 @@ class woocommerce { 'option_ajax_add_to_cart' => get_option('woocommerce_enable_ajax_add_to_cart') ); - $woocommerce_params['is_checkout'] = ( is_page(get_option('woocommerce_checkout_page_id')) ) ? 1 : 0; - $woocommerce_params['is_pay_page'] = ( is_page(get_option('woocommerce_pay_page_id')) ) ? 1 : 0; + $woocommerce_params['is_checkout'] = ( is_page(woocommerce_get_page_id('checkout')) ) ? 1 : 0; + $woocommerce_params['is_pay_page'] = ( is_page(woocommerce_get_page_id('pay')) ) ? 1 : 0; $woocommerce_params['is_cart'] = ( is_cart() ) ? 1 : 0; if (is_checkout() || is_cart()) : $woocommerce_params['locale'] = json_encode( $this->countries->get_country_locale() ); endif; - wp_localize_script( 'woocommerce', 'woocommerce_params', $woocommerce_params ); + wp_localize_script( 'woocommerce', 'woocommerce_params', apply_filters('woocommerce_params', $woocommerce_params) ); } /** Load Instances on demand **********************************************/ @@ -1014,7 +1014,7 @@ class woocommerce { // IIS fix if ($is_IIS) session_write_close(); - return $location; + return apply_filters('woocommerce_redirect', $location); } /** Attribute Helpers ****************************************************************/