Stored ID handling - Phase 2#1309
Conversation
…nitial callback function for term.
dkotter
left a comment
There was a problem hiding this comment.
Haven't had time to actually test this but from a code perspective, this looks really good to me. Left a handful of minor comments
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
|
Finally, E2E tests are now passing in all env and we are ready to go with this. |
|
@iamdharmesh @peterwilsoncc would be great to sort out any updates needed from Peter's latest review so we can get this merged and ready for a v2.2 release |
peterwilsoncc
left a comment
There was a problem hiding this comment.
This looks great, thank you.
My one thought is to make sure the post and term IDs differ between the two sites by adding the following to the end of initialize.sh
# Create some posts to bump the post IDs so they differ between the two sites.
wp-env run tests-cli wp post generate --count=10 --post_type=post --post_author=1
wp-env run tests-cli wp post generate --count=20 --post_type=post --post_author=1 --url=localhost/second
# Now delete the posts created by the test suite
wp-env run tests-cli wp post delete $(wp-env run tests-cli wp post list --post_type=post --format=ids) --force
wp-env run tests-cli wp post delete $(wp-env run tests-cli wp post list --post_type=post --format=ids --url=localhost/second) --url=localhost/second --force
# Create some terms to bump the term IDs so they differ between the two sites.
wp-env run tests-cli wp term generate category --count=10
wp-env run tests-cli wp term generate category --count=20 --url=localhost/second
# Now delete the terms created by the test suite
wp-env run tests-cli wp term delete category $(wp-env run tests-cli wp term list category --format=ids)
wp-env run tests-cli wp term delete category $(wp-env run tests-cli wp term list category --format=ids --url=localhost/second) --url=localhost/secondIt's not a blocker so I'll approve now and you can decide.
Thanks for suggestion @peterwilsoncc. This is added and PR is ready for merge. |
Description of the Change
This PR is the Phase 2 of the "Stored ID handling" work we began in #1302.
It introduces a new
typekey in the$argsparameter ofdistributor_register_data. This allows users to utilize the default pre/post callback functions we've implemented for common entities like posts, terms, and media. For these types of entities, users no longer need to write custom pre/post callbacks, they can simply provide the data type, location, and attribute, and the default callback functions will handle the rest.Example:
An image ID stored in post meta under the key
example_image_idwould be handled like this: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.post,mediaandtermtype.Changelog Entry
Credits
Props @dkotter @iamdharmesh
Checklist: