From 104166adba1fb2453cfb80c001dc2165c41ce8f3 Mon Sep 17 00:00:00 2001 From: Matty Date: Fri, 16 Sep 2011 13:15:49 +0200 Subject: [PATCH] Fixed "undefined index" errors and made sure term meta database table is registered. --- admin/admin-post-types.php | 4 +++- admin/admin-settings-forms.php | 8 +++++++- admin/admin-settings.php | 2 +- admin/admin-taxonomies.php | 12 ------------ woocommerce_actions.php | 19 +++++++++++++++++++ 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/admin/admin-post-types.php b/admin/admin-post-types.php index d39450a4b2a..b241cf4bd85 100644 --- a/admin/admin-post-types.php +++ b/admin/admin-post-types.php @@ -275,7 +275,9 @@ function woocommerce_products_by_category() { $output = ""; echo $output; diff --git a/admin/admin-settings-forms.php b/admin/admin-settings-forms.php index dfacb8f7b78..0444d55e6e9 100644 --- a/admin/admin-settings-forms.php +++ b/admin/admin-settings-forms.php @@ -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']) : diff --git a/admin/admin-settings.php b/admin/admin-settings.php index c24b05d0d7d..60904b7b462 100644 --- a/admin/admin-settings.php +++ b/admin/admin-settings.php @@ -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[] = ''.$title.''; endforeach; diff --git a/admin/admin-taxonomies.php b/admin/admin-taxonomies.php index 6ac0a43e2dc..f6eca8796ee 100644 --- a/admin/admin-taxonomies.php +++ b/admin/admin-taxonomies.php @@ -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 * diff --git a/woocommerce_actions.php b/woocommerce_actions.php index 6642683c25b..257e1174a7a 100644 --- a/woocommerce_actions.php +++ b/woocommerce_actions.php @@ -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