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' => "
%thumbnail% %title%
%address%
%description%
" ); return (!empty($attr) && isset($default[$attr])) ? $default[$attr] : $default; } // End _default_configuration /** * Set default system and maps configuration */ function set_default_configuration(){ $cpm_default = $this->_default_configuration(); $options = get_option('cpm_config'); if($options !== false) $options = array_replace_recursive($cpm_default, $options); else $options = $cpm_default; return $options; } // End set_default_configuration /** * Get a part of option variable or the complete array */ function get_configuration_option($option = null){ $options = get_option('cpm_config'); $default = $this->_default_configuration(); if(!isset($options)){ $options = $default; } if(isset($option)){ return (isset($options[$option])) ? $options[$option] : ((isset($default[$option])) ? $default[$option] : null); }else{ return $options; } } // End get_configuration_option //---------- METADATA FORM METHODS ---------- /** * Private method to deploy the list of languages */ function _deploy_languages($options){ print ''; } // End _deploy_languages /** * Private method to get the list of icons */ function _deploy_icons($options = null){ $icon_path = CPM_PLUGIN_URL.'/images/icons/'; $icon_dir = CPM_PLUGIN_DIR.'/images/icons/'; $icons_array = array(); $default_icon = (isset($options) && isset($options['icon'])) ? $options['icon'] : $this->get_configuration_option('default_icon'); if( strpos($default_icon, 'http') !== 0 ) $default_icon = CPM_PLUGIN_URL.$default_icon; if ($handle = opendir($icon_dir)) { while (false !== ($file = readdir($handle))) { $file_type = wp_check_filetype($file); $file_ext = $file_type['ext']; if ($file != "." && $file != ".." && ($file_ext == 'gif' || $file_ext == 'jpg' || $file_ext == 'png') ) { array_push($icons_array,$icon_path.$file); } } } ?>
">
[ + more information]

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

:
- Maps JavaScript API
- Geocoding API
- Places API ("Display a search box for places" option is enabled', 'codepeople-post-map'); ?>)
- Directions API ("Display route" option is enabled', 'codepeople-post-map'); ?>)

/>
[ + 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
>
/>
/>
/>
/>
/>

    • "Map Styles"
    • "Create style."
    • "Map Management"
    • "Style" "Associated Style" "Edit."
    • "Map ID"

      [codepeople-post-map mapid="1234567890"]

This feature is available only in commercial version of plugin. Click Here
_default_configuration(); // create a custom nonce for submit verification later echo ''; ?>

CodePeople Post Map plugin page', 'codepeople-post-map'); ?>

contact page and leave us a message.', 'codepeople-post-map'); ?>

:

advanced version.', '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" />
Address, latitude and longitude are required fields.

_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"]
Note: the number 35 correspond to the ID of category.

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' ); ?>
_deploy_map_form($options, true); ?>

 

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').'

'; }else{ $options = $this->get_configuration_option(); } ?>
_deploy_map_form($options); ?>






true), 'names'); print '' . __('Posts and Pages are selected by default', 'codepeople-post-map') . '.
'; ?>



/>

CodePeople Post Map plugin page', 'codepeople-post-map'); ?>

'; ?>
false)); $point = ( is_array($tmp_point) ) ? $tmp_point : array( 'address' => $point ); } if( !is_array( $point ) ) { $point = array( 'address' => $point ); } $point['post_id'] = $post_id; if(!in_array($point, $this->points)){ $this->points[] = $point; } } else { $latitude = apply_filters('cpm-post-latitude', '', $post_id); $longitude = apply_filters('cpm-post-longitude', '', $post_id); $address = apply_filters('cpm-post-address', '', $post_id); if( (!empty( $latitude ) && !empty( $longitude )) || !empty($address)) { $point = array(); if(!empty( $latitude ) && !empty( $longitude )) { $point['latitude'] = $latitude; $point['longitude'] = $longitude; } if(!empty( $address )) { $point['address'] = $address; } $point['post_id'] = $post_id; if(!in_array($point, $this->points)){ $this->points[] = apply_filters('cpm-point', $point); } } } } // End populate_points /* * Generates the javascript code of map points, only called from webpage of multiples posts */ function print_points(){ global $id; $limit = abs($this->limit); $str = ''; $current_post = ''; $count_posts = 0; $count_points = 0; foreach($this->points as $point){ if(!empty($limit)){ if($current_post != $point['post_id']){ $current_post = $point['post_id']; $count_posts++; if( $count_posts > $limit) break; if( !empty($this->defaultpost) && $this->defaultpost == $current_post ) { $point[ 'default' ] = 1; $this->defaultpost = ''; } } } $str .= $this->_set_map_point($point, $count_points); $count_points++; } if(strlen($str)) { $map_id_json = wp_json_encode( $this->map_id ); $str = ''; } $this->points = array(); print $str; } // End print_points /** * Replace each [codepeople-post-map] shortcode by the map */ function replace_shortcode($atts){ if(defined( 'REST_REQUEST' )) return; global $post, $id, $cpm_objs, $cpm_in_loop; // Load the plugin resources $this->load_resources(); $cpm_obj = new CPM; $cpm_objs[] = $cpm_obj; if(is_array($atts)) $cpm_obj->extended = $atts; if( !empty( $atts[ 'defaultpost' ] ) ) $cpm_obj->defaultpost = str_replace( ' ', '', $atts[ 'defaultpost' ] ); if( isset($id) && ( is_singular() || !empty( $cpm_in_loop ) ) ){ $cpm_map = get_post_meta($id, 'cpm_map', TRUE); } if(empty($cpm_map)){ $cpm_map = $cpm_obj->get_configuration_option(); } if( ! empty($atts['mapid']) ) $cpm_map['mapid'] = trim( $atts['mapid'] ); if(!empty($cpm_map['points'])){ $cpm_obj->limit = $cpm_map['points']; } if( !empty( $atts[ 'points' ] ) ) { $atts[ 'points' ] = trim( $atts[ 'points' ] ); if( is_numeric( $atts[ 'points' ] ) && $atts[ 'points' ] > 0 ) $cpm_obj->limit = $atts[ 'points' ]; } $cpm_map[ 'tooltip' ] = $this->get_configuration_option('tooltip'); if( isset( $atts[ 'tooltip' ] ) ) { $cpm_map[ 'tooltip' ] = trim($atts[ 'tooltip' ]); } if( isset($id) && ( is_singular() || !empty( $cpm_in_loop ) ) ){ // For maps in a post or page // Set the actual post only to avoid duplicates $posts = array( $id ); $query_arg = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'cpm_point' ), ), 'post_status' => 'publish', 'orderby' => 'post_date', 'order' => 'DESC', 'cache_results' => false, 'fields' => 'ids', 'post__not_in' => array( $id ) ); /* * If the latitude and longitude or address is stored into custom fields, * it is possible to include them in the selector query * function custom_complete_query_structure($query_components) * { * $query_components[] = array( * 'key' => 'custom_address' * ); * return $query_components; * } * add_filter('cpm-complete-structured-query', 'custom_complete_query_structure'); */ $query_arg['meta_query'] = apply_filters('cpm-complete-structured-query', $query_arg['meta_query']); if( !empty($cpm_obj->limit) ){ $query_arg[ 'numberposts' ] = $cpm_obj->limit - 1; } // Get POSTs in the same category $categories = get_the_category(); $categories_ids = array(); foreach($categories as $category){ array_push( $categories_ids, $category->term_id); } if( !empty( $categories_ids ) ){ $query_arg[ 'category' ] = implode( ',', $categories_ids ); } $posts = array_merge( $posts, get_posts( $query_arg ) ); // WMPL $wpml_option = $this->get_configuration_option( 'wpml' ); if(function_exists( 'icl_object_id' )) $current_lang = apply_filters( 'wpml_current_language', NULL ); foreach( $posts as $_post){ if(function_exists( 'icl_object_id' )) { $post_language_information = apply_filters( 'wpml_post_language_details', NULL, $_post ); $language = $post_language_information["language_code"]; if( $language != $current_lang && ! empty( $wpml_option ) && 'some' == $wpml_option ) continue; } $cpm_obj->populate_points($_post); } }else{ $cpm_obj->multiple = true; } $output = $cpm_obj->_set_map_tag($cpm_map); $output .= $cpm_obj->_set_map_config($cpm_map); $output .= " "; if( !empty( $atts['print'] ) ){ print $output; $cpm_obj->print_points(); return ''; } return $output; } // End replace_shortcode function preview() { $user = wp_get_current_user(); $allowed_roles = array('editor', 'administrator', 'author'); if(array_intersect($allowed_roles, $user->roles )) { if( !empty($_REQUEST['cpm-preview']) && !empty($_REQUEST['post-id']) && ($post_id = @intval($_REQUEST['post-id'])) !== 0 ) { // Nonce verification if (!isset($_REQUEST['cpm_preview_nonce']) || !wp_verify_nonce( sanitize_text_field(wp_unslash($_REQUEST['cpm_preview_nonce'])), 'cpm-preview-'.$post_id )) { return; } // Object-level capability check if (!current_user_can('read_post', $post_id)) { return; } // Sanitizing variable $preview = sanitize_text_field(wp_unslash($_REQUEST['cpm-preview'])); // Remove every shortcode that is not in the music store list remove_all_shortcodes(); add_shortcode('codepeople-post-map', array(&$this, 'replace_shortcode')); get_post($post_id); if(has_shortcode($preview, 'codepeople-post-map')) { // To indicate in the replace_shortcode that should be used the particular settings. global $id, $cpm_in_loop; $id = $post_id; $cpm_in_loop = true; // Includes the print attribute in the shortcode $preview = preg_replace('/(\[codepeople\-post\-map)/i', '$1 print="1" ', $preview); wp_head(); print '
'.do_shortcode($preview).'
'; if( function_exists('wp_print_styles') && function_exists('wp_print_scripts') ) { wp_print_styles(); wp_print_scripts(); } else { wp_footer(); } print''; exit; } } } } // End preview /* * Generates the DIV tag where the map will be loaded */ function _set_map_tag($atts){ $atts = array_merge($atts, $this->extended); extract($atts, EXTR_SKIP); if(isset($width)) { $width = trim($width); if(is_numeric($width)) $width .= 'px'; } else $width = '100%'; if(isset($height)) { $height = trim($height); if(is_numeric($height)) $height .= 'px'; } else $height = '500px'; $output ='