public function get_wp_object_fields($object = 'post_type', $pod = null, $refresh = false)
{
$pod_name = pods_var_raw('name', $pod, $object, null, true);
if ('media' == $pod_name) {
$object = 'post_type';
$pod_name = 'attachment';
}
$fields = false;
if (pods_api_cache()) {
$fields = pods_transient_get(trim('pods_api_object_fields_' . $object . $pod_name . '_', '_'));
}
if (false !== $fields && !$refresh) {
return $this->do_hook('get_wp_object_fields', $fields, $object, $pod);
}
$fields = array();
if ('post_type' == $object) {
$fields = array('ID' => array('name' => 'ID', 'label' => 'ID', 'type' => 'number', 'alias' => array('id'), 'options' => array('number_format' => '9999.99')), 'post_title' => array('name' => 'post_title', 'label' => 'Title', 'type' => 'text', 'alias' => array('title', 'name'), 'options' => array('display_filter' => 'the_title', 'display_filter_args' => array('post_ID'))), 'post_content' => array('name' => 'post_content', 'label' => 'Content', 'type' => 'wysiwyg', 'alias' => array('content'), 'options' => array('wysiwyg_allowed_html_tags' => '', 'display_filter' => 'the_content', 'pre_save' => 0)), 'post_excerpt' => array('name' => 'post_excerpt', 'label' => 'Excerpt', 'type' => 'paragraph', 'alias' => array('excerpt'), 'options' => array('paragraph_allow_html' => 1, 'paragraph_allowed_html_tags' => '', 'display_filter' => 'the_excerpt', 'pre_save' => 0)), 'post_author' => array('name' => 'post_author', 'label' => 'Author', 'type' => 'pick', 'alias' => array('author'), 'pick_object' => 'user', 'options' => array('pick_format_type' => 'single', 'pick_format_single' => 'autocomplete', 'default_value' => '{@user.ID}')), 'post_date' => array('name' => 'post_date', 'label' => 'Publish Date', 'type' => 'datetime', 'alias' => array('created', 'date')), 'post_date_gmt' => array('name' => 'post_date_gmt', 'label' => 'Publish Date (GMT)', 'type' => 'datetime', 'alias' => array(), 'hidden' => true), 'post_status' => array('name' => 'post_status', 'label' => 'Status', 'type' => 'pick', 'pick_object' => 'post-status', 'default' => $this->do_hook('default_status_' . $pod_name, pods_var('default_status', pods_var_raw('options', $pod), 'draft', null, true), $pod), 'alias' => array('status')), 'comment_status' => array('name' => 'comment_status', 'label' => 'Comment Status', 'type' => 'text', 'default' => get_option('default_comment_status', 'open'), 'alias' => array(), 'data' => array('open' => __('Open', 'pods'), 'closed' => __('Closed', 'pods'))), 'ping_status' => array('name' => 'ping_status', 'label' => 'Ping Status', 'default' => get_option('default_ping_status', 'open'), 'type' => 'text', 'alias' => array(), 'data' => array('open' => __('Open', 'pods'), 'closed' => __('Closed', 'pods'))), 'post_password' => array('name' => 'post_password', 'label' => 'Password', 'type' => 'text', 'alias' => array()), 'post_name' => array('name' => 'post_name', 'label' => 'Permalink', 'type' => 'slug', 'alias' => array('slug', 'permalink')), 'to_ping' => array('name' => 'to_ping', 'label' => 'To Ping', 'type' => 'text', 'alias' => array(), 'hidden' => true), 'pinged' => array('name' => 'pinged', 'label' => 'Pinged', 'type' => 'text', 'alias' => array(), 'hidden' => true), 'post_modified' => array('name' => 'post_modified', 'label' => 'Last Modified Date', 'type' => 'datetime', 'alias' => array('modified'), 'hidden' => true), 'post_modified_gmt' => array('name' => 'post_modified_gmt', 'label' => 'Last Modified Date (GMT)', 'type' => 'datetime', 'alias' => array(), 'hidden' => true), 'post_content_filtered' => array('name' => 'post_content_filtered', 'label' => 'Content (filtered)', 'type' => 'paragraph', 'alias' => array(), 'hidden' => true, 'options' => array('paragraph_allow_html' => 1, 'paragraph_oembed' => 1, 'paragraph_wptexturize' => 1, 'paragraph_convert_chars' => 1, 'paragraph_wpautop' => 1, 'paragraph_allow_shortcode' => 1, 'paragraph_allowed_html_tags' => '')), 'post_parent' => array('name' => 'post_parent', 'label' => 'Parent', 'type' => 'pick', 'pick_object' => 'post_type', 'pick_val' => '__current__', 'alias' => array('parent'), 'data' => array(), 'hidden' => true), 'guid' => array('name' => 'guid', 'label' => 'GUID', 'type' => 'text', 'alias' => array(), 'hidden' => true), 'menu_order' => array('name' => 'menu_order', 'label' => 'Menu Order', 'type' => 'number', 'alias' => array(), 'options' => array('number_format' => '9999.99')), 'post_type' => array('name' => 'post_type', 'label' => 'Type', 'type' => 'text', 'alias' => array('type'), 'hidden' => true), 'post_mime_type' => array('name' => 'post_mime_type', 'label' => 'Mime Type', 'type' => 'text', 'alias' => array(), 'hidden' => true), 'comment_count' => array('name' => 'comment_count', 'label' => 'Comment Count', 'type' => 'number', 'alias' => array(), 'hidden' => true));
if (!empty($pod)) {
$taxonomies = get_object_taxonomies($pod_name, 'objects');
foreach ($taxonomies as $taxonomy) {
$fields[$taxonomy->name] = array('name' => $taxonomy->name, 'label' => $taxonomy->labels->name, 'type' => 'taxonomy', 'pick_object' => 'taxonomy', 'pick_val' => $taxonomy->name, 'alias' => array(), 'hidden' => true, 'options' => array('taxonomy_format_type' => 'multi'));
}
}
} elseif ('user' == $object) {
$fields = array('ID' => array('name' => 'ID', 'label' => 'ID', 'type' => 'number', 'alias' => array('id'), 'options' => array('number_format' => '9999.99')), 'user_login' => array('name' => 'user_login', 'label' => 'Title', 'type' => 'text', 'alias' => array('login'), 'options' => array('required' => 1)), 'user_nicename' => array('name' => 'user_nicename', 'label' => 'Permalink', 'type' => 'slug', 'alias' => array('nicename', 'slug', 'permalink')), 'display_name' => array('name' => 'display_name', 'label' => 'Display Name', 'type' => 'text', 'alias' => array('title', 'name')), 'user_pass' => array('name' => 'user_pass', 'label' => 'Password', 'type' => 'text', 'alias' => array('password', 'pass'), 'options' => array('required' => 1, 'text_format_type' => 'password')), 'user_email' => array('name' => 'user_email', 'label' => 'E-mail', 'type' => 'text', 'alias' => array('email'), 'options' => array('required' => 1, 'text_format_type' => 'email')), 'user_url' => array('name' => 'user_url', 'label' => 'URL', 'type' => 'text', 'alias' => array('url', 'website'), 'options' => array('required' => 0, 'text_format_type' => 'website', 'text_format_website' => 'normal')), 'user_registered' => array('name' => 'user_registered', 'label' => 'Registration Date', 'type' => 'date', 'alias' => array('created', 'date', 'registered'), 'options' => array('date_format_type' => 'datetime')));
} elseif ('comment' == $object) {
$fields = array('comment_ID' => array('name' => 'comment_ID', 'label' => 'ID', 'type' => 'number', 'alias' => array('id', 'ID', 'comment_id'), 'options' => array('number_format' => '9999.99')), 'comment_content' => array('name' => 'comment_content', 'label' => 'Content', 'type' => 'wysiwyg', 'alias' => array('content')), 'comment_approved' => array('name' => 'comment_approved', 'label' => 'Approved', 'type' => 'number', 'alias' => array('approved'), 'options' => array('number_format' => '9999.99')), 'comment_post_ID' => array('name' => 'comment_post_ID', 'label' => 'Post', 'type' => 'pick', 'alias' => array('post', 'post_id'), 'data' => array()), 'user_id' => array('name' => 'user_id', 'label' => 'Author', 'type' => 'pick', 'alias' => array('author'), 'pick_object' => 'user', 'data' => array()), 'comment_date' => array('name' => 'comment_date', 'label' => 'Date', 'type' => 'date', 'alias' => array('created', 'date'), 'options' => array('date_format_type' => 'datetime')), 'comment_author' => array('name' => 'comment_author', 'label' => 'Author', 'type' => 'text', 'alias' => array('author')), 'comment_author_email' => array('name' => 'comment_author_email', 'label' => 'Author E-mail', 'type' => 'email', 'alias' => array('author_email')), 'comment_author_url' => array('name' => 'comment_author_url', 'label' => 'Author URL', 'type' => 'text', 'alias' => array('author_url')), 'comment_author_IP' => array('name' => 'comment_author_IP', 'label' => 'Author IP', 'type' => 'text', 'alias' => array('author_IP')), 'comment_type' => array('name' => 'comment_type', 'label' => 'Type', 'type' => 'text', 'alias' => array('type'), 'hidden' => true), 'comment_parent' => array('name' => 'comment_parent', 'label' => 'Parent', 'type' => 'pick', 'pick_object' => 'comment', 'pick_val' => '__current__', 'alias' => array('parent'), 'data' => array(), 'hidden' => true));
} elseif ('taxonomy' == $object) {
$fields = array('term_id' => array('name' => 'term_id', 'label' => 'ID', 'type' => 'number', 'alias' => array('id', 'ID'), 'options' => array('number_format' => '9999.99')), 'name' => array('name' => 'name', 'label' => 'Title', 'type' => 'text', 'alias' => array('title')), 'slug' => array('name' => 'slug', 'label' => 'Permalink', 'type' => 'slug', 'alias' => array('permalink')), 'description' => array('name' => 'description', 'label' => 'Description', 'type' => 'wysiwyg', 'alias' => array('content')), 'taxonomy' => array('name' => 'taxonomy', 'label' => 'Taxonomy', 'type' => 'pick', 'alias' => array()), 'parent' => array('name' => 'parent', 'label' => 'Parent', 'type' => 'pick', 'pick_object' => 'taxonomy', 'pick_val' => '__current__', 'alias' => array('parent'), 'data' => array(), 'hidden' => true), 'term_taxonomy_id' => array('name' => 'term_taxonomy_id', 'label' => 'Term Taxonomy ID', 'type' => 'number', 'alias' => array(), 'hidden' => true, 'options' => array('number_format' => '9999.99')), 'term_group' => array('name' => 'term_group', 'label' => 'Term Group', 'type' => 'number', 'alias' => array('group'), 'hidden' => true, 'options' => array('number_format' => '9999.99')), 'count' => array('name' => 'count', 'label' => 'Count', 'type' => 'number', 'alias' => array(), 'hidden' => true, 'options' => array('number_format' => '9999.99')));
}
$fields = $this->do_hook('get_wp_object_fields', $fields, $object, $pod);
foreach ($fields as $field => $options) {
if (!isset($options['alias'])) {
$options['alias'] = array();
} else {
$options['alias'] = (array) $options['alias'];
}
if (!isset($options['name'])) {
$options['name'] = $field;
}
$fields[$field] = $options;
}
$fields = PodsForm::fields_setup($fields);
if (did_action('init') && pods_api_cache()) {
pods_transient_set(trim('pods_api_object_fields_' . $object . $pod_name . '_', '_'), $fields);
}
return $fields;
}