]> git.openstreetmap.org Git - stateofthemap.git/blob - functions.php
Aerodrome 1.0.5
[stateofthemap.git] / functions.php
1 <?php
2 if ( function_exists('register_sidebar') )
3 register_sidebar(array(
4 'name' => 'Left Sidebar',
5         'before_widget' => '<li id="%1$s" class="widget %2$s">',
6         'after_widget' => '</li>',
7 'before_title' => '<h3>',
8 'after_title' => '</h3>',
9 ));
10 if ( function_exists('register_sidebar') )
11 register_sidebar(array(
12 'name' => 'Right Sidebar',
13         'before_widget' => '<li id="%1$s" class="widget %2$s">',
14         'after_widget' => '</li>',
15 'before_title' => '<h3>',
16 'after_title' => '</h3>',
17 ));
18
19 ///////////////////////////////////////////////////////////////////////////////////////////////////
20 /* Begin background image select admin page. Created by Aaron Edwards - http://MissionsPlace.com */
21 /* It should work with Wordpress/WordpressMU 2.1+ */
22
23 // Image Sources (all Creative Commons License):
24 // Vector Landscape: http://www.flickr.com/photos/24471966@N04/2851251413/
25 // Africa: http://www.flickr.com/photos/mdorn/2168347/ 
26 // Temple: http://www.flickr.com/photos/stuckincustoms/527078736/
27 // Great Wall: http://www.flickr.com/photos/smokingpermitted/1952627233/
28 // Foggy Mountains: http://www.flickr.com/photos/davelau/1061671042/
29 // Antique Map: http://www.flickr.com/photos/normanbleventhalmapcenter/2674855383/
30 // Parchment Map: http://www.sxc.hu/photo/938403
31 // all other images taken from http://sxc.hu -- standard restrictions
32
33 //inserts new image url css in header
34 function aero_style() {
35   ?>
36   <style type="text/css">
37   <?php if (get_theme_mod('aero_background_image') == "Default") { ?>
38     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/default.jpg) no-repeat fixed center center #fff; }
39   <?php } elseif (get_theme_mod('aero_background_image') == "ParchmentMap") { ?>
40     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/parchment-map.jpg) no-repeat fixed center center #fff; }
41   <?php } elseif (get_theme_mod('aero_background_image') == "OldMap") { ?>
42     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/old-map.jpg) no-repeat fixed center center #fff; }
43   <?php } elseif (get_theme_mod('aero_background_image') == "Africa") { ?>
44     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/africa.jpg) no-repeat fixed center center #fff; }
45   <?php } elseif (get_theme_mod('aero_background_image') == "Autumn") { ?>
46     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/autumn.jpg) no-repeat fixed center center #fff; }
47   <?php } elseif (get_theme_mod('aero_background_image') == "Winter") { ?>
48     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/winter.jpg) no-repeat fixed center center #fff; }
49   <?php } elseif (get_theme_mod('aero_background_image') == "Desert") { ?>
50     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/desert.jpg) no-repeat fixed center center #fff; }
51   <?php } elseif (get_theme_mod('aero_background_image') == "Sunflowers") { ?>
52     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/sunflowers.jpg) no-repeat fixed center center #fff; }
53   <?php } elseif (get_theme_mod('aero_background_image') == "ChinaMountains") { ?>
54     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/yellow-mountains.jpg) no-repeat fixed center center #fff; }
55   <?php } elseif (get_theme_mod('aero_background_image') == "GreatWall") { ?>
56     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/china-wall.jpg) no-repeat fixed center center #fff; }
57   <?php } elseif (get_theme_mod('aero_background_image') == "VectorLandscape") { ?>
58     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/vector-landscape.jpg) no-repeat fixed center bottom #eb7034; }
59   <?php } elseif (get_theme_mod('aero_background_image') == "Temple") { ?>
60     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/temple.jpg) no-repeat fixed center center #fff; }
61   <?php } elseif (get_theme_mod('aero_background_image') == "Christmas") { ?>
62     body { background: url(<?php echo bloginfo('template_directory'); ?>/images/christmas.jpg) no-repeat fixed center center #fff; }
63         <?php } ?>
64   
65   </style>
66 <?php
67 }
68 if (get_theme_mod('aero_background_image')) //add css hook if option is set
69   add_action('wp_head', 'aero_style');
70
71
72
73 //admin menu process options
74 function aero_add_admin() {             
75         if ( 'save' == $_POST['aero_action'] ) {
76
77                 // Update Options
78                 $aero_background_image = preg_replace( '|[^a-z]|i', '', $_POST['aero_background_image'] );
79                 set_theme_mod('aero_background_image', $aero_background_image );
80
81                 // Go back to the options
82                 header("Location: themes.php?page=aero-options&saved=true");
83                 die;
84         }
85         add_submenu_page('themes.php', __('Change Background Image'), __('Change Background Image'), 5, 'aero-options', 'aero_admin');
86 }
87
88 //actual menu to select background image
89 function aero_admin() {
90
91         if ( $_GET['saved'] ) echo '<div id="message" class="updated fade"><p>Aero background image option saved. <a href="'. get_bloginfo('url') .'">View Site &raquo;</a></strong></p></div>';
92         
93 ?>
94
95 <div class="wrap">
96 <h2>Select a Background Image:</h2>
97         <form id='aero_options' method="post">
98                 <p>
99                         <label><input type="radio" name="aero_background_image" value="Default" <?php if (get_theme_mod('aero_background_image') == "Default" || !get_theme_mod('aero_background_image')) { echo "checked='checked'"; } ?> /> Default<img src="<?php bloginfo('template_directory'); ?>/images/option-default.jpg" alt="Default" /></label>
100       <label><input type="radio" name="aero_background_image" value="ParchmentMap" <?php if (get_theme_mod('aero_background_image') == "ParchmentMap") { echo "checked='checked'"; } ?> /> Parchment Map<img src="<?php bloginfo('template_directory'); ?>/images/option-parchment-map.jpg" alt="Parchment Map" /></label>
101       <label><input type="radio" name="aero_background_image" value="OldMap" <?php if (get_theme_mod('aero_background_image') == "OldMap") { echo "checked='checked'"; } ?> /> Antique Map<img src="<?php bloginfo('template_directory'); ?>/images/option-old-map.jpg" alt="Old Map" /></label>
102       <label><input type="radio" name="aero_background_image" value="Africa" <?php if (get_theme_mod('aero_background_image') == "Africa") { echo "checked='checked'"; } ?> /> Africa<img src="<?php bloginfo('template_directory'); ?>/images/option-africa.jpg" alt="Africa" /></label>
103       <label><input type="radio" name="aero_background_image" value="Autumn" <?php if (get_theme_mod('aero_background_image') == "Autumn") { echo "checked='checked'"; } ?> /> Autumn<img src="<?php bloginfo('template_directory'); ?>/images/option-autumn.jpg" alt="Autumn" /></label>
104       <label><input type="radio" name="aero_background_image" value="Winter" <?php if (get_theme_mod('aero_background_image') == "Winter") { echo "checked='checked'"; } ?> /> Winter<img src="<?php bloginfo('template_directory'); ?>/images/option-winter.jpg" alt="Winter" /></label>
105       <label><input type="radio" name="aero_background_image" value="Desert" <?php if (get_theme_mod('aero_background_image') == "Desert") { echo "checked='checked'"; } ?> /> Desert<img src="<?php bloginfo('template_directory'); ?>/images/option-desert.jpg" alt="Desert" /></label>
106       <label><input type="radio" name="aero_background_image" value="Sunflowers" <?php if (get_theme_mod('aero_background_image') == "Sunflowers") { echo "checked='checked'"; } ?> /> Sunflowers<img src="<?php bloginfo('template_directory'); ?>/images/option-sunflowers.jpg" alt="Sunflowers" /></label>
107       <label><input type="radio" name="aero_background_image" value="ChinaMountains" <?php if (get_theme_mod('aero_background_image') == "ChinaMountains") { echo "checked='checked'"; } ?> /> Foggy Mountains<img src="<?php bloginfo('template_directory'); ?>/images/option-yellow-mountains.jpg" alt="China Mountains" /></label>
108       <label><input type="radio" name="aero_background_image" value="GreatWall" <?php if (get_theme_mod('aero_background_image') == "GreatWall") { echo "checked='checked'"; } ?> /> Great Wall<img src="<?php bloginfo('template_directory'); ?>/images/option-china-wall.jpg" alt="Great Wall" /></label>
109       <label><input type="radio" name="aero_background_image" value="VectorLandscape" <?php if (get_theme_mod('aero_background_image') == "VectorLandscape") { echo "checked='checked'"; } ?> /> Vector Landscape<img src="<?php bloginfo('template_directory'); ?>/images/option-vector-landscape.jpg" alt="Vector Landscape" /></label>
110       <label><input type="radio" name="aero_background_image" value="Temple" <?php if (get_theme_mod('aero_background_image') == "Temple") { echo "checked='checked'"; } ?> /> Temple<img src="<?php bloginfo('template_directory'); ?>/images/option-temple.jpg" alt="Temple" /></label>
111       <label><input type="radio" name="aero_background_image" value="Christmas" <?php if (get_theme_mod('aero_background_image') == "Christmas") { echo "checked='checked'"; } ?> /> Christmas<img src="<?php bloginfo('template_directory'); ?>/images/option-christmas.jpg" alt="Christmas" /></label>
112           </p>
113                 <input type="hidden" name="aero_action" value="save" />
114         <p class="submit" style="clear: both"><input name="save" id="save" type="submit" value="Save Options &raquo;" /></p>
115         </form>
116
117 </div>
118 <?php
119 }
120
121 //css for option list
122 function aero_admin_header() { ?>
123 <style media="screen" type="text/css">
124   form#aero_options label { 
125     width:150px;
126     margin-left:10px;
127     margin-bottom:20px;
128         display: block;
129         float: left;
130   }
131 </style>
132 <?php }
133
134 add_action('admin_head', 'aero_admin_header');
135 add_action('admin_menu', 'aero_add_admin');
136
137 ?>