Projects : mp-wp : mp-wp_svg-screenshots-and-errorreporting-r2
1 | <?php |
2 | /** |
3 | * @package WordPress |
4 | * @subpackage Default_Theme |
5 | */ |
6 | |
7 | if ( function_exists('register_sidebar') ) |
8 | register_sidebar(array( |
9 | 'before_widget' => '<li id="%1$s" class="widget %2$s">', |
10 | 'after_widget' => '</li>', |
11 | 'before_title' => '<h2 class="widgettitle">', |
12 | 'after_title' => '</h2>', |
13 | )); |
14 | |
15 | /** @ignore */ |
16 | function kubrick_head() { |
17 | $head = "<style type='text/css'>\n<!--"; |
18 | $output = ''; |
19 | if ( kubrick_header_image() ) { |
20 | $url = kubrick_header_image_url() ; |
21 | $output .= "#header { background: url('$url') no-repeat bottom center; }\n"; |
22 | } |
23 | if ( false !== ( $color = kubrick_header_color() ) ) { |
24 | $output .= "#headerimg h1 a, #headerimg h1 a:visited, #headerimg .description { color: $color; }\n"; |
25 | } |
26 | if ( false !== ( $display = kubrick_header_display() ) ) { |
27 | $output .= "#headerimg { display: $display }\n"; |
28 | } |
29 | $foot = "--></style>\n"; |
30 | if ( '' != $output ) |
31 | echo $head . $output . $foot; |
32 | } |
33 | |
34 | add_action('wp_head', 'kubrick_head'); |
35 | |
36 | function kubrick_header_image() { |
37 | return apply_filters('kubrick_header_image', get_option('kubrick_header_image')); |
38 | } |
39 | |
40 | function kubrick_upper_color() { |
41 | if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) { |
42 | parse_str(substr($url, strpos($url, '?') + 1), $q); |
43 | return $q['upper']; |
44 | } else |
45 | return '69aee7'; |
46 | } |
47 | |
48 | function kubrick_lower_color() { |
49 | if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) { |
50 | parse_str(substr($url, strpos($url, '?') + 1), $q); |
51 | return $q['lower']; |
52 | } else |
53 | return '4180b6'; |
54 | } |
55 | |
56 | function kubrick_header_image_url() { |
57 | if ( $image = kubrick_header_image() ) |
58 | $url = get_template_directory_uri() . '/images/' . $image; |
59 | else |
60 | $url = get_template_directory_uri() . '/images/kubrickheader.svg'; |
61 | |
62 | return $url; |
63 | } |
64 | |
65 | function kubrick_header_color() { |
66 | return apply_filters('kubrick_header_color', get_option('kubrick_header_color')); |
67 | } |
68 | |
69 | function kubrick_header_color_string() { |
70 | $color = kubrick_header_color(); |
71 | if ( false === $color ) |
72 | return 'white'; |
73 | |
74 | return $color; |
75 | } |
76 | |
77 | function kubrick_header_display() { |
78 | return apply_filters('kubrick_header_display', get_option('kubrick_header_display')); |
79 | } |
80 | |
81 | function kubrick_header_display_string() { |
82 | $display = kubrick_header_display(); |
83 | return $display ? $display : 'inline'; |
84 | } |
85 | |
86 | add_action('admin_menu', 'kubrick_add_theme_page'); |
87 | |
88 | function kubrick_add_theme_page() { |
89 | if ( isset( $_GET['page'] ) && $_GET['page'] == basename(__FILE__) ) { |
90 | if ( isset( $_REQUEST['action'] ) && 'save' == $_REQUEST['action'] ) { |
91 | check_admin_referer('kubrick-header'); |
92 | if ( isset($_REQUEST['njform']) ) { |
93 | if ( isset($_REQUEST['defaults']) ) { |
94 | delete_option('kubrick_header_image'); |
95 | delete_option('kubrick_header_color'); |
96 | delete_option('kubrick_header_display'); |
97 | } else { |
98 | if ( '' == $_REQUEST['njfontcolor'] ) |
99 | delete_option('kubrick_header_color'); |
100 | else { |
101 | $fontcolor = preg_replace('/^.*(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['njfontcolor']); |
102 | update_option('kubrick_header_color', $fontcolor); |
103 | } |
104 | if ( preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njuppercolor'], $uc) && preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njlowercolor'], $lc) ) { |
105 | $uc = ( strlen($uc[0]) == 3 ) ? $uc[0]{0}.$uc[0]{0}.$uc[0]{1}.$uc[0]{1}.$uc[0]{2}.$uc[0]{2} : $uc[0]; |
106 | $lc = ( strlen($lc[0]) == 3 ) ? $lc[0]{0}.$lc[0]{0}.$lc[0]{1}.$lc[0]{1}.$lc[0]{2}.$lc[0]{2} : $lc[0]; |
107 | update_option('kubrick_header_image', "header-img.php?upper=$uc&lower=$lc"); |
108 | } |
109 | |
110 | if ( isset($_REQUEST['toggledisplay']) ) { |
111 | if ( false === get_option('kubrick_header_display') ) |
112 | update_option('kubrick_header_display', 'none'); |
113 | else |
114 | delete_option('kubrick_header_display'); |
115 | } |
116 | } |
117 | } else { |
118 | |
119 | if ( isset($_REQUEST['headerimage']) ) { |
120 | check_admin_referer('kubrick-header'); |
121 | if ( '' == $_REQUEST['headerimage'] ) |
122 | delete_option('kubrick_header_image'); |
123 | else { |
124 | $headerimage = preg_replace('/^.*?(header-img.php\?upper=[0-9a-fA-F]{6}&lower=[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['headerimage']); |
125 | update_option('kubrick_header_image', $headerimage); |
126 | } |
127 | } |
128 | |
129 | if ( isset($_REQUEST['fontcolor']) ) { |
130 | check_admin_referer('kubrick-header'); |
131 | if ( '' == $_REQUEST['fontcolor'] ) |
132 | delete_option('kubrick_header_color'); |
133 | else { |
134 | $fontcolor = preg_replace('/^.*?(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['fontcolor']); |
135 | update_option('kubrick_header_color', $fontcolor); |
136 | } |
137 | } |
138 | |
139 | if ( isset($_REQUEST['fontdisplay']) ) { |
140 | check_admin_referer('kubrick-header'); |
141 | if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] ) |
142 | delete_option('kubrick_header_display'); |
143 | else |
144 | update_option('kubrick_header_display', 'none'); |
145 | } |
146 | } |
147 | //print_r($_REQUEST); |
148 | wp_redirect("themes.php?page=functions.php&saved=true"); |
149 | die; |
150 | } |
151 | add_action('admin_head', 'kubrick_theme_page_head'); |
152 | } |
153 | add_theme_page(__('Customize Header'), __('Header Image and Color'), 'edit_themes', basename(__FILE__), 'kubrick_theme_page'); |
154 | } |
155 | |
156 | function kubrick_theme_page_head() { |
157 | ?> |
158 | <script type="text/javascript" src="../wp-includes/js/colorpicker.js"></script> |
159 | <script type='text/javascript'> |
160 | // <![CDATA[ |
161 | function pickColor(color) { |
162 | ColorPicker_targetInput.value = color; |
163 | kUpdate(ColorPicker_targetInput.id); |
164 | } |
165 | function PopupWindow_populate(contents) { |
166 | contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" class="button-secondary" value="<?php echo attribute_escape(__('Close Color Picker')); ?>" onclick="cp.hidePopup(\'prettyplease\')"></input></p>'; |
167 | this.contents = contents; |
168 | this.populated = false; |
169 | } |
170 | function PopupWindow_hidePopup(magicword) { |
171 | if ( magicword != 'prettyplease' ) |
172 | return false; |
173 | if (this.divName != null) { |
174 | if (this.use_gebi) { |
175 | document.getElementById(this.divName).style.visibility = "hidden"; |
176 | } |
177 | else if (this.use_css) { |
178 | document.all[this.divName].style.visibility = "hidden"; |
179 | } |
180 | else if (this.use_layers) { |
181 | document.layers[this.divName].visibility = "hidden"; |
182 | } |
183 | } |
184 | else { |
185 | if (this.popupWindow && !this.popupWindow.closed) { |
186 | this.popupWindow.close(); |
187 | this.popupWindow = null; |
188 | } |
189 | } |
190 | return false; |
191 | } |
192 | function colorSelect(t,p) { |
193 | if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" ) |
194 | cp.hidePopup('prettyplease'); |
195 | else { |
196 | cp.p = p; |
197 | cp.select(t,p); |
198 | } |
199 | } |
200 | function PopupWindow_setSize(width,height) { |
201 | this.width = 162; |
202 | this.height = 210; |
203 | } |
204 | |
205 | var cp = new ColorPicker(); |
206 | function advUpdate(val, obj) { |
207 | document.getElementById(obj).value = val; |
208 | kUpdate(obj); |
209 | } |
210 | function kUpdate(oid) { |
211 | if ( 'uppercolor' == oid || 'lowercolor' == oid ) { |
212 | uc = document.getElementById('uppercolor').value.replace('#', ''); |
213 | lc = document.getElementById('lowercolor').value.replace('#', ''); |
214 | hi = document.getElementById('headerimage'); |
215 | hi.value = 'header-img.php?upper='+uc+'&lower='+lc; |
216 | document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/'+hi.value+'") center no-repeat'; |
217 | document.getElementById('advuppercolor').value = '#'+uc; |
218 | document.getElementById('advlowercolor').value = '#'+lc; |
219 | } |
220 | if ( 'fontcolor' == oid ) { |
221 | document.getElementById('header').style.color = document.getElementById('fontcolor').value; |
222 | document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value; |
223 | } |
224 | if ( 'fontdisplay' == oid ) { |
225 | document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value; |
226 | } |
227 | } |
228 | function toggleDisplay() { |
229 | td = document.getElementById('fontdisplay'); |
230 | td.value = ( td.value == 'none' ) ? 'inline' : 'none'; |
231 | kUpdate('fontdisplay'); |
232 | } |
233 | function toggleAdvanced() { |
234 | a = document.getElementById('jsAdvanced'); |
235 | if ( a.style.display == 'none' ) |
236 | a.style.display = 'block'; |
237 | else |
238 | a.style.display = 'none'; |
239 | } |
240 | function kDefaults() { |
241 | document.getElementById('headerimage').value = ''; |
242 | document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#69aee7'; |
243 | document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#4180b6'; |
244 | document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/kubrickheader.svg") center no-repeat'; |
245 | document.getElementById('header').style.color = '#FFFFFF'; |
246 | document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = ''; |
247 | document.getElementById('fontdisplay').value = 'inline'; |
248 | document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value; |
249 | } |
250 | function kRevert() { |
251 | document.getElementById('headerimage').value = '<?php echo js_escape(kubrick_header_image()); ?>'; |
252 | document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo js_escape(kubrick_upper_color()); ?>'; |
253 | document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo js_escape(kubrick_lower_color()); ?>'; |
254 | document.getElementById('header').style.background = 'url("<?php echo js_escape(kubrick_header_image_url()); ?>") center no-repeat'; |
255 | document.getElementById('header').style.color = ''; |
256 | document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo js_escape(kubrick_header_color_string()); ?>'; |
257 | document.getElementById('fontdisplay').value = '<?php echo js_escape(kubrick_header_display_string()); ?>'; |
258 | document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value; |
259 | } |
260 | function kInit() { |
261 | document.getElementById('jsForm').style.display = 'block'; |
262 | document.getElementById('nonJsForm').style.display = 'none'; |
263 | } |
264 | addLoadEvent(kInit); |
265 | // ]]> |
266 | </script> |
267 | <style type='text/css'> |
268 | #headwrap { |
269 | text-align: center; |
270 | } |
271 | #kubrick-header { |
272 | font-size: 80%; |
273 | } |
274 | #kubrick-header .hibrowser { |
275 | width: 780px; |
276 | height: 260px; |
277 | overflow: scroll; |
278 | } |
279 | #kubrick-header #hitarget { |
280 | display: none; |
281 | } |
282 | #kubrick-header #header h1 { |
283 | font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif; |
284 | font-weight: bold; |
285 | font-size: 4em; |
286 | text-align: center; |
287 | padding-top: 70px; |
288 | margin: 0; |
289 | } |
290 | |
291 | #kubrick-header #header .description { |
292 | font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; |
293 | font-size: 1.2em; |
294 | text-align: center; |
295 | } |
296 | #kubrick-header #header { |
297 | text-decoration: none; |
298 | color: <?php echo kubrick_header_color_string(); ?>; |
299 | padding: 0; |
300 | margin: 0; |
301 | height: 200px; |
302 | text-align: center; |
303 | background: url('<?php echo kubrick_header_image_url(); ?>') center no-repeat; |
304 | } |
305 | #kubrick-header #headerimg { |
306 | margin: 0; |
307 | height: 200px; |
308 | width: 100%; |
309 | display: <?php echo kubrick_header_display_string(); ?>; |
310 | } |
311 | #jsForm { |
312 | display: none; |
313 | text-align: center; |
314 | } |
315 | #jsForm input.submit, #jsForm input.button, #jsAdvanced input.button { |
316 | padding: 0px; |
317 | margin: 0px; |
318 | } |
319 | #advanced { |
320 | text-align: center; |
321 | width: 620px; |
322 | } |
323 | html>body #advanced { |
324 | text-align: center; |
325 | position: relative; |
326 | left: 50%; |
327 | margin-left: -380px; |
328 | } |
329 | #jsAdvanced { |
330 | text-align: right; |
331 | } |
332 | #nonJsForm { |
333 | position: relative; |
334 | text-align: left; |
335 | margin-left: -370px; |
336 | left: 50%; |
337 | } |
338 | #nonJsForm label { |
339 | padding-top: 6px; |
340 | padding-right: 5px; |
341 | float: left; |
342 | width: 100px; |
343 | text-align: right; |
344 | } |
345 | .defbutton { |
346 | font-weight: bold; |
347 | } |
348 | .zerosize { |
349 | width: 0px; |
350 | height: 0px; |
351 | overflow: hidden; |
352 | } |
353 | #colorPickerDiv a, #colorPickerDiv a:hover { |
354 | padding: 1px; |
355 | text-decoration: none; |
356 | border-bottom: 0px; |
357 | } |
358 | </style> |
359 | <?php |
360 | } |
361 | |
362 | function kubrick_theme_page() { |
363 | if ( isset( $_REQUEST['saved'] ) ) echo '<div id="message" class="updated fade"><p><strong>'.__('Options saved.').'</strong></p></div>'; |
364 | ?> |
365 | <div class='wrap'> |
366 | <h2><?php _e('Customize Header'); ?></h2> |
367 | <div id="kubrick-header"> |
368 | <div id="headwrap"> |
369 | <div id="header"> |
370 | <div id="headerimg"> |
371 | <h1><?php bloginfo('name'); ?></h1> |
372 | <div class="description"><?php bloginfo('description'); ?></div> |
373 | </div> |
374 | </div> |
375 | </div> |
376 | <br /> |
377 | <div id="nonJsForm"> |
378 | <form method="post" action=""> |
379 | <?php wp_nonce_field('kubrick-header'); ?> |
380 | <div class="zerosize"><input type="submit" name="defaultsubmit" value="<?php echo attribute_escape(__('Save')); ?>" /></div> |
381 | <label for="njfontcolor"><?php _e('Font Color:'); ?></label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /> <?php printf(__('Any CSS color (%s or %s or %s)'), '<code>red</code>', '<code>#FF0000</code>', '<code>rgb(255, 0, 0)</code>'); ?><br /> |
382 | <label for="njuppercolor"><?php _e('Upper Color:'); ?></label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br /> |
383 | <label for="njlowercolor"><?php _e('Lower Color:'); ?></label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br /> |
384 | <input type="hidden" name="hi" id="hi" value="<?php echo attribute_escape(kubrick_header_image()); ?>" /> |
385 | <input type="submit" name="toggledisplay" id="toggledisplay" value="<?php echo attribute_escape(__('Toggle Text')); ?>" /> |
386 | <input type="submit" name="defaults" value="<?php echo attribute_escape(__('Use Defaults')); ?>" /> |
387 | <input type="submit" class="defbutton" name="submitform" value=" <?php _e('Save'); ?> " /> |
388 | <input type="hidden" name="action" value="save" /> |
389 | <input type="hidden" name="njform" value="true" /> |
390 | </form> |
391 | </div> |
392 | <div id="jsForm"> |
393 | <form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo attribute_escape($_SERVER['REQUEST_URI']); ?>"> |
394 | <?php wp_nonce_field('kubrick-header'); ?> |
395 | <input type="button" class="button-secondary" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="<?php echo attribute_escape(__('Font Color')); ?>"></input> |
396 | <input type="button" class="button-secondary" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="<?php echo attribute_escape(__('Upper Color')); ?>"></input> |
397 | <input type="button" class="button-secondary" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="<?php echo attribute_escape(__('Lower Color')); ?>"></input> |
398 | <input type="button" class="button-secondary" name="revert" value="<?php echo attribute_escape(__('Revert')); ?>" onclick="kRevert()" /> |
399 | <input type="button" class="button-secondary" value="<?php echo attribute_escape(__('Advanced')); ?>" onclick="toggleAdvanced()" /> |
400 | <input type="hidden" name="action" value="save" /> |
401 | <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo attribute_escape(kubrick_header_display()); ?>" /> |
402 | <input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /> |
403 | <input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo attribute_escape(kubrick_upper_color()); ?>" /> |
404 | <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo attribute_escape(kubrick_lower_color()); ?>" /> |
405 | <input type="hidden" name="headerimage" id="headerimage" value="<?php echo attribute_escape(kubrick_header_image()); ?>" /> |
406 | <p class="submit"><input type="submit" name="submitform" class="button-primary" value="<?php echo attribute_escape(__('Update Header')); ?>" onclick="cp.hidePopup('prettyplease')" /></p> |
407 | </form> |
408 | <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div> |
409 | <div id="advanced"> |
410 | <form id="jsAdvanced" style="display:none;" action=""> |
411 | <?php wp_nonce_field('kubrick-header'); ?> |
412 | <label for="advfontcolor"><?php _e('Font Color (CSS):'); ?> </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /><br /> |
413 | <label for="advuppercolor"><?php _e('Upper Color (HEX):');?> </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /><br /> |
414 | <label for="advlowercolor"><?php _e('Lower Color (HEX):'); ?> </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /><br /> |
415 | <input type="button" class="button-secondary" name="default" value="<?php echo attribute_escape(__('Select Default Colors')); ?>" onclick="kDefaults()" /><br /> |
416 | <input type="button" class="button-secondary" onclick="toggleDisplay();return false;" name="pick" id="pick" value="<?php echo attribute_escape(__('Toggle Text Display')); ?>"></input><br /> |
417 | </form> |
418 | </div> |
419 | </div> |
420 | </div> |
421 | </div> |
422 | <?php } ?> |