Skip to content

Commit

Permalink
Correct how $order and $orderby are used.
Browse files Browse the repository at this point in the history
$order contains the sort direction: ASC or DESC.
$orderby contains the column names to sort on.
  • Loading branch information
pondermatic committed May 10, 2019
1 parent 63fc98d commit 289eb5f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions includes/class.llms.query.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ public function pre_get_posts( $query ) {

$sorting = explode( ',', get_option( 'lifterlms_shop_ordering', 'menu_order,ASC' ) );

$order = empty( $sorting[0] ) ? 'menu_order' : $sorting[0];
if ( 'menu_order' === $order ) {
$order .= ' post_title';
$orderby = empty( $sorting[0] ) ? 'menu_order' : $sorting[0];
if ( 'menu_order' === $orderby ) {
$orderby .= ' post_title';
}
$orderby = empty( $sorting[1] ) ? 'ASC' : $sorting[1];
$order = empty( $sorting[1] ) ? 'ASC' : $sorting[1];

$query->set( 'orderby', apply_filters( 'llms_courses_orderby', $order ) );
$query->set( 'order', apply_filters( 'llms_courses_order', $orderby ) );
$query->set( 'orderby', apply_filters( 'llms_courses_orderby', $orderby ) );
$query->set( 'order', apply_filters( 'llms_courses_order', $order ) );

$modify_tax_query = true;

Expand All @@ -210,14 +210,14 @@ public function pre_get_posts( $query ) {

$sorting = explode( ',', get_option( 'lifterlms_memberships_ordering', 'menu_order,ASC' ) );

$order = empty( $sorting[0] ) ? 'menu_order' : $sorting[0];
if ( 'menu_order' === $order ) {
$order .= ' post_title';
$orderby = empty( $sorting[0] ) ? 'menu_order' : $sorting[0];
if ( 'menu_order' === $orderby ) {
$orderby .= ' post_title';
}
$orderby = empty( $sorting[1] ) ? 'ASC' : $sorting[1];
$order = empty( $sorting[1] ) ? 'ASC' : $sorting[1];

$query->set( 'orderby', apply_filters( 'llms_memberships_orderby', $order ) );
$query->set( 'order', apply_filters( 'llms_memberships_order', $orderby ) );
$query->set( 'orderby', apply_filters( 'llms_memberships_orderby', $orderby ) );
$query->set( 'order', apply_filters( 'llms_memberships_order', $order ) );

$modify_tax_query = true;

Expand Down

0 comments on commit 289eb5f

Please sign in to comment.