Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Let post_name changes skip doing any partial refreshing by default #151

Merged
merged 1 commit into from
May 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions js/customize-preview-posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,24 @@
}
} else {
partial = new api.previewPosts.PostFieldPartial( schema.id, { params: schema.params } );
partial.renderContent = function() {
api.selectiveRefresh.requestFullRefresh();
return true;

/**
* Suppress wasted partial refreshes for partials that lack selectors.
*
* For example, since the post_name field is not normally
* displayed, suppress refreshing changes.
*
* @returns {jQuery.promise} Promise.
*/
partial.refresh = function refreshWithoutSelector() {
var deferred = $.Deferred();
if ( this.params.fallbackRefresh ) {
api.selectiveRefresh.requestFullRefresh();
deferred.resolve();
} else {
deferred.reject();
}
return deferred.promise();
};
api.selectiveRefresh.partial.add( partial.id, partial );
}
Expand Down
3 changes: 3 additions & 0 deletions php/class-wp-customize-posts-preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ public function get_post_field_partial_schema( $field_id = '' ) {
'post_title' => array(
'selector' => '.entry-title',
),
'post_name' => array(
'fallback_refresh' => false,
),
'post_content' => array(
'selector' => '.entry-content',
),
Expand Down