Skip to content

Commit

Permalink
New filters
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
ajaydsouza committed Jul 28, 2023
1 parent 6aaf4b9 commit 219b2a7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
60 changes: 60 additions & 0 deletions includes/frontend/class-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,66 @@ public static function get_popular_author_ids( $args = array() ) {
$groupby = " GROUP BY {$groupby} ";
$orderby = " ORDER BY {$orderby} ";

/**
* Filters the SELECT clause of the query.
*
* @since 1.2.0
*
* @param string $fields The SELECT clause of the query.
* @param array $args Arguments array.
*/
$fields = apply_filters_ref_array( 'wzpa_query_fields', array( $fields, $args ) );

/**
* Filters the JOIN clause of the query.
*
* @since 1.2.0
*
* @param string $join The JOIN clause of the query.
* @param array $args Arguments array.
*/
$join = apply_filters_ref_array( 'wzpa_query_join', array( $join, $args ) );

/**
* Filters the WHERE clause of the query.
*
* @since 1.2.0
*
* @param string $where The WHERE clause of the query.
* @param array $args Arguments array.
*/
$where = apply_filters_ref_array( 'wzpa_query_where', array( $where, $args ) );

/**
* Filters the GROUP BY clause of the query.
*
* @since 1.2.0
*
* @param string $groupby The GROUP BY clause of the query.
* @param array $args Arguments array.
*/
$groupby = apply_filters_ref_array( 'wzpa_query_groupby', array( $groupby, $args ) );

/**
* Filters the ORDER BY clause of the query.
*
* @since 1.2.0
*
* @param string $orderby The ORDER BY clause of the query.
* @param array $args Arguments array.
*/
$orderby = apply_filters_ref_array( 'wzpa_query_orderby', array( $orderby, $args ) );

/**
* Filters the LIMIT clause of the query.
*
* @since 1.2.0
*
* @param string $limits The LIMIT clause of the query.
* @param array $args Arguments array.
*/
$limits = apply_filters_ref_array( 'wzpa_query_limits', array( $limits, $args ) );

// Create the mySQL statement.
$sql = "SELECT $fields FROM {$wpdb->users} $join WHERE 1=1 $where $groupby $orderby $limits";

Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ Use `[wzpa_popular_authors]` to display the popular authors. Check [this knowled

Popular Authors has been rewritten to use classes and autoloading.

* Features:
* New filters: `wzpa_query_fields`, `wzpa_query_join`, `wzpa_query_where`, `wzpa_query_groupby`, `wzpa_query_orderby` and `wzpa_query_limits` to modify the Popular Authors mySQL query

= 1.1.1 =

* Security fix in block
Expand Down

0 comments on commit 219b2a7

Please sign in to comment.