/** * If the user selected a geofence in the Filters Bar add-on, use it for the query filter. * @param $distance * * @return mixed */ public function setup_geofence_in_query($distance) { if (!empty($this->currentValue)) { $distance = tribe_convert_units($this->currentValue, 'miles', 'kms'); } return $distance; }
/** * Returns the formatted and converted distance from the db (always in kms.) to the unit selected * by the user in the 'defaults' tab of our settings. * * @param $distance_in_kms * * @return mixed * */ function tribe_get_distance_with_unit($distance_in_kms) { $tec = TribeEvents::instance(); $unit = $tec->getOption('geoloc_default_unit', 'miles'); $distance = round(tribe_convert_units($distance_in_kms, 'kms', $unit), 2); return apply_filters('tribe_formatted_distance', $distance . ' ' . $unit); }
/** * Returns the formatted and converted distance from the db (always in kms.) to the unit selected * by the user in the 'defaults' tab of our settings. * * @param $distance_in_kms * * @return mixed * @todo remove tribe_formatted_distance filter in 3.11 */ function tribe_get_distance_with_unit($distance_in_kms) { $tec = Tribe__Events__Main::instance(); $unit = $tec->getOption('geoloc_default_unit', 'miles'); $distance = round(tribe_convert_units($distance_in_kms, 'kms', $unit), 2); if (has_filter('tribe_formatted_distance')) { _deprecated_function("The 'tribe_formatted_distance' filter", '3.9', " the 'tribe_get_distance_with_unit' filter"); $distance = apply_filters('tribe_formatted_distance', $distance . ' ' . $unit); } return apply_filters('tribe_get_distance_with_unit', $distance, $distance_in_kms, $unit); }
/** * Returns the default geo fence size in kms. * @return mixed|void */ private function get_geofence_default_size() { $tec = TribeEvents::instance(); $geofence = $tec->getOption('geoloc_default_geofence', 25); $unit = $tec->getOption('geoloc_default_unit', 'miles'); //Our queries need the size always in kms $geofence = tribe_convert_units($geofence, $unit, 'kms'); return apply_filters('tribe_geoloc_geofence', $geofence); }
/** * Returns the geofence size in kms. * * @return mixed|void */ private function get_geofence_size() { $default = tribe_get_option('geoloc_default_geofence', 25); $geofence = apply_filters('tribe_geoloc_geofence', $default); $unit = tribe_get_option('geoloc_default_unit', 'miles'); // Ensure we use the correct internal unit of measure (kilometres) return tribe_convert_units($geofence, $unit, 'kms'); }