Changeset 20241 for trunk/wp-admin/custom-header.php
- Timestamp:
- 03/21/2012 07:10:13 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/custom-header.php
r20212 r20241 209 209 } 210 210 211 if ( isset( $_POST['text-color'] ) ) { 211 if ( ! isset( $_POST['display-header-text'] ) ) { 212 check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); 213 set_theme_mod( 'header_textcolor', 'blank' ); 214 } elseif ( isset( $_POST['text-color'] ) ) { 212 215 check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); 213 216 $_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] ); 214 if ( 'blank' == $_POST['text-color'] ) { 217 $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text-color']); 218 if ( strlen($color) == 6 || strlen($color) == 3 ) 219 set_theme_mod('header_textcolor', $color); 220 elseif ( ! $color ) 215 221 set_theme_mod( 'header_textcolor', 'blank' ); 216 } else {217 $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text-color']);218 if ( strlen($color) == 6 || strlen($color) == 3 )219 set_theme_mod('header_textcolor', $color);220 }221 222 } 222 223 … … 330 331 <script type="text/javascript"> 331 332 /* <![CDATA[ */ 332 var text_objects = ['#name', '#desc', '#text-color-row'];333 var farbtastic; 334 var default_color = '#<?php echo get_theme_support( 'custom-header', 'default-text-color' ); ?>' ;335 var old_color = null;333 var farbtastic; 334 (function($){ 335 var default_color = '#<?php echo get_theme_support( 'custom-header', 'default-text-color' ); ?>', 336 header_text_fields; 336 337 337 338 function pickColor(color) { 338 jQuery('#name').css('color', color);339 jQuery('#desc').css('color', color);340 jQuery('#text-color').val(color);339 $('#name').css('color', color); 340 $('#desc').css('color', color); 341 $('#text-color').val(color); 341 342 farbtastic.setColor(color); 342 343 } 343 344 344 function toggle_text(s) { 345 if (jQuery(s).attr('id') == 'showtext' && jQuery('#text-color').val() != 'blank') 345 function toggle_text() { 346 var checked = $('#display-header-text').prop('checked'), 347 text_color; 348 header_text_fields.toggle( checked ); 349 if ( ! checked ) 346 350 return; 347 348 if (jQuery(s).attr('id') == 'hidetext' && jQuery('#text-color').val() == 'blank') 349 return; 350 351 if (jQuery('#text-color').val() == 'blank') { 352 //Show text 353 if (old_color == '#blank') 354 old_color = default_color; 355 356 jQuery( text_objects.toString() ).show(); 357 jQuery('#text-color').val(old_color); 358 jQuery('#name').css('color', old_color); 359 jQuery('#desc').css('color', old_color); 360 pickColor(old_color); 351 text_color = $('#text-color'); 352 if ( '' == text_color.val().replace('#', '') ) { 353 text_color.val( default_color ); 354 pickColor( default_color ); 361 355 } else { 362 //Hide text 363 jQuery( text_objects.toString() ).hide(); 364 old_color = jQuery('#text-color').val(); 365 jQuery('#text-color').val('blank'); 366 } 367 } 368 369 jQuery(document).ready(function() { 370 jQuery('#pickcolor').click(function() { 371 jQuery('#color-picker').show(); 356 pickColor( text_color.val() ); 357 } 358 } 359 360 $(document).ready(function() { 361 header_text_fields = $('.displaying-header-text'); 362 $('#pickcolor').click(function(e) { 363 e.preventDefault(); 364 $('#color-picker').show(); 372 365 }); 373 366 374 jQuery('input[name="hidetext"]').click(function() { 375 toggle_text(this); 367 $('#display-header-text').click( toggle_text ); 368 369 $('#defaultcolor').click(function() { 370 pickColor(default_color); 371 $('#text-color').val(default_color); 376 372 }); 377 373 378 jQuery('#defaultcolor').click(function() { 379 pickColor(default_color); 380 jQuery('#text-color').val(default_color) 381 }); 382 383 jQuery('#text-color').keyup(function() { 384 var _hex = jQuery('#text-color').val(); 374 $('#text-color').keyup(function() { 375 var _hex = $('#text-color').val(); 385 376 var hex = _hex; 386 377 if ( hex[0] != '#' ) … … 388 379 hex = hex.replace(/[^#a-fA-F0-9]+/, ''); 389 380 if ( hex != _hex ) 390 jQuery('#text-color').val(hex);381 $('#text-color').val(hex); 391 382 if ( hex.length == 4 || hex.length == 7 ) 392 383 pickColor( hex ); 393 384 }); 394 385 395 jQuery(document).mousedown(function(){396 jQuery('#color-picker').each( function() {397 var display = jQuery(this).css('display');386 $(document).mousedown(function(){ 387 $('#color-picker').each( function() { 388 var display = $(this).css('display'); 398 389 if (display == 'block') 399 jQuery(this).fadeOut(2);390 $(this).fadeOut(2); 400 391 }); 401 392 }); 402 393 403 farbtastic = jQuery.farbtastic('#color-picker', function(color) { pickColor(color); }); 404 <?php if ( $color = get_header_textcolor() ) { ?> 405 pickColor('#<?php echo $color; ?>'); 406 <?php } ?> 407 408 <?php if ( 'blank' == $color || '' == $color || ! current_theme_supports( 'custom-header', 'header-text' ) ) { ?> 409 toggle_text(); 394 farbtastic = $.farbtastic('#color-picker', function(color) { pickColor(color); }); 395 <?php if ( display_header_text() ) { ?> 396 pickColor('#<?php echo get_header_textcolor(); ?>'); 397 <?php } else { ?> 398 toggle_text(); 410 399 <?php } ?> 411 400 }); 401 })(jQuery); 412 402 /* ]]> */ 413 403 </script> … … 508 498 <?php } ?> 509 499 500 <h3><?php _e( 'Header Image' ); ?></h3> 501 510 502 <table class="form-table"> 511 503 <tbody> … … 520 512 <div id="headimg" style="background-image:url(<?php esc_url ( header_image() ) ?>);max-width:<?php echo get_custom_header()->width; ?>px;height:<?php echo get_custom_header()->height; ?>px;"> 521 513 <?php 522 $color = get_header_textcolor(); 523 if ( 'blank' == $color || '' == $color || ! current_theme_supports( 'custom-header', 'header-text' ) ) 514 if ( display_header_text() ) 515 $style = ' style="color:#' . get_header_textcolor() . ';"'; 516 else 524 517 $style = ' style="display:none;"'; 525 else526 $style = ' style="color:#' . $color . ';"';527 518 ?> 528 <h1><a id="name" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>"><?php bloginfo( 'name' ); ?></a></h1>529 <div id="desc" <?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>519 <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>"><?php bloginfo( 'name' ); ?></a></h1> 520 <div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> 530 521 </div> 531 522 <?php } ?> … … 619 610 </tbody> 620 611 </table> 621 <?php if ( current_theme_supports( 'custom-header', 'header-text' ) ) : ?> 612 613 <?php if ( current_theme_supports( 'custom-header', 'header-text' ) ) : ?> 614 615 <h3><?php _e( 'Header Text' ); ?></h3> 616 622 617 <table class="form-table"> 623 618 <tbody> 624 <tr valign="top" class="hide-if-no-js">625 <th scope="row"><?php _e( ' DisplayText' ); ?></th>619 <tr valign="top"> 620 <th scope="row"><?php _e( 'Header Text' ); ?></th> 626 621 <td> 627 622 <p> 628 <?php 629 $show_text = get_header_textcolor(); 630 if ( 'blank' == $show_text ) 631 $show_text = false; 632 else 633 $show_text = (bool) $show_text; 634 ?> 635 <label><input type="radio" value="1" name="hidetext" id="hidetext"<?php checked( ! $show_text ); ?> /> <?php _e( 'No' ); ?></label> 636 <label><input type="radio" value="0" name="hidetext" id="showtext"<?php checked( $show_text ); ?> /> <?php _e( 'Yes' ); ?></label> 623 <label><input type="checkbox" name="display-header-text" id="display-header-text"<?php checked( display_header_text() ); ?> /> <?php _e( 'Show header text with your image.' ); ?></label> 637 624 </p> 638 625 </td> 639 626 </tr> 640 627 641 <tr valign="top" id="text-color-row">628 <tr valign="top" class="displaying-header-text"> 642 629 <th scope="row"><?php _e( 'Text Color' ); ?></th> 643 630 <td> 644 631 <p> 632 <?php if ( display_header_text() ) : ?> 645 633 <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr( get_header_textcolor() ); ?>" /> 646 <span class="description hide-if-js"><?php _e( 'If you want to hide header text, add <strong>#blank</strong> as text color.' );?></span> 647 <input type="button" class="button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color' ); ?>" id="pickcolor" /> 634 <?php else : ?> 635 <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr( get_theme_support( 'custom-header', 'default-text-color' ) ); ?>" /> 636 <?php endif; ?> 637 <a href="#" class="hide-if-no-js" id="pickcolor"><?php _e( 'Select a Color' ); ?></a> 648 638 </p> 649 639 <div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> … … 663 653 </tbody> 664 654 </table> 665 655 <?php endif; 666 656 667 657 do_action( 'custom_header_options' );
Note: See TracChangeset
for help on using the changeset viewer.