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


PHP wpcf_admin_is_repetitive函数代码示例

本文整理汇总了PHP中wpcf_admin_is_repetitive函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_is_repetitive函数的具体用法?PHP wpcf_admin_is_repetitive怎么用?PHP wpcf_admin_is_repetitive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: wpcf_api_field_meta_value_repetitive

/**
 * Gets repetitive meta value.
 * 
 * @global type $wpcf
 * @param type $field
 * @param type $post_id
 * @param type $meta_id
 * @return type 
 */
function wpcf_api_field_meta_value_repetitive($field, $post_id = null, $meta_id = null)
{
    global $wpcf;
    // Set post
    $post = $wpcf->api->set_post($post_id);
    // Set field
    $wpcf->repeater->set($post, $field);
    $meta = $wpcf->repeater->meta;
    // See if single
    if (!wpcf_admin_is_repetitive($field)) {
        return isset($meta['single']) ? $meta['single'] : null;
    }
    // Return single repetitive field value if meta_id specified
    if (!is_null($meta_id) && isset($meta['by_meta_id'][$meta_id])) {
        return $meta['by_meta_id'][$meta_id];
    }
    // Return ordered
    if (isset($wpcf->repeater->meta['custom_order'])) {
        return $wpcf->repeater->meta['custom_order'];
    }
    // Return by_meta_id
    if (isset($wpcf->repeater->meta['by_meta_id'])) {
        return $wpcf->repeater->meta['by_meta_id'];
    }
    return array();
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:35,代码来源:api.php

示例2: prepare_field_select_screen

 /**
  * Summary.
  *
  * Description.
  *
  * @since x.x.x
  * @access (for functions: only use if private)
  *
  * @see Function/method/class relied on
  * @link URL
  * @global type $varname Description.
  * @global type $varname Description.
  *
  * @param type $var Description.
  * @param type $var Optional. Description.
  * @return type Description.
  */
 public function prepare_field_select_screen()
 {
     /**
      * check nonce
      */
     if (0 || !isset($_REQUEST['_wpnonce']) || !isset($_REQUEST['parent']) || !isset($_REQUEST['child']) || !wp_verify_nonce($_REQUEST['_wpnonce'], $this->get_nonce('child-post-fields', $_REQUEST['parent'], $_REQUEST['child']))) {
         $this->verification_failed_and_die();
     }
     $parent = $_REQUEST['parent'];
     $child = $_REQUEST['child'];
     $post_type_parent = get_post_type_object($parent);
     $post_type_child = get_post_type_object($child);
     if (empty($post_type_parent) || empty($post_type_child)) {
         die(__('Wrong post types', 'wpcf'));
     }
     $relationships = get_option('wpcf_post_relationship', array());
     if (!isset($relationships[$parent][$child])) {
         $this->print_notice_and_die(__('Please save Post Type first to edit these fields.', 'wpcf'));
     }
     $repetitive_warning_markup = array();
     $data = $relationships[$parent][$child];
     $form = array();
     $form['repetitive_warning_markup'] = $repetitive_warning_markup;
     $form['select'] = array('#type' => 'radios', '#name' => 'fields_setting', '#options' => array(__('Title, all custom fields and parents', 'wpcf') => 'all_cf', __('Do not show management options for this post type', 'wpcf') => 'only_list', __('All fields, including the standard post fields', 'wpcf') => 'all_cf_standard', __('Specific fields', 'wpcf') => 'specific'), '#attributes' => array('display' => 'ul'), '#default_value' => empty($data['fields_setting']) ? 'all_cf' : $data['fields_setting']);
     /**
      * check default, to avoid missing configuration
      */
     if (!in_array($form['select']['#default_value'], $form['select']['#options'])) {
         $form['select']['#default_value'] = 'all_cf';
     }
     /**
      * Specific options
      */
     $groups = wpcf_admin_get_groups_by_post_type($child);
     $options_cf = array();
     $repetitive_warning = false;
     $repetitive_warning_txt = __('Repeating fields should not be used in child posts. Types will update all field values.', 'wpcf');
     foreach ($groups as $group) {
         $fields = wpcf_admin_fields_get_fields_by_group($group['id']);
         foreach ($fields as $key => $cf) {
             $__key = wpcf_types_cf_under_control('check_outsider', $key) ? $key : WPCF_META_PREFIX . $key;
             $options_cf[$__key] = array('#title' => $cf['name'], '#name' => 'fields[' . $__key . ']', '#default_value' => isset($data['fields'][$__key]) ? 1 : 0, '#inline' => true, '#before' => '<li>', '#after' => '</li>');
             // Repetitive warning
             if (wpcf_admin_is_repetitive($cf)) {
                 if (!$repetitive_warning) {
                     $repetitive_warning_markup = array('#type' => 'markup', '#markup' => '<div class="message error" style="display:none;" id="wpcf-repetitive-warning"><p>' . $repetitive_warning_txt . '</p></div>');
                 }
                 $repetitive_warning = true;
                 $options_cf[$__key]['#after'] = !isset($data['fields'][$__key]) ? '<div class="message error" style="display:none;"><p>' : '<div class="message error"><p>';
                 $options_cf[$__key]['#after'] .= $repetitive_warning_txt;
                 $options_cf[$__key]['#after'] .= '</p></div></li>';
                 $options_cf[$__key]['#attributes'] = array('onclick' => 'jQuery(this).parent().find(\'.message\').toggle();', 'disabled' => 'disabled');
             }
         }
     }
     /**
      * build options for "Specific fields"
      */
     $options = array();
     /**
      * check and add built-in properites
      */
     require_once WPCF_INC_ABSPATH . '/post-relationship.php';
     $supports = wpcf_post_relationship_get_supported_fields_by_post_type($child);
     foreach ($supports as $child_field_key => $child_field_data) {
         $options[$child_field_data['name']] = array('#title' => $child_field_data['title'], '#name' => sprintf('fields[%s]', $child_field_data['name']), '#default_value' => isset($data['fields'][$child_field_data['name']]) ? 1 : 0, '#inline' => true, '#before' => '<li>', '#after' => '</li>');
     }
     /**
      * add custom fields
      */
     $options = $options + $options_cf;
     $temp_belongs = wpcf_pr_admin_get_belongs($child);
     foreach ($temp_belongs as $temp_parent => $temp_data) {
         if ($temp_parent == $parent) {
             continue;
         }
         $temp_parent_type = get_post_type_object($temp_parent);
         $options[$temp_parent] = array('#title' => $temp_parent_type->label, '#name' => 'fields[_wpcf_pr_parents][' . $temp_parent . ']', '#default_value' => isset($data['fields']['_wpcf_pr_parents'][$temp_parent]) ? 1 : 0, '#inline' => true, '#before' => '<li>', '#after' => '</li>');
     }
     /**
      * remove "Specific fields" if there is no fields
      */
     if (empty($options)) {
//.........这里部分代码省略.........
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:101,代码来源:class.types.admin.edit.post.type.php

示例3: wpcf_admin_post_process_field


//.........这里部分代码省略.........
            /*
             * 
             * 
             * TODO First two check are not needed anymore
             */
            // If array has more than one field - see which one is marked
            if ($field_object->__multiple && isset($element['#_validate_this'])) {
                $element['#validate'] = $field['data']['validate'];
            } else {
                if (!$field_object->__multiple) {
                    $element['#validate'] = $field['data']['validate'];
                }
            }
        }
        // Set atributes #2 (override)
        if (isset($field['disable'])) {
            $element['#disable'] = $field['disable'];
        }
        if (!empty($field['disable'])) {
            $element['#attributes']['disabled'] = 'disabled';
        }
        if (!empty($field['readonly'])) {
            $element['#attributes']['readonly'] = 'readonly';
            if (!empty($element['#options'])) {
                foreach ($element['#options'] as $key => $option) {
                    if (!is_array($option)) {
                        $element['#options'][$key] = array('#title' => $key, '#value' => $option);
                    }
                    $element['#options'][$key]['#attributes']['readonly'] = 'readonly';
                    if ($element['#type'] == 'select') {
                        $element['#options'][$key]['#attributes']['disabled'] = 'disabled';
                    }
                }
            }
            if ($element['#type'] == 'select') {
                $element['#attributes']['disabled'] = 'disabled';
            }
        }
        // Check if it was invalid on submit and add error message
        if ($post && !empty($invalid_fields)) {
            if (isset($invalid_fields[$element['#id']]['#error'])) {
                $element['#error'] = $invalid_fields[$element['#id']]['#error'];
            }
        }
        // Set WPML locked icon
        if (isset($field['wpml_action']) && $field['wpml_action'] == 'copy') {
            $element['#title'] .= '<img src="' . WPCF_EMBEDDED_RES_RELPATH . '/images/locked.png" alt="' . __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf') . '" title="' . __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf') . '" style="position:relative;left:2px;top:2px;" />';
        }
        // Add repetitive class
        // TODO Check if this is covered by Repeater and move/remove 1.1.5
        // TODO Check why not add repetitive class if copied 1.1.5
        if (wpcf_admin_is_repetitive($field) && $context != 'post_relationship' && (!isset($field['wpml_action']) || $field['wpml_action'] != 'copy')) {
            if (!empty($element['#options']) && $element['#type'] != 'select') {
                foreach ($element['#options'] as $temp_key => $temp_value) {
                    $element['#options'][$temp_key]['#attributes']['class'] = isset($element['#attributes']['class']) ? $element['#attributes']['class'] . ' wpcf-repetitive' : 'wpcf-repetitive';
                }
            } else {
                $element['#attributes']['class'] = isset($element['#attributes']['class']) ? $element['#attributes']['class'] . ' wpcf-repetitive' : 'wpcf-repetitive';
            }
            /*
            * 
            * 
            * Since Types 1.2 we allow same field values
            * 
            * TODO Remove
            * 
            * wpcf_admin_add_js_settings('wpcfFormRepetitiveUniqueValuesCheckText',
             '\'' . __('Warning: same values set', 'wpcf') . '\'');
            */
        }
        // Set read-only if copied by WPML
        // TODO Move this to separate WPML code and use only hooks 1.1.5
        if (isset($field['wpml_action']) && $field['wpml_action'] == 'copy') {
            if (isset($element['#options'])) {
                foreach ($element['#options'] as $temp_key => $temp_value) {
                    if (isset($temp_value['#attributes'])) {
                        $element['#options'][$temp_key]['#attributes']['readonly'] = 'readonly';
                    } else {
                        $element['#options'][$temp_key]['#attributes'] = array('readonly' => 'readonly');
                    }
                }
            }
            if ($field['type'] == 'select') {
                if (isset($element['#attributes'])) {
                    $element['#attributes']['disabled'] = 'disabled';
                } else {
                    $element['#attributes'] = array('disabled' => 'disabled');
                }
            } else {
                if (isset($element['#attributes'])) {
                    $element['#attributes']['readonly'] = 'readonly';
                } else {
                    $element['#attributes'] = array('readonly' => 'readonly');
                }
            }
        }
        return array('field' => $field, 'element' => $element);
    }
    return false;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:fields-post.php

示例4: types_render_usermeta_field

/**
 * Calls view function for specific field type.
 *
 * @param type $field
 * @param type $atts
 * @return type
 */
function types_render_usermeta_field($field_id, $params, $content = null, $code = '')
{
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
    global $wpcf, $post;
    // HTML var holds actual output
    $html = '';
    // Set post ID
    $post_id = $post->ID;
    if (isset($params['post_id']) && !empty($params['post_id'])) {
        $post_id = $params['post_id'];
    }
    // Get field
    $field = wpcf_fields_get_field_by_slug($field_id, 'wpcf-usermeta');
    // If field not found return empty string
    if (empty($field)) {
        // Log
        if (!function_exists('wplogger')) {
            require_once WPCF_EMBEDDED_ABSPATH . '/common/wplogger.php';
        }
        global $wplogger;
        $wplogger->log('types_render_usermeta_field call for missing field \'' . $field_id . '\'', WPLOG_DEBUG);
        return '';
    }
    //Get user By ID
    if (isset($params['user_id'])) {
        $user_id = $params['user_id'];
    } else {
        if (isset($params['user_name'])) {
            //Get user by login
            $user_id = $wpdb->get_var("SELECT * FROM " . $wpdb->prefix . "users WHERE user_login = '" . $params['user_name'] . "'", 0, 0);
        } else {
            if (isset($params['user_is_author'])) {
                //Get Post author
                $user_id = $post->post_author;
            } else {
                if (isset($params['user_current'])) {
                    //Get current logged user
                    $user_id = wpcf_usermeta_get_user();
                } else {
                    //If empty get post author, if no post, return empty
                    if (!empty($post_id)) {
                        $user_id = $post->post_author;
                    } else {
                        return;
                    }
                }
            }
        }
    }
    if (empty($user_id)) {
        return;
    }
    // Set field
    $wpcf->usermeta_field->set($user_id, $field);
    // See if repetitive
    if (wpcf_admin_is_repetitive($field)) {
        $wpcf->usermeta_repeater->set($user_id, $field);
        $_meta = $wpcf->usermeta_repeater->_get_meta();
        $meta = $_meta['custom_order'];
        //        $meta = get_post_meta( $post_id,
        //                wpcf_types_get_meta_prefix( $field ) . $field['slug'], false );
        // Sometimes if meta is empty - array(0 => '') is returned
        if (count($meta) == 1) {
            $meta_id = key($meta);
            $_temp = array_shift($meta);
            if (strval($_temp) == '') {
                return '';
            } else {
                $params['field_value'] = $_temp;
                return types_render_field_single($field, $params, $content, $code, $meta_id);
            }
        } else {
            if (!empty($meta)) {
                $output = '';
                if (isset($params['index'])) {
                    $index = $params['index'];
                } else {
                    $index = '';
                }
                // Allow wpv-for-each shortcode to set the index
                $index = apply_filters('wpv-for-each-index', $index);
                if ($index === '') {
                    $output = array();
                    foreach ($meta as $temp_key => $temp_value) {
                        $params['field_value'] = $temp_value;
                        $temp_output = types_render_field_single($field, $params, $content, $code, $temp_key);
                        if (!empty($temp_output)) {
                            $output[] = $temp_output;
                        }
                    }
                    if (!empty($output) && isset($params['separator'])) {
                        $output = implode(html_entity_decode($params['separator']), $output);
                    } else {
//.........这里部分代码省略.........
开发者ID:MiquelAdell,项目名称:miqueladell,代码行数:101,代码来源:usermeta-init.php

示例5: wpcf_pr_admin_edit_fields

/**
 * Edit fields form.
 * 
 * @global type $wpdb
 * @param type $parent
 * @param type $child 
 */
function wpcf_pr_admin_edit_fields($parent, $child)
{
    global $wpdb;
    $post_type_parent = get_post_type_object($parent);
    $post_type_child = get_post_type_object($child);
    if (empty($post_type_parent) || empty($post_type_child)) {
        die(__('Wrong post types'));
    }
    $relationships = get_option('wpcf_post_relationship', array());
    if (!isset($relationships[$parent][$child])) {
        die(__('Relationship do not exist'));
    }
    $data = $relationships[$parent][$child];
    wp_enqueue_script('jquery');
    wpcf_admin_ajax_head('Edit fields', 'wpcf');
    // Process submit
    if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'pt_edit_fields')) {
        $relationships[$parent][$child]['fields_setting'] = $_POST['fields_setting'];
        $relationships[$parent][$child]['fields'] = isset($_POST['fields']) ? $_POST['fields'] : array();
        update_option('wpcf_post_relationship', $relationships);
        ?>
        <script type="text/javascript">
            window.parent.jQuery('#TB_closeWindowButton').trigger('click');
            window.parent.location.reload();
        </script>
        <?php 
        die;
    }
    $groups = wpcf_admin_get_groups_by_post_type($child);
    $options_cf = array();
    $repetitive_warning = false;
    $repetitive_warning_markup = array();
    $repetitive_warning_txt = __('Repeating fields should not be used in child posts. Types will update all field values.', 'wpcf');
    foreach ($groups as $group) {
        $fields = wpcf_admin_fields_get_fields_by_group($group['id']);
        foreach ($fields as $key => $cf) {
            $options_cf[WPCF_META_PREFIX . $key] = array();
            $options_cf[WPCF_META_PREFIX . $key]['#title'] = $cf['name'];
            $options_cf[WPCF_META_PREFIX . $key]['#name'] = 'fields[' . WPCF_META_PREFIX . $key . ']';
            $options_cf[WPCF_META_PREFIX . $key]['#default_value'] = isset($data['fields'][WPCF_META_PREFIX . $key]) ? 1 : 0;
            // Repetitive warning
            if (wpcf_admin_is_repetitive($cf)) {
                if (!$repetitive_warning) {
                    $repetitive_warning_markup = array('#type' => 'markup', '#markup' => '<div class="message error" style="display:none;" id="wpcf-repetitive-warning"><p>' . $repetitive_warning_txt . '</p></div>');
                }
                $repetitive_warning = true;
                $options_cf[WPCF_META_PREFIX . $key]['#after'] = !isset($data['fields'][WPCF_META_PREFIX . $key]) ? '<div class="message error" style="display:none;"><p>' : '<div class="message error"><p>';
                $options_cf[WPCF_META_PREFIX . $key]['#after'] .= $repetitive_warning_txt;
                $options_cf[WPCF_META_PREFIX . $key]['#after'] .= '</p></div>';
                $options_cf[WPCF_META_PREFIX . $key]['#attributes'] = array('onclick' => 'jQuery(this).parent().find(\'.message\').toggle();');
            }
        }
    }
    $form = array();
    $form['repetitive_warning_markup'] = $repetitive_warning_markup;
    $form['select'] = array('#type' => 'radios', '#name' => 'fields_setting', '#options' => array(__('Title, all custom fields and parents', 'wpcf') => 'all_cf', __('All fields, including the standard post fields', 'wpcf') => 'all_cf_standard', __('Specific fields', 'wpcf') => 'specific'), '#default_value' => empty($data['fields_setting']) ? 'all_cf' : $data['fields_setting']);
    $options = array();
    $options['_wp_title'] = array('#title' => __('Post title', 'wpcf'), '#name' => 'fields[_wp_title]', '#default_value' => isset($data['fields']['_wp_title']) ? 1 : 0);
    $options['_wp_body'] = array('#title' => __('Post body', 'wpcf'), '#name' => 'fields[_wp_body]', '#default_value' => isset($data['fields']['_wp_body']) ? 1 : 0);
    $options = $options + $options_cf;
    $temp_belongs = wpcf_pr_admin_get_belongs($child);
    foreach ($temp_belongs as $temp_parent => $temp_data) {
        if ($temp_parent == $parent) {
            continue;
        }
        $temp_parent_type = get_post_type_object($temp_parent);
        $options[$temp_parent] = array();
        $options[$temp_parent]['#title'] = $temp_parent_type->label;
        $options[$temp_parent]['#name'] = 'fields[_wpcf_pr_parents][' . $temp_parent . ']';
        $options[$temp_parent]['#default_value'] = isset($data['fields']['_wpcf_pr_parents'][$temp_parent]) ? 1 : 0;
    }
    $form['specific'] = array('#type' => 'checkboxes', '#name' => 'fields', '#options' => $options, '#default_value' => isset($data['fields']), '#before' => '<div id="wpcf-specific" style="display:none;margin:10px 0 0 20px;">', '#after' => '</div>');
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary'));
    echo '<form method="post" action="">';
    echo wpcf_form_simple($form);
    echo wp_nonce_field('pt_edit_fields');
    echo '</form>';
    ?>
    <script type="text/javascript">
        jQuery(document).ready(function(){
            if (jQuery('input[name="fields_setting"]:checked').val() == 'specific') {
                jQuery('#wpcf-specific').show();
            } else {
    <?php 
    if ($repetitive_warning) {
        ?>
                                    jQuery('#wpcf-repetitive-warning').show();
        <?php 
    }
    ?>
                            }
                            jQuery('input[name="fields_setting"]').change(function(){
                                if (jQuery(this).val() == 'specific') {
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:post-relationship.php

示例6: wpcf_fields_get_shortcode

/**
 * Returns shortcode for specified field.
 * 
 * @param type $field
 * @param type $add Additional attributes
 */
function wpcf_fields_get_shortcode($field, $add = '')
{
    $shortcode = '[';
    $shortcode .= 'types field="' . $field['slug'] . '"' . $add;
    if (in_array($field['type'], array('textfield', 'textarea', 'wysiwyg'))) {
        $shortcode .= ' class="" style=""';
    }
    // If repetitive add separator
    if (wpcf_admin_is_repetitive($field)) {
        $shortcode .= ' separator=", "';
    }
    $shortcode .= '][/types]';
    $shortcode = apply_filters('wpcf_fields_shortcode', $shortcode, $field);
    $shortcode = apply_filters('wpcf_fields_shortcode_type_' . $field['type'], $shortcode, $field);
    $shortcode = apply_filters('wpcf_fields_shortcode_slug_' . $field['slug'], $shortcode, $field);
    return $shortcode;
}
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:23,代码来源:fields.php

示例7: _field_triggers

 /**
  * Add here various triggers for field
  */
 function _field_triggers()
 {
     /*
      * Check if repetitive - add warning
      */
     if (wpcf_admin_is_repetitive($this->cf->cf)) {
         $this->repetitive_warning = true;
     }
     /*
      * Check if date - trigger it
      * TODO Move to date
      */
     if ($this->cf->cf['type'] == 'date') {
         $this->trigger_date = true;
     }
 }
开发者ID:phuocdungit,项目名称:fundy,代码行数:19,代码来源:form-child.php

示例8: types_render_usermeta

/**
 * Calls view function for specific usermeta field type.
 *
 * @global object $wpdb
 *
 * @param type $field
 * @param type $atts (additional attributes: user_id, user_name, user_is_author, user_current)
 * @return type
 */
function types_render_usermeta($field_id, $params, $content = null, $code = '')
{
    global $wpcf, $post, $wpdb, $WP_Views;
    // HTML var holds actual output
    $html = '';
    $current_user = wp_get_current_user();
    $current_user_id = $current_user->ID;
    // Set post ID
    // user_id, user_name, user_is_author, user_current
    if (is_object($post)) {
        $post_id = $post->ID;
    } else {
        $post_id = 0;
    }
    if (isset($params['post_id']) && !empty($params['post_id'])) {
        $post_id = $params['post_id'];
    }
    //Get User id from views loop
    if (isset($WP_Views->users_data['term']->ID) && !empty($WP_Views->users_data['term']->ID)) {
        $params['user_id'] = $WP_Views->users_data['term']->ID;
    }
    //print_r($params);exit;
    //Get user By ID
    if (isset($params['user_id'])) {
        $user_id = $params['user_id'];
    } else {
        if (isset($params['user_name'])) {
            //Get user by login
            $user_id = $wpdb->get_var($wpdb->prepare("SELECT * FROM " . $wpdb->users . " WHERE user_login = %s", $params['user_name']));
        } else {
            if (isset($params['user_is_author'])) {
                //Get Post author
                $user_id = $post->post_author;
            } else {
                if (isset($params['user_current'])) {
                    //Get current logged user
                    $user_id = $current_user_id;
                } else {
                    //If empty get post author, if no post, return empty
                    if (!empty($post_id)) {
                        $user_id = $post->post_author;
                    } else {
                        return;
                    }
                }
            }
        }
    }
    if (empty($user_id)) {
        return;
    }
    // Get field
    $field = types_get_field($field_id, 'usermeta');
    // If field not found return empty string
    if (empty($field)) {
        // Log
        if (!function_exists('wplogger')) {
            require_once WPCF_EMBEDDED_TOOLSET_ABSPATH . '/toolset-common/wplogger.php';
        }
        global $wplogger;
        $wplogger->log('types_render_field call for missing field \'' . $field_id . '\'', WPLOG_DEBUG);
        return '';
    }
    // See if repetitive
    if (wpcf_admin_is_repetitive($field)) {
        $wpcf->usermeta_repeater->set($user_id, $field);
        $_meta = $wpcf->usermeta_repeater->_get_meta();
        $meta = '';
        if (isset($_meta['custom_order'])) {
            $meta = $_meta['custom_order'];
        }
        if (count($meta) == 1) {
            $meta_id = key($meta);
            $_temp = array_shift($meta);
            if (strval($_temp) == '') {
                return '';
            } else {
                $params['field_value'] = $_temp;
                return types_render_field_single($field, $params, $content, $code, $meta_id);
            }
        } else {
            if (!empty($meta)) {
                $output = '';
                if (isset($params['index'])) {
                    $index = $params['index'];
                } else {
                    $index = '';
                }
                // Allow wpv-for-each shortcode to set the index
                $index = apply_filters('wpv-for-each-index', $index);
                if ($index === '') {
//.........这里部分代码省略.........
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:101,代码来源:frontend.php

示例9: wpcf_fields_get_field_form_data

/**
 * Processes field form data.
 *
 * @param type $type
 * @param type $form_data
 * @return type
 */
function wpcf_fields_get_field_form_data($type, $form_data = array())
{
    // Get field type data
    $field_data = wpcf_fields_type_action($type);
    if (!empty($field_data)) {
        $form = array();
        // Set right ID if existing field
        if (isset($form_data['submitted_key'])) {
            $id = $form_data['submitted_key'];
        } else {
            $id = $type . '-' . rand();
        }
        // Sanitize
        $form_data = wpcf_sanitize_field($form_data);
        // Set remove link
        $remove_link = isset($form_data['group_id']) ? admin_url('admin-ajax.php?' . 'wpcf_ajax_callback=wpcfFieldsFormDeleteElement&amp;wpcf_warning=' . __('Are you sure?', 'wpcf') . '&amp;action=wpcf_ajax&amp;wpcf_action=remove_field_from_group' . '&amp;group_id=' . intval($form_data['group_id']) . '&amp;field_id=' . $form_data['id']) . '&amp;_wpnonce=' . wp_create_nonce('remove_field_from_group') : admin_url('admin-ajax.php?' . 'wpcf_ajax_callback=wpcfFieldsFormDeleteElement&amp;wpcf_warning=' . __('Are you sure?', 'wpcf') . '&amp;action=wpcf_ajax&amp;wpcf_action=remove_field_from_group') . '&amp;_wpnonce=' . wp_create_nonce('remove_field_from_group');
        // Set move button
        $form['wpcf-' . $id . '-control'] = array('#type' => 'markup', '#markup' => '<img src="' . WPCF_RES_RELPATH . '/images/move.png" class="wpcf-fields-form-move-field" alt="' . __('Move this field', 'wpcf') . '" /><a href="' . $remove_link . '" ' . 'class="wpcf-form-fields-delete wpcf-ajax-link">' . '<img src="' . WPCF_RES_RELPATH . '/images/delete-2.png" alt="' . __('Delete this field', 'wpcf') . '" /></a>');
        // Set fieldset
        $collapsed = wpcf_admin_fields_form_fieldset_is_collapsed('fieldset-' . $id);
        // Set collapsed on AJAX call (insert)
        $collapsed = defined('DOING_AJAX') ? false : $collapsed;
        // Set title
        $title = !empty($form_data['name']) ? $form_data['name'] : __('Untitled', 'wpcf');
        $title = '<span class="wpcf-legend-update">' . $title . '</span> - ' . sprintf(__('%s field', 'wpcf'), $field_data['title']);
        // Do not display on Usermeta Group edit screen
        if (!isset($_GET['page']) || $_GET['page'] != 'wpcf-edit-usermeta') {
            if (!empty($form_data['data']['conditional_display']['conditions'])) {
                $title .= ' ' . __('(conditional)', 'wpcf');
            }
        }
        $form['wpcf-' . $id] = array('#type' => 'fieldset', '#title' => $title, '#id' => 'fieldset-' . $id, '#collapsible' => true, '#collapsed' => $collapsed);
        // Get init data
        $field_init_data = wpcf_fields_type_action($type);
        // See if field inherits some other
        $inherited_field_data = false;
        if (isset($field_init_data['inherited_field_type'])) {
            $inherited_field_data = wpcf_fields_type_action($field_init_data['inherited_field_type']);
        }
        $form_field = array();
        // Force name and description
        $form_field['name'] = array('#type' => 'textfield', '#name' => 'name', '#attributes' => array('class' => 'wpcf-forms-set-legend wpcf-forms-field-name', 'style' => 'width:100%;margin:10px 0 10px 0;', 'placeholder' => __('Enter field name', 'wpcf')), '#validate' => array('required' => array('value' => true)), '#inline' => true);
        $form_field['slug'] = array('#type' => 'textfield', '#name' => 'slug', '#attributes' => array('class' => 'wpcf-forms-field-slug', 'style' => 'width:100%;margin:0 0 10px 0;', 'maxlength' => 255, 'placeholder' => __('Enter field slug', 'wpcf')), '#validate' => array('nospecialchars' => array('value' => true)), '#inline' => true);
        // If insert form callback is not provided, use generic form data
        if (function_exists('wpcf_fields_' . $type . '_insert_form')) {
            $form_field_temp = call_user_func('wpcf_fields_' . $type . '_insert_form', $form_data, 'wpcf[fields][' . $id . ']');
            if (is_array($form_field_temp)) {
                unset($form_field_temp['name'], $form_field_temp['slug']);
                $form_field = $form_field + $form_field_temp;
            }
        }
        $form_field['description'] = array('#type' => 'textarea', '#name' => 'description', '#attributes' => array('rows' => 5, 'cols' => 1, 'style' => 'margin:0 0 10px 0;', 'placeholder' => __('Describe this field', 'wpcf')), '#inline' => true);
        /**
         * add placeholder field
         */
        switch ($type) {
            case 'audio':
            case 'colorpicker':
            case 'date':
            case 'email':
            case 'embed':
            case 'file':
            case 'image':
            case 'numeric':
            case 'phone':
            case 'skype':
            case 'textarea':
            case 'textfield':
            case 'url':
            case 'video':
                $form_field['placeholder'] = array('#type' => 'textfield', '#name' => 'placeholder', '#inline' => true, '#title' => __('Placeholder', 'wpcf'), '#attributes' => array('style' => 'width:100%;margin:0 0 10px 0;', 'placeholder' => __('Enter placeholder', 'wpcf')));
                break;
        }
        if (wpcf_admin_can_be_repetitive($type)) {
            $temp_warning_message = '';
            $form_field['repetitive'] = array('#type' => 'radios', '#name' => 'repetitive', '#title' => __('Single or repeating field?', 'wpcf'), '#options' => array('repeat' => array('#title' => __('Allow multiple-instances of this field', 'wpcf'), '#value' => '1', '#attributes' => array('onclick' => 'jQuery(this).parent().parent().find(\'.wpcf-cd-warning\').hide(); jQuery(this).parent().find(\'.wpcf-cd-repetitive-warning\').show();')), 'norepeat' => array('#title' => __('This field can have only one value', 'wpcf'), '#value' => '0', '#attributes' => array('onclick' => 'jQuery(this).parent().parent().find(\'.wpcf-cd-warning\').show(); jQuery(this).parent().find(\'.wpcf-cd-repetitive-warning\').hide();'))), '#default_value' => isset($form_data['data']['repetitive']) ? $form_data['data']['repetitive'] : '0', '#after' => wpcf_admin_is_repetitive($form_data) ? '<div class="wpcf-message wpcf-cd-warning wpcf-error" style="display:none;"><p>' . __("There may be multiple instances of this field already. When you switch back to single-field mode, all values of this field will be updated when it's edited.", 'wpcf') . '</p></div>' . $temp_warning_message : $temp_warning_message);
        }
        // Process all form fields
        foreach ($form_field as $k => $field) {
            $form['wpcf-' . $id][$k] = $field;
            // Check if nested
            if (isset($field['#name']) && strpos($field['#name'], '[') === false) {
                $form['wpcf-' . $id][$k]['#name'] = 'wpcf[fields][' . $id . '][' . $field['#name'] . ']';
            } else {
                if (isset($field['#name'])) {
                    $form['wpcf-' . $id][$k]['#name'] = 'wpcf[fields][' . $id . ']' . $field['#name'];
                }
            }
            if (!isset($field['#id'])) {
                $form['wpcf-' . $id][$k]['#id'] = $type . '-' . $field['#type'] . '-' . rand();
            }
            if (isset($field['#name']) && isset($form_data[$field['#name']])) {
                $form['wpcf-' . $id][$k]['#value'] = $form_data[$field['#name']];
//.........这里部分代码省略.........
开发者ID:chrismathers,项目名称:premierplacement,代码行数:101,代码来源:fields-form.php

示例10: types_render_field

/**
 * Calls view function for specific field type.
 * 
 * @param type $field
 * @param type $atts
 * @return type 
 */
function types_render_field($field_id, $params, $content = null, $code = '')
{
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
    global $post;
    // Get field
    $field = wpcf_fields_get_field_by_slug($field_id);
    if (empty($field)) {
        if (!function_exists('wplogger')) {
            require_once WPCF_EMBEDDED_ABSPATH . '/common/wplogger.php';
        }
        global $wplogger;
        $wplogger->log('types_render_field call for missing field \'' . $field_id . '\'', WPLOG_DEBUG);
        return '';
    }
    // See if repetitive
    if (wpcf_admin_is_repetitive($field)) {
        $meta = get_post_meta($post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], false);
        if (!empty($meta)) {
            $output = '';
            if (isset($params['index'])) {
                $index = $params['index'];
            } else {
                $index = '';
            }
            // Allow wpv-for-each shortcode to set the index
            $index = apply_filters('wpv-for-each-index', $index);
            if ($index === '') {
                $output = array();
                foreach ($meta as $temp_key => $temp_value) {
                    $params['field_value'] = $temp_value;
                    $temp_output = types_render_field_single($field, $params, $content, $code);
                    if (!empty($temp_output)) {
                        $output[] = $temp_output;
                    }
                }
                if (!empty($output) && isset($params['separator'])) {
                    $output = implode($params['separator'], $output);
                } else {
                    if (!empty($output)) {
                        $output = implode('', $output);
                    } else {
                        return '';
                    }
                }
            } else {
                if (isset($meta[$index])) {
                    $params['field_value'] = $meta[$index];
                    return types_render_field_single($field, $params, $content, $code);
                } else {
                    return '';
                }
            }
            return $output;
        } else {
            return '';
        }
    } else {
        $params['field_value'] = get_post_meta($post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
        if ($params['field_value'] == '' && $field['type'] != 'checkbox') {
            return '';
        }
        return types_render_field_single($field, $params, $content, $code);
    }
}
开发者ID:sriram911,项目名称:pls,代码行数:71,代码来源:frontend.php

示例11: wpcf_admin_post_process_field

/**
 * Processes single field.
 * 
 * @staticvar array $repetitive_started
 * @param type $post
 * @param type $field
 * @param type $use_cache
 * @param type $add_to_editor
 * @param type $context
 * @param type $original_cf
 * @param type $invalid_fields
 * @return mixed boolean|array
 */
function wpcf_admin_post_process_field($post = false, $field_unedited = array(), $use_cache = true, $add_to_editor = true, $context = 'group', $original_cf = array(), $invalid_fields = array())
{
    $field = wpcf_admin_fields_get_field($field_unedited['id']);
    if (!empty($field)) {
        // Set values
        $field['value'] = isset($field_unedited['value']) ? $field_unedited['value'] : '';
        $field['wpml_action'] = isset($field_unedited['wpml_action']) ? $field_unedited['wpml_action'] : '';
        if (isset($count[$field['type'] . '-' . $field['slug']])) {
            $field_id = 'wpcf-' . $field['type'] . '-' . $field['slug'] . '-' . $count[$field['type'] . '-' . $field['slug']] . '-' . mt_rand();
            $count[$field['type'] . '-' . $field['slug']] += 1;
        } else {
            $field_id = 'wpcf-' . $field['type'] . '-' . $field['slug'] . '-' . mt_rand();
            $count[$field['type'] . '-' . $field['slug']] = 1;
        }
        $field_init_data = wpcf_fields_type_action($field['type']);
        // Get inherited field
        $inherited_field_data = false;
        if (isset($field_init_data['inherited_field_type'])) {
            $inherited_field_data = wpcf_fields_type_action($field_init_data['inherited_field_type']);
        }
        // Mark any field that is going to be copied.
        if (!empty($original_cf['fields'])) {
            foreach ($original_cf['fields'] as $cf_id) {
                if (wpcf_types_get_meta_prefix($field) . $field['slug'] == $cf_id) {
                    $field['readonly'] = true;
                    $field['wpml_action'] = 'copy';
                    break;
                }
            }
        }
        // Apply filters
        $field['value'] = apply_filters('wpcf_fields_value_get', $field['value'], $field, $field_init_data);
        $field['value'] = apply_filters('wpcf_fields_slug_' . $field['slug'] . '_value_get', $field['value'], $field, $field_init_data);
        $field['value'] = apply_filters('wpcf_fields_type_' . $field['type'] . '_value_get', $field['value'], $field, $field_init_data);
        wpcf_admin_post_field_load_js_css($field_init_data);
        $element = array();
        // Set generic values
        $element = array('#type' => isset($field_init_data['inherited_field_type']) ? $field_init_data['inherited_field_type'] : $field['type'], '#id' => $field_id, '#title' => wpcf_translate('field ' . $field['id'] . ' name', $field['name']), '#description' => wpautop(wpcf_translate('field ' . $field['id'] . ' description', $field['description'])), '#name' => 'wpcf[' . $field['slug'] . ']', '#value' => isset($field['value']) ? $field['value'] : '', 'wpcf-id' => $field['id'], 'wpcf-slug' => $field['slug'], 'wpcf-type' => $field['type']);
        // Set inherited values
        $element_inherited = array();
        if ($inherited_field_data) {
            if (function_exists('wpcf_fields_' . $field_init_data['inherited_field_type'] . '_meta_box_form')) {
                $element_inherited = call_user_func_array('wpcf_fields_' . $field_init_data['inherited_field_type'] . '_meta_box_form', array($field, $element));
            }
        }
        $element = array_merge($element, $element_inherited);
        if (isset($field['description_extra'])) {
            $element['#description'] .= wpautop($field['description_extra']);
        }
        // Set atributes #1
        if (isset($field['disable'])) {
            $field['#disable'] = $field['disable'];
        }
        if (!empty($field['disable'])) {
            $field['#attributes']['disabled'] = 'disabled';
        }
        if (!empty($field['readonly'])) {
            $field['#attributes']['readonly'] = 'readonly';
        }
        // Set specific values
        if (defined('WPCF_INC_ABSPATH') && file_exists(WPCF_INC_ABSPATH . '/fields/' . $field['type'] . '.php')) {
            require_once WPCF_INC_ABSPATH . '/fields/' . $field['type'] . '.php';
        }
        // Load field
        if (function_exists('wpcf_fields_' . $field['type'] . '_meta_box_form')) {
            $element_specific = call_user_func_array('wpcf_fields_' . $field['type'] . '_meta_box_form', array($field, $element));
            // Check if it's single
            if (isset($element_specific['#type'])) {
                // Format description
                if (!empty($element_specific['#description'])) {
                    $element_specific['#description'] = wpautop($element_specific['#description']);
                }
                $element = array_merge($element, $element_specific);
                // Set validation element
                if (isset($field['data']['validate'])) {
                    $element['#validate'] = $field['data']['validate'];
                }
                // Repetitive fields
                if (wpcf_admin_is_repetitive($field) && $context != 'post_relationship' && (!isset($field['wpml_action']) || $field['wpml_action'] != 'copy')) {
                    $element = wpcf_admin_post_process_repetitive_field($post, $field, $element);
                }
            } else {
                // More fields, loop all
                // Only Skype for now have multiple fields, so process only that
                if ($field['type'] == 'skype') {
                    $skype_element = array();
                    foreach ($element_specific as $element_specific_fields_key => $element_specific_fields_value) {
//.........这里部分代码省略.........
开发者ID:sriram911,项目名称:pls,代码行数:101,代码来源:fields-post.php

示例12: types_render_termmeta

function types_render_termmeta($field_id, $params, $content = null, $code = '')
{
    global $wpcf, $wpdb, $WP_Views;
    // HTML var holds actual output
    $html = '';
    //Get User id from views loop
    if (isset($WP_Views->taxonomy_data['term']->term_id) && !empty($WP_Views->taxonomy_data['term']->term_id)) {
        $params['term_id'] = $WP_Views->taxonomy_data['term']->term_id;
    }
    if (!isset($params['term_id']) && (is_tax() || is_category() || is_tag())) {
        global $wp_query;
        $term = $wp_query->get_queried_object();
        if ($term && isset($term->term_id)) {
            $params['term_id'] = $term->term_id;
        }
    }
    //print_r($params);exit;
    //Get user By ID
    if (isset($params['term_id'])) {
        $term_id = $params['term_id'];
    } else {
        return;
    }
    if (empty($term_id)) {
        return;
    }
    // Get field
    $field = types_get_field($field_id, 'termmeta');
    // If field not found return empty string
    if (empty($field)) {
        // Log
        if (!function_exists('wplogger')) {
            require_once WPCF_EMBEDDED_TOOLSET_ABSPATH . '/toolset-common/wplogger.php';
        }
        global $wplogger;
        $wplogger->log('types_render_field call for missing field \'' . $field_id . '\'', WPLOG_DEBUG);
        return '';
    }
    // See if repetitive
    if (wpcf_admin_is_repetitive($field)) {
        $wpcf->termmeta_repeater->set($term_id, $field);
        $_meta = $wpcf->termmeta_repeater->_get_meta();
        $meta = '';
        if (isset($_meta['custom_order'])) {
            $meta = $_meta['custom_order'];
        }
        if (count($meta) == 1) {
            $meta_id = key($meta);
            $_temp = array_shift($meta);
            if (strval($_temp) == '') {
                return '';
            } else {
                $params['field_value'] = $_temp;
                return types_render_field_single($field, $params, $content, $code, $meta_id);
            }
        } else {
            if (!empty($meta)) {
                $output = '';
                if (isset($params['index'])) {
                    $index = $params['index'];
                } else {
                    $index = '';
                }
                // Allow wpv-for-each shortcode to set the index
                $index = apply_filters('wpv-for-each-index', $index);
                if ($index === '') {
                    $output = array();
                    foreach ($meta as $temp_key => $temp_value) {
                        $params['field_value'] = $temp_value;
                        $temp_output = types_render_field_single($field, $params, $content, $code, $temp_key);
                        if (!Toolset_Utils::is_field_value_truly_empty($temp_output)) {
                            $output[] = $temp_output;
                        }
                    }
                    if (!empty($output) && isset($params['separator'])) {
                        $output = implode(html_entity_decode($params['separator']), $output);
                    } else {
                        if (!empty($output)) {
                            $output = implode('', $output);
                        } else {
                            return '';
                        }
                    }
                } else {
                    // Make sure indexed right
                    $_index = 0;
                    foreach ($meta as $temp_key => $temp_value) {
                        if ($_index == $index) {
                            $params['field_value'] = $temp_value;
                            $output = types_render_field_single($field, $params, $content, $code, $temp_key);
                        }
                        $_index++;
                    }
                }
                $html = $output;
            } else {
                return '';
            }
        }
    } else {
//.........这里部分代码省略.........
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:101,代码来源:frontend.php

示例13: headers

 /**
  * Header HTML formatted output.
  * 
  * Each header <th> is array element. Sortable.
  * 
  * @return array 'header_id' => html
  */
 function headers()
 {
     // Sorting
     $dir = isset($_GET['sort']) && $_GET['sort'] == 'ASC' ? 'DESC' : 'ASC';
     $dir_default = 'ASC';
     $sort_field = isset($_GET['field']) ? $_GET['field'] : '';
     // Set values
     $post = $this->parent;
     $post_type = $this->child_post_type;
     $parent_post_type = $this->parent_post_type;
     $data = $this->data;
     $wpcf_fields = wpcf_admin_fields_get_fields(true);
     $headers = array();
     foreach ($this->headers as $k => $header) {
         if ($k === '__parents') {
             continue;
         }
         if ($header == '_wp_title') {
             $title_dir = $sort_field == '_wp_title' ? $dir : 'ASC';
             $headers[$header] = '';
             $headers[$header] .= $sort_field == '_wp_title' ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
             $headers[$header] .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=pr_sort&amp;field=' . '_wp_title&amp;sort=' . $title_dir . '&amp;post_id=' . $post->ID . '&amp;post_type=' . $post_type . '&amp;_wpnonce=' . wp_create_nonce('pr_sort')) . '">' . __('Post Title') . '</a>';
         } else {
             if ($header == '_wp_body') {
                 $body_dir = $sort_field == '_wp_body' ? $dir : $dir_default;
                 $headers[$header] = '';
                 $headers[$header] .= $sort_field == '_wp_body' ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
                 $headers[$header] .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=pr_sort&amp;field=' . '_wp_body&amp;sort=' . $body_dir . '&amp;post_id=' . $post->ID . '&amp;post_type=' . $post_type . '&amp;_wpnonce=' . wp_create_nonce('pr_sort')) . '">' . __('Post Body') . '</a>';
             } else {
                 if (strpos($header, WPCF_META_PREFIX) === 0 && isset($wpcf_fields[str_replace(WPCF_META_PREFIX, '', $header)])) {
                     wpcf_admin_post_field_load_js_css($post, wpcf_fields_type_action($wpcf_fields[str_replace(WPCF_META_PREFIX, '', $header)]['type']));
                     $field_dir = $sort_field == $header ? $dir : $dir_default;
                     $headers[$header] = '';
                     $headers[$header] .= $sort_field == $header ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
                     $headers[$header] .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=pr_sort&amp;field=' . $header . '&amp;sort=' . $field_dir . '&amp;post_id=' . $post->ID . '&amp;post_type=' . $post_type . '&amp;_wpnonce=' . wp_create_nonce('pr_sort')) . '">' . stripslashes($wpcf_fields[str_replace(WPCF_META_PREFIX, '', $header)]['name']) . '</a>';
                     if (wpcf_admin_is_repetitive($wpcf_fields[str_replace(WPCF_META_PREFIX, '', $header)])) {
                         $repetitive_warning = true;
                     }
                 } else {
                     $field_dir = $sort_field == $header ? $dir : $dir_default;
                     $headers[$header] = '';
                     $headers[$header] .= $sort_field == $header ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
                     $headers[$header] .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=pr_sort&amp;field=' . $header . '&amp;sort=' . $field_dir . '&amp;post_id=' . $post->ID . '&amp;post_type=' . $post_type . '&amp;_wpnonce=' . wp_create_nonce('pr_sort')) . '">' . stripslashes($header) . '</a>';
                 }
             }
         }
     }
     if (!empty($this->headers['__parents'])) {
         foreach ($this->headers['__parents'] as $_parent => $data) {
             if ($_parent == $parent_post_type) {
                 continue;
             }
             $temp_parent_type = get_post_type_object($_parent);
             if (empty($temp_parent_type)) {
                 continue;
             }
             $parent_dir = $sort_field == '_wpcf_pr_parent' ? $dir : $dir_default;
             $headers['_wpcf_pr_parent_' . $_parent] = $sort_field == '_wpcf_pr_parent' ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
             $headers['_wpcf_pr_parent_' . $_parent] .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=pr_sort&amp;field=' . '_wpcf_pr_parent&amp;sort=' . $parent_dir . '&amp;post_id=' . $post->ID . '&amp;post_type=' . $post_type . '&amp;post_type_sort_parent=' . $_parent . '&amp;_wpnonce=' . wp_create_nonce('pr_sort')) . '">' . $temp_parent_type->label . '</a>';
         }
     }
     return $headers;
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:70,代码来源:form-child.php

示例14: wpcf_api_field_meta_value_repetitive

/**
 * Gets repetitive meta value.
 * 
 * @global type $wpcf
 * @param type $field
 * @param type $post_id
 * @param type $meta_id
 * @return type 
 */
function wpcf_api_field_meta_value_repetitive($field, $post_id = null, $meta_id = null)
{
    static $cache = array();
    $cache_key = md5(serialize(func_get_args()));
    if (isset($cache[$cache_key])) {
        return $cache[$cache_key];
    }
    global $wpcf;
    // Get field
    if (!is_array($field)) {
        $field = types_get_field($field);
        if (empty($field)) {
            return NULL;
        }
    }
    // Set post
    if (!is_null($post_id)) {
        if (!($post_id = absint($post_id))) {
            return NULL;
        }
        $post = get_post($post_id);
    } else {
        global $post;
    }
    if (empty($post->ID)) {
        return NULL;
    }
    // Set field
    $wpcf->repeater->set($post, $field);
    $meta = $wpcf->repeater->meta;
    $values = array();
    // See if single
    if (!wpcf_admin_is_repetitive($field)) {
        $values = isset($meta['single']) ? $meta['single'] : NULL;
    } else {
        if (!is_null($meta_id) && isset($meta['by_meta_id'][$meta_id])) {
            // Return single repetitive field value if meta_id specified
            $values = $meta['by_meta_id'][$meta_id];
        } else {
            if (isset($wpcf->repeater->meta['custom_order'])) {
                // Return ordered
                $values = $wpcf->repeater->meta['custom_order'];
            } else {
                if (isset($wpcf->repeater->meta['by_meta_id'])) {
                    // Return by_meta_id
                    $values = $wpcf->repeater->meta['by_meta_id'];
                }
            }
        }
    }
    $cache[$cache_key] = $values;
    return $values;
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:62,代码来源:api.php

示例15: wpcf_cd_admin_form_single_filter

/**
 * Single condition form elements.
 * 
 * @param type $data
 * @param type $condition
 * @param type $key
 * @return string 
 */
function wpcf_cd_admin_form_single_filter($data, $condition, $key = null, $group = false, $force_multi = false)
{
    if ($group) {
        $name = 'wpcf[group][conditional_display]';
    } else {
        $name = 'wpcf[fields][' . $data['id'] . '][conditional_display]';
    }
    $group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : false;
    if ($group_id && !$group) {
        // Allow group to use other fields
        $fields = wpcf_admin_fields_get_fields_by_group($group_id);
    } else {
        $fields = wpcf_admin_fields_get_fields();
    }
    $options = array();
    foreach ($fields as $field_id => $field) {
        if (!$group && $data['id'] == $field_id) {
            continue;
        }
        if (wpcf_admin_is_repetitive($field)) {
            continue;
        }
        $options[$field_id] = array('#value' => $field_id, '#title' => $field['name'], '#attributes' => array('class' => 'wpcf-conditional-select-' . $field['type']));
    }
    if (!$group && empty($options)) {
        return array('cd' => array('#type' => 'markup', '#markup' => '<p>' . __('You will be able to set conditional field display when you save more fields.', 'wpcf') . '</p>'));
    }
    $id = !is_null($key) ? $key : strval('condition_' . mt_rand());
    $form = array();
    $before = '<div class="wpcf-cd-entry"><br />';
    $form['cd']['field_' . $id] = array('#type' => 'select', '#name' => $name . '[conditions][' . $id . '][field]', '#options' => $options, '#inline' => true, '#before' => $before, '#default_value' => isset($condition['field']) ? $condition['field'] : null, '#attributes' => array('class' => 'wpcf-cd-field'));
    $form['cd']['operation_' . $id] = array('#type' => 'select', '#name' => $name . '[conditions][' . $id . '][operation]', '#options' => array_flip(wpcf_cd_admin_operations()), '#inline' => true, '#default_value' => isset($condition['operation']) ? $condition['operation'] : null, '#attributes' => array('class' => 'wpcf-cd-operation'));
    $form['cd']['value_' . $id] = array('#type' => 'textfield', '#name' => $name . '[conditions][' . $id . '][value]', '#options' => wpcf_cd_admin_operations(), '#inline' => true, '#value' => isset($condition['value']) ? $condition['value'] : '', '#attributes' => array('class' => 'wpcf-cd-value'));
    $form['cd']['remove_' . $id] = array('#type' => 'button', '#name' => 'remove', '#value' => __('Remove condition', 'wpcf'), '#attributes' => array('onclick' => 'wpcfCdRemoveCondition(jQuery(this));', 'class' => 'wpcf-add-condition'), '#before' => '<br />', '#after' => '</div>');
    return $form['cd'];
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:44,代码来源:conditional-display.php


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