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 | |
332 | | //set up default values |
333 | | jQuery( '#x1' ).val(0); |
334 | | jQuery( '#y1' ).val(0); |
335 | | jQuery( '#x2' ).val(xinit); |
336 | | jQuery( '#y2' ).val(yinit); |
337 | | jQuery( '#width' ).val(xinit); |
338 | | jQuery( '#height' ).val(yinit); |
339 | | |
340 | | if ( yimg < yinit || ximg < xinit ) { |
341 | | if ( ximg / yimg > ratio ) { |
342 | | yinit = yimg; |
343 | | xinit = yinit * ratio; |
344 | | } else { |
345 | | xinit = ximg; |
346 | | yinit = xinit / ratio; |
| 353 | jQuery('#upload').imgAreaSelect({ |
| 354 | handles: true, |
| 355 | keys: true, |
| 356 | aspectRatio: ratio, |
| 357 | maxHeight: <?php echo HEADER_IMAGE_HEIGHT; ?>, |
| 358 | maxWidth: <?php echo HEADER_IMAGE_WIDTH; ?>, |
| 359 | onSelectChange: function(img, c) { |
| 360 | jQuery('#x1').val(c.x1); |
| 361 | jQuery('#y1').val(c.y1); |
| 362 | jQuery('#width').val(c.width); |
| 363 | jQuery('#height').val(c.height); |
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 } ?> |
| 396 | <tr valign="top"> |
| 397 | <th scope="row"><?php _e( 'Preview' ); ?></th> |
| 398 | <td > |
| 399 | <?php if ( $this->admin_image_div_callback ) { |
| 400 | call_user_func( $this->admin_image_div_callback ); |
| 401 | } else { |
| 402 | ?> |
| 403 | <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() ) ?>);"> |
| 404 | <?php |
| 405 | if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || ! $this->header_text() ) |
| 406 | $style = ' style="display:none;"'; |
| 407 | else |
| 408 | $style = ' style="color:#' . get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) . ';"'; |
| 409 | ?> |
| 410 | <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>"><?php bloginfo( 'name' ); ?></a></h1> |
| 411 | <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> |
| 412 | </div> |
| 413 | <?php } ?> |
| 414 | </td> |
| 415 | </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> |
| 417 | <tr valign="top"> |
| 418 | <th scope="row"><?php _e( 'Upload Image' ); ?></th> |
| 419 | <td> |
| 420 | <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 /> |
| 421 | <?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> |
| 422 | <form enctype="multipart/form-data" id="upload-form" method="post" action="<?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?>"> |
| 423 | <p> |
| 424 | <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> |
| 425 | <input type="file" id="upload" name="import" /> |
| 426 | <input type="hidden" name="action" value="save" /> |
| 427 | <?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ) ?> |
| 428 | <input type="submit" class="button" value="<?php esc_attr_e( 'Upload' ); ?>" /> |
| 429 | </p> |
| 430 | </form> |
| 431 | </td> |
| 432 | </tr> |
| 433 | </tbody> |
| 434 | </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> |
| 436 | <form method="post" action="<?php echo esc_attr( add_query_arg( 'step', 1 ) ) ?>"> |
| 437 | <table class="form-table"> |
| 438 | <tbody> |
| 439 | <?php if ( ! empty( $this->default_headers ) ) : ?> |
| 440 | <tr valign="top"> |
| 441 | <th scope="row"><?php _e( 'Default Images' ); ?></th> |
| 442 | <td> |
| 443 | <p><?php _e( 'If you didn‘t want to upload your own image, you can use one of these cool headers.' ) ?></p> |
| 444 | <?php |
| 445 | $this->show_default_header_selector(); |
| 446 | ?> |
| 447 | </td> |
| 448 | </tr> |
| 449 | <?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 } ?> |
| 461 | if ( defined( 'HEADER_IMAGE' ) ) : ?> |
| 462 | <tr valign="top"> |
| 463 | <th scope="row"><?php _e( 'Reset Image' ); ?></th> |
| 464 | <td> |
| 465 | <p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ) ?></p> |
| 466 | <input type="submit" class="button" name="resetheader" value="<?php esc_attr_e( 'Restore Original Header Image' ); ?>" /> |
| 467 | </td> |
| 468 | </tr> |
| 469 | <?php endif; ?> |
| 470 | </tbody> |
| 471 | </table> |
| 472 | |
| 473 | <?php if ( $this->header_text() ) : ?> |
| 474 | <h3><?php _e( 'Header Text' ) ?></h3> |
| 475 | <table class="form-table"> |
| 476 | <tbody> |
| 477 | <tr valign="top" class="hide-if-no-js"> |
| 478 | <th scope="row"><?php _e( 'Display Text' ); ?></th> |
| 479 | <td> |
| 480 | <p> |
| 481 | <?php $hidetext = get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ); ?> |
| 482 | <label><input type="radio" value="1" name="hidetext" id="hidetext"<?php checked( ( 'blank' == $hidetext || empty( $hidetext ) ) ? true : false ); ?> /> <?php _e( 'No' ); ?></label> |
| 483 | <label><input type="radio" value="0" name="hidetext" id="showtext"<?php checked( ( 'blank' == $hidetext || empty( $hidetext ) ) ? false : true ); ?> /> <?php _e( 'Yes' ); ?></label> |
| 484 | </p> |
| 485 | </td> |
| 486 | </tr> |
| 487 | |
| 488 | <tr valign="top" id="text-color-row"> |
| 489 | <th scope="row"><?php _e( 'Text Color' ); ?></th> |
| 490 | <td> |
| 491 | <p> |
| 492 | <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr( get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) ); ?>" /> |
| 493 | <span class="description hide-if-js"><?php _e( 'If you want to hide header text, add <strong>#blank</strong> as text color.' );?></span> |
| 494 | <input type="button" class="button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color' ); ?>" id="pickcolor" /> |
| 495 | </p> |
| 496 | <div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> |
| 497 | </td> |
| 498 | </tr> |
| 499 | |
| 500 | <?php if ( defined('HEADER_TEXTCOLOR') && get_theme_mod('header_textcolor') ) { ?> |
| 501 | <tr valign="top"> |
| 502 | <th scope="row"><?php _e('Reset Text Color'); ?></th> |
| 503 | <td> |
| 504 | <p><?php _e( 'This will restore the original header text. You will not be able to restore any customizations.' ) ?></p> |
| 505 | <input type="submit" class="button" name="resettext" value="<?php esc_attr_e( 'Restore Original Header Text' ); ?>" /> |
| 506 | </td> |
| 507 | </tr> |
| 508 | <?php } ?> |
| 509 | |
| 510 | </tbody> |
| 511 | </table> |
| 512 | <?php endif; |
| 513 | |
| 514 | wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> |
| 515 | <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 | | |
| 586 | <p class="submit"> |
| 587 | <input type="hidden" name="x1" id="x1" value="0"/> |
| 588 | <input type="hidden" name="y1" id="y1" value="0"/> |
| 589 | <input type="hidden" name="width" id="width" value="<?php echo esc_attr( $width ); ?>"/> |
| 590 | <input type="hidden" name="height" id="height" value="<?php echo esc_attr( $height ); ?>"/> |
| 591 | <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $id ); ?>" /> |
| 592 | <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr( $oitar ); ?>" /> |
| 593 | <?php wp_nonce_field( 'custom-header-crop-image' ) ?> |
| 594 | <input type="submit" value="<?php esc_attr_e( 'Crop Header' ); ?>" /> |
| 595 | </p> |