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


PHP wpcf_admin_can_be_repetitive函数代码示例

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


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

示例1: wpcf_admin_is_repetitive

/**
 * Check if field is repetitive
 * @param type $type
 * @return type 
 */
function wpcf_admin_is_repetitive($field)
{
    if (!isset($field['data']['repetitive']) || !isset($field['type'])) {
        return false;
    }
    $check = intval($field['data']['repetitive']);
    return !empty($check) && wpcf_admin_can_be_repetitive($field['type']);
}
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:13,代码来源:functions.php

示例2: 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&wpcf_warning=' . __('Are you sure?', 'wpcf') . '&action=wpcf_ajax&wpcf_action=remove_field_from_group' . '&group_id=' . intval($form_data['group_id']) . '&field_id=' . $form_data['id']) . '&_wpnonce=' . wp_create_nonce('remove_field_from_group') : admin_url('admin-ajax.php?' . 'wpcf_ajax_callback=wpcfFieldsFormDeleteElement&wpcf_warning=' . __('Are you sure?', 'wpcf') . '&action=wpcf_ajax&wpcf_action=remove_field_from_group') . '&_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

示例3: get_field_form_data


//.........这里部分代码省略.........
         case 'audio':
         case 'email':
         case 'embed':
         case 'file':
         case 'image':
         case 'numeric':
         case 'phone':
         case 'textfield':
         case 'url':
         case 'video':
             $form_field['user_default_value'] = array('#type' => 'textfield', '#name' => 'user_default_value', '#inline' => true, '#title' => __('Default Value', 'wpcf'), '#attributes' => array('placeholder' => __('Enter default value', 'wpcf'), 'class' => 'widefat', 'tooltip' => __('This is the initial value of the field.', 'wpcf')), '#pattern' => $table_row);
             break;
         case 'textarea':
         case 'wysiwyg':
             $form_field['user_default_value'] = array('#type' => 'textarea', '#name' => 'user_default_value', '#inline' => true, '#title' => __('Default Value', 'wpcf'), '#attributes' => array('style' => 'width:100%;margin:0 0 10px 0;', 'placeholder' => __('Enter default value', 'wpcf')), '#pattern' => $table_row);
             break;
     }
     switch ($type) {
         case 'audio':
         case 'file':
         case 'image':
         case 'embed':
         case 'url':
         case 'video':
             $form_field['user_default_value']['#validate'] = array('url' => array());
             break;
         case 'email':
             $form_field['user_default_value']['#validate'] = array('email' => array());
             break;
         case 'numeric':
             $form_field['user_default_value']['#validate'] = array('number' => array());
             break;
     }
     if (wpcf_admin_can_be_repetitive($type)) {
         $temp_warning_message = '';
         // We need to set the "repetitive" setting to a string '0' or '1', not numbers, because it will be used
         // again later in this method (which I'm not going to refactor now) and because the form renderer
         // is oversensitive.
         $is_repetitive_as_string = 1 == wpcf_getnest($form_data, array('data', 'repetitive'), '0') ? '1' : '0';
         if (!array_key_exists('data', $form_data) || !is_array($form_data['data'])) {
             $form_data['data'] = array();
         }
         $form_data['data']['repetitive'] = $is_repetitive_as_string;
         $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();'), '#before' => '<li>', '#after' => '</li>', '#inline' => true), '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();'), '#before' => '<li>', '#after' => '</li>', '#inline' => true)), '#default_value' => $is_repetitive_as_string, '#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, '#pattern' => preg_replace('/<tr>/', '<tr class="wpcf-border-top">', $table_row), '#inline' => true, '#before' => '<ul>', '#after' => '</ul>');
     }
     /**
             /* Add validation box
     */
     $validate_function = sprintf('wpcf_fields_%s', $type);
     if (is_callable($validate_function)) {
         $form_validate = $this->form_validation('wpcf[fields][' . $id . '][validate]', call_user_func($validate_function), $form_data);
         foreach ($form_validate as $k => $v) {
             if ('hidden' != $v['#type'] && !isset($v['#pattern'])) {
                 $v['#pattern'] = $table_row;
             }
             $form_field['wpcf-' . $id . $k] = $v;
         }
     }
     /**
      * WPML Translation Preferences
      *
      * only for post meta
      *
      */
     $form_field += $this->wpml($form_data);
     // Conditional display, Relevanssi integration and other modifications can be added here.
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:67,代码来源:class.types.admin.edit.fields.php

示例4: wpcf_admin_is_repetitive

/**
 * Check if field is repetitive.
 *
 * @deprecated Use types_is_repetitive instead.
 * @param array $field Field definition array.
 * @return bool
 */
function wpcf_admin_is_repetitive($field)
{
    $field_type = wpcf_getarr($field, 'type', '');
    $is_repetitive = (int) wpcf_getnest($field, array('data', 'repetitive'), 0);
    return $is_repetitive && !empty($field_type) && wpcf_admin_can_be_repetitive($field_type);
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:13,代码来源:functions.php


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