Function Reference: geodir_term_slug_is_exists
Summary
Check whether a term slug exists or not.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
- $table_prefix
- (string) (required) WordPress Database Table prefix.
- Default: None
Package
GeoDirectory
Parameters
- $slug_exists
- (bool) (required)
- Default: : false
- $slug
- (string) (required) Term slug.
- Default: None
- $term_id
- (int) (required) The term ID.
- Default: None
Return Values
- (bool)
- true when exists.
- false when not exists.
Change Log
Since: 1.0.0
Source File
geodir_term_slug_is_exists() is located in geodirectory_hooks_actions.php [Line: 1809]
Used by
geodirectory/geodirectory_hooks_actions.php: geodir_update_term_slug() [Line: 1760]
geodirectory/geodirectory_hooks_actions.php: geodir_update_term_slug() [Line: 1769]
Source Code
function geodir_term_slug_is_exists($slug_exists, $slug, $term_id) { global $wpdb, $table_prefix; $default_location = geodir_get_default_location(); $country_slug = $default_location->country_slug; $region_slug = $default_location->region_slug; $city_slug = $default_location->city_slug; if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) return $slug_exists = true; if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) return $slug_exists = true; return $slug_exists; }