Function Reference: geodir_cpt_allowed_location_where

Summary

Filter whether search by location allowed for CPT.

Global Values

$plugin_prefix
(string) (required) Geodirectory plugin table prefix.

Default: None

Parameters

$allowed
(bool) (required) True if search by location allowed. Otherwise false.

Default: None
$gd_wp_query_vars
(object) (required) WP_Query query vars object.

Default: None
$gd_table
(string) (required) Listing database table name.

Default: None
$gd_wp_query
(object) (required) WP_Query query object.

Default: None
$gd_p_table
(string) (required) Listing database table name.

Default: None

Return Values

(bool)
  • True if search by location allowed.
  • Otherwise false.

Change Log

Since: 1.1.6

Source File

geodir_cpt_allowed_location_where() is located in geodir_custom_posts/geodir_cp_functions.php [Line: 1157]

Source Code

function geodir_cpt_allowed_location_where( $allowed, $gd_wp_query_vars, $gd_table, $gd_wp_query, $gd_p_table = '' ) {
	global $plugin_prefix;
	
	$gd_post_type = !empty( $gd_wp_query_vars ) && isset( $gd_wp_query_vars['post_type'] ) && $gd_wp_query_vars['post_type'] != '' ? $gd_wp_query_vars['post_type'] : '';
	
	if ( $gd_table != '' || $gd_p_table != '' ) {
		$gd_posttypes = geodir_get_posttypes();
		
		$gd_table = $gd_p_table != '' ? $gd_p_table : $gd_table;
		
		foreach ( $gd_posttypes as $gd_posttype ) {
			if ( $gd_table == $plugin_prefix . $gd_posttype . '_detail' ) {
				$gd_post_type = $gd_posttype;
			}
		}
	}
	
	if ( geodir_cpt_no_location( $gd_post_type ) ) {
		$allowed = false;
	}
	
	return $allowed;
}