Merge pull request #25180 from woocommerce/fix/24575

Fixed sorting order in shortcode
This commit is contained in:
Peter Fabian 2019-12-06 15:25:49 +01:00 committed by GitHub
commit c0ec976503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 18 deletions

View File

@ -115,8 +115,8 @@ class WC_Shortcode_Products {
'limit' => '-1', // Results limit.
'columns' => '', // Number of columns.
'rows' => '', // Number of rows. If defined, limit will be ignored.
'orderby' => 'title', // menu_order, title, date, rand, price, popularity, rating, or id.
'order' => 'ASC', // ASC or DESC.
'orderby' => '', // menu_order, title, date, rand, price, popularity, rating, or id.
'order' => '', // ASC or DESC.
'ids' => '', // Comma separated IDs.
'skus' => '', // Comma separated SKUs.
'category' => '', // Comma separated category slugs or ids.
@ -189,7 +189,7 @@ class WC_Shortcode_Products {
$query_args['order'] = $order;
if ( wc_string_to_bool( $this->attributes['paginate'] ) ) {
$this->attributes['page'] = absint( empty( $_GET['product-page'] ) ? 1 : $_GET['product-page'] ); // WPCS: input var ok, CSRF ok.
$this->attributes['page'] = absint( empty( $_GET['product-page'] ) ? 1 : $_GET['product-page'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
if ( ! empty( $this->attributes['rows'] ) ) {
@ -643,7 +643,7 @@ class WC_Shortcode_Products {
if ( wc_get_loop_prop( 'total' ) ) {
foreach ( $products->ids as $product_id ) {
$GLOBALS['post'] = get_post( $product_id ); // WPCS: override ok.
$GLOBALS['post'] = get_post( $product_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
setup_postdata( $GLOBALS['post'] );
// Set custom product visibility when quering hidden products.
@ -657,7 +657,7 @@ class WC_Shortcode_Products {
}
}
$GLOBALS['post'] = $original_post; // WPCS: override ok.
$GLOBALS['post'] = $original_post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
woocommerce_product_loop_end();
// Fire standard shop loop hooks when paginating results so we can show result counts and so on.

View File

@ -18,8 +18,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
$expected = array(
'limit' => '-1',
'columns' => 4,
'orderby' => 'title',
'order' => 'ASC',
'orderby' => '',
'order' => '',
'ids' => '',
'skus' => '',
'category' => '',
@ -84,9 +84,9 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'orderby' => 'title',
'orderby' => 'menu_order title',
'order' => 'ASC',
'posts_per_page' => '-1',
'posts_per_page' => -1,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'fields' => 'ids',
@ -125,9 +125,9 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'orderby' => 'title',
'orderby' => 'menu_order title',
'order' => 'ASC',
'posts_per_page' => '-1',
'posts_per_page' => -1,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'post__in' => array( '1', '2', '3' ),
@ -249,9 +249,9 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'orderby' => 'title',
'orderby' => 'menu_order title',
'order' => 'ASC',
'posts_per_page' => '1',
'posts_per_page' => 1,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'tax_query' => $tax_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
'p' => '1',
@ -465,7 +465,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'orderby' => 'title',
'orderby' => 'menu_order title',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
@ -493,7 +493,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'orderby' => 'title',
'orderby' => 'menu_order title',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
@ -528,7 +528,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'orderby' => 'title',
'orderby' => 'menu_order title',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
@ -565,7 +565,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'orderby' => 'title',
'orderby' => 'menu_order title',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
@ -598,7 +598,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'post_status' => 'publish',
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'orderby' => 'title',
'orderby' => 'menu_order title',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => $meta_query, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query