Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Julian Jöris 2012-05-18 09:10:45 +02:00
commit f186cc4a4f
25 changed files with 433 additions and 377 deletions

View File

@ -77,7 +77,7 @@ function woocommerce_custom_order_columns($column) {
$user = __('Guest', 'woocommerce');
endif;
echo '<a href="'.admin_url('post.php?post='.$post->ID.'&action=edit').'"><strong>'.sprintf( __('Order #%s', 'woocommerce'), $post->ID ).'</strong></a> ' . __('made by', 'woocommerce') . ' ' . $user;
echo '<a href="'.admin_url('post.php?post='.$post->ID.'&action=edit').'"><strong>'.sprintf( __('Order %s', 'woocommerce'), $order->get_order_number() ).'</strong></a> ' . __('made by', 'woocommerce') . ' ' . $user;
if ($order->billing_email) :
echo '<small class="meta">'.__('Email:', 'woocommerce') . ' ' . '<a href="' . esc_url( 'mailto:'.$order->billing_email ).'">'.esc_html( $order->billing_email ).'</a></small>';
@ -330,7 +330,7 @@ function woocommerce_shop_order_search_custom_fields( $wp ) {
if( !isset( $wp->query_vars['s'] ) || !$wp->query_vars['s'] ) return $wp;
if ($wp->query_vars['post_type']!='shop_order') return $wp;
$search_fields = array(
$search_fields = apply_filters( 'woocommerce_shop_order_search_fields', array(
'_order_key',
'_billing_first_name',
'_billing_last_name',
@ -344,7 +344,7 @@ function woocommerce_shop_order_search_custom_fields( $wp ) {
'_billing_email',
'_order_items',
'_billing_phone'
);
) );
// Query matching custom fields - this seems faster than meta_query
$post_ids = $wpdb->get_col($wpdb->prepare('SELECT post_id FROM '.$wpdb->postmeta.' WHERE meta_key IN ('.'"'.implode('","', $search_fields).'"'.') AND meta_value LIKE "%%%s%%"', esc_attr($_GET['s']) ));

View File

@ -52,7 +52,7 @@ function woocommerce_order_data_meta_box($post) {
<div class="order_data_left">
<h2><?php _e('Order Details', 'woocommerce'); ?> &mdash; #<?php echo $thepostid; ?></h2>
<h2><?php _e('Order Details', 'woocommerce'); ?> &mdash; <?php echo $order->get_order_number(); ?></h2>
<p class="form-field"><label for="order_status"><?php _e('Order status:', 'woocommerce') ?></label>
<select id="order_status" name="order_status" class="chosen_select">

View File

@ -10,6 +10,19 @@
function woocommerce_debug() {
global $woocommerce;
$tools = apply_filters( 'wc_debug_tools', array(
'clear_transients' => array(
'name' => __('Transients','woocommerce'),
'button' => __('Clear Transients','woocommerce'),
'desc' => __( 'This tool will clear the product/shop transients cache.', 'woocommerce' ),
),
'reset_roles' => array(
'name' => __('Capabilities','woocommerce'),
'button' => __('Reset Capabilities','woocommerce'),
'desc' => __( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce' ),
),
) );
?>
<div class="wrap woocommerce">
<div class="icon32 icon32-woocommerce-status" id="icon-woocommerce"><br /></div>
@ -17,6 +30,7 @@ function woocommerce_debug() {
<?php
if ( ! empty( $_GET['action'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'debug_action' ) ) {
switch ( $_GET['action'] ) {
case "clear_transients" :
$woocommerce->clear_product_transients();
@ -37,6 +51,20 @@ function woocommerce_debug() {
echo '<div class="updated"><p>' . __('Roles successfully reset', 'woocommerce') . '</p></div>';
break;
default:
$action = esc_attr( $_GET['action'] );
if( isset( $tools[ $action ]['callback'] ) ) {
$callback = $tools[ $action ]['callback'];
$return = call_user_func( $callback );
if( $return === false ) {
if( is_array( $callback ) ) {
echo '<div class="error"><p>' . sprintf( __('There was an error calling %s::%s', 'woocommerce'), get_class( $callback[0] ), $callback[1] ) . '</p></div>';
} else {
echo '<div class="error"><p>' . sprintf( __('There was an error calling %s', 'woocommerce'), $callback ) . '</p></div>';
}
}
}
}
}
?>
@ -51,7 +79,7 @@ function woocommerce_debug() {
</thead>
<tbody>
<tr class="alternate">
<tr>
<td><?php _e('WooCommerce version','woocommerce')?></td>
<td><?php echo $woocommerce->version; ?></td>
</tr>
@ -59,7 +87,7 @@ function woocommerce_debug() {
<td><?php _e('WordPress version','woocommerce')?></td>
<td><?php if ( is_multisite() ) echo 'WPMU'; else echo 'WP'; ?> <?php echo bloginfo('version'); ?></td>
</tr>
<tr class="alternate">
<tr>
<td><?php _e('Installed plugins','woocommerce')?></td>
<td><?php
$active_plugins = (array) get_option( 'active_plugins', array() );
@ -97,7 +125,7 @@ function woocommerce_debug() {
</thead>
<tbody>
<tr class="alternate">
<tr>
<td><?php _e('Home URL','woocommerce')?></td>
<td><?php echo home_url(); ?></td>
</tr>
@ -105,7 +133,7 @@ function woocommerce_debug() {
<td><?php _e('Site URL','woocommerce')?></td>
<td><?php echo site_url(); ?></td>
</tr>
<tr class="alternate">
<tr>
<td><?php _e('Force SSL','woocommerce')?></td>
<td><?php echo ucwords(get_option('woocommerce_force_ssl_checkout')); ?></td>
</tr>
@ -162,7 +190,7 @@ function woocommerce_debug() {
foreach ( $check_pages as $page_name => $values ) {
if ( $alt == 1 ) echo '<tr class="alternate">'; else echo '<tr>';
if ( $alt == 1 ) echo '<tr>'; else echo '<tr>';
echo '<td>' . $page_name . '</td><td>';
@ -206,7 +234,7 @@ function woocommerce_debug() {
</thead>
<tbody>
<tr class="alternate">
<tr>
<td><?php _e('PHP Version','woocommerce')?></td>
<td><?php
if ( function_exists( 'phpversion' ) ) echo phpversion();
@ -218,7 +246,7 @@ function woocommerce_debug() {
echo $_SERVER['SERVER_SOFTWARE'];
?></td>
</tr>
<tr class="alternate">
<tr>
<td><?php _e('WP Max Upload Size','woocommerce'); ?></td>
<td><?php
echo wp_convert_bytes_to_hr( wp_max_upload_size() );
@ -231,7 +259,7 @@ function woocommerce_debug() {
echo wp_convert_bytes_to_hr( woocommerce_let_to_num( ini_get('upload_max_filesize') ) );
?></td>
</tr>
<tr class="alternate">
<tr>
<td><?php _e('Server post_max_size','woocommerce')?></td>
<td><?php
if(function_exists('phpversion'))
@ -244,7 +272,7 @@ function woocommerce_debug() {
echo wp_convert_bytes_to_hr( woocommerce_let_to_num( WP_MEMORY_LIMIT ) );
?></td>
</tr>
<tr class="alternate">
<tr>
<td><?php _e('WP Debug Mode','woocommerce')?></td>
<td><?php if ( defined('WP_DEBUG') && WP_DEBUG ) echo '<mark class="yes">' . __('Yes', 'woocommerce') . '</mark>'; else echo '<mark class="no">' . __('No', 'woocommerce') . '</mark>'; ?></td>
</tr>
@ -266,7 +294,7 @@ function woocommerce_debug() {
</thead>
<tbody>
<tr class="alternate">
<tr>
<td><?php _e('Session save path','woocommerce')?></td>
<td><?php
$save_path = session_save_path();
@ -288,31 +316,49 @@ function woocommerce_debug() {
</tr>
</thead>
<tbody>
<tr class="alternate">
<td><?php _e('fsockopen/Curl','woocommerce')?></td>
<td><?php
if( function_exists('fsockopen') || function_exists('curl_init') )
echo '<mark class="yes">' . __('Your server has fsockopen or Curl enabled.', 'woocommerce'). '</mark>';
else
echo '<mark class="error">' . __('Your server does not have fsockopen or Curl enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'woocommerce'). '</mark>'; ?></td>
</tr>
<tr>
<td><?php _e('WP Remote Post Check','woocommerce')?></td>
<td><?php
<?php
$posting = array();
// fsockopen/Curl
$posting['fsockopen_curl']['name'] = __('fsockopen/Curl','woocommerce');
if( function_exists('fsockopen') || function_exists('curl_init') ) {
$posting['fsockopen_curl']['note'] = __('Your server has fsockopen or Curl enabled.', 'woocommerce');
$posting['fsockopen_curl']['success'] = true;
} else {
$posting['fsockopen_curl']['note'] = __('Your server does not have fsockopen or Curl enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'woocommerce'). '</mark>';
$posting['fsockopen_curl']['success'] = false;
}
// WP Remote Post Check
$posting['wp_remote_post']['name'] = __('WP Remote Post Check','woocommerce');
$params = array(
'sslverify' => false,
'timeout' => 30,
'user-agent' => 'WooCommerce/'.$woocommerce->version
);
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
$posting['wp_remote_post']['note'] = __('wp_remote_post() was successful - PayPal IPN is working.', 'woocommerce');
$posting['wp_remote_post']['success'] = true;
} else {
$posting['wp_remote_post']['note'] = __('wp_remote_post() failed. PayPal IPN won\'t work with your server. Contact your hosting provider. Error: ', 'woocommerce') . $response->get_error_message();
$posting['wp_remote_post']['success'] = false;
}
if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 )
echo '<mark class="yes">' . __('wp_remote_post() was successful - PayPal IPN is working.', 'woocommerce'). '</mark>';
else
echo '<mark class="error">' . __('wp_remote_post() failed. PayPal IPN won\'t work with your server. Contact your hosting provider. Error: ', 'woocommerce') . $response->get_error_message() . '</mark>';
?></td>
$posting = apply_filters( 'wc_debug_posting', $posting );
?>
<tbody>
<?php foreach($posting as $post) { $mark = ( isset( $post['success'] ) && $post['success'] == true ) ? 'yes' : 'error'; ?>
<tr>
<td><?php echo $post['name']; ?></td>
<td>
<mark class="<?php echo $mark; ?>">
<?php echo $post['note']; ?>
</mark>
</td>
</tr>
<?php } ?>
</tbody>
<thead class="tools">
@ -322,24 +368,17 @@ function woocommerce_debug() {
</thead>
<tbody class="tools">
<tr class="alternate">
<td><?php _e('Transients','woocommerce')?></td>
<td>
<p>
<a href="<?php echo wp_nonce_url( admin_url('tools.php?page=woocommerce_debug&action=clear_transients'), 'debug_action' ); ?>" class="button"><?php _e('Clear Transients','woocommerce')?></a>
<span class="description"><?php _e( 'This tool will clear the product/shop transients cache.', 'woocommerce' ); ?></span>
</p>
</td>
</tr>
<?php foreach($tools as $action => $tool) { ?>
<tr>
<td><?php _e('Capabilities','woocommerce')?></td>
<td><?php echo $tool['name']; ?></td>
<td>
<p>
<a href="<?php echo wp_nonce_url( admin_url('tools.php?page=woocommerce_debug&action=reset_roles'), 'debug_action' ); ?>" class="button"><?php _e('Reset Capabilities','woocommerce')?></a>
<span class="description"><?php _e( 'This tool will reset the admin, customer and shop_manager roles to default. Use this if your users cannot access all of the WooCommerce admin pages.', 'woocommerce' ); ?></span>
<a href="<?php echo wp_nonce_url( admin_url('tools.php?page=woocommerce_debug&action=' . $action ), 'debug_action' ); ?>" class="button"><?php echo $tool['button']; ?></a>
<span class="description"><?php echo $tool['desc']; ?></span>
</p>
</td>
</tr>
<?php } ?>
</tbody>
</table>

View File

@ -18,7 +18,6 @@ function do_install_woocommerce() {
// Do install
woocommerce_default_options();
woocommerce_tables_install();
woocommerce_install_custom_fields();
// Register post types
$woocommerce->init_taxonomy();
@ -29,21 +28,23 @@ function do_install_woocommerce() {
// Install folder for uploading files and prevent hotlinking
$upload_dir = wp_upload_dir();
$downloads_url = $upload_dir['basedir'] . '/woocommerce_uploads';
if ( wp_mkdir_p($downloads_url) && !file_exists($downloads_url.'/.htaccess') ) :
if ($file_handle = @fopen( $downloads_url . '/.htaccess', 'w' )) :
if ( wp_mkdir_p( $downloads_url ) && ! file_exists( $downloads_url.'/.htaccess' ) ) {
if ( $file_handle = @fopen( $downloads_url . '/.htaccess', 'w' ) ) {
fwrite($file_handle, 'deny from all');
fclose($file_handle);
endif;
endif;
}
}
// Install folder for logs
$logs_url = WP_PLUGIN_DIR . "/" . plugin_basename( dirname(dirname(__FILE__))) . '/logs';
if ( wp_mkdir_p($logs_url) && !file_exists($logs_url.'/.htaccess') ) :
if ($file_handle = @fopen( $logs_url . '/.htaccess', 'w' )) :
if ( wp_mkdir_p( $logs_url ) && ! file_exists( $logs_url . '/.htaccess' ) ) {
if ( $file_handle = @fopen( $logs_url . '/.htaccess', 'w' ) ) {
fwrite($file_handle, 'deny from all');
fclose($file_handle);
endif;
endif;
}
}
// Clear transient cache
$woocommerce->clear_product_transients();
@ -79,24 +80,6 @@ function do_install_woocommerce() {
update_option( "woocommerce_db_version", $woocommerce->version );
}
/**
* Add required post meta so queries work
*/
function woocommerce_install_custom_fields() {
// Attachment exclusion
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'fields' => 'ids'
);
$attachments = get_posts($args);
if ($attachments) foreach ($attachments as $id) :
update_post_meta($id, '_woocommerce_exclude_image', 0);
endforeach;
}
/**
* Default options
*
@ -108,28 +91,28 @@ function woocommerce_default_options() {
// Include settings so that we can run through defaults
include_once( 'woocommerce-admin-settings.php' );
foreach ($woocommerce_settings as $section) :
foreach ($woocommerce_settings as $section) {
foreach ($section as $value) :
foreach ( $section as $value ) {
if (isset($value['std']) && isset($value['id'])) :
if ( isset( $value['std'] ) && isset( $value['id'] ) ) {
if ($value['type']=='image_width') :
if ( $value['type'] == 'image_width' ) {
add_option($value['id'].'_width', $value['std']);
add_option($value['id'].'_height', $value['std']);
else :
} else {
add_option($value['id'], $value['std']);
endif;
}
endif;
}
endforeach;
}
endforeach;
}
add_option( 'woocommerce_shop_slug', 'shop' );
}
@ -142,17 +125,13 @@ function woocommerce_create_page( $slug, $option, $page_title = '', $page_conten
$option_value = get_option($option);
if ($option_value>0) :
if (get_post( $option_value )) :
// Page exists
if ( $option_value > 0 && get_post( $option_value ) )
return;
endif;
endif;
$page_found = $wpdb->get_var("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = '$slug' LIMIT 1;");
if ( $page_found ) :
// Page exists
if (!$option_value) update_option($option, $page_found);
if ( ! $option_value )
update_option( $option, $page_found );
return;
endif;
@ -277,13 +256,14 @@ CREATE TABLE ". $wpdb->prefix . "woocommerce_termmeta (
// Update woocommerce_downloadable_product_permissions table to include order ID's as well as keys
$results = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."woocommerce_downloadable_product_permissions WHERE order_id = 0;" );
if ($results) foreach ($results as $result) :
if ( $results ) foreach ( $results as $result ) {
if (!$result->order_key) continue;
if ( ! $result->order_key )
continue;
$order_id = $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM ".$wpdb->postmeta." WHERE meta_key = '_order_key' AND meta_value = '%s' LIMIT 1;", $result->order_key) );
$order_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_order_key' AND meta_value = '%s' LIMIT 1;", $result->order_key ) );
if ($order_id) :
if ( $order_id ) {
$wpdb->update( $wpdb->prefix . "woocommerce_downloadable_product_permissions", array(
'order_id' => $order_id,
@ -292,24 +272,22 @@ CREATE TABLE ". $wpdb->prefix . "woocommerce_termmeta (
'order_key' => $result->order_key
), array( '%s' ), array( '%s', '%s' ) );
endif;
}
endforeach;
}
// Upgrade old meta keys for product data
$meta = array('sku', 'downloadable', 'virtual', 'price', 'visibility', 'stock', 'stock_status', 'backorders', 'manage_stock', 'sale_price', 'regular_price', 'weight', 'length', 'width', 'height', 'tax_status', 'tax_class', 'upsell_ids', 'crosssell_ids', 'sale_price_dates_from', 'sale_price_dates_to', 'min_variation_price', 'max_variation_price', 'featured', 'product_attributes', 'file_path', 'download_limit', 'product_url', 'min_variation_price', 'max_variation_price');
$wpdb->query("
UPDATE $wpdb->postmeta
LEFT JOIN $wpdb->posts ON ( $wpdb->postmeta.post_id = $wpdb->posts.ID )
UPDATE {$wpdb->postmeta}
LEFT JOIN {$wpdb->posts} ON ( {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID )
SET meta_key = CONCAT( '_', meta_key )
WHERE meta_key IN ( '" . implode( "', '", $meta ) . "' )
AND $wpdb->posts.post_type IN ('product', 'product_variation')
AND {$wpdb->posts}.post_type IN ('product', 'product_variation')
");
}
$wpdb->show_errors();
}
/**
@ -350,23 +328,23 @@ function woocommerce_default_taxonomies() {
// Upgrade from old downloadable/virtual product types
$downloadable_type = get_term_by( 'slug', 'downloadable', 'product_type' );
if ($downloadable_type) :
if ( $downloadable_type ) {
$products = get_objects_in_term( $downloadable_type->term_id, 'product_type' );
foreach ($products as $product) :
foreach ( $products as $product ) {
update_post_meta( $product, '_downloadable', 'yes' );
update_post_meta( $product, '_virtual', 'yes' );
wp_set_object_terms( $product, 'simple', 'product_type');
endforeach;
endif;
}
}
$virtual_type = get_term_by( 'slug', 'virtual', 'product_type' );
if ($virtual_type) :
if ( $virtual_type ) {
$products = get_objects_in_term( $virtual_type->term_id, 'product_type' );
foreach ($products as $product) :
foreach ( $products as $product ) {
update_post_meta( $product, '_downloadable', 'no' );
update_post_meta( $product, '_virtual', 'yes' );
wp_set_object_terms( $product, 'simple', 'product_type');
endforeach;
endif;
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -160,12 +160,6 @@ input.wc-error {
background-color: #FFBABA;
}
span.mce_woocommerce_shortcodes_button {
background-image: url(../images/icons/wc_icon.png) !important;
background-repeat: no-repeat !important;
background-position: center !important;
}
/* Status page */
table.wc_status_table {
th {

View File

@ -1,12 +1,47 @@
#adminmenu #menu-posts-product div.wp-menu-image{background:transparent url(../images/icons/menu_icons.png) no-repeat -32px -32px;}
#adminmenu #menu-posts-product.wp-menu-open div.wp-menu-image,#adminmenu #menu-posts-product:hover div.wp-menu-image{background-position:-32px 0px;}
#adminmenu #menu-posts-product img{display:none;}
#adminmenu #menu-posts-shop_order div.wp-menu-image{background:transparent url(../images/icons/menu_icons.png) no-repeat -64px -32px;}
#adminmenu #menu-posts-shop_order.wp-menu-open div.wp-menu-image,#adminmenu #menu-posts-shop_order:hover div.wp-menu-image{background-position:-64px 0px;}
#adminmenu #menu-posts-shop_order img{display:none;}
#adminmenu #menu-posts-shop_coupon div.wp-menu-image{background:transparent url(../images/icons/menu_icons.png) no-repeat -96px -32px;}
#adminmenu #menu-posts-shop_coupon.wp-menu-open div.wp-menu-image,#adminmenu #menu-posts-shop_coupon:hover div.wp-menu-image{background-position:-96px 0px;}
#adminmenu #menu-posts-shop_coupon img{display:none;}
#adminmenu #toplevel_page_woocommerce div.wp-menu-image{background:transparent url(../images/icons/menu_icons.png) no-repeat 0px -32px;}
#adminmenu #toplevel_page_woocommerce.wp-menu-open div.wp-menu-image,#adminmenu #toplevel_page_woocommerce:hover div.wp-menu-image{background-position:0px 0px;}
#adminmenu #toplevel_page_woocommerce img{display:none;}
/* Menu */
#adminmenu #menu-posts-product div.wp-menu-image {
background: transparent url(../images/icons/menu_icons.png) no-repeat -32px -32px;
}
#adminmenu #menu-posts-product.wp-menu-open div.wp-menu-image,
#adminmenu #menu-posts-product:hover div.wp-menu-image {
background-position: -32px 0px;
}
#adminmenu #menu-posts-product img {
display: none;
}
#adminmenu #menu-posts-shop_order div.wp-menu-image {
background: transparent url(../images/icons/menu_icons.png) no-repeat -64px -32px;
}
#adminmenu #menu-posts-shop_order.wp-menu-open div.wp-menu-image,
#adminmenu #menu-posts-shop_order:hover div.wp-menu-image {
background-position: -64px 0px;
}
#adminmenu #menu-posts-shop_order img {
display: none;
}
#adminmenu #menu-posts-shop_coupon div.wp-menu-image {
background: transparent url(../images/icons/menu_icons.png) no-repeat -96px -32px;
}
#adminmenu #menu-posts-shop_coupon.wp-menu-open div.wp-menu-image,
#adminmenu #menu-posts-shop_coupon:hover div.wp-menu-image {
background-position: -96px 0px;
}
#adminmenu #menu-posts-shop_coupon img {
display: none;
}
#adminmenu #toplevel_page_woocommerce div.wp-menu-image {
background: transparent url(../images/icons/menu_icons.png) no-repeat 0px -32px;
}
#adminmenu #toplevel_page_woocommerce.wp-menu-open div.wp-menu-image,
#adminmenu #toplevel_page_woocommerce:hover div.wp-menu-image {
background-position: 0px 0px;
}
#adminmenu #toplevel_page_woocommerce img {
display: none;
}
/* Editor button */
span.mce_woocommerce_shortcodes_button {
background-image: url(../images/icons/wc_icon.png) !important;
background-repeat: no-repeat !important;
background-position: center !important;
}

View File

@ -45,3 +45,10 @@
}
}
}
/* Editor button */
span.mce_woocommerce_shortcodes_button {
background-image: url(../images/icons/wc_icon.png) !important;
background-repeat: no-repeat !important;
background-position: center !important;
}

View File

@ -262,11 +262,11 @@ jQuery(document).ready(function($) {
});
/* Tabs */
$('div.woocommerce_tabs .panel').hide();
$('div.woocommerce_tabs ul.tabs li a').click(function(){
$('.woocommerce_tabs .panel').hide();
$('.woocommerce_tabs ul.tabs li a').click(function(){
var $tab = $(this);
var $tabs_wrapper = $tab.closest('div.woocommerce_tabs');
var $tabs_wrapper = $tab.closest('.woocommerce_tabs');
$('ul.tabs li', $tabs_wrapper).removeClass('active');
$('div.panel', $tabs_wrapper).hide();
@ -275,7 +275,7 @@ jQuery(document).ready(function($) {
return false;
});
$('div.woocommerce_tabs').each(function() {
$('.woocommerce_tabs').each(function() {
var hash = window.location.hash;
if (hash.toLowerCase().indexOf("comment-") >= 0) {
$('ul.tabs li.reviews_tab a', $(this)).click();
@ -425,8 +425,6 @@ jQuery(document).ready(function($) {
$('.single_variation_wrap').find('input[name=quantity]').removeAttr('data-max');
}
alert(variation.is_sold_individually);
if ( variation.is_sold_individually == 'yes' ) {
$('.single_variation_wrap').find('input[name=quantity]').val('1');
$('.single_variation_wrap').find('.quantity').hide();

File diff suppressed because one or more lines are too long

View File

@ -121,7 +121,7 @@ class WC_Email {
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$subject = apply_filters( 'woocommerce_email_subject_new_order', sprintf( __( '[%s] New Customer Order (# %s)', 'woocommerce' ), $blogname, $order_id ), $order );
$subject = apply_filters( 'woocommerce_email_subject_new_order', sprintf( __( '[%s] New Customer Order (%s)', 'woocommerce' ), $blogname, $order->get_order_number() ), $order );
// Buffer
ob_start();

View File

@ -404,6 +404,9 @@ class WC_Product {
* @return int
*/
function get_stock_quantity() {
if ( get_option( 'woocommerce_manage_stock' ) == 'no' )
return '';
return (int) $this->stock;
}
@ -692,7 +695,7 @@ class WC_Product {
endif;
endif;
return $price;
return apply_filters('woocommerce_get_price_html', $price, $this);
}
/** Functions for getting parts of a price, in html, used by get_price_html */

View File

@ -54,14 +54,10 @@ class WC_Query {
if (
( ! $query ) // Abort if theres no query
||
( empty( $this->post__in ) ) // Abort if we're not filtering posts
||
( ! empty( $query->wc_query ) ) // Abort if this query is already done
||
( empty( $query->query_vars["s"] ) ) // Abort if this isn't a search query
||
( ! $query->is_post_type_archive( 'product' ) && ! $query->is_tax( array_merge( array('product_cat', 'product_tag'), $woocommerce->get_attribute_taxonomy_names() ) ) ) // Abort if we're not on a post type archive/prduct taxonomy
|| ( empty( $this->post__in ) ) // Abort if we're not filtering posts
|| ( ! empty( $query->wc_query ) ) // Abort if this query is already done
|| ( empty( $query->query_vars["s"] ) ) // Abort if this isn't a search query
|| ( ! $query->is_post_type_archive( 'product' ) && ! $query->is_tax( array_merge( array('product_cat', 'product_tag'), $woocommerce->get_attribute_taxonomy_names() ) ) ) // Abort if we're not on a post type archive/prduct taxonomy
)
return $posts;
@ -110,13 +106,15 @@ class WC_Query {
// Ordering query vars
$q->set( 'orderby', $ordering['orderby'] );
$q->set( 'order', $ordering['order'] );
if (isset($ordering['meta_key'])) $q->set( 'meta_key', $ordering['meta_key'] );
if ( isset( $ordering['meta_key'] ) )
$q->set( 'meta_key', $ordering['meta_key'] );
// Query vars that affect posts shown
if (!$q->is_tax( 'product_cat' ) && !$q->is_tax( 'product_tag' )) $q->set( 'post_type', 'product' );
if ( ! $q->is_tax( 'product_cat' ) && ! $q->is_tax( 'product_tag' ) )
$q->set( 'post_type', 'product' );
$q->set( 'meta_query', $meta_query );
$q->set( 'post__in', $post__in );
$q->set( 'posts_per_page', ($q->get('posts_per_page')) ? $q->get('posts_per_page') : apply_filters('loop_shop_per_page', get_option('posts_per_page') ) );
$q->set( 'posts_per_page', $q->get('posts_per_page') ? $q->get('posts_per_page') : apply_filters('loop_shop_per_page', get_option('posts_per_page') ) );
// Set a special variable
$q->set( 'wc_query', true );
@ -256,32 +254,4 @@ class WC_Query {
return $meta_query;
}
/**
* Get a list of product id's which should be hidden from the frontend; useful for custom queries and loops. Makes use of transients.
*/
function get_hidden_product_ids() {
$transient_name = (is_search()) ? 'wc_hidden_product_ids_search' : 'wc_hidden_product_ids';
if ( false === ( $hidden_product_ids = get_transient( $transient_name ) ) ) {
$meta_query = array();
$meta_query[] = $this->visibility_meta_query( 'NOT IN' );
$meta_query[] = $this->stock_status_meta_query( 'outofstock' );
$hidden_product_ids = get_posts(array(
'post_type' => 'product',
'numberposts' => -1,
'post_status' => 'publish',
'meta_query' => $meta_query,
'fields' => 'ids',
'no_found_rows' => true
));
set_transient( $transient_name, $hidden_product_ids );
}
return (array) $hidden_product_ids;
}
}

View File

@ -68,7 +68,7 @@ class WC_Payment_Gateways {
endforeach;
return $_available_gateways;
return apply_filters( 'woocommerce_available_payment_gateways', $_available_gateways );
}
function process_admin_options() {

View File

@ -172,9 +172,11 @@ class WC_Google_Analytics extends WC_Integration {
} else {
$out = array();
$categories = get_the_terms($_product->id, 'product_cat');
if ( $categories ) {
foreach ( $categories as $category ){
$out[] = $category->name;
}
}
echo join( "/", $out);
}
?>', // category or variation

View File

@ -20,7 +20,7 @@ class WC_ShareThis extends WC_Integration {
$this->default_code = '<div class="social">
<iframe src="https://www.facebook.com/plugins/like.php?href={permalink}&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
<span class="st_twitter"></span><span class="st_email"></span><span class="st_sharethis"></span><span class="st_plusone_button"></span>
<span class="st_twitter"></span><span class="st_email"></span><span class="st_sharethis" st_image="{image}"></span><span class="st_plusone_button"></span>
</div>';
// Load the form fields.
@ -33,7 +33,7 @@ class WC_ShareThis extends WC_Integration {
$this->publisher_id = $this->settings['publisher_id'];
$this->sharethis_code = $this->settings['sharethis_code'];
if ( ! $this->sharethis_code ) $this->sharethis_code = $this->default_code;
if ( ! $this->sharethis_code ) $this->settings['sharethis_code'] = $this->sharethis_code = $this->default_code;
// Actions
add_action( 'woocommerce_update_options_integration_sharethis', array( &$this, 'process_admin_options') );
@ -74,9 +74,14 @@ class WC_ShareThis extends WC_Integration {
if ( $this->publisher_id ) {
$thumbnail = ( $thumbnail_id = get_post_thumbnail_id( $post->ID ) ) ? current(wp_get_attachment_image_src( $thumbnail_id, 'large' )) : '';
$sharethis = ( is_ssl() ) ? 'https://ws.sharethis.com/button/buttons.js' : 'http://w.sharethis.com/button/buttons.js';
echo str_replace( '{permalink}', urlencode(get_permalink($post->ID)), $this->sharethis_code );
$sharethis_code = str_replace( '{permalink}', urlencode( get_permalink( $post->ID ) ), $this->sharethis_code );
if ( isset( $thumbnail ) ) $sharethis_code = str_replace( '{image}', urlencode( $thumbnail ), $sharethis_code );
echo $sharethis_code;
echo '<script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="' . $sharethis . '"></script>';
echo '<script type="text/javascript">stLight.options({publisher:"' . $this->publisher_id . '"});</script>';

View File

@ -10,7 +10,6 @@
* @author WooThemes
*/
class WC_Flat_Rate extends WC_Shipping_Method {
function __construct() {
$this->id = 'flat_rate';
$this->method_title = __( 'Flat rate', 'woocommerce' );
@ -26,7 +25,6 @@ class WC_Flat_Rate extends WC_Shipping_Method {
}
function init() {
// Load the form fields.
$this->init_form_fields();
@ -41,6 +39,7 @@ class WC_Flat_Rate extends WC_Shipping_Method {
$this->type = $this->settings['type'];
$this->tax_status = $this->settings['tax_status'];
$this->cost = $this->settings['cost'];
$this->cost_per_order = isset( $this->settings['cost_per_order'] ) ? $this->settings['cost_per_order'] : '';
$this->fee = $this->settings['fee'];
$this->minimum_fee = isset( $this->settings['minimum_fee'] ) ? $this->settings['minimum_fee'] : '';
$this->options = isset( $this->settings['options'] ) ? $this->settings['options'] : '';
@ -63,13 +62,19 @@ class WC_Flat_Rate extends WC_Shipping_Method {
'title' => __( 'Enable/Disable', 'woocommerce' ),
'type' => 'checkbox',
'label' => __( 'Enable this shipping method', 'woocommerce' ),
'default' => 'no'
'default' => 'no',
),
'title' => array(
'title' => __( 'Method Title', 'woocommerce' ),
'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Flat Rate', 'woocommerce' )
'default' => __( 'Flat Rate', 'woocommerce' ),
),
'cost_per_order' => array(
'title' => __( 'Cost per order', 'woocommerce' ),
'type' => 'text',
'description' => __( 'Enter a cost per order, e.g. 5.00. Leave blank to disable.', 'woocommerce' ),
'default' => '',
),
'availability' => array(
'title' => __( 'Method availability', 'woocommerce' ),
@ -78,8 +83,8 @@ class WC_Flat_Rate extends WC_Shipping_Method {
'class' => 'availability',
'options' => array(
'all' => __( 'All allowed countries', 'woocommerce' ),
'specific' => __('Specific Countries', 'woocommerce')
)
'specific' => __( 'Specific Countries', 'woocommerce' ),
),
),
'countries' => array(
'title' => __( 'Specific Countries', 'woocommerce' ),
@ -87,7 +92,7 @@ class WC_Flat_Rate extends WC_Shipping_Method {
'class' => 'chosen_select',
'css' => 'width: 450px;',
'default' => '',
'options' => $woocommerce->countries->countries
'options' => $woocommerce->countries->countries,
),
'type' => array(
'title' => __( 'Calculation Type', 'woocommerce' ),
@ -97,8 +102,8 @@ class WC_Flat_Rate extends WC_Shipping_Method {
'options' => array(
'order' => __( 'Per Order - charge shipping for the entire order as a whole', 'woocommerce' ),
'item' => __( 'Per Item - charge shipping for each item individually', 'woocommerce' ),
'class' => __('Per Class - charge shipping for each shipping class in an order', 'woocommerce')
)
'class' => __( 'Per Class - charge shipping for each shipping class in an order', 'woocommerce' ),
),
),
'tax_status' => array(
'title' => __( 'Tax Status', 'woocommerce' ),
@ -107,32 +112,32 @@ class WC_Flat_Rate extends WC_Shipping_Method {
'default' => 'taxable',
'options' => array(
'taxable' => __( 'Taxable', 'woocommerce' ),
'none' => __('None', 'woocommerce')
)
'none' => __( 'None', 'woocommerce' ),
),
),
'cost' => array(
'title' => __( 'Default Cost', 'woocommerce' ),
'type' => 'text',
'description' => __( 'Cost excluding tax. Enter an amount, e.g. 2.50.', 'woocommerce' ),
'default' => ''
'default' => '',
),
'fee' => array(
'title' => __( 'Default Handling Fee', 'woocommerce' ),
'type' => 'text',
'description' => __( 'Fee excluding tax. Enter an amount, e.g. 2.50, or a percentage, e.g. 5%. Leave blank to disable.', 'woocommerce' ),
'default' => ''
'default' => '',
),
'minimum_fee' => array(
'title' => __( 'Minimum Fee', 'woocommerce' ),
'type' => 'text',
'description' => __( 'Enter a minimum fee amount. Fee\'s less than this will be increased. Leave blank to disable.', 'woocommerce' ),
'default' => ''
'default' => '',
),
'options' => array(
'title' => __( 'Shipping Options', 'woocommerce' ),
'type' => 'textarea',
'description' => __( 'Optional extra shipping options with additional costs (one per line). Example: <code>Option Name|Cost|Per-order (yes or no)</code>. Example: <code>Priority Mail|6.95|yes</code>. If per-order is set to no, it will use the "Calculation Type" setting.', 'woocommerce' ),
'default' => ''
'default' => '',
),
);
@ -142,36 +147,33 @@ class WC_Flat_Rate extends WC_Shipping_Method {
global $woocommerce;
$this->rates = array();
$cost_per_order = ( isset( $this->cost_per_order ) && ! empty( $this->cost_per_order ) ) ? $this->cost_per_order : 0;
if ( $this->type == 'order' ) {
$shipping_total = $this->order_shipping( $package );
$rate = array(
'id' => $this->id,
'label' => $this->title,
'cost' => $shipping_total
'cost' => $shipping_total + $cost_per_order,
);
} elseif ( $this->type == 'class' ) {
$shipping_total = $this->class_shipping( $package );
$rate = array(
'id' => $this->id,
'label' => $this->title,
'cost' => $shipping_total
'cost' => $shipping_total + $cost_per_order,
);
} elseif ( $this->type == 'item' ) {
$costs = $this->item_shipping( $package );
$costs['order'] = $cost_per_order;
$rate = array(
'id' => $this->id,
'label' => $this->title,
'cost' => $costs,
'calc_tax' => 'per_item'
'calc_tax' => 'per_item',
);
}
@ -194,11 +196,9 @@ class WC_Flat_Rate extends WC_Shipping_Method {
$this_cost = $this_option[1];
if ( is_array( $extra_rate['cost'] ) ) {
if ( $per_order_cost ) {
$extra_rate['cost']['order'] = $this_cost;
} else {
$total_quantity = 0;
// Shipping per item
@ -209,9 +209,7 @@ class WC_Flat_Rate extends WC_Shipping_Method {
// Per-product shipping
$extra_rate['cost']['order'] = $this_cost * $total_quantity;
}
} else {
// If using shipping per class, multiple the cost by the classes we found
if ( ! $per_order_cost && $this->type == 'class' ) {
$this_cost = $this_cost * $found_shipping_classes;
@ -221,7 +219,6 @@ class WC_Flat_Rate extends WC_Shipping_Method {
}
$this->add_rate( $extra_rate );
}
}
@ -276,36 +273,34 @@ class WC_Flat_Rate extends WC_Shipping_Method {
$fee = null;
if ( sizeof( $this->flat_rates ) > 0 ) {
$found_shipping_classes = array();
// Find shipping classes for products in the cart. Store prices too, so we can calc a fee for the class.
if ( sizeof( $package['contents'] ) > 0 ) {
foreach ( $package['contents'] as $item_id => $values ) {
if ( $values['data']->needs_shipping() ) :
if ( $values['data']->needs_shipping() ) {
if ( isset( $found_shipping_classes[ $values['data']->get_shipping_class() ] ) ) {
$found_shipping_classes[ $values['data']->get_shipping_class() ] = ( $values['data']->get_price() * $values['quantity'] ) + $found_shipping_classes[ $values['data']->get_shipping_class() ];
} else {
$found_shipping_classes[ $values['data']->get_shipping_class() ] = ( $values['data']->get_price() * $values['quantity'] );
}
endif;
}
}
}
$found_shipping_classes = array_unique( $found_shipping_classes );
// For each found class, add up the costs and fees
foreach ($found_shipping_classes as $shipping_class => $class_price) :
if (isset($this->flat_rates[$shipping_class])) :
foreach ( $found_shipping_classes as $shipping_class => $class_price ) {
if ( isset( $this->flat_rates[ $shipping_class ] ) ) {
$cost += $this->flat_rates[ $shipping_class ]['cost'];
$fee += $this->get_fee( $this->flat_rates[ $shipping_class ]['fee'], $class_price );
else :
} else {
// Class not set so we use default rate
$cost += $this->cost;
$fee += $this->get_fee( $this->fee, $class_price );
endif;
endforeach;
}
}
}
// Total
@ -318,11 +313,9 @@ class WC_Flat_Rate extends WC_Shipping_Method {
// Shipping per item
foreach ( $package['contents'] as $item_id => $values ) {
$_product = $values['data'];
if ( $values['quantity'] > 0 && $_product->needs_shipping() ) {
$shipping_class = $_product->get_shipping_class();
if ( isset( $this->flat_rates[ $shipping_class ] ) ) {
@ -376,27 +369,31 @@ class WC_Flat_Rate extends WC_Shipping_Method {
</tfoot>
<tbody class="flat_rates">
<?php
$i = -1; if ($this->flat_rates) foreach( $this->flat_rates as $class => $rate ) : $i++;
$i = -1;
if ( $this->flat_rates ) {
foreach ( $this->flat_rates as $class => $rate ) {
$i++;
echo '<tr class="flat_rate">
<td class="check-column"><input type="checkbox" name="select" /></td>
<td class="flat_rate_class">
<select name="'. $this->id .'_class[' . $i . ']" class="select">';
if ($woocommerce->shipping->get_shipping_classes()) :
foreach ($woocommerce->shipping->get_shipping_classes() as $shipping_class) :
if ( $woocommerce->shipping->get_shipping_classes() ) {
foreach ( $woocommerce->shipping->get_shipping_classes() as $shipping_class ) {
echo '<option value="'.$shipping_class->slug.'" '.selected($shipping_class->slug, $class, false).'>'.$shipping_class->name.'</option>';
endforeach;
else :
}
} else {
echo '<option value="">'.__('Select a class&hellip;', 'woocommerce').'</option>';
endif;
}
echo '</select>
</td>
<td><input type="text" value="' . $rate['cost'] . '" name="'. $this->id .'_cost[' . $i . ']" placeholder="'.__( '0.00', 'woocommerce' ).'" size="4" /></td>
<td><input type="text" value="' . $rate['fee'] . '" name="'. $this->id .'_fee[' . $i . ']" placeholder="'.__( '0.00', 'woocommerce' ).'" size="4" /></td>
</tr>';
endforeach;
}
}
?>
</tbody>
</table>
@ -449,7 +446,6 @@ class WC_Flat_Rate extends WC_Shipping_Method {
} // End admin_options()
function process_flat_rates() {
// Save the rates
$flat_rate_class = array();
$flat_rate_cost = array();
@ -466,21 +462,18 @@ class WC_Flat_Rate extends WC_Shipping_Method {
$value = end( $values );
$key = key( $values );
for ($i=0; $i<=$key; $i++) :
if (isset($flat_rate_class[$i]) && isset($flat_rate_cost[$i]) && isset($flat_rate_fee[$i])) :
for ( $i = 0; $i <= $key; $i++ ) {
if ( isset( $flat_rate_class[ $i ] ) && isset( $flat_rate_cost[ $i ] ) && isset( $flat_rate_fee[ $i ] ) ) {
$flat_rate_cost[$i] = number_format($flat_rate_cost[$i], 2, '.', '');
// Add to flat rates array
$flat_rates[ sanitize_title($flat_rate_class[$i]) ] = array(
'cost' => $flat_rate_cost[ $i ],
'fee' => $flat_rate_fee[$i]
'fee' => $flat_rate_fee[ $i ],
);
endif;
endfor;
}
}
update_option( $this->flat_rate_option, $flat_rates );

View File

@ -1,10 +1,10 @@
=== WooCommerce excelling eCommerce ===
=== WooCommerce - excelling eCommerce ===
Contributors: woothemes, mikejolley, jameskoster, CoenJacobs
Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, affiliate, store, sales, sell, shop, shopping, cart, checkout, configurable, variable, widgets, reports, download, downloadable, digital, inventory, stock, reports, shipping, tax
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@woothemes.com&item_name=Donation+for+WooCommerce
Requires at least: 3.3
Tested up to: 3.4
Stable tag: 1.5.5
Stable tag: 1.5.6
WooCommerce is a powerful, extendable eCommerce plugin that helps you sell anything. Beautifully.
@ -147,15 +147,27 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
= 1.5.6 =
==
* Fix - Strange error where detecting the page (is_page etc) would break the canonical redirect in some instances when hooked into 'wp'. Used the later get_header hook instead.
= 1.5.6 - 17/05/2012 =
* Feature - Default display for shipping methods is radio buttons. Before, when methods were enabled/disabled based on coupons or customer, changed methods could go unnoticed. Radio options are always visible.
* Feature - Option to display shipping methods as a select box vs. radio buttons
* Feature - Added support for cost per order to Flat Rate shipping
* Feature - image support added to sharethis
* Tweak - When the count of available shipping methods changes, reset to default
* Tweak - Optimisations to monthly and product reports
* Tweak - Individually sold variation handling
* Tweak - Removed mdash; from shipping options
* Tweak - Made woocommerce_locate_template more useful for third party plugins - ability to pass a full path
* Tweak - WC Debug page hooks
* Tweak - Tidied up installer
* Tweak - Removed unused get_hidden_product_ids
* Fix - Google Analytics options fix
* Fix - % discount rounding
* Fix - get_stock_quantity returns '' if stock management is off in global settings
* Fix - Prevent error in ecommerce tracking if no categories set
= 1.5.5 - 10/05/2012 =
* Feature - New 'default' sorting order using menu_order, with drag and drop sorting (based on http://wordpress.org/extend/plugins/simple-page-ordering/)

View File

@ -27,10 +27,10 @@ function woocommerce_order_tracking( $atts ) {
$woocommerce->verify_nonce( 'order_tracking' );
if (isset($_POST['orderid']) && $_POST['orderid'] > 0) $order_id = (int) $_POST['orderid']; else $order_id = 0;
if (isset($_POST['orderid']) && $_POST['orderid']) $order_id = $_POST['orderid']; else $order_id = 0;
if (isset($_POST['order_email']) && $_POST['order_email']) $order_email = trim($_POST['order_email']); else $order_email = '';
$order = new WC_Order( $order_id );
$order = new WC_Order( apply_filters( 'woocommerce_shortcode_order_tracking_order_id', $order_id ) );
if ($order->id && $order_email) :

View File

@ -68,7 +68,12 @@ class WooCommerce_Widget_Best_Sellers extends WP_Widget {
);
if ( isset( $instance['hide_free'] ) && 1 == $instance['hide_free'] ) {
$query_args['meta_query'] = array( array( 'key' => '_price', 'value' => 0, 'compare' => '>' ) );
$query_args['meta_query'] = array( array(
'key' => '_price',
'value' => 0,
'compare' => '>',
'type' => 'DECIMAL',
) );
}
$r = new WP_Query($query_args);
@ -125,7 +130,7 @@ class WooCommerce_Widget_Best_Sellers extends WP_Widget {
function form( $instance ) {
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
if ( !isset($instance['number']) || !$number = (int) $instance['number'] ) $number = 5;
if ( isset( $instance['hide_free'] ) && 1 == $instance['hide_free'] ) $hide_free_checked = ' checked="checked"';
$hide_free_checked = ( isset( $instance['hide_free'] ) && 1 == $instance['hide_free'] ) ? ' checked="checked"' : '';
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'woocommerce'); ?></label>

View File

@ -90,6 +90,7 @@ class WooCommerce_Widget_Featured_Products extends WP_Widget {
echo $content;
wp_cache_set('widget_featured_products', $cache, 'widget');
wp_reset_postdata();
}
/** @see WP_Widget->update */

View File

@ -262,13 +262,13 @@ function woocommerce_get_template_part( $slug, $name = '' ) {
/**
* Get other templates (e.g. product attributes) passing attributes and including the file
*/
function woocommerce_get_template( $template_name, $args = array(), $template_path = '' ) {
function woocommerce_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
global $woocommerce;
if ( $args && is_array($args) )
extract( $args );
$located = woocommerce_locate_template( $template_name, $template_path );
$located = woocommerce_locate_template( $template_name, $template_path, $default_path );
do_action( 'woocommerce_before_template_part', $template_name, $template_path, $located );
@ -278,19 +278,33 @@ function woocommerce_get_template( $template_name, $args = array(), $template_pa
}
/**
* Locate a template and return the path for inclusion
* Locate a template and return the path for inclusion.
*
* This is the load order:
*
* yourtheme / $template_path / $template_name
* yourtheme / $template_name
* $default_path / $template_name
*/
function woocommerce_locate_template( $template_name, $template_path = '' ) {
function woocommerce_locate_template( $template_name, $template_path = '', $default_path = '' ) {
global $woocommerce;
$template = ( ! empty( $template_path ) ) ? locate_template( array( $template_path . $template_name , $template_name ) ) : '';
if ( ! $template_path ) $template_path = $woocommerce->template_url;
if ( ! $default_path ) $default_path = $woocommerce->plugin_path() . '/templates/';
// Look in yourtheme/woocommerce/template-name and yourtheme/template-name
if ( ! $template ) $template = locate_template( array( $woocommerce->template_url . $template_name , $template_name ) );
// Look within passed path within the theme - this is priority
$template = locate_template(
array(
$template_path . $template_name,
$template_name
)
);
// Get default template
if ( ! $template ) $template = $woocommerce->plugin_path() . '/templates/' . $template_name;
if ( ! $template )
$template = $default_path . $template_name;
// Return what we found
return apply_filters('woocommerce_locate_template', $template, $template_name, $template_path);
}

View File

@ -102,7 +102,7 @@ if ( !is_admin() || defined('DOING_AJAX') ) {
/* Shop Page Handling and Support */
add_action( 'template_redirect', 'woocommerce_redirects' );
add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_item_classes', 2, 20 );
add_action( 'wp', 'woocommerce_front_page_archive_paging_fix', 1 );
add_action( 'get_header', 'woocommerce_front_page_archive_paging_fix', 1 );
add_action( 'woocommerce_before_shop_loop', 'woocommerce_front_page_archive', 1 );
add_filter( 'wp_list_pages', 'woocommerce_list_pages' );
@ -111,7 +111,7 @@ add_filter( 'wp_nav_menu_items', 'woocommerce_nav_menu_items', 10, 2 );
/* Clear the cart */
if (get_option('woocommerce_clear_cart_on_logout')=='yes') add_action( 'wp_logout', 'woocommerce_empty_cart' );
add_action( 'wp', 'woocommerce_clear_cart_after_payment' );
add_action( 'get_header', 'woocommerce_clear_cart_after_payment' );
/* Disable admin bar */
add_action( 'init', 'woocommerce_disable_admin_bar' );

View File

@ -3,7 +3,7 @@
* Plugin Name: WooCommerce
* Plugin URI: http://www.woothemes.com/woocommerce/
* Description: An e-commerce toolkit that helps you sell anything. Beautifully.
* Version: 1.5.5
* Version: 1.5.6
* Author: WooThemes
* Author URI: http://woothemes.com
* Requires at least: 3.3
@ -32,7 +32,7 @@ class Woocommerce {
/** Version ***************************************************************/
var $version = '1.5.5';
var $version = '1.5.6';
/** URLS ******************************************************************/
@ -220,7 +220,7 @@ class Woocommerce {
add_filter( 'template_include', array(&$this, 'template_loader') );
add_filter( 'comments_template', array(&$this, 'comments_template_loader') );
add_filter( 'wp_redirect', array(&$this, 'redirect'), 1, 2 );
add_action( 'wp', array(&$this, 'buffer_checkout') );
add_action( 'get_header', array(&$this, 'buffer_checkout') );
add_action( 'wp_enqueue_scripts', array(&$this, 'frontend_scripts') );
add_action( 'wp_head', array(&$this, 'generator') );
add_action( 'wp_head', array(&$this, 'wp_head') );
@ -239,7 +239,7 @@ class Woocommerce {
// Actions for SSL
if ( ! is_admin() || defined('DOING_AJAX') ) {
add_action( 'wp', array( &$this, 'ssl_redirect' ) );
add_action( 'get_header', array( &$this, 'ssl_redirect' ) );
$filters = array( 'post_thumbnail_html', 'widget_text', 'wp_get_attachment_url', 'wp_get_attachment_image_attributes', 'wp_get_attachment_url', 'option_siteurl', 'option_homeurl', 'option_home', 'option_url', 'option_wpurl', 'option_stylesheet_url', 'option_template_url', 'script_loader_src', 'style_loader_src', 'template_directory_uri', 'stylesheet_directory_uri', 'site_url' );
foreach ( $filters as $filter ) add_filter( $filter, array( &$this, 'force_ssl') );