Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-directory into dev
  • Loading branch information
andrewlimaza committed Feb 19, 2024
2 parents 4760a2d + bbd72d0 commit abcaf1c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion templates/directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ function pmpromd_shortcode($atts, $content=null, $code="")
else
$s = "";

// Set the default order value to be either ASC or DESC.
if ( $order !== 'DESC' ) {
$order = 'ASC';
}

if(isset($_REQUEST['pn']))
$pn = intval($_REQUEST['pn']);
else
Expand All @@ -107,7 +112,9 @@ function pmpromd_shortcode($atts, $content=null, $code="")

$sql_parts['GROUP'] = "GROUP BY u.ID ";

$sql_parts['ORDER'] = "ORDER BY ". esc_sql($order_by) . " " . $order . " ";
// Clean up order_by to only include text, underscores and periods.
$order_by = preg_replace( '/[^a-z._]/', '', $order_by );
$sql_parts['ORDER'] = "ORDER BY ". esc_sql( $order_by ) . " " . esc_sql( $order ) . " ";

$sql_parts['LIMIT'] = "LIMIT $start, $limit";

Expand Down Expand Up @@ -136,6 +143,7 @@ function pmpromd_shortcode($atts, $content=null, $code="")

// If levels are passed in.
if ( $levels ) {
$levels = preg_replace('/[^0-9,]/', '', $levels ); // Only allow commas and numeric values.
$sql_parts['WHERE'] .= "AND mu.membership_id IN(" . esc_sql($levels) . ") ";
}

Expand Down

0 comments on commit abcaf1c

Please sign in to comment.