LLMS_REST_Webhooks_Query::sql_where()
SQL “where” clause for the query
Return Return
(string)
Source Source
File: libraries/lifterlms-rest/includes/class-llms-rest-webhooks-query.php
protected function sql_where() {
global $wpdb;
$sql = 'WHERE 1';
// "IN" clauses for id fields.
$ids_include = array(
'include' => 'id',
);
foreach ( $ids_include as $query_key => $db_key ) {
$ids = $this->get( $query_key );
if ( $ids ) {
$prepared = implode( ',', $ids );
$sql .= " AND {$db_key} IN ({$prepared})";
}
}
// "NOT IN" clauses for id fields.
$ids_exclude = array(
'exclude' => 'id',
);
foreach ( $ids_exclude as $query_key => $db_key ) {
$ids = $this->get( $query_key );
if ( $ids ) {
$prepared = implode( ',', $ids );
$sql .= " AND {$db_key} NOT IN ({$prepared})";
}
}
// Status match.
$status = $this->get( 'status' );
if ( $status ) {
$sql .= $wpdb->prepare( ' AND status = %s', $status );
}
if ( $this->get( 'suppress_filters' ) ) {
return $sql;
}
/**
* Filters the query WHERE clause
*
* @since 1.0.0-beta.1
*
* @param string $sql The WHERE clause of the query.
* @param LLMS_REST_Webhooks_Query $webhooks_query Instance of LLMS_REST_Webhooks_Query.
*/
return apply_filters( 'llms_rest_webhook_query_where', $sql, $this );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0-beta.16 | Drop usage of $this->get_filter('where') in favor of 'llms_rest_webhook_query_where'. |
| 1.0.0-beta.1 | Introduced. |