-
Notifications
You must be signed in to change notification settings - Fork 0
(feat): termdata #61
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
(feat): termdata #61
Conversation
|
Coverage report for commit: 762360f Summary - Lines: 11.30% | Methods: 5.88%
🤖 comment via lucassabreu/comment-coverage-clover |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ee88c69 to
3b0b9a0
Compare
3b0b9a0 to
03ce64a
Compare
src/Attributes/Meta.php
Outdated
| } | ||
|
|
||
| public function getValue(int $postID, string $metaKey, string $prefix): mixed | ||
| public function getValue(string|int $postID, string $metaKey, string $prefix): mixed |
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.
Goeie, dit om ACF niet te laten breken toch?
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.
Klopt, de werking van get_field is een beetje vreemd: https://www.advancedcustomfields.com/resources/get_field/#get-a-value-from-different-objects
SimonvanWijhe
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.
Nog wel even een voorbeeld aan de README.md toevoegen.
src/Traits/HasMeta.php
Outdated
| return $metaPrefixAttribute?->newInstance()->prefix ?? ''; | ||
| } | ||
|
|
||
| private function postID(): string|int |
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.
postID() is hier niet helemaal juist. WordPress noemt dit $object_id https://developer.wordpress.org/reference/functions/get_metadata dus ik zou deze method objectID noemen.
YvetteNikolov
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.
Jeej 🎉
Kun je de README updaten? En dan specifiek wat voorbeelden van hoe je het kan gebruiken in PHP / Blade templates voor de domme frontenders? https://github.com/yardinternet/yard-data#reading-terms-from-your-data-object
This pull request refactors how meta fields are loaded for data objects, introducing a reusable trait to centralize and simplify meta loading logic. It also adds flexibility to taxonomy attribute handling and improves type compatibility for meta operations. The main changes are grouped below:
Meta loading refactor and code reuse:
HasMetatrait (src/Traits/HasMeta.php) that encapsulates the logic for loading meta fields, determining meta prefixes, and resolving IDs for both posts and terms. This trait is now used by bothPostDataandTermData, removing duplicated code and improving maintainability.PostDataandTermDatato use theHasMetatrait, and refactored their constructors to callloadMeta()without requiring an explicit ID parameter. This centralizes meta-loading behavior and ensures consistency. [1] [2] [3]PostData, as this logic is handled by the new trait.Attribute and type improvements:
Termsattribute to accept a custom data class for term collection, increasing flexibility for term data mapping. ThegetValuemethod now uses the specified data class instead of being hardcoded toTermData. [1] [2]Metaattribute'sgetValuemethod to accept both string and integer post IDs, improving compatibility with different ID formats.Other minor cleanup:
PostData.phpfor clarity.