corcel / acf

Advanced Custom Fields (ACF) plugin for Corcel
128 stars 100 forks source link

Make compatible with taxonomies #16

Closed marcoboom closed 6 years ago

marcoboom commented 7 years ago

Hi @jgrossi,

What do you think what would be the impact to make the ACF package compatible with taxonomies?

All Field class has now a dependency with the Post class, can we make that dynamic?

jgrossi commented 7 years ago

@marcoboom hey! you mean instead of passing a Post object a Model one?

marcoboom commented 7 years ago

If both Post and Taxonomy extends Model, then that would solve the typehinting issue. Do you think that is the only issue for getting this work?

jgrossi commented 7 years ago

@marcoboom actually I don't see reasons to that:

Post::find(1)->acf->text('name'); // ok

I think when would I do this?

Post::find(1)->taxonomy(...)->acf->text(..);

ACF fields are related to posts only. Or am I wrong? :-)

marcoboom commented 7 years ago

@jgrossi No, ACF fields kan be available on Posts, Taxonomies, Users and even special admin option pages.

Big issue I think is that meta data of taxonomies are saved in another table: wp_termmeta

jgrossi commented 7 years ago

@marcoboom hm got it... yep, maybe just verifying if $model instanceof Taxonomy getting data from wp_termmeta, else if it's a Post get from wp_postmeta like it currently does...

but I think this is a great addition btw ;-)

tlaverdure commented 7 years ago

Is there a PR being submitted for this?

tlaverdure commented 7 years ago

Sent some PRs let me know what you think @jgrossi