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