$style){ if($style['id'] == $id){ return $index; } } return null; } function _getStyle(&$styles, $id){ $index = _getStyleIndex($styles, $id); return !is_null($index) ? $styles[$index] : null; } function _styleAction(&$style, $action){ return "?page=snazzy_maps&tab=0&action=$action&style=" . $style['id']; }; 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 Services_JSON(); $newStyle = _object_to_array($json->decode(base64_decode($_POST['new_style']))); if(!_getStyle($styles, $newStyle['id'])){ $styles[] = $newStyle; update_option('SnazzyMapStyles', $styles); } } } function admin_styles_tab($tab){ $styles = get_option('SnazzyMapStyles', null); if($styles == null){ $styles = array(); } //Delete the specified style from the array if(isset($_GET['action']) && $_GET['action'] == 'delete_style'){ $index = _getStyleIndex($styles, $_GET['style']); $defaultStyle = get_option('SnazzyMapDefaultStyle', null); if(!is_null($index)){ $oldStyle = $styles[$index]; array_splice($styles, $index, 1); update_option('SnazzyMapStyles', $styles); //Delete the default style when it is removed from this list if(!is_null($defaultStyle) && $defaultStyle['id'] == $oldStyle['id']){ delete_option('SnazzyMapDefaultStyle'); } } } //Enable the specified style if(isset($_GET['action']) && $_GET['action'] == 'enable_style'){ $index = _getStyleIndex($styles, $_GET['style']); if(!is_null($index)){ update_option('SnazzyMapDefaultStyle', $styles[$index]); } } //Disable the specified style if(isset($_GET['action']) && $_GET['action'] == 'disable_style'){ $index = _getStyleIndex($styles, $_GET['style']); $defaultStyle = get_option('SnazzyMapDefaultStyle', null); if(!is_null($index) && !is_null($defaultStyle) && $styles[$index]['id'] == $defaultStyle['id']){ delete_option('SnazzyMapDefaultStyle'); } } $defaultStyle = get_option('SnazzyMapDefaultStyle', null); //Used during testing if(isset($_GET['clear_styles'])){ delete_option('SnazzyMapStyles'); } ?> 0) { ?>
Looks like you haven't picked any styles yet.
Explore and choose some styles for your site!