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. git-svn-id: https://develop.svn.wordpress.org/trunk@32976 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a4fd22608f
commit
556ec207f1
@ -3210,6 +3210,27 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Change previewed URL to the homepage when changing the page_on_front.
|
||||
api( 'show_on_front', 'page_on_front', function( showOnFront, pageOnFront ) {
|
||||
var updatePreviewUrl = function() {
|
||||
if ( showOnFront() === 'page' && parseInt( pageOnFront(), 10 ) > 0 ) {
|
||||
api.previewer.previewUrl.set( api.settings.url.home );
|
||||
}
|
||||
};
|
||||
showOnFront.bind( updatePreviewUrl );
|
||||
pageOnFront.bind( updatePreviewUrl );
|
||||
});
|
||||
|
||||
// Change the previewed URL to the selected page when changing the page_for_posts.
|
||||
api( 'page_for_posts', function( setting ) {
|
||||
setting.bind(function( pageId ) {
|
||||
pageId = parseInt( pageId, 10 );
|
||||
if ( pageId > 0 ) {
|
||||
api.previewer.previewUrl.set( api.settings.url.home + '?page_id=' + pageId );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
api.trigger( 'ready' );
|
||||
|
||||
// Make sure left column gets focus
|
||||
|
Loading…
Reference in New Issue
Block a user