当前位置: 首页>>代码示例>>PHP>>正文


PHP PodsForm::fields_setup方法代码示例

本文整理汇总了PHP中PodsForm::fields_setup方法的典型用法代码示例。如果您正苦于以下问题:PHP PodsForm::fields_setup方法的具体用法?PHP PodsForm::fields_setup怎么用?PHP PodsForm::fields_setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PodsForm的用法示例。


在下文中一共展示了PodsForm::fields_setup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: foreach

</div>
<?php 
}
foreach ($tabs as $tab => $tab_label) {
    $tab = sanitize_title($tab);
    if (in_array($tab, array('manage-fields', 'labels', 'advanced', 'extra-fields')) || !isset($tab_options[$tab]) || empty($tab_options[$tab])) {
        continue;
    }
    ?>
    <div id="pods-<?php 
    echo esc_attr($tab);
    ?>
" class="pods-nav-tab pods-manage-field pods-dependency pods-submittable-fields">
        <?php 
    $fields = $tab_options[$tab];
    $field_options = PodsForm::fields_setup($fields);
    $field = $pod;
    include PODS_DIR . 'ui/admin/field-option.php';
    ?>
    </div>
<?php 
}
if (isset($tabs['extra-fields'])) {
    ?>
<div id="pods-extra-fields" class="pods-nav-tab">
    <p><?php 
    _e('Taxonomies do not support extra fields natively, but Pods can add this feature for you easily. Table based storage will operate in a way where each field you create for your content type becomes a field in a table.', 'pods');
    ?>
</p>

    <p><?php 
开发者ID:jeremybradbury,项目名称:wp-ninja-kit,代码行数:31,代码来源:setup-edit.php

示例2: group_add

 /**
  * Add a meta group of fields to add/edit forms
  *
  * @param string|array $pod The pod or type of element to attach the group to.
  * @param string $label Title of the edit screen section, visible to user.
  * @param string|array $fields Either a comma separated list of text fields or an associative array containing field infomration.
  * @param string $context (optional) The part of the page where the edit screen section should be shown ('normal', 'advanced', or 'side').
  * @param string $priority (optional) The priority within the context where the boxes should show ('high', 'core', 'default' or 'low').
  *
  * @since 2.0
  *
  * @return mixed|void
  */
 public function group_add($pod, $label, $fields, $context = 'normal', $priority = 'default')
 {
     if (!is_array($pod)) {
         $_pod = pods_api()->load_pod(array('name' => $pod), false);
         if (!empty($_pod)) {
             $pod = $_pod;
         } else {
             $type = 'post_type';
             if (in_array($pod, array('media', 'user', 'comment'))) {
                 $type = $pod;
             }
             $pod = array('name' => $pod, 'type' => $type);
         }
     }
     if (is_array($pod) && !isset($pod['id'])) {
         $defaults = array('name' => '', 'type' => 'post_type');
         $pod = array_merge($defaults, $pod);
     }
     if ('post' == $pod['type']) {
         $pod['type'] = 'post_type';
     }
     if (empty($pod['name']) && isset($pod['object']) && !empty($pod['object'])) {
         $pod['name'] = $pod['object'];
     } elseif (!isset($pod['object']) || empty($pod['object'])) {
         $pod['object'] = $pod['name'];
     }
     if (empty($pod['object'])) {
         return pods_error(__('Object required to add a Pods meta group', 'pods'));
     }
     $object_name = $pod['object'];
     if ('pod' == $pod['type']) {
         $object_name = $pod['name'];
     }
     if (!isset(self::$groups[$pod['type']])) {
         self::$groups[$pod['type']] = array();
     }
     if (!isset(self::$groups[$pod['type']][$object_name])) {
         self::$groups[$pod['type']][$object_name] = array();
     }
     $_fields = array();
     if (!is_array($fields)) {
         $fields = explode(',', $fields);
     }
     foreach ($fields as $k => $field) {
         $name = $k;
         $defaults = array('name' => $name, 'label' => $name, 'type' => 'text');
         if (!is_array($field)) {
             $name = trim($field);
             $field = array('name' => $name, 'label' => $name);
         }
         $field = array_merge($defaults, $field);
         $field['name'] = trim($field['name']);
         if (isset($pod['fields']) && isset($pod['fields'][$field['name']])) {
             $field = array_merge($field, $pod['fields'][$field['name']]);
         }
         $_fields[$k] = $field;
     }
     // Setup field options
     $fields = PodsForm::fields_setup($_fields);
     $group = array('pod' => $pod, 'label' => $label, 'fields' => $fields, 'context' => $context, 'priority' => $priority);
     // Filter group data, pass vars separately for reference down the line (in case array changed by other filter)
     $group = apply_filters('pods_meta_group_add_' . $pod['type'] . '_' . $object_name, $group, $pod, $label, $fields);
     $group = apply_filters('pods_meta_group_add_' . $pod['type'], $group, $pod, $label, $fields);
     $group = apply_filters('pods_meta_group_add', $group, $pod, $label, $fields);
     self::$groups[$pod['type']][$object_name][] = $group;
     // Hook it up!
     if ('post_type' == $pod['type']) {
         if (!has_action('add_meta_boxes', array($this, 'meta_post_add'))) {
             add_action('add_meta_boxes', array($this, 'meta_post_add'));
         }
         /*if ( !has_action( 'save_post', array( $this, 'save_post' ), 10, 2 ) )
           add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );*/
     } elseif ('taxonomy' == $pod['type']) {
         if (!has_action($pod['object'] . '_edit_form_fields', array($this, 'meta_taxonomy'), 10, 2)) {
             add_action($pod['object'] . '_edit_form_fields', array($this, 'meta_taxonomy'), 10, 2);
             add_action($pod['object'] . '_add_form_fields', array($this, 'meta_taxonomy'), 10, 1);
         }
         if (!has_action('edit_term', array($this, 'save_taxonomy'), 10, 3)) {
             add_action('edit_term', array($this, 'save_taxonomy'), 10, 3);
             add_action('create_term', array($this, 'save_taxonomy'), 10, 3);
         }
     } elseif ('media' == $pod['type']) {
         if (!has_filter('wp_update_attachment_metadata', array($this, 'save_media'), 10, 2)) {
             if (pods_version_check('wp', '3.5')) {
                 add_action('add_meta_boxes', array($this, 'meta_post_add'));
                 add_action('wp_ajax_save-attachment-compat', array($this, 'save_media_ajax'), 0);
             }
//.........这里部分代码省略.........
开发者ID:centaurustech,项目名称:chipin,代码行数:101,代码来源:PodsMeta.php

示例3: get_wp_object_fields

 /**
  * Get a list of core WP object fields for a specific object
  *
  * @param string $object The pod type to look for, possible values: post_type, user, comment, taxonomy
  * @param array $pod Array of Pod data
  * @param boolean $refresh Whether to force refresh the information
  *
  * @return array Array of fields
  *
  * @since 2.0
  */
 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('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()), '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('pick_format_type' => 'multi'));
             }
         }
     } elseif ('user' == $object) {
         $fields = array('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_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')), '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('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('term_taxonomy_id'), 'hidden' => true), 'term_group' => array('name' => 'term_group', 'label' => 'Term Group', 'type' => 'number', 'alias' => array('term_group'), 'hidden' => true), 'count' => array('name' => 'count', 'label' => 'Count', 'type' => 'number', 'alias' => array('count'), 'hidden' => true));
     }
     $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;
 }
开发者ID:satokora,项目名称:IT354Project,代码行数:59,代码来源:PodsAPI.php

示例4: select

 /**
  * Select items, eventually building dynamic query
  *
  * @param array $params
  *
  * @return array|bool|mixed
  * @since 2.0
  */
 public function select($params)
 {
     global $wpdb;
     $cache_key = $results = false;
     // Debug purposes
     if (1 == pods_var('pods_debug_params', 'get', 0) && pods_is_admin(array('pods'))) {
         pods_debug($params);
     }
     // Get from cache if enabled
     if (null !== pods_var('expires', $params, null, null, true)) {
         $cache_key = md5(serialize(get_object_vars($params)));
         $results = pods_view_get($cache_key, pods_var('cache_mode', $params, 'cache', null, true), 'pods_data_select');
         if (empty($results)) {
             $results = false;
         }
     }
     if (empty($results)) {
         // Build
         $this->sql = $this->build($params);
         // Debug purposes
         if ((1 == pods_var('pods_debug_sql', 'get', 0) || 1 == pods_var('pods_debug_sql_all', 'get', 0)) && pods_is_admin(array('pods'))) {
             echo '<textarea cols="100" rows="24">' . str_replace(array('@wp_users', '@wp_'), array($wpdb->users, $wpdb->prefix), $this->sql) . '</textarea>';
         }
         if (empty($this->sql)) {
             return array();
         }
         // Get Data
         $results = pods_query($this->sql, $this);
         // Cache if enabled
         if (false !== $cache_key) {
             pods_view_set($cache_key, $results, pods_var('expires', $params, 0, null, true), pods_var('cache_mode', $params, 'cache', null, true), 'pods_data_select');
         }
     }
     $results = $this->do_hook('select', $results);
     $this->data = $results;
     $this->row_number = -1;
     // Fill in empty field data (if none provided)
     if ((!isset($this->fields) || empty($this->fields)) && !empty($this->data)) {
         $this->fields = array();
         $data = (array) @current($this->data);
         foreach ($data as $data_key => $data_value) {
             $this->fields[$data_key] = array('label' => ucwords(str_replace('-', ' ', str_replace('_', ' ', $data_key))));
         }
         $this->fields = PodsForm::fields_setup($this->fields);
     }
     $this->total_found_calculated = false;
     $this->total = count((array) $this->data);
     return $this->data;
 }
开发者ID:Ingenex,项目名称:redesign,代码行数:57,代码来源:PodsData.php


注:本文中的PodsForm::fields_setup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。