最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to check if Wordpress object type is already extended by pods

programmeradmin2浏览0评论

I'm looking to dynamically setup some pods housekeeping when a certain plugin is installed.

I can easily check to see if a certain pod object has been set up (and create the pod type programatically if it hasn't) by using the following code:

// Set up the Pods API object
$pods_api = pods_api();

// Check to see if the post type has already been set up
if ( !pods('custom_post_type_1') ) {
    // Create the new post type if it hasn't been set up already
    $new_pod_object_id = $pods_api->add_pod($params);
}

This works for new custom pod types, but how to I check for pods extending an object like WP_User?

I'm looking to dynamically setup some pods housekeeping when a certain plugin is installed.

I can easily check to see if a certain pod object has been set up (and create the pod type programatically if it hasn't) by using the following code:

// Set up the Pods API object
$pods_api = pods_api();

// Check to see if the post type has already been set up
if ( !pods('custom_post_type_1') ) {
    // Create the new post type if it hasn't been set up already
    $new_pod_object_id = $pods_api->add_pod($params);
}

This works for new custom pod types, but how to I check for pods extending an object like WP_User?

Share Improve this question asked Feb 18, 2020 at 23:36 JRad the BadJRad the Bad 1684 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

It turns out that Pods handles this exactly as you would expect.

It doesn't differentiate between completely new post types and extending post types in the Pods API.

To check if the WP_User class is being extended by pods, the method is identical:

// pods() returns false if there's no extended class for `user`
if ( !pods('user') ) { 
    // Do things if there's no extended User set up in Pods
}
发布评论

评论列表(0)

  1. 暂无评论