Replies: 7 comments 14 replies
-
I welcome any feedback you might have. |
Beta Was this translation helpful? Give feedback.
-
What you propose sounds compelling but I am worried about the "where" of where transformations happen and that it's not feasible to implement in practise. If I understand you correctly, you propose to have the "content detection" be a Gutenberg paste handler so that when you paste in a product, it would create the right blocks that a product has. It could then store the respective data in the blocks it finds. This means that the content detection moves away from the user and into autodetecting it in the paste handler. I am not sure this would work well. In the current model, we'd create structured data by the user selecting the fields. This would be passed on as that auxiliary data you mention, and stored as post_meta, as well as being provided to the I like that current model better because it separates out the parsing concerns better. We can work on automatically detecting the right fields on the page using something like https://github.com/fivefilters/ftr-site-config definitions and send a defined set of metadata per defined entity. If the detection would happen in blocks it means that each plugin would have to implement that data detection and/or we'd have to juggle with data liberation provided blocks and do the content detection there. |
Beta Was this translation helpful? Give feedback.
-
I think maybe I didn't make that part clear. The current model that we have today, where the user clicks on individual fields, would remain the same. The user would not be clicking on the "container" element, they would still click on individual fields. In the approach suggested here, the difference is that which fields are shown for a given post type, comes from wherever the block editor goes look for that information, and is not hard-coded. For example, if the block editor is able to know that a "product" has a title and price attribute, we would also be able to know that. So our UI renders the title and price "fields" (as it does today), and the user clicks on the title and on the price explicitly. The UI we have today, and the principle that the user should click on individual fields would remain. So the html to blocks parser would be parsing individual fields, not the "container", which is the behavior we have today. |
Beta Was this translation helpful? Give feedback.
-
Thanks for writing the proposal! I like the idea of try-wp just being an alternative block editor but I can't imagine how it would even work in practice. The block editor concerns itself with the content of the page and the site editor concerns itself with the structure/layout of the page. Also note that not all pages in WordPress use block editor to manage content. Eg: Woocommerce's product page doesn't but might support in some other sense that I don't fully understand.
The user interacts with the block editor for content of some pages (think a html page). Our objective however, is to liberate data by not just copying over the content of a html page from source site to new WordPress site, but carry over the relationships (media assets, hyperlinks etc) and auxiliary data (for backtracking & re-transforming the data) for each of that page. And even more importantly, orchestrate this process on scale for however many pages are there on the source site. This would involve working outside of the scope of a block editor, for crawling, establishing relationships and importing assets. I think this complicates some practical aspects of achieving our objectives. Instead of working with the data as we understand it (direct access to under the hood), we would be limiting ourselves to only interface with how the Block editor operates, and when it can't support us in what we want to do, we would branch out and use custom endpoints anyway. Hence, I am unsure of the benefit offered by this approach.
I believe the process is best offered by sane defaults and then another candidate plugin can come in, at any point in future, to re-pick the data and re-transform data as many times as desired. This is aligned with we ourselves wanting to re-transform data at a later date if we have better transformations to offer. We really shouldn't expect the user to make a choice of what e-commerce plugin they want to use for importing products, or even have them installed to begin with. This complicates the UX by introducing friction and offering more ways of how something can be done.
I believe a lot of solutions to tackle certain problems like (correcting links post import, downloading media assets and updating their reference links) is more suitable to be PHP-based to better address overlaps with other projects like Playground & to allow the possibility of eventually merging it in WP core. I'm open to discussing this further and understanding your vision more deeply, as I may have missed some aspects of your proposal. Let me know your thoughts on these points. |
Beta Was this translation helpful? Give feedback.
-
I love this. Any intermediate format is similar to reinventing WordPress exports, even if it's just for a brief moment in memory. The number 1 reason for using Playground here is not having to reinvent that wheel again. +100 for reusing the existing WordPress data structures and interfaces. The original {Platform} to WordPress Proposal is highly relevant and the diagrams there overlap with the ones in this discussion. |
Beta Was this translation helpful? Give feedback.
-
@dmsnell and I explored something related on CloudFest earlier this year:
There's also a related exploration from Automattic: I believe something like this will ultimately become a part of WordPress core – it's such a popular problem. |
Beta Was this translation helpful? Give feedback.
-
@youknowriad @mcsf @ellatrix Does anything in this discussion stand out to you as directionally aligned with core? Anything we can do to help each other? |
Beta Was this translation helpful? Give feedback.
-
As we dove deeper into the development of
try-wordpress
, I noticed some patterns emerge out of the code that made me look at things through a different lens. I wanted to write down these thoughts to clarify my own understanding and to gather feedback, so here goes.How
try-wordpress
works todayToday,
try-wordpress
works as follows. We take the information from the source site, convert it to an intermediate format (json
) and pass it to a custom API endpoint, which will then persist the data wherever it needs to go (e.g.wp_posts
):We have been struggling to define what this intermediate format should look like, which I think is expected because it needs to be able to represent all types of data we'll encounter, so it's not a simple problem to solve.
However, I think there is an alternative approach that would allow us to remove the need for this intermediate format, and bring along additional advantages. The remainder of this post will describe this alternative approach.
High-level overview
If I think of the goal of
try-wordpress
in a really abstract way, I would describe it as allowing a user to easily author a new WordPress site. What differentiatestry-wordpress
however, is that the new WordPress site will be authored from a pre-existing source site. Or in other words:A user traditionally authors a WordPress site by transferring information from their brain into a format that WordPress understands. They do so by using the block editor (or the site editor; from now on, when I mention block editor I mean either the block editor or the site editor):
In
try-wordpress
, the scenario is very similar, but instead of the information coming from the user's brain, it comes from the source site. So we can think oftry-wordpress
as a black box that has the same role that the block editor has in the traditional scenario, which would allow us to represent data flow as follows:This results in there no longer being a need for an intermediate format, and thus neither a custom REST API that transforms the intermediate format to the format that WordPress expects.
This results in a significantly smaller surface where
try-wordpress
needs to operate in. We don't need to implement anything on the right side of the diagrams above, and we're left with the problem of converting the raw information to blocks + attributes (more on this below).Additionally, by speaking the same language as the Block editor,
try-wordpress
would seamlessly integrate into the existing WordPress ecosystem. Because we would make the exact same API calls that the Block editor makes, WordPress would in fact not know or care whether a request came from the block editor or fromtry-wordpress
.Raw information to blocks
As mentioned above, by making
try-wordpress
"block-native", we would be left with the problem of converting raw information to blocks + attributes (the left section in the diagrams above).This is of course a very complex problem, and a solution for such a problem would likely be useful in contexts other than
try-wordpress
. For this reason, I think it would make sense to extract this responsibility out oftry-wordpress
into its own thing, maybe as part of WordPress/wordpress-playground#1888.For the time being, since such a parser does not exist yet, we could implement an ad hoc parser in
try-wordpress
, with the bare minimum functionality needed for us to implement an MVP oftry-wordpress.
Auxiliary data
All that has been written above has to do with user data, i.e. data that comes from the source site. However, for
try-wordpress
to do its function, it also needs to store additional data that relates to the import process itself. As an example, for each imported blog post, we would need to store:This auxiliary data would be persisted through a custom REST API, that we would design to address the specific needs of
try-wordpress
. This would result in the following data flow:Continuing on the blog post example from above, for each imported blog post, we would make requests to the Core API and to the Custom REST API:
Extensibility
One major unknown we have today relates to how to make
try-wordpress
work with any post type. What does a plugin developer need to do to maketry-wordpress
support their plugin? For example, if I develop an e-commerce plugin, how can I make it so that atry-wordpress
user can import their existing e-commerce site into my plugin?Another related subject is that we don't want there to be a need for UI development for every post type we need to support. The UI should seamlessly adapt to the post type, so that it shows the fields that are relevant for that post type. For an e-commerce product, this could be a title, a description and a price.
How can we solve both these problems in
try-wordpress
? If we think oftry-wordpress
as an "alternative block editor" as described in previous sections, then the answer becomes: We do it in the same way the block editor does. To determine what fields a certain post type has, we would make the same API calls that the block editor makes.Now, the answer to the question "What does a plugin developer need to do to make
try-wordpress
support their plugin" is simply: they need to make it work in the block editor, at which point it automatically also works intry-wordpress
.Conclusion
By thinking of
try-wordpress
as a black box that behaves as the block editor (i.e. it makes the same REST API calls as the block editor), we would be able to massively reduce the surface of wheretry-wordpress
needs to operate. We would remove the need for an intermediate format and for custom API endpoints that deal with user data (we'd still have custom endpoints for auxiliary data).Additionally, and more importantly,
try-wordpress
would automatically work with any custom post type, provided that that custom post type works in the block editor.Next steps
If we end up adapting the solution proposed above, I would imagine the next steps to be:
try-wordpress
core features are "done".Beta Was this translation helpful? Give feedback.
All reactions