Settings'; // add the link to the list array_unshift($links, $settings_link); } return $links; } function enqueue_WP_GPX_Maps_scripts() { //wp_enqueue_script( 'jquery' ); wp_deregister_script( 'googleapis' ); wp_register_script( 'googleapis', 'https://maps.googleapis.com/maps/api/js?sensor=false&v=3.9', null, null); wp_enqueue_script( 'googleapis' ); wp_deregister_script( 'WP-GPX-Maps' ); wp_register_script( 'WP-GPX-Maps', plugins_url('/WP-GPX-Maps.js', __FILE__), array('jquery'), "1.1.26"); wp_enqueue_script( 'WP-GPX-Maps' ); wp_deregister_script( 'highcharts' ); wp_register_script( 'highcharts', plugins_url('/highcharts.js', __FILE__), array('jquery'), "2.2.1", true); wp_enqueue_script( 'highcharts' ); } function print_WP_GPX_Maps_scripts() { ?> lat) as $i) { $points_maps .= '['.(float)$points->lat[$i].','.(float)$points->lon[$i].'],'; $_ele = (float)$points->ele[$i]; $_dist = (float)$points->dist[$i]; if ($uom == '1') { // Miles and feet $_dist *= 0.000621371192; $_ele *= 3.2808399; } else if ($uom == '2') { // meters / kilometers $_dist = (float)($_dist / 1000); } $points_graph_dist .= $_dist.','; $points_graph_ele .= $_ele.','; if ($showSpeed == true) { $_speed = (float)$points->speed[$i]; // dafault m/s if ($uomspeed == '2') // miles/h { $_speed *= 2.2369362920544025; } else if ($uomspeed == '1') // km/h { $_speed *= 3.6; } $points_graph_speed .= $_speed.','; } if ($showHr == true) { $points_graph_hr .= $points->hr[$i].','; } if ($showCad == true) { $points_graph_cad .= $points->cad[$i].','; } } if ($showW == true) { $wpoints = getWayPoints($gpx); foreach ($wpoints as $p) { $waypoints .= '['.(float)$p[0].','.(float)$p[1].',\''.unescape($p[4]).'\',\''.unescape($p[5]).'\',\''.unescape($p[7]).'\'],'; } } $p="/,$/"; $points_maps = preg_replace($p, "", $points_maps); $points_graph_dist = preg_replace($p, "", $points_graph_dist); $points_graph_ele = preg_replace($p, "", $points_graph_ele); $points_graph_speed = preg_replace($p, "", $points_graph_speed); $points_graph_hr = preg_replace($p, "", $points_graph_hr); $points_graph_cad = preg_replace($p, "", $points_graph_cad); $waypoints = preg_replace($p, "", $waypoints); if (preg_match("/^(0,?)+$/", $points_graph_dist)) $points_graph_dist = ""; if (preg_match("/^(0,?)+$/", $points_graph_ele)) $points_graph_ele = ""; if (preg_match("/^(0,?)+$/", $points_graph_speed)) $points_graph_speed = ""; if (preg_match("/^(0,?)+$/", $points_graph_hr)) $points_graph_hr = ""; if (preg_match("/^(0,?)+$/", $points_graph_cad)) $points_graph_cad = ""; } $ngimgs_data = ''; if ( $ngGalleries != '' || $ngImages != '' ) { $ngimgs = getNGGalleryImages($ngGalleries, $ngImages, $error); $ngimgs_data =''; foreach ($ngimgs as $img) { $data = $img['data']; $data = str_replace("\n","",$data); $ngimgs_data .= ''.$data.''; } } @file_put_contents($gpxcache, serialize(array( "points_maps" => $points_maps, "points_graph_dist" => $points_graph_dist, "points_graph_ele" => $points_graph_ele, "points_graph_speed" => $points_graph_speed, "points_graph_hr" => $points_graph_hr, "points_graph_cad" => $points_graph_cad, "waypoints" => $waypoints) ), LOCK_EX); @chmod($gpxcache,0755); $output = '
'. $error .' '; if ($download=='true' && $gpxurl != '') { if ($isGpxUrl == true) { } else { $gpxurl = get_bloginfo('url').$gpxurl; } $output.="".__("Download", "wp-gpx-maps").""; } return $output; } function downloadRemoteFile($remoteFile) { try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $remoteFile); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); $resp = curl_exec($ch); curl_close($ch); $tmpfname = tempnam ( '/tmp', 'gpx' ); $fp = fopen($tmpfname, "w"); fwrite($fp, $resp); fclose($fp); return $tmpfname; } catch (Exception $e) { return ''; } } function unescape($value) { $value = str_replace("'", "\'", $value); $value = str_replace(array("\n","\r"), "", $value); return $value; } function WP_GPX_Maps_install() { add_option("wpgpxmaps_width", '100%', '', 'yes'); add_option("wpgpxmaps_graph_height", '200px', '', 'yes'); add_option("wpgpxmaps_height", '450px', '', 'yes'); add_option('wpgpxmaps_map_type','HYBRID','','yes'); add_option('wpgpxmaps_show_waypoint','','','yes'); add_option('wpgpxmaps_show_speed','','','yes'); add_option('wpgpxmaps_pointsoffset','10','','yes'); add_option('wpgpxmaps_donotreducegpx','true','','yes'); add_option("wpgpxmaps_unit_of_measure", '0', '', 'yes'); add_option("wpgpxmaps_unit_of_measure_speed", '0', '', 'yes'); add_option("wpgpxmaps_graph_line_color", '#3366cc', '', 'yes'); add_option("wpgpxmaps_graph_line_color_speed", '#ff0000', '', 'yes'); add_option("wpgpxmaps_map_line_color", '#3366cc', '', 'yes'); add_option("wpgpxmaps_graph_line_color_cad", '#beecff', '', 'yes'); add_option("wpgpxmaps_graph_offset_from1", '', '', 'yes'); add_option("wpgpxmaps_graph_offset_to1", '', '', 'yes'); add_option("wpgpxmaps_graph_offset_from2", '', '', 'yes'); add_option("wpgpxmaps_graph_offset_to2", '', '', 'yes'); add_option("wpgpxmaps_map_start_icon", '', '', 'yes'); add_option("wpgpxmaps_map_end_icon", '', '', 'yes'); add_option("wpgpxmaps_map_current_icon", '', '', 'yes'); add_option("wpgpxmaps_map_waypoint_icon", '', '', 'yes'); add_option("wpgpxmaps_map_nggallery", '', '', 'yes'); add_option("wpgpxmaps_show_hr", '', '', 'yes'); add_option("wpgpxmaps_graph_line_color_hr", '#ff77bd', '', 'yes'); add_option('wpgpxmaps_show_cadence','','','yes'); add_option('wpgpxmaps_zoomonscrollwheel','','','yes'); add_option('wpgpxmaps_download','','','yes'); } function WP_GPX_Maps_remove() { delete_option('wpgpxmaps_width'); delete_option('wpgpxmaps_graph_height'); delete_option('wpgpxmaps_height'); delete_option('wpgpxmaps_map_type'); delete_option('wpgpxmaps_show_waypoint'); delete_option('wpgpxmaps_show_speed'); delete_option('wpgpxmaps_pointsoffset'); delete_option('wpgpxmaps_donotreducegpx'); delete_option('wpgpxmaps_unit_of_measure'); delete_option('wpgpxmaps_unit_of_measure_speed'); delete_option('wpgpxmaps_graph_line_color'); delete_option('wpgpxmaps_map_line_color'); delete_option('wpgpxmaps_graph_line_color_speed'); delete_option('wpgpxmaps_graph_offset_from1'); delete_option('wpgpxmaps_graph_offset_to1'); delete_option('wpgpxmaps_graph_offset_from2'); delete_option('wpgpxmaps_graph_offset_to2'); delete_option('wpgpxmaps_map_start_icon'); delete_option('wpgpxmaps_map_end_icon'); delete_option('wpgpxmaps_map_current_icon'); delete_option('wpgpxmaps_map_waypoint_icon'); delete_option('wpgpxmaps_map_nggallery'); delete_option('wpgpxmaps_show_hr'); delete_option('wpgpxmaps_graph_line_color_hr'); delete_option('wpgpxmaps_show_cadence'); delete_option('wpgpxmaps_graph_line_color_cad'); delete_option('wpgpxmaps_zoomonscrollwheel'); delete_option('wpgpxmaps_download'); } ?>