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

Add snippet for setting meta data automatically. #1063

Merged
merged 4 commits into from
Jun 5, 2023

Conversation

peterwilsoncc
Copy link
Collaborator

@peterwilsoncc peterwilsoncc commented May 30, 2023

Description of the Change

Provides snippet for setting both Distributor and custom meta data using the dt_after_set_meta hook.

Closes #971

How to test the Change

Changelog Entry

Added - Snippets for setting meta data automatically.

Credits

Props @peterwilsoncc, @iamdharmesh.

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@peterwilsoncc peterwilsoncc self-assigned this May 30, 2023
@peterwilsoncc peterwilsoncc added this to the 2.0.0 milestone May 30, 2023
@peterwilsoncc peterwilsoncc force-pushed the do/971-custom-meta-snippet branch from 7aa2c98 to 5e6a6af Compare May 31, 2023 04:49
@peterwilsoncc peterwilsoncc marked this pull request as ready for review May 31, 2023 05:08
@peterwilsoncc peterwilsoncc requested a review from a team as a code owner May 31, 2023 05:08
@peterwilsoncc peterwilsoncc requested review from iamdharmesh and removed request for a team May 31, 2023 05:08
@@ -428,7 +428,7 @@ public function pull( $items ) {
update_post_meta( $new_post, 'dt_full_connection', true );
}

if ( ! empty( $post_array['meta'] ) ) {
if ( isset( $post_array['meta'] ) && is_array( $post_array['meta'] ) ) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty check was preventing the hook from running if there was no meta because empty( [] ) === true. My understanding is that the hook should fire regardless of whether there is or is not meta so I've changed it to fire when the array is set.

@peterwilsoncc peterwilsoncc force-pushed the do/971-custom-meta-snippet branch from 93759bf to f8105f8 Compare June 2, 2023 01:08
Copy link
Member

@iamdharmesh iamdharmesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this @peterwilsoncc. Snippets working fine. LGTM 🚀

@peterwilsoncc peterwilsoncc merged commit 6861c43 into develop Jun 5, 2023
@peterwilsoncc peterwilsoncc deleted the do/971-custom-meta-snippet branch June 5, 2023 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide example for setting custom meta data in snippits.
2 participants