WPML filters #244

This commit is contained in:
Mike Jolley 2012-01-06 17:14:31 +00:00
parent 13cd6952c7
commit aba310f321
31 changed files with 112 additions and 99 deletions

View File

@ -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;
}

View File

@ -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') );
}

View File

@ -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;

View File

@ -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))));
}
/**

View File

@ -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;

View File

@ -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'))))
);
}

View File

@ -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'))))
);
}

View File

@ -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'))))
);
}

View File

@ -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);
}
/**

View File

@ -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() ))))));
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -31,14 +31,14 @@ global $woocommerce;
<tr>
<td class="product-remove"><a href="<?php echo esc_url( $woocommerce->cart->get_remove_url($cart_item_key) ); ?>" class="remove" title="<?php _e('Remove this item', 'woocommerce'); ?>">&times;</a></td>
<td class="product-thumbnail">
<a href="<?php echo esc_url( get_permalink($values['product_id']) ); ?>">
<a href="<?php echo esc_url( get_permalink(apply_filters('woocommerce_in_cart_product_id', $values['product_id'])) ); ?>">
<?php
echo $_product->get_image();
?>
</a>
</td>
<td class="product-name">
<a href="<?php echo esc_url( get_permalink($values['product_id']) ); ?>"><?php echo $_product->get_title(); ?></a>
<a href="<?php echo esc_url( get_permalink(apply_filters('woocommerce_in_cart_product_id', $values['product_id'])) ); ?>"><?php echo $_product->get_title(); ?></a>
<?php
// Meta data
echo $woocommerce->cart->get_item_data( $values );

View File

@ -8,4 +8,4 @@
<?php do_action('woocommerce_cart_is_empty'); ?>
<p><a class="button" href="<?php echo get_permalink(get_option('woocommerce_shop_page_id')); ?>"><?php _e('&larr; Return To Shop', 'woocommerce') ?></a></p>
<p><a class="button" href="<?php echo get_permalink(woocommerce_get_page_id('shop')); ?>"><?php _e('&larr; Return To Shop', 'woocommerce') ?></a></p>

View File

@ -10,4 +10,4 @@ $info_message = apply_filters('woocommerce_checkout_login_message', __('Already
<p class="info"><?php echo $info_message; ?> <a href="#" class="showlogin"><?php _e('Click here to login', 'woocommerce'); ?></a></p>
<?php woocommerce_login_form( array( 'message' => __('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 &amp; Shipping section.', 'woocommerce'), 'redirect' => get_permalink(get_option('woocommerce_checkout_page_id')) ) ); ?>
<?php woocommerce_login_form( array( 'message' => __('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 &amp; Shipping section.', 'woocommerce'), 'redirect' => get_permalink(woocommerce_get_page_id('checkout')) ) ); ?>

View File

@ -234,9 +234,9 @@
<input type="submit" class="button alt" name="place_order" id="place_order" value="<?php echo apply_filters('woocommerce_order_button_text', __('Place order', 'woocommerce')); ?>" />
<?php if (get_option('woocommerce_terms_page_id')>0) : ?>
<?php if (woocommerce_get_page_id('terms')>0) : ?>
<p class="form-row terms">
<label for="terms" class="checkbox"><?php _e('I accept the', 'woocommerce'); ?> <a href="<?php echo esc_url( get_permalink(get_option('woocommerce_terms_page_id')) ); ?>" target="_blank"><?php _e('terms &amp; conditions', 'woocommerce'); ?></a></label>
<label for="terms" class="checkbox"><?php _e('I accept the', 'woocommerce'); ?> <a href="<?php echo esc_url( get_permalink(woocommerce_get_page_id('terms')) ); ?>" target="_blank"><?php _e('terms &amp; conditions', 'woocommerce'); ?></a></label>
<input type="checkbox" class="input-checkbox" name="terms" <?php if (isset($_POST['terms'])) echo 'checked="checked"'; ?> id="terms" />
</p>
<?php endif; ?>

View File

@ -23,7 +23,7 @@ global $woocommerce, $order;
<p>
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e('Pay', 'woocommerce') ?></a>
<?php if (is_user_logged_in()) : ?>
<a href="<?php echo esc_url( get_permalink(get_option('woocommerce_myaccount_page_id')) ); ?>" class="button pay"><?php _e('My Account', 'woocommerce'); ?></a>
<a href="<?php echo esc_url( get_permalink(woocommerce_get_page_id('myaccount')) ); ?>" class="button pay"><?php _e('My Account', 'woocommerce'); ?></a>
<?php endif; ?>
</p>

View File

@ -11,7 +11,7 @@
<li><?php echo sprintf(__('Password: %s', 'woocommerce'), $user_pass); ?></li>
</ul>
<p><?php echo sprintf(__("You can login to your account area here: %s.", 'woocommerce'), get_permalink(get_option('woocommerce_myaccount_page_id'))); ?></p>
<p><?php echo sprintf(__("You can login to your account area here: %s.", 'woocommerce'), get_permalink(woocommerce_get_page_id('myaccount'))); ?></p>
<div style="clear:both;"></div>

View File

@ -8,7 +8,7 @@ global $woocommerce;
<?php $woocommerce->show_messages(); ?>
<form action="<?php echo esc_url( get_permalink(get_option('woocommerce_change_password_page_id')) ); ?>" method="post">
<form action="<?php echo esc_url( get_permalink(woocommerce_get_page_id('change_password')) ); ?>" method="post">
<p class="form-row form-row-first">
<label for="password_1"><?php _e('New password', 'woocommerce'); ?> <span class="required">*</span></label>

View File

@ -8,7 +8,7 @@ global $woocommerce, $load_address, $address;
<?php $woocommerce->show_messages(); ?>
<form action="<?php echo esc_url( add_query_arg( 'address', $load_address, get_permalink( get_option( 'woocommerce_edit_address_page_id' ) ) ) ); ?>" method="post">
<form action="<?php echo esc_url( add_query_arg( 'address', $load_address, get_permalink( woocommerce_get_page_id('edit_address') ) ) ); ?>" method="post">
<h3><?php if ($load_address=='billing') _e('Billing Address', 'woocommerce'); else _e('Shipping Address', 'woocommerce'); ?></h3>

View File

@ -8,7 +8,7 @@ global $woocommerce, $current_user, $recent_orders;
<?php $woocommerce->show_messages(); ?>
<p><?php echo sprintf( __('Hello, <strong>%s</strong>. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">change your password</a>.', 'woocommerce'), $current_user->display_name, get_permalink(get_option('woocommerce_change_password_page_id'))); ?></p>
<p><?php echo sprintf( __('Hello, <strong>%s</strong>. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">change your password</a>.', 'woocommerce'), $current_user->display_name, get_permalink(woocommerce_get_page_id('change_password'))); ?></p>
<?php do_action('woocommerce_before_my_account'); ?>
@ -65,7 +65,7 @@ if ($customer_orders) :
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e('Pay', 'woocommerce'); ?></a>
<a href="<?php echo esc_url( $order->get_cancel_order_url() ); ?>" class="button cancel"><?php _e('Cancel', 'woocommerce'); ?></a>
<?php endif; ?>
<a href="<?php echo esc_url( add_query_arg('order', $order->id, get_permalink(get_option('woocommerce_view_order_page_id'))) ); ?>" class="button"><?php _e('View', 'woocommerce'); ?></a>
<a href="<?php echo esc_url( add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('view_order'))) ); ?>" class="button"><?php _e('View', 'woocommerce'); ?></a>
</td>
</tr><?php
endforeach;
@ -86,7 +86,7 @@ endif;
<header class="title">
<h3><?php _e('Billing Address', 'woocommerce'); ?></h3>
<a href="<?php echo esc_url( add_query_arg('address', 'billing', get_permalink(get_option('woocommerce_edit_address_page_id'))) ); ?>" class="edit"><?php _e('Edit', 'woocommerce'); ?></a>
<a href="<?php echo esc_url( add_query_arg('address', 'billing', get_permalink(woocommerce_get_page_id('edit_address'))) ); ?>" class="edit"><?php _e('Edit', 'woocommerce'); ?></a>
</header>
<address>
<?php
@ -114,7 +114,7 @@ endif;
<header class="title">
<h3><?php _e('Shipping Address', 'woocommerce'); ?></h3>
<a href="<?php echo esc_url( add_query_arg('address', 'shipping', get_permalink(get_option('woocommerce_edit_address_page_id'))) ); ?>" class="edit"><?php _e('Edit', 'woocommerce'); ?></a>
<a href="<?php echo esc_url( add_query_arg('address', 'shipping', get_permalink(woocommerce_get_page_id('edit_address'))) ); ?>" class="edit"><?php _e('Edit', 'woocommerce'); ?></a>
</header>
<address>
<?php

View File

@ -11,10 +11,10 @@ $home_link = home_url();
$prepend = '';
if ( get_option('woocommerce_prepend_shop_page_to_urls')=="yes" && get_option('woocommerce_shop_page_id') && get_option('page_on_front') !== get_option('woocommerce_shop_page_id') )
$prepend = $before . '<a href="' . get_permalink( get_option('woocommerce_shop_page_id') ) . '">' . get_the_title( get_option('woocommerce_shop_page_id') ) . '</a> ' . $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 . '<a href="' . get_permalink( woocommerce_get_page_id('shop') ) . '">' . get_the_title( woocommerce_get_page_id('shop') ) . '</a> ' . $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()) :

View File

@ -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");

View File

@ -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') );

View File

@ -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')) );
?>
<form method="post">
@ -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 = '';

View File

@ -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

View File

@ -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')) {

View File

@ -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 .= '<li><a href="'. wp_logout_url(home_url()) .'">'.__('Logout', 'woocommerce').'</a></li>';
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&hellip;', '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 :

View File

@ -31,7 +31,7 @@ if (!function_exists('woocommerce_archive_product_content')) {
function woocommerce_archive_product_content() { ?>
<?php
$shop_page_id = get_option('woocommerce_shop_page_id');
$shop_page_id = woocommerce_get_page_id('shop');
$shop_page = get_post($shop_page_id);
$shop_page_title = (get_option('woocommerce_shop_page_title')) ? get_option('woocommerce_shop_page_title') : $shop_page->post_title;
?>

View File

@ -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 ****************************************************************/