-
Notifications
You must be signed in to change notification settings - Fork 212
Issue 152 #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Issue 152 #471
Changes from all commits
8cf44fc
ac1e60b
6576f13
416401b
b7d1117
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -264,14 +264,17 @@ 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; | ||
|
|
||
| $category_value_count = 0; | ||
| $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 +308,7 @@ function wpsc_admin_category_forms_edit() { | |
| ?> | ||
| <select name='display_type'> | ||
| <option value='default'<?php checked( $display_type, 'default' ); ?>><?php esc_html_e( 'Default View', 'wpsc' ); ?></option> | ||
| <option value='list'<?php disabled( _wpsc_is_display_type_supported( 'list' ), false ); ?><?php checked( $display_type, 'list' ); ?>><?php esc_html_e('List View', 'wpsc'); ?></option> | ||
| <option value='list'<?php disabled( _wpsc_is_display_type_supported( 'list' ), false ); ?><?php checked( $display_type, 'list' ); ?>><?php esc_html_e( 'List View', 'wpsc' ); ?></option> | ||
| <option value='grid' <?php disabled( _wpsc_is_display_type_supported( 'grid' ), false ); ?><?php checked( $display_type, 'grid' ); ?>><?php esc_html_e( 'Grid View', 'wpsc' ); ?></option> | ||
| </select><br /> | ||
| </td> | ||
|
|
@@ -325,7 +328,7 @@ function wpsc_admin_category_forms_edit() { | |
| <span class="description"><?php esc_html_e( 'You can set an image for the category here. If one exists, check the box to delete.', 'wpsc' ); ?></span> | ||
| </td> | ||
| </tr> | ||
| <?php if ( function_exists( "getimagesize" ) ) : ?> | ||
| <?php if ( function_exists( 'getimagesize' ) ) : ?> | ||
| <tr class="form-field"> | ||
| <th scope="row" valign="top"> | ||
| <label for="image"><?php esc_html_e( 'Thumbnail Size', 'wpsc' ); ?></label> | ||
|
|
@@ -342,7 +345,6 @@ function wpsc_admin_category_forms_edit() { | |
| </tr> | ||
| <?php endif; // 'getimagesize' condition ?> | ||
|
|
||
|
|
||
| <tr> | ||
| <td colspan="2"><h4><?php esc_html_e( 'Shortcodes and Template Tags', 'wpsc' ); ?></h4></td> | ||
| </tr> | ||
|
|
@@ -352,7 +354,7 @@ function wpsc_admin_category_forms_edit() { | |
| <label for="image"><?php esc_html_e( 'Display Category Shortcode', 'wpsc' ); ?></label> | ||
| </th> | ||
| <td> | ||
| <code>[wpsc_products category_url_name='<?php echo $category["slug"]; ?>']</code><br /> | ||
| <code>[wpsc_products category_url_name='<?php echo esc_html($category['slug']); ?>']</code><br /> | ||
| <span class="description"><?php esc_html_e( 'Shortcodes are used to display a particular category or group within any WordPress page or post.', 'wpsc' ); ?></span> | ||
| </td> | ||
| </tr> | ||
|
|
@@ -361,7 +363,7 @@ function wpsc_admin_category_forms_edit() { | |
| <label for="image"><?php esc_html_e( 'Display Category Template Tag', 'wpsc' ); ?></label> | ||
| </th> | ||
| <td> | ||
| <code><?php echo wpsc_display_products_page( array( 'category_url_name' => '<?php echo $category["slug"]; ?>' ) ); ?></code><br /> | ||
| <code><?php echo wpsc_display_products_page( array( 'category_url_name' => '<?php echo esc_html( $category['slug'] ); ?>' ) ); ?></code><br /> | ||
| <span class="description"><?php esc_html_e( 'Template tags are used to display a particular category or group within your theme / template.', 'wpsc' ); ?></span> | ||
| </td> | ||
| </tr> | ||
|
|
@@ -374,7 +376,7 @@ function wpsc_admin_category_forms_edit() { | |
| </td> | ||
| </tr> | ||
| <?php | ||
| $countrylist = $wpdb->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' ); | ||
| ?> | ||
| <tr> | ||
|
|
@@ -387,16 +389,16 @@ function wpsc_admin_category_forms_edit() { | |
| <?php else : ?> | ||
| <span><?php esc_html_e( 'Select', 'wpsc' ); ?>: <a href='' class='wpsc_select_all'><?php esc_html_e( 'All', 'wpsc' ); ?></a> <a href='' class='wpsc_select_none'><?php esc_html_e( 'None', 'wpsc' ); ?></a></span><br /> | ||
| <div id='resizeable' class='ui-widget-content multiple-select'> | ||
| <?php foreach( $countrylist as $country ) { | ||
| <?php foreach ( $countrylist as $country ) { | ||
| if ( in_array( $country['id'], (array)$selectedCountries ) ) { | ||
| ?> | ||
| <input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo $country['id']; ?>' value='<?php echo $country['id']; ?>' checked='<?php echo $country['visible']; ?>' /> | ||
| <label for="countrylist2-<?php echo $country['id']; ?>"><?php esc_html_e( $country['country'] ); ?></label><br /> | ||
| <input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo esc_attr( $country['id'] ); ?>' value='<?php echo esc_attr( $country['id'] ); ?>' checked='<?php echo esc_attr( $country['visible'] ); ?>' /> | ||
| <label for="countrylist2-<?php echo esc_attr( $country['id'] ); ?>"><?php esc_html_e( $country['country'] ); ?></label><br /> | ||
| <?php | ||
| } else { | ||
| ?> | ||
| <input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo $country['id']; ?>' value='<?php echo $country['id']; ?>' /> | ||
| <label for="countrylist2-<?php echo $country['id']; ?>"><?php esc_html_e( $country['country'] ); ?></label><br /> | ||
| <input type='checkbox' name='countrylist2[]' id='countrylist2-<?php echo esc_attr( $country['id'] ); ?>' value='<?php echo esc_attr( $country['id'] ); ?>' /> | ||
| <label for="countrylist2-<?php echo esc_attr( $country['id'] ); ?>"><?php esc_html_e( $country['country'] ); ?></label><br /> | ||
| <?php | ||
| } | ||
| } ?> | ||
|
|
@@ -418,7 +420,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,12 +432,12 @@ function wpsc_admin_category_forms_edit() { | |
| <select name='use_additional_form_set'> | ||
| <option value=''><?php esc_html_e( 'None', 'wpsc' ); ?></option> | ||
| <?php | ||
| foreach( (array) $checkout_sets as $key => $value ) { | ||
| $selected_state = ""; | ||
| foreach ( (array) $checkout_sets as $key => $value ) { | ||
| $selected_state = ''; | ||
| if ( $used_additonal_form_set == $key ) { | ||
| $selected_state = "selected='selected'"; | ||
| } ?> | ||
| <option <?php echo $selected_state; ?> value='<?php echo $key; ?>'><?php echo esc_html( $value ); ?></option> | ||
| <option <?php echo $selected_state; ?> value='<?php echo esc_attr( $key ); ?>'><?php echo esc_html( $value ); ?></option> | ||
| <?php | ||
| } | ||
| ?> | ||
|
|
@@ -448,8 +450,8 @@ function wpsc_admin_category_forms_edit() { | |
| <label><?php esc_html_e( 'Address to calculate shipping with', 'wpsc' ); ?></label> | ||
| </th> | ||
| <td> | ||
| <label><input type='radio' class='wpsc_cat_box' value='0' name='uses_billing_address' <?php echo ( ( $uses_billing_address != true ) ? "checked='checked'" : "" ); ?> /> <?php esc_html_e( 'Default Setting', 'wpsc' ); ?></label> | ||
| <label><input type='radio' class='wpsc_cat_box' value='1' name='uses_billing_address' <?php echo ( ( $uses_billing_address == true ) ? "checked='checked'" : "" ); ?> /> <?php esc_html_e( 'Billing Address', 'wpsc' ); ?></label> | ||
| <label><input type='radio' class='wpsc_cat_box' value='0' name='uses_billing_address' <?php checked( $uses_billing_address, false ); ?> /> <?php esc_html_e( 'Default Setting', 'wpsc' ); ?></label> | ||
| <label><input type='radio' class='wpsc_cat_box' value='1' name='uses_billing_address' <?php checked( $uses_billing_address ); ?> /> <?php esc_html_e( 'Billing Address', 'wpsc' ); ?></label> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome, thanks for using checked()! The last thing we need here is to make sure we're not introducing any regressions - we've recently had some bugs fixed in this area of pagination, I want to make sure we're not re-breaking them. |
||
| <p class='description'><?php esc_html_e( 'Products in this category will use the address specified to calculate shipping costs.', 'wpsc' ); ?></p> | ||
| </td> | ||
| </tr> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -902,68 +902,69 @@ 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 ( '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']) && '1' == get_option('use_pagination')){ | ||
| if ( ! empty( $query['number_per_page'] ) ) { | ||
| $args['posts_per_page'] = $query['number_per_page']; | ||
| $args['paged'] = $query['page']; | ||
| $args['nopaging'] = false; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just wanted to confirm with you that this specific set of changes has been tested extensively?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No - absolutely not. I've tested it in the context of the original bug report, but I'm not clear on where else this is used. I'll have a dig and see if I can identify any other uses ... |
||
| } | ||
| 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 +975,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(); | ||
|
|
@@ -1472,7 +1474,7 @@ function is_products_page(){ | |
|
|
||
| } | ||
| /** | ||
| * wpsc_display_products_page function. | ||
| * wpsc_display_featured_products_page function. | ||
| * | ||
| * @access public | ||
| * @param mixed $query | ||
|
|
@@ -1514,7 +1516,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. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the "" get inadvertently escaped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is intended to be escaped, as it's displaying the code.