plugin_domain, 'wp-content/plugins/' . $plugin_dir . '/lang', $plugin_dir . '/lang' ); $this->plugin_url = SIMPLEMAP_URL; // Add shortcode handler add_shortcode( 'simplemap', array( &$this, 'display_map' ) ); // Enqueue frontend scripts & styles into
add_action( 'template_redirect', array( &$this, 'enqueue_frontend_scripts_styles' ) ); // Enqueue backend scripts add_action( 'init', array( &$this, 'enqueue_backend_scripts_styles' ) ); // Add hook for master js file add_action( 'template_redirect', array( &$this, 'google_map_js_script' ) ); // Add hook for general options js file add_action( 'init', array( &$this, 'general_options_js_script' ) ); // Query vars add_filter( 'query_vars', array( &$this, 'register_query_vars' ) ); // Backwards compat for core sm taxonomies add_filter( 'sm_category-text', array( &$this, 'backwards_compat_categories_text' ) ); add_filter( 'sm_tag-text', array( &$this, 'backwards_compat_tags_text' ) ); add_filter( 'sm_day-text', array( &$this, 'backwards_compat_days_text' ) ); add_filter( 'sm_time-text', array( &$this, 'backwards_compat_times_text' ) ); } // This function generates the code to display the map function display_map( $atts ) { $options = $this->get_options(); $atts = $this->parse_shortcode_atts( $atts ); extract( $atts ); $to_display = ''; $to_display .= $this->location_search_form( $atts ); if ( $powered_by ) $to_display .= 'General Settings before your maps will work.', 'SimpleMap' ), admin_url( 'admin.php?page=simplemap' ) ); ?>
" ); if ( lat == 0 ) { lat = ''; } if ( lng == 0 ) { lng = ''; } var latlng = new google.maps.LatLng( lat, lng ); var myOptions = { zoom: parseInt(zoom_level), center: latlng, mapTypeId: google.maps.MapTypeId[map_type] }; map = new google.maps.Map( document.getElementById( "simplemap" ), myOptions ); // Adsense for Google Maps // Adsense ID. If no shortcode, check for options. If not options, use blank string. if ( aspid == 0 ) aspid = ''; // Channel ID. If no shortcode, check for options. If not options, use blank string. if ( ascid == 0 ) ascid = ''; // Max ads per map. If no shortcode, check for options. If no options, use 2. if ( asma == 0 ) asma = ''; var publisher_id = aspid; var adUnitDiv = document.createElement('div'); var adUnitOptions = { channelNumber: ascid, format: google.maps.adsense.AdFormat.HALF_BANNER, position: google.maps.ControlPosition.TOP, map: map, visible: true, publisherId: publisher_id }; adUnit = new google.maps.adsense.AdUnit(adUnitDiv, adUnitOptions); } function codeAddress() { // if this is modified, modify mirror function in general-options-js php function var d_address = document.getElementById("default_address").value; geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': d_address }, function( results, status ) { if ( status == google.maps.GeocoderStatus.OK ) { var latlng = results[0].geometry.location; document.getElementById("default_lat").value = latlng.lat(); document.getElementById("default_lng").value = latlng.lng(); } else { alert("Geocode was not successful for the following reason: " + status); } }); } function codeNewAddress() { if (document.getElementById("store_lat").value != '' && document.getElementById("store_lng").value != '') { document.new_location_form.submit(); } else { var address = ''; var street = document.getElementById("store_address").value; var city = document.getElementById("store_city").value; var state = document.getElementById("store_state").value; var country = document.getElementById("store_country").value; if (street) { address += street + ', '; } if (city) { address += city + ', '; } if (state) { address += state + ', '; } address += country; geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': address }, function( results, status ) { if ( status == google.maps.GeocoderStatus.OK ) { var latlng = results[0].geometry.location; document.getElementById("store_lat").value = latlng.lat(); document.getElementById("store_lng").value = latlng.lng(); document.new_location_form.submit(); } else { alert("Geocode was not successful for the following reason: " + status); } }); } } function codeChangedAddress() { var address = ''; var street = document.getElementById("store_address").value; var city = document.getElementById("store_city").value; var state = document.getElementById("store_state").value; var country = document.getElementById("store_country").value; if (street) { address += street + ', '; } if (city) { address += city + ', '; } if (state) { address += state + ', '; } address += country; geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': address }, function( results, status ) { if ( status == google.maps.GeocoderStatus.OK ) { var latlng = results[0].geometry.location; document.getElementById("store_lat").value = latlng.lat(); document.getElementById("store_lng").value = latlng.lng(); } else { alert("Geocode was not successful for the following reason: " + status); } }); } function searchLocations( is_search ) { // Init searchData var searchData = {}; searchData.taxes = {}; // Set defaults for search form fields searchData.address = ''; searchData.city = ''; searchData.state = ''; searchData.zip = ''; searchData.country = ''; if ( null != document.getElementById('location_search_address_field') ) { searchData.address = document.getElementById('location_search_address_field').value; } if ( null != document.getElementById('location_search_city_field') ) { searchData.city = document.getElementById('location_search_city_field').value; } if ( null != document.getElementById('location_search_country_field') ) { searchData.country = document.getElementById('location_search_country_field').value;; } if ( null != document.getElementById('location_search_state_field') ) { searchData.state = document.getElementById('location_search_state_field').value; } if ( null != document.getElementById('location_search_zip_field') ) { searchData.zip = document.getElementById('location_search_zip_field').value; } if ( null != document.getElementById('location_search_distance_field') ) { searchData.radius = document.getElementById('location_search_distance_field').value; } searchData.lat = document.getElementById('location_search_default_lat').value; searchData.lng = document.getElementById('location_search_default_lng').value; searchData.limit = document.getElementById('location_search_limit').value; searchData.page = document.getElementById('location_search_page').value; searchData.searching = document.getElementById('location_is_search_results').value; // Do SimpleMap Taxonomies // Do taxnonomy for checkboxes searchData.taxes. = ''; var checks_found = false; jQuery( 'input[rel=location_search__field]' ).each( function() { checks_found = true; if ( jQuery( this ).attr( 'checked' ) && jQuery( this ).attr( 'value' ) != null ) { += jQuery( this ).attr( 'value' ) + ','; } }); // Do taxnonomy for select box if checks weren't found if ( false == checks_found ) { jQuery( 'option[rel=location_search__select_val]' ).each( function() { if ( jQuery( this ).attr( 'selected' ) && jQuery( this ).attr( 'value' ) != null ) { += jQuery( this ).attr( 'value' ) + ','; } }); } var query = ''; var start = 0; if ( searchData.address && searchData.address != '' ) { query += searchData.address + ', '; } if ( searchData.city && searchData.city != '' ) { query += searchData.city + ', '; } if ( searchData.state && searchData.state != '' ) { query += searchData.state + ', '; } if ( searchData.zip && searchData.zip != '' ) { query += searchData.zip + ', '; } if ( searchData.country && searchData.country != '' ) { query += searchData.country + ', '; } // Query if ( query != null ) { query = query.slice(0, -2); } if ( searchData.limit == '' || searchData.limit == null ) { searchData.limit = 0; } if ( searchData.page == '' || searchData.page == null ) { searchData.page = 0; } if ( searchData.radius == '' || searchData.radius == null ) { searchData.radius = 0; } // Taxonomies if ( != null ) { var _ = .slice(0, -1); } else { var _ = ''; } // Append available taxes logic if no taxes are selected but limited taxes were passed through shortcode as available if ( '' != document.getElementById('avail_').value && '' == _ ) { _ = 'OR,' + document.getElementById('avail_').value; } searchData.taxes. = _; // Load default location if query is empty if ( query == '' || query == null ) { if ( searchData.lat != 0 && searchData.lng != 0 ) query = searchData.lat + ', ' + searchData.lng; else query = ', '; } // Searching if ( 1 == searchData.searching || 1 == is_search ) { is_search = 1; searchData.source = 'search'; } else { is_search = 0; searchData.source = 'initial_load'; } geocoder.geocode( { 'address': query }, function( results, status ) { if ( status == google.maps.GeocoderStatus.OK ) { searchData.center = results[0].geometry.location; if ( 'none' != autoload || is_search ) { if ( 'all' == autoload && is_search != 1 ) { searchData.radius = 0; //searchData.limit = 0; } if (! searchData.center) { searchData.center = new GLatLng( 44.9799654, -93.2638361 ); } searchData.query_type = 'all'; searchData.mapLock = 'unlock'; searchData.homeAddress = query; searchLocationsNear(searchData); } } }); } function searchLocationsNear(searchData) { // Radius if ( searchData.radius != null && searchData.radius != '' ) { searchData.radius = parseInt( searchData.radius ); if ( units == 'km' ) { searchData.radius = parseInt( searchData.radius ) / 1.609344; } } else if ( autoload == 'all' ) { searchData.radius = 0; } else { if ( units == 'mi' ) { searchData.radius = parseInt( default_radius ); } else if ( units == 'km' ) { searchData.radius = parseInt( default_radius ) / 1.609344; } } // Build search URL get_sm_taxonomies( 'array', '', true ) ) { $js_tax_string = ''; foreach( $taxonomies as $taxonomy ) { $js_tax_string .= "'&$taxonomy=' + searchData.taxes.$taxonomy + "; } } ?> var searchUrl = siteurl + '/?sm-xml-search=1&lat=' + searchData.center.lat() + '&lng=' + searchData.center.lng() + '&radius=' + searchData.radius + '&namequery=' + searchData.homeAddress + '&query_type=' + searchData.query_type + '&limit=' + searchData.limit + '&page=' + searchData.page + '&address=' + searchData.address + '&city=' + searchData.city + '&state=' + searchData.state + '&zip=' + searchData.zip + '&pid='; // Display Updating Message and hide search results if ( jQuery( "#simplemap" ).is(":visible") ) { jQuery( "#simplemap" ).hide(); jQuery( "#simplemap-updating" ).show(); } jQuery( "#results" ).html( '' ); jQuery.get( searchUrl, {}, function(data) { // Hide Updating Message if ( jQuery( "#simplemap-updating" ).is(":visible") ) { jQuery( "#simplemap-updating" ).hide(); jQuery( "#simplemap" ).show(); } clearOverlays(); var results = document.getElementById('results'); results.innerHTML = ''; var markers = jQuery( eval( data ) ); if (markers.length == 0) { results.innerHTML = '";print_r( $body );die(); $location = $body->results[0]->geometry->location; // Format: Longitude, Latitude, Altitude $lat = $location->lat; $lng = $location->lng; } return compact( 'body', 'status', 'lat', 'lng' ); } else { return false; } } // Returns list of SimpleMap Taxonomies function get_sm_taxonomies( $format='array', $prefix='', $php_safe=false, $output='names' ) { $taxes = array(); if ( $taxes = get_object_taxonomies( 'sm-location', $output ) ) { foreach( $taxes as $key => $tax ) { // Convert to PHP safe and add prefix if ( $php_safe && 'names' == $output ) $taxes[$key] = str_replace( '-', '_', $prefix.$tax ); elseif ( $php_safe ) $taxes[$key]->name = str_replace( '-', '_', $prefix.$tax->name ); } } // Convert to string if needed if ( 'string' == $format ) $taxes = implode( ', ', $taxes ); return $taxes; } function get_taxonomy_settings( $taxonomy = null ) { $standard_taxonomies = array( 'sm-category' => array( 'singular' => 'Category', 'plural' => 'Categories', 'hierarchical' => true, 'field' => 'category' ), 'sm-tag' => array( 'singular' => 'Tag', 'plural' => 'Tags', 'field' => 'tags' ), 'sm-day' => array( 'singular' => 'Day', 'plural' => 'Days', 'field' => 'days', 'description' => 'day of week' ), 'sm-time' => array( 'singular' => 'Time', 'plural' => 'Times', 'field' => 'times', 'description' => 'time of day' ), ); if ( empty( $taxonomy ) ) { return $standard_taxonomies; } if ( isset( $standard_taxonomies[$taxonomy] ) ) { return $standard_taxonomies[$taxonomy]; } else { $singular = ucwords( substr( $taxonomy, strpos( $taxonomy, '-' ) + 1 ) ); return array( 'singular' => $singular, 'plural' => $singular . 's' ); } } // This function returns the default SimpleMap options function get_options() { $options = array(); $saved = get_option( 'SimpleMap_options' ); if ( !empty( $saved ) ) { $options = $saved; } static $default = null; if ( empty( $default ) ) { $default = array( 'map_width' => '100%', 'map_height' => '350px', 'default_lat' => '44.968684', 'default_lng' => '-93.215561', 'zoom_level' => '10', 'default_radius' => '10', 'map_type' => 'ROADMAP', 'special_text' => '', 'default_state' => '', 'default_country' => 'US', 'default_language' => 'en', 'default_domain' => '.com', 'map_stylesheet' => 'inc/styles/light.css', 'units' => 'mi', 'autoload' => 'all', 'lock_default_location' => false, 'results_limit' => '1',//'20', 'results_page' => '0', 'address_format' => 'town, province postalcode', 'powered_by' => 0, 'enable_permalinks' => 0, 'permalink_slug' => 'location', 'display_search' => 'show', 'map_pages' => '0', 'adsense_for_maps' => 0, 'adsense_pub_id' => '', 'adsense_channel_id' => '', 'adsense_max_ads' => 2, //'api_key' => '', 'auto_locate' => '', 'taxonomies' => array( 'sm-category' => $this->get_taxonomy_settings( 'sm-category' ), 'sm-tag' => $this->get_taxonomy_settings( 'sm-tag' ), ), ); $valid_map_type_map = array( 'ROADMAP' => 'ROADMAP', 'SATELLITE' => 'SATELLITE', 'HYBRID' => 'HYBRID', 'TERRAIN' => 'TERRAIN', 'G_NORMAL_MAP' => 'ROADMAP', 'G_SATELLITE_MAP' => 'SATELLITE', 'G_HYBRID_MAP' => 'HYBRID', 'G_PHYSICAL_MAP' => 'TERRAIN', ); if ( empty( $valid_map_type_map[$options['map_type']] ) ) { $options['map_type'] = $default['map_type']; } else { $options['map_type'] = $valid_map_type_map[$options['map_type']]; } } $options += $default; if ( isset( $options['days_taxonomy'] ) ) { if ( ! empty( $options['days_taxonomy'] ) ) { $options['taxonomies']['sm-day'] = $this->get_taxonomy_settings( 'sm-day' ); } unset( $options['days_taxonomy'] ); } if ( isset( $options['time_taxonomy'] ) ) { if ( ! empty( $options['time_taxonomy'] ) ) { $options['taxonomies']['sm-time'] = $this->get_taxonomy_settings( 'sm-time' ); } unset( $options['time_taxonomy'] ); } if ( $saved != $options ) { update_option( 'SimpleMap_options', $options ); } return $options; } // Google Domains function get_domain_options() { $domains_list = array( 'United States' => '.com', 'Austria' => '.at', 'Australia' => '.com.au', 'Bosnia and Herzegovina' => '.com.ba', 'Belgium' => '.be', 'Brazil' => '.com.br', 'Canada' => '.ca', 'Switzerland' => '.ch', 'Czech Republic' => '.cz', 'Germany' => '.de', 'Denmark' => '.dk', 'Spain' => '.es', 'Finland' => '.fi', 'France' => '.fr', 'Italy' => '.it', 'Japan' => '.jp', 'Netherlands' => '.nl', 'Norway' => '.no', 'New Zealand' => '.co.nz', 'Poland' => '.pl', 'Russia' => '.ru', 'Sweden' => '.se', 'Taiwan' => '.tw', 'United Kingdom' => '.co.uk', 'South Africa' => '.co.za' ); return apply_filters( 'sm-domain-list', $domains_list ); } // Region list from http://code.google.com/apis/adwords/docs/appendix/provincecodes.html // Used for Maps v3 localization: http://code.google.com/apis/maps/documentation/javascript/basics.html#Localization function get_region_options() { $region_list = array( 'US' => 'United States', 'AR' => 'Argentina', 'AU' => 'Australia', 'AT' => 'Austria', 'BE' => 'Belgium', 'BR' => 'Brazil', 'CA' => 'Canada', 'CL' => 'Chile', 'CN' => 'China', 'CO' => 'Colombia', 'HR' => 'Croatia', 'CZ' => 'Czech Republic', 'DK' => 'Denmark', 'EG' => 'Egypt', 'FI' => 'Finland', 'FR' => 'France', 'DE' => 'Germany', 'HU' => 'Hungary', 'IN' => 'India', 'IE' => 'Ireland', 'IL' => 'Israel', 'IT' => 'Italy', 'JP' => 'Japan', 'MY' => 'Malaysia', 'MX' => 'Mexico', 'MA' => 'Morocco', 'NL' => 'Netherlands', 'NZ' => 'New Zealand', 'NG' => 'Nigeria', 'NO' => 'Norway', 'PL' => 'Poland', 'PT' => 'Portugal', 'RU' => 'Russian Federation', 'SA' => 'Saudi Arabia', 'ZA' => 'South Africa', 'KR' => 'South Korea', 'ES' => 'Spain', 'SE' => 'Sweden', 'CH' => 'Switzerland', 'TH' => 'Thailand', 'TR' => 'Turkey', 'UA' => 'Ukraine', 'GB' => 'United Kingdom', ); return apply_filters( 'sm-region-list', $region_list ); } // Country list function get_country_options() { $country_list = array( 'US' => 'United States', 'AF' => 'Afghanistan', 'AL' => 'Albania', 'DZ' => 'Algeria', 'AS' => 'American Samoa', 'AD' => 'Andorra', 'AO' => 'Angola', 'AI' => 'Anguilla', 'AQ' => 'Antarctica', 'AG' => 'Antigua and Barbuda', 'AR' => 'Argentina', 'AM' => 'Armenia', 'AW' => 'Aruba', 'AU' => 'Australia', 'AT' => 'Austria', 'AZ' => 'Azerbaijan', 'BS' => 'Bahamas', 'BH' => 'Bahrain', 'BD' => 'Bangladesh', 'BB' => 'Barbados', 'BY' => 'Belarus', 'BE' => 'Belgium', 'BZ' => 'Belize', 'BJ' => 'Benin', 'BM' => 'Bermuda', 'BT' => 'Bhutan', 'BO' => 'Bolivia', 'BA' => 'Bosnia and Herzegowina', 'BW' => 'Botswana', 'BV' => 'Bouvet Island', 'BR' => 'Brazil', 'IO' => 'British Indian Ocean Territory', 'BN' => 'Brunei Darussalam', 'BG' => 'Bulgaria', 'BF' => 'Burkina Faso', 'BI' => 'Burundi', 'KH' => 'Cambodia', 'CM' => 'Cameroon', 'CA' => 'Canada', 'CV' => 'Cape Verde', 'KY' => 'Cayman Islands', 'CF' => 'Central African Republic', 'TD' => 'Chad', 'CL' => 'Chile', 'CN' => 'China', 'CX' => 'Christmas Island', 'CC' => 'Cocos (Keeling) Islands', 'CO' => 'Colombia', 'KM' => 'Comoros', 'CG' => 'Congo', 'CD' => 'Congo, The Democratic Republic of the', 'CK' => 'Cook Islands', 'CR' => 'Costa Rica', 'CI' => 'Cote D\'Ivoire', 'HR' => 'Croatia (Local Name: Hrvatska)', 'CU' => 'Cuba', 'CY' => 'Cyprus', 'CZ' => 'Czech Republic', 'DK' => 'Denmark', 'DJ' => 'Djibouti', 'DM' => 'Dominica', 'DO' => 'Dominican Republic', 'TP' => 'East Timor', 'EC' => 'Ecuador', 'EG' => 'Egypt', 'SV' => 'El Salvador', 'GQ' => 'Equatorial Guinea', 'ER' => 'Eritrea', 'EE' => 'Estonia', 'ET' => 'Ethiopia', 'FK' => 'Falkland Islands (Malvinas)', 'FO' => 'Faroe Islands', 'FJ' => 'Fiji', 'FI' => 'Finland', 'FR' => 'France', 'FX' => 'France, Metropolitan', 'GF' => 'French Guiana', 'PF' => 'French Polynesia', 'TF' => 'French Southern Territories', 'GA' => 'Gabon', 'GM' => 'Gambia', 'GE' => 'Georgia', 'DE' => 'Germany', 'GH' => 'Ghana', 'GI' => 'Gibraltar', 'GR' => 'Greece', 'GL' => 'Greenland', 'GD' => 'Grenada', 'GP' => 'Guadeloupe', 'GU' => 'Guam', 'GT' => 'Guatemala', 'GN' => 'Guinea', 'GW' => 'Guinea-Bissau', 'GY' => 'Guyana', 'HT' => 'Haiti', 'HM' => 'Heard and Mc Donald Islands', 'VA' => 'Holy See (Vatican City State)', 'HN' => 'Honduras', 'HK' => 'Hong Kong', 'HU' => 'Hungary', 'IS' => 'Iceland', 'IN' => 'India', 'ID' => 'Indonesia', 'IR' => 'Iran (Islamic Republic of)', 'IQ' => 'Iraq', 'IE' => 'Ireland', 'IL' => 'Israel', 'IT' => 'Italy', 'JM' => 'Jamaica', 'JP' => 'Japan', 'JO' => 'Jordan', 'KZ' => 'Kazakhstan', 'KE' => 'Kenya', 'KI' => 'Kiribati', 'KP' => 'Korea, Democratic People\'s Republic of', 'KR' => 'Korea, Republic of', 'KW' => 'Kuwait', 'KG' => 'Kyrgyzstan', 'LA' => 'Lao People\'s Democratic Republic', 'LV' => 'Latvia', 'LB' => 'Lebanon', 'LS' => 'Lesotho', 'LR' => 'Liberia', 'LY' => 'Libyan Arab Jamahiriya', 'LI' => 'Liechtenstein', 'LT' => 'Lithuania', 'LU' => 'Luxembourg', 'MO' => 'Macau', 'MK' => 'Macedonia, Former Yugoslav Republic of', 'MG' => 'Madagascar', 'MW' => 'Malawi', 'MY' => 'Malaysia', 'MV' => 'Maldives', 'ML' => 'Mali', 'MT' => 'Malta', 'MH' => 'Marshall Islands', 'MQ' => 'Martinique', 'MR' => 'Mauritania', 'MU' => 'Mauritius', 'YT' => 'Mayotte', 'MX' => 'Mexico', 'FM' => 'Micronesia, Federated States of', 'MD' => 'Moldova, Republic of', 'MC' => 'Monaco', 'MN' => 'Mongolia', 'MS' => 'Montserrat', 'MA' => 'Morocco', 'MZ' => 'Mozambique', 'MM' => 'Myanmar', 'NA' => 'Namibia', 'NR' => 'Nauru', 'NP' => 'Nepal', 'NL' => 'Netherlands', 'AN' => 'Netherlands Antilles', 'NC' => 'New Caledonia', 'NZ' => 'New Zealand', 'NI' => 'Nicaragua', 'NE' => 'Niger', 'NG' => 'Nigeria', 'NU' => 'Niue', 'NF' => 'Norfolk Island', 'MP' => 'Northern Mariana Islands', 'NO' => 'Norway', 'OM' => 'Oman', 'PK' => 'Pakistan', 'PW' => 'Palau', 'PA' => 'Panama', 'PG' => 'Papua New Guinea', 'PY' => 'Paraguay', 'PE' => 'Peru', 'PH' => 'Philippines', 'PN' => 'Pitcairn', 'PL' => 'Poland', 'PT' => 'Portugal', 'PR' => 'Puerto Rico', 'QA' => 'Qatar', 'RE' => 'Reunion', 'RO' => 'Romania', 'RU' => 'Russian Federation', 'RW' => 'Rwanda', 'KN' => 'Saint Kitts and Nevis', 'LC' => 'Saint Lucia', 'VC' => 'Saint Vincent and The Grenadines', 'WS' => 'Samoa', 'SM' => 'San Marino', 'ST' => 'Sao Tome And Principe', 'SA' => 'Saudi Arabia', 'SN' => 'Senegal', 'SC' => 'Seychelles', 'SL' => 'Sierra Leone', 'SG' => 'Singapore', 'SK' => 'Slovakia (Slovak Republic)', 'SI' => 'Slovenia', 'SB' => 'Solomon Islands', 'SO' => 'Somalia', 'ZA' => 'South Africa', 'GS' => 'South Georgia, South Sandwich Islands', 'ES' => 'Spain', 'LK' => 'Sri Lanka', 'SH' => 'St. Helena', 'PM' => 'St. Pierre and Miquelon', 'SD' => 'Sudan', 'SR' => 'Suriname', 'SJ' => 'Svalbard and Jan Mayen Islands', 'SZ' => 'Swaziland', 'SE' => 'Sweden', 'CH' => 'Switzerland', 'SY' => 'Syrian Arab Republic', 'TW' => 'Taiwan', 'TJ' => 'Tajikistan', 'TZ' => 'Tanzania, United Republic of', 'TH' => 'Thailand', 'TG' => 'Togo', 'TK' => 'Tokelau', 'TO' => 'Tonga', 'TT' => 'Trinidad and Tobago', 'TN' => 'Tunisia', 'TR' => 'Turkey', 'TM' => 'Turkmenistan', 'TC' => 'Turks and Caicos Islands', 'TV' => 'Tuvalu', 'UG' => 'Uganda', 'UA' => 'Ukraine', 'AE' => 'United Arab Emirates', 'GB' => 'United Kingdom', 'UM' => 'United States Minor Outlying Islands', 'UY' => 'Uruguay', 'UZ' => 'Uzbekistan', 'VU' => 'Vanuatu', 'VE' => 'Venezuela', 'VN' => 'Vietnam', 'VG' => 'Virgin Islands (British)', 'VI' => 'Virgin Islands (U.S.)', 'WF' => 'Wallis and Futuna Islands', 'EH' => 'Western Sahara', 'YE' => 'Yemen', 'YU' => 'Yugoslavia', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe' ); return apply_filters( 'sm-country-list', $country_list ); } // Region list from http://code.google.com/apis/maps/faq.html#languagesupport // Used for Maps v3 localization: http://code.google.com/apis/maps/documentation/javascript/basics.html#Localization function get_language_options() { $language_list = array( 'ar' => 'Arabic', 'eu' => 'Basque', 'bg' => 'Bulgarian', 'bn' => 'Bengali', 'ca' => 'Catalan', 'cs' => 'Czech', 'da' => 'Danish', 'de' => 'German', 'el' => 'Greek', 'en' => 'English', 'en-AU' => 'English (Australian)', 'en-GB' => 'English (Great Britain)', 'es' => 'Spanish', 'eu' => 'Basque', 'fa' => 'Farsi', 'fi' => 'Finnish', 'fil' => 'Filipino', 'fr' => 'French', 'gl' => 'Galician', 'gu' => 'Gujarati', 'hi' => 'Hindi', 'hr' => 'Croatian', 'hu' => 'Hungarian', 'id' => 'Indonesian', 'it' => 'Italian', 'iw' => 'Hebrew', 'ja' => 'Japanese', 'kn' => 'Kannada', 'ko' => 'Korean', 'lt' => 'Lithuanian', 'lv' => 'Latvian', 'ml' => 'Malayalam', 'mr' => 'Marathi', 'nl' => 'Dutch', 'no' => 'Norwegian', 'pl' => 'Polish', 'pt' => 'Portuguese', 'pt-BR' => 'Portuguese (Brazil)', 'pt-PT' => 'Portuguese (Portugal)', 'ro' => 'Romanian', 'ru' => 'Russian', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'sr' => 'Serbian', 'sv' => 'Swedish', 'tl' => 'Tagalog', 'ta' => 'Tamil', 'te' => 'Telugu', 'th' => 'Thai', 'tr' => 'Turkish', 'uk' => 'Ukrainian', 'vi' => 'Vietnamese', 'zh-CN' => 'Chinese (Simplified)', 'zh-TW' => 'Chinese (Traditional)', ); return apply_filters( 'sm-language-list', $language_list ); } function get_auto_locate_options() { $auto_locate_list = array( '' => 'No Automatic Location', 'ip' => 'Use IP Address', 'html5' => 'Use HTML5', ); return apply_filters( 'sm-auto-locte-list', $auto_locate_list ); } // Echo the toolbar function show_toolbar( $title = '' ) { global $simple_map; $options = $simple_map->get_options(); if ( '' == $title ) $title = 'SimpleMap'; ?>
' . __( 'You must enter an API key for your domain.', 'SimpleMap' ).' ' . __( 'Enter a key on the General Options page.', 'SimpleMap' ) . '
'; */ } // Return the available search_radii function get_search_radii(){ $search_radii = array( 1, 5, 10, 25, 50, 100, 500, 1000 ); return apply_filters( 'sm-search-radii', $search_radii ); } // What link are we using for google's API function get_api_link() { $lo = str_replace('_', '-', get_locale()); $l = substr($lo, 0, 2); switch($l) { case 'es': case 'de': case 'ja': case 'ko': case 'ru': $api_link = "http://code.google.com/intl/$l/apis/maps/signup.html"; break; case 'pt': case 'zh': $api_link = "http://code.google.com/intl/$lo/apis/maps/signup.html"; break; case 'en': default: $api_link = "http://code.google.com/apis/maps/signup.html"; break; } return $api_link; } // Returns true if legacy tables exist in the DB function legacy_tables_exist() { global $wpdb; $sql = "SHOW TABLES LIKE '" . $wpdb->prefix . "simple_map'"; if ( $tables = $wpdb->get_results( $sql ) ) { return true; } return false; } // Search form / widget query vars function register_query_vars( $vars ) { $vars[] = 'location_search_address'; $vars[] = 'location_search_city'; $vars[] = 'location_search_state'; $vars[] = 'location_search_zip'; $vars[] = 'location_search_distance'; $vars[] = 'location_search_limit'; $vars[] = 'location_search_page'; $vars[] = 'location_is_search_results'; return $vars; } /** * Parses the shortcode attributes with the default options and returns array * * @since 2.3 */ function parse_shortcode_atts( $shortcode_atts ) { $options = $this->get_options(); $default_atts = $this->get_default_shortcode_atts(); $atts = shortcode_atts( $default_atts, $shortcode_atts ); // If deprecated shortcodes were used, replace with current ones if ( isset( $atts['show_categories_filter'] ) ) $atts['show_sm_category_filter'] = $atts['show_categories_filter']; if ( isset( $atts['show_tags_filter'] ) ) $atts['show_sm_tag_filter'] = $atts['show_tags_filter']; if ( isset( $atts['show_days_filter'] ) ) $atts['show_sm_day_filter'] = $atts['show_days_filter']; if ( isset( $atts['show_times_filter'] ) ) $atts['show_sm_time_filter'] = $atts['show_times_filter']; if ( isset( $atts['categories'] ) ) $atts['sm_category'] = $atts['categories']; if ( isset( $atts['tags'] ) ) $atts['sm_tag'] = $atts['tags']; if ( isset( $atts['days'] ) ) $atts['sm_day'] = $atts['days']; if ( isset( $atts['times'] ) ) $atts['sm_time'] = $atts['times']; // Determine if we need to hide the search form or not if ( '' == $atts['hide_search'] ) { // Use default value if ( 'show' == $options['display_search'] ) $atts['hide_search'] = 0; else $atts['hide_search'] = 1; } // Set categories and tags to available equivelants $atts['avail_sm_category'] = $atts['sm_category']; $atts['avail_sm_tag'] = $atts['sm_tag']; $atts['avail_sm_day'] = $atts['sm_day']; $atts['avail_sm_time'] = $atts['sm_time']; // Default lat / lng from shortcode? if ( ! $atts['default_lat'] ) $atts['default_lat'] = $options['default_lat']; if ( ! $atts['default_lng'] ) $atts['default_lng'] = $options['default_lng']; // Doing powered by? if ( '' == $atts['powered_by'] ) { // Use default value $atts['powered_by'] = $options['powered_by']; } else { // Use shortcode if ( 0 == $atts['powered_by'] ) $atts['powered_by'] = 0; else $atts['powered_by'] = 1; } // Default units or shortcode units? if ( 'km' != $atts['units'] && 'mi' != $atts['units'] ) $atts['units'] = $options['units']; // Default radius or shortcode radius? if ( '' != $atts['radius'] && in_array( $atts['radius'], $this->get_search_radii() ) ) $atts['radius'] = absint( $atts['radius'] ); else $atts['radius'] = $options['default_radius']; //Make sure we have limit if ( '' == $atts['limit'] ) $atts['limit'] = $options['results_limit']; //Make sure we have page if ( '' == $atts['page'] ) $atts['page'] = $options['results_page']; // Clean search_field_cols if ( 0 === absint( $atts['search_form_cols'] ) ) $atts['search_form_cols'] = $default_atts['search_form_cols']; // Which type of map are we using? if ( '' == $atts['map_type'] ) $atts['map_type'] = $options['map_type']; // Height of the map? if ( '' == $atts['map_height'] ) $atts['map_height'] = $options['map_height']; // Width of the map? if ( '' == $atts['map_width'] ) $atts['map_width'] = $options['map_width']; // Which zoom level are we using? if ( '' == $atts['zoom_level'] ) $atts['zoom_level'] = $options['zoom_level']; // Which autoload option are we using? if ( '' == $atts['autoload'] ) $atts['autoload'] = $options['autoload']; // Return final array return $atts; } /** * Returns default shortcode attributes * * @since 2.3 */ function get_default_shortcode_atts() { $options = $this->get_options(); $tax_atts = array(); $tax_search_fields = array(); foreach ( $options['taxonomies'] as $taxonomy => $taxonomy_info ) { $tax_search_fields[] = "||labeltd_$taxonomy||empty"; $safe_tax = str_replace('-', '_', $taxonomy); $tax_atts[$safe_tax] = ''; $tax_atts['show_' . $safe_tax . '_filter'] = 1; // The following are deprecated. Don't use them. $tax_atts[strtolower($taxonomy_info['plural'])] = null; $tax_atts['show_' . strtolower($taxonomy_info['plural']) . '_filter'] = null; } $atts = $tax_atts + array( 'search_title' => __( 'Find Locations Near:', 'SimpleMap' ), 'search_form_type' => 'table', 'search_form_cols' => 3, 'search_fields' => 'labelbr_street||labelbr_city||labelbr_state||labelbr_zip||empty||empty||labeltd_distance||empty' . implode('', $tax_search_fields) . '||submit||empty||empty', 'taxonomy_field_type' => 'checkboxes', 'hide_search' => '', 'hide_map' => 0, 'hide_list' => 0, 'default_lat' => 0, 'default_lng' => 0, 'adsense_publisher_id' => 0, 'adsense_channel_id' => 0, 'adsense_max_ads' => 0, 'map_width' => '', 'map_height' => '', 'units' => '', 'radius' => '', 'limit' => '', 'page' => '', 'autoload' => '', 'zoom_level' => '', 'map_type' => '', 'powered_by' => '', 'sm_day' => '', 'sm_time' => '' ); return apply_filters( 'sm-default-shortcode-atts', $atts ); } // This function filters category text labels function backwards_compat_categories_text( $text ) { return __( 'Categories', 'SimpleMap' ); } // This function filters category text labels function backwards_compat_tags_text( $text ) { return __( 'Tags', 'SimpleMap' ); } // This function filters category text labels function backwards_compat_days_text( $text ) { return __( 'Days', 'SimpleMap' ); } // This function filters category text labels function backwards_compat_times_text( $text ) { return __( 'Times', 'SimpleMap' ); } } }