Fixed "undefined index" errors and made sure term meta database table is registered.

This commit is contained in:
Matty 2011-09-16 13:15:49 +02:00
parent 5d84ea814a
commit 104166adba
5 changed files with 30 additions and 15 deletions

View File

@ -275,7 +275,9 @@ function woocommerce_products_by_category() {
$output = "<select name='product_cat' id='dropdown_product_cat'>";
$output .= '<option value="">'.__('Show all categories', 'woothemes').'</option>';
foreach($terms as $term){
$output .="<option value='$term->slug' ".selected($term->slug, $wp_query->query['product_cat'], false).">$term->name ($term->count)</option>";
if ( isset( $wp_query->query['product_cat'] ) ) {
$output .="<option value='$term->slug' ".selected($term->slug, $wp_query->query['product_cat'], false).">$term->name ($term->count)</option>";
}
}
$output .="</select>";
echo $output;

View File

@ -15,7 +15,10 @@
function woocommerce_update_options($options) {
if(!isset($_POST) || !$_POST) return false;
// Nonce security check.
check_admin_referer( 'woocommerce_admin_fields' );
foreach ($options as $value) {
if (isset($value['id']) && $value['id']=='woocommerce_tax_rates') :
@ -125,6 +128,9 @@ function woocommerce_update_options($options) {
*/
function woocommerce_admin_fields($options) {
global $woocommerce;
// Nonce security field.
wp_nonce_field( 'woocommerce_admin_fields' );
foreach ($options as $value) :
switch($value['type']) :

View File

@ -627,7 +627,7 @@ function woocommerce_settings() {
$links = array();
foreach ($woocommerce->payment_gateways->payment_gateways() as $gateway) :
$title = ($gateway->method_title) ? ucwords($gateway->method_title) : ucwords($gateway->id);
$title = ( isset( $gateway->method_title ) && $gateway->method_title) ? ucwords($gateway->method_title) : ucwords($gateway->id);
$links[] = '<a href="#gateway-'.$gateway->id.'">'.$title.'</a>';
endforeach;

View File

@ -13,18 +13,6 @@
* Categories ordering
*/
/**
* Add a table to $wpdb to benefit from wordpress meta api
*/
add_action('init','taxonomy_metadata_wpdbfix');
add_action('switch_blog','taxonomy_metadata_wpdbfix');
function taxonomy_metadata_wpdbfix() {
global $wpdb;
$wpdb->woocommerce_termmeta = "{$wpdb->prefix}woocommerce_termmeta";
}
/**
* Add product_cat ordering to get_terms
*

View File

@ -4,6 +4,7 @@
*
* Actions/functions/hooks for WooCommerce related events.
*
* - Add a table to $wpdb to benefit from the WordPress Metadata API
* - AJAX update shipping method on cart page
* - AJAX update order review on checkout
* - AJAX add to cart
@ -23,6 +24,24 @@
* @author WooThemes
*/
/**
* woocommerce_taxonomy_metadata_wpdbfix()
*
* Add a table to $wpdb to benefit from the WordPress Metadata API
*
* @since 1.0.0
* @uses $wpdb global
*/
add_action( 'init', 'woocommerce_taxonomy_metadata_wpdbfix', 0 );
add_action( 'switch_blog', 'woocommerce_taxonomy_metadata_wpdbfix', 0 );
function woocommerce_taxonomy_metadata_wpdbfix() {
global $wpdb;
$variable_name = 'woocommerce_termmeta';
$wpdb->$variable_name = $wpdb->prefix . $variable_name;
$wpdb->tables[] = $variable_name;
} // End woocommerce_taxonomy_metadata_wpdbfix()
/**
* AJAX update shipping method on cart page