map_id = "cpm_".wp_generate_password(6, false); $this->lang_array = array( "ar"=>__("ARABIC","codepeople-post-map"), "eu"=>__("BASQUE","codepeople-post-map"), "bg"=>__("BULGARIAN","codepeople-post-map"), "bn"=>__("BENGALI","codepeople-post-map"), "ca"=>__("CATALAN","codepeople-post-map"), "cs"=>__("CZECH","codepeople-post-map"), "da"=>__("DANISH","codepeople-post-map"), "de"=>__("GERMAN","codepeople-post-map"), "el"=>__("GREEK","codepeople-post-map"), "en"=>__("ENGLISH","codepeople-post-map"), "en-AU"=>__("ENGLISH (AUSTRALIAN)","codepeople-post-map"), "en-GB"=>__("ENGLISH (GREAT BRITAIN)","codepeople-post-map"), "es"=>__("SPANISH","codepeople-post-map"), "eu"=>__("BASQUE","codepeople-post-map"), "fa"=>__("FARSI","codepeople-post-map"), "fi"=>__("FINNISH","codepeople-post-map"), "fil"=>__("FILIPINO","codepeople-post-map"), "fr"=>__("FRENCH","codepeople-post-map"), "gl"=>__("GALICIAN","codepeople-post-map"), "gu"=>__("GUJARATI","codepeople-post-map"), "hi"=>__("HINDI","codepeople-post-map"), "hr"=>__("CROATIAN","codepeople-post-map"), "hu"=>__("HUNGARIAN","codepeople-post-map"), "id"=>__("INDONESIAN","codepeople-post-map"), "it"=>__("ITALIAN","codepeople-post-map"), "iw"=>__("HEBREW","codepeople-post-map"), "ja"=>__("JAPANESE","codepeople-post-map"), "kn"=>__("KANNADA","codepeople-post-map"), "ko"=>__("KOREAN","codepeople-post-map"), "lt"=>__("LITHUANIAN","codepeople-post-map"), "lv"=>__("LATVIAN","codepeople-post-map"), "ml"=>__("MALAYALAM","codepeople-post-map"), "mr"=>__("MARATHI","codepeople-post-map"), "nl"=>__("DUTCH","codepeople-post-map"), "no"=>__("NORWEGIAN","codepeople-post-map"), "or"=>__("ORIYA","codepeople-post-map"), "pl"=>__("POLISH","codepeople-post-map"), "pt"=>__("PORTUGUESE","codepeople-post-map"), "pt-BR"=>__("PORTUGUESE (BRAZIL)","codepeople-post-map"), "pt-PT"=>__("PORTUGUESE (PORTUGAL)","codepeople-post-map"), "ro"=>__("ROMANIAN","codepeople-post-map"), "ru"=>__("RUSSIAN","codepeople-post-map"), "sk"=>__("SLOVAK","codepeople-post-map"), "sl"=>__("SLOVENIAN","codepeople-post-map"), "sr"=>__("SERBIAN","codepeople-post-map"), "sv"=>__("SWEDISH","codepeople-post-map"), "tl"=>__("TAGALOG","codepeople-post-map"), "ta"=>__("TAMIL","codepeople-post-map"), "te"=>__("TELUGU","codepeople-post-map"), "th"=>__("THAI","codepeople-post-map"), "tr"=>__("TURKISH","codepeople-post-map"), "uk"=>__("UKRAINIAN","codepeople-post-map"), "vi"=>__("VIETNAMESE","codepeople-post-map"), "zh-CN"=>__("CHINESE (SIMPLIFIED)","codepeople-post-map"), "zh-TW"=>__("CHINESE (TRADITIONAL)","codepeople-post-map") ); } // End __construct function array_map_recursive($callback, $array) { foreach ($array as $key => $value) { if (is_array($array[$key])) { $array[$key] = $this->array_map_recursive($callback, $array[$key]); } else { $array[$key] = call_user_func($callback, $array[$key]); } } return $array; } function sanitize_coord( $v ) { if ( ! is_string( $v ) && ! is_numeric( $v ) ) return ''; $v = trim( (string) $v ); return preg_match( '/^-?\d{1,3}(\.\d+)?$/', $v ) ? $v : ''; } // End sanitize_coord function sanitize_description( $v ) { if ( ! is_string( $v ) ) return ''; return wp_kses_post( $v ); } // End sanitize_description //---------- CREATE MAP ---------- /** * Save a map object in database * called by the action save_post */ function save_map($post_id){ // authentication checks // make sure data came from our meta box if (!isset($_POST['cpm_map_noncename']) || !wp_verify_nonce($_POST['cpm_map_noncename'],__FILE__)) return $post_id; // check user permissions if (isset($_POST['post_type'] ) && $_POST['post_type'] == 'page'){ if (!current_user_can('publish_pages')) return $post_id; } else{ if (!current_user_can('publish_posts')) return $post_id; } // authentication passed, save data $default_icon = ( !empty( $_POST['default_icon'] ) ) ? sanitize_text_field( wp_unslash( $_POST['default_icon'] ) ) : $this->get_configuration_option('default_icon'); delete_post_meta($post_id,'cpm_point'); delete_post_meta($post_id,'cpm_map'); $new_cpm_point = ( isset( $_POST['cpm_point'] ) && is_array( $_POST['cpm_point'] ) ) ? wp_unslash( $_POST['cpm_point'] ) : array(); $new_cpm_map = ( isset( $_POST['cpm_map'] ) && is_array( $_POST['cpm_map'] ) ) ? wp_unslash( $_POST['cpm_map'] ) : array(); $new_cpm_map = $this->array_map_recursive('sanitize_text_field', $new_cpm_map); // Per-field sanitization (storage layer hardening). // Runs unconditionally - never gated by $new_cpm_map['single']. $new_cpm_point['address'] = isset( $new_cpm_point['address'] ) ? sanitize_text_field( $new_cpm_point['address'] ) : ''; $new_cpm_point['name'] = isset( $new_cpm_point['name'] ) ? sanitize_text_field( $new_cpm_point['name'] ) : ''; $new_cpm_point['description'] = isset( $new_cpm_point['description'] ) ? $this->sanitize_description( $new_cpm_point['description'] ) : ''; $new_cpm_point['latitude'] = isset( $new_cpm_point['latitude'] ) ? $this->sanitize_coord( $new_cpm_point['latitude'] ) : ''; $new_cpm_point['longitude'] = isset( $new_cpm_point['longitude'] ) ? $this->sanitize_coord( $new_cpm_point['longitude'] ) : ''; $new_cpm_point['thumbnail'] = isset( $new_cpm_point['thumbnail'] ) ? esc_url_raw( $new_cpm_point['thumbnail'], array( 'http', 'https' ) ) : ''; $new_cpm_point['icon'] = str_replace( CPM_PLUGIN_URL, '', $default_icon ); // Set the map's config $new_cpm_map['single'] = (isset($new_cpm_map['single'])) ? true : false; if($new_cpm_map['single']){ $new_cpm_map['zoompancontrol'] = (! empty( $new_cpm_map['zoompancontrol'] ) && $new_cpm_map['zoompancontrol'] == true); $new_cpm_map['fullscreencontrol'] = (! empty( $new_cpm_map['fullscreencontrol'] ) && $new_cpm_map['fullscreencontrol'] == true); $new_cpm_map['mousewheel'] = (! empty( $new_cpm_map['mousewheel'] ) && $new_cpm_map['mousewheel'] == true); $new_cpm_map['typecontrol'] = (! empty( $new_cpm_map['typecontrol'] ) && $new_cpm_map['typecontrol'] == true); $new_cpm_map['streetviewcontrol'] = (! empty( $new_cpm_map['streetviewcontrol'] ) && $new_cpm_map['streetviewcontrol'] == true); $new_cpm_map['trafficlayer'] = (! empty( $new_cpm_map['trafficlayer'] ) && $new_cpm_map['trafficlayer'] == true); $new_cpm_map['dynamic_zoom'] = (isset($new_cpm_map['dynamic_zoom']) && $new_cpm_map['dynamic_zoom']) ? true : false; $new_cpm_map['show_default'] = (isset($new_cpm_map['show_default']) && $new_cpm_map['show_default']) ? true : false; $new_cpm_map['show_window'] = (isset($new_cpm_map['show_window']) && $new_cpm_map['show_window']) ? true : false; $new_cpm_map['drag_map'] = (isset($new_cpm_map['drag_map']) && $new_cpm_map['drag_map']) ? true : false; add_post_meta($post_id,'cpm_map',$new_cpm_map,TRUE); } // The address is required, if address is empty the couple: latitude, longitude must be defined if(!(empty($new_cpm_point['latitude']) || empty($new_cpm_point['longitude']))){ add_post_meta($post_id,'cpm_point',$new_cpm_point,TRUE); } } // End save_map //---------- OPTIONS FOR CODEPEOPLE POST MAP ---------- /** * Get default configuration options */ function _default_configuration( $attr = '' ){ $default = array( 'zoom' => '10', 'dynamic_zoom' => false, 'width' => '450', 'height' => '450', 'margin' => '10', 'align' => 'center', 'language' => 'en', 'drag_map' => true, 'icons' => array(), 'default_icon' => CPM_PLUGIN_URL.'/images/icons/marker.png', 'type' => 'ROADMAP', 'points' => 3, 'display' => 'map', 'mousewheel' => true, 'zoompancontrol' => true, 'fullscreencontrol' => true, 'typecontrol' => true, 'streetviewcontrol' => true, 'trafficlayer' => false, 'highlight' => true, 'highlight_class' => 'cpm_highlight', 'tooltip' => 'title', 'show_window' => true, 'show_default' => true, 'wpml' => 'all', 'windowhtml' => "
To use your own markers icons, you only should to upload the icons images to the following location:
/wp-content/plugins/codepeople-post-map/images/icons
and then select the icon's image from the list
[ + less information]
contact page and leave us a message.', 'codepeople-post-map'); ?>
Administration area: Click to access the administration area demo
Public page: Click to access the CodePeople Post Map for Google Maps', 'codepeople-post-map' ); ?>
|
⬐ https://developers.google.com/maps/documentation/javascript/get-api-key
: |
|
| /> | |
|
[ + more information]
To insert the map in a responsive design (in a responsive design, the map's width should be adjusted with the page width): the value of map's width should be defined as a percentage of container's width, for example, type the value: 100% [ + less information] |
|
| _deploy_languages($options); ?> | |
| /> | |
| > | |
| > | |
|
/> /> /> |
|
| > | |
|
Click Here', 'codepeople-post-map' ); ?> |
|
|
Click Here', 'codepeople-post-map' ); ?> |
|
|
Click Here', 'codepeople-post-map' ); ?> |
|
|
Click Here', 'codepeople-post-map' ); ?> |
|
|
Click Here', 'codepeople-post-map' ); ?> |
|
|
Click Here', 'codepeople-post-map' ); ?> |
|
|
Click Here', 'codepeople-post-map' ); ?> |
|
|
Click Here', 'codepeople-post-map' ); ?> |
|
|
The route between points is available only for the commercial version of plugin. Click Here |
|
| > | |
|
/>
/> /> /> /> |
|
|
|
| This feature is available only in commercial version of plugin. Click Here | |
CodePeople Post Map plugin page', 'codepeople-post-map'); ?>
contact page and leave us a message.', 'codepeople-post-map'); ?>
:
|
It is possible to insert a link to another page in the infowindow associated to the point. Type the link tag to the other page in the point description box, similar to: <a href="http://wordpress.dwbooster.com" >CLICK HERE </a> |
|||||||||||
| " id="cpm_point_thumbnail" /> | |||||||||||
|
|||||||||||
| _deploy_icons($options); ?> | |||||||||||
"insert the map tag" button and save the post/page modifications.', 'codepeople-post-map' ); ?>
shape on map?', 'codepeople-post-map' );
?>
Click Here', 'codepeople-post-map' ); ?>
|
[ + more information]
It is possible to use attributes in the shortcode, like: width, height, zoom and the other maps attributes:
[codepeople-post-map width="450" height="500"] The premium version of plugin allows to use a special attribute "cat" (referent to category), to display all points created in a category: [codepeople-post-map cat="35"] or all points on website, using as category ID the value "-1" [codepeople-post-map cat="-1"] The special attribute "tag", allow to display all points that belong to the posts with a specific tag assigned, for example "mytag": [codepeople-post-map tag="mytag"] ', 'codepeople-post-map' ); ?> |
Click Here', 'codepeople-post-map' ); ?> |
ID, 'cpm_point', TRUE); if(is_string($cpm_point) && preg_match('/^a:\d+:\{/', $cpm_point)){ $tmp = @unserialize($cpm_point, array('allowed_classes' => false)); $cpm_point = ( is_array($tmp) ) ? $tmp : array(); }elseif(!is_array($cpm_point)){ $cpm_point = array(); } $cpm_map = get_post_meta($post->ID, 'cpm_map', TRUE); $general_options = $this->get_configuration_option(); $options = array_merge((array)$general_options, (array)$cpm_point, (array)$cpm_map); $options['post_id'] = $post->ID; $this->_print_form($options); } // End insert_form //---------- LOADING RESOURCES ---------- /* * Load the required scripts and styles for ADMIN section of website */ function load_admin_resources(){ wp_enqueue_style( 'admin_cpm_style', CPM_PLUGIN_URL.'/styles/cpm-admin-styles.css' ); wp_enqueue_script( 'admin_cpm_script', CPM_PLUGIN_URL.'/js/cpm.admin.js', array('jquery'), null, true ); $cpm_global = array(); $api_key = $this->get_configuration_option( 'api_key' ); if( !empty( $api_key ) ) { $cpm_global[ 'api_key' ] = trim($api_key); } wp_localize_script('admin_cpm_script', 'cpm_global', $cpm_global); } // End load_admin_resources /** * Loads the scripts required to integrate the plugin with the Gutenberg Editor. */ function load_gutenberg_code(){ global $post; wp_enqueue_style('cpm-admin-gutenberg-editor-css', CPM_PLUGIN_URL.'/styles/cpm-gutenberg.css'); if(!empty($post)) $url = get_preview_post_link($post->ID); else $url = rtrim( get_home_url( get_current_blog_id() ), "/" ).( ( strpos( get_current_blog_id(), '?' ) === false ) ? "/" : "" ); $nonce = !empty($post) ? wp_create_nonce('cpm-preview-'.$post->ID) : ''; $url .= ((strpos($url, '?') === false) ? '?' : '&') . 'cpm_preview_nonce=' . urlencode($nonce) .'&cpm-preview='; $config = array('url' => $url); wp_enqueue_script('cpm-gutenberg-editor', CPM_PLUGIN_URL.'/js/gutenberg.js'); wp_localize_script('cpm-gutenberg-editor', 'cpm_ge_config', $config); } // End load_gutenberg_code /** * Load script and style files required for display google maps on public website */ function load_resources() { global $cpm_resources_loaded; if( !is_admin() && empty( $cpm_resources_loaded ) ) { $cpm_resources_loaded = true; if(get_option('cpm_load_resources_in_footer', false)) { wp_enqueue_script('jquery'); wp_enqueue_style('cpm_style_css', CPM_PLUGIN_URL.'/styles/cpm-styles.css'); wp_enqueue_script('cpm_public_js', CPM_PLUGIN_URL.'/js/cpm.js', array('jquery'), 'pro', true); } else { if( !wp_script_is( 'jquery' ) ) { print ""; } print ""; print ""; } } } // End load_resources function load_header_resources(){ echo ''; } // End load_header_resources /** * Print the settings page for entering the general setting's data of maps */ function settings_page(){ if (isset($_GET["page"])) { if( $_GET["page"] == 'google_maps_cp_upgrade' ) { echo("Redirecting to upgrade page..."); exit; } elseif( $_GET["page"] == 'google_maps_cp_help') { echo("Redirecting to documentation..."); exit; } elseif( $_GET["page"] == 'google_maps_cp_question') { echo("Redirecting to documentation..."); exit; } } // Check if post exists and save the configuraton options if (isset($_POST['cpm_map_noncename']) && wp_verify_nonce($_POST['cpm_map_noncename'],__FILE__)){ $options = $_POST['cpm_map']; $options = $this->array_map_recursive('sanitize_text_field', $options); $options['drag_map'] = ( isset( $options[ 'drag_map' ] ) ) ? true : false; $options['windowhtml'] = $this->get_configuration_option('windowhtml'); update_option('cpm_config', $options); update_option('cpm_load_resources_in_footer', (isset($_POST['cpm_load_resources_in_footer'])) ? true : false); echo '
'.__("Settings Updated", 'codepeople-post-map').'