| 131 | | if ( isset( $_POST['textcolor'] ) ) { |
| 132 | | check_admin_referer('custom-header'); |
| 133 | | if ( 'blank' == $_POST['textcolor'] ) { |
| 134 | | set_theme_mod('header_textcolor', 'blank'); |
| | 143 | if ( empty( $_POST ) ) |
| | 144 | return; |
| | 145 | |
| | 146 | $this->updated = true; |
| | 147 | |
| | 148 | if ( isset( $_POST['resetheader'] ) ) { |
| | 149 | check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
| | 150 | remove_theme_mod( 'header_image' ); |
| | 151 | return; |
| | 152 | } |
| | 153 | |
| | 154 | if ( isset( $_POST['resettext'] ) ) { |
| | 155 | check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
| | 156 | remove_theme_mod('header_textcolor'); |
| | 157 | return; |
| | 158 | } |
| | 159 | |
| | 160 | if ( isset( $_POST['removeheader'] ) ) { |
| | 161 | check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
| | 162 | set_theme_mod( 'header_image', '' ); |
| | 163 | return; |
| | 164 | } |
| | 165 | |
| | 166 | if ( isset( $_POST['text-color'] ) ) { |
| | 167 | check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
| | 168 | $_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] ); |
| | 169 | if ( 'blank' == $_POST['text-color'] ) { |
| | 170 | set_theme_mod( 'header_textcolor', 'blank' ); |
| 182 | | echo '<table id="available-headers" cellspacing="0" cellpadding="0">'; |
| 183 | | |
| 184 | | $headers = array_keys($this->default_headers); |
| 185 | | $table = array(); |
| 186 | | $rows = ceil(count($headers) / 3); |
| 187 | | for ( $row = 1; $row <= $rows; $row++ ) { |
| 188 | | for ( $col = 1; $col <= 3; $col++ ) { |
| 189 | | $table[$row][$col] = array_shift($headers); |
| 190 | | } |
| | 213 | echo '<div id="available-headers">'; |
| | 214 | foreach ( $this->default_headers as $header_key => $header ) { |
| | 215 | $header_thumbnail = $header['thumbnail_url']; |
| | 216 | $header_url = $header['url']; |
| | 217 | $header_desc = $header['description']; |
| | 218 | echo '<div class="default-header">'; |
| | 219 | echo '<label><input name="default-header" type="radio" value="' . esc_attr($header_key) . '" ' . checked($header_url, get_theme_mod( 'header_image' ), false) . ' />'; |
| | 220 | echo '<img src="' . $header_thumbnail . '" alt="' . esc_attr($header_desc) .'" title="' . esc_attr($header_desc) .'" /></label>'; |
| | 221 | echo '</div>'; |
| 192 | | |
| 193 | | foreach ( $table as $row => $cols ) { |
| 194 | | echo '<tr>'; |
| 195 | | foreach ( $cols as $col => $header_key ) { |
| 196 | | if ( !$header_key ) |
| 197 | | continue; |
| 198 | | $class = array('available-header'); |
| 199 | | if ( $row == 1 ) $class[] = 'top'; |
| 200 | | if ( $col == 1 ) $class[] = 'left'; |
| 201 | | if ( $row == $rows ) $class[] = 'bottom'; |
| 202 | | if ( $col == 3 ) $class[] = 'right'; |
| 203 | | if ( !isset($this->headers[$header_key])) |
| 204 | | echo '<td class="' . join(' ', $class) . '">'; |
| 205 | | $header_thumbnail = $this->default_headers[$header_key]['thumbnail_url']; |
| 206 | | $header_url = $this->default_headers[$header_key]['url']; |
| 207 | | $header_desc = $this->default_headers[$header_key]['description']; |
| 208 | | echo '<label><input name="default-header" type="radio" value="' . esc_attr($header_key) . '" ' . checked($header_url, get_header_image(), false) . ' />'; |
| 209 | | echo '<img src="' . $header_thumbnail . '" alt="' . esc_attr($header_desc) .'" /></label>'; |
| 210 | | echo '</td>'; |
| 211 | | } |
| 212 | | echo '</tr>'; |
| 213 | | } |
| 214 | | echo '</table>'; |
| | 223 | echo '<div class="clear"></div></div>'; |
| | 259 | function toggle_text(s) { |
| | 260 | if (jQuery(s).attr('id') == 'showtext' && jQuery('#text-color').val() != 'blank') |
| | 261 | return; |
| | 262 | |
| | 263 | if (jQuery(s).attr('id') == 'hidetext' && jQuery('#text-color').val() == 'blank') |
| | 264 | return; |
| | 265 | |
| | 266 | if (jQuery('#text-color').val() == 'blank') { |
| | 267 | //Show text |
| | 268 | if (old_color == '#blank') |
| | 269 | old_color = default_color; |
| | 270 | |
| | 271 | jQuery( text_objects.toString() ).show(); |
| | 272 | jQuery('#text-color').val(old_color); |
| | 273 | jQuery('#name').css('color', old_color); |
| | 274 | jQuery('#desc').css('color', old_color); |
| | 275 | pickColor(old_color); |
| | 276 | } else { |
| | 277 | //Hide text |
| | 278 | jQuery( text_objects.toString() ).hide(); |
| | 279 | old_color = jQuery('#text-color').val(); |
| | 280 | jQuery('#text-color').val('blank'); |
| | 281 | } |
| | 282 | } |
| | 283 | |
| 350 | | jQuery('#upload').Jcrop({ |
| 351 | | aspectRatio: ratio, |
| 352 | | setSelect: [ 0, 0, xinit, yinit ], |
| 353 | | onSelect: onEndCrop |
| | 363 | jQuery('#upload').imgAreaSelect({ |
| | 364 | handles: true, |
| | 365 | keys: true, |
| | 366 | aspectRatio: xinit + ':' + yinit, |
| | 367 | show: true, |
| | 368 | x1: 0, |
| | 369 | y1: 0, |
| | 370 | x2: xinit, |
| | 371 | y2: yinit, |
| | 372 | maxHeight: <?php echo HEADER_IMAGE_HEIGHT; ?>, |
| | 373 | maxWidth: <?php echo HEADER_IMAGE_WIDTH; ?>, |
| | 374 | onInit: function () { |
| | 375 | jQuery('#width').val(xinit); |
| | 376 | jQuery('#height').val(yinit); |
| | 377 | }, |
| | 378 | onSelectChange: function(img, c) { |
| | 379 | jQuery('#x1').val(c.x1); |
| | 380 | jQuery('#y1').val(c.y1); |
| | 381 | jQuery('#width').val(c.width); |
| | 382 | jQuery('#height').val(c.height); |
| | 383 | } |
| 395 | | <?php if ( !defined( 'NO_HEADER_TEXT' ) ) { ?> |
| 396 | | <form method="post" action="<?php echo admin_url('themes.php?page=custom-header&updated=true') ?>"> |
| 397 | | <input type="button" class="button" value="<?php esc_attr_e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" /> |
| 398 | | <input type="button" class="button" value="<?php esc_attr_e('Select a Text Color'); ?>" id="pickcolor" /><input type="button" class="button" value="<?php esc_attr_e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" /> |
| 399 | | <?php wp_nonce_field('custom-header'); ?> |
| 400 | | <input type="hidden" name="textcolor" id="textcolor" value="#<?php esc_attr(header_textcolor()) ?>" /><input name="submit" type="submit" class="button" value="<?php esc_attr_e('Save Changes'); ?>" /></form> |
| 401 | | <?php } ?> |
| | 415 | <tr valign="top"> |
| | 416 | <th scope="row"><?php _e( 'Preview' ); ?></th> |
| | 417 | <td > |
| | 418 | <?php if ( $this->admin_image_div_callback ) { |
| | 419 | call_user_func( $this->admin_image_div_callback ); |
| | 420 | } else { |
| | 421 | ?> |
| | 422 | <div id="headimg" style="max-width:<?php echo HEADER_IMAGE_WIDTH; ?>px;height:<?php echo HEADER_IMAGE_HEIGHT; ?>px;background-image:url(<?php esc_url ( header_image() ) ?>);"> |
| | 423 | <?php |
| | 424 | if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || ! $this->header_text() ) |
| | 425 | $style = ' style="display:none;"'; |
| | 426 | else |
| | 427 | $style = ' style="color:#' . get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) . ';"'; |
| | 428 | ?> |
| | 429 | <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>"><?php bloginfo( 'name' ); ?></a></h1> |
| | 430 | <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> |
| | 431 | </div> |
| | 432 | <?php } ?> |
| | 433 | </td> |
| | 434 | </tr> |
| 403 | | <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"> </div> |
| 404 | | </div> |
| 405 | | <?php |
| 406 | | else: |
| 407 | | echo '<p>' . __('Choose one of these cool headers, or upload your own image below.') . '</p>'; |
| 408 | | echo '<form method="post" action="' . admin_url('themes.php?page=custom-header&updated=true') . '">'; |
| 409 | | wp_nonce_field('custom-header'); |
| 410 | | $this->show_default_header_selector(); |
| 411 | | echo '<input type="submit" class="button" value="' . esc_attr__('Save Changes') . '" />'; |
| 412 | | echo '</form>'; |
| 413 | | echo '</div>'; |
| 414 | | endif; |
| 415 | | ?> |
| 416 | | <div class="wrap"> |
| 417 | | <h3><?php _e('Upload New Header Image'); ?></h3><p><?php _e('Here you can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.'); ?> <?php printf(__('Images of exactly <strong>%1$d x %2$d pixels</strong> will be used as-is.'), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); ?></p> |
| | 436 | <tr valign="top"> |
| | 437 | <th scope="row"><?php _e( 'Upload Image' ); ?></th> |
| | 438 | <td> |
| | 439 | <p><?php _e( 'Here you can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.' ); ?><br /> |
| | 440 | <?php printf( __( 'Images of exactly <strong>%1$d x %2$d pixels</strong> will be used as-is.' ), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); ?></p> |
| | 441 | <form enctype="multipart/form-data" id="upload-form" method="post" action="<?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?>"> |
| | 442 | <p> |
| | 443 | <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> |
| | 444 | <input type="file" id="upload" name="import" /> |
| | 445 | <input type="hidden" name="action" value="save" /> |
| | 446 | <?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ) ?> |
| | 447 | <input type="submit" class="button" value="<?php esc_attr_e( 'Upload' ); ?>" /> |
| | 448 | </p> |
| | 449 | </form> |
| | 450 | </td> |
| | 451 | </tr> |
| | 452 | </tbody> |
| | 453 | </table> |
| 419 | | <form enctype="multipart/form-data" id="uploadForm" method="post" action="<?php echo esc_attr(add_query_arg('step', 2)) ?>"> |
| 420 | | <label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" /> |
| 421 | | <input type="hidden" name="action" value="save" /> |
| 422 | | <?php wp_nonce_field('custom-header') ?> |
| 423 | | <p class="submit"> |
| 424 | | <input type="submit" value="<?php esc_attr_e('Upload'); ?>" /> |
| 425 | | </p> |
| 426 | | </form> |
| | 455 | <form method="post" action="<?php echo esc_attr( add_query_arg( 'step', 1 ) ) ?>"> |
| | 456 | <table class="form-table"> |
| | 457 | <tbody> |
| | 458 | <?php if ( ! empty( $this->default_headers ) ) : ?> |
| | 459 | <tr valign="top"> |
| | 460 | <th scope="row"><?php _e( 'Default Images' ); ?></th> |
| | 461 | <td> |
| | 462 | <p><?php _e( 'If you didn‘t want to upload your own image, you can use one of these cool headers.' ) ?></p> |
| | 463 | <?php |
| | 464 | $this->show_default_header_selector(); |
| | 465 | ?> |
| | 466 | </td> |
| | 467 | </tr> |
| | 468 | <?php endif; |
| 430 | | <?php if ( get_theme_mod('header_image') || get_theme_mod('header_textcolor') ) : ?> |
| 431 | | <div class="wrap"> |
| 432 | | <h3><?php _e('Reset Header Image and Color'); ?></h3> |
| 433 | | <form method="post" action="<?php echo esc_attr(add_query_arg('step', 1)) ?>"> |
| 434 | | <?php |
| 435 | | wp_nonce_field('custom-header'); |
| 436 | | if ( !empty($this->default_headers) ) { |
| 437 | | ?> |
| 438 | | <p><?php _e('Use one of these cool headers.') ?></p> |
| 439 | | <?php |
| 440 | | $this->show_default_header_selector(); |
| 441 | | ?> |
| 442 | | <input type="submit" class="button" name="resetheader" value="<?php esc_attr_e('Save Changes'); ?>" /> |
| 443 | | <?php |
| 444 | | } else { |
| 445 | | ?> |
| 446 | | <p><?php _e('This will restore the original header image and color. You will not be able to retrieve any customizations.') ?></p> |
| 447 | | <input type="submit" class="button" name="resetheader" value="<?php esc_attr_e('Restore Original Header'); ?>" /> |
| 448 | | <?php } ?> |
| | 480 | if ( defined( 'HEADER_IMAGE' ) ) : ?> |
| | 481 | <tr valign="top"> |
| | 482 | <th scope="row"><?php _e( 'Reset Image' ); ?></th> |
| | 483 | <td> |
| | 484 | <p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ) ?></p> |
| | 485 | <input type="submit" class="button" name="resetheader" value="<?php esc_attr_e( 'Restore Original Header Image' ); ?>" /> |
| | 486 | </td> |
| | 487 | </tr> |
| | 488 | <?php endif; ?> |
| | 489 | </tbody> |
| | 490 | </table> |
| | 491 | |
| | 492 | <?php if ( $this->header_text() ) : ?> |
| | 493 | <h3><?php _e( 'Header Text' ) ?></h3> |
| | 494 | <table class="form-table"> |
| | 495 | <tbody> |
| | 496 | <tr valign="top" class="hide-if-no-js"> |
| | 497 | <th scope="row"><?php _e( 'Display Text' ); ?></th> |
| | 498 | <td> |
| | 499 | <p> |
| | 500 | <?php $hidetext = get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ); ?> |
| | 501 | <label><input type="radio" value="1" name="hidetext" id="hidetext"<?php checked( ( 'blank' == $hidetext || empty( $hidetext ) ) ? true : false ); ?> /> <?php _e( 'No' ); ?></label> |
| | 502 | <label><input type="radio" value="0" name="hidetext" id="showtext"<?php checked( ( 'blank' == $hidetext || empty( $hidetext ) ) ? false : true ); ?> /> <?php _e( 'Yes' ); ?></label> |
| | 503 | </p> |
| | 504 | </td> |
| | 505 | </tr> |
| | 506 | |
| | 507 | <tr valign="top" id="text-color-row"> |
| | 508 | <th scope="row"><?php _e( 'Text Color' ); ?></th> |
| | 509 | <td> |
| | 510 | <p> |
| | 511 | <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr( get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) ); ?>" /> |
| | 512 | <span class="description hide-if-js"><?php _e( 'If you want to hide header text, add <strong>#blank</strong> as text color.' );?></span> |
| | 513 | <input type="button" class="button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color' ); ?>" id="pickcolor" /> |
| | 514 | </p> |
| | 515 | <div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> |
| | 516 | </td> |
| | 517 | </tr> |
| | 518 | |
| | 519 | <?php if ( defined('HEADER_TEXTCOLOR') && get_theme_mod('header_textcolor') ) { ?> |
| | 520 | <tr valign="top"> |
| | 521 | <th scope="row"><?php _e('Reset Text Color'); ?></th> |
| | 522 | <td> |
| | 523 | <p><?php _e( 'This will restore the original header text. You will not be able to restore any customizations.' ) ?></p> |
| | 524 | <input type="submit" class="button" name="resettext" value="<?php esc_attr_e( 'Restore Original Header Text' ); ?>" /> |
| | 525 | </td> |
| | 526 | </tr> |
| | 527 | <?php } ?> |
| | 528 | |
| | 529 | </tbody> |
| | 530 | </table> |
| | 531 | <?php endif; |
| | 532 | |
| | 533 | wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> |
| | 534 | <p class="submit"><input type="submit" class="button-primary" name="save-header-options" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p> |
| 517 | | <p class="submit"> |
| 518 | | <input type="hidden" name="x1" id="x1" /> |
| 519 | | <input type="hidden" name="y1" id="y1" /> |
| 520 | | <input type="hidden" name="x2" id="x2" /> |
| 521 | | <input type="hidden" name="y2" id="y2" /> |
| 522 | | <input type="hidden" name="width" id="width" /> |
| 523 | | <input type="hidden" name="height" id="height" /> |
| 524 | | <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr($id); ?>" /> |
| 525 | | <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr($oitar); ?>" /> |
| 526 | | <?php wp_nonce_field('custom-header') ?> |
| 527 | | <input type="submit" value="<?php esc_attr_e('Crop Header'); ?>" /> |
| 528 | | </p> |
| 529 | | |
| | 605 | <p class="submit"> |
| | 606 | <input type="hidden" name="x1" id="x1" value="0"/> |
| | 607 | <input type="hidden" name="y1" id="y1" value="0"/> |
| | 608 | <input type="hidden" name="width" id="width" value="<?php echo esc_attr( $width ); ?>"/> |
| | 609 | <input type="hidden" name="height" id="height" value="<?php echo esc_attr( $height ); ?>"/> |
| | 610 | <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $id ); ?>" /> |
| | 611 | <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr( $oitar ); ?>" /> |
| | 612 | <?php wp_nonce_field( 'custom-header-crop-image' ) ?> |
| | 613 | <input type="submit" value="<?php esc_attr_e( 'Crop Header' ); ?>" /> |
| | 614 | </p> |