Is there a reason that you use the static getPostType() method inside of save(), instead of first checking if the instance has $this->postType set?
I'm looking at using WP_Model as part of a user-configurable syncing process, so hard-coded classes won't exist. Instead, based on the configuration that the user has set up, I want to create an instance of $userConfedPostType = new MyDynamicPostType(), set $userConfedPostType->postType, set the data and then call $userConfedPostType->save().
MyDynamicPostType extends WP_Model to handle the custom syncing details.
$userConfedPostType->save() fails because save() calls WP_Model::getPostType() which uses reflection to check the post type in the base class, and completely ignores the postType value that I have set.
I'm happy to fork and apply my changes, but I'm wondering if I missed some a reason for it, or if I'm just trying to do something that's unsupported.
Hi Anthony,
Is there a reason that you use the static getPostType() method inside of save(), instead of first checking if the instance has
$this->postType
set?I'm looking at using WP_Model as part of a user-configurable syncing process, so hard-coded classes won't exist. Instead, based on the configuration that the user has set up, I want to create an instance of
$userConfedPostType = new MyDynamicPostType()
, set$userConfedPostType->postType
, set the data and then call$userConfedPostType->save()
.MyDynamicPostType
extendsWP_Model
to handle the custom syncing details.$userConfedPostType->save()
fails becausesave()
callsWP_Model::getPostType()
which uses reflection to check the post type in the base class, and completely ignores the postType value that I have set.I'm happy to fork and apply my changes, but I'm wondering if I missed some a reason for it, or if I'm just trying to do something that's unsupported.
Thanks, Michael Moore