Function Reference: geodir_function_widget_listings_where
Summary
Listing query where clause SQL part for widgets.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
- $plugin_prefix
- (string) (required) Geodirectory plugin table prefix.
- Default: None
Package
GeoDirectory
Parameters
- $where
- (string) (required) Where clause SQL.
- Default: None
Return Values
- (string)
- Modified where clause SQL.
Change Log
Since: 1.0.0
1.6.18 New attributes added in gd_listings shortcode to filter user favorite listings.
Source File
geodir_function_widget_listings_where() is located in geodirectory-functions/general_functions.php [Line: 2513]
Source Code
function geodir_function_widget_listings_where( $where ) { global $wpdb, $plugin_prefix, $gd_query_args_widgets; $query_args = $gd_query_args_widgets; if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) { return $where; } $post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type']; $table = $plugin_prefix . $post_type . '_detail'; if ( ! empty( $query_args ) ) { if ( ! empty( $query_args['gd_location'] ) && function_exists( 'geodir_default_location_where' ) ) { $where = geodir_default_location_where( $where, $table ); } if ( ! empty( $query_args['post_author'] ) ) { $where .= " AND " . $wpdb->posts . ".post_author = " . (int) $query_args['post_author']; } if ( ! empty( $query_args['show_featured_only'] ) ) { $where .= " AND " . $table . ".is_featured = '1'"; } if ( ! empty( $query_args['show_special_only'] ) ) { $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; } if ( ! empty( $query_args['with_pics_only'] ) ) { $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL "; } if ( ! empty( $query_args['featured_image_only'] ) ) { $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' "; } if ( ! empty( $query_args['with_videos_only'] ) ) { $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; } if ( ! empty( $query_args['show_favorites_only'] ) ) { $user_favorites = '-1'; if ( !empty( $query_args['favorites_by_user'] ) ) { $site_id = ''; if ( is_multisite() ) { $blog_id = get_current_blog_id(); if($blog_id && $blog_id!='1'){$site_id = '_' . $blog_id ;} } $user_favorites = geodir_get_user_favourites( (int)$query_args['favorites_by_user'] ); $user_favorites = !empty($user_favorites) && is_array($user_favorites) ? implode("','", $user_favorites) : '-1'; } $where .= " AND `" . $wpdb->posts . "`.`ID` IN('" . $user_favorites . "')"; } if ( ! empty( $query_args['tax_query'] ) ) { $tax_queries = get_tax_sql( $query_args['tax_query'], $wpdb->posts, 'ID' ); if ( ! empty( $tax_queries['join'] ) && ! empty( $tax_queries['where'] ) ) { $where .= $tax_queries['where']; } } } return $where; }