-
Notifications
You must be signed in to change notification settings - Fork 158
Stored ID handling - Phase 1 #1302
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
Conversation
|
E2E tests with WP trunk are failing due to an issue in |
dkotter
left a comment
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 didn't do a super thorough test of everything here but overall code looks good to me and the tests I have done also look good. Since this is just phase 1 of a larger effort, I'd love to see this get merged in so we can work on the next piece
|
@peterwilsoncc Dharmesh mentioned you may want to review / have already reviewed this PR and may have some feedback to provide. If you get a chance to add that feedback, that would be great so we can get this merged and start progress on phase 2 of this feature |
peterwilsoncc
left a comment
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.
Added a few notes, as discussed they're mainly nitpicks.
…ributor into enhancement/stored-id-handling
peterwilsoncc
left a comment
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.
Thanks for the follow up, this looks good for merge.
…t/stored-id-handling
Sidsector9
left a comment
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.
Re-approving only to enable merging.
Description of the Change
This PR introduces a new helper function,
distributor_register_data, which enables developers to register stored data references, such as IDs stored in post meta, shortcodes, or block attributes and define custom pre-distribution and post-distribution callbacks to process these references.Function Definition
distributor_register_dataThis function registers a piece of data by providing details about its location and the callbacks needed to process it during distribution.
Parameters
$data_name(string): The unique identifier for the data.$args(array): An array of parameters that describe:location(string): Where the data is stored. Accepted values are'post_meta'or'post_content'.attributes(array): Additional details depending on the location:meta_key(string): The post meta key. (Required)shortcode(string): The shortcode tag. (Required)shortcode_attribute(string|array): The attribute(s) containing the data. (Required)block_name(string): The block name. (Required)block_attribute(string|array): The attribute(s) containing the data. (Required)pre_distribute_cb(callable): A callback function that prepares the data on the source site before distribution. It should return extra data required for processing on the target site.post_distribute_cb(callable): A callback function that processes the extra data on the target site and returns the updated ID to replace the source reference.I have added detailed information on how this function works along with examples. You can view them here.
Note
How to test the Change
You can find examples of data registration using the
distributor_register_datafunction in the documentation and the e2e-test-plugin file. But please feel free to experiment on your own for something different.distributor_register_datafor specific stored IDs infunctions.phpor in a custom plugin.distributor_register_data.distributor_register_data.shortcode_attribute, to ensure everything works as expected.distributor_register_data.block_attribute, to ensure everything works as expected.Changelog Entry
Credits
Props @dkotter, @iamdharmesh
Checklist: