1
|
1 |
<?php |
|
2 |
|
|
3 |
// Theme options adapted from "A Theme Tip For WordPress Theme Authors" |
|
4 |
// http://literalbarrage.org/blog/archives/2007/05/03/a-theme-tip-for-wordpress-theme-authors/ |
|
5 |
|
|
6 |
$themename = "Thematic"; |
|
7 |
$shortname = "thm"; |
|
8 |
|
|
9 |
// Create theme options |
|
10 |
|
|
11 |
$options = array ( |
|
12 |
|
|
13 |
array( "name" => __('Index Insert Position','thematic'), |
|
14 |
"desc" => __('The widgetized Index Insert will follow after this post number.','thematic'), |
|
15 |
"id" => $shortname."_insert_position", |
|
16 |
"std" => "2", |
|
17 |
"type" => "text"), |
|
18 |
|
|
19 |
array( "name" => __('Info on Author Page','thematic'), |
|
20 |
"desc" => __("Display a <a href=\"http://microformats.org/wiki/hcard\" target=\"_blank\">microformatted vCard</a>—with the author's avatar, bio and email—on the author page.",'thematic'), |
|
21 |
"id" => $shortname."_authorinfo", |
|
22 |
"std" => "false", |
|
23 |
"type" => "checkbox"), |
|
24 |
|
|
25 |
array( "name" => __('Text in Footer','thematic'), |
|
26 |
"desc" => __("You can use the following shortcodes in your footer text: [wp-link] [theme-link] [loginout-link] [blog-title] [blog-link] [the-year]",'thematic'), |
|
27 |
"id" => $shortname."_footertext", |
|
28 |
"std" => __("Powered by [wp-link]. Built on the [theme-link].", 'thematic'), |
|
29 |
"type" => "textarea", |
|
30 |
"options" => array( "rows" => "5", |
|
31 |
"cols" => "94") ), |
|
32 |
|
|
33 |
); |
|
34 |
|
|
35 |
function mytheme_add_admin() { |
|
36 |
|
|
37 |
global $themename, $shortname, $options, $blog_id; |
|
38 |
|
|
39 |
if ( $_GET['page'] == basename(__FILE__) ) { |
|
40 |
|
|
41 |
if ( 'save' == $_REQUEST['action'] ) { |
|
42 |
|
|
43 |
foreach ($options as $value) { |
|
44 |
update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } |
|
45 |
|
|
46 |
foreach ($options as $value) { |
|
47 |
if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } |
|
48 |
|
|
49 |
header("Location: themes.php?page=theme-options.php&saved=true"); |
|
50 |
die; |
|
51 |
|
|
52 |
} else if( 'reset' == $_REQUEST['action'] ) { |
|
53 |
|
|
54 |
foreach ($options as $value) { |
|
55 |
delete_option( $value['id'] ); } |
|
56 |
|
|
57 |
header("Location: themes.php?page=theme-options.php&reset=true"); |
|
58 |
die; |
|
59 |
|
|
60 |
} else if ( 'resetwidgets' == $_REQUEST['action'] ) { |
|
61 |
update_option('sidebars_widgets',NULL); |
|
62 |
header("Location: themes.php?page=theme-options.php&resetwidgets=true"); |
|
63 |
die; |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
add_theme_page($themename." Options", "Thematic Options", 'edit_themes', basename(__FILE__), 'mytheme_admin'); |
|
68 |
|
|
69 |
} |
|
70 |
|
|
71 |
function mytheme_admin() { |
|
72 |
|
|
73 |
global $themename, $shortname, $options; |
|
74 |
|
|
75 |
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' '.__('settings saved.','thematic').'</strong></p></div>'; |
|
76 |
if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' '.__('settings reset.','thematic').'</strong></p></div>'; |
|
77 |
if ( $_REQUEST['resetwidgets'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' '.__('widgets reset.','thematic').'</strong></p></div>'; |
|
78 |
|
|
79 |
?> |
|
80 |
<div class="wrap"> |
|
81 |
<?php if ( function_exists('screen_icon') ) screen_icon(); ?> |
|
82 |
<h2><?php echo $themename; ?> Options</h2> |
|
83 |
|
|
84 |
<form method="post" action=""> |
|
85 |
|
|
86 |
<table class="form-table"> |
|
87 |
|
|
88 |
<?php foreach ($options as $value) { |
|
89 |
|
|
90 |
switch ( $value['type'] ) { |
|
91 |
case 'text': |
|
92 |
?> |
|
93 |
<tr valign="top"> |
|
94 |
<th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo __($value['name'],'thematic'); ?></label></th> |
|
95 |
<td> |
|
96 |
<input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_option( $value['id'] ) != "") { echo get_option( $value['id'] ); } else { echo $value['std']; } ?>" /> |
|
97 |
<?php echo __($value['desc'],'thematic'); ?> |
|
98 |
|
|
99 |
</td> |
|
100 |
</tr> |
|
101 |
<?php |
|
102 |
break; |
|
103 |
|
|
104 |
case 'select': |
|
105 |
?> |
|
106 |
<tr valign="top"> |
|
107 |
<th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo __($value['name'],'thematic'); ?></label></th> |
|
108 |
<td> |
|
109 |
<select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"> |
|
110 |
<?php foreach ($value['options'] as $option) { ?> |
|
111 |
<option<?php if ( get_option( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option> |
|
112 |
<?php } ?> |
|
113 |
</select> |
|
114 |
</td> |
|
115 |
</tr> |
|
116 |
<?php |
|
117 |
break; |
|
118 |
|
|
119 |
case 'textarea': |
|
120 |
$ta_options = $value['options']; |
|
121 |
?> |
|
122 |
<tr valign="top"> |
|
123 |
<th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo __($value['name'],'thematic'); ?></label></th> |
|
124 |
<td><textarea name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" cols="<?php echo $ta_options['cols']; ?>" rows="<?php echo $ta_options['rows']; ?>"><?php |
|
125 |
if( get_option($value['id']) != "") { |
|
126 |
echo __(stripslashes(get_option($value['id'])),'thematic'); |
|
127 |
}else{ |
|
128 |
echo __($value['std'],'thematic'); |
|
129 |
}?></textarea><br /><?php echo __($value['desc'],'thematic'); ?></td> |
|
130 |
</tr> |
|
131 |
<?php |
|
132 |
break; |
|
133 |
|
|
134 |
case 'radio': |
|
135 |
?> |
|
136 |
<tr valign="top"> |
|
137 |
<th scope="row"><?php echo __($value['name'],'thematic'); ?></th> |
|
138 |
<td> |
|
139 |
<?php foreach ($value['options'] as $key=>$option) { |
|
140 |
$radio_setting = get_option($value['id']); |
|
141 |
if($radio_setting != ''){ |
|
142 |
if ($key == get_option($value['id']) ) { |
|
143 |
$checked = "checked=\"checked\""; |
|
144 |
} else { |
|
145 |
$checked = ""; |
|
146 |
} |
|
147 |
}else{ |
|
148 |
if($key == $value['std']){ |
|
149 |
$checked = "checked=\"checked\""; |
|
150 |
}else{ |
|
151 |
$checked = ""; |
|
152 |
} |
|
153 |
}?> |
|
154 |
<input type="radio" name="<?php echo $value['id']; ?>" id="<?php echo $value['id'] . $key; ?>" value="<?php echo $key; ?>" <?php echo $checked; ?> /><label for="<?php echo $value['id'] . $key; ?>"><?php echo $option; ?></label><br /> |
|
155 |
<?php } ?> |
|
156 |
</td> |
|
157 |
</tr> |
|
158 |
<?php |
|
159 |
break; |
|
160 |
|
|
161 |
case 'checkbox': |
|
162 |
?> |
|
163 |
<tr valign="top"> |
|
164 |
<th scope="row"><?php echo __($value['name'],'thematic'); ?></th> |
|
165 |
<td> |
|
166 |
<?php |
|
167 |
if(get_option($value['id'])){ |
|
168 |
$checked = "checked=\"checked\""; |
|
169 |
}else{ |
|
170 |
$checked = ""; |
|
171 |
} |
|
172 |
?> |
|
173 |
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> /> |
|
174 |
<label for="<?php echo $value['id']; ?>"><?php echo __($value['desc'],'thematic'); ?></label> |
|
175 |
</td> |
|
176 |
</tr> |
|
177 |
<?php |
|
178 |
break; |
|
179 |
|
|
180 |
default: |
|
181 |
|
|
182 |
break; |
|
183 |
} |
|
184 |
} |
|
185 |
?> |
|
186 |
|
|
187 |
</table> |
|
188 |
|
|
189 |
<p class="submit"> |
|
190 |
<input class="button-primary" name="save" type="submit" value="<?php _e('Save changes','thematic'); ?>" /> |
|
191 |
<input type="hidden" name="action" value="save" /> |
|
192 |
</p> |
|
193 |
</form> |
|
194 |
<form method="post" action=""> |
|
195 |
<p class="submit"> |
|
196 |
<input class="button-secondary" name="reset" type="submit" value="<?php _e('Reset','thematic'); ?>" /> |
|
197 |
<input type="hidden" name="action" value="reset" /> |
|
198 |
</p> |
|
199 |
</form> |
|
200 |
<form method="post" action=""> |
|
201 |
<p class="submit"> |
|
202 |
<input class="button-secondary" name="reset_widgets" type="submit" value="<?php _e('Reset Widgets','thematic'); ?>" /> |
|
203 |
<input type="hidden" name="action" value="resetwidgets" /> |
|
204 |
</p> |
|
205 |
</form> |
|
206 |
|
|
207 |
<p><?php _e('For more information about this theme, <a href="http://themeshaper.com">visit ThemeShaper</a>. Please visit the <a href="http://themeshaper.com/forums/">ThemeShaper Forums</a> if you have any questions about Thematic.', 'thematic'); ?></p> |
|
208 |
</div> |
|
209 |
<?php |
|
210 |
} |
|
211 |
|
|
212 |
add_action('admin_menu' , 'mytheme_add_admin'); |
|
213 |
|
|
214 |
|
|
215 |
?> |