Skip to content
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

WP 5.2: Change preview link or rewrite PostPreviewButton component #15895

Closed
demo-igor opened this issue May 29, 2019 · 6 comments
Closed

WP 5.2: Change preview link or rewrite PostPreviewButton component #15895

demo-igor opened this issue May 29, 2019 · 6 comments
Labels
[Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Question Questions about the design or development of the editor.

Comments

@demo-igor
Copy link

WP 5.2
I would like to ask is it possible to update preview link for preview button on post edit page? I have a custom preview link and I'm able to update link related to php with add_action and add_filter but I' didn't find any way to update preview link to PostPreviewButton.
Maybe there is possible to rewrite PostPreviewButton component?

@talldan
Copy link
Contributor

talldan commented May 30, 2019

@demo-igor If it helps, the link that's used by PostPreviewButton is:

  • The preview_link property received from the REST API autosaves endpoint if an autosave exists.
  • The link property received from the REST APIs posts endpoint if there isn't an autosave.

I'm not sure if there are ways to intercept those properties on the post objects, but that might be the most promising route to investigate.

@talldan talldan added the [Type] Question Questions about the design or development of the editor. label May 30, 2019
@demo-igor
Copy link
Author

@talldan the main problem to me that WP used the same API on many places and I don't want to change the API globally. I just would like to change preview link for PostPreviewButton only, like I did with WP php hooks for another places.
Maybe we have a good way to modify selectors functions:
wp.data.select('core/editor').getCurrentPostAttribute() wp.data.select('core/editor').getEditedPostPreviewLink()

@demo-igor
Copy link
Author

@youknowriad could you help to understand is it possible to replace link for PostPreviewButton or maybe is it possible to updated those methods:
wp.data.select('core/editor').getCurrentPostAttribute() wp.data.select('core/editor').getEditedPostPreviewLink()
Thanks!

@ocean90 ocean90 added the [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed label Jul 1, 2019
@ocean90
Copy link
Member

ocean90 commented Jul 1, 2019

Closing as a duplicate of #13998.

@ocean90 ocean90 closed this as completed Jul 1, 2019
@chrisvanpatten
Copy link
Member

I'd like to consider reopening this as I think it's slightly distinct from #13998.

In my particular case, simply rewriting the preview link isn't enough — that gets a small part of the job done, but you are still unable to overwrite a lot of the behavior around how Gutenberg handles autosaving and preview generation.

In my case, I'm working within an architecture where our front-end is completely decoupled from WordPress and from the WP API (two levels of headless!) where previews need to actually trigger a POST event with data from another database to work properly.

In my case, it would be much easier to be able to filter the button entirely, or completely disable it and provide my own alternative. As of now, I'm not able to find a great way to do that, short of using CSS, which feels frustratingly hacky in this declarative Gutenberg world.

@avblink
Copy link

avblink commented Nov 3, 2020

@chrisvanpatten have you solved the problem?
Could you please share your solution.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Question Questions about the design or development of the editor.
Projects
None yet
Development

No branches or pull requests

5 participants