• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wpcf_admin_validation_messages函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_message

 /**
  * Return method invalid message.
  * 
  * @param type $method
  * @return type 
  */
 public static function get_message($method, $sprintf = '')
 {
     return wpcf_admin_validation_messages($method, $sprintf);
     if (is_null(self::$messages)) {
         self::_set_messages();
     }
     if (isset(self::$messages[$method])) {
         return self::$messages[$method];
     }
     return null;
 }
开发者ID:sonvq,项目名称:passioninvestment,代码行数:17,代码来源:validate.php


示例2: wpcf_admin_bulk_string_translation

/**
 * Bulk translation. 
 */
function wpcf_admin_bulk_string_translation()
{
    if (!function_exists('icl_register_string')) {
        return false;
    }
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
    require_once WPCF_INC_ABSPATH . '/custom-types-form.php';
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
    require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
    // Register groups
    $groups = wpcf_admin_fields_get_groups();
    foreach ($groups as $group_id => $group) {
        wpcf_translate_register_string('plugin Types', 'group ' . $group_id . ' name', $group['name']);
        if (isset($group['description'])) {
            wpcf_translate_register_string('plugin Types', 'group ' . $group_id . ' description', $group['description']);
        }
    }
    // Register fields
    $fields = wpcf_admin_fields_get_fields();
    foreach ($fields as $field_id => $field) {
        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' name', $field['name']);
        if (isset($field['description'])) {
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' description', $field['description']);
        }
        // For radios or select
        if (!empty($field['data']['options'])) {
            foreach ($field['data']['options'] as $name => $option) {
                if ($name == 'default') {
                    continue;
                }
                if (isset($option['title'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' title', $option['title']);
                }
                if (isset($option['value'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' value', $option['value']);
                }
                if (isset($option['display_value'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value', $option['display_value']);
                }
            }
        }
        if ($field['type'] == 'checkbox' && (isset($field['set_value']) && $field['set_value'] != '1')) {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value', $field['set_value']);
        }
        if ($field['type'] == 'checkbox' && !empty($field['display_value_selected'])) {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value selected', $field['display_value_selected']);
        }
        if ($field['type'] == 'checkbox' && !empty($field['display_value_not_selected'])) {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value not selected', $field['display_value_not_selected']);
        }
        // Validation message
        if (!empty($field['data']['validate'])) {
            foreach ($field['data']['validate'] as $method => $validation) {
                if (!empty($validation['message'])) {
                    // Skip if it's same as default
                    $default_message = wpcf_admin_validation_messages($method);
                    if ($validation['message'] != $default_message) {
                        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' validation message ' . $method, $validation['message']);
                    }
                }
            }
        }
    }
    // Register types
    $custom_types = get_option('wpcf-custom-types', array());
    foreach ($custom_types as $post_type => $data) {
        wpcf_custom_types_register_translation($post_type, $data);
    }
    // Register taxonomies
    $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
    foreach ($custom_taxonomies as $taxonomy => $data) {
        wpcf_custom_taxonimies_register_translation($taxonomy, $data);
    }
}
开发者ID:sriram911,项目名称:pls,代码行数:81,代码来源:admin.php


示例3: _set_messages

 /**
  * Inits messages.
  */
 private static function _set_messages()
 {
     // Set outside in /admin.php
     self::$messages = wpcf_admin_validation_messages();
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:8,代码来源:validate.php


示例4: wpcf_admin_fields_save_field


//.........这里部分代码省略.........
    $save_data['description'] = $field['description'];
    $save_data['data'] = $field['data'];
    $save_data['data']['disabled_by_type'] = 0;
    // For radios or select
    if (!empty($field['data']['options'])) {
        foreach ($field['data']['options'] as $name => $option) {
            if (isset($option['title'])) {
                $option['title'] = $field['data']['options'][$name]['title'] = htmlspecialchars_decode($option['title']);
            }
            if (isset($option['value'])) {
                $option['value'] = $field['data']['options'][$name]['value'] = htmlspecialchars_decode($option['value']);
            }
            if (isset($option['display_value'])) {
                $option['display_value'] = $field['data']['options'][$name]['display_value'] = htmlspecialchars_decode($option['display_value']);
            }
            // For checkboxes
            if ($field['type'] == 'checkboxes' && isset($option['set_value']) && $option['set_value'] != '1') {
                $option['set_value'] = $field['data']['options'][$name]['set_value'] = htmlspecialchars_decode($option['set_value']);
            }
            if ($field['type'] == 'checkboxes' && !empty($option['display_value_selected'])) {
                $option['display_value_selected'] = $field['data']['options'][$name]['display_value_selected'] = htmlspecialchars_decode($option['display_value_selected']);
            }
            if ($field['type'] == 'checkboxes' && !empty($option['display_value_not_selected'])) {
                $option['display_value_not_selected'] = $field['data']['options'][$name]['display_value_not_selected'] = htmlspecialchars_decode($option['display_value_not_selected']);
            }
        }
    }
    // For checkboxes
    if ($field['type'] == 'checkbox' && $field['set_value'] != '1') {
        $field['set_value'] = htmlspecialchars_decode($field['set_value']);
    }
    if ($field['type'] == 'checkbox' && !empty($field['display_value_selected'])) {
        $field['display_value_selected'] = htmlspecialchars_decode($field['display_value_selected']);
    }
    if ($field['type'] == 'checkbox' && !empty($field['display_value_not_selected'])) {
        $field['display_value_not_selected'] = htmlspecialchars_decode($field['display_value_not_selected']);
    }
    // Save field
    $fields = get_option('wpcf-fields', array());
    $fields[$field['slug']] = $save_data;
    update_option('wpcf-fields', $fields);
    $field_id = $field['slug'];
    // WPML register strings
    if (function_exists('icl_register_string')) {
        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' name', $field['name']);
        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' description', $field['description']);
        // For radios or select
        if (!empty($field['data']['options'])) {
            foreach ($field['data']['options'] as $name => $option) {
                if ($name == 'default') {
                    continue;
                }
                if (isset($option['title'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' title', $option['title']);
                }
                if (isset($option['value'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' value', $option['value']);
                }
                if (isset($option['display_value'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value', $option['display_value']);
                }
                // For checkboxes
                if (isset($option['set_value']) && $option['set_value'] != '1') {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' value', $option['set_value']);
                }
                if (!empty($option['display_value_selected'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value selected', $option['display_value_selected']);
                }
                if (!empty($option['display_value_not_selected'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value not selected', $option['display_value_not_selected']);
                }
            }
        }
        if ($field['type'] == 'checkbox' && $field['set_value'] != '1') {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value', $field['set_value']);
        }
        if ($field['type'] == 'checkbox' && !empty($field['display_value_selected'])) {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value selected', $field['display_value_selected']);
        }
        if ($field['type'] == 'checkbox' && !empty($field['display_value_not_selected'])) {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value not selected', $field['display_value_not_selected']);
        }
        // Validation message
        if (!empty($field['data']['validate'])) {
            foreach ($field['data']['validate'] as $method => $validation) {
                if (!empty($validation['message'])) {
                    // Skip if it's same as default
                    $default_message = wpcf_admin_validation_messages($method);
                    if ($validation['message'] != $default_message) {
                        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' validation message ' . $method, $validation['message']);
                    }
                }
            }
        }
    }
    return $field_id;
}
开发者ID:sriram911,项目名称:pls,代码行数:101,代码来源:fields.php


示例5: wpcf_form_render_js_validation

/**
 * Renders JS validation rules.
 * 
 * @return type 
 */
function wpcf_form_render_js_validation($form = '.wpcf-form-validate')
{
    $elements = wpcf_form_add_js_validation('get');
    if (empty($elements)) {
        return '';
    }
    echo "\r\n" . '<script type="text/javascript">' . "\r\n" . '/* <![CDATA[ */' . "\r\n" . 'jQuery(document).ready(function(){' . "\r\n" . 'if (jQuery("' . $form . '").length > 0){' . "\r\n" . 'jQuery("' . $form . '").validate({
        errorClass: "wpcf-form-error",
        errorPlacement: function(error, element){
            error.insertBefore(element);
        },
        highlight: function(element, errorClass, validClass) {
            jQuery(element).parents(\'.collapsible\').slideDown();
            jQuery("input#publish").addClass("button-primary-disabled");
            jQuery("input#save-post").addClass("button-disabled");
            jQuery("#save-action .ajax-loading").css("visibility", "hidden");
            jQuery("#publishing-action #ajax-loading").css("visibility", "hidden");
//            jQuery.validator.defaults.highlight(element, errorClass, validClass); // Do not add class to element
		},
        unhighlight: function(element, errorClass, validClass) {
			jQuery("input#publish, input#save-post").removeClass("button-primary-disabled").removeClass("button-disabled");
//            jQuery.validator.defaults.unhighlight(element, errorClass, validClass);
		},
    });' . "\r\n";
    foreach ($elements as $id => $element) {
        if (in_array($element['#type'], array('radios'))) {
            echo 'jQuery(\'input:[name="' . $element['#name'] . '"]\').rules("add", {' . "\r\n";
        } else {
            echo 'jQuery("#' . $id . '").rules("add", {' . "\r\n";
        }
        $rules = array();
        $messages = array();
        foreach ($element['#validate'] as $method => $args) {
            if (!isset($args['value'])) {
                $args['value'] = 'true';
            }
            $rules[] = $method . ': ' . $args['value'];
            if (empty($args['message'])) {
                $args['message'] = wpcf_admin_validation_messages($method);
            }
            // TODO Why is this here?
            //            if (!empty($args['message'])) {
            //                $messages[] = $method . ': "' . wpcf_translate('field ' . $element['wpcf-id'] . ' validation message ' . $method, $args['message']) . '"';
            //            }
        }
        echo implode(',' . "\r\n", $rules);
        if (!empty($messages)) {
            echo ',' . "\r\n" . 'messages: {' . "\r\n" . implode(',' . "\r\n", $messages) . "\r\n" . '}';
        }
        echo "\r\n" . '});' . "\r\n";
    }
    echo "\r\n" . '/* ]]> */' . "\r\n" . '}' . "\r\n" . '})' . "\r\n" . '</script>' . "\r\n";
}
开发者ID:rdbartlett,项目名称:kellyspencer.co.nz,代码行数:58,代码来源:admin.php


示例6: wpcf_admin_fields_save_field


//.........这里部分代码省略.........
            // For checkboxes
            if ($field['type'] == 'checkboxes' && isset($option['set_value']) && $option['set_value'] != '1') {
                $option['set_value'] = $field['data']['options'][$name]['set_value'] = htmlspecialchars_decode($option['set_value']);
            }
            if ($field['type'] == 'checkboxes' && !empty($option['display_value_selected'])) {
                $option['display_value_selected'] = $field['data']['options'][$name]['display_value_selected'] = htmlspecialchars_decode($option['display_value_selected']);
            }
            if ($field['type'] == 'checkboxes' && !empty($option['display_value_not_selected'])) {
                $option['display_value_not_selected'] = $field['data']['options'][$name]['display_value_not_selected'] = htmlspecialchars_decode($option['display_value_not_selected']);
            }
        }
    }
    // For checkboxes
    if ($field['type'] == 'checkbox' && $field['set_value'] != '1') {
        $field['set_value'] = htmlspecialchars_decode($field['set_value']);
    }
    if ($field['type'] == 'checkbox' && !empty($field['display_value_selected'])) {
        $field['display_value_selected'] = htmlspecialchars_decode($field['display_value_selected']);
    }
    if ($field['type'] == 'checkbox' && !empty($field['display_value_not_selected'])) {
        $field['display_value_not_selected'] = htmlspecialchars_decode($field['display_value_not_selected']);
    }
    // Save field
    $fields = get_option($meta_name, array());
    $fields[$field['slug']] = $save_data;
    update_option($meta_name, $fields);
    $field_id = $field['slug'];
    // WPML register strings
    if (function_exists('icl_register_string')) {
        if (isset($_POST['wpml_cf_translation_preferences'][$field_id])) {
            $__wpml_action = intval($_POST['wpml_cf_translation_preferences'][$field_id]);
        } else {
            $__wpml_action = wpcf_wpml_get_action_by_type($field['type']);
        }
        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' name', $field['name']);
        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' description', $field['description']);
        // For radios or select
        if (!empty($field['data']['options'])) {
            foreach ($field['data']['options'] as $name => $option) {
                if ($name == 'default') {
                    continue;
                }
                if (isset($option['title'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' title', $option['title']);
                }
                if ($__wpml_action === 2) {
                    if (isset($option['value'])) {
                        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' value', $option['value']);
                    }
                }
                if (isset($option['display_value'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value', $option['display_value']);
                }
                // For checkboxes
                if (isset($option['set_value']) && $option['set_value'] != '1') {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' value', $option['set_value']);
                }
                if (!empty($option['display_value_selected'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value selected', $option['display_value_selected']);
                }
                if (!empty($option['display_value_not_selected'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value not selected', $option['display_value_not_selected']);
                }
            }
        }
        if ($field['type'] == 'checkbox' && $field['set_value'] != '1') {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value', $field['set_value']);
        }
        if ($field['type'] == 'checkbox' && !empty($field['display_value_selected'])) {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value selected', $field['display_value_selected']);
        }
        if ($field['type'] == 'checkbox' && !empty($field['display_value_not_selected'])) {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value not selected', $field['display_value_not_selected']);
        }
        // Validation message
        if (!empty($field['data']['validate'])) {
            foreach ($field['data']['validate'] as $method => $validation) {
                if (!empty($validation['message'])) {
                    // Skip if it's same as default
                    $default_message = wpcf_admin_validation_messages($method);
                    if ($validation['message'] != $default_message) {
                        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' validation message ' . $method, $validation['message']);
                    }
                }
            }
        }
    }
    /**
     * WPML update translation status
     */
    if (isset($save_data['data']) && isset($save_data['data']['submit-key'])) {
        if (isset($_POST['wpml_cf_translation_preferences'][$save_data['data']['submit-key']])) {
            do_action('wpml_config', array('section' => 'custom-fields', 'key' => wpcf_types_get_meta_prefix(wpcf_admin_fields_get_field($save_data['slug'])) . $save_data['slug'], 'value' => intval($_POST['wpml_cf_translation_preferences'][$save_data['data']['submit-key']]), 'read_only' => true));
        }
    }
    return $field_id;
}
开发者ID:aarongillett,项目名称:B22-151217,代码行数:101,代码来源:fields.php


示例7: fields_js


//.........这里部分代码省略.........
        
            // validator.errorList contains an array of objects, where each object has properties "element" and "message".  element is the actual HTML Input.
            for (var i=0;i<validator.errorList.length;i++){
                var el = validator.errorList[i].element;
                elements.push(jQuery(el).attr(\'id\'));
            }

            // validator.errorMap is an object mapping input names -> error messages
            //    for (var i in validator.errorMap) {
            //      console.log(i, ":", validator.errorMap[i]);
            //    }

            var form = jQuery(\'' . $selector . '\');
            var passed = false;
            ' . $additional_js . '
//            alert(passed);
            if (passed) {
                jQuery(\'' . $selector . '\').validate().cancelSubmit = true;
                jQuery(\'' . $selector . '\').submit();
            }
        },
        ';
        $output .= 'errorClass: "wpcf-form-error"';
        $output .= '});' . "\r\n";
        /*
         * 
         * 
         * Render JS validation code for each element collected
         */
        foreach ($elements as $id => $element) {
            // Basic check
            if (empty($element['#validate'])) {
                continue;
            }
            /*
             * 
             * Adjust rules according to field type
             * 
             * TODO Document why radios selects 'name' instead of 'id'
             */
            if (in_array($element['#type'], array('radios'))) {
                $output .= 'jQuery(\'input[name="' . $element['#name'] . '"]\').rules("add", {' . "\r\n";
            } else {
                $output .= 'jQuery("#' . $id . '").rules("add", {' . "\r\n";
            }
            $rules = array();
            // Rules output
            $messages = array();
            // Messages output
            $collected = array();
            // Various collected data (for hooks)
            /*
             * $method is registered jQuery validation method
             * $args['value'] is custom tailored parameter
             * $args['message'] is custom message that will be displayed on failure
             * 
             * $args may be used to pass other useful properties
             */
            foreach ($element['#validate'] as $method => $args) {
                // Set generic value 'true'
                if (!isset($args['value'])) {
                    $args['value'] = 'true';
                }
                // Set rule
                // since Types 1.1.5 we use element ID
                $rules[$id][$method] = $method . ': ' . $args['value'];
                // Set message
                if (empty($args['message'])) {
                    $args['message'] = wpcf_admin_validation_messages($method);
                }
                // since Types 1.1.5 we use element ID
                $messages[$id][$method] = $method . ': \'' . esc_js($args['message']) . '\'';
                // Collect!
                $collected[$id][$method] = $args;
            }
            /*
             * 
             * Add rules to output
             */
            $_rules_o = apply_filters('wpcf_validation_js_fields_rules', $rules, $collected);
            foreach ($_rules_o as $_rules) {
                $output .= implode(',' . "\r\n", $_rules);
            }
            /*
             * 
             * Add messages to output
             */
            if (!empty($messages)) {
                $_messages_o = apply_filters('wpcf_validation_js_fields_messages', $messages, $collected);
                foreach ($_messages_o as $_messages) {
                    $output .= ',' . "\r\n" . 'messages: {' . "\r\n" . implode(',' . "\r\n", $_messages) . "\r\n" . '},';
                }
            }
            // Close main jQuery function call
            $output .= "\r\n" . '});' . "\r\n";
        }
        // Close tag
        $output .= "\r\n" . '/* ]]> */' . "\r\n" . '}' . "\r\n" . '})' . "\r\n" . '</script>' . "\r\n";
        return apply_filters('wpcf_validation_js_fields_output', $output, $collected);
    }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:javascript.php


示例8: wpcf_admin_fields_save_field


//.........这里部分代码省略.........
                case 'wp-types-group':
                    $group = Types_Field_Group_Post_Factory::load($_GET['group_id']);
                    break;
                case 'wp-types-term-group':
                    $group = Types_Field_Group_Term_Factory::load($_GET['group_id']);
                    break;
                case 'wp-types-user-group':
                    $group = Types_Field_Group_User_Factory::load($_GET['group_id']);
                    break;
            }
            if (null != $group) {
                $assigned_types = $group->get_assigned_to_types();
                if (!empty($assigned_types)) {
                    $items = $group->get_assigned_to_items();
                    if (is_array($items) && !empty($items)) {
                        global $wpdb;
                        foreach ($items as $item) {
                            $wpdb->update($wpdb->postmeta, array('meta_key' => 'wpcf-' . $field['slug']), array('meta_key' => 'wpcf-' . $field['slug-pre-save'], 'post_id' => $item->ID), array('%s', '%d'), array('%s'));
                        }
                    }
                }
            }
        }
    }
    $fields[$field['slug']] = $save_data;
    update_option($option_name, $fields);
    $field_id = $field['slug'];
    // WPML register strings
    if (function_exists('icl_register_string')) {
        if (isset($_POST['wpml_cf_translation_preferences'][$field_id])) {
            $__wpml_action = intval($_POST['wpml_cf_translation_preferences'][$field_id]);
        } else {
            $__wpml_action = wpcf_wpml_get_action_by_type($field['type']);
        }
        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' name', $field['name']);
        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' description', $field['description']);
        // For radios or select
        if (!empty($field['data']['options'])) {
            foreach ($field['data']['options'] as $name => $option) {
                if ($name == 'default') {
                    continue;
                }
                if (isset($option['title'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' title', $option['title']);
                }
                if ($__wpml_action === 2) {
                    if (isset($option['value'])) {
                        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' value', $option['value']);
                    }
                }
                if (isset($option['display_value'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value', $option['display_value']);
                }
                // For checkboxes
                if (isset($option['set_value']) && $option['set_value'] != '1') {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' value', $option['set_value']);
                }
                if (!empty($option['display_value_selected'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value selected', $option['display_value_selected']);
                }
                if (!empty($option['display_value_not_selected'])) {
                    wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' option ' . $name . ' display value not selected', $option['display_value_not_selected']);
                }
            }
        }
        if ($field['type'] == 'checkbox' && $field['set_value'] != '1') {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value', $field['set_value']);
        }
        if ($field['type'] == 'checkbox' && !empty($field['display_value_selected'])) {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value selected', $field['display_value_selected']);
        }
        if ($field['type'] == 'checkbox' && !empty($field['display_value_not_selected'])) {
            // we need to translate the check box value to store
            wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' checkbox value not selected', $field['display_value_not_selected']);
        }
        // Validation message
        if (!empty($field['data']['validate'])) {
            foreach ($field['data']['validate'] as $method => $validation) {
                if (!empty($validation['message'])) {
                    // Skip if it's same as default
                    $default_message = wpcf_admin_validation_messages($method);
                    if ($validation['message'] != $default_message) {
                        wpcf_translate_register_string('plugin Types', 'field ' . $field_id . ' validation message ' . $method, $validation['message']);
                    }
                }
            }
        }
    }
    /**
     * WPML update translation status
     */
    if (isset($save_data['data']) && isset($save_data['data']['submit-key'])) {
        if (isset($_POST['wpml_cf_translation_preferences'][$save_data['data']['submit-key']])) {
            do_action('wpml_config', array('section' => 'custom-fields', 'key' => wpcf_types_get_meta_prefix(wpcf_admin_fields_get_field($save_data['slug'])) . $save_data['slug'], 'value' => intval($_POST['wpml_cf_translation_preferences'][$save_data['data']['submit-key']]), 'read_only' => true));
        }
    }
    return $field_id;
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:101,代码来源:fields.php


示例9: renderJsonData

    /**
     * Returns formatted JSON validation data.
     * 
     * @param type $selector Can be CSS class or element ID
     * @return string
     */
    static function renderJsonData($selector = '.wpcf-form-validate')
    {
        // Get collected validation rules
        $elements = wpcf_form_add_js_validation('get');
        // Not collected!
        if (empty($elements)) {
            return '';
        }
        $json = array('selector' => $selector, 'elements' => array());
        foreach ($elements as $id => $element) {
            // Basic check or skip read-only
            if (empty($element['#validate']) || isset($element['#attributes']['readonly'])) {
                continue;
            }
            $json['elements'][$id] = array('id' => $id);
            // Set selectors
            if (in_array($element['#type'], array('radios'))) {
                $json['elements'][$id]['selector'] = "input[name=\"{$element['#name']}\"]";
            } else {
                $json['elements'][$id]['selector'] = "#{$id}";
            }
            foreach ($element['#validate'] as $method => $args) {
                $args['value'] = !isset($args['value']) ? 'true' : $args['value'];
                if (empty($args['message'])) {
                    $args['message'] = wpcf_admin_validation_messages($method, $args['value']);
                }
                //Check if wordpress date format is d/m/Y and use ITA validation
                if ($method == 'date' && isset($element['wpcf-type']) && $element['wpcf-type'] == 'date' && get_option('date_format') == 'd/m/Y') {
                    $method = 'dateITA:true';
                }
                // Set JSON data
                $json['elements'][$id]['rules'][] = array('method' => $method, 'value' => $args['value'], 'message' => $args['message']);
            }
        }
        ob_start();
        ?>

        <script type="text/javascript">
            //<![CDATA[
            types.validation.push(<?php 
        echo json_encode($json);
        ?>
);
            <?php 
        if (defined('DOING_AJAX')) {
            ?>
            jQuery(document).ready(function($) {
                typesValidation.setRules();
            });
        <?php 
        }
        ?>
            /* ]]> */
        </script>

        <?php 
        $output = ob_get_contents();
        ob_get_clean();
        wp_enqueue_script('types-validation');
        return $output;
    }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:67,代码来源:validation.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wpcf_compare_wp_version函数代码示例发布时间:2022-05-23
下一篇:
PHP wpcf_admin_post_process_fields函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap