Make WordPress Core

Changeset 32976


Ignore:
Timestamp:
06/27/2015 07:58:41 PM (8 years ago)
Author:
westonruter
Message:

Customizer: Improve previewing setting changes for show_on_front, page_on_front, and page_for_posts.

When changing the page_on_front setting (with show_on_front), change the previewed URL to be the home URL so that the effect can be seen. When changing page_for_posts, change the previewed URL to be the selected page.

Props valendesigns, westonruter.
Fixes #30677.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r32743 r32976  
    32113211        });
    32123212
     3213        // Change previewed URL to the homepage when changing the page_on_front.
     3214        api( 'show_on_front', 'page_on_front', function( showOnFront, pageOnFront ) {
     3215            var updatePreviewUrl = function() {
     3216                if ( showOnFront() === 'page' && parseInt( pageOnFront(), 10 ) > 0 ) {
     3217                    api.previewer.previewUrl.set( api.settings.url.home );
     3218                }
     3219            };
     3220            showOnFront.bind( updatePreviewUrl );
     3221            pageOnFront.bind( updatePreviewUrl );
     3222        });
     3223
     3224        // Change the previewed URL to the selected page when changing the page_for_posts.
     3225        api( 'page_for_posts', function( setting ) {
     3226            setting.bind(function( pageId ) {
     3227                pageId = parseInt( pageId, 10 );
     3228                if ( pageId > 0 ) {
     3229                    api.previewer.previewUrl.set( api.settings.url.home + '?page_id=' + pageId );
     3230                }
     3231            });
     3232        });
     3233
    32133234        api.trigger( 'ready' );
    32143235
Note: See TracChangeset for help on using the changeset viewer.