settings = NIMAP_DATA::get_instance(); $this->language = ''; add_action( 'init', array( $this, 'shortcode_init' ) ); // Ajax //add_action( 'wp_ajax_nimap_location_search', array( $this, 'nimap_location_search' ) ); //Locator search add_action( 'wp_ajax_nimap_location_store', array( $this, 'nimap_location_store' ) ); add_action( 'wp_ajax_nopriv_nimap_location_store', array( $this, 'nimap_location_store' ) ); //Store data search add_action( 'wp_ajax_nimap_store_info_search', array( $this, 'nimap_store_info_search' ) ); add_action( 'wp_ajax_nopriv_nimap_store_info_search', array( $this, 'nimap_store_info_search' ) ); } public function shortcode_init() { add_shortcode( 'nimap_store_locator', array( $this, 'render_store_locator' ) ); add_shortcode( 'nimap_store_search', array( $this, 'render_store_search' ) ); add_shortcode( 'nimap_store_detail', array( $this, 'render_store_detail' ) ); add_shortcode( 'nimap_store_widget', array( $this, 'render_store_widget' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_register_script' ) ); // add_action( 'wp_footer', array( $this, 'add_frontend_scripts' ) ); } public function render_store_locator( $atts, $content = null ) { // if ( ! wp_script_is( 'nimap-frontend' ) ) { // wp_enqueue_script( 'nimap-frontend' ); // wp_enqueue_style( 'nimap-frontend' ); // } // // FRONTEND Public // $shortcode_attr = array(); // extract( shortcode_atts( // array( // 'template' => ( ( ! empty( $atts['template'] ) || $atts['template'] == '0' ) ? $shortcode_attr['template'] = 'template="' . $atts['template'] . '"' : '' ), // 'search_type' => ( ( ! empty( $atts['search_type'] ) || $atts['search_type'] == '0' ) ? $shortcode_attr['search_type'] = 'search_type="' . $atts['search_type'] . '"' : '' ), // 'layout' => ( ( ! empty( $atts['layout'] ) || $atts['layout'] == '0' ) ? $shortcode_attr['layout'] = 'layout="' . $atts['layout'] . '"' : '' ), // 'distance_control' => ( ( ! empty( $atts['distance_control'] ) || $atts['distance_control'] == '0' ) ? $shortcode_attr['distance_control'] = 'distance_control="' . $atts['distance_control'] . '"' : '' ), // 'head_title' => '' // ), // $atts ) ); // $shortcode_attr = implode( ' ', $shortcode_attr ); // $shortcode = '[NIMAP_STORELOCATOR ' . $shortcode_attr . ']'; // extract( shortcode_atts( array( // 'layout_type' => 'fullwidth', // 'map_lang' => '', // ), $atts ) ); if ( ! $atts ) { $atts = array(); } $all_configs = $this->settings->get_params(); if ( ! empty( $atts ) && is_array( $atts ) ) { $all_configs = shortcode_atts( $all_configs, $atts ); } $all_configs = array_merge( $all_configs, $atts ); $lang = $this->format_lang_code( $all_configs['map_language'], $all_configs['map_locale'] ); if ( $lang ) { $all_configs['lang'] = $lang; } // if ( isset( $_GET['mapppin_latitude'] ) && isset( $_GET['mapppin_longitude'] ) ) { // $all_configs['map_start_latitude'] = sanitize_text_field( wp_unslash( $_GET['mapppin_latitude'] ) ); // $all_configs['map_start_longitude'] = sanitize_text_field( wp_unslash( $_GET['mapppin_longitude'] ) ); // } // Get the JSON for the Map layout $all_configs['map_style'] = NIMAP_MULTI_LOCATOR_Function::mapStyle( $all_configs['map_style'], $all_configs['map_custom_style'] ); $all_configs = apply_filters( 'nimap_filter_locator_attrs', $all_configs ); $all_categories = array(); $terms_categories = get_terms( [ 'taxonomy' => 'nimap_store_category', 'hide_empty' => false, ] ); foreach ( $terms_categories as $_result ) { $all_categories[ $_result->term_id ] = $_result; } $this->enqueue_scripts( 'locator', $all_configs ); $template_selected = 'location-locator.php'; $is_customize = self::is_customize_preview(); // $template_selected = isset( $all_configs['locator_template'] ) ? $all_configs['locator_template'] : $all_configs['general_store_locator_type']; // switch ( $template_selected ) { // case 'fullwidth': // $template_file = 'location-locator.php'; // break; // case '2col': // default: // $template_file = 'store-locator.php'; // } ob_start(); if ( $theme_file = locate_template( array( $template_selected ) ) ) { $template_path = $theme_file; } else { $template_path = NIMAP_TEMPLATES . $template_selected; } include $template_path; $mp_output = ob_get_contents(); ob_end_clean(); return $mp_output; } public function render_store_search( $atts ) { if ( ! $atts ) { $atts = array(); } $all_configs = $this->settings->get_params(); if ( ! empty( $atts ) && is_array( $atts ) ) { $all_configs = shortcode_atts( $all_configs, $atts ); } $all_configs = array_merge( $all_configs, $atts ); // Language if ( ! empty( $atts ) && is_array( $atts ) ) { $all_configs = shortcode_atts( $all_configs, $atts ); } $lang = $this->format_lang_code( $all_configs['map_language'], $all_configs['map_locale'] ); if ( $lang ) { $all_configs['lang'] = $lang; } $all_configs = apply_filters( 'nimap_filter_list_attrs', $all_configs ); // Get the categories $all_categories = array(); $terms_categories = get_terms( [ 'taxonomy' => 'nimap_store_category', 'hide_empty' => false, ] ); foreach ( $terms_categories as $_result ) { $all_categories[ $_result->term_id ] = $_result; } $number_post = $this->settings->get_params( 'store_paging_enable' ) ? (int) $this->settings->get_params( 'store_paging_number' ) : - 1; $store_list = get_posts( [ 'post_type' => 'nimap_store', // 'post_status' => 'publish', 'order' => 'ASC', 'numberposts' => - 1, ] ); $store_count = 0; if ( is_array( $store_list ) ) { $store_count = count( $store_list ); if ( $store_count > $number_post ) { $store_list = array_slice( $store_list, 0, $number_post ); } } $count_posts_obj = wp_count_posts( 'nimap_store' ); $count_posts = 0; if ( is_object( $count_posts_obj ) ) { foreach ( $count_posts_obj as $p_key => $p_val ) { $count_posts += intval( $p_val ); } } $this->enqueue_scripts( 'list', $all_configs ); ob_start(); $template_file = 'list-locator.php'; if ( $theme_file = locate_template( array( $template_file ) ) ) { $template_path = $theme_file; } else { $template_path = NIMAP_TEMPLATES . $template_file; } include $template_path; $mp_output = ob_get_contents(); ob_end_clean(); return $mp_output; } public function render_store_detail( $atts ) { if ( ! $atts ) { $atts = array(); } if ( isset( $_REQUEST['nimap_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['nimap_nonce'] ) ), 'nimap-nonce' ) ) { $store_id = isset( $_REQUEST['nimap-store'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['nimap-store'] ) ) : ''; } else { $store_id = ''; } $all_configs = $this->settings->get_params(); if ( ! empty( $atts ) && is_array( $atts ) ) { $all_configs = shortcode_atts( $all_configs, $atts ); } $all_configs = array_merge( $all_configs, $atts ); if ( ! empty( $atts ) && is_array( $atts ) ) { $all_configs = shortcode_atts( $all_configs, $atts ); } $lang = $this->format_lang_code( $all_configs['map_language'], $all_configs['map_locale'] ); if ( $lang ) { $all_configs['lang'] = $lang; } $all_configs = apply_filters( 'nimap_filter_list_attrs', $all_configs ); $all_categories = array(); $terms_categories = get_terms( [ 'taxonomy' => 'nimap_store_category', 'hide_empty' => false, ] ); foreach ( $terms_categories as $_result ) { $all_categories[ $_result->term_id ] = $_result; } if ( empty( $store_id ) ) { $store_lists = get_posts( [ 'post_type' => 'nimap_store', 'orderby' => 'date', 'order' => 'DESC', 'numberposts' => 1, ] ); if ( $store_lists && isset( $store_lists[0] ) && is_object( $store_lists[0] ) && property_exists( $store_lists[0], 'ID' ) ) { $store_id = $store_lists[0]->ID; $store_list['title'] = $store_lists[0]->post_title; } } else { $store_list['title'] = get_the_title( $store_id ); } $all_configs['map_style'] = NIMAP_MULTI_LOCATOR_Function::mapStyle( $all_configs['map_style'], $all_configs['map_custom_style'] ); $address_meta = get_post_meta( $store_id, 'nimap_store_address', true ) ?: ''; $all_configs['select_latitude'] = $address_meta && is_array( $address_meta ) && isset( $address_meta['latitude'] ) && $address_meta['latitude'] ? floatval( $address_meta['latitude'] ) : ''; $all_configs['select_longitude'] = $address_meta && is_array( $address_meta ) && isset( $address_meta['longitude'] ) && $address_meta['longitude'] ? floatval( $address_meta['longitude'] ) : ''; $this->enqueue_scripts( 'detail', $all_configs ); ob_start(); $template_file = 'detail-locator.php'; if ( $theme_file = locate_template( array( $template_file ) ) ) { $template_path = $theme_file; } else { $template_path = NIMAP_TEMPLATES . $template_file; } include $template_path; $mp_output = ob_get_contents(); ob_end_clean(); return $mp_output; } public function render_store_widget( $atts ) { if ( ! $atts ) { $atts = array( 'widget_title' => 'Search store' ); } $all_configs = $this->settings->get_params(); if ( ! empty( $atts ) && is_array( $atts ) ) { $all_configs = shortcode_atts( $all_configs, $atts ); } $all_configs = array_merge( $all_configs, $atts ); if ( ! empty( $atts ) && is_array( $atts ) ) { $all_configs = shortcode_atts( $all_configs, $atts ); } $lang = $this->format_lang_code( $all_configs['map_language'], $all_configs['map_locale'] ); if ( $lang ) { $all_configs['lang'] = $lang; } $all_configs = apply_filters( 'nimap_filter_list_attrs', $all_configs ); $all_categories = array(); $terms_categories = get_terms( [ 'taxonomy' => 'nimap_store_category', 'hide_empty' => false, ] ); foreach ( $terms_categories as $_result ) { $all_categories[ $_result->term_id ] = $_result; } $this->enqueue_scripts( 'widget', $all_configs ); ob_start(); $template_file = 'widget-locator.php'; if ( $theme_file = locate_template( array( $template_file ) ) ) { $template_path = $theme_file; } else { $template_path = NIMAP_TEMPLATES . $template_file; } include $template_path; $mp_output = ob_get_contents(); ob_end_clean(); return $mp_output; } function check_store_distance( $stores, $location, $count = '' ) { $d_stores = []; $d_unit = $this->settings->get_params( 'general_distance_unit' ); $earth_radius = 6371000; switch ( $d_unit ) { case 'km': $earth_radius = 6371; break; case 'ml': $earth_radius = 3958.756; break; default: } foreach ( $stores as $s_k => $s_val ) { if ( empty( $s_val ) || ! is_array( $s_val ) || ! isset( $s_val['lng'] ) || ! isset( $s_val['lat'] ) || empty( $location ) || ! is_array( $location ) || ! isset( $location['lng'] ) || ! isset( $location['lat'] ) ) { continue; } $l_store = $s_val; $l_distance = (float) NIMAP_MULTI_LOCATOR_Function::vincentyGreatCircleDistance( $s_val['lat'], $s_val['lng'], $location['lat'], $location['lng'], $earth_radius ); $l_store['distance'] = round( $l_distance, 2 ); $d_stores[] = $l_store; } $d_distance = array_column( $d_stores, 'distance' ); array_multisort( $d_distance, SORT_ASC, $d_stores ); if ( $count && count( $d_stores ) > $count ) { $d_distance = array_slice( $d_distance, 0, $count ); } return $d_stores; } function nimap_location_search() { check_ajax_referer( 'nimap-nonce', 'nonce' ); $o_data = NIMAP_MULTI_LOCATOR_Function::vincentyGreatCircleDistance( 21.576216, 105.849422, 20.814604, 106.810989 ); $o_data = self::check_store_distance( [ [ 'id' => 21, 'lat' => 20.554, 'lng' => 105.43425 ], [ 'id' => 4231, 'lat' => 31.876, 'lng' => 11.345 ], [ 'id' => 134, 'lat' => 27.465, 'lng' => 85.2144 ] ], [ 'lat' => 23.145, 'lng' => 57.465 ] ); wp_send_json( $o_data ); } function nimap_location_store() { check_ajax_referer( 'nimap-nonce', 'nonce' ); $key = isset( $_POST['search'] ) ? (float) sanitize_text_field( wp_unslash( $_POST['search'] ) ) : ''; $latitude = isset( $_POST['lat'] ) ? (float) sanitize_text_field( wp_unslash( $_POST['lat'] ) ) : 0; $longitude = isset( $_POST['lng'] ) ? (float) sanitize_text_field( wp_unslash( $_POST['lng'] ) ) : 0; $max_results = isset( $_POST['result'] ) ? (float) sanitize_text_field( wp_unslash( $_POST['result'] ) ) : 50; $search_radius = isset( $_POST['radius'] ) ? (float) sanitize_text_field( wp_unslash( $_POST['radius'] ) ) : 50; $category = isset( $_POST['category'] ) ? sanitize_text_field( wp_unslash( $_POST['category'] ) ) : ''; $status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : 'publish'; $search_object = [ 'post_type' => 'nimap_store', // 'category' => $category, 'post_status' => $status, 'order' => 'ASC', 'numberposts' => - 1, ]; $store_list = get_posts( $search_object ); $st_unit = $this->settings->get_params( 'general_distance_unit' ); $earth_radius = 6371000; switch ( $st_unit ) { case 'km': $earth_radius = 6371; break; case 'ml': $earth_radius = 3958.756; break; default: } $f_location = [ 'lat' => $latitude, 'lng' => $longitude ]; $stores_data = NIMAP_MULTI_LOCATOR_Function::getFormattedStores( $store_list, $category, $f_location, $search_radius, $earth_radius ); $o_data = NIMAP_MULTI_LOCATOR_Function::sortStoreResults( $stores_data, $this->settings->get_params( 'filter_sort_by' ) ); // $o_data = self::check_store_distance( $stores_data, [ // 'lat' => $latitude, // 'lng' => $longitude // ], $max_results ); wp_send_json( $o_data ); } function nimap_store_info_search() { check_ajax_referer( 'nimap-nonce', 'nonce' ); $page = isset( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; $category = isset( $_POST['category'] ) ? sanitize_text_field( wp_unslash( $_POST['category'] ) ) : ''; $key_word = isset( $_POST['key'] ) ? sanitize_text_field( wp_unslash( $_POST['key'] ) ) : ''; $latitude = isset( $_POST['lat'] ) ? sanitize_text_field( wp_unslash( $_POST['lat'] ) ) : ''; $longitude = isset( $_POST['lng'] ) ? sanitize_text_field( wp_unslash( $_POST['lng'] ) ) : ''; $source = isset( $_POST['source'] ) ? sanitize_text_field( wp_unslash( $_POST['source'] ) ) : 'list'; $search_type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : 'list'; $search_radius = isset( $_POST['radius'] ) ? (float) sanitize_text_field( wp_unslash( $_POST['radius'] ) ) : 0; if ( $source == 'locator' ) { $paging_enable = $this->settings->get_params( 'list_paging_enable' ); $number_post = $paging_enable ? (int) $this->settings->get_params( 'list_paging_number' ) : 999999; } else { $paging_enable = $this->settings->get_params( 'store_paging_enable' ); $number_post = $paging_enable ? (int) $this->settings->get_params( 'store_paging_number' ) : 999999; } $search_field = $this->settings->get_params( 'search_store_by_field' ) ?: 'title'; $store_list = get_posts( [ 'post_type' => 'nimap_store', // 'category' => $category, 'post_status' => 'publish', 'order' => 'ASC', 'numberposts' => - 1, ] ); $store_count = 0; $start_index = $number_post && $paging_enable ? $number_post * ( $page - 1 ) : 0; $stores_data = []; foreach ( $store_list as $store_arr ) { $store_title = get_the_title( $store_arr->ID ) ?: ''; $store_category = get_the_terms( $store_arr->ID, 'nimap_store_category' ); $format_category = []; if ( $store_category && is_array( $store_category ) && ! empty( $store_category ) ) { $exits_cat = false; foreach ( $store_category as $cat_data ) { if ( ! $category ) { $exits_cat = true; } else { if ( ! $exits_cat ) { if ( $cat_data->term_id == $category ) { $exits_cat = true; } } } $format_category[ $cat_data->term_id ] = $cat_data->name; } if ( ! $exits_cat ) { continue; } } $store_description = get_post_meta( $store_arr->ID, 'nimap_store_description', true ) ?: ''; $store_address = get_post_meta( $store_arr->ID, 'nimap_store_address', true ) ?: ''; $store_information = get_post_meta( $store_arr->ID, 'nimap_store_information', true ) ?: ''; $store_opening = get_post_meta( $store_arr->ID, 'nimap_store_opening', true ) ?: ''; $store_image = get_post_meta( $store_arr->ID, 'nimap_store_image', true ) ?: ''; $store_address = maybe_unserialize( $store_address ); $store_information = maybe_unserialize( $store_information ); $store_opening = maybe_unserialize( $store_opening ); $is_match = true; if ( $key_word ) { switch ( $search_field ) { case 'address': if ( ! str_contains( $store_address['address'], $key_word ) ) { $is_match = false; } break; case 'description': if ( ! str_contains( $store_description, $key_word ) ) { $is_match = false; } break; case 'phone': if ( ! str_contains( $store_information['phone'], $key_word ) ) { $is_match = false; } break; case 'email': if ( ! str_contains( $store_information['email'], $key_word ) ) { $is_match = false; } break; case 'website': if ( ! str_contains( $store_information['website'], $key_word ) ) { $is_match = false; } break; case 'zip': if ( ! str_contains( $store_address['zip'], $key_word ) ) { $is_match = false; } break; case 'custom': if ( ! str_contains( $store_information['custom'], $key_word ) ) { $is_match = false; } break; default: if ( ! str_contains( $store_title, $key_word ) ) { $is_match = false; } } } if ( ! $is_match ) { continue; } $s_distance = 0; if ( $latitude && $longitude ) { $st_unit = $this->settings->get_params( 'general_distance_unit' ); $location = [ 'lat' => $latitude, 'lng' => $longitude ]; $earth_radius = 6371000; switch ( $st_unit ) { case 'km': $earth_radius = 6371; break; case 'ml': $earth_radius = 3958.756; break; default: } $s_distance = NIMAP_MULTI_LOCATOR_Function::getStoreDistance( $store_address, $location, $earth_radius ); if ( $search_radius ) { if ( $s_distance > $search_radius ) { continue; } } } $store_count += 1; $store_image = NIMAP_MULTI_LOCATOR_Function::getStoreThumbnail( $store_image, $store_title ); $category_render = NIMAP_MULTI_LOCATOR_Function::printCategory( $format_category ); $store_opening = NIMAP_MULTI_LOCATOR_Function::formatStoreOpening( $store_opening ); $store_data = array( 'id' => $store_arr->ID, 'title' => $store_title, 'description' => $store_description, 'address' => $store_address['address'], // 'information' => $store_information, 'image' => $store_image['list'], 'image_info' => $store_image['info'], 'city' => $store_address['city'], 'state' => isset( $store_address['state'] ) ? $store_address['state'] : '', 'country' => $store_address['country'], 'zip' => $store_address['zip'], 'phone' => $store_information['phone'], 'fax' => $store_information['fax'], 'website' => $store_information['website'], 'url' => $store_information['website'], 'custom' => $store_information['custom'], 'email' => $store_information['email'], 'opening' => NIMAP_MULTI_LOCATOR_Function::printOpening( $store_opening ), 'category' => $category_render[0], 'category_r' => $category_render[1], 'lat' => $store_address['latitude'], 'lng' => $store_address['longitude'], 'distance' => $s_distance, ); $stores_data[] = $store_data; } $sort_data = NIMAP_MULTI_LOCATOR_Function::sortStoreResults( $stores_data, $this->settings->get_params( 'filter_sort_by' ) ); $paging_block = NIMAP_MULTI_LOCATOR_Function::renderPagingResults( count( $stores_data ), $page, $number_post ); //paging $paging_data = $paging_enable && $search_type != 'location' ? array_slice( $sort_data, $start_index, $number_post ) : $sort_data; $o_data = array( 'count' => $store_count, 'paging' => wp_kses_post( $paging_block ), 'stores' => $paging_data ); wp_send_json( $o_data ); } public function get_directions_travel_mode() { $default = 'driving'; $travel_mode = apply_filters( 'nimap_direction_travel_mode', $default ); $allowed_modes = array( 'driving', 'bicycling', 'transit', 'walking' ); if ( ! in_array( $travel_mode, $allowed_modes ) ) { $travel_mode = $default; } return strtoupper( $travel_mode ); } public function shortcode_register_script() { $min = WP_DEBUG ? '' : '.min'; if ( ! wp_style_is( 'nimap-locator', 'registered' ) ) { wp_register_style( 'nimap-locator', NIMAP_CSS . 'nimap-locator' . $min . '.css', array(), NIMAP_VERSION ); } if ( ! wp_style_is( 'nimap-list', 'registered' ) ) { wp_register_style( 'nimap-list', NIMAP_CSS . 'nimap-list' . $min . '.css', array(), NIMAP_VERSION ); } if ( ! wp_style_is( 'nimap-details', 'registered' ) ) { wp_register_style( 'nimap-details', NIMAP_CSS . 'nimap-details' . $min . '.css', array(), NIMAP_VERSION ); } if ( ! wp_style_is( 'nimap-widget', 'registered' ) ) { wp_register_style( 'nimap-widget', NIMAP_CSS . 'nimap-widget' . $min . '.css', array(), NIMAP_VERSION ); } if ( ! wp_style_is( 'nimap-icon', 'registered' ) ) { wp_register_style( 'nimap-icon', NIMAP_CSS . 'nimap-icon.min.css', array(), NIMAP_VERSION ); } if ( ! wp_script_is( 'nimap-locator', 'registered' ) ) { wp_register_script( 'nimap-locator', NIMAP_JS . 'nimap-locator' . $min . '.js', array( 'jquery' ), NIMAP_VERSION, false ); } if ( ! wp_script_is( 'nimap-list', 'registered' ) ) { wp_register_script( 'nimap-list', NIMAP_JS . 'nimap-list' . $min . '.js', array( 'jquery' ), NIMAP_VERSION, false ); } if ( ! wp_script_is( 'nimap-details', 'registered' ) ) { wp_register_script( 'nimap-details', NIMAP_JS . 'nimap-details' . $min . '.js', array( 'jquery' ), NIMAP_VERSION, false ); } if ( ! wp_script_is( 'nimap-widget', 'registered' ) ) { wp_register_script( 'nimap-widget', NIMAP_JS . 'nimap-widget' . $min . '.js', array( 'jquery' ), NIMAP_VERSION, false ); } if ( ! wp_script_is( 'nimap-infobox', 'registered' ) ) { wp_register_script( 'nimap-infobox', NIMAP_JS . 'infobox.js', array( 'jquery' ), NIMAP_VERSION, false ); } if ( ! wp_script_is( 'nimap-markerclusterer', 'registered' ) ) { wp_register_script( 'nimap-markerclusterer', NIMAP_JS . 'markerclusterer.js', array( 'jquery' ), NIMAP_VERSION, false ); } $detail_link = get_permalink( $this->settings->get_page_locator( 'general_store_detail' ) ); $list_vars = array( 'nonce' => wp_create_nonce( 'nimap-nonce' ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'storeLink' => $detail_link, 'noResults' => $this->settings->get_params( 'list_no_result_title' ), 'countResults' => $this->settings->get_params( 'list_count_title' ), 'findEmpty' => esc_html__( 'No store found', '9map-map-multi-locations' ), 'preloader' => esc_html__( 'Searching...', '9map-map-multi-locations' ), 'autoCompleteOptions' => apply_filters( 'nimap_autocomplete_options', array( 'fields' => array( 'address_components', 'geometry', 'name' ), ) ), 'iconUrl' => NIMAP_IMAGES, 'mapDistanceUnit' => $this->settings->get_params( 'general_distance_unit' ) == 'km' ? '(km)' : '(ml)', ); //locator $eq_labels = array( 'preloader' => esc_html__( 'Searching...', '9map-map-multi-locations' ), 'noResults' => $this->settings->get_params( 'list_no_result_title' ), 'countResults' => $this->settings->get_params( 'list_count_title' ), 'moreInfo' => esc_html__( 'More info', '9map-map-multi-locations' ), 'generalError' => esc_html__( 'Something went wrong, please try again!', '9map-map-multi-locations' ), 'queryLimit' => esc_html__( 'API usage limit reached', '9map-map-multi-locations' ), 'directions' => esc_html__( 'Directions', '9map-map-multi-locations' ), 'noDirectionsFound' => esc_html__( 'No route could be found between the origin and destination', '9map-map-multi-locations' ), 'startPoint' => esc_html__( 'Start location', '9map-map-multi-locations' ), 'back' => esc_html__( 'Back', '9map-map-multi-locations' ), 'streetView' => esc_html__( 'Street view', '9map-map-multi-locations' ), 'zoomHere' => esc_html__( 'Zoom here', '9map-map-multi-locations' ), 'denied' => esc_html__( 'The application does not have permission to use the Geolocation API.', '9map-map-multi-locations' ), 'unavailable' => esc_html__( 'Location information is unavailable.', '9map-map-multi-locations' ), 'timeout' => esc_html__( 'The geolocation request timed out.', '9map-map-multi-locations' ), 'generalGeoError' => esc_html__( 'An unknown error occurred.', '9map-map-multi-locations' ) ); $st_localize = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'nimap-nonce' ), 'storeLink' => $detail_link, 'apiKey' => $this->settings->get_params( 'general_api_key' ), 'markerClusters' => $this->settings->get_params( 'map_marker_clusters' ) ?: 0, 'clusterZoom' => $this->settings->get_params( 'map_cluster_zoom' ) ?: 0, 'clusterSize' => $this->settings->get_params( 'map_cluster_size' ) ?: 0, 'autoLocate' => $this->settings->get_params( 'map_auto_locate' ) ?: 0, 'directionRedirect' => $this->settings->get_params( 'map_direction_redirect' ) ?: 0, 'autoLoad' => $this->settings->get_params( 'map_auto_load_stores' ), 'zoomLevel' => $this->settings->get_params( 'map_zoom_level' ), 'markerZoomTo' => $this->settings->get_params( 'map_marker_zoom_to' ) ?: 0, 'autoZoomLevel' => $this->settings->get_params( 'map_auto_zoom_level' ), 'scrollWheel' => $this->settings->get_params( 'map_scroll_wheel' ) ?: false, 'gestureHandling' => $this->settings->get_params( 'map_gesture_handling' ), 'controlPosition' => $this->settings->get_params( 'map_control_position' ) ?: 'RIGHT_BOTTOM', 'loadLocation' => $this->settings->get_params( 'map_load_location_init' ), 'startLatlng' => $this->settings->get_params( 'map_start_latitude' ) . ',' . $this->settings->get_params( 'map_start_longitude' ), 'infoWindowStyle' => $this->settings->get_params( 'map_info_window_style' ) ?: '', 'markerIconProps' => [ 'scaledSize' => '24,35', 'origin' => '0,0', 'anchor' => '12,35' ], 'url' => NIMAP_IMAGES, 'preloader' => NIMAP_IMAGES . 'ajax-loader.gif', 'autoCompleteOptions' => apply_filters( 'nimap_autocomplete_options', array( 'fields' => array( 'address_components', 'geometry', 'name' ), // 'fields' => array( "address_components", "geometry.location", "name" ), // 'types' => array( '(regions)' ) ) ), 'autoComplete' => $this->settings->get_params( 'map_auto_complete' ) ?: 1, 'mapType' => $this->settings->get_params( 'map_type' ) ?: 'roadmap', 'mapId' => $this->settings->get_params( 'general_map_id' ) ?: 'DEMO_MAP_ID', 'mapSIconType' => $this->settings->get_params( 'map_store_marker' ), 'mapSIcon' => $this->settings->get_params( 'map_store_marker_custom' ), 'mapUIconType' => $this->settings->get_params( 'map_user_marker' ), 'mapUIcon' => $this->settings->get_params( 'map_user_marker_custom' ), 'mapTypeControl' => $this->settings->get_params( 'map_type_control' ) ?: 0, 'mapStyle' => NIMAP_MULTI_LOCATOR_Function::mapStyle( $this->settings->get_params( 'map_style' ), $this->settings->get_params( 'map_custom_style' ) ), 'mapShowDistanceRadius' => $this->settings->get_params( 'map_show_distance_radius' ) ?: 0, 'mapLatitude' => $this->settings->get_params( 'map_start_latitude' ), 'mapLongitude' => $this->settings->get_params( 'map_start_longitude' ), 'mapDistanceUnit' => $this->settings->get_params( 'general_distance_unit' ) == 'km' ? '(km)' : '(ml)', 'mapDistanceEx' => $this->settings->get_params( 'general_distance_unit' ) == 'km' ? 1000 : 1609.34, 'maxResults' => $this->settings->get_params( 'map_max_results' ) ?: 99, 'mapRadiusColor' => $this->settings->get_params( 'map_radius_color' ) ?: '#80FFFF', 'mapRadiusBorderColor' => $this->settings->get_params( 'map_radius_border_color' ) ?: '#30BAFF', 'infoWidth' => $this->settings->get_params( 'info_width' ) ?: '', 'streetView' => $this->settings->get_params( 'map_street_view' ), 'searchRadius' => $this->settings->get_params( 'map_search_radius' ) ?: 500, 'phoneUrl' => $this->settings->get_params( 'map_phone_url' ) ?: 0, 'clickableDetails' => $this->settings->get_params( 'map_clickable_details' ) ?: 0, 'markerStreetView' => $this->settings->get_params( 'map_marker_street_view' ) ?: 0, 'runFitBounds' => $this->settings->get_params( 'map_run_fit_bounds' ) ?: 0, 'directionsTravelMode' => $this->get_directions_travel_mode(), 'enableStyledDropdowns' => apply_filters( 'nimap_enable_styled_dropdown', true ), 'geoLocationTimeout' => apply_filters( 'nimap_geolocation_timeout', 8000 ), 'storeMarker' => $this->settings->get_params( 'map_store_marker' ) == 'custom' ? $this->settings->get_params( 'map_store_marker_custom' ) : '', 'startMarker' => $this->settings->get_params( 'map_user_marker' ) == 'custom' ? $this->settings->get_params( 'map_user_marker_custom' ) : '', 'storeMarkerType' => $this->settings->get_params( 'map_store_marker_custom' ), 'clusterImagePath' => 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m', ); wp_localize_script( 'nimap-locator', 'nimapLocator', $st_localize ); wp_localize_script( 'nimap-locator', 'nimapLabels', $eq_labels ); $css = ''; $css .= wp_kses_post( $this->settings->get_params( 'general_store_css' ) ); wp_add_inline_style( 'nimap-locator', wp_kses_post( $css ) ); //list wp_localize_script( 'nimap-list', 'nimapList', $list_vars ); $list_column = intval( $this->settings->get_params( 'store_result_column' ) ); $list_col_width = 1 != $list_column ? ceil( 94 / $list_column ) : 100; $css = ''; $css .= '.nimap-stores-wrap .nimap-result-section-wrap .nimap-result-list-wrap .nimap-item-container {'; $css .= 'width: ' . $list_col_width . '%'; $css .= '}'; $css .= wp_kses_post( $this->settings->get_params( 'general_store_css' ) ); wp_add_inline_style( 'nimap-list', wp_kses_post( $css ) ); //details wp_localize_script( 'nimap-details', 'nimapDetail', array( 'apiKey' => $this->settings->get_params( 'general_api_key' ), 'mapZoom' => $this->settings->get_params( 'map_zoom_level' ), 'mapId' => $this->settings->get_params( 'general_map_id' ) ?: 'DEMO_MAP_ID', 'mapSIconType' => $this->settings->get_params( 'map_store_marker' ), 'mapSIcon' => $this->settings->get_params( 'map_store_marker_custom' ), 'scrollWheel' => $this->settings->get_params( 'map_scroll_wheel' ) ?: false, 'gestureHandling' => $this->settings->get_params( 'map_gesture_handling' ) ?: 'cooperative', 'mapType' => $this->settings->get_params( 'map_type' ) ?: 'roadmap', 'mapStyle' => NIMAP_MULTI_LOCATOR_Function::mapStyle( $this->settings->get_params( 'map_style' ), $this->settings->get_params( 'map_custom_style' ) ), // 'mapLatitude' => $atts['select_latitude'], // 'mapLongitude' => $atts['select_longitude'], 'country_select' => esc_html__( 'Select an option', '9map-map-multi-locations' ), 'startLatitude' => $this->settings->get_params( 'map_start_latitude' ), 'startLongitude' => $this->settings->get_params( 'map_start_longitude' ), 'isCustomize' => self::is_customize_preview(), 'startPoint' => esc_html__( 'Store location', '9map-map-multi-locations' ), 'markerUrl' => NIMAP_IMAGES, 'generalGeoError' => esc_html__( 'An unknown error occurred.', '9map-map-multi-locations' ), 'unavailable' => esc_html__( 'Location information is unavailable.', '9map-map-multi-locations' ), ) ); $css = ''; $css .= wp_kses_post( $this->settings->get_params( 'general_store_css' ) ); wp_add_inline_style( 'nimap-details', wp_kses_post( $css ) ); //widget wp_localize_script( 'nimap-widget', 'nimapWidget', $list_vars ); $css = ''; $css .= wp_kses_post( $this->settings->get_params( 'general_store_css' ) ); wp_add_inline_style( 'nimap-widget', wp_kses_post( $css ) ); } public function enqueue_scripts( $type = '', $atts = array() ) { $detail_link = get_permalink( $this->settings->get_params( 'general_store_detail' ) ); $list_vars = []; if ( $type == 'widget' || $type == 'list' ) { $list_vars = array( 'nonce' => wp_create_nonce( 'nimap-nonce' ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'noResults' => $this->settings->get_params( 'list_no_result_title' ), 'countResults' => $this->settings->get_params( 'list_count_title' ), 'findEmpty' => esc_html__( 'No store found', '9map-map-multi-locations' ), 'preloader' => esc_html__( 'Searching...', '9map-map-multi-locations' ), 'autoCompleteOptions' => apply_filters( 'nimap_autocomplete_options', array( 'fields' => array( 'address_components', 'geometry', 'name' ), ) ), 'iconUrl' => NIMAP_IMAGES, 'mapDistanceUnit' => $this->settings->get_params( 'general_distance_unit' ) == 'km' ? '(km)' : '(ml)', ); } switch ( $type ) { case 'locator': wp_enqueue_script( 'nimap-locator' ); wp_enqueue_style( 'nimap-locator' ); wp_enqueue_style( 'nimap-icon' ); NIMAP_MULTI_LOCATOR_Function::registerGoogleMaps( $atts ); // wp_enqueue_script( 'nimap-infobox' ); if ( $this->settings->get_params( 'map_marker_clusters' ) ) { wp_enqueue_script( 'nimap-markerclusterer' ); // wp_localize_script( 'nimap-locator', 'nimapLocator', array( // 'clusterImagePath' => 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m', // ) ); } $eq_labels = array( 'preloader' => esc_html__( 'Searching...', '9map-map-multi-locations' ), 'noResults' => $this->settings->get_params( 'list_no_result_title' ), 'countResults' => $this->settings->get_params( 'list_count_title' ), 'moreInfo' => esc_html__( 'More info', '9map-map-multi-locations' ), 'generalError' => esc_html__( 'Something went wrong, please try again!', '9map-map-multi-locations' ), 'queryLimit' => esc_html__( 'API usage limit reached', '9map-map-multi-locations' ), 'directions' => esc_html__( 'Directions', '9map-map-multi-locations' ), 'noDirectionsFound' => esc_html__( 'No route could be found between the origin and destination', '9map-map-multi-locations' ), 'startPoint' => esc_html__( 'Start location', '9map-map-multi-locations' ), 'back' => esc_html__( 'Back', '9map-map-multi-locations' ), 'streetView' => esc_html__( 'Street view', '9map-map-multi-locations' ), 'zoomHere' => esc_html__( 'Zoom here', '9map-map-multi-locations' ), 'denied' => esc_html__( 'The application does not have permission to use the Geolocation API.', '9map-map-multi-locations' ), 'unavailable' => esc_html__( 'Location information is unavailable.', '9map-map-multi-locations' ), 'timeout' => esc_html__( 'The geolocation request timed out.', '9map-map-multi-locations' ), 'generalGeoError' => esc_html__( 'An unknown error occurred.', '9map-map-multi-locations' ) ); $st_localize = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'nimap-nonce' ), 'storeLink' => $detail_link, 'apiKey' => $this->settings->get_params( 'general_api_key' ), 'markerClusters' => $this->settings->get_params( 'map_marker_clusters' ) ?: 0, 'clusterZoom' => $this->settings->get_params( 'map_cluster_zoom' ) ?: 0, 'clusterSize' => $this->settings->get_params( 'map_cluster_size' ) ?: 0, 'autoLocate' => $this->settings->get_params( 'map_auto_locate' ) ?: 0, 'directionRedirect' => $this->settings->get_params( 'map_direction_redirect' ) ?: 0, 'autoLoad' => $this->settings->get_params( 'map_auto_load_stores' ), 'zoomLevel' => $this->settings->get_params( 'map_zoom_level' ), 'markerZoomTo' => $this->settings->get_params( 'map_marker_zoom_to' ) ?: 0, 'autoZoomLevel' => $this->settings->get_params( 'map_auto_zoom_level' ), 'scrollWheel' => $this->settings->get_params( 'map_scroll_wheel' ) ?: false, 'gestureHandling' => $this->settings->get_params( 'map_gesture_handling' ), 'controlPosition' => $this->settings->get_params( 'map_control_position' ) ?: 'RIGHT_BOTTOM', 'loadLocation' => $this->settings->get_params( 'map_load_location_init' ), 'startLatlng' => $this->settings->get_params( 'map_start_latitude' ) . ',' . $this->settings->get_params( 'map_start_longitude' ), 'infoWindowStyle' => $this->settings->get_params( 'map_info_window_style' ) ?: '', 'markerIconProps' => [ 'scaledSize' => '24,35', 'origin' => '0,0', 'anchor' => '12,35' ], 'url' => NIMAP_IMAGES, 'preloader' => NIMAP_IMAGES . 'ajax-loader.gif', 'autoCompleteOptions' => apply_filters( 'nimap_autocomplete_options', array( 'fields' => array( 'address_components', 'geometry', 'name' ), // 'fields' => array( "address_components", "geometry.location", "name" ), // 'types' => array( '(regions)' ) ) ), 'autoComplete' => $this->settings->get_params( 'map_auto_complete' ) ?: 1, 'mapType' => $this->settings->get_params( 'map_type' ) ?: 'roadmap', 'mapTypeControl' => $this->settings->get_params( 'map_type_control' ) ?: 0, 'mapStyle' => $atts['map_style'] ?: NIMAP_MULTI_LOCATOR_Function::mapStyle( $atts['map_style'], $atts['map_custom_style'] ), 'mapShowDistanceRadius' => $this->settings->get_params( 'map_show_distance_radius' ) ?: 0, 'mapLatitude' => $this->settings->get_params( 'map_start_latitude' ), 'mapLongitude' => $this->settings->get_params( 'map_start_longitude' ), 'mapDistanceUnit' => $this->settings->get_params( 'general_distance_unit' ) == 'km' ? '(km)' : '(ml)', 'mapDistanceEx' => $this->settings->get_params( 'general_distance_unit' ) == 'km' ? 1000 : 1609.34, 'maxResults' => $this->settings->get_params( 'map_max_results' ) ?: 99, 'mapRadiusColor' => $this->settings->get_params( 'map_radius_color' ) ?: '#80FFFF', 'mapRadiusBorderColor' => $this->settings->get_params( 'map_radius_border_color' ) ?: '#30BAFF', 'infoWidth' => $this->settings->get_params( 'info_width' ) ?: '', 'streetView' => $this->settings->get_params( 'map_street_view' ), 'searchRadius' => $this->settings->get_params( 'map_search_radius' ) ?: 500, 'phoneUrl' => $this->settings->get_params( 'map_phone_url' ) ?: 0, 'clickableDetails' => $this->settings->get_params( 'map_clickable_details' ) ?: 0, 'markerStreetView' => $this->settings->get_params( 'map_marker_street_view' ) ?: 0, 'runFitBounds' => $this->settings->get_params( 'map_run_fit_bounds' ) ?: 0, 'directionsTravelMode' => $this->get_directions_travel_mode(), 'enableStyledDropdowns' => apply_filters( 'nimap_enable_styled_dropdown', true ), 'geoLocationTimeout' => apply_filters( 'nimap_geolocation_timeout', 8000 ), 'storeMarker' => apply_filters( 'nimap_store_marker', 'store.png' ), 'startMarker' => apply_filters( 'nimap_start_marker', 'user.png' ), 'clusterImagePath' => 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m', ); // wp_localize_script( 'nimap-locator', 'nimapLocator', $st_localize ); // wp_add_inline_script( 'nimap-locator', 'nimapLocator', $st_localize ); // wp_localize_script( 'nimap-locator', 'nimapLabels', $eq_labels ); // // $css = ''; // $css .= wp_kses_post( $this->settings->get_params( 'general_store_css' ) ); // wp_add_inline_style( 'nimap-locator', wp_kses_post( $css ) ); break; case 'list': wp_enqueue_script( 'nimap-list' ); wp_enqueue_style( 'nimap-list' ); wp_enqueue_style( 'nimap-icon' ); NIMAP_MULTI_LOCATOR_Function::registerGoogleMaps( $atts, 'list' ); // wp_localize_script( 'nimap-list', 'nimapList', $list_vars ); // // $list_column = intval( $this->settings->get_params( 'store_result_column' ) ); // $list_col_width = 1 != $list_column ? ceil( 94 / $list_column ) : 100; // // $css = ''; //// $css .= '.nimap-stores-wrap .nimap-result-section-wrap .nimap-result-list-container .nimap-result-list-wrap {'; //// $css .= 'grid-template-columns: repeat(' . intval( $this->settings->get_params('store_result_column') ) . ', 1fr)'; //// $css .= '}'; // $css .= '.nimap-stores-wrap .nimap-result-section-wrap .nimap-result-list-wrap .nimap-item-container {'; // $css .= 'width: ' . $list_col_width . '%'; // $css .= '}'; // $css .= wp_kses_post( $this->settings->get_params( 'general_store_css' ) ); // wp_add_inline_style( 'nimap-list', wp_kses_post( $css ) ); break; case 'detail': wp_enqueue_script( 'nimap-details' ); wp_enqueue_style( 'nimap-details' ); wp_enqueue_style( 'nimap-icon' ); NIMAP_MULTI_LOCATOR_Function::registerGoogleMaps( $atts ); // wp_localize_script( 'nimap-details', 'nimapDetail', array( // 'apiKey' => $this->settings->get_params( 'general_api_key' ), // 'mapZoom' => $atts['map_zoom_level'] ?: $this->settings->get_params( 'map_zoom_level' ), // 'scrollWheel' => $this->settings->get_params( 'map_scroll_wheel' ) ?: false, // 'gestureHandling' => $this->settings->get_params( 'map_gesture_handling' ) ?: 'cooperative', // 'mapType' => $this->settings->get_params( 'map_type' ) ?: 'roadmap', // 'mapStyle' => $atts['map_style'] ?: NIMAP_MULTI_LOCATOR_Function::mapStyle( $atts['map_style'], $atts['map_custom_style'] ), // 'mapLatitude' => $atts['select_latitude'], // 'mapLongitude' => $atts['select_longitude'], // 'country_select' => esc_html__( 'Select an option', '9map-map-multi-locations' ), // 'startLatitude' => $this->settings->get_params( 'map_start_latitude' ), // 'startLongitude' => $this->settings->get_params( 'map_start_longitude' ), // 'startPoint' => esc_html__( 'Start location', '9map-map-multi-locations' ), // 'markerUrl' => NIMAP_IMAGES, // 'generalGeoError' => esc_html__( 'An unknown error occurred.', '9map-map-multi-locations' ), // 'unavailable' => esc_html__( 'Location information is unavailable.', '9map-map-multi-locations' ), // ) // ); // // $css = ''; // $css .= wp_kses_post( $this->settings->get_params( 'general_store_css' ) ); // wp_add_inline_style( 'nimap-details', wp_kses_post( $css ) ); break; case 'widget': wp_enqueue_script( 'nimap-widget' ); wp_enqueue_style( 'nimap-widget' ); wp_enqueue_style( 'nimap-icon' ); NIMAP_MULTI_LOCATOR_Function::registerGoogleMaps( $atts, 'widget' ); // wp_localize_script( 'nimap-widget', 'nimapWidget', $list_vars ); // // $css = ''; // $css .= wp_kses_post( $this->settings->get_params( 'general_store_css' ) ); // wp_add_inline_style( 'nimap-widget', wp_kses_post( $css ) ); default: // wp_enqueue_script( '-script' ); } } public function enqueue_styles( $type = '', $atts = array() ) { } public function add_frontend_scripts() { $this::nimapCreateUnderscoreTemplates( 'locator' ); } public function w8tabs_frontend_enqueue_scripts() { if ( $this->settings->get_params( 'enable' ) || self::is_customize_preview() ) { $this->settings->enqueue_style( array( 'w8tabs-frontend', 'w8tabs-icon', ), array( 'w8tabs-frontend', 'w8tabs-icon' ), array( 0, 0 ) ); $this->settings->enqueue_script( array( 'w8tabs-frontend' ), array( 'w8tabs-frontend' ), array( 0 ) ); $border_normal = explode( '/', $this->settings->get_params( 'tab_title_normal_border' ) ); if ( 4 != count( $border_normal ) ) { $border_normal = array( 1, 1, 1, 1 ); } $border_active = explode( '/', $this->settings->get_params( 'tab_title_active_border' ) ); if ( 4 != count( $border_active ) ) { $border_active = array( 1, 1, 1, 1 ); } $border_content = explode( '/', $this->settings->get_params( 'tab_content_border' ) ); if ( 4 != count( $border_content ) ) { $border_content = array( 1, 1, 1, 1 ); } $css = esc_attr( $this->settings->get_params( 'custom_css' ) ); if ( ! self::is_customize_preview() ) { wp_add_inline_style( 'w8tabs-frontend', esc_attr( $css ) ); } } } public static function is_customize_preview() { if ( isset( self::$cache['is_customize_preview'] ) ) { return self::$cache['is_customize_preview']; } return self::$cache['is_customize_preview'] = is_customize_preview(); } function format_lang_code( $i_lang, $locale = '' ) { $lang = $locale == '1' ? get_locale() : ''; // Lang override by attribute if ( ! empty( $i_lang ) && strlen( $i_lang <= 13 ) ) { if ( $i_lang == 'en' ) { $lang = 'en_US'; } } else { $lang = 'en_US'; } // Clean the language code if ( $lang ) { $lang = esc_sql( $lang ); } return $lang; } private function map_style( $layout_code ) { /// Get the map configuration switch ( $layout_code ) { // case '-1': return '[]'; break; //25-blue-water case '0': return '[{featureType:"administrative",elementType:"labels.text.fill",stylers:[{color:"#444444"}]},{featureType:"landscape",elementType:"all",stylers:[{color:"#f2f2f2"}]},{featureType:"poi",elementType:"all",stylers:[{visibility:"off"}]},{featureType:"road",elementType:"all",stylers:[{saturation:-100},{lightness:45}]},{featureType:"road.highway",elementType:"all",stylers:[{visibility:"simplified"}]},{featureType:"road.arterial",elementType:"labels.icon",stylers:[{visibility:"off"}]},{featureType:"transit",elementType:"all",stylers:[{visibility:"off"}]},{featureType:"water",elementType:"all",stylers:[{color:"#46bcec"},{visibility:"on"}]}]'; break; //Flat Map case '1': return '[{"featureType": "poi.business","stylers": [{"visibility": "off"}]},{featureType:"landscape",elementType:"all",stylers:[{visibility:"on"},{color:"#f3f4f4"}]},{featureType:"landscape.man_made",elementType:"geometry",stylers:[{weight:.9},{visibility:"off"}]},{featureType:"poi.park",elementType:"geometry.fill",stylers:[{visibility:"on"},{color:"#83cead"}]},{featureType:"road",elementType:"all",stylers:[{visibility:"on"},{color:"#ffffff"}]},{featureType:"road",elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"road.highway",elementType:"all",stylers:[{visibility:"on"},{color:"#fee379"}]},{featureType:"road.arterial",elementType:"all",stylers:[{visibility:"on"},{color:"#fee379"}]},{featureType:"water",elementType:"all",stylers:[{visibility:"on"},{color:"#7fc8ed"}]}]'; break; //Icy Blue case '2': return '[{stylers:[{hue:"#2c3e50"},{saturation:250}]},{featureType:"road",elementType:"geometry",stylers:[{lightness:50},{visibility:"simplified"}]},{featureType:"road",elementType:"labels",stylers:[{visibility:"off"}]}]'; break; //Pale Dawn case '3': return '[{featureType:"administrative",elementType:"all",stylers:[{visibility:"on"},{lightness:33}]},{featureType:"landscape",elementType:"all",stylers:[{color:"#f2e5d4"}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#c5dac6"}]},{featureType:"poi.park",elementType:"labels",stylers:[{visibility:"on"},{lightness:20}]},{featureType:"road",elementType:"all",stylers:[{lightness:20}]},{featureType:"road.highway",elementType:"geometry",stylers:[{color:"#c5c6c6"}]},{featureType:"road.arterial",elementType:"geometry",stylers:[{color:"#e4d7c6"}]},{featureType:"road.local",elementType:"geometry",stylers:[{color:"#fbfaf7"}]},{featureType:"water",elementType:"all",stylers:[{visibility:"on"},{color:"#acbcc9"}]}]'; break; //cladme case '4': return '[{featureType:"administrative",elementType:"labels.text.fill",stylers:[{color:"#444444"}]},{featureType:"landscape",elementType:"all",stylers:[{color:"#f2f2f2"}]},{featureType:"poi",elementType:"all",stylers:[{visibility:"off"}]},{featureType:"road",elementType:"all",stylers:[{saturation:-100},{lightness:45}]},{featureType:"road.highway",elementType:"all",stylers:[{visibility:"simplified"}]},{featureType:"road.arterial",elementType:"labels.icon",stylers:[{visibility:"off"}]},{featureType:"transit",elementType:"all",stylers:[{visibility:"off"}]},{featureType:"water",elementType:"all",stylers:[{color:"#4f595d"},{visibility:"on"}]}]'; break; //light monochrome case '5': return '[{featureType:"administrative.locality",elementType:"all",stylers:[{hue:"#2c2e33"},{saturation:7},{lightness:19},{visibility:"on"}]},{featureType:"landscape",elementType:"all",stylers:[{hue:"#ffffff"},{saturation:-100},{lightness:100},{visibility:"simplified"}]},{featureType:"poi",elementType:"all",stylers:[{hue:"#ffffff"},{saturation:-100},{lightness:100},{visibility:"off"}]},{featureType:"road",elementType:"geometry",stylers:[{hue:"#bbc0c4"},{saturation:-93},{lightness:31},{visibility:"simplified"}]},{featureType:"road",elementType:"labels",stylers:[{hue:"#bbc0c4"},{saturation:-93},{lightness:31},{visibility:"on"}]},{featureType:"road.arterial",elementType:"labels",stylers:[{hue:"#bbc0c4"},{saturation:-93},{lightness:-2},{visibility:"simplified"}]},{featureType:"road.local",elementType:"geometry",stylers:[{hue:"#e9ebed"},{saturation:-90},{lightness:-8},{visibility:"simplified"}]},{featureType:"transit",elementType:"all",stylers:[{hue:"#e9ebed"},{saturation:10},{lightness:69},{visibility:"on"}]},{featureType:"water",elementType:"all",stylers:[{hue:"#e9ebed"},{saturation:-78},{lightness:67},{visibility:"simplified"}]}]'; break; //mostly grayscale case '6': return '[{featureType:"administrative",elementType:"all",stylers:[{visibility:"on"},{lightness:33}]},{featureType:"administrative",elementType:"labels",stylers:[{saturation:"-100"}]},{featureType:"administrative",elementType:"labels.text",stylers:[{gamma:"0.75"}]},{featureType:"administrative.neighborhood",elementType:"labels.text.fill",stylers:[{lightness:"-37"}]},{featureType:"landscape",elementType:"geometry",stylers:[{color:"#f9f9f9"}]},{featureType:"landscape.man_made",elementType:"geometry",stylers:[{saturation:"-100"},{lightness:"40"},{visibility:"off"}]},{featureType:"landscape.natural",elementType:"labels.text.fill",stylers:[{saturation:"-100"},{lightness:"-37"}]},{featureType:"landscape.natural",elementType:"labels.text.stroke",stylers:[{saturation:"-100"},{lightness:"100"},{weight:"2"}]},{featureType:"landscape.natural",elementType:"labels.icon",stylers:[{saturation:"-100"}]},{featureType:"poi",elementType:"geometry",stylers:[{saturation:"-100"},{lightness:"80"}]},{featureType:"poi",elementType:"labels",stylers:[{saturation:"-100"},{lightness:"0"}]},{featureType:"poi.attraction",elementType:"geometry",stylers:[{lightness:"-4"},{saturation:"-100"}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#c5dac6"},{visibility:"on"},{saturation:"-95"},{lightness:"62"}]},{featureType:"poi.park",elementType:"labels",stylers:[{visibility:"on"},{lightness:20}]},{featureType:"road",elementType:"all",stylers:[{lightness:20}]},{featureType:"road",elementType:"labels",stylers:[{saturation:"-100"},{gamma:"1.00"}]},{featureType:"road",elementType:"labels.text",stylers:[{gamma:"0.50"}]},{featureType:"road",elementType:"labels.icon",stylers:[{saturation:"-100"},{gamma:"0.50"}]},{featureType:"road.highway",elementType:"geometry",stylers:[{color:"#c5c6c6"},{saturation:"-100"}]},{featureType:"road.highway",elementType:"geometry.stroke",stylers:[{lightness:"-13"}]},{featureType:"road.highway",elementType:"labels.icon",stylers:[{lightness:"0"},{gamma:"1.09"}]},{featureType:"road.arterial",elementType:"geometry",stylers:[{color:"#e4d7c6"},{saturation:"-100"},{lightness:"47"}]},{featureType:"road.arterial",elementType:"geometry.stroke",stylers:[{lightness:"-12"}]},{featureType:"road.arterial",elementType:"labels.icon",stylers:[{saturation:"-100"}]},{featureType:"road.local",elementType:"geometry",stylers:[{color:"#fbfaf7"},{lightness:"77"}]},{featureType:"road.local",elementType:"geometry.fill",stylers:[{lightness:"-5"},{saturation:"-100"}]},{featureType:"road.local",elementType:"geometry.stroke",stylers:[{saturation:"-100"},{lightness:"-15"}]},{featureType:"transit.station.airport",elementType:"geometry",stylers:[{lightness:"47"},{saturation:"-100"}]},{featureType:"water",elementType:"all",stylers:[{visibility:"on"},{color:"#acbcc9"}]},{featureType:"water",elementType:"geometry",stylers:[{saturation:"53"}]},{featureType:"water",elementType:"labels.text.fill",stylers:[{lightness:"-42"},{saturation:"17"}]},{featureType:"water",elementType:"labels.text.stroke",stylers:[{lightness:"61"}]}]'; break; //turquoise water case '7': return '[{stylers:[{hue:"#16a085"},{saturation:0}]},{featureType:"road",elementType:"geometry",stylers:[{lightness:100},{visibility:"simplified"}]},{featureType:"road",elementType:"labels",stylers:[{visibility:"off"}]}]'; break; //unsaturated browns case '8': return '[{elementType:"geometry",stylers:[{hue:"#ff4400"},{saturation:-68},{lightness:-4},{gamma:.72}]},{featureType:"road",elementType:"labels.icon"},{featureType:"landscape.man_made",elementType:"geometry",stylers:[{hue:"#0077ff"},{gamma:3.1}]},{featureType:"water",stylers:[{hue:"#00ccff"},{gamma:.44},{saturation:-33}]},{featureType:"poi.park",stylers:[{hue:"#44ff00"},{saturation:-23}]},{featureType:"water",elementType:"labels.text.fill",stylers:[{hue:"#007fff"},{gamma:.77},{saturation:65},{lightness:99}]},{featureType:"water",elementType:"labels.text.stroke",stylers:[{gamma:.11},{weight:5.6},{saturation:99},{hue:"#0091ff"},{lightness:-86}]},{featureType:"transit.line",elementType:"geometry",stylers:[{lightness:-48},{hue:"#ff5e00"},{gamma:1.2},{saturation:-23}]},{featureType:"transit",elementType:"labels.text.stroke",stylers:[{saturation:-64},{hue:"#ff9100"},{lightness:16},{gamma:.47},{weight:2.7}]}]'; break; case '9': $custom_map_style = $this->settings->get_params( 'map_custom_style' ); if ( $custom_map_style ) { return $custom_map_style; } break; //turquoise water default: return '[{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"lightness":33}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2e5d4"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#c5dac6"}]},{"featureType":"poi.park","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":20}]},{"featureType":"road","elementType":"all","stylers":[{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#c5c6c6"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#e4d7c6"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#fbfaf7"}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"color":"#acbcc9"}]}]'; break; } return '[]'; } function nimapCreateUnderscoreTemplates( $template ) { $nimap_settings = $this->settings->get_params(); $info_fields = $this->settings->get_params( 'info_display_fields' ); $list_fields = $this->settings->get_params( 'list_display_fields' ); $btn_list = json_decode( $this->settings->get_params( 'list_buttons' ) ); $btn_info = json_decode( $this->settings->get_params( 'info_buttons' ) ); $distance_unit = $this->settings->get_params( 'general_distance_unit' ) == 'km' ? '(km)' : '(ml)'; $i_image_class = in_array( 'image', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_title_class = in_array( 'title', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_address_class = in_array( 'address', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_description_class = in_array( 'description', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_phone_class = in_array( 'phone', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_email_class = in_array( 'email', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_website_class = in_array( 'website', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_open_time_class = in_array( 'open_time', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_category_class = in_array( 'category', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_zip_class = in_array( 'zip', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_distance_class = in_array( 'distance', $info_fields ) ? '' : ' nimap-detail-hidden'; $i_custom_class = in_array( 'custom', $info_fields ) ? '' : ' nimap-detail-hidden'; $l_image_class = in_array( 'image', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_title_class = in_array( 'title', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_address_class = in_array( 'address', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_description_class = in_array( 'description', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_phone_class = in_array( 'phone', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_email_class = in_array( 'email', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_website_class = in_array( 'website', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_open_time_class = in_array( 'open_time', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_category_class = in_array( 'category', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_zip_class = in_array( 'zip', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_distance_class = in_array( 'distance', $list_fields ) ? '' : ' nimap-detail-hidden'; $l_custom_class = in_array( 'custom', $list_fields ) ? '' : ' nimap-detail-hidden'; if ( $template == 'locator' ) { ?> settings->get_params(); if ( isset( $nimap_settings['new_window'] ) && $nimap_settings['new_window'] ) { $new_window = ''; } else { $new_window = ' target="_blank"'; } /* * To keep the code readable in the HTML source we ( unfortunately ) need to adjust the * amount of tabs in front of it based on the location were it is shown. */ if ( $location == 'listing' ) { $tab = "\t\t\t"; } else { $tab = "\t\t\t"; } if ( isset( $nimap_settings['permalinks'] ) && $nimap_settings['permalinks'] ) { /** * It's possible the permalinks are enabled, but not included in the location data on * pages where the [wpsl_map] shortcode is used. * * So we need to check for undefined, which isn't necessary in all other cases. */ if ( $location == 'locator' ) { $header_template = '<% if ( typeof permalink !== "undefined" ) { %>' . "\r\n"; $header_template .= $tab . '
<%= store %>
' . "\r\n"; $header_template .= $tab . '<% } else { %>' . "\r\n"; $header_template .= $tab . '
<%= store %>
' . "\r\n"; $header_template .= $tab . '<% } %>'; } else { $header_template = '
<%= store %>
'; } } else { $header_template = '<% if ( nimapLocator.storeUrl == 1 && url ) { %>' . "\r\n"; $header_template .= $tab . '
<%= store %>
' . "\r\n"; $header_template .= $tab . '<% } else { %>' . "\r\n"; $header_template .= $tab . '
<%= store %>
' . "\r\n"; $header_template .= $tab . '<% } %>'; } return apply_filters( 'nimap_underscore_header_template', $header_template ); } function nimap_address_format_placeholders() { $address_format = explode( '_', $this->settings->get_params( 'info_address_format' ) ); $placeholders = ''; $part_count = count( $address_format ) - 1; $i = 0; foreach ( $address_format as $address_part ) { if ( $address_part != 'comma' ) { /* * Don't add a space after the placeholder if the next part * is going to be a comma or if it is the last part. */ if ( $i == $part_count || $address_format[ $i + 1 ] == 'comma' ) { $space = ''; } else { $space = ' '; } $placeholders .= '<%= ' . $address_part . ' %>' . $space; } else { $placeholders .= ', '; } $i ++; } return $placeholders; } } }