display_page(); } function lmm_list_layers() { global $wpdb; $lmm_options = get_option( 'leafletmapsmarker_options' ); $columnsort = isset($_GET['orderby']) ? mysql_real_escape_string($_GET['orderby']) : 'id'; $columnsortorder = isset($_GET['order']) ? mysql_real_escape_string($_GET['order']) : 'asc'; $table_name_layers = $wpdb->prefix.'leafletmapsmarker_layers'; $table_name_markers = $wpdb->prefix.'leafletmapsmarker_markers'; $layerlist = $wpdb->get_results('SELECT * FROM '.$table_name_layers.' WHERE id>0 order by '.$columnsort.' '.$columnsortorder.'', ARRAY_A); $lcount = intval($wpdb->get_var('SELECT COUNT(*)-1 FROM '.$table_name_layers)); include('leaflet-list-layers.php'); } function lmm_list_markers() { global $wpdb; $lmm_options = get_option( 'leafletmapsmarker_options' ); $table_name_markers = $wpdb->prefix.'leafletmapsmarker_markers'; $table_name_layers = $wpdb->prefix.'leafletmapsmarker_layers'; $radius = 1; $pagenum = isset($_POST['paged']) ? intval($_POST['paged']) : (isset($_GET['paged']) ? intval($_GET['paged']) : 1); $columnsort = isset($_GET['orderby']) ? mysql_real_escape_string($_GET['orderby']) : 'id'; $columnsortorder = isset($_GET['order']) ? mysql_real_escape_string($_GET['order']) : 'asc'; $start = ($pagenum - 1) * intval($lmm_options[ 'markers_per_page' ]); $action = isset($_POST['action']) ? $_POST['action'] : (isset($_GET['action']) ? $_GET['action'] : ''); $searchtext = isset($_POST['searchtext']) ? $_POST['searchtext'] : (isset($_GET['searchtext']) ? mysql_real_escape_string($_GET['searchtext']) : ''); if ($action == 'search') { $markersearchnonce = isset($_POST['_wpnonce']) ? $_POST['_wpnonce'] : ''; if (! wp_verify_nonce($markersearchnonce, 'markersearch-nonce') ) die('
'.__('Security check failed - please call this function from the according Leaflet Maps Marker admin page!','lmm').''); $mcount = intval($wpdb->get_var('SELECT COUNT(*) FROM '.$table_name_markers.' WHERE markername like \'%'.$searchtext.'%'.'\' OR popuptext like \'%'.$searchtext.'%'.'\'')); $marklist = $wpdb->get_results('SELECT m.id,CONCAT(m.lat,\',\',m.lon) AS coords,m.basemap,m.icon,m.popuptext,m.layer,m.zoom,m.openpopup as openpopup,m.lat,m.lon,m.mapwidth,m.mapheight,m.mapwidthunit,m.markername,m.panel,m.createdby,m.createdon,m.updatedby,m.updatedon,m.controlbox,m.overlays_custom,m.overlays_custom2,m.overlays_custom3,m.overlays_custom4,m.wms,m.wms2,m.wms3,m.wms4,m.wms5,m.wms6,m.wms7,m.wms8,m.wms9,m.wms10,l.name AS layername,l.id as layerid FROM '.$table_name_markers.' AS m LEFT OUTER JOIN '.$table_name_layers.' AS l ON m.layer=l.id WHERE m.markername like \'%'.$searchtext.'%'.'\' OR m.popuptext like \'%'.$searchtext.'%'.'\' order by '.$columnsort.' '.$columnsortorder.' LIMIT '.intval($lmm_options[ 'markers_per_page' ]).' OFFSET '.$start, ARRAY_A); } else { $mcount = intval($wpdb->get_var('SELECT COUNT(*) FROM '.$table_name_markers)); $marklist = $wpdb->get_results('SELECT m.id,CONCAT(m.lat,\',\',m.lon) AS coords,m.basemap,m.icon,m.popuptext,m.layer,m.zoom,m.openpopup as openpopup,m.lat,m.lon,m.mapwidth,m.mapheight,m.mapwidthunit,m.markername,m.panel,m.createdby,m.createdon,m.updatedby,m.updatedon,m.controlbox,m.overlays_custom,m.overlays_custom2,m.overlays_custom3,m.overlays_custom4,m.wms,m.wms2,m.wms3,m.wms4,m.wms5,m.wms6,m.wms7,m.wms8,m.wms9,m.wms10,l.name AS layername,l.id as layerid FROM '.$table_name_markers.' AS m LEFT OUTER JOIN '.$table_name_layers.' AS l ON m.layer=l.id order by '.$columnsort.' '.$columnsortorder.' LIMIT '.intval($lmm_options[ 'markers_per_page' ]).' OFFSET '.$start, ARRAY_A); } if ($start > $mcount or $start < 0) $start = 0; include('leaflet-list-markers.php'); } function lmm_layer() { global $wpdb; $lmm_options = get_option( 'leafletmapsmarker_options' ); $table_name_markers = $wpdb->prefix.'leafletmapsmarker_markers'; $table_name_layers = $wpdb->prefix.'leafletmapsmarker_layers'; include('leaflet-layer.php'); } function lmm_marker() { global $wpdb; $lmm_options = get_option( 'leafletmapsmarker_options' ); $table_name_markers = $wpdb->prefix.'leafletmapsmarker_markers'; $table_name_layers = $wpdb->prefix.'leafletmapsmarker_layers'; include('leaflet-marker.php'); } function lmm_showmap($atts) { global $wpdb; $lmm_options = get_option( 'leafletmapsmarker_options' ); $uid = substr(md5(''.rand()), 0, 8); extract(shortcode_atts(array( 'lat' => '', 'lon' => '', 'mlat' => '', 'mlon' => '', 'basemap' => $lmm_options[ 'defaults_marker_shortcode_basemap'], 'mpopuptext' => '', 'micon' => '', 'zoom' => intval($lmm_options[ 'defaults_marker_shortcode_zoom' ]), 'openpopup' => '', 'geojson' => '', 'geojsonurl' => '', 'layer' => '', 'marker' => '', 'markername' => '', 'panel' => '0', 'mapwidth' => intval($lmm_options[ 'defaults_marker_shortcode_mapwidth' ]), 'mapwidthunit' => $lmm_options[ 'defaults_marker_shortcode_mapwidthunit' ], 'mapheight' => intval($lmm_options[ 'defaults_marker_shortcode_mapheight' ]), 'mapname' => 'mapsmarker_'.$uid ), $atts)); $pname = 'pa'.$uid; //info: prepare layers if (!empty($layer)) { $table_name_layers = $wpdb->prefix.'leafletmapsmarker_layers'; $row = $wpdb->get_row('SELECT id,name,basemap,mapwidth,mapheight,mapwidthunit,panel,layerzoom,layerviewlat,layerviewlon,controlbox,overlays_custom,overlays_custom2,overlays_custom3,overlays_custom4,wms,wms2,wms3,wms4,wms5,wms6,wms7,wms8,wms9,wms10 FROM '.$table_name_layers.' WHERE id='.$layer, ARRAY_A); $id = $row['id']; $basemap = $row['basemap']; $lat = $row['layerviewlat']; $lon = $row['layerviewlon']; $zoom = $row['layerzoom']; $mapwidth = $row['mapwidth']; $mapheight = $row['mapheight']; $mapwidthunit = $row['mapwidthunit']; $panel = $row['panel']; $paneltext = ($row['name'] == NULL) ? ' ' : $row['name']; $controlbox = $row['controlbox']; $overlays_custom = $row['overlays_custom']; $overlays_custom2 = $row['overlays_custom2']; $overlays_custom3 = $row['overlays_custom3']; $overlays_custom4 = $row['overlays_custom4']; $wms = $row['wms']; $wms2 = $row['wms2']; $wms3 = $row['wms3']; $wms4 = $row['wms4']; $wms5 = $row['wms5']; $wms6 = $row['wms6']; $wms7 = $row['wms7']; $wms8 = $row['wms8']; $wms9 = $row['wms9']; $wms10 = $row['wms10']; } //info: prepare markers if (!empty($marker)) { $table_name_markers = $wpdb->prefix.'leafletmapsmarker_markers'; $row = $wpdb->get_row('SELECT id,markername,basemap,layer,lat,lon,icon,popuptext,zoom,openpopup,mapwidth,mapwidthunit,mapheight,panel,controlbox,overlays_custom,overlays_custom2,overlays_custom3,overlays_custom4,wms,wms2,wms3,wms4,wms5,wms6,wms7,wms8,wms9,wms10 FROM '.$table_name_markers.' WHERE id='.$marker, ARRAY_A); if(!empty($row)) { $id = $row['id']; $basemap = $row['basemap']; $lon = $row['lon']; $lat = $row['lat']; $coords = $lat.', '.$lon; $icon = $row['icon']; $popuptext = $row['popuptext']; $zoom = $row['zoom']; $openpopup = ($row['openpopup'] == 1) ? '.openPopup()' : ''; $mopenpopup = $openpopup; $layer = $row['layer']; $mlat = $lat; $mlon = $lon; $mpopuptext = $popuptext; $micon = $icon; $mapwidth = $row['mapwidth']; $mapwidthunit = $row['mapwidthunit']; $mapheight = $row['mapheight']; $panel = $row['panel']; $paneltext = ($row['markername'] == NULL) ? ' ' : $row['markername']; $controlbox = $row['controlbox']; $overlays_custom = $row['overlays_custom']; $overlays_custom2 = $row['overlays_custom2']; $overlays_custom3 = $row['overlays_custom3']; $overlays_custom4 = $row['overlays_custom4']; $wms = $row['wms']; $wms2 = $row['wms2']; $wms3 = $row['wms3']; $wms4 = $row['wms4']; $wms5 = $row['wms5']; $wms6 = $row['wms6']; $wms7 = $row['wms7']; $wms8 = $row['wms8']; $wms9 = $row['wms9']; $wms10 = $row['wms10']; } } //info: prepare markers only added by shortcode and not defined in backend if (empty($layer) and empty($marker)) { $lat = $mlat; $lon = $mlon; $controlbox = $lmm_options[ 'defaults_marker_shortcode_controlbox' ]; $overlays_custom = isset($lmm_options[ 'defaults_marker_shortcode_overlays_custom_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_overlays_custom_active' ] == 1 ) ? '1' : '0'; $overlays_custom2 = isset($lmm_options[ 'defaults_marker_shortcode_overlays_custom2_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_overlays_custom2_active' ] == 1 ) ? '1' : '0'; $overlays_custom3 = isset($lmm_options[ 'defaults_marker_shortcode_overlays_custom3_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_overlays_custom3_active' ] == 1 ) ? '1' : '0'; $overlays_custom4 = isset($lmm_options[ 'defaults_marker_shortcode_overlays_custom4_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_overlays_custom4_active' ] == 1 ) ? '1' : '0'; $wms = isset($lmm_options[ 'defaults_marker_shortcode_wms_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_wms_active' ] == 1 ) ? '1' : '0'; $wms2 = isset($lmm_options[ 'defaults_marker_shortcode_wms2_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_wms2_active' ] == 1 ) ? '1' : '0'; $wms3 = isset($lmm_options[ 'defaults_marker_shortcode_wms3_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_wms3_active' ] == 1 ) ? '1' : '0'; $wms4 = isset($lmm_options[ 'defaults_marker_shortcode_wms4_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_wms4_active' ] == 1 ) ? '1' : '0'; $wms5 = isset($lmm_options[ 'defaults_marker_shortcode_wms5_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_wms5_active' ] == 1 ) ? '1' : '0'; $wms6 = isset($lmm_options[ 'defaults_marker_shortcode_wms6_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_wms6_active' ] == 1 ) ? '1' : '0'; $wms7 = isset($lmm_options[ 'defaults_marker_shortcode_wms7_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_wms7_active' ] == 1 ) ? '1' : '0'; $wms8 = isset($lmm_options[ 'defaults_marker_shortcode_wms8_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_wms8_active' ] == 1 ) ? '1' : '0'; $wms9 = isset($lmm_options[ 'defaults_marker_shortcode_wms9_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_wms9_active' ] == 1 ) ? '1' : '0'; $wms10 = isset($lmm_options[ 'defaults_marker_shortcode_wms10_active' ]) == TRUE && ($lmm_options[ 'defaults_marker_shortcode_wms10_active' ] == 1 ) ? '1' : '0'; } //info: check if layer/marker ID exists if ($lat == NULL) { $error_layer_not_exists = sprintf( esc_attr__('Error: a layer with the ID %1$s does not exist!','lmm'), $layer); $error_marker_not_exists = sprintf( esc_attr__('Error: a marker with the ID %1$s does not exist!','lmm'), $marker); if (empty($layer)) { echo $error_marker_not_exists . '
'; } if (empty($marker)) { echo $error_layer_not_exists . '
'; } echo '
'; } else { //info: starting output on frontend $lmm_out = ''; //info: panel for layer/marker name and API URLs if ($panel == 1) { if ($mapwidthunit == 'px') { $lmm_out .= '
'.PHP_EOL; } if ($mapwidthunit == '%') { $lmm_out .= '
'.PHP_EOL; } if (!empty($marker)) { $lmm_out .= '' . $paneltext . ''; if ( (isset($lmm_options[ 'defaults_marker_panel_kml' ] ) == TRUE ) && ( $lmm_options[ 'defaults_marker_panel_kml' ] == 1 ) ) { $lmm_out .= 'KML-Logo '; } if ( (isset($lmm_options[ 'defaults_marker_panel_geojson' ] ) == TRUE ) && ( $lmm_options[ 'defaults_marker_panel_geojson' ] == 1 ) ) { $lmm_out .= 'GeoJSON-Logo '; } if ( (isset($lmm_options[ 'defaults_marker_panel_wikitude' ] ) == TRUE ) && ( $lmm_options[ 'defaults_marker_panel_wikitude' ] == 1 ) ) { $lmm_out .= 'Wikitude-Logo'; } } if (!empty($layer) && empty($marker)) //info: check if problems get reported - fix for marker name shown twice when layer+marker map on 1 page { $lmm_out .= '' . $paneltext . ''; if ( (isset($lmm_options[ 'defaults_layer_panel_kml' ] ) == TRUE ) && ( $lmm_options[ 'defaults_layer_panel_kml' ] == 1 ) ) { $lmm_out .= 'KML-Logo '; } if ( (isset($lmm_options[ 'defaults_layer_panel_geojson' ] ) == TRUE ) && ( $lmm_options[ 'defaults_layer_panel_geojson' ] == 1 ) ) { $lmm_out .= 'GeoJSON-Logo '; } if ( (isset($lmm_options[ 'defaults_layer_panel_wikitude' ] ) == TRUE ) && ( $lmm_options[ 'defaults_layer_panel_wikitude' ] == 1 ) ) { $lmm_out .= 'Wikitude-Logo'; } } $lmm_out .= '
'.PHP_EOL; } $lmm_out .= PHP_EOL.'
'. PHP_EOL; $plugin_version = get_option('leafletmapsmarker_version'); $lmm_out .= ''; return $lmm_out; } //info: end check if marker/layer exists } //info: end lmm_showmap() function lmm_admin_menu() { $lmm_options = get_option( 'leafletmapsmarker_options' ); $page = add_object_page('Leaflet Maps Marker', 'Leaflet Maps Marker', $lmm_options[ 'capabilities_edit' ], 'leafletmapsmarker_markers', array(&$this, 'lmm_list_markers'), LEAFLET_PLUGIN_URL.'/img/icon-menu-page.png' ); $page2 = add_submenu_page('leafletmapsmarker_markers', 'Leaflet Maps Marker - ' . __('List all markers', 'lmm'), __('List all markers', 'lmm'), $lmm_options[ 'capabilities_edit' ], 'leafletmapsmarker_markers', array(&$this, 'lmm_list_markers') ); $page3 = add_submenu_page('leafletmapsmarker_markers', 'Leaflet Maps Marker - ' . __('Add new marker', 'lmm'), __('Add new marker', 'lmm'), $lmm_options[ 'capabilities_edit' ], 'leafletmapsmarker_marker', array(&$this, 'lmm_marker') ); $page4 = add_submenu_page('leafletmapsmarker_markers', 'Leaflet Maps Marker - ' . __('List all layers', 'lmm'), __('List all layers', 'lmm'), $lmm_options[ 'capabilities_edit' ], 'leafletmapsmarker_layers', array(&$this, 'lmm_list_layers') ); $page5 = add_submenu_page('leafletmapsmarker_markers', 'Leaflet Maps Marker - ' . __('Add new layer', 'lmm'), __('Add new layer', 'lmm'), $lmm_options[ 'capabilities_edit' ], 'leafletmapsmarker_layer', array(&$this, 'lmm_layer') ); $page6 = add_submenu_page('leafletmapsmarker_markers', 'Leaflet Maps Marker - ' . __('Help & Credits', 'lmm'), __('Help & Credits', 'lmm'), $lmm_options[ 'capabilities_edit' ], 'leafletmapsmarker_help', array(&$this, 'lmm_help') ); $page7 = add_submenu_page('leafletmapsmarker_markers', 'Leaflet Maps Marker - ' . __('Settings', 'lmm'), __('Settings', 'lmm'), 'activate_plugins','leafletmapsmarker_settings', array(&$this, 'lmm_settings') ); //info: add javascript - leaflet.js - for admin area add_action('admin_print_scripts-'.$page3, array(&$this, 'lmm_admin_enqueue_scripts'),7); add_action('admin_print_scripts-'.$page5, array(&$this, 'lmm_admin_enqueue_scripts'),8); add_action('admin_print_scripts-'.$page7, array(&$this, 'lmm_admin_jquery_ui'),9); //info: add flattr-script on all pages add_action('admin_print_scripts-'.$page, array(&$this, 'lmm_admin_enqueue_scripts_flattr'),10); add_action('admin_print_scripts-'.$page2, array(&$this, 'lmm_admin_enqueue_scripts_flattr'),11); add_action('admin_print_scripts-'.$page3, array(&$this, 'lmm_admin_enqueue_scripts_flattr'),12); add_action('admin_print_scripts-'.$page4, array(&$this, 'lmm_admin_enqueue_scripts_flattr'),13); add_action('admin_print_scripts-'.$page5, array(&$this, 'lmm_admin_enqueue_scripts_flattr'),14); add_action('admin_print_scripts-'.$page6, array(&$this, 'lmm_admin_enqueue_scripts_flattr'),15); add_action('admin_print_scripts-'.$page7, array(&$this, 'lmm_admin_enqueue_scripts_flattr'),16); //info: add css styles for admin area add_action('admin_print_styles-'.$page, array(&$this, 'lmm_admin_enqueue_stylesheets'),17); add_action('admin_print_styles-'.$page2, array(&$this, 'lmm_admin_enqueue_stylesheets'),18); add_action('admin_print_styles-'.$page3, array(&$this, 'lmm_admin_enqueue_stylesheets'),19); add_action('admin_print_styles-'.$page4, array(&$this, 'lmm_admin_enqueue_stylesheets'),20); add_action('admin_print_styles-'.$page5, array(&$this, 'lmm_admin_enqueue_stylesheets'),21); add_action('admin_print_styles-'.$page6, array(&$this, 'lmm_admin_enqueue_stylesheets'),22); add_action('admin_print_styles-'.$page7, array(&$this, 'lmm_admin_enqueue_stylesheets'),23); //info: add contextual help on all pages add_action('admin_print_scripts-'.$page, array(&$this, 'lmm_add_contextual_help')); add_action('admin_print_scripts-'.$page2, array(&$this, 'lmm_add_contextual_help')); add_action('admin_print_scripts-'.$page3, array(&$this, 'lmm_add_contextual_help')); add_action('admin_print_scripts-'.$page4, array(&$this, 'lmm_add_contextual_help')); add_action('admin_print_scripts-'.$page5, array(&$this, 'lmm_add_contextual_help')); add_action('admin_print_scripts-'.$page6, array(&$this, 'lmm_add_contextual_help')); add_action('admin_print_scripts-'.$page7, array(&$this, 'lmm_add_contextual_help')); } function lmm_add_admin_bar_menu() { global $wp_version; if ( version_compare( $wp_version, '3.1', '>=' ) ) { $lmm_options = get_option( 'leafletmapsmarker_options' ); if ( $lmm_options[ 'admin_bar_integration' ] == 'enabled' && current_user_can($lmm_options[ 'capabilities_edit' ]) ) { global $wp_admin_bar; $menu_items = array( array( 'id' => 'lmm', 'title' => ' Leaflet Maps Marker', 'href' => admin_url('admin.php?page=leafletmapsmarker_markers'), 'meta' => array( 'title' => 'Wordpress-Plugin ' . __('by','lmm') . ' www.mapsmarker.com' ) ), array( 'id' => 'lmm-markers', 'parent' => 'lmm', 'title' => __('List all markers','lmm'), 'href' => admin_url('admin.php?page=leafletmapsmarker_markers') ), array( 'id' => 'lmm-add-marker', 'parent' => 'lmm', 'title' => __('Add new marker','lmm'), 'href' => admin_url('admin.php?page=leafletmapsmarker_marker') ), array( 'id' => 'lmm-layers', 'parent' => 'lmm', 'title' => __('List all layers','lmm'), 'href' => admin_url('admin.php?page=leafletmapsmarker_layers') ), array( 'id' => 'lmm-add-layers', 'parent' => 'lmm', 'title' => __('Add new layer','lmm'), 'href' => admin_url('admin.php?page=leafletmapsmarker_layer') ), array( 'id' => 'lmm-help-credits', 'parent' => 'lmm', 'title' => __('Help & Credits','lmm'), 'href' => admin_url('admin.php?page=leafletmapsmarker_help') ), array( 'id' => 'lmm-plugin-website', 'parent' => 'lmm', 'title' => 'mapsmarker.com', 'href' => 'http://www.mapsmarker.com', 'meta' => array( 'target' => '_blank', 'title' => __('Open plugin website','lmm') ) ) ); if ( current_user_can( 'activate_plugins' ) ) { $menu_items = array_merge($menu_items, array( array( 'id' => 'lmm-settings', 'parent' => 'lmm', 'title' => __('Settings','lmm'), 'href' => admin_url('admin.php?page=leafletmapsmarker_settings') ) )); } foreach ($menu_items as $menu_item) { $wp_admin_bar->add_menu($menu_item); } } } } function lmm_add_contextual_help() { global $wp_version; $helptext = '

' . __('Do you have questions or issues with Leaflet Maps Marker? Please use the following support channels appropriately.','lmm') . '

'; $helptext .= ''; $helptext .= '

' . __('More information on support','lmm') . ': http://www.mapsmarker.com/support

'; if ( version_compare( $wp_version, '3.3', '<' ) ) { global $current_screen; add_contextual_help( $current_screen, $helptext ); } else if ( version_compare( $wp_version, '3.3', '>=' ) ) { $screen = get_current_screen(); $screen->add_help_tab( array( 'id' => 'lmm_help_tab', 'title' => __('Help & Support','lmm'), 'content' => $helptext )); } } function lmm_admin_jquery_ui() { wp_enqueue_script( array ( 'jquery', 'jquery-ui-tabs' ) ); } function lmm_frontend_enqueue_scripts() { wp_enqueue_script( array ( 'jquery' ) ); wp_enqueue_script( 'leafletmapsmarker', LEAFLET_PLUGIN_URL.'/leaflet-dist/leaflet.js', array(), NULL); wp_localize_script ( 'leafletmapsmarker', 'leafletmapsmarker_L10n', array( 'lmm_zoom_in' => __( 'Zoom in', 'lmm' ), 'lmm_zoom_out' => __( 'Zoom out', 'lmm' ) ) ); } function lmm_admin_enqueue_scripts_flattr() { wp_enqueue_script( 'leafletmapsmarker-flattr', LEAFLET_PLUGIN_URL.'/js/flattr.js', array(), NULL); } function lmm_admin_enqueue_scripts() { wp_enqueue_script( array ( 'jquery' ) ); wp_enqueue_script( 'leafletmapsmarker', LEAFLET_PLUGIN_URL.'/leaflet-dist/leaflet.js', array(), NULL); wp_localize_script ( 'leafletmapsmarker', 'leafletmapsmarker_L10n', array( 'lmm_zoom_in' => __( 'Zoom in', 'lmm' ), 'lmm_zoom_out' => __( 'Zoom out', 'lmm' ) ) ); } function lmm_frontend_enqueue_stylesheets() { global $wp_styles; wp_register_style('leafletmapsmarker', LEAFLET_PLUGIN_URL . '/leaflet-dist/leaflet.css', array(), NULL); wp_enqueue_style('leafletmapsmarker'); wp_register_style('leafletmapsmarker-ie-only', LEAFLET_PLUGIN_URL . '/leaflet-dist/leaflet.ie.css', array(), NULL); wp_enqueue_style('leafletmapsmarker-ie-only'); $wp_styles->add_data('leafletmapsmarker-ie-only', 'conditional', 'lt IE 9'); } function lmm_admin_enqueue_stylesheets() { global $wp_styles; wp_register_style( 'leafletmapsmarker', LEAFLET_PLUGIN_URL . '/leaflet-dist/leaflet.css', array(), NULL ); wp_enqueue_style( 'leafletmapsmarker' ); wp_register_style( 'leafletmapsmarker-admin', LEAFLET_PLUGIN_URL . '/css/leafletmapsmarker-admin.css', array(), NULL ); wp_enqueue_style('leafletmapsmarker-admin' ); wp_register_style('leafletmapsmarker-ie-only', LEAFLET_PLUGIN_URL . '/leaflet-dist/leaflet.ie.css', array(), NULL); wp_enqueue_style('leafletmapsmarker-ie-only'); $wp_styles->add_data('leafletmapsmarker-ie-only', 'conditional', 'lt IE 8'); } function lmm_install_and_updates() { global $wpdb; //info: 2 options not managed by Settings API (class-leaflet-options.php) add_option('leafletmapsmarker_version', 'init'); add_option('leafletmapsmarker_redirect', 'true'); //redirect to plugin settings page after first activation only if (get_option('leafletmapsmarker_version') == 'init') { //info: copy map icons to wp-content/uploads WP_Filesystem(); $target = ABSPATH . 'wp-content/uploads/leaflet-maps-marker-icons'; if (!is_dir($target)) //info: check for multisite installations { wp_mkdir_p( $target ); $source = WP_PLUGIN_DIR . '/' . end(explode('/', dirname(__FILE__))) . '/img/mapicons'; copy_dir($source, $target, $skip_list = array() ); $zipfile = ABSPATH . 'wp-content/uploads/leaflet-maps-marker-icons/mapicons.zip'; unzip_file( $zipfile, $target ); } //info: create tables for markers & layers $table_name_markers = $wpdb->prefix.'leafletmapsmarker_markers'; $table_name_layers = $wpdb->prefix.'leafletmapsmarker_layers'; $sql_create_marker_table = "CREATE TABLE IF NOT EXISTS `" . $table_name_markers . "` ( `id` int(6) unsigned NOT NULL auto_increment, `markername` varchar(255) CHARACTER SET utf8 NOT NULL, `basemap` varchar(20) NOT NULL, `layer` int(6) unsigned NOT NULL, `lat` decimal(9,6) NOT NULL, `lon` decimal(9,6) NOT NULL, `icon` varchar(255) CHARACTER SET utf8 NOT NULL, `popuptext` text CHARACTER SET utf8 NOT NULL, `zoom` int(2) NOT NULL, `openpopup` tinyint(1) NOT NULL, `mapwidth` int(4) NOT NULL, `mapwidthunit` varchar(2) NOT NULL, `mapheight` int(4) NOT NULL, `panel` tinyint(1) NOT NULL, `createdby` varchar(30) CHARACTER SET utf8 NOT NULL, `createdon` datetime NOT NULL, `updatedby` varchar(30) CHARACTER SET utf8 NOT NULL, `updatedon` datetime NOT NULL, `controlbox` int(1) NOT NULL, `overlays_custom` int(1) NOT NULL, `overlays_custom2` int(1) NOT NULL, `overlays_custom3` int(1) NOT NULL, `overlays_custom4` int(1) NOT NULL, `wms` int(1) NOT NULL, `wms2` int(1) NOT NULL, `wms3` int(1) NOT NULL, `wms4` int(1) NOT NULL, `wms5` int(1) NOT NULL, `wms6` int(1) NOT NULL, `wms7` int(1) NOT NULL, `wms8` int(1) NOT NULL, `wms9` int(1) NOT NULL, `wms10` int(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;"; $wpdb->query($sql_create_marker_table); $sql_create_layer_table = "CREATE TABLE IF NOT EXISTS `".$table_name_layers."` ( `id` int(6) unsigned NOT NULL auto_increment, `name` varchar(255) CHARACTER SET utf8 NOT NULL, `basemap` varchar(20) NOT NULL, `layerzoom` int(2) NOT NULL, `mapwidth` int(4) NOT NULL, `mapwidthunit` varchar(2) NOT NULL, `mapheight` int(4) NOT NULL, `panel` tinyint(1) NOT NULL, `layerviewlat` decimal(9,6) NOT NULL, `layerviewlon` decimal(9,6) NOT NULL, `createdby` varchar(30) CHARACTER SET utf8 NOT NULL, `createdon` datetime NOT NULL, `updatedby` varchar(30) CHARACTER SET utf8 NOT NULL, `updatedon` datetime NOT NULL, `controlbox` int(1) NOT NULL, `overlays_custom` int(1) NOT NULL, `overlays_custom2` int(1) NOT NULL, `overlays_custom3` int(1) NOT NULL, `overlays_custom4` int(1) NOT NULL, `wms` int(1) NOT NULL, `wms2` int(1) NOT NULL, `wms3` int(1) NOT NULL, `wms4` int(1) NOT NULL, `wms5` int(1) NOT NULL, `wms6` int(1) NOT NULL, `wms7` int(1) NOT NULL, `wms8` int(1) NOT NULL, `wms9` int(1) NOT NULL, `wms10` int(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; $wpdb->query($sql_create_layer_table); //info: insert layer row 0 for markers without assigned layer $sql = "SET SESSION sql_mode=NO_AUTO_VALUE_ON_ZERO;"; $wpdb->query($sql); $sql2 = "INSERT INTO `".$table_name_layers."` ( `id`, `name`, `basemap`, `layerzoom`, `mapwidth`, `mapwidthunit`, `mapheight`, `layerviewlat`, `layerviewlon` ) VALUES (0, 'markers not assigned to a layer', 'osm_mapnik', '11', '640', 'px', '480', '', '');"; $wpdb->query($sql2); $sql3 = "SET SESSION sql_mode='';"; $wpdb->query($sql3); update_option('leafletmapsmarker_version', '1.0'); //info: redirect to settings page only on first plugin activation, otherwise redirect is also done on bulk plugin activations if (get_option('leafletmapsmarker_redirect') == 'true') { update_option('leafletmapsmarker_redirect', 'false'); wp_redirect(WP_ADMIN_URL.'admin.php?page=leafletmapsmarker_settings&display=install_note'); } } /* prepared for plugin update 1.1 if (get_option('leafletmapsmarker_version') == '1.0' ) { //mandatory if new options in class-leaflet-options.php were added $save_defaults_for_new_options = new Leafletmapsmarker_options(); $save_defaults_for_new_options->save_defaults_for_new_options(); //optional: add code for sql ddl updates //mandatory: update_option('leafletmapsmarker_version', '1.1'); //mandatory: move code for redirect-on-first-activation-check to here } */ }//info: end install_and_updates() function lmm_plugin_meta_links() { define( 'FB_BASENAME', plugin_basename( __FILE__ ) ); define( 'FB_BASEFOLDER', plugin_basename( dirname( __FILE__ ) ) ); define( 'FB_FILENAME', str_replace( FB_BASEFOLDER.'/', '', plugin_basename(__FILE__) ) ); function leafletmapsmarker_filter_plugin_meta($links, $file) { if ( $file == FB_BASENAME ) { array_unshift( $links, ''.__('Markers','lmm').'', ''.__('Layers','lmm').'' , ''.__('Settings','lmm').'' ); } return $links; } add_filter( 'plugin_action_links', 'leafletmapsmarker_filter_plugin_meta', 10, 2 ); } //info: end plugin_meta_links() } //info: end class $run_leafletmapsmarker = new Leafletmapsmarker(); unset($run_leafletmapsmarker); ?>