From 8cf44fc8fca560c4e0a0d86e59a7a1c5b8f8bbb6 Mon Sep 17 00:00:00 2001 From: Lee Willis Date: Thu, 30 May 2013 21:42:06 +0100 Subject: [PATCH 1/5] Whitespace / coding standards fixes --- wpsc-admin/includes/save-data.functions.php | 21 ++++---- wpsc-includes/theme.functions.php | 55 +++++++++++---------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/wpsc-admin/includes/save-data.functions.php b/wpsc-admin/includes/save-data.functions.php index de37628480..6724cc2643 100755 --- a/wpsc-admin/includes/save-data.functions.php +++ b/wpsc-admin/includes/save-data.functions.php @@ -271,7 +271,7 @@ function wpsc_admin_category_forms_edit() { $category_name = ''; $category = array(); - $category_id = absint( $_REQUEST["tag_ID"] ); + $category_id = absint( $_REQUEST['tag_ID'] ); $category = get_term( $category_id, 'wpsc_product_category', ARRAY_A ); $category['nice-name'] = wpsc_get_categorymeta( $category['term_id'], 'nice-name' ); $category['description'] = wpsc_get_categorymeta( $category['term_id'], 'description' ); @@ -305,7 +305,7 @@ function wpsc_admin_category_forms_edit() { ?>
@@ -325,7 +325,7 @@ function wpsc_admin_category_forms_edit() { - + @@ -342,7 +342,6 @@ function wpsc_admin_category_forms_edit() { -

@@ -374,7 +373,7 @@ function wpsc_admin_category_forms_edit() { get_results( "SELECT id,country,visible FROM `".WPSC_TABLE_CURRENCY_LIST."` ORDER BY country ASC ",ARRAY_A ); + $countrylist = $wpdb->get_results( 'SELECT id,country,visible FROM `'.WPSC_TABLE_CURRENCY_LIST.'` ORDER BY country ASC ',ARRAY_A ); $selectedCountries = wpsc_get_meta( $category_id,'target_market','wpsc_category' ); ?> @@ -387,7 +386,7 @@ function wpsc_admin_category_forms_edit() { :  
- ' value='' checked='' /> @@ -418,7 +417,7 @@ function wpsc_admin_category_forms_edit() { $category['term_id'] = ''; $used_additonal_form_set = wpsc_get_categorymeta( $category['term_id'], 'use_additional_form_set' ); - $checkout_sets = get_option('wpsc_checkout_form_sets'); + $checkout_sets = get_option( 'wpsc_checkout_form_sets' ); unset($checkout_sets[0]); $uses_billing_address = (bool)wpsc_get_categorymeta( $category['term_id'], 'uses_billing_address' ); ?> @@ -430,8 +429,8 @@ function wpsc_admin_category_forms_edit() { /> - + +

diff --git a/wpsc-includes/theme.functions.php b/wpsc-includes/theme.functions.php index 8cc04baa4b..0bc121f0a0 100755 --- a/wpsc-includes/theme.functions.php +++ b/wpsc-includes/theme.functions.php @@ -902,68 +902,68 @@ function wpsc_get_the_new_id($prod_id){ function wpsc_display_products_page( $query ) { global $wpdb, $wpsc_query,$wp_query, $wp_the_query; - remove_filter('the_title','wpsc_the_category_title'); + remove_filter( 'the_title','wpsc_the_category_title' ); // If the data is coming from a shortcode parse the values into the args variable, // I did it this was to preserve backwards compatibility - if(!empty($query)){ + if ( ! empty( $query ) ) { $args = array(); $args['post_type'] = 'wpsc-product'; - if(!empty($query['product_id']) && is_array($query['product_id'])){ + if ( ! empty( $query['product_id'] ) && is_array( $query['product_id'] ) ) { $args['post__in'] = $query['product_id']; - }elseif(is_string($query['product_id'])){ + } elseif ( is_string( $query['product_id'] ) ) { $args['post__in'] = (array)$query['product_id']; } - if(!empty($query['old_product_id'])){ - $post_id = wpsc_get_the_new_id($query['old_product_id']); + if ( ! empty( $query['old_product_id'] ) ) { + $post_id = wpsc_get_the_new_id( $query['old_product_id'] ); $args['post__in'] = (array)$post_id; } - if(!empty($query['price']) && 'sale' != $query['price']){ + if ( ! empty( $query['price'] ) && 'sale' != $query['price'] ) { $args['meta_key'] = '_wpsc_price'; $args['meta_value'] = $query['price']; - }elseif(!empty($query['price']) && 'sale' == $query['price']){ + } elseif ( ! empty( $query['price'] ) && 'sale' == $query['price'] ) { $args['meta_key'] = '_wpsc_special_price'; $args['meta_compare'] = '>='; $args['meta_value'] = '1'; } - if(!empty($query['product_name'])){ + if ( ! empty( $query['product_name'] ) ) { $args['pagename'] = $query['product_name']; } - if(!empty($query['category_id'])){ - $term = get_term($query['category_id'],'wpsc_product_category'); - $id = wpsc_get_meta($query['category_id'], 'category_id','wpsc_old_category'); - if( !empty($id)){ - $term = get_term($id,'wpsc_product_category'); + if ( ! empty( $query['category_id'] ) ) { + $term = get_term( $query['category_id'],'wpsc_product_category' ); + $id = wpsc_get_meta( $query['category_id'], 'category_id','wpsc_old_category' ); + if ( ! empty( $id ) ){ + $term = get_term( $id,'wpsc_product_category' ); $args['wpsc_product_category'] = $term->slug; $args['wpsc_product_category__in'] = $term->term_id; - }else{ + } else { $args['wpsc_product_category'] = $term->slug; $args['wpsc_product_category__in'] = $term->term_id; } } - if(!empty($query['category_url_name'])){ + if ( ! empty( $query['category_url_name'] ) ) { $args['wpsc_product_category'] = $query['category_url_name']; } $orderby = ( !empty($query['sort_order']) ) ? $query['sort_order'] : null; - $args = array_merge( $args, wpsc_product_sort_order_query_vars($orderby) ); + $args = array_merge( $args, wpsc_product_sort_order_query_vars( $orderby ) ); - if(!empty($query['order'])){ + if ( ! empty( $query['order'] ) ) { $args['order'] = $query['order']; } - if(!empty($query['limit_of_items']) && '1' == get_option('use_pagination')){ + if ( ! empty( $query['limit_of_items'] ) && '1' == get_option( 'use_pagination' ) ) { $args['posts_per_page'] = $query['limit_of_items']; } - if(!empty($query['number_per_page']) && '1' == get_option('use_pagination')){ + if ( ! empty( $query['number_per_page'] ) && '1' == get_option( 'use_pagination' ) ) { $args['posts_per_page'] = $query['number_per_page']; $args['paged'] = $query['page']; } - if( '0' == get_option('use_pagination') ){ + if ( '0' == get_option( 'use_pagination' ) ) { $args['nopaging'] = true; $args['posts_per_page'] = '-1'; } - if(!empty($query['tag'])){ + if ( ! empty( $query['tag'] ) ) { $args['product_tag'] = $query['tag']; } query_posts( $args ); @@ -974,12 +974,13 @@ function wpsc_display_products_page( $query ) { // Pretty sure this single_product code is legacy...but fixing it up just in case. // get the display type for the selected category - if(!empty($temp_wpsc_query->query_vars['term'])) - $display_type = wpsc_get_the_category_display($temp_wpsc_query->query_vars['term']); - elseif( !empty( $args['wpsc_product_category'] ) ) - $display_type = wpsc_get_the_category_display($args['wpsc_product_category']); - else + if ( ! empty( $temp_wpsc_query->query_vars['term'] ) ) { + $display_type = wpsc_get_the_category_display( $temp_wpsc_query->query_vars['term'] ); + } elseif ( ! empty( $args['wpsc_product_category'] ) ) { + $display_type = wpsc_get_the_category_display( $args['wpsc_product_category'] ); + } else { $display_type = 'default'; + } $saved_display = wpsc_get_customer_meta( 'display_type' ); $display_type = ! empty( $saved_display ) ? $saved_display : wpsc_check_display_type(); From ac1e60b2e382956b0029713812fe73542c60c8de Mon Sep 17 00:00:00 2001 From: Lee Willis Date: Thu, 30 May 2013 21:42:25 +0100 Subject: [PATCH 2/5] Comment fixes --- wpsc-admin/includes/save-data.functions.php | 3 +++ wpsc-includes/theme.functions.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wpsc-admin/includes/save-data.functions.php b/wpsc-admin/includes/save-data.functions.php index 6724cc2643..0bbc49eb74 100755 --- a/wpsc-admin/includes/save-data.functions.php +++ b/wpsc-admin/includes/save-data.functions.php @@ -264,6 +264,9 @@ function _wpsc_is_display_type_supported( $display_type ) { return function_exists( $callback ); } +/** + * Renders the additional content for the category edit page + */ function wpsc_admin_category_forms_edit() { global $wpdb; diff --git a/wpsc-includes/theme.functions.php b/wpsc-includes/theme.functions.php index 0bc121f0a0..ca51530172 100755 --- a/wpsc-includes/theme.functions.php +++ b/wpsc-includes/theme.functions.php @@ -1473,7 +1473,7 @@ function is_products_page(){ } /** - * wpsc_display_products_page function. + * wpsc_display_featured_products_page function. * * @access public * @param mixed $query @@ -1515,7 +1515,7 @@ function wpsc_display_featured_products_page() { /** - * wpsc_display_products_page class + * WPSC_Hide_subcatsprods_in_cat class * * Shows only products from current category, but not from subcategories. * From 6576f1345b4c9dbc3b6533ad14ae9b15d1a42a0d Mon Sep 17 00:00:00 2001 From: Lee Willis Date: Thu, 30 May 2013 21:42:56 +0100 Subject: [PATCH 3/5] escaping fixes --- wpsc-admin/includes/save-data.functions.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wpsc-admin/includes/save-data.functions.php b/wpsc-admin/includes/save-data.functions.php index 0bbc49eb74..1c130b0bf0 100755 --- a/wpsc-admin/includes/save-data.functions.php +++ b/wpsc-admin/includes/save-data.functions.php @@ -354,7 +354,7 @@ function wpsc_admin_category_forms_edit() { - [wpsc_products category_url_name='']
+ [wpsc_products category_url_name='']
@@ -363,7 +363,7 @@ function wpsc_admin_category_forms_edit() { - <?php echo wpsc_display_products_page( array( 'category_url_name' => '' ) ); ?>
+ <?php echo wpsc_display_products_page( array( 'category_url_name' => '' ) ); ?>
@@ -392,13 +392,13 @@ function wpsc_admin_category_forms_edit() { - ' value='' checked='' /> -
+ ' value='' checked='' /> +
- ' value='' /> -
+ ' value='' /> +
@@ -437,7 +437,7 @@ function wpsc_admin_category_forms_edit() { if ( $used_additonal_form_set == $key ) { $selected_state = "selected='selected'"; } ?> - + From 416401bd9c67b4859d08e0764fe09537837faaba Mon Sep 17 00:00:00 2001 From: Lee Willis Date: Thu, 30 May 2013 22:04:06 +0100 Subject: [PATCH 4/5] Default to global pagination option, but allow number_per_page to override --- wpsc-includes/theme.functions.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/wpsc-includes/theme.functions.php b/wpsc-includes/theme.functions.php index ca51530172..25d6a75d30 100755 --- a/wpsc-includes/theme.functions.php +++ b/wpsc-includes/theme.functions.php @@ -952,17 +952,18 @@ function wpsc_display_products_page( $query ) { if ( ! empty( $query['order'] ) ) { $args['order'] = $query['order']; } - if ( ! empty( $query['limit_of_items'] ) && '1' == get_option( 'use_pagination' ) ) { - $args['posts_per_page'] = $query['limit_of_items']; - } - if ( ! empty( $query['number_per_page'] ) && '1' == get_option( 'use_pagination' ) ) { - $args['posts_per_page'] = $query['number_per_page']; - $args['paged'] = $query['page']; - } if ( '0' == get_option( 'use_pagination' ) ) { $args['nopaging'] = true; $args['posts_per_page'] = '-1'; } + if ( ! empty( $query['limit_of_items'] ) ) { + $args['posts_per_page'] = $query['limit_of_items']; + $args['nopaging'] = false; + } + if ( ! empty( $query['number_per_page'] ) ) { + $args['posts_per_page'] = $query['number_per_page']; + $args['nopaging'] = false; + } if ( ! empty( $query['tag'] ) ) { $args['product_tag'] = $query['tag']; } From b7d111731a064057e7d1d76004b904b7d230339c Mon Sep 17 00:00:00 2001 From: Lee Willis Date: Fri, 31 May 2013 19:47:58 +0100 Subject: [PATCH 5/5] Use checked() --- wpsc-admin/includes/save-data.functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wpsc-admin/includes/save-data.functions.php b/wpsc-admin/includes/save-data.functions.php index 1c130b0bf0..e0fc9b6844 100755 --- a/wpsc-admin/includes/save-data.functions.php +++ b/wpsc-admin/includes/save-data.functions.php @@ -450,8 +450,8 @@ function wpsc_admin_category_forms_edit() { - - + +