[wp-trac] [WordPress Trac] #59915: Preview Whilst Editing Broken
WordPress Trac
noreply at wordpress.org
Thu Nov 7 22:11:37 UTC 2024
#59915: Preview Whilst Editing Broken
-------------------------------+-----------------------------
Reporter: simonjonharding | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone:
Component: Editor | Version: 6.4.2
Severity: minor | Resolution:
Keywords: reporter-feedback | Focuses: ui, javascript
-------------------------------+-----------------------------
Comment (by jgutix):
Turns out it was our legacy code at fault for the issue in our
installation, we had something like this:
{{{
var editor = wp.data.dispatch( 'core/editor' );
....
// Reference original method.
var savePost = editor.savePost;
.....
// Override core method.
editor.savePost = function() {
var currentPost = wp.data.select('core/editor').getCurrentPost();
var postPublished = wp.data.select( 'core/editor'
).isCurrentPostPublished();
var postStatus = wp.data.select( 'core/editor'
).getEditedPostAttribute( 'status' );
if ((postStatus == 'draft') || (!postPublished && postStatus == 'auto-
draft')) {
notices.removeNotice('excerptNotice');
notices.removeNotice('postCategoryNotice');
excerptNotice = null;
postCategoryNotice = null;
savePost();
return false;
}
....
}}}
We were returning false which then returned the preview link as undefined
It was simply fixed by changing the last two lines to: return savePost();
P.S.: At this point I'm not sure why disabling Yoast allowed the post to
be previewed ¯\_(ツ)_/¯
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59915#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list