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

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?

Topic pods-framework custom-post-types Wordpress

Category Web


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
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.