Changeset 41788
- Timestamp:
- 10/07/2017 05:59:45 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/customize-controls.js
r41778 r41788 2802 2802 */ 2803 2803 attachEvents: function() { 2804 var panel = this ;2804 var panel = this, toggleDisabledNotification; 2805 2805 2806 2806 // Attach regular panel events. 2807 2807 api.Panel.prototype.attachEvents.apply( panel ); 2808 2809 toggleDisabledNotification = function() { 2810 if ( 'publish' === api.state( 'selectedChangesetStatus' ).get() ) { 2811 panel.notifications.remove( 'theme_switch_unavailable' ); 2812 } else { 2813 panel.notifications.add( new api.Notification( 'theme_switch_unavailable', { 2814 message: api.l10n.themePreviewUnavailable, 2815 type: 'warning' 2816 } ) ); 2817 } 2818 }; 2819 toggleDisabledNotification(); 2820 api.state( 'selectedChangesetStatus' ).bind( toggleDisabledNotification ); 2808 2821 2809 2822 // Collapse panel to customize the current theme. … … 2888 2901 * @since 4.9.0 2889 2902 * 2890 * @returns {void} 2903 * @param {jQuery.Event} event - Event. 2904 * @returns {jQuery.promise} Promise. 2891 2905 */ 2892 2906 installTheme: function( event ) { 2893 var panel = this, preview = false, slug = $( event.target ).data( 'slug' ); 2894 2907 var panel = this, preview, onInstallSuccess, slug = $( event.target ).data( 'slug' ), deferred = $.Deferred(), request; 2908 preview = $( event.target ).hasClass( 'preview' ); 2909 2910 // Prevent loading a non-active theme preview when there is a drafted/scheduled changeset. 2911 if ( 'publish' !== api.state( 'selectedChangesetStatus' ).get() && slug !== api.settings.theme.stylesheet ) { 2912 deferred.reject({ 2913 errorCode: 'theme_switch_unavailable' 2914 }); 2915 return deferred.promise(); 2916 } 2917 2918 // Theme is already being installed. 2895 2919 if ( _.contains( panel.installingThemes, slug ) ) { 2896 return; // Theme is already being installed. 2920 deferred.reject({ 2921 errorCode: 'theme_already_installing' 2922 }); 2923 return deferred.promise(); 2897 2924 } 2898 2925 2899 2926 wp.updates.maybeRequestFilesystemCredentials( event ); 2900 2927 2901 $( document ).one( 'wp-theme-install-success', function( event,response ) {2928 onInstallSuccess = function( response ) { 2902 2929 var theme = false, themeControl; 2903 2930 if ( preview ) { … … 2916 2943 // Don't add the same theme more than once. 2917 2944 if ( ! theme || api.control.has( 'installed_theme_' + theme.id ) ) { 2945 deferred.resolve( response ); 2918 2946 return; 2919 2947 } … … 2940 2968 }); 2941 2969 } 2942 } ); 2943 2944 panel.installingThemes.push( $( event.target ).data( 'slug' ) ); // Note: we don't remove elements from installingThemes, since they shouldn't be installed again. 2945 wp.updates.installTheme( { 2970 deferred.resolve( response ); 2971 }; 2972 2973 panel.installingThemes.push( slug ); // Note: we don't remove elements from installingThemes, since they shouldn't be installed again. 2974 request = wp.updates.installTheme( { 2946 2975 slug: slug 2947 2976 } ); 2948 2977 2949 2978 // Also preview the theme as the event is triggered on Install & Preview. 2950 if ( $( event.target ).hasClass( 'preview' ) ) { 2951 preview = true; 2952 2979 if ( preview ) { 2953 2980 api.notifications.add( new api.OverlayNotification( 'theme_installing', { 2954 2981 message: api.l10n.themeDownloading, … … 2957 2984 } ) ); 2958 2985 } 2986 2987 request.done( onInstallSuccess ); 2988 request.fail( function() { 2989 api.notifications.remove( 'theme_installing' ); 2990 } ); 2991 2992 return deferred.promise(); 2959 2993 }, 2960 2994 … … 2969 3003 loadThemePreview: function( themeId ) { 2970 3004 var deferred = $.Deferred(), onceProcessingComplete, urlParser, queryParams; 3005 3006 // Prevent loading a non-active theme preview when there is a drafted/scheduled changeset. 3007 if ( 'publish' !== api.state( 'selectedChangesetStatus' ).get() && themeId !== api.settings.theme.stylesheet ) { 3008 return deferred.reject().promise(); 3009 } 2971 3010 2972 3011 urlParser = document.createElement( 'a' ); … … 4742 4781 */ 4743 4782 ready: function() { 4744 var control = this; 4783 var control = this, disableSwitchButtons, updateButtons; 4784 4785 disableSwitchButtons = function() { 4786 return 'publish' !== api.state( 'selectedChangesetStatus' ).get() && control.params.theme.id !== api.settings.theme.stylesheet; 4787 }; 4788 updateButtons = function() { 4789 control.container.find( 'button' ).toggleClass( 'disabled', disableSwitchButtons() ); 4790 }; 4791 4792 api.state( 'selectedChangesetStatus' ).bind( updateButtons ); 4793 updateButtons(); 4745 4794 4746 4795 control.container.on( 'touchmove', '.theme', function() { … … 4750 4799 // Bind details view trigger. 4751 4800 control.container.on( 'click keydown touchend', '.theme', function( event ) { 4801 var section; 4752 4802 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { 4753 4803 return; … … 4765 4815 4766 4816 event.preventDefault(); // Keep this AFTER the key filter above 4767 api.section( control.section() ).showDetails( control.params.theme ); 4817 section = api.section( control.section() ); 4818 section.showDetails( control.params.theme, function() { 4819 section.overlay.find( '.theme-actions button' ).toggleClass( 'disabled', disableSwitchButtons() ); 4820 } ); 4768 4821 }); 4769 4822 … … 7340 7393 }; 7341 7394 7342 // Deactivate themes panel if changeset status is not auto-draft.7343 api.panel( 'themes', function( themesPanel ) {7344 var isPanelActive, updatePanelActive;7345 7346 isPanelActive = function() {7347 return 'publish' === selectedChangesetStatus.get() && ( ! changesetStatus() || 'auto-draft' === changesetStatus() );7348 };7349 themesPanel.active.validate = isPanelActive;7350 7351 updatePanelActive = function() {7352 themesPanel.active.set( isPanelActive() );7353 };7354 7355 updatePanelActive();7356 changesetStatus.bind( updatePanelActive );7357 selectedChangesetStatus.bind( updatePanelActive );7358 } );7359 7360 7395 // Show changeset UUID in URL when in branching mode and there is a saved changeset. 7361 7396 if ( api.settings.changeset.branching ) { -
trunk/src/wp-includes/class-wp-customize-manager.php
r41771 r41788 608 608 $changeset_uuid = null; 609 609 610 if ( ! $this->branching() ) {610 if ( ! $this->branching() && $this->is_theme_active() ) { 611 611 $unpublished_changeset_posts = $this->get_changeset_posts( array( 612 612 'post_status' => array_diff( get_post_stati(), array( 'auto-draft', 'publish', 'trash', 'inherit', 'private' ) ), -
trunk/src/wp-includes/customize/class-wp-customize-themes-panel.php
r41709 r41788 89 89 <# } #> 90 90 <?php endif; ?> 91 92 <div class="customize-control-notifications-container"></div> 91 93 </li> 92 94 <li class="customize-themes-full-container-container"> -
trunk/src/wp-includes/script-loader.php
r41771 r41788 581 581 /* translators: %s: URL to the Customizer to load the autosaved version */ 582 582 'autosaveNotice' => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ), 583 'videoHeaderNotice' => __( 'This theme doesn \'t support video headers on this page. Navigate to the front page or another page that supports video headers.' ),583 'videoHeaderNotice' => __( 'This theme doesn’t support video headers on this page. Navigate to the front page or another page that supports video headers.' ), 584 584 // Used for overriding the file types allowed in plupload. 585 585 'allowedFiles' => __( 'Allowed Files' ), … … 596 596 ), 597 597 'scheduleDescription' => __( 'Schedule your customization changes to publish ("go live") at a future date.' ), 598 'themePreviewUnavailable' => __( 'Sorry, you can’t preview new themes when you have changes scheduled or saved as a draft. Please publish your changes, or wait until they publish to preview new themes.' ), 598 599 ) ); 599 600 $scripts->add( 'customize-selective-refresh', "/wp-includes/js/customize-selective-refresh$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 ); -
trunk/tests/phpunit/tests/customize/manager.php
r41750 r41788 197 197 ) ); 198 198 $this->assertNotContains( $wp_customize->changeset_uuid(), array( $uuid1, $uuid2 ) ); 199 $this->assertEmpty( $wp_customize->changeset_post_id() ); 200 201 // Make sure existing changeset is not autoloaded in the case of previewing a theme switch. 202 switch_theme( 'twentyseventeen' ); 203 $wp_customize = new WP_Customize_Manager( array( 204 'changeset_uuid' => false, // Cause UUID to be deferred. 205 'branching' => false, 206 'theme' => 'twentyfifteen', 207 ) ); 199 208 $this->assertEmpty( $wp_customize->changeset_post_id() ); 200 209 }
Note: See TracChangeset
for help on using the changeset viewer.