-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose preview_link
through the REST API and use within client
#6882
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor tweaks, but 👍🏻once they're done.
@@ -354,12 +353,11 @@ export function getEditedPostExcerpt( state ) { | |||
* @return {string} Preview URL. | |||
*/ | |||
export function getEditedPostPreviewLink( state ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be simplified further, see getCurrentPostId()
for an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
editor/store/test/selectors.js
Outdated
@@ -1068,11 +1068,11 @@ describe( 'selectors', () => { | |||
it( 'should return the correct url adding a preview parameter to the query string', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description should be updated to match the new behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
return addQueryArgs( link, { preview: 'true' } ); | ||
return getCurrentPost( state ).preview_link || null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to use getEditedPostAttribute( 'preview_link' )
so we could get rid of getCurrentPost
at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make an issue for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Exposes a
preview_link
value for Posts through the REST API, and then references this value when generating the "Preview" button.Fixes #4555
Related https://core.trac.wordpress.org/ticket/44180
How has this been tested?
Manually verified the correct link is displayed when a post is in draft vs. publish:
Checklist: