/';
$replacements = array();
$replacements[0] = '[';
$replacements[1] = ']';
//$replacements[2] = '';
$attr = preg_replace($patterns, $replacements, $attr);
// Default values.
$defaults = array(
'width' => '',
'height' => '400',
'zoom' => 12,
'scrollwheel' => 0,
'markers' => '[]',
'center' => '[]',
'iconurl' => plugin_dir_url( __FILE__ ) . 'img/pin.png',
'styles' => '[]',
'maptype' => 'ROADMAP',
'clustergridsize' => '50'
);
// Merging user values and defaults.
extract( shortcode_atts( $defaults, $attr ) );
// Shortcode output.
$output = '';
$zoom = esc_js( $zoom );
$width = esc_attr( $width );
$height = esc_attr( $height );
$scrollwheel = esc_js( $scrollwheel );
$iconurl = esc_url( $iconurl );
$maptype = esc_js( strtoupper( $maptype ) );
$center = esc_js( $center );
$clustergridsize = absint( $clustergridsize );
//$styles = esc_js( $styles );
//$markers = esc_js( $markers );
//var_dump($attr);
// Unique shortcode id - support for multiple maps on one page.
$map_id = 'agms_'.md5( $markers . $zoom . $center );
// We are adding scripts on page only once and only when shortcode used.
static $script_added = false;
if( $script_added == false ) {
$output .= '';
$output .= '';
$script_added = true;
}
// Google map javascript code.
$output .= <<
CODE;
return $output;
}
function add_tinymce_button() {
global $typenow;
// check user permissions
if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) {
return;
}
// verify the post type
if( ! in_array( $typenow, array( 'post', 'page' ) ) ) {
return;
}
// check if WYSIWYG is enabled
if ( get_user_option('rich_editing') == 'true') {
add_filter('mce_external_plugins', array( $this, 'add_tinymce_plugin' ) );
add_filter('mce_buttons', array( $this, 'register_tinymce_button' ) );
}
}
function add_tinymce_plugin($plugin_array) {
$plugin_array['agms_tinymce_button'] = plugin_dir_url( __FILE__ ) . 'js/tinymce-button.min.js';
return $plugin_array;
}
function register_tinymce_button($buttons) {
array_push($buttons, 'agms_tinymce_button');
return $buttons;
}
}
new AdvancedGoogleMapsShortcode;