| 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 | | } |
| | 197 | foreach ( $this->default_headers as $header_key => $header ) { |
| | 198 | $header_thumbnail = $header['thumbnail_url']; |
| | 199 | $header_url = $header['url']; |
| | 200 | $header_desc = $header['description']; |
| | 201 | echo '<div class="default-header">'; |
| | 202 | echo '<label><input name="default-header" type="radio" value="' . esc_attr($header_key) . '" ' . checked($header_url, get_theme_mod( 'header_image' ), false) . ' />'; |
| | 203 | echo '<img src="' . $header_thumbnail . '" alt="' . esc_attr($header_desc) .'" title="' . esc_attr($header_desc) .'" /></label>'; |
| | 204 | 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>'; |
| | 206 | |
| | 207 | echo '<div class="clear"></div></div>'; |
| | 249 | if (jQuery('#text-color').val() == 'blank') { |
| | 250 | //Show text |
| | 251 | if (old_color == '#blank') |
| | 252 | old_color = default_color; |
| | 253 | |
| | 254 | jQuery( text_objects.toString() ).show(); |
| | 255 | jQuery('#text-color').val(old_color); |
| | 256 | jQuery('#name').css('color', old_color); |
| | 257 | jQuery('#desc').css('color', old_color); |
| | 258 | pickColor(old_color); |
| | 259 | } else { |
| | 260 | //Hide text |
| | 261 | jQuery( text_objects.toString() ).hide(); |
| | 262 | old_color = jQuery('#text-color').val(); |
| | 263 | jQuery('#text-color').val('blank'); |
| | 264 | } |
| | 265 | } |
| | 266 | |
| | 275 | |
| | 276 | jQuery('#defaultcolor').click(function() { |
| | 277 | pickColor(default_color); |
| | 278 | jQuery('#text-color').val(default_color) |
| | 279 | }); |
| | 280 | |
| | 281 | jQuery('#text-color').keyup(function() { |
| | 282 | var _hex = jQuery('#text-color').val(); |
| | 283 | var hex = _hex; |
| | 284 | if ( hex[0] != '#' ) |
| | 285 | hex = '#' + hex; |
| | 286 | hex = hex.replace(/[^#a-fA-F0-9]+/, ''); |
| | 287 | if ( hex != _hex ) |
| | 288 | jQuery('#text-color').val(hex); |
| | 289 | if ( hex.length == 4 || hex.length == 7 ) |
| | 290 | pickColor( hex ); |
| | 291 | }); |
| | 292 | |
| | 293 | jQuery(document).mousedown(function(){ |
| | 294 | jQuery('#colorPickerDiv').each( function() { |
| | 295 | var display = jQuery(this).css('display'); |
| | 296 | if (display == 'block') |
| | 297 | jQuery(this).fadeOut(2); |
| | 298 | }); |
| | 299 | }); |
| 262 | | }); |
| 263 | | |
| 264 | | jQuery(document).mousedown(function(){ |
| 265 | | // Make the picker disappear, since we're using it in an independant div |
| 266 | | hide_picker(); |
| 267 | | }); |
| 268 | | |
| 269 | | function colorDefault() { |
| 270 | | pickColor('#<?php echo HEADER_TEXTCOLOR; ?>'); |
| 271 | | } |
| 272 | | |
| 273 | | function hide_picker(what) { |
| 274 | | var update = false; |
| 275 | | jQuery('#colorPickerDiv').each(function(){ |
| 276 | | var id = jQuery(this).attr('id'); |
| 277 | | if (id == what) { |
| 278 | | return; |
| 279 | | } |
| 280 | | var display = jQuery(this).css('display'); |
| 281 | | if (display == 'block') { |
| 282 | | jQuery(this).fadeOut(2); |
| 283 | | } |
| 352 | | setSelect: [ 0, 0, xinit, yinit ], |
| 353 | | onSelect: onEndCrop |
| | 337 | maxHeight: <?php echo HEADER_IMAGE_HEIGHT; ?>, |
| | 338 | maxWidth: <?php echo HEADER_IMAGE_WIDTH; ?>, |
| | 339 | onSelectChange: function(img, c) { |
| | 340 | jQuery('#x1').val(c.x1); |
| | 341 | jQuery('#y1').val(c.y1); |
| | 342 | jQuery('#width').val(c.width); |
| | 343 | jQuery('#height').val(c.height); |
| | 344 | }, |
| 385 | | if ( $this->admin_image_div_callback ) { |
| 386 | | call_user_func($this->admin_image_div_callback); |
| 387 | | } else { |
| 388 | | ?> |
| 389 | | <div id="headimg" style="background-image: url(<?php esc_url(header_image()) ?>);"> |
| 390 | | <h1><a onclick="return false;" href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>" id="name"><?php bloginfo('name'); ?></a></h1> |
| 391 | | <div id="desc"><?php bloginfo('description');?></div> |
| 392 | | </div> |
| 393 | | <?php } ?> |
| | 374 | <?php if ( get_header_image() ) { ?> |
| | 375 | <tr valign="top"> |
| | 376 | <th scope="row"><?php _e( 'Current Image' ); ?></th> |
| | 377 | <td > |
| | 378 | <?php if ( $this->admin_image_div_callback ) { |
| | 379 | call_user_func( $this->admin_image_div_callback ); |
| | 380 | } else { |
| | 381 | ?> |
| | 382 | <div id="headimg" style="color:#<?php echo get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ); ?>;max-width:<?php echo HEADER_IMAGE_WIDTH; ?>px;;height:<?php echo HEADER_IMAGE_HEIGHT; ?>px"> |
| | 383 | <img id="image" src="<?php esc_url ( header_image() ) ?>" /> |
| | 384 | <?php |
| | 385 | $style = ''; |
| | 386 | if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || defined( 'NO_HEADER_TEXT' ) ) |
| | 387 | $style = " style='display:none'"; |
| | 388 | ?> |
| | 389 | <h1 id="name"<?php echo $style; ?>><?php bloginfo( 'name' ); ?></h1> |
| | 390 | <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> |
| | 391 | </div> |
| | 392 | <?php } ?> |
| | 393 | </td> |
| | 394 | </tr> |
| | 395 | <?php } ?> |
| 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 } ?> |
| | 397 | <tr valign="top"> |
| | 398 | <th scope="row"><?php _e( 'Upload Image' ); ?></th> |
| | 399 | <td> |
| | 400 | <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 /> |
| | 401 | <?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> |
| | 402 | <form enctype="multipart/form-data" id="uploadForm" method="post" action="<?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?>"> |
| | 403 | <label><input type="checkbox" value="1" name="transparency"/> <?php _e( 'Retain transparency (If you want to upload a transparent image, you should enable this option.)' ); ?></label> |
| | 404 | <p> |
| | 405 | <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> |
| | 406 | <input type="file" id="upload" name="import" /> |
| | 407 | <input type="hidden" name="action" value="save" /> |
| | 408 | <?php wp_nonce_field( 'custom-header' ) ?> |
| | 409 | <input type="submit" class="button" value="<?php esc_attr_e( 'Upload' ); ?>" /> |
| | 410 | </p> |
| | 411 | </form> |
| | 412 | </td> |
| | 413 | </tr> |
| | 414 | <form method="post" action="<?php echo esc_attr( add_query_arg( 'step', 1 ) ) ?>"> |
| | 415 | <?php if ( ! empty( $this->default_headers ) ) { ?> |
| | 416 | <tr valign="top"> |
| | 417 | <th scope="row"><?php _e( 'Default Images' ); ?></th> |
| | 418 | <td> |
| | 419 | <p><?php _e( 'If you didn‘t want to upload your own image, you can use one of these cool headers.' ) ?></p> |
| | 420 | <?php |
| | 421 | $this->show_default_header_selector(); |
| | 422 | ?> |
| | 423 | </td> |
| | 424 | </tr> |
| | 425 | <?php } |
| 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> |
| | 427 | if ( get_theme_mod( 'header_image' ) && defined( 'HEADER_IMAGE' ) ) { ?> |
| | 428 | <tr valign="top"> |
| | 429 | <th scope="row"><?php _e( 'Reset Header Image' ); ?></th> |
| | 430 | <td> |
| | 431 | <p><?php _e( 'This will restore the original header image. You will not be able to retrieve any customizations.' ) ?></p> |
| | 432 | <input type="submit" class="button" name="resetheader" value="<?php esc_attr_e( 'Restore Original Header Image' ); ?>" /> |
| | 433 | </td> |
| | 434 | </tr> |
| | 435 | <?php } ?> |
| | 436 | </tbody> |
| | 437 | </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> |
| | 439 | <?php if ( !defined( 'NO_HEADER_TEXT' ) ) { ?> |
| | 440 | <h3><?php _e( 'Header Text' ) ?></h3> |
| | 441 | <table class="form-table"> |
| | 442 | <tbody> |
| | 443 | <tr valign="top" class="hide-if-no-js"> |
| | 444 | <th scope="row"><?php _e( 'Display Text' ); ?></th> |
| | 445 | <td> |
| | 446 | <p> |
| | 447 | <?php $hidetext = get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ); ?> |
| | 448 | <label><input type="radio" value="1" name="hidetext" id="hidetext"<?php checked( 'blank' == $hidetext ? true : false ); ?> /> <?php _e( 'No' ); ?></label> |
| | 449 | <label><input type="radio" value="0" name="hidetext" id="showtext"<?php checked( 'blank' == $hidetext ? false : true ); ?> /> <?php _e( 'Yes' ); ?></label> |
| | 450 | </p> |
| | 451 | </td> |
| | 452 | </tr> |
| 428 | | </div> |
| | 454 | <tr valign="top" id="text-color-row"> |
| | 455 | <th scope="row"><?php _e( 'Text Color' ); ?></th> |
| | 456 | <td> |
| | 457 | <p> |
| | 458 | <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr( get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) ); ?>" /> |
| | 459 | <span class="description hide-if-js"><?php _e( 'If you want to hide header text, add <strong>#blank</strong> as text color.' );?></span> |
| | 460 | <input type="button" class="button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color' ); ?>" id="pickcolor" /> |
| | 461 | <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> |
| | 462 | </p> |
| | 463 | </td> |
| | 464 | </tr> |
| 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 } ?> |
| | 466 | <?php if ( defined( 'HEADER_TEXTCOLOR' ) && get_theme_mod( 'header_textcolor' ) ) { ?> |
| | 467 | <tr valign="top"> |
| | 468 | <th scope="row"><?php _e( 'Reset Header Text' ); ?></th> |
| | 469 | <td> |
| | 470 | <p><?php _e( 'This will restore the original header text. You will not be able to retrieve any customizations.' ) ?></p> |
| | 471 | <input type="submit" class="button" name="resettext" value="<?php esc_attr_e( 'Restore Original Header Text' ); ?>" /> |
| | 472 | </td> |
| | 473 | </tr> |
| | 474 | <?php } ?> |
| | 475 | |
| | 476 | </tbody> |
| | 477 | </table> |
| | 478 | <?php } |
| | 479 | |
| | 480 | wp_nonce_field( 'custom-header' ); ?> |
| | 481 | <p class="submit"><input type="submit" class="button-primary" name="save-header-options" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p> |
| 494 | | $image = wp_crop_image($file, 0, 0, $width, $height, HEADER_IMAGE_WIDTH, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); |
| | 528 | $transparency = ( isset( $_POST['transparency'] ) && 1 == $_POST['transparency'] ) ? true : false; |
| | 529 | $image = wp_crop_image( $file, 0, 0, $width, $height, HEADER_IMAGE_WIDTH, $height / $oitar, false, str_replace( basename( $file ), 'midsize-'.basename( $file ), $file ), $transparency ); |
| 510 | | <form method="POST" action="<?php echo esc_attr(add_query_arg('step', 3)) ?>"> |
| | 552 | <form method="post" action="<?php echo esc_attr( add_query_arg( 'step', 3 ) ); ?>"> |
| | 553 | <p class="hide-if-no-js"><?php _e( 'Choose the part of the image you want to use as your header.' ); ?></p> |
| | 554 | <p class="hide-if-js"><strong><?php _e( 'You need Javascript to choose a part of the image.' ); ?></strong></p> |
| | 555 | <p><?php printf( __( 'Images smaller then <strong>%1$d x %2$d pixels</strong> will be zoomed.' ), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); ?></p> |
| | 556 | <div id="crop_image" style="position: relative"> |
| | 557 | <img src="<?php echo esc_url( $url ); ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" /> |
| | 558 | </div> |
| 512 | | <p><?php _e('Choose the part of the image you want to use as your header.'); ?></p> |
| 513 | | <div id="testWrap" style="position: relative"> |
| 514 | | <img src="<?php echo $url; ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" /> |
| 515 | | </div> |
| 516 | | |
| 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 | | |
| | 560 | <input type="hidden" name="x1" id="x1" value="0"/> |
| | 561 | <input type="hidden" name="y1" id="y1" value="0"/> |
| | 562 | <input type="hidden" name="width" id="width" value="<?php echo esc_attr( $width ); ?>"/> |
| | 563 | <input type="hidden" name="height" id="height" value="<?php echo esc_attr( $height ); ?>"/> |
| | 564 | <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $id ); ?>" /> |
| | 565 | <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr( $oitar ); ?>" /> |
| | 566 | <input type="hidden" name="transparency" id="transparency" value="<?php echo esc_attr( $transparency ); ?>"/> |
| | 567 | <?php wp_nonce_field( 'custom-header' ) ?> |
| | 568 | <p class="submit"><input type="submit" value="<?php esc_attr_e( 'Crop Header' ); ?>" /></p> |
| 551 | | $cropped = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); |
| | 593 | // Crop the image |
| | 594 | $cropped = wp_crop_image( $_POST['attachment_id'], $x1, $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, false, false, $transparency ); |