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

Unable to PUSH new CPTs #366

Closed
jeffpaul opened this issue Apr 9, 2019 · 6 comments · Fixed by #528
Closed

Unable to PUSH new CPTs #366

jeffpaul opened this issue Apr 9, 2019 · 6 comments · Fixed by #528
Assignees
Labels
type:bug Something isn't working.
Milestone

Comments

@jeffpaul
Copy link
Member

jeffpaul commented Apr 9, 2019

In order for CPTs to be supported, we state in our Known Caveats/Issues section that:

In addition, in order for distribution to work with external connections that have custom post type content, that post type needs to be registered with the argument show_in_rest => true on the external site.

I've been triaging a couple user setups who are leveraging the CPT UI plugin for creating CPTs. In my testing I'm seeing that with proper External Connections created and the same CPT setup on each side of the connection, that you can PULL new CPTs without issue. However, when you try to PUSH a new CPT the Distributor menu only shows No connections available for distribution. instead of the existing external connection site as expected.

The CPT UI plugin does default to show_in_menu: true when it registers its CPTs and I've confirmed those settings via its Post Types and Taxonomies registered by Custom Post Type UI page (e.g., http://sampledomain.com/wp-admin/admin.php?page=cptui_listings). I don't think we require anything added to the custom "supports" value, but that's something we might investigate as possibly needed (at least in relation to the CPT UI plugin, see more on that here).

I was eventually able to get PUSH working for these external connections, but only after going into each sites' Edit External Connection pages and clicking Update Connection. So I'm not sure if there's a race condition happening, if Distributor needs to more regularly check for newly registered CPTs, have something added to the CPT UI custom "supports" value, or something I've yet to imagine.

@jeffpaul jeffpaul added the type:bug Something isn't working. label Apr 9, 2019
@jeffpaul jeffpaul added this to the Future Release milestone Apr 9, 2019
@jeffpaul jeffpaul modified the milestones: Future Release, 2.0.0 Jun 6, 2019
@jeffpaul jeffpaul modified the milestones: 3.0.0, 2.0.0 Jan 30, 2020
@dinhtungdu
Copy link
Contributor

@jeffpaul, It's expected behavior for the current codebase (see below). When we add new CPT, the value dt_external_connections doesn't have that new post type included.

I'm thinking about checking if supported custom post types listed in dt_external_connections meta, then update the connection silently. But it also means that we need to check every time we push a post, while we don't add new CPT much.

https://github.com/10up/distributor/blob/feature/distribute_post_status/includes/push-ui.php#L158-L160

@jeffpaul
Copy link
Member Author

@dkotter any preference on approach for this^?

@dkotter
Copy link
Collaborator

dkotter commented Feb 14, 2020

@jeffpaul @dinhtungdu Yeah, this is tricky and not sure there's a great solution. Basically once an external connection is setup, we don't check again what post types that connection supports. So if a new CPT is added or an old one is removed or details about an existing one are changed, we don't ever know that.

This could be something we keep as a manual thing, where we add documentation that states you need to go re-save your connection if you add, remove or change content types on the external site.

Or take an approach where we periodically check the connection again. That could be done on a regular cron interval, though that seems overkill (but may be fine). The other approach would be what @dinhtungdu recommends, updating these connection details whenever we use that external connection (either push or pull potentially). Downside there is this connection step ends up making multiple remote requests (and thus will impact performance on each push/pull) and as mentioned, CPT information probably won't change very often.

So that doesn't answer the question but I'd lean more towards keeping this a manual thing. Maybe we can add a refresh button on the external connections screen that refreshes all the connections at once? Or at least an inline action on that list screen to more easily trigger that update for each connection?

@dinhtungdu
Copy link
Contributor

This could be something we keep as a manual thing, where we add documentation that states you need to go re-save your connection if you add, remove or change content types on the external site.

@dkotter @jeffpaul, I agree with this, IMO documentation is the best way to solve this issue because:

  1. We can solve this problem already with the current codebase.
  2. We don't need to change the codebase.
  3. CPT information probably won't change very often

@jeffpaul
Copy link
Member Author

@dinhtungdu sounds good, you able to work on a docs PR to cover this?

@dinhtungdu
Copy link
Contributor

@jeffpaul sure, I will do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants