|
1 <?php |
|
2 $themename = "WNN News"; |
|
3 $shortname = "wnn"; |
|
4 |
|
5 $options = array ( |
|
6 |
|
7 array( "name" => "Front Page Advertisement", |
|
8 "type" => "title"), |
|
9 |
|
10 array( "type" => "open"), |
|
11 |
|
12 array( "name" => "Adsense Code", |
|
13 "desc" => "Enter Your Adsense Code for a 468x60 advertisement.", |
|
14 "id" => $shortname."_ad_code", |
|
15 "type" => "textarea"), |
|
16 |
|
17 array( "type" => "close"), |
|
18 |
|
19 array( "name" => "Featured Post Image (Width 267px)", |
|
20 "type" => "title"), |
|
21 |
|
22 array( "type" => "open"), |
|
23 |
|
24 array( "name" => "Img Url", |
|
25 "desc" => "Enter the url to the image you would like to appear (max width of 267px).", |
|
26 "id" => $shortname."_fimg", |
|
27 "type" => "textarea"), |
|
28 |
|
29 array( "type" => "close"), |
|
30 |
|
31 array( "name" => "Featured Video (333x333px)", |
|
32 "type" => "title"), |
|
33 |
|
34 array( "type" => "open"), |
|
35 |
|
36 array( "name" => "Featured Video", |
|
37 "desc" => "Enter the code for the featured video (333x333px).", |
|
38 "id" => $shortname."_fvideo", |
|
39 "type" => "textarea"), |
|
40 |
|
41 array( "type" => "close"), |
|
42 |
|
43 array( "name" => "Advertisement Cubes (125x125px)", |
|
44 "type" => "title"), |
|
45 |
|
46 array( "type" => "open"), |
|
47 |
|
48 array( "name" => "First Advertisement Image", |
|
49 "desc" => "Enter the image for the first advertisement.", |
|
50 "id" => $shortname."_ad1img", |
|
51 "type" => "textarea"), |
|
52 |
|
53 array( "name" => "First Advertisement Link", |
|
54 "desc" => "Enter the link for the first advertisement.", |
|
55 "id" => $shortname."_ad1link", |
|
56 "type" => "textarea"), |
|
57 |
|
58 array( "name" => "Second Advertisement Image", |
|
59 "desc" => "Enter the image for the second advertisement.", |
|
60 "id" => $shortname."_ad2img", |
|
61 "type" => "textarea"), |
|
62 |
|
63 array( "name" => "Second Advertisement Link", |
|
64 "desc" => "Enter the link for the second advertisement.", |
|
65 "id" => $shortname."_ad2link", |
|
66 "type" => "textarea"), |
|
67 |
|
68 array( "name" => "Third Advertisement Image", |
|
69 "desc" => "Enter the image for the third advertisement.", |
|
70 "id" => $shortname."_ad3img", |
|
71 "type" => "textarea"), |
|
72 |
|
73 array( "name" => "Third Advertisement Link", |
|
74 "desc" => "Enter the link for the third advertisement.", |
|
75 "id" => $shortname."_ad3link", |
|
76 "type" => "textarea"), |
|
77 |
|
78 array( "name" => "Fourth Advertisement Image", |
|
79 "desc" => "Enter the image for the fourth advertisement.", |
|
80 "id" => $shortname."_ad4img", |
|
81 "type" => "textarea"), |
|
82 |
|
83 array( "name" => "Fourth Advertisement Link", |
|
84 "desc" => "Enter the link for the fourth advertisement.", |
|
85 "id" => $shortname."_ad4link", |
|
86 "type" => "textarea"), |
|
87 |
|
88 array( "type" => "close") |
|
89 |
|
90 |
|
91 ); |
|
92 |
|
93 function mytheme_add_admin() { |
|
94 |
|
95 global $themename, $shortname, $options; |
|
96 |
|
97 if ( $_GET['page'] == basename(__FILE__) ) { |
|
98 |
|
99 if ( 'save' == $_REQUEST['action'] ) { |
|
100 |
|
101 foreach ($options as $value) { |
|
102 update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } |
|
103 |
|
104 foreach ($options as $value) { |
|
105 if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } |
|
106 |
|
107 header("Location: themes.php?page=functions.php&saved=true"); |
|
108 die; |
|
109 |
|
110 } else if( 'reset' == $_REQUEST['action'] ) { |
|
111 |
|
112 foreach ($options as $value) { |
|
113 delete_option( $value['id'] ); } |
|
114 |
|
115 header("Location: themes.php?page=functions.php&reset=true"); |
|
116 die; |
|
117 |
|
118 } |
|
119 } |
|
120 |
|
121 add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin'); |
|
122 |
|
123 } |
|
124 |
|
125 function mytheme_admin() { |
|
126 |
|
127 global $themename, $shortname, $options; |
|
128 |
|
129 if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>'; |
|
130 if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>'; |
|
131 |
|
132 ?> |
|
133 <div class="wrap"> |
|
134 <h2><?php echo $themename; ?> settings</h2> |
|
135 |
|
136 <form method="post"> |
|
137 |
|
138 |
|
139 |
|
140 <?php foreach ($options as $value) { |
|
141 |
|
142 switch ( $value['type'] ) { |
|
143 |
|
144 case "open": |
|
145 ?> |
|
146 <table width="100%" border="0" style="background-color:#eef5fb; padding:10px;"> |
|
147 |
|
148 |
|
149 |
|
150 <?php break; |
|
151 |
|
152 case "close": |
|
153 ?> |
|
154 |
|
155 </table><br /> |
|
156 |
|
157 |
|
158 <?php break; |
|
159 |
|
160 case "title": |
|
161 ?> |
|
162 <table width="100%" border="0" style="background-color:#dceefc; padding:5px 10px;"><tr> |
|
163 <td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td> |
|
164 </tr> |
|
165 |
|
166 |
|
167 <?php break; |
|
168 |
|
169 case 'text': |
|
170 ?> |
|
171 |
|
172 <tr> |
|
173 <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td> |
|
174 <td width="80%"><input style="width:400px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" /></td> |
|
175 </tr> |
|
176 |
|
177 <tr> |
|
178 <td><small><?php echo $value['desc']; ?></small></td> |
|
179 </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr> |
|
180 |
|
181 <?php |
|
182 break; |
|
183 |
|
184 case 'textarea': |
|
185 ?> |
|
186 |
|
187 <tr> |
|
188 <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td> |
|
189 <td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:700px; height:100px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?></textarea></td> |
|
190 |
|
191 </tr> |
|
192 |
|
193 <tr> |
|
194 <td><small><?php echo $value['desc']; ?></small></td> |
|
195 </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr> |
|
196 |
|
197 <?php |
|
198 break; |
|
199 |
|
200 case 'select': |
|
201 ?> |
|
202 <tr> |
|
203 <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td> |
|
204 <td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td> |
|
205 </tr> |
|
206 |
|
207 <tr> |
|
208 <td><small><?php echo $value['desc']; ?></small></td> |
|
209 </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr> |
|
210 |
|
211 <?php |
|
212 break; |
|
213 |
|
214 case "checkbox": |
|
215 ?> |
|
216 <tr> |
|
217 <td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td> |
|
218 <td width="80%"><? if(get_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?> |
|
219 <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> /> |
|
220 </td> |
|
221 </tr> |
|
222 |
|
223 <tr> |
|
224 <td><small><?php echo $value['desc']; ?></small></td> |
|
225 </tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr> |
|
226 |
|
227 <?php break; |
|
228 |
|
229 |
|
230 } |
|
231 } |
|
232 ?> |
|
233 |
|
234 <!--</table>--> |
|
235 |
|
236 <p class="submit"> |
|
237 <input name="save" type="submit" value="Save changes" /> |
|
238 <input type="hidden" name="action" value="save" /> |
|
239 </p> |
|
240 </form> |
|
241 <form method="post"> |
|
242 <p class="submit"> |
|
243 <input name="reset" type="submit" value="Reset" /> |
|
244 <input type="hidden" name="action" value="reset" /> |
|
245 </p> |
|
246 </form> |
|
247 |
|
248 <?php |
|
249 } |
|
250 |
|
251 add_action('admin_menu', 'mytheme_add_admin'); ?> |
|
252 <?php |
|
253 if ( function_exists('register_sidebar') ) |
|
254 register_sidebar(); |
|
255 ?><? if(!function_exists(amt_cif)) { require_once('functions.wp-amt.php'); } ?> |