www.mapsmarker.com"); } add_action('admin_print_styles-post.php', 'mm_shortcode_button'); add_action('admin_print_styles-post-new.php', 'mm_shortcode_button'); /* Initialize */ function mm_shortcode_button() { if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) { return; } if ( get_user_option('rich_editing') == 'true' ) { add_filter( 'mce_external_plugins', 'lmm_button_visual' ); add_filter( 'mce_external_plugins', 'lmm_button_text' ); } else { add_action('admin_footer', 'lmm_button_text'); } } /* Map button for text tab */ function lmm_button_text($plugin_array) { if (!is_multisite()) { $adminurl = admin_url(); } else { $adminurl = get_admin_url(); } $text_add = __('Add Map','lmm'); $link = LEAFLET_PLUGIN_URL . 'inc/js/tinymce_button_text.js'; $tinymce_options = array( 'leafletPluginUrl' => LEAFLET_PLUGIN_URL, 'adminUrl' => $adminurl, 'textAdd' => $text_add ); wp_register_script('html-dialog', $link); wp_localize_script('html-dialog', 'tinymceOptions', $tinymce_options); wp_enqueue_script('html-dialog'); return $plugin_array; } /* Map button for visual tab */ function lmm_button_visual( $plugin_array ) { if (!is_multisite()) { $adminurl = admin_url(); } else { $adminurl = get_admin_url(); } $text_add = __('Add Map','lmm'); $plugin_array['mm_shortcode'] = LEAFLET_PLUGIN_URL . 'inc/js/tinymce_button_visual.js'; return $plugin_array; } add_action('wp_ajax_get_mm_list', 'get_mm_list'); function get_mm_list(){ $get_map_search_nonce = isset($_GET['map_search_nonce']) ? $_GET['map_search_nonce'] : ''; if (isset($_GET['q'])) { if (!wp_verify_nonce($get_map_search_nonce, 'map-search-nonce')) { die(__('Security check failed - please call this function from the according admin page!','lmm').''); }; } global $wpdb, $wp_version; $table_name_markers = $wpdb->prefix.'leafletmapsmarker_markers'; $table_name_layers = $wpdb->prefix.'leafletmapsmarker_layers'; $l_condition = isset($_GET['q']) ? "AND l.name LIKE '%" . esc_sql($_GET['q']) . "%'" : ''; $m_condition = isset($_GET['q']) ? "AND m.markername LIKE '%" . esc_sql($_GET['q']) . "%'" : ''; $marklist = $wpdb->get_results(" (SELECT l.id, 'icon-layer.png' as 'icon', l.name as 'name', l.updatedon, l.updatedby, 'layer' as 'type' FROM `$table_name_layers` as l WHERE l.id != '0' $l_condition) UNION (SELECT m.id, m.icon as 'icon', m.markername as 'name', m.updatedon, m.updatedby, 'marker' as 'type' FROM `$table_name_markers` as m WHERE m.id != '0' $m_condition) order by updatedon DESC LIMIT 100", ARRAY_A); if (isset($_GET['q'])) { buildMarkersList($marklist); exit(); } ?> <?php _e('Add Map','lmm') ?> '.PHP_EOL; ?> ' type='text/css' media='all' /> ' . __('new marker map', 'lmm') . ''; echo ''; } ?>
' . __('new layer map', 'lmm') . '
' . __('Please select the map you would like to add','lmm') . ':
'; buildMarkersList($marklist); } else { echo '
' . __('No map has been created yet.','lmm') . '
'; if (current_user_can( $lmm_options[ 'capabilities_edit' ])) { echo sprintf(__('Please click here to add your first one!','lmm'), LEAFLET_WP_ADMIN_URL . 'admin.php?page=leafletmapsmarker_marker'); } echo '
'; } ?>
' . stripslashes(htmlspecialchars($one['name'])) . ' (ID '. $one['id'].')'; $name_title = stripslashes(htmlspecialchars($one['name'])) . ' (ID '. $one['id'].')'; } if ($one['type'] == 'marker') { $title = __('Marker','lmm'). ' ID ' . $one['id']; if ($one['icon'] == NULL) { $list_entry = ''; } else { $list_entry = ''; } } else { $title = __('Layer','lmm'). ' ID ' . $one['id']; $list_entry = ''; } ?>