function enqueue_script() { $uniqueStyle = get_option('SnazzyMapDefaultStyle'); if (!empty($uniqueStyle) && !is_null($uniqueStyle)) { $handle = 'snazzymaps-js'; wp_enqueue_script($handle, plugins_url('snazzymaps.js', __FILE__), $deps = array('jquery'), $ver = SNAZZY_VERSION_NUMBER, $in_footer = false); //We have to use l10n_print_after so we can support older versions of WordPress $json = new SnazzyMaps_Services_JSON(); wp_localize_script($handle, 'SnazzyDataForSnazzyMaps', array('l10n_print_after' => 'SnazzyDataForSnazzyMaps=' . $json->encode($uniqueStyle))); } }
function admin_styles_head($tab) { $styles = get_option('SnazzyMapStyles', null); if ($styles == null) { $styles = array(); } //When a new style is selected we have to go through some checks if (isset($_POST['new_style'])) { $json = new SnazzyMaps_Services_JSON(); $newStyle = _object_to_array($json->decode(urldecode($_POST['new_style']))); if (!_getStyle($styles, $newStyle['id'])) { $styles[] = $newStyle; update_option('SnazzyMapStyles', $styles); } } }