Changeset 43571 for trunk/src/wp-admin/custom-header.php
- Timestamp:
- 08/17/2018 01:50:26 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/custom-header.php
r42719 r43571 381 381 })(jQuery); 382 382 </script> 383 <?php383 <?php 384 384 } 385 385 … … 391 391 public function js_2() { 392 392 393 ?>393 ?> 394 394 <script type="text/javascript"> 395 395 function onEndCrop( coords ) { … … 427 427 <?php 428 428 if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) { 429 ?>429 ?> 430 430 aspectRatio: xinit + ':' + yinit, 431 <?php431 <?php 432 432 } 433 433 if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) { 434 ?>434 ?> 435 435 maxHeight: <?php echo get_theme_support( 'custom-header', 'height' ); ?>, 436 <?php436 <?php 437 437 } 438 438 if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) { 439 ?>439 ?> 440 440 maxWidth: <?php echo get_theme_support( 'custom-header', 'width' ); ?>, 441 <?php441 <?php 442 442 } 443 443 ?> … … 455 455 }); 456 456 </script> 457 <?php457 <?php 458 458 } 459 459 … … 465 465 public function step_1() { 466 466 $this->process_default_headers(); 467 ?>467 ?> 468 468 469 469 <div class="wrap"> 470 470 <h1><?php _e( 'Custom Header' ); ?></h1> 471 471 472 <?php if ( current_user_can( 'customize' ) ) { ?>472 <?php if ( current_user_can( 'customize' ) ) { ?> 473 473 <div class="notice notice-info hide-if-no-customize"> 474 474 <p> 475 <?php476 printf(477 __( 'You can now manage and live-preview Custom Header in the <a href="%1$s">Customizer</a>.' ),478 admin_url( 'customize.php?autofocus[control]=header_image' )479 );480 ?>475 <?php 476 printf( 477 __( 'You can now manage and live-preview Custom Header in the <a href="%1$s">Customizer</a>.' ), 478 admin_url( 'customize.php?autofocus[control]=header_image' ) 479 ); 480 ?> 481 481 </p> 482 482 </div> 483 <?php } ?>484 485 <?php if ( ! empty( $this->updated ) ) { ?>483 <?php } ?> 484 485 <?php if ( ! empty( $this->updated ) ) { ?> 486 486 <div id="message" class="updated"> 487 487 <p><?php printf( __( 'Header updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); ?></p> 488 488 </div> 489 <?php } ?>489 <?php } ?> 490 490 491 491 <h3><?php _e( 'Header Image' ); ?></h3> … … 494 494 <tbody> 495 495 496 <?php if ( get_custom_header() || display_header_text() ) : ?>496 <?php if ( get_custom_header() || display_header_text() ) : ?> 497 497 <tr> 498 498 <th scope="row"><?php _e( 'Preview' ); ?></th> 499 499 <td> 500 <?php501 if ( $this->admin_image_div_callback ) {502 call_user_func( $this->admin_image_div_callback );503 } else {504 $custom_header = get_custom_header();505 $header_image = get_header_image();506 507 if ( $header_image ) {508 $header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');';509 } else {510 $header_image_style = '';511 }512 513 if ( $custom_header->width ) {514 $header_image_style .= 'max-width:' . $custom_header->width . 'px;';515 }516 if ( $custom_header->height ) {517 $header_image_style .= 'height:' . $custom_header->height . 'px;';518 }519 ?>500 <?php 501 if ( $this->admin_image_div_callback ) { 502 call_user_func( $this->admin_image_div_callback ); 503 } else { 504 $custom_header = get_custom_header(); 505 $header_image = get_header_image(); 506 507 if ( $header_image ) { 508 $header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');'; 509 } else { 510 $header_image_style = ''; 511 } 512 513 if ( $custom_header->width ) { 514 $header_image_style .= 'max-width:' . $custom_header->width . 'px;'; 515 } 516 if ( $custom_header->height ) { 517 $header_image_style .= 'height:' . $custom_header->height . 'px;'; 518 } 519 ?> 520 520 <div id="headimg" style="<?php echo $header_image_style; ?>"> 521 <?php522 if ( display_header_text() ) {523 $style = ' style="color:#' . get_header_textcolor() . ';"';524 } else {525 $style = ' style="display:none;"';526 }527 ?>521 <?php 522 if ( display_header_text() ) { 523 $style = ' style="color:#' . get_header_textcolor() . ';"'; 524 } else { 525 $style = ' style="display:none;"'; 526 } 527 ?> 528 528 <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo( 'url' ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> 529 529 <div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> 530 530 </div> 531 <?php } ?>531 <?php } ?> 532 532 </td> 533 533 </tr> 534 <?php endif; ?>535 536 <?php if ( current_user_can( 'upload_files' ) && current_theme_supports( 'custom-header', 'uploads' ) ) : ?>534 <?php endif; ?> 535 536 <?php if ( current_user_can( 'upload_files' ) && current_theme_supports( 'custom-header', 'uploads' ) ) : ?> 537 537 <tr> 538 538 <th scope="row"><?php _e( 'Select Image' ); ?></th> 539 539 <td> 540 540 <p><?php _e( 'You can select an image to be shown at the top of your site by uploading from your computer or choosing from your media library. After selecting an image you will be able to crop it.' ); ?><br /> 541 <?php542 if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) {543 printf( __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ) . '<br />', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ) );544 } elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) {545 if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) {546 printf(547 /* translators: %s: size in pixels */548 __( 'Images should be at least %s wide.' ) . ' ',549 sprintf(550 /* translators: %d: custom header width */551 '<strong>' . __( '%d pixels' ) . '</strong>',552 get_theme_support( 'custom-header', 'width' )553 )554 );555 }556 } elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) {557 if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) {558 printf(559 /* translators: %s: size in pixels */560 __( 'Images should be at least %s tall.' ) . ' ',561 sprintf(562 /* translators: %d: custom header height */563 '<strong>' . __( '%d pixels' ) . '</strong>',564 get_theme_support( 'custom-header', 'height' )565 )566 );567 }568 }569 if ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) {570 if ( current_theme_supports( 'custom-header', 'width' ) ) {571 printf(572 /* translators: %s: size in pixels */573 __( 'Suggested width is %s.' ) . ' ',574 sprintf(575 /* translators: %d: custom header width */576 '<strong>' . __( '%d pixels' ) . '</strong>',577 get_theme_support( 'custom-header', 'width' )578 )579 );580 }581 if ( current_theme_supports( 'custom-header', 'height' ) ) {582 printf(583 /* translators: %s: size in pixels */584 __( 'Suggested height is %s.' ) . ' ',585 sprintf(586 /* translators: %d: custom header height */587 '<strong>' . __( '%d pixels' ) . '</strong>',588 get_theme_support( 'custom-header', 'height' )589 )590 );591 }592 }593 ?>541 <?php 542 if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) { 543 printf( __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ) . '<br />', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ) ); 544 } elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) { 545 if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) { 546 printf( 547 /* translators: %s: size in pixels */ 548 __( 'Images should be at least %s wide.' ) . ' ', 549 sprintf( 550 /* translators: %d: custom header width */ 551 '<strong>' . __( '%d pixels' ) . '</strong>', 552 get_theme_support( 'custom-header', 'width' ) 553 ) 554 ); 555 } 556 } elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) { 557 if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) { 558 printf( 559 /* translators: %s: size in pixels */ 560 __( 'Images should be at least %s tall.' ) . ' ', 561 sprintf( 562 /* translators: %d: custom header height */ 563 '<strong>' . __( '%d pixels' ) . '</strong>', 564 get_theme_support( 'custom-header', 'height' ) 565 ) 566 ); 567 } 568 } 569 if ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) { 570 if ( current_theme_supports( 'custom-header', 'width' ) ) { 571 printf( 572 /* translators: %s: size in pixels */ 573 __( 'Suggested width is %s.' ) . ' ', 574 sprintf( 575 /* translators: %d: custom header width */ 576 '<strong>' . __( '%d pixels' ) . '</strong>', 577 get_theme_support( 'custom-header', 'width' ) 578 ) 579 ); 580 } 581 if ( current_theme_supports( 'custom-header', 'height' ) ) { 582 printf( 583 /* translators: %s: size in pixels */ 584 __( 'Suggested height is %s.' ) . ' ', 585 sprintf( 586 /* translators: %d: custom header height */ 587 '<strong>' . __( '%d pixels' ) . '</strong>', 588 get_theme_support( 'custom-header', 'height' ) 589 ) 590 ); 591 } 592 } 593 ?> 594 594 </p> 595 595 <form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url( add_query_arg( 'step', 2 ) ); ?>"> … … 598 598 <input type="file" id="upload" name="import" /> 599 599 <input type="hidden" name="action" value="save" /> 600 <?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ); ?>601 <?php submit_button( __( 'Upload' ), '', 'submit', false ); ?>600 <?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ); ?> 601 <?php submit_button( __( 'Upload' ), '', 'submit', false ); ?> 602 602 </p> 603 <?php 604 $modal_update_href = esc_url( 605 add_query_arg( 606 array( 607 'page' => 'custom-header', 608 'step' => 2, 609 '_wpnonce-custom-header-upload' => wp_create_nonce( 'custom-header-upload' ), 610 ), admin_url( 'themes.php' ) 611 ) 612 ); 613 ?> 603 <?php 604 $modal_update_href = esc_url( 605 add_query_arg( 606 array( 607 'page' => 'custom-header', 608 'step' => 2, 609 '_wpnonce-custom-header-upload' => wp_create_nonce( 'custom-header-upload' ), 610 ), 611 admin_url( 'themes.php' ) 612 ) 613 ); 614 ?> 614 615 <p> 615 616 <label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br /> … … 622 623 </td> 623 624 </tr> 624 <?php endif; ?>625 <?php endif; ?> 625 626 </tbody> 626 627 </table> 627 628 628 629 <form method="post" action="<?php echo esc_url( add_query_arg( 'step', 1 ) ); ?>"> 629 <?php submit_button( null, 'screen-reader-text', 'save-header-options', false ); ?>630 <?php submit_button( null, 'screen-reader-text', 'save-header-options', false ); ?> 630 631 <table class="form-table"> 631 632 <tbody> 632 <?php if ( get_uploaded_header_images() ) : ?>633 <?php if ( get_uploaded_header_images() ) : ?> 633 634 <tr> 634 635 <th scope="row"><?php _e( 'Uploaded Images' ); ?></th> 635 636 <td> 636 637 <p><?php _e( 'You can choose one of your previously uploaded headers, or show a random one.' ); ?></p> 637 <?php638 $this->show_header_selector( 'uploaded' );639 ?>638 <?php 639 $this->show_header_selector( 'uploaded' ); 640 ?> 640 641 </td> 641 642 </tr> 642 <?php643 <?php 643 644 endif; 644 645 if ( ! empty( $this->default_headers ) ) : … … 647 648 <th scope="row"><?php _e( 'Default Images' ); ?></th> 648 649 <td> 649 <?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?>650 <?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?> 650 651 <p><?php _e( 'If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.' ); ?></p> 651 <?php else : ?>652 <?php else : ?> 652 653 <p><?php _e( 'You can use one of these cool headers or show a random one on each page.' ); ?></p> 653 <?php endif; ?>654 <?php endif; ?> 654 655 <?php 655 656 $this->show_header_selector( 'default' ); … … 685 686 </table> 686 687 687 <?php if ( current_theme_supports( 'custom-header', 'header-text' ) ) : ?>688 <?php if ( current_theme_supports( 'custom-header', 'header-text' ) ) : ?> 688 689 689 690 <h3><?php _e( 'Header Text' ); ?></h3> … … 704 705 <td> 705 706 <p> 706 <?php707 $default_color = '';708 if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) {709 $default_color = get_theme_support( 'custom-header', 'default-text-color' );710 if ( $default_color && false === strpos( $default_color, '#' ) ) {711 $default_color = '#' . $default_color;712 }713 }714 715 $default_color_attr = $default_color ? ' data-default-color="' . esc_attr( $default_color ) . '"' : '';716 717 $header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support( 'custom-header', 'default-text-color' );718 if ( $header_textcolor && false === strpos( $header_textcolor, '#' ) ) {719 $header_textcolor = '#' . $header_textcolor;720 }721 722 echo '<input type="text" name="text-color" id="text-color" value="' . esc_attr( $header_textcolor ) . '"' . $default_color_attr . ' />';723 if ( $default_color ) {724 echo ' <span class="description hide-if-js">' . sprintf( _x( 'Default: %s', 'color' ), esc_html( $default_color ) ) . '</span>';725 }726 ?>707 <?php 708 $default_color = ''; 709 if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { 710 $default_color = get_theme_support( 'custom-header', 'default-text-color' ); 711 if ( $default_color && false === strpos( $default_color, '#' ) ) { 712 $default_color = '#' . $default_color; 713 } 714 } 715 716 $default_color_attr = $default_color ? ' data-default-color="' . esc_attr( $default_color ) . '"' : ''; 717 718 $header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support( 'custom-header', 'default-text-color' ); 719 if ( $header_textcolor && false === strpos( $header_textcolor, '#' ) ) { 720 $header_textcolor = '#' . $header_textcolor; 721 } 722 723 echo '<input type="text" name="text-color" id="text-color" value="' . esc_attr( $header_textcolor ) . '"' . $default_color_attr . ' />'; 724 if ( $default_color ) { 725 echo ' <span class="description hide-if-js">' . sprintf( _x( 'Default: %s', 'color' ), esc_html( $default_color ) ) . '</span>'; 726 } 727 ?> 727 728 </p> 728 729 </td> … … 730 731 </tbody> 731 732 </table> 732 <?php733 <?php 733 734 endif; 734 735 735 /**736 * Fires just before the submit button in the custom header options form.737 *738 * @since 3.1.0739 */740 do_action( 'custom_header_options' );741 742 wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' );736 /** 737 * Fires just before the submit button in the custom header options form. 738 * 739 * @since 3.1.0 740 */ 741 do_action( 'custom_header_options' ); 742 743 wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); 743 744 ?> 744 745 745 <?php submit_button( null, 'primary', 'save-header-options' ); ?>746 <?php submit_button( null, 'primary', 'save-header-options' ); ?> 746 747 </form> 747 748 </div> 748 749 749 <?php750 <?php 750 751 } 751 752 … … 853 854 <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $attachment_id ); ?>" /> 854 855 <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr( $oitar ); ?>" /> 855 <?php if ( empty( $_POST ) && isset( $_GET['file'] ) ) { ?>856 <?php if ( empty( $_POST ) && isset( $_GET['file'] ) ) { ?> 856 857 <input type="hidden" name="create-new-attachment" value="true" /> 857 858 <?php } ?> 858 <?php wp_nonce_field( 'custom-header-crop-image' ); ?>859 <?php wp_nonce_field( 'custom-header-crop-image' ); ?> 859 860 860 861 <p class="submit"> 861 <?php submit_button( __( 'Crop and Publish' ), 'primary', 'submit', false ); ?>862 <?php863 if ( isset( $oitar ) && 1 == $oitar && ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) {864 submit_button( __( 'Skip Cropping, Publish Image as Is' ), '', 'skip-cropping', false );865 }866 ?>862 <?php submit_button( __( 'Crop and Publish' ), 'primary', 'submit', false ); ?> 863 <?php 864 if ( isset( $oitar ) && 1 == $oitar && ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) { 865 submit_button( __( 'Skip Cropping, Publish Image as Is' ), '', 'skip-cropping', false ); 866 } 867 ?> 867 868 </p> 868 869 </form>
Note: See TracChangeset
for help on using the changeset viewer.