diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css
index f9ca1d7..be2d41b 100644
|
a
|
b
|
body { |
| 465 | 465 | margin-bottom: 18px; |
| 466 | 466 | } |
| 467 | 467 | |
| | 468 | #customize-control-header_image .uploaded button, |
| | 469 | #customize-control-header_image .default button { |
| | 470 | width: 100%; |
| | 471 | padding: 0; |
| | 472 | margin: 0; |
| | 473 | background: none; |
| | 474 | border: none; |
| | 475 | color: inherit; |
| | 476 | cursor: pointer; |
| | 477 | } |
| | 478 | |
| | 479 | #customize-control-header_image button img { |
| | 480 | display: block; |
| | 481 | } |
| | 482 | |
| 468 | 483 | /* Header control: current image container */ |
| 469 | 484 | |
| 470 | 485 | #customize-control-header_image .current .container { |
| 471 | 486 | overflow: hidden; |
| 472 | 487 | -webkit-border-radius: 2px; |
| | 488 | border: 1px solid #eee; |
| 473 | 489 | border-radius: 2px; |
| 474 | 490 | } |
| 475 | 491 | |
| 476 | 492 | #customize-control-header_image .placeholder { |
| 477 | 493 | width: 100%; |
| 478 | 494 | position: relative; |
| 479 | | background: #262626; |
| 480 | 495 | text-align: center; |
| 481 | 496 | cursor: default; |
| 482 | 497 | } |
| … |
… |
body { |
| 485 | 500 | display: none; |
| 486 | 501 | position: absolute; |
| 487 | 502 | width: 100%; |
| 488 | | height: 18px; |
| 489 | | margin-top: -9px; |
| 490 | | top: 50%; |
| 491 | | color: #eee; |
| | 503 | color: #555; |
| | 504 | white-space: nowrap; |
| | 505 | text-overflow: ellipsis; |
| | 506 | overflow: hidden; |
| 492 | 507 | } |
| 493 | 508 | |
| 494 | | /* Header control: overlay "close" button */ |
| | 509 | #customize-control-header_image .inner, |
| | 510 | #customize-control-header_image .inner .dashicons { |
| | 511 | line-height: 20px; |
| | 512 | top: 10px; |
| | 513 | } |
| | 514 | #customize-control-header_image .list .inner, |
| | 515 | #customize-control-header_image .list .inner .dashicons { |
| | 516 | top: 9px; |
| | 517 | } |
| 495 | 518 | |
| 496 | 519 | #customize-control-header_image .header-view { |
| 497 | 520 | position: relative; |
| | 521 | width: 100%; |
| | 522 | margin-bottom: 5px; |
| 498 | 523 | } |
| 499 | 524 | |
| | 525 | #customize-control-header_image .header-view:last-child { |
| | 526 | margin-bottom: 0px; |
| | 527 | } |
| | 528 | |
| | 529 | /* Convoluted, but 'outline' support isn't good enough yet */ |
| | 530 | #customize-control-header_image .header-view:after { |
| | 531 | border: 0; |
| | 532 | } |
| | 533 | #customize-control-header_image .header-view.selected:after { |
| | 534 | content: ''; |
| | 535 | position: absolute; |
| | 536 | top: 0; left: 0; bottom: 0; right: 0; |
| | 537 | border: 4px solid #2ea2cc; |
| | 538 | border-radius: 2px; |
| | 539 | } |
| | 540 | #customize-control-header_image .header-view.button.selected { |
| | 541 | border: 0; |
| | 542 | } |
| | 543 | |
| | 544 | /* Header control: overlay "close" button */ |
| | 545 | |
| 500 | 546 | #customize-control-header_image .uploaded .header-view .close { |
| 501 | 547 | font-size: 2em; |
| 502 | 548 | color: grey; |
| … |
… |
body { |
| 575 | 621 | margin-bottom: 9px; |
| 576 | 622 | } |
| 577 | 623 | |
| 578 | | #customize-control-header_image .choice.random:before { |
| 579 | | position: absolute; |
| 580 | | content: attr(data-label); |
| 581 | | left: 0; |
| 582 | | top: 0; |
| 583 | | } |
| 584 | | |
| 585 | 624 | #customize-control-header_image .uploaded div:last-child > .choice { |
| 586 | 625 | margin-bottom: 0; |
| 587 | 626 | } |
| 588 | 627 | |
| 589 | | #customize-control-header_image .choices hr { |
| 590 | | visibility: hidden; |
| 591 | | } |
| 592 | | |
| 593 | 628 | #customize-control-header_image img { |
| 594 | 629 | width: 100%; |
| 595 | 630 | -webkit-border-radius: 2px; |
diff --git a/src/wp-admin/custom-header.php b/src/wp-admin/custom-header.php
index 4a2d44c..2a6a2f3 100644
|
a
|
b
|
wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> |
| 1272 | 1272 | public function get_uploaded_header_images() { |
| 1273 | 1273 | $header_images = get_uploaded_header_images(); |
| 1274 | 1274 | $timestamp_key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
| | 1275 | $alt_text_key = '_wp_attachment_image_alt'; |
| 1275 | 1276 | |
| 1276 | 1277 | foreach ( $header_images as &$header_image ) { |
| 1277 | | $header_image['timestamp'] = get_post_meta( $header_image['attachment_id'], $timestamp_key, true ); |
| | 1278 | $header_meta = get_post_meta( $header_image['attachment_id'] ); |
| | 1279 | $header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : ''; |
| | 1280 | $header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : ''; |
| 1278 | 1281 | } |
| 1279 | 1282 | |
| 1280 | 1283 | return $header_images; |
diff --git a/src/wp-includes/class-wp-customize-control.php b/src/wp-includes/class-wp-customize-control.php
index e55a759..478a706 100644
|
a
|
b
|
final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control |
| 774 | 774 | |
| 775 | 775 | <div class="placeholder random"> |
| 776 | 776 | <div class="inner"> |
| 777 | | <span><span class="dashicons dashicons-randomize dice"></span> |
| | 777 | <button type="button"><span class="dashicons dashicons-randomize dice"></span> |
| 778 | 778 | <# if ( data.type === 'uploaded' ) { #> |
| 779 | 779 | <?php _e( 'Randomize uploaded headers' ); ?> |
| 780 | 780 | <# } else if ( data.type === 'default' ) { #> |
| 781 | 781 | <?php _e( 'Randomize suggested headers' ); ?> |
| 782 | 782 | <# } #> |
| 783 | | </span> |
| | 783 | </button> |
| 784 | 784 | </div> |
| 785 | 785 | </div> |
| 786 | 786 | |
| 787 | 787 | <# } else { #> |
| 788 | 788 | |
| 789 | 789 | <# if (data.type === 'uploaded') { #> |
| 790 | | <div class="dashicons dashicons-no close"></div> |
| | 790 | <div class="dashicons dashicons-no close"></div> |
| 791 | 791 | <# } #> |
| 792 | 792 | |
| 793 | | <a href="#" class="choice thumbnail #>" |
| | 793 | <button type="button" class="choice thumbnail" |
| 794 | 794 | data-customize-image-value="{{{data.header.url}}}" |
| 795 | 795 | data-customize-header-image-data="{{JSON.stringify(data.header)}}"> |
| 796 | | <img src="{{{data.header.thumbnail_url}}}"> |
| 797 | | </a> |
| | 796 | <span class="screen-reader-text"><?php _e( 'Set image' ); ?></span> |
| | 797 | <img src="{{{data.header.thumbnail_url}}}" alt="{{{data.header.alt_text || data.header.description}}}"> |
| | 798 | </button> |
| 798 | 799 | |
| 799 | 800 | <# } #> |
| 800 | 801 | </script> |
| … |
… |
final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control |
| 803 | 804 | <# if (data.choice) { #> |
| 804 | 805 | <# if (data.random) { #> |
| 805 | 806 | |
| 806 | | <div class="placeholder"> |
| | 807 | <div class="placeholder" tabindex="0"> |
| 807 | 808 | <div class="inner"> |
| 808 | 809 | <span><span class="dashicons dashicons-randomize dice"></span> |
| 809 | 810 | <# if ( data.type === 'uploaded' ) { #> |
| … |
… |
final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control |
| 817 | 818 | |
| 818 | 819 | <# } else { #> |
| 819 | 820 | |
| 820 | | <img src="{{{data.header.thumbnail_url}}}" /> |
| | 821 | <img src="{{{data.header.thumbnail_url}}}" alt="{{{data.header.alt_text || data.header.description}}}" tabindex="0"/> |
| 821 | 822 | |
| 822 | 823 | <# } #> |
| 823 | 824 | <# } else { #> |
| 824 | 825 | |
| 825 | | <div class="placeholder"> |
| | 826 | <div class="placeholder" tabindex="0"> |
| 826 | 827 | <div class="inner"> |
| 827 | 828 | <span> |
| 828 | 829 | <?php _e( 'No image set' ); ?> |
| … |
… |
final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control |
| 853 | 854 | |
| 854 | 855 | |
| 855 | 856 | <div class="customize-control-content"> |
| 856 | | <p class="customizer-section-intro"> |
| | 857 | <p class="customizer-section-intro" tabindex="0"> |
| 857 | 858 | <?php |
| 858 | 859 | // @todo translate (and look to custom-header.php for inspiration) |
| 859 | 860 | echo ( 'Personalize your site with your own header image.' ); |
| … |
… |
final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control |
| 867 | 868 | ?> |
| 868 | 869 | </p> |
| 869 | 870 | <div class="current"> |
| 870 | | <span class="customize-control-title"> |
| | 871 | <span class="customize-control-title" tabindex="0"> |
| 871 | 872 | <?php _e( 'Current header' ); ?> |
| 872 | 873 | </span> |
| 873 | 874 | <div class="container"> |
| … |
… |
final class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control |
| 875 | 876 | </div> |
| 876 | 877 | <div class="actions"> |
| 877 | 878 | <?php /* translators: Hide as in hide header image via the Customizer */ ?> |
| 878 | | <a href="#" <?php echo $visibility ?> class="button remove"><?php _ex( 'Hide', 'custom header' ); ?></a> |
| | 879 | <button type="button"<?php echo $visibility ?> class="button remove"><?php _ex( 'Hide image', 'custom header' ); ?></button> |
| 879 | 880 | <?php /* translators: New as in add new header image via the Customizer */ ?> |
| 880 | | <a href="#" class="button new"><?php _ex( 'Add new', 'header image' ); ?></a> |
| | 881 | <button type="button" class="button new"><?php _ex( 'Add new image', 'header image' ); ?></button> |
| 881 | 882 | <div style="clear:both"></div> |
| 882 | 883 | </div> |
| 883 | 884 | <div class="choices"> |
| 884 | | <span class="customize-control-title header-previously-uploaded"> |
| | 885 | <span class="customize-control-title header-previously-uploaded" tabindex="0"> |
| 885 | 886 | <?php _ex( 'Previously uploaded', 'custom headers' ); ?> |
| 886 | 887 | </span> |
| 887 | 888 | <div class="uploaded"> |
| 888 | 889 | <div class="list"> |
| 889 | 890 | </div> |
| 890 | 891 | </div> |
| 891 | | <span class="customize-control-title header-default"> |
| | 892 | <span class="customize-control-title header-default" tabindex="0"> |
| 892 | 893 | <?php _ex( 'Suggested', 'custom headers' ); ?> |
| 893 | 894 | </span> |
| 894 | 895 | <div class="default"> |
diff --git a/src/wp-includes/js/customize-models.js b/src/wp-includes/js/customize-models.js
index f97750b..3c8001c 100644
|
a
|
b
|
|
| 26 | 26 | thumbnail_url: '' |
| 27 | 27 | }, |
| 28 | 28 | choice: '', |
| 29 | | hidden: false, |
| | 29 | selected: false, |
| 30 | 30 | random: false |
| 31 | 31 | }; |
| 32 | 32 | }, |
| … |
… |
|
| 160 | 160 | elt.defaultName = index; |
| 161 | 161 | } |
| 162 | 162 | |
| | 163 | if (typeof elt.timestamp === 'undefined') { |
| | 164 | elt.timestamp = 0; |
| | 165 | } |
| | 166 | |
| 163 | 167 | this.add({ |
| 164 | 168 | header: elt, |
| 165 | 169 | choice: elt.url.split('/').pop(), |
| 166 | | hidden: current === elt.url.replace(/^https?:\/\//, '') |
| | 170 | selected: current === elt.url.replace(/^https?:\/\//, '') |
| 167 | 171 | }, { silent: true }); |
| 168 | 172 | }, this); |
| 169 | 173 | |
| … |
… |
|
| 191 | 195 | }, |
| 192 | 196 | choice: randomChoice, |
| 193 | 197 | random: true, |
| 194 | | hidden: isRandomSameType |
| | 198 | selected: isRandomSameType |
| 195 | 199 | }); |
| 196 | 200 | }, |
| 197 | 201 | |
| … |
… |
|
| 200 | 204 | }, |
| 201 | 205 | |
| 202 | 206 | shouldHideTitle: function() { |
| 203 | | return _.every(this.pluck('hidden')); |
| | 207 | return this.size() < 2; |
| 204 | 208 | }, |
| 205 | 209 | |
| 206 | 210 | setImage: function(model) { |
| 207 | 211 | this.each(function(m) { |
| 208 | | m.set('hidden', false); |
| | 212 | m.set('selected', false); |
| 209 | 213 | }); |
| 210 | 214 | |
| 211 | 215 | if (model) { |
| 212 | | model.set('hidden', true); |
| 213 | | // Bump images to top except for special "Randomize" images |
| 214 | | if (!model.get('random')) { |
| 215 | | model.get('header').timestamp = _.now(); |
| 216 | | this.sort(); |
| 217 | | } |
| | 216 | model.set('selected', true); |
| 218 | 217 | } |
| 219 | 218 | }, |
| 220 | 219 | |
| 221 | 220 | removeImage: function() { |
| 222 | 221 | this.each(function(m) { |
| 223 | | m.set('hidden', false); |
| | 222 | m.set('selected', false); |
| 224 | 223 | }); |
| 225 | | }, |
| 226 | | |
| 227 | | shown: function() { |
| 228 | | var filtered = this.where({ hidden: false }); |
| 229 | | return new api.HeaderTool.ChoiceList( filtered ); |
| 230 | 224 | } |
| 231 | 225 | }); |
| 232 | 226 | |
diff --git a/src/wp-includes/js/customize-views.js b/src/wp-includes/js/customize-views.js
index eb3d4aa..39ad65b 100644
|
a
|
b
|
|
| 32 | 32 | |
| 33 | 33 | getHeight: function() { |
| 34 | 34 | var image = this.$el.find('img'), |
| 35 | | saved = this.model.get('savedHeight'), |
| 36 | | height = image.height() || saved, |
| 37 | | headerImageData; |
| | 35 | saved, height, headerImageData; |
| 38 | 36 | |
| 39 | 37 | if (image.length) { |
| 40 | 38 | this.$el.find('.inner').hide(); |
| 41 | 39 | } else { |
| 42 | 40 | this.$el.find('.inner').show(); |
| | 41 | return 40; |
| 43 | 42 | } |
| 44 | 43 | |
| | 44 | saved = this.model.get('savedHeight'); |
| | 45 | height = image.height() || saved; |
| | 46 | |
| 45 | 47 | // happens at ready |
| 46 | 48 | if (!height) { |
| 47 | 49 | headerImageData = api.get().header_image_data; |
| … |
… |
|
| 92 | 94 | * @constructor |
| 93 | 95 | * @augments wp.Backbone.View |
| 94 | 96 | */ |
| 95 | | (function () { // closures FTW |
| 96 | | var lastHeight = 0; |
| 97 | 97 | api.HeaderTool.ChoiceView = wp.Backbone.View.extend({ |
| 98 | 98 | template: wp.template('header-choice'), |
| 99 | 99 | |
| … |
… |
|
| 110 | 110 | this.model.get('choice') |
| 111 | 111 | ]; |
| 112 | 112 | |
| 113 | | this.listenTo(this.model, 'change', this.render); |
| | 113 | this.listenTo(this.model, 'change:selected', this.toggleSelected); |
| 114 | 114 | |
| 115 | 115 | if (_.contains(properties, api.get().header_image)) { |
| 116 | 116 | api.HeaderTool.currentHeader.set(this.extendedModel()); |
| … |
… |
|
| 118 | 118 | }, |
| 119 | 119 | |
| 120 | 120 | render: function() { |
| 121 | | var model = this.model; |
| 122 | | |
| 123 | 121 | this.$el.html(this.template(this.extendedModel())); |
| 124 | 122 | |
| 125 | | if (model.get('random')) { |
| | 123 | if (this.model.get('random')) { |
| | 124 | this.$el.addClass('button display-options'); |
| 126 | 125 | this.setPlaceholder(40); |
| 127 | 126 | } |
| 128 | | else { |
| 129 | | lastHeight = this.getHeight(); |
| 130 | | } |
| 131 | 127 | |
| 132 | | this.$el.toggleClass('hidden', model.get('hidden')); |
| | 128 | this.toggleSelected(); |
| 133 | 129 | return this; |
| 134 | 130 | }, |
| 135 | 131 | |
| | 132 | toggleSelected: function() { |
| | 133 | this.$el.toggleClass('selected', this.model.get('selected')); |
| | 134 | }, |
| | 135 | |
| 136 | 136 | extendedModel: function() { |
| 137 | 137 | var c = this.model.get('collection'); |
| 138 | 138 | return _.extend(this.model.toJSON(), { |
| … |
… |
|
| 145 | 145 | setPlaceholder: api.HeaderTool.CurrentView.prototype.setPlaceholder, |
| 146 | 146 | |
| 147 | 147 | select: function() { |
| | 148 | this.preventJump(); |
| 148 | 149 | this.model.save(); |
| 149 | 150 | api.HeaderTool.currentHeader.set(this.extendedModel()); |
| 150 | 151 | }, |
| 151 | 152 | |
| | 153 | preventJump: function() { |
| | 154 | var container = $('.wp-full-overlay-sidebar-content'), |
| | 155 | scroll = container.scrollTop(); |
| | 156 | |
| | 157 | _.defer(function() { |
| | 158 | container.scrollTop(scroll); |
| | 159 | }); |
| | 160 | }, |
| | 161 | |
| 152 | 162 | removeImage: function(e) { |
| 153 | 163 | e.stopPropagation(); |
| 154 | 164 | this.model.destroy(); |
| 155 | 165 | this.remove(); |
| 156 | 166 | } |
| 157 | 167 | }); |
| 158 | | })(); |
| 159 | 168 | |
| 160 | 169 | |
| 161 | 170 | /** |
| … |
… |
|
| 174 | 183 | this.listenTo(this.collection, 'add', this.addOne); |
| 175 | 184 | this.listenTo(this.collection, 'remove', this.render); |
| 176 | 185 | this.listenTo(this.collection, 'sort', this.render); |
| 177 | | this.listenTo(this.collection, 'change:hidden', this.toggleTitle); |
| 178 | | this.listenTo(this.collection, 'change:hidden', this.setMaxListHeight); |
| | 186 | this.listenTo(this.collection, 'change', this.toggleList); |
| 179 | 187 | this.render(); |
| 180 | 188 | }, |
| 181 | 189 | |
| 182 | 190 | render: function() { |
| 183 | 191 | this.$el.empty(); |
| 184 | 192 | this.collection.each(this.addOne, this); |
| 185 | | this.toggleTitle(); |
| | 193 | this.toggleList(); |
| 186 | 194 | }, |
| 187 | 195 | |
| 188 | 196 | addOne: function(choice) { |
| … |
… |
|
| 192 | 200 | this.$el.append(view.render().el); |
| 193 | 201 | }, |
| 194 | 202 | |
| 195 | | toggleTitle: function() { |
| 196 | | var title = this.$el.parents().prev('.customize-control-title'); |
| | 203 | toggleList: function() { |
| | 204 | var title = this.$el.parents().prev('.customize-control-title'), |
| | 205 | randomButton = this.$el.find('.random').parent(); |
| 197 | 206 | if (this.collection.shouldHideTitle()) { |
| 198 | | title.hide(); |
| | 207 | title.add(randomButton).hide(); |
| 199 | 208 | } else { |
| 200 | | title.show(); |
| | 209 | title.add(randomButton).show(); |
| 201 | 210 | } |
| 202 | 211 | } |
| 203 | 212 | }); |