| 583 | | public $type = 'upload'; |
| 584 | | public $removed = ''; |
| 585 | | public $context; |
| 586 | | public $extensions = array(); |
| | 583 | public $type = 'upload'; |
| | 584 | public $mime_type = ''; |
| | 585 | public $button_labels = array( |
| | 586 | 'select' => 'Select File', // @todo PHP doesn't like letting us translate these |
| | 587 | 'change' => 'Change File', |
| | 588 | 'remove' => 'Remove', |
| | 589 | 'frame_title' => 'Select File', |
| | 590 | 'frame_button' => 'Choose File', |
| | 591 | ); |
| | 592 | public $removed = ''; // unused |
| | 593 | public $context; // unused |
| | 594 | public $extensions = array(); // unused |
| 623 | | <?php if ( ! empty( $this->label ) ) : ?> |
| 624 | | <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
| 625 | | <?php endif; |
| 626 | | if ( ! empty( $this->description ) ) : ?> |
| 627 | | <span class="description customize-control-description"><?php echo $this->description; ?></span> |
| 628 | | <?php endif; ?> |
| 629 | | <div> |
| 630 | | <a href="#" class="button-secondary upload"><?php _e( 'Upload' ); ?></a> |
| 631 | | <a href="#" class="remove"><?php _e( 'Remove' ); ?></a> |
| 632 | | </div> |
| | 641 | <# if ( data.label ) { #> |
| | 642 | <span class="customize-control-title">{{ data.label }}</span> |
| | 643 | <# } #> |
| | 644 | <# if ( data.description ) { #> |
| | 645 | <span class="description customize-control-description">{{ data.description }}</span> |
| | 646 | <# } #> |
| | 647 | |
| | 648 | <# if ( data.attachment && data.attachment.id ) { #> |
| | 649 | <div class="attachment-media-view {{ data.attachment.orientation }}"> |
| | 650 | <div class="thumbnail thumbnail-{{ data.attachment.type }}"> |
| | 651 | <# if ( 'image' === data.attachment.type && data.attachment.sizes && data.attachment.sizes.medium ) { #> |
| | 652 | <img class="attachment-thumb" src="{{ data.attachment.sizes.medium.url }}" draggable="false" /> |
| | 653 | <# } else if ( 'image' === data.attachment.type && data.attachment.sizes && data.attachment.sizes.full ) { #> |
| | 654 | <img class="attachment-thumb" src="{{ data.attachment.sizes.full.url }}" draggable="false" /> |
| | 655 | <# } else if ( -1 === jQuery.inArray( data.attachment.type, [ 'audio', 'video' ] ) ) { #> |
| | 656 | <img class="attachment-thumb type-icon" src="{{ data.attachment.icon }}" class="icon" draggable="false" /> |
| | 657 | <p class="attachment-title">{{ data.attachment.title }}</p> |
| | 658 | <# } #> |
| | 659 | |
| | 660 | <# if ( 'audio' === data.attachment.type ) { #> |
| | 661 | <div class="wp-media-wrapper"> |
| | 662 | <audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none"> |
| | 663 | <source type="{{ data.attachment.mime }}" src="{{ data.attachment.url }}"/> |
| | 664 | </audio> |
| | 665 | </div> |
| | 666 | <# } else if ( 'video' === data.attachment.type ) { |
| | 667 | var w_rule = h_rule = ''; |
| | 668 | if ( data.attachment.width ) { |
| | 669 | w_rule = 'width: ' + data.attachment.width + 'px;'; |
| | 670 | } else if ( wp.media.view.settings.contentWidth ) { |
| | 671 | w_rule = 'width: ' + wp.media.view.settings.contentWidth + 'px;'; |
| | 672 | } |
| | 673 | if ( data.attachment.height ) { |
| | 674 | h_rule = 'height: ' + data.attachment.height + 'px;'; |
| | 675 | } |
| | 676 | #> |
| | 677 | <div style="{{ w_rule }}{{ h_rule }}" class="wp-media-wrapper wp-video"> |
| | 678 | <video controls="controls" class="wp-video-shortcode" preload="metadata" |
| | 679 | <# if ( data.attachment.width ) { #>width="{{ data.attachment.width }}"<# } #> |
| | 680 | <# if ( data.attachment.height ) { #>height="{{ data.attachment.height }}"<# } #> |
| | 681 | <# if ( data.attachment.image && data.attachment.image.src !== data.attachment.icon ) { #>poster="{{ data.attachment.image.src }}"<# } #>> |
| | 682 | <source type="{{ data.attachment.mime }}" src="{{ data.attachment.url }}"/> |
| | 683 | </video> |
| | 684 | </div> |
| | 685 | <# } #> |
| | 686 | </div> |
| | 687 | </div> |
| | 688 | <a class="button upload-button" href="#"><?php echo $this->button_labels['change']; ?></a> |
| | 689 | <a class="remove-button" href="#"><?php echo $this->button_labels['remove']; ?></a> |
| | 690 | <# } else { #> |
| | 691 | <a class="button upload-button" href="#"><?php echo $this->button_labels['select']; ?></a> |
| | 692 | <# } #> |
| 647 | | public $get_url; |
| 648 | | public $statuses; |
| 649 | | public $extensions = array( 'jpg', 'jpeg', 'gif', 'png' ); |
| | 707 | public $mime_type = 'image'; |
| | 708 | public $button_labels = array( |
| | 709 | 'select' => 'Select Image', // @todo PHP doesn't like letting us translate these |
| | 710 | 'change' => 'Change Image', |
| | 711 | 'remove' => 'Remove', |
| | 712 | 'frame_title' => 'Select Image', |
| | 713 | 'frame_button' => 'Choose Image', |
| | 714 | ); |
| 654 | | * Constructor. |
| 655 | | * |
| 656 | | * @since 3.4.0 |
| 657 | | * @uses WP_Customize_Upload_Control::__construct() |
| 658 | | * |
| 659 | | * @param WP_Customize_Manager $manager |
| 660 | | * @param string $id |
| 661 | | * @param array $args |
| 662 | | */ |
| 663 | | public function __construct( $manager, $id, $args ) { |
| 664 | | $this->statuses = array( '' => __('No Image') ); |
| 665 | | |
| 666 | | parent::__construct( $manager, $id, $args ); |
| 667 | | |
| 668 | | $this->add_tab( 'upload-new', __('Upload New'), array( $this, 'tab_upload_new' ) ); |
| 669 | | $this->add_tab( 'uploaded', __('Uploaded'), array( $this, 'tab_uploaded' ) ); |
| 670 | | |
| 671 | | // Early priority to occur before $this->manager->prepare_controls(); |
| 672 | | add_action( 'customize_controls_init', array( $this, 'prepare_control' ), 5 ); |
| 673 | | } |
| 674 | | |
| 675 | | /** |
| 676 | | * Prepares the control. |
| 677 | | * |
| 678 | | * If no tabs exist, removes the control from the manager. |
| 679 | | * |
| 680 | | * @since 3.4.2 |
| 681 | | */ |
| 682 | | public function prepare_control() { |
| 683 | | if ( ! $this->tabs ) |
| 684 | | $this->manager->remove_control( $this->id ); |
| 685 | | } |
| 686 | | |
| 687 | | /** |
| 688 | | * Refresh the parameters passed to the JavaScript via JSON. |
| 689 | | * |
| 690 | | * @since 3.4.0 |
| 691 | | * @uses WP_Customize_Upload_Control::to_json() |
| 692 | | */ |
| 693 | | public function to_json() { |
| 694 | | parent::to_json(); |
| 695 | | $this->json['statuses'] = $this->statuses; |
| 696 | | } |
| 697 | | |
| 698 | | /** |
| 699 | | * Render the control's content. |
| 700 | | * |
| 701 | | * @since 3.4.0 |
| 702 | | */ |
| 703 | | public function render_content() { |
| 704 | | $src = $this->value(); |
| 705 | | if ( isset( $this->get_url ) ) |
| 706 | | $src = call_user_func( $this->get_url, $src ); |
| 707 | | |
| 708 | | ?> |
| 709 | | <div class="customize-image-picker"> |
| 710 | | <?php if ( ! empty( $this->label ) ) : ?> |
| 711 | | <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
| 712 | | <?php endif; |
| 713 | | if ( ! empty( $this->description ) ) : ?> |
| 714 | | <span class="description customize-control-description"><?php echo $this->description; ?></span> |
| 715 | | <?php endif; ?> |
| 716 | | |
| 717 | | <div class="customize-control-content"> |
| 718 | | <div class="dropdown preview-thumbnail" tabindex="0"> |
| 719 | | <div class="dropdown-content"> |
| 720 | | <?php if ( empty( $src ) ): ?> |
| 721 | | <img style="display:none;" /> |
| 722 | | <?php else: ?> |
| 723 | | <img src="<?php echo esc_url( set_url_scheme( $src ) ); ?>" /> |
| 724 | | <?php endif; ?> |
| 725 | | <div class="dropdown-status"></div> |
| 726 | | </div> |
| 727 | | <div class="dropdown-arrow"></div> |
| 728 | | </div> |
| 729 | | </div> |
| 730 | | |
| 731 | | <div class="library"> |
| 732 | | <ul> |
| 733 | | <?php foreach ( $this->tabs as $id => $tab ): ?> |
| 734 | | <li data-customize-tab='<?php echo esc_attr( $id ); ?>' tabindex='0'> |
| 735 | | <?php echo esc_html( $tab['label'] ); ?> |
| 736 | | </li> |
| 737 | | <?php endforeach; ?> |
| 738 | | </ul> |
| 739 | | <?php foreach ( $this->tabs as $id => $tab ): ?> |
| 740 | | <div class="library-content" data-customize-tab='<?php echo esc_attr( $id ); ?>'> |
| 741 | | <?php call_user_func( $tab['callback'] ); ?> |
| 742 | | </div> |
| 743 | | <?php endforeach; ?> |
| 744 | | </div> |
| 745 | | |
| 746 | | <div class="actions"> |
| 747 | | <a href="#" class="remove"><?php _e( 'Remove Image' ); ?></a> |
| 748 | | </div> |
| 749 | | </div> |
| 750 | | <?php |
| 751 | | } |
| 752 | | |
| 753 | | /** |
| 776 | | public function remove_tab( $id ) { |
| 777 | | unset( $this->tabs[ $id ] ); |
| 778 | | } |
| 779 | | |
| 780 | | /** |
| 781 | | * @since 3.4.0 |
| 782 | | */ |
| 783 | | public function tab_upload_new() { |
| 784 | | if ( ! _device_can_upload() ) { |
| 785 | | echo '<p>' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://apps.wordpress.org/' ) . '</p>'; |
| 786 | | } else { |
| 787 | | ?> |
| 788 | | <div class="upload-dropzone"> |
| 789 | | <?php _e('Drop a file here or <a href="#" class="upload">select a file</a>.'); ?> |
| 790 | | </div> |
| 791 | | <div class="upload-fallback"> |
| 792 | | <span class="button-secondary"><?php _e('Select File'); ?></span> |
| 793 | | </div> |
| 794 | | <?php |
| 795 | | } |
| 796 | | } |
| 797 | | |
| 798 | | /** |
| 799 | | * @since 3.4.0 |
| 800 | | */ |
| 801 | | public function tab_uploaded() { |
| 802 | | ?> |
| 803 | | <div class="uploaded-target"></div> |
| 804 | | <?php |
| 805 | | } |
| 806 | | |
| 807 | | /** |
| 808 | | * @since 3.4.0 |
| 809 | | * |
| 810 | | * @param string $url |
| 811 | | * @param string $thumbnail_url |
| 812 | | */ |
| 813 | | public function print_tab_image( $url, $thumbnail_url = null ) { |
| 814 | | $url = set_url_scheme( $url ); |
| 815 | | $thumbnail_url = ( $thumbnail_url ) ? set_url_scheme( $thumbnail_url ) : $url; |
| 816 | | ?> |
| 817 | | <a href="#" class="thumbnail" data-customize-image-value="<?php echo esc_url( $url ); ?>"> |
| 818 | | <img src="<?php echo esc_url( $thumbnail_url ); ?>" /> |
| 819 | | </a> |
| 820 | | <?php |
| 821 | | } |
| | 736 | public function remove_tab( $id ) {} |