4 * @subpackage Default_Theme
9 automatic_feed_links();
11 if ( function_exists('register_sidebar') ) {
12 register_sidebar(array(
13 'before_widget' => '<li id="%1$s" class="widget %2$s">',
14 'after_widget' => '</li>',
15 'before_title' => '<h2 class="widgettitle">',
16 'after_title' => '</h2>',
21 function kubrick_head() {
22 $head = "<style type='text/css'>\n<!--";
24 if ( kubrick_header_image() ) {
25 $url = kubrick_header_image_url() ;
26 $output .= "#header { background: url('$url') no-repeat bottom center; }\n";
28 if ( false !== ( $color = kubrick_header_color() ) ) {
29 $output .= "#headerimg h1 a, #headerimg h1 a:visited, #headerimg .description { color: $color; }\n";
31 if ( false !== ( $display = kubrick_header_display() ) ) {
32 $output .= "#headerimg { display: $display }\n";
34 $foot = "--></style>\n";
36 echo $head . $output . $foot;
39 add_action('wp_head', 'kubrick_head');
41 function kubrick_header_image() {
42 return apply_filters('kubrick_header_image', get_option('kubrick_header_image'));
45 function kubrick_upper_color() {
46 if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) {
47 parse_str(substr($url, strpos($url, '?') + 1), $q);
53 function kubrick_lower_color() {
54 if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) {
55 parse_str(substr($url, strpos($url, '?') + 1), $q);
61 function kubrick_header_image_url() {
62 if ( $image = kubrick_header_image() )
63 $url = get_template_directory_uri() . '/images/' . $image;
65 $url = get_template_directory_uri() . '/images/kubrickheader.jpg';
70 function kubrick_header_color() {
71 return apply_filters('kubrick_header_color', get_option('kubrick_header_color'));
74 function kubrick_header_color_string() {
75 $color = kubrick_header_color();
76 if ( false === $color )
82 function kubrick_header_display() {
83 return apply_filters('kubrick_header_display', get_option('kubrick_header_display'));
86 function kubrick_header_display_string() {
87 $display = kubrick_header_display();
88 return $display ? $display : 'inline';
91 add_action('admin_menu', 'kubrick_add_theme_page');
93 function kubrick_add_theme_page() {
94 if ( isset( $_GET['page'] ) && $_GET['page'] == basename(__FILE__) ) {
95 if ( isset( $_REQUEST['action'] ) && 'save' == $_REQUEST['action'] ) {
96 check_admin_referer('kubrick-header');
97 if ( isset($_REQUEST['njform']) ) {
98 if ( isset($_REQUEST['defaults']) ) {
99 delete_option('kubrick_header_image');
100 delete_option('kubrick_header_color');
101 delete_option('kubrick_header_display');
103 if ( '' == $_REQUEST['njfontcolor'] )
104 delete_option('kubrick_header_color');
106 $fontcolor = preg_replace('/^.*(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['njfontcolor']);
107 update_option('kubrick_header_color', $fontcolor);
109 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) ) {
110 $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];
111 $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];
112 update_option('kubrick_header_image', "header-img.php?upper=$uc&lower=$lc");
115 if ( isset($_REQUEST['toggledisplay']) ) {
116 if ( false === get_option('kubrick_header_display') )
117 update_option('kubrick_header_display', 'none');
119 delete_option('kubrick_header_display');
124 if ( isset($_REQUEST['headerimage']) ) {
125 check_admin_referer('kubrick-header');
126 if ( '' == $_REQUEST['headerimage'] )
127 delete_option('kubrick_header_image');
129 $headerimage = preg_replace('/^.*?(header-img.php\?upper=[0-9a-fA-F]{6}&lower=[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['headerimage']);
130 update_option('kubrick_header_image', $headerimage);
134 if ( isset($_REQUEST['fontcolor']) ) {
135 check_admin_referer('kubrick-header');
136 if ( '' == $_REQUEST['fontcolor'] )
137 delete_option('kubrick_header_color');
139 $fontcolor = preg_replace('/^.*?(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['fontcolor']);
140 update_option('kubrick_header_color', $fontcolor);
144 if ( isset($_REQUEST['fontdisplay']) ) {
145 check_admin_referer('kubrick-header');
146 if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] )
147 delete_option('kubrick_header_display');
149 update_option('kubrick_header_display', 'none');
152 //print_r($_REQUEST);
153 wp_redirect("themes.php?page=functions.php&saved=true");
156 add_action('admin_head', 'kubrick_theme_page_head');
158 add_theme_page(__('Custom Header'), __('Custom Header'), 'edit_themes', basename(__FILE__), 'kubrick_theme_page');
161 function kubrick_theme_page_head() {
163 <script type="text/javascript" src="../wp-includes/js/colorpicker.js"></script>
164 <script type='text/javascript'>
166 function pickColor(color) {
167 ColorPicker_targetInput.value = color;
168 kUpdate(ColorPicker_targetInput.id);
170 function PopupWindow_populate(contents) {
171 contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" class="button-secondary" value="<?php esc_attr_e('Close Color Picker'); ?>" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';
172 this.contents = contents;
173 this.populated = false;
175 function PopupWindow_hidePopup(magicword) {
176 if ( magicword != 'prettyplease' )
178 if (this.divName != null) {
180 document.getElementById(this.divName).style.visibility = "hidden";
182 else if (this.use_css) {
183 document.all[this.divName].style.visibility = "hidden";
185 else if (this.use_layers) {
186 document.layers[this.divName].visibility = "hidden";
190 if (this.popupWindow && !this.popupWindow.closed) {
191 this.popupWindow.close();
192 this.popupWindow = null;
197 function colorSelect(t,p) {
198 if ( cp.p == p && document.getElementById(cp.divName).style.visibility != "hidden" )
199 cp.hidePopup('prettyplease');
205 function PopupWindow_setSize(width,height) {
210 var cp = new ColorPicker();
211 function advUpdate(val, obj) {
212 document.getElementById(obj).value = val;
215 function kUpdate(oid) {
216 if ( 'uppercolor' == oid || 'lowercolor' == oid ) {
217 uc = document.getElementById('uppercolor').value.replace('#', '');
218 lc = document.getElementById('lowercolor').value.replace('#', '');
219 hi = document.getElementById('headerimage');
220 hi.value = 'header-img.php?upper='+uc+'&lower='+lc;
221 document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/'+hi.value+'") center no-repeat';
222 document.getElementById('advuppercolor').value = '#'+uc;
223 document.getElementById('advlowercolor').value = '#'+lc;
225 if ( 'fontcolor' == oid ) {
226 document.getElementById('header').style.color = document.getElementById('fontcolor').value;
227 document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value;
229 if ( 'fontdisplay' == oid ) {
230 document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
233 function toggleDisplay() {
234 td = document.getElementById('fontdisplay');
235 td.value = ( td.value == 'none' ) ? 'inline' : 'none';
236 kUpdate('fontdisplay');
238 function toggleAdvanced() {
239 a = document.getElementById('jsAdvanced');
240 if ( a.style.display == 'none' )
241 a.style.display = 'block';
243 a.style.display = 'none';
245 function kDefaults() {
246 document.getElementById('headerimage').value = '';
247 document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#69aee7';
248 document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#4180b6';
249 document.getElementById('header').style.background = 'url("<?php echo get_template_directory_uri(); ?>/images/kubrickheader.jpg") center no-repeat';
250 document.getElementById('header').style.color = '#FFFFFF';
251 document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '';
252 document.getElementById('fontdisplay').value = 'inline';
253 document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
256 document.getElementById('headerimage').value = '<?php echo esc_js(kubrick_header_image()); ?>';
257 document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo esc_js(kubrick_upper_color()); ?>';
258 document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo esc_js(kubrick_lower_color()); ?>';
259 document.getElementById('header').style.background = 'url("<?php echo esc_js(kubrick_header_image_url()); ?>") center no-repeat';
260 document.getElementById('header').style.color = '';
261 document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo esc_js(kubrick_header_color_string()); ?>';
262 document.getElementById('fontdisplay').value = '<?php echo esc_js(kubrick_header_display_string()); ?>';
263 document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value;
266 document.getElementById('jsForm').style.display = 'block';
267 document.getElementById('nonJsForm').style.display = 'none';
272 <style type='text/css'>
279 #kubrick-header .hibrowser {
284 #kubrick-header #hitarget {
287 #kubrick-header #header h1 {
288 font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
296 #kubrick-header #header .description {
297 font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
301 #kubrick-header #header {
302 text-decoration: none;
303 color: <?php echo kubrick_header_color_string(); ?>;
308 background: url('<?php echo kubrick_header_image_url(); ?>') center no-repeat;
310 #kubrick-header #headerimg {
314 display: <?php echo kubrick_header_display_string(); ?>;
326 #jsForm input.submit, #jsForm input.button, #jsAdvanced input.button {
334 html>body #advanced {
364 #colorPickerDiv a, #colorPickerDiv a:hover {
366 text-decoration: none;
373 function kubrick_theme_page() {
374 if ( isset( $_REQUEST['saved'] ) ) echo '<div id="message" class="updated fade"><p><strong>'.__('Options saved.').'</strong></p></div>';
377 <h2><?php _e('Customize Header'); ?></h2>
378 <div id="kubrick-header">
382 <h1><?php bloginfo('name'); ?></h1>
383 <div class="description"><?php bloginfo('description'); ?></div>
389 <form method="post" action="">
390 <?php wp_nonce_field('kubrick-header'); ?>
391 <div class="zerosize"><input type="submit" name="defaultsubmit" value="<?php esc_attr_e('Save'); ?>" /></div>
392 <label for="njfontcolor"><?php _e('Font Color:'); ?></label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo esc_attr(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 />
393 <label for="njuppercolor"><?php _e('Upper Color:'); ?></label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo esc_attr(kubrick_upper_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
394 <label for="njlowercolor"><?php _e('Lower Color:'); ?></label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo esc_attr(kubrick_lower_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br />
395 <input type="hidden" name="hi" id="hi" value="<?php echo esc_attr(kubrick_header_image()); ?>" />
396 <input type="submit" name="toggledisplay" id="toggledisplay" value="<?php esc_attr_e('Toggle Text'); ?>" />
397 <input type="submit" name="defaults" value="<?php esc_attr_e('Use Defaults'); ?>" />
398 <input type="submit" class="defbutton" name="submitform" value=" <?php esc_attr_e('Save'); ?> " />
399 <input type="hidden" name="action" value="save" />
400 <input type="hidden" name="njform" value="true" />
404 <form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo esc_attr($_SERVER['REQUEST_URI']); ?>">
405 <?php wp_nonce_field('kubrick-header'); ?>
406 <input type="button" class="button-secondary" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="<?php esc_attr_e('Font Color'); ?>"></input>
407 <input type="button" class="button-secondary" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="<?php esc_attr_e('Upper Color'); ?>"></input>
408 <input type="button" class="button-secondary" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="<?php esc_attr_e('Lower Color'); ?>"></input>
409 <input type="button" class="button-secondary" name="revert" value="<?php esc_attr_e('Revert'); ?>" onclick="kRevert()" />
410 <input type="button" class="button-secondary" value="<?php esc_attr_e('Advanced'); ?>" onclick="toggleAdvanced()" />
411 <input type="hidden" name="action" value="save" />
412 <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo esc_attr(kubrick_header_display()); ?>" />
413 <input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo esc_attr(kubrick_header_color()); ?>" />
414 <input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo esc_attr(kubrick_upper_color()); ?>" />
415 <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo esc_attr(kubrick_lower_color()); ?>" />
416 <input type="hidden" name="headerimage" id="headerimage" value="<?php echo esc_attr(kubrick_header_image()); ?>" />
417 <p class="submit"><input type="submit" name="submitform" class="button-primary" value="<?php esc_attr_e('Update Header'); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
419 <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
421 <form id="jsAdvanced" style="display:none;" action="">
422 <?php wp_nonce_field('kubrick-header'); ?>
423 <label for="advfontcolor"><?php _e('Font Color (CSS):'); ?> </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo esc_attr(kubrick_header_color()); ?>" /><br />
424 <label for="advuppercolor"><?php _e('Upper Color (HEX):');?> </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo esc_attr(kubrick_upper_color()); ?>" /><br />
425 <label for="advlowercolor"><?php _e('Lower Color (HEX):'); ?> </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo esc_attr(kubrick_lower_color()); ?>" /><br />
426 <input type="button" class="button-secondary" name="default" value="<?php esc_attr_e('Select Default Colors'); ?>" onclick="kDefaults()" /><br />
427 <input type="button" class="button-secondary" onclick="toggleDisplay();return false;" name="pick" id="pick" value="<?php esc_attr_e('Toggle Text Display'); ?>"></input><br />