Function Reference: geodir_get_loc_term_count
Summary
Get term count for a location.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
Package
GeoDirectory_Location_Manager
Parameters
- $count_type
- (string) (required) Count type. Possible values are ‘review_count’, ‘term_count’.
- Default: None
- $location_name
- (null|string) (required) Location name slug. Ex: new-york.
- Default: None
- $location_type
- (null|string) (required) Location type. Possible values ‘gd_city’,’gd_region’,’gd_country’.
- Default: None
- $force_update
- (bool) (required) Do you want to force update? default: false.
- Default: None
- $loc
- (bool|array) (required) {
Attributes of the location array. @type string $gd_country The country slug. @type string $gd_region The region slug. @type string $gd_city The city slug. }.- Default: None
Return Values
- (array|mixed|void)
Change Log
Since: 1.0.0
Source File
geodir_get_loc_term_count() is located in geodir_location_manager/geodir_count_functions.php [Line: 196]
Source Code
function geodir_get_loc_term_count($count_type = 'term_count', $location_name=null, $location_type=null, $force_update=false, $loc=false ) { //accepted count type: term_count, review_count global $wpdb; if (!$location_name || !$location_type) { $loc = geodir_get_current_location_terms(); if (isset($loc['gd_city']) && $loc['gd_city'] != '') { $location_name = $loc['gd_city']; $location_type = 'gd_city'; } elseif (isset($loc['gd_region']) && $loc['gd_region'] != '') { $location_name = $loc['gd_region']; $location_type = 'gd_region'; } elseif (isset($loc['gd_country']) && $loc['gd_country'] != '') { $location_name = $loc['gd_country']; $location_type = 'gd_country'; } } if ($location_name && $location_type) { $sql = $wpdb->prepare( "SELECT * FROM " . GEODIR_TERM_META . " WHERE location_type=%s AND location_name=%s LIMIT 1", array( $location_type, $location_name ) ); $row = $wpdb->get_row( $sql ); if ( $row ) { if ( $force_update || !$row->$count_type) { return geodir_insert_term_count_by_loc( $location_name, $location_type, $count_type, $row->id,$loc ); } else { $data = unserialize( $row->$count_type ); return $data; } } else { return geodir_insert_term_count_by_loc( $location_name, $location_type, $count_type,null,$loc ); } } else { return; } }