| Server IP : 216.250.13.251 / Your IP : 216.73.217.37 Web Server : nginx/1.24.0 System : Linux gunay 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : root ( 0) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/gunay/wp-content/plugins/rt19-extentions/inc/shortcodes/ |
Upload File : |
<?php
/*
*
* Google Map Shortcodes
*
*/
if( ! function_exists("rt_google_map") ){
/**
* Google Map Holder Shortcode
*
* @param array $atts
* @param string $content
* @return html $google_map
*/
function rt_google_map( $atts, $content = null ) {
global $rt_map_id, $rt_total_location, $rt_location_count, $rt_locations_output, $rt_zoom;
extract(shortcode_atts(array(
"map_id" => "map-".rand(100000, 1000000),
"height" => 300,
"zoom" => 3,
"class" => "",
"bwcolor" => ""
), $atts));
//fix map id if empty
$map_id = empty( $map_id ) ? 'map-'.rand(100000, 1000000) : $map_id ;
//class
$class = ! empty( $class ) ? ' '. $class : "";
//load google api
$api_key = get_theme_mod(RT_THEMESLUG.'_google_api_key');
if( ! empty( $api_key ) ){
$googlemaps_url = add_query_arg( 'key', urlencode( $api_key ), "//maps.googleapis.com/maps/api/js" );
wp_enqueue_script('googlemaps',$googlemaps_url,array(), '1.0.0');
}else{
wp_enqueue_script('googlemaps','//maps.googleapis.com/maps/api/js');
}
//find total location number
$total_location = substr_count($content,'[location');
//global values
$rt_map_id = $map_id;
$rt_total_location = $total_location;
$rt_location_count = 0; //reset counter
$rt_locations_output = ""; //reset locations_output
$rt_zoom = $zoom;
$rt_map_color = $bwcolor;
//content
$content = do_shortcode($content);
//output
$google_map = sprintf('<div class="google_map_holder%s" data-height="%s" data-scope="#%s" data-bw="%s">%s</div>',$class, $height, $map_id, $bwcolor, $content);
return $google_map;
}
}
if( ! function_exists("rt_map_location") ){
/**
* Google Map Single Location
*
* @param array $atts
* @param string $content
* @return html $js_output
*/
function rt_map_location( $atts, $content = null ) {
global $rt_map_id, $rt_total_location, $rt_location_count, $rt_locations_output, $rt_zoom;
extract(shortcode_atts(array(
"title" => "",
"lat" => 0,
"lon" => 0,
), $atts));
$rt_location_count++;
//locations_output
$new_rt_location = ! empty( $lat ) && ! empty( $lon ) ? sprintf('["%s", %s, %s, 4,"%s"],', addslashes($title), $lat, $lon, addslashes($content)) : "";
$rt_locations_output .= preg_replace('~[\r\n\t]+~', '', $new_rt_location );
if ( $rt_total_location == $rt_location_count) {
//js script to run
$js_output = sprintf('
<div id="%s" class="google_map"></div>
<script type="text/javascript">
/* <![CDATA[ */
// Runs google maps
jQuery(function() {
jQuery("#%s").rt_maps([%s],%s);
});
/* ]]> */
</script>
', $rt_map_id, $rt_map_id, $rt_locations_output,$rt_zoom);
return $js_output;
}
}
}
add_shortcode('google_maps', 'rt_google_map');
add_shortcode('location', 'rt_map_location');