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

Improve compatibility with Customize Changesets (née Transactions aka Snapshots) #300

Merged
merged 5 commits into from Oct 19, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions js/customize-preview-posts.js
Expand Up @@ -138,6 +138,33 @@
return newParams;
};

// WP 4.7-alpha-patch: Prevent edit post links from being classified as un-previewable. See https://github.com/xwp/wordpress-develop/pull/161.
if ( api.isLinkPreviewable ) {

// Prevent not-allowed cursor on edit-post-links.
api.isLinkPreviewable = ( function( originalIsLinkPreviewable ) {
return function( element ) {
if ( $( element ).hasClass( 'post-edit-link' ) ) {
return true;
}
return originalIsLinkPreviewable.call( this, element );
};
} )( api.isLinkPreviewable );
}

// WP 4.7-alpha-patch: Override behavior for clicking on edit post links to prevent sending url message to pane.
if ( api.Preview.prototype.handleLinkClick ) {
api.Preview.prototype.handleLinkClick = ( function( originalHandleLinkClick ) {
return function( event ) {
if ( $( event.target ).hasClass( 'post-edit-link' ) ) {
event.preventDefault();
} else {
originalHandleLinkClick.call( this, event );
}
};
} )( api.Preview.prototype.handleLinkClick );
}

api.bind( 'preview-ready', function onPreviewReady() {
_.extend( api.previewPosts.data, _wpCustomizePreviewPostsData );

Expand Down
4 changes: 4 additions & 0 deletions tests/php/test-class-wp-customize-posts.php
Expand Up @@ -647,6 +647,10 @@ public function test_preview_customize_draft( $post_type ) {
}
$this->posts->transition_customize_draft( $data );

if ( post_type_exists( 'customize_changeset' ) ) {
$this->markTestIncomplete( 'Rework test for compatibility with changesets (aka transactions). Post values are not read for unauthenticated users.' );
}

$GLOBALS['current_user'] = null;

$this->go_to( home_url( sprintf( '?%s=%d&preview=true', 'page' === $post_type ? 'page_id' : 'p', $post->ID ) ) );
Expand Down