Exemple #1
0
 /**
  * Localize the CSL Script
  */
 public function localize_script()
 {
     // Handle any IconAttributes optionally set using the shortcode in combination with the Pro Pack
     $this->handleIconAttributes('map_home_icon', 'homeicon');
     $this->handleIconAttributes('map_end_icon', 'endicon');
     $slplus_home_icon_file = str_replace(SLPLUS_ICONURL, SLPLUS_ICONDIR, $this->slplus->options['map_home_icon']);
     $slplus_end_icon_file = str_replace(SLPLUS_ICONURL, SLPLUS_ICONDIR, $this->slplus->options['map_end_icon']);
     $this->slplus->data['home_size'] = function_exists('getimagesize') && file_exists($slplus_home_icon_file) ? getimagesize($slplus_home_icon_file) : array(0 => 20, 1 => 34);
     $this->slplus->data['end_size'] = function_exists('getimagesize') && file_exists($slplus_end_icon_file) ? getimagesize($slplus_end_icon_file) : array(0 => 20, 1 => 34);
     add_shortcode('slp_location', array($this, 'process_slp_location_Shortcode'));
     // Load up some basic options.
     // This can probably be handled better.
     //
     $this->slplus->options['use_sensor'] = get_option(SLPLUS_PREFIX . '_use_location_sensor', 0) == 1;
     // Set starting map center
     //
     $this->slplus->options['map_center'] = $this->set_MapCenter();
     // Environment
     //
     $this->slplus->createobject_AddOnManager();
     $environment['addons'] = $this->slplus->add_ons->get_versions();
     $environment['slp'] = SLPLUS_VERSION;
     add_filter('slp_js_options', array($this, 'add_to_js_options'));
     // Lets get some variables into our script.
     // "Higher Level" JS Options are those noted below.
     //
     // TODO: ALL of these options should go inside the options property other than plugin_url, core_url, and environment.
     //
     $scriptData = array('plugin_url' => SLPLUS_PLUGINURL, 'disable_scroll' => get_option(SLPLUS_PREFIX . '_disable_scrollwheel') == 1, 'map_3dcontrol' => get_option(SLPLUS_PREFIX . '_disable_largemapcontrol3d') == 0, 'map_home_sizew' => $this->slplus->data['home_size'][0], 'map_home_sizeh' => $this->slplus->data['home_size'][1], 'map_end_sizew' => $this->slplus->data['end_size'][0], 'map_end_sizeh' => $this->slplus->data['end_size'][1], 'map_scalectrl' => get_option(SLPLUS_PREFIX . '_disable_scalecontrol') == 0, 'map_typectrl' => get_option(SLPLUS_PREFIX . '_disable_maptypecontrol') == 0, 'msg_noresults' => $this->slplus->get_item('message_noresultsfound', 'No results found.', '_'), 'results_string' => $this->set_ResultsLayout(false), 'overview_ctrl' => get_option('sl_map_overview_control', 0), 'environment' => apply_filters('slp_js_environment', $environment), 'options' => apply_filters('slp_js_options', $this->slplus->options));
     remove_shortcode('slp_location');
     // AJAX URL Stuff
     //
     $scriptData['ajaxurl'] = admin_url('admin-ajax.php');
     $scriptData['nonce'] = wp_create_nonce('em');
     wp_localize_script('csl_script', 'slplus', $scriptData);
 }