Permalink
Browse files

widget conflict

  • Loading branch information...
1 parent 955bda0 commit f951fbc70e1de58a2ac59696168518e3c955046d @mikejolley mikejolley committed Jun 25, 2012
Showing with 51 additions and 45 deletions.
  1. +1 −0 readme.txt
  2. +36 −31 widgets/widget-layered_nav.php
  3. +14 −14 widgets/widget-price_filter.php
View
@@ -150,6 +150,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
+* Fix - Widget init function conflict with widget logic
* Fix - PLN currency code
= 1.5.8 - 21/06/2012 =
@@ -6,44 +6,49 @@
* @category Widgets
* @author WooThemes
*/
-if (is_active_widget( false, false, 'woocommerce_layered_nav', 'true' ) && !is_admin()) :
- add_action('init', 'woocommerce_layered_nav_init', 1);
- add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query');
-endif;
-
/**
* Layered Nav Init
*/
+add_action( 'init', 'woocommerce_layered_nav_init', 1 );
+
function woocommerce_layered_nav_init( ) {
- global $_chosen_attributes, $woocommerce, $_attributes_array;
- $_chosen_attributes = array();
- $_attributes_array = array();
+ if ( is_active_widget( false, false, 'woocommerce_layered_nav', true ) && ! is_admin() ) {
- $attribute_taxonomies = $woocommerce->attribute_taxonomies;
- if ( $attribute_taxonomies ) :
- foreach ($attribute_taxonomies as $tax) :
-
- $attribute = strtolower(sanitize_title($tax->attribute_name));
- $taxonomy = $woocommerce->attribute_taxonomy_name($attribute);
-
- // create an array of product attribute taxonomies
- $_attributes_array[] = $taxonomy;
-
- $name = 'filter_' . $attribute;
- $query_type_name = 'query_type_' . $attribute;
-
- if (isset($_GET[$name]) && $_GET[$name] && taxonomy_exists($taxonomy)) :
- $_chosen_attributes[$taxonomy]['terms'] = explode(',', $_GET[$name] );
- if (isset($_GET[$query_type_name]) && $_GET[$query_type_name]=='or') :
- $_chosen_attributes[$taxonomy]['query_type'] = 'or';
- else :
- $_chosen_attributes[$taxonomy]['query_type'] = 'and';
- endif;
- endif;
- endforeach;
- endif;
+ global $_chosen_attributes, $woocommerce, $_attributes_array;
+
+ $_chosen_attributes = array();
+ $_attributes_array = array();
+
+ $attribute_taxonomies = $woocommerce->attribute_taxonomies;
+ if ( $attribute_taxonomies ) {
+ foreach ( $attribute_taxonomies as $tax ) {
+
+ $attribute = strtolower(sanitize_title($tax->attribute_name));
+ $taxonomy = $woocommerce->attribute_taxonomy_name($attribute);
+
+ // create an array of product attribute taxonomies
+ $_attributes_array[] = $taxonomy;
+
+ $name = 'filter_' . $attribute;
+ $query_type_name = 'query_type_' . $attribute;
+
+ if ( ! empty( $_GET[$name] ) && taxonomy_exists( $taxonomy ) ) {
+
+ $_chosen_attributes[$taxonomy]['terms'] = explode( ',', $_GET[ $name ] );
+
+ if ( ! empty( $_GET[$query_type_name] ) && $_GET[ $query_type_name ] == 'or' )
+ $_chosen_attributes[$taxonomy]['query_type'] = 'or';
+ else
+ $_chosen_attributes[$taxonomy]['query_type'] = 'and';
+
+ }
+ }
+ }
+
+ add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query');
+ }
}
/**
@@ -9,26 +9,26 @@
* @author WooThemes
*/
-if (is_active_widget( false, false, 'price_filter', 'true' ) && !is_admin()) :
- add_action('init', 'woocommerce_price_filter_init');
- add_filter('loop_shop_post_in', 'woocommerce_price_filter');
-endif;
-
/**
* Price filter Init
*/
+add_action( 'init', 'woocommerce_price_filter_init' );
+
function woocommerce_price_filter_init() {
- unset($_SESSION['min_price']);
- unset($_SESSION['max_price']);
-
- if (isset($_GET['min_price'])) :
- $_SESSION['min_price'] = $_GET['min_price'];
- endif;
- if (isset($_GET['max_price'])) :
- $_SESSION['max_price'] = $_GET['max_price'];
- endif;
+ if ( is_active_widget( false, false, 'price_filter', true ) && ! is_admin() ) {
+ unset( $_SESSION['min_price'] );
+ unset( $_SESSION['max_price'] );
+
+ if ( isset( $_GET['min_price'] ) )
+ $_SESSION['min_price'] = $_GET['min_price'];
+
+ if ( isset( $_GET['max_price'] ) )
+ $_SESSION['max_price'] = $_GET['max_price'];
+
+ add_filter( 'loop_shop_post_in', 'woocommerce_price_filter' );
+ }
}
/**

0 comments on commit f951fbc

Please sign in to comment.