本文整理汇总了PHP中wpcf_admin_message_store函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_message_store函数的具体用法?PHP wpcf_admin_message_store怎么用?PHP wpcf_admin_message_store使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_admin_message_store函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf_admin_settings_form_submit
/**
* Saves settings.
*
* @param type $form
*/
function wpcf_admin_settings_form_submit($form)
{
$settings = wpcf_get_settings();
$data = $_POST['wpcf_settings'];
foreach ($settings as $setting => $value) {
if (!isset($data[$setting])) {
$settings[$setting] = 0;
} else {
$settings[$setting] = $data[$setting];
}
}
update_option('wpcf_settings', $settings);
// Credits
require_once WPCF_EMBEDDED_INC_ABSPATH . '/footer-credit.php';
$option = get_option('wpcf_footer_credit', array());
if (!isset($option['message'])) {
$data = wpcf_footer_credit_defaults();
shuffle($data);
$option['message'] = rand(0, count($data));
}
if (!isset($_POST['show_credits'])) {
update_option('wpcf_footer_credit', array('active' => 0, 'message' => $option['message']));
} else {
update_option('wpcf_footer_credit', array('active' => 1, 'message' => $option['message']));
}
wpcf_admin_message_store(__('Settings saved', 'wpcf'));
}
示例2: wpcf_admin_custom_fields_change_type
/**
* Changes field type.
* Modified by Gen, 13.02.2013
*
* @param type $fields
* @param type $type
*/
function wpcf_admin_custom_fields_change_type($fields, $type, $post_type = TYPES_CUSTOM_FIELD_GROUP_CPT_NAME, $meta_name = 'wpcf-fields')
{
if (!is_array($fields)) {
$fields = array(strval($fields));
}
$fields = wpcf_types_cf_under_control('add', array('fields' => $fields, 'type' => $type), $post_type, $meta_name);
/**
* wpcf_filter_field_control_change_type_allowed_types_from
*
* Filter the field types that you can switch to, given a type field
*
* @param array Valid targets for a given origin type
* @param string Field type to switch from
*
* @since 1.8.9
*/
$allowed = array('audio' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'url', 'textarea', 'textfield', 'email', 'date', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'audio'), 'textfield' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'textfield', 'textarea', 'email', 'url', 'date', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'textfield'), 'textarea' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'textfield', 'textarea', 'email', 'url', 'date', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'textarea'), 'date' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'date', 'textarea', 'textfield', 'email', 'url', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'date'), 'email' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'email', 'textarea', 'textfield', 'date', 'url', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'email'), 'embed' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'url', 'textarea', 'textfield', 'email', 'date', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'embed'), 'file' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'file', 'textarea', 'textfield', 'email', 'url', 'phone', 'fdate', 'image', 'numeric', 'audio', 'video', 'embed'), 'file'), 'image' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'image', 'textarea', 'textfield', 'email', 'url', 'phone', 'file', 'idate', 'numeric', 'audio', 'video', 'embed'), 'image'), 'numeric' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'numeric', 'textarea', 'textfield', 'email', 'url', 'phone', 'file', 'image', 'date', 'audio', 'video', 'embed'), 'numeric'), 'phone' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'phone', 'textarea', 'textfield', 'email', 'url', 'date', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'phone'), 'select' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'select', 'textarea', 'textfield', 'date', 'email', 'url', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'select'), 'skype' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'skype', 'textarea', 'textfield', 'date', 'email', 'url', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'skype'), 'url' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'url', 'textarea', 'textfield', 'email', 'date', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'url'), 'checkbox' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'checkbox', 'textarea', 'textfield', 'email', 'url', 'date', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'checkbox'), 'radio' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'radio', 'textarea', 'textfield', 'email', 'url', 'date', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'radio'), 'video' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'url', 'textarea', 'textfield', 'email', 'date', 'phone', 'file', 'image', 'numeric', 'audio', 'video', 'embed'), 'video'), 'wysiwyg' => apply_filters('wpcf_filter_field_control_change_type_allowed_types_from', array('wysiwyg', 'textarea'), 'wysiwyg'));
/**
* wpcf_filter_field_control_change_type_allowed_types
*
* Filter the pairs field type origin -> valid field type targets when using the fields control change field type feature
*
* @param array $allowed Valid correspondence between field types and target field types
*
* @since 1.8.9
*/
$allowed = apply_filters('wpcf_filter_field_control_change_type_allowed_types', $allowed);
$all_fields = wpcf_admin_fields_get_fields(false, false, false, $meta_name);
foreach ($fields as $field_id) {
if (!isset($all_fields[$field_id])) {
continue;
}
$field = $all_fields[$field_id];
if (!in_array($type, $allowed[$field['type']])) {
wpcf_admin_message_store(sprintf(__('Field "%s" type was converted from %s to %s. You need to set some further settings in the group editor.', 'wpcf'), $field['name'], $field['type'], $type));
$all_fields[$field_id]['data']['disabled_by_type'] = 1;
} else {
$all_fields[$field_id]['data']['disabled'] = 0;
$all_fields[$field_id]['data']['disabled_by_type'] = 0;
}
if ($field['type'] == 'numeric' && isset($all_fields[$field_id]['data']['validate']['number'])) {
unset($all_fields[$field_id]['data']['validate']['number']);
} else {
if ($type == 'numeric') {
$all_fields[$field_id]['data']['validate'] = array('number' => array('active' => true, 'message' => __('Please enter numeric data', 'wpcf')));
}
}
$all_fields[$field_id]['type'] = $type;
}
update_option($meta_name, $all_fields);
}
示例3: wpcf_admin_custom_fields_control_bulk_actions
/**
* Submitted Bulk actions.
*/
function wpcf_admin_custom_fields_control_bulk_actions($action = '')
{
if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'custom_fields_control_bulk')) {
return;
}
switch ($action) {
case 'wpcf-change-type-bulk':
if (true && isset($_POST['wpcf-id']) && isset($_POST['fields'])) {
wpcf_admin_custom_fields_change_type($_POST['fields'], $_POST['wpcf-id'], TYPES_CUSTOM_FIELD_GROUP_CPT_NAME);
}
break;
case 'wpcf-deactivate-bulk':
$fields = wpcf_admin_fields_get_fields(false, true);
foreach ($_POST['fields'] as $field_id) {
$field_id = sanitize_text_field($field_id);
if (isset($fields[$field_id])) {
$fields[$field_id]['data']['disabled'] = 1;
wpcf_admin_message_store(sprintf(__('Removed from Types control: %s', 'wpcf'), $fields[$field_id]['name']));
}
}
wpcf_admin_fields_save_fields($fields);
break;
case 'wpcf-activate-bulk':
$fields = wpcf_admin_fields_get_fields(false, true);
$fields_bulk = wpcf_types_cf_under_control('add', array('fields' => $_POST['fields']));
foreach ($fields_bulk as $field_id) {
if (isset($fields[$field_id])) {
$fields[$field_id]['data']['disabled'] = 0;
}
wpcf_admin_message_store(sprintf(__('Added to Types control: %s', 'wpcf'), $field_id));
}
wpcf_admin_fields_save_fields($fields);
break;
case 'wpcf-delete-bulk':
require_once WPCF_INC_ABSPATH . '/fields.php';
$failed = array();
$success = array();
foreach ($_POST['fields'] as $field_id) {
$field_id = sanitize_text_field($field_id);
$response = wpcf_admin_fields_delete_field($field_id);
if (!$response) {
$failed[] = str_replace('_' . md5('wpcf_not_controlled'), '', $field_id);
} else {
$success[] = $field_id;
}
}
if (!empty($success)) {
wpcf_admin_message_store(sprintf(__('Fields %s have been deleted.', 'wpcf'), implode(', ', $success)));
}
if (!empty($failed)) {
wpcf_admin_message_store(sprintf(__('Fields %s are not Types fields. Types wont delete these fields.', 'wpcf'), implode(', ', $failed)), 'error');
}
break;
case 'wpcf-add-to-group-bulk':
case 'wpcf-remove-from-group-bulk':
if (true && isset($_POST['wpcf-id']) && isset($_POST['fields'])) {
$fields = array_values((array) $_POST['fields']);
if (!empty($fields)) {
$groups = explode(',', $_POST['wpcf-id']);
foreach ($groups as $group_id) {
switch ($action) {
case 'wpcf-add-to-group-bulk':
wpcf_admin_fields_save_group_fields($group_id, $fields, true);
break;
case 'wpcf-remove-from-group-bulk':
wpcf_admin_fields_remove_field_from_group_bulk($group_id, $fields);
break;
}
}
}
}
break;
}
wp_safe_redirect(esc_url_raw(add_query_arg(array('page' => 'wpcf-custom-fields-control'), admin_url('admin.php'))));
die;
}
示例4: wpcf_admin_custom_taxonomies_form_submit
/**
* Submit function
*/
function wpcf_admin_custom_taxonomies_form_submit($form)
{
if (!isset($_POST['ct'])) {
return false;
}
$data = $_POST['ct'];
$update = false;
// Sanitize data
if (isset($data['wpcf-tax'])) {
$update = true;
$data['wpcf-tax'] = sanitize_title($data['wpcf-tax']);
}
if (isset($data['slug'])) {
$data['slug'] = sanitize_title($data['slug']);
}
if (isset($data['rewrite']['slug'])) {
$data['rewrite']['slug'] = remove_accents($data['rewrite']['slug']);
$data['rewrite']['slug'] = strtolower($data['rewrite']['slug']);
$data['rewrite']['slug'] = trim($data['rewrite']['slug']);
}
// Set tax name
$tax = '';
if (!empty($data['slug'])) {
$tax = $data['slug'];
} else {
if (!empty($data['wpcf-tax'])) {
$tax = $data['wpcf-tax'];
} else {
if (!empty($data['labels']['singular_name'])) {
$tax = sanitize_title($data['labels']['singular_name']);
}
}
}
if (empty($tax)) {
wpcf_admin_message(__('Please set taxonomy name', 'wpcf'), 'error');
return false;
}
if (empty($data['labels']['singular_name'])) {
$data['labels']['singular_name'] = $tax;
}
$data['slug'] = $tax;
$custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
// Check reserved name
if (wpcf_is_reserved_name($tax)) {
wpcf_admin_message(sprintf(__('The name %s is reserved in WordPress and cannot be used in custom taxonomies. Please use a different name.', 'wpcf'), $tax), 'error');
return false;
}
// Check if exists
if ($update && !array_key_exists($data['wpcf-tax'], $custom_taxonomies)) {
wpcf_admin_message(__("Custom taxonomy do not exist", 'wpcf'), 'error');
return false;
}
// Check overwriting
if (!$update && array_key_exists($tax, $custom_taxonomies)) {
wpcf_admin_message(__('Custom taxonomy already exists', 'wpcf'), 'error');
return false;
}
// Check if our tax overwrites some tax outside
$tax_exists = get_taxonomy($tax);
if (!$update && !empty($tax_exists)) {
wpcf_admin_message(__('Taxonomy already exists', 'wpcf'), 'error');
return false;
}
// Check if renaming
if ($update && $data['wpcf-tax'] != $tax) {
global $wpdb;
$wpdb->update($wpdb->term_taxonomy, array('taxonomy' => $tax), array('taxonomy' => $data['wpcf-tax']), array('%s'), array('%s'));
// Delete old type
unset($custom_taxonomies[$data['wpcf-tax']]);
}
// Check if active
if (isset($custom_taxonomies[$tax]['disabled'])) {
$data['disabled'] = $custom_taxonomies[$tax]['disabled'];
}
// Sync with post types
if (!empty($data['supports'])) {
$post_types = get_option('wpcf-custom-types', array());
foreach ($post_types as $id => $type) {
if (array_key_exists($id, $data['supports'])) {
$post_types[$id]['taxonomies'][$data['slug']] = 1;
} else {
unset($post_types[$id]['taxonomies'][$data['slug']]);
}
}
update_option('wpcf-custom-types', $post_types);
}
$custom_taxonomies[$tax] = $data;
update_option('wpcf-custom-taxonomies', $custom_taxonomies);
// WPML register strings
wpcf_custom_taxonimies_register_translation($tax, $data);
wpcf_admin_message_store(__('Custom taxonomy saved', 'wpcf'));
// Flush rewrite rules
flush_rewrite_rules();
// Redirect
wp_redirect(admin_url('admin.php?page=wpcf-edit-tax&wpcf-tax=' . $tax . '&wpcf-rewrite=1'));
die;
}
示例5: wpcf_admin_post_save_post_hook
/**
* Important save_post hook.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @internal breakpoint
* @param type $post_ID
* @param type $post
*/
function wpcf_admin_post_save_post_hook($post_ID, $post)
{
if (defined('WPTOOLSET_FORMS_VERSION')) {
global $wpcf;
$errors = false;
// Do not save post if is type of
if (in_array($post->post_type, array('revision', 'view', 'view-template', 'cred-form', 'nav_menu_item', 'mediapage'))) {
return false;
}
$_post_wpcf = array();
if (!empty($_POST['wpcf'])) {
$_post_wpcf = $_POST['wpcf'];
}
/**
* handle checkbox
*/
if (array_key_exists('_wptoolset_checkbox', $_POST) && is_array($_POST['_wptoolset_checkbox'])) {
foreach ($_POST['_wptoolset_checkbox'] as $key => $field_value) {
$field_slug = preg_replace('/^wpcf\\-/', '', $key);
if (array_key_exists($field_slug, $_post_wpcf)) {
continue;
}
$_post_wpcf[$field_slug] = false;
}
}
if (count($_post_wpcf)) {
/**
* check some attachment to delete
*/
$delete_attachments = apply_filters('wpcf_delete_attachments', true);
$images_to_delete = array();
if ($delete_attachments && isset($_POST['wpcf']) && array_key_exists('delete-image', $_POST['wpcf']) && is_array($_POST['wpcf']['delete-image'])) {
foreach ($_POST['wpcf']['delete-image'] as $image) {
$images_to_delete[$image] = 1;
}
}
foreach ($_post_wpcf as $field_slug => $field_value) {
// Get field by slug
$field = wpcf_fields_get_field_by_slug($field_slug);
if (empty($field)) {
continue;
}
// Skip copied fields
if (isset($_POST['wpcf_repetitive_copy'][$field['slug']])) {
continue;
}
$_field_value = !types_is_repetitive($field) ? array($field_value) : $field_value;
// Set config
$config = wptoolset_form_filter_types_field($field, $post_ID, $_post_wpcf);
/**
* remove from images_to_delete if user add again
*/
if ($delete_attachments && 'image' == $config['type']) {
$images = $_field_value;
if (!is_array($images)) {
$images = array($images);
}
foreach ($images as $image) {
if (array_key_exists($image, $images_to_delete)) {
unset($images_to_delete[$image]);
}
}
}
foreach ($_field_value as $_k => $_val) {
// Check if valid
$validation = wptoolset_form_validate_field('post', $config, $_val);
$conditional = wptoolset_form_conditional_check($config);
$not_valid = is_wp_error($validation) || !$conditional;
if (is_wp_error($validation)) {
$errors = true;
$_errors = $validation->get_error_data();
$_msg = sprintf(__('Field "%s" not updated:', 'wpcf'), $field['name']);
wpcf_admin_message_store($_msg . ' ' . implode(', ', $_errors), 'error');
}
if ($not_valid) {
if (types_is_repetitive($field)) {
unset($field_value[$_k]);
} else {
break;
}
}
}
// Save field
if (types_is_repetitive($field)) {
$wpcf->repeater->set($post_ID, $field);
$wpcf->repeater->save($field_value);
} else {
if (!$not_valid) {
$wpcf->field->set($post_ID, $field);
$wpcf->field->save($field_value);
//.........这里部分代码省略.........
示例6: wpcf_admin_userprofilesave_init
function wpcf_admin_userprofilesave_init($user_id)
{
if (defined('WPTOOLSET_FORMS_VERSION')) {
global $wpcf;
$errors = false;
/**
* check checkbox type fields to delete or save empty if needed
*/
$groups = wpcf_admin_usermeta_get_groups_fields();
foreach ($groups as $group) {
if (!array_key_exists('fields', $group) || empty($group['fields'])) {
continue;
}
foreach ($group['fields'] as $field) {
switch ($field['type']) {
case 'checkboxes':
if (!array_key_exists('wpcf', $_POST) || !array_key_exists($field['slug'], $_POST['wpcf'])) {
delete_user_meta($user_id, $field['meta_key']);
}
break;
case 'checkbox':
if (!array_key_exists('wpcf', $_POST) || !array_key_exists($field['slug'], $_POST['wpcf'])) {
if ('yes' == $field['data']['save_empty']) {
$_POST['wpcf'][$field['slug']] = 0;
} else {
delete_user_meta($user_id, $field['meta_key']);
}
}
break;
}
}
}
// Save meta fields
if (!empty($_POST['wpcf'])) {
foreach ($_POST['wpcf'] as $field_slug => $field_value) {
// Get field by slug
$field = wpcf_fields_get_field_by_slug($field_slug, 'wpcf-usermeta');
if (empty($field)) {
continue;
}
// Skip copied fields
if (isset($_POST['wpcf_repetitive_copy'][$field['slug']])) {
continue;
}
$_field_value = !types_is_repetitive($field) ? array($field_value) : $field_value;
// Set config
$config = wptoolset_form_filter_types_field($field, $user_id);
foreach ($_field_value as $_k => $_val) {
// Check if valid
$valid = wptoolset_form_validate_field('your-profile', $config, $_val);
if (is_wp_error($valid)) {
$errors = true;
$_errors = $valid->get_error_data();
$_msg = sprintf(__('Field "%s" not updated:', 'wpcf'), $field['name']);
wpcf_admin_message_store($_msg . ' ' . implode(', ', $_errors), 'error');
if (types_is_repetitive($field)) {
unset($field_value[$_k]);
} else {
break;
}
}
}
// Save field
if (types_is_repetitive($field)) {
$wpcf->usermeta_repeater->set($user_id, $field);
$wpcf->usermeta_repeater->save($field_value);
} else {
$wpcf->usermeta_field->set($user_id, $field);
$wpcf->usermeta_field->usermeta_save($field_value);
}
do_action('wpcf_user_field_saved', $user_id, $field);
// TODO Move to checkboxes
if ($field['type'] == 'checkboxes') {
$field_data = wpcf_admin_fields_get_field($field['id'], false, false, false, 'wpcf-usermeta');
if (!empty($field_data['data']['options'])) {
$update_data = array();
foreach ($field_data['data']['options'] as $option_id => $option_data) {
if (!isset($_POST['wpcf'][$field['id']][$option_id])) {
if (isset($field_data['data']['save_empty']) && $field_data['data']['save_empty'] == 'yes') {
$update_data[$option_id] = 0;
}
} else {
$update_data[$option_id] = $_POST['wpcf'][$field['id']][$option_id];
}
}
update_user_meta($user_id, $field['meta_key'], $update_data);
}
}
}
}
if ($errors) {
update_post_meta($user_id, '__wpcf-invalid-fields', true);
}
do_action('wpcf_user_saved', $user_id);
return;
}
global $wpcf;
$all_fields = array();
$_not_valid = array();
$_error = false;
//.........这里部分代码省略.........
示例7: wpcf_admin_custom_types_form_submit
//.........这里部分代码省略.........
if (isset($data['wpcf-post-type'])) {
$update = true;
$data['wpcf-post-type'] = sanitize_title($data['wpcf-post-type']);
}
if (isset($data['slug'])) {
$data['slug'] = sanitize_title($data['slug']);
}
if (isset($data['rewrite']['slug'])) {
$data['rewrite']['slug'] = remove_accents($data['rewrite']['slug']);
$data['rewrite']['slug'] = strtolower($data['rewrite']['slug']);
$data['rewrite']['slug'] = trim($data['rewrite']['slug']);
}
// Set post type name
$post_type = '';
if (!empty($data['slug'])) {
$post_type = $data['slug'];
} else {
if (!empty($data['wpcf-post-type'])) {
$post_type = $data['wpcf-post-type'];
} else {
if (!empty($data['labels']['singular_name'])) {
$post_type = sanitize_title($data['labels']['singular_name']);
}
}
}
if (empty($post_type)) {
wpcf_admin_message(__('Please set post type name', 'wpcf'), 'error');
// $form->triggerError();
return false;
}
$data['slug'] = $post_type;
$custom_types = get_option('wpcf-custom-types', array());
// Check reserved name
$reserved = wpcf_is_reserved_name($post_type);
if (is_wp_error($reserved)) {
wpcf_admin_message($reserved->get_error_message(), 'error');
return false;
}
// Check overwriting
if (!$update && array_key_exists($post_type, $custom_types)) {
wpcf_admin_message(__('Custom post type already exists', 'wpcf'), 'error');
// $form->triggerError();
return false;
}
/*
* Since Types 1.2
* We do not allow plural and singular names to be same.
*/
if ($wpcf->post_types->check_singular_plural_match($data)) {
wpcf_admin_message($wpcf->post_types->message('warning_singular_plural_match'), 'error');
return false;
}
// Check if renaming then rename all post entries and delete old type
if (!empty($data['wpcf-post-type']) && $data['wpcf-post-type'] != $post_type) {
global $wpdb;
$wpdb->update($wpdb->posts, array('post_type' => $post_type), array('post_type' => $data['wpcf-post-type']), array('%s'), array('%s'));
// Set protected data
$protected_data_check = $custom_types[$data['wpcf-post-type']];
// Delete old type
unset($custom_types[$data['wpcf-post-type']]);
$data['wpcf-post-type'] = $post_type;
} else {
// Set protected data
$protected_data_check = !empty($custom_types[$post_type]) ? $custom_types[$post_type] : array();
}
// Check if active
if (isset($custom_types[$post_type]['disabled'])) {
$data['disabled'] = $custom_types[$post_type]['disabled'];
}
// Sync taxes with custom taxes
if (!empty($data['taxonomies'])) {
$taxes = get_option('wpcf-custom-taxonomies', array());
foreach ($taxes as $id => $tax) {
if (array_key_exists($id, $data['taxonomies'])) {
$taxes[$id]['supports'][$data['slug']] = 1;
} else {
unset($taxes[$id]['supports'][$data['slug']]);
}
}
update_option('wpcf-custom-taxonomies', $taxes);
}
// Preserve protected data
foreach ($protected_data_check as $key => $value) {
if (strpos($key, '_') !== 0) {
unset($protected_data_check[$key]);
}
}
// Merging protected data
$custom_types[$post_type] = array_merge($protected_data_check, $data);
update_option('wpcf-custom-types', $custom_types);
// WPML register strings
wpcf_custom_types_register_translation($post_type, $data);
wpcf_admin_message_store(apply_filters('types_message_custom_post_type_saved', __('Custom post type saved', 'wpcf'), $data, $update), 'custom');
// Flush rewrite rules
flush_rewrite_rules();
do_action('wpcf_custom_types_save', $data);
// Redirect
wp_redirect(admin_url('admin.php?page=wpcf-edit-type&wpcf-post-type=' . $post_type . '&wpcf-rewrite=1'));
die;
}
示例8: save
//.........这里部分代码省略.........
unset($custom_types[$data[$this->get_id]]);
$data[$this->get_id] = $post_type;
} else {
// Set protected data
$protected_data_check = !empty($custom_types[$post_type]) ? $custom_types[$post_type] : array();
}
// Check if active
if (isset($custom_types[$post_type]['disabled'])) {
$data['disabled'] = $custom_types[$post_type]['disabled'];
}
}
// Sync taxes with custom taxes
$taxes = get_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array());
foreach ($taxes as $id => $tax) {
if (isset($data['taxonomies']) && !empty($data['taxonomies']) && array_key_exists($id, $data['taxonomies'])) {
$taxes[$id]['supports'][$data['slug']] = 1;
} else {
if (isset($taxes[$id]['supports'][$data['slug']])) {
unset($taxes[$id]['supports'][$data['slug']]);
}
}
}
update_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, $taxes);
// Preserve protected data
foreach ($protected_data_check as $key => $value) {
if (strpos($key, '_') !== 0) {
unset($protected_data_check[$key]);
}
}
/**
* save custom field group
*/
/* removed types-608
$post_to_groups = isset($_POST['ct']['custom-field-group'])?$_POST['ct']['custom-field-group']:array();
$groups = $this->fields->get_groups_with_post_types();
foreach( $groups as $group) {
$post_types_to_save = $group['_wp_types_group_post_types'];
// save
if ( array_key_exists($group['id'], $post_to_groups)) {
$post_types_to_save[] = $data['slug'];
} else {
if(($key = array_search($data['slug'], $post_types_to_save)) !== false) {
unset($post_types_to_save[$key]);
}
if (
false
|| empty($post_types_to_save)
|| (
true
&& 1 == sizeof($post_types_to_save)
&& 'all' == current($post_types_to_save)
)
) {
$post_types_to_save = array();
foreach( get_post_types() as $key => $value ) {
if ( $data['slug'] == $value) {
continue;
}
if ( in_array($value, $wpcf->excluded_post_types) ) {
continue;
}
$post_types_to_save[] = $value;
}
}
}
wpcf_admin_fields_save_group_post_types($group['id'], $post_types_to_save);
}
*/
/**
* set last edit time
*/
$data[TOOLSET_EDIT_LAST] = time();
/**
* set last edit author
*/
$data[WPCF_AUTHOR] = get_current_user_id();
/**
* add builid in
*/
if ($data['_builtin'] && !isset($protected_data_check[$data['slug']])) {
$protected_data_check[$data['slug']] = array();
}
// Merging protected data
$custom_types[$post_type] = array_merge($protected_data_check, $data);
update_option(WPCF_OPTION_NAME_CUSTOM_TYPES, $custom_types);
// WPML register strings
if (!$data['_builtin']) {
wpcf_custom_types_register_translation($post_type, $data);
}
// success message
$msg = $update ? __('Post Type saved.', 'wpcf') : __('New Post Type created.', 'wpcf');
wpcf_admin_message_store($msg, 'updated notice notice-success is-dismissible');
flush_rewrite_rules();
if (!$data['_builtin']) {
do_action('wpcf_custom_types_save', $data);
}
// Redirect
wp_safe_redirect(esc_url_raw(add_query_arg(array('page' => 'wpcf-edit-type', $this->get_id => $post_type, 'wpcf-message' => 'view', 'flush' => '1'), admin_url('admin.php'))));
die;
}
示例9: wpcf_admin_custom_types_form_submit
/**
* Submit function
*/
function wpcf_admin_custom_types_form_submit($form)
{
if (!isset($_POST['ct'])) {
return false;
}
$data = $_POST['ct'];
$update = false;
// Sanitize data
if (isset($data['wpcf-post-type'])) {
$update = true;
$data['wpcf-post-type'] = sanitize_title($data['wpcf-post-type']);
}
if (isset($data['slug'])) {
$data['slug'] = sanitize_title($data['slug']);
}
if (isset($data['rewrite']['slug'])) {
$data['rewrite']['slug'] = remove_accents($data['rewrite']['slug']);
$data['rewrite']['slug'] = strtolower($data['rewrite']['slug']);
$data['rewrite']['slug'] = trim($data['rewrite']['slug']);
}
// Set post type name
$post_type = '';
if (!empty($data['slug'])) {
$post_type = $data['slug'];
} else {
if (!empty($data['wpcf-post-type'])) {
$post_type = $data['wpcf-post-type'];
} else {
if (!empty($data['labels']['singular_name'])) {
$post_type = sanitize_title($data['labels']['singular_name']);
}
}
}
if (empty($post_type)) {
wpcf_admin_message(__('Please set post type name', 'wpcf'), 'error');
// $form->triggerError();
return false;
}
$data['slug'] = $post_type;
$custom_types = get_option('wpcf-custom-types', array());
// Check overwriting
if (!$update && array_key_exists($post_type, $custom_types)) {
wpcf_admin_message(__('Custom post type already exists', 'wpcf'), 'error');
// $form->triggerError();
return false;
}
// Check if renaming then rename all post entries and delete old type
if (!empty($data['wpcf-post-type']) && $data['wpcf-post-type'] != $post_type) {
global $wpdb;
$wpdb->update($wpdb->posts, array('post_type' => $post_type), array('post_type' => $data['wpcf-post-type']), array('%s'), array('%s'));
// Delete old type
unset($custom_types[$data['wpcf-post-type']]);
}
// Check if active
if (isset($custom_types[$post_type]['disabled'])) {
$data['disabled'] = $custom_types[$post_type]['disabled'];
}
// Sync taxes with custom taxes
if (!empty($data['taxonomies'])) {
$taxes = get_option('wpcf-custom-taxonomies', array());
foreach ($taxes as $id => $tax) {
if (array_key_exists($id, $data['taxonomies'])) {
$taxes[$id]['supports'][$data['slug']] = 1;
} else {
unset($taxes[$id]['supports'][$data['slug']]);
}
}
update_option('wpcf-custom-taxonomies', $taxes);
}
$custom_types[$post_type] = $data;
update_option('wpcf-custom-types', $custom_types);
wpcf_admin_message_store(__('Custom post type saved', 'wpcf'));
// Flush rewrite rules
flush_rewrite_rules();
// Redirect
wp_redirect(admin_url('admin.php?page=wpcf-edit-type&wpcf-post-type=' . $post_type . '&wpcf-rewrite=1'));
die;
}
示例10: wpcf_admin_save_fields_groups_submit
//.........这里部分代码省略.........
// Check if already exists
$exists = get_page_by_title($_POST['wpcf']['group']['name'], 'OBJECT', 'wp-types-group');
if (!empty($exists)) {
$form->triggerError();
wpcf_admin_message(sprintf(__("A group by name <em>%s</em> already exists. Please use a different name and save again.", 'wpcf'), htmlspecialchars($_POST['wpcf']['group']['name'])), 'error');
return $form;
}
}
// Save fields for future use
$fields = array();
if (!empty($_POST['wpcf']['fields'])) {
// Before anything - search unallowed characters
foreach ($_POST['wpcf']['fields'] as $key => $field) {
if (empty($field['slug']) && preg_match('#[^a-zA-Z0-9\\s\\_\\-]#', $field['name']) || !empty($field['slug']) && preg_match('#[^a-zA-Z0-9\\s\\_\\-]#', $field['slug'])) {
$form->triggerError();
wpcf_admin_message(sprintf(__('Field slugs cannot contain non-English characters. Please edit this field name %s and save again.', 'wpcf'), $field['name']), 'error');
return $form;
}
if (!empty($field['name']) && is_numeric($field['name']) || !empty($field['slug']) && is_numeric($field['slug'])) {
$form->triggerError();
wpcf_admin_message(sprintf(__('Field names or slugs cannot contain only numbers.', 'wpcf'), $field['name']), 'error');
return $form;
}
}
// First check all fields
foreach ($_POST['wpcf']['fields'] as $key => $field) {
$field = apply_filters('wpcf_field_pre_save', $field);
if (!empty($field['is_new'])) {
// Check name and slug
if (wpcf_types_cf_under_control('check_exists', sanitize_title($field['name']))) {
$form->triggerError();
wpcf_admin_message(sprintf(__('Field with name "%s" already exists', 'wpcf'), $field['name']), 'error');
return $form;
}
if (isset($field['slug']) && wpcf_types_cf_under_control('check_exists', sanitize_title($field['slug']))) {
$form->triggerError();
wpcf_admin_message(sprintf(__('Field with slug "%s" already exists', 'wpcf'), $field['slug']), 'error');
return $form;
}
}
// Field ID and slug are same thing
$field_id = wpcf_admin_fields_save_field($field);
if (is_wp_error($field_id)) {
$form->triggerError();
wpcf_admin_message($field_id->get_error_message(), 'error');
return $form;
}
if (!empty($field_id)) {
$fields[] = $field_id;
}
// WPML
if (function_exists('wpml_cf_translation_preferences_store')) {
$wpml_save_cf = wpml_cf_translation_preferences_store($key, wpcf_types_get_meta_prefix(wpcf_admin_fields_get_field($field_id)) . $field_id);
}
}
}
// Save group
$post_types = isset($_POST['wpcf']['group']['supports']) ? $_POST['wpcf']['group']['supports'] : array();
$taxonomies_post = isset($_POST['wpcf']['group']['taxonomies']) ? $_POST['wpcf']['group']['taxonomies'] : array();
$admin_style = $_POST['wpcf']['group']['admin_styles'];
$terms = array();
foreach ($taxonomies_post as $taxonomy) {
foreach ($taxonomy as $tax => $term) {
$terms[] = $term;
}
}
// Rename if needed
if (isset($_REQUEST['group_id'])) {
$_POST['wpcf']['group']['id'] = intval($_REQUEST['group_id']);
}
$group_id = wpcf_admin_fields_save_group($_POST['wpcf']['group']);
$_POST['wpcf']['group']['id'] = $group_id;
// Set open fieldsets
if ($new_group && !empty($group_id)) {
$open_fieldsets = get_user_meta(get_current_user_id(), 'wpcf-group-form-toggle', true);
if (isset($open_fieldsets[-1])) {
$open_fieldsets[$group_id] = $open_fieldsets[-1];
unset($open_fieldsets[-1]);
update_user_meta(get_current_user_id(), 'wpcf-group-form-toggle', $open_fieldsets);
}
}
// Rest of processes
if (!empty($group_id)) {
wpcf_admin_fields_save_group_fields($group_id, $fields);
wpcf_admin_fields_save_group_post_types($group_id, $post_types);
wpcf_admin_fields_save_group_terms($group_id, $terms);
wpcf_admin_fields_save_group_admin_styles($group_id, $admin_style);
if (empty($_POST['wpcf']['group']['templates'])) {
$_POST['wpcf']['group']['templates'] = array();
}
wpcf_admin_fields_save_group_templates($group_id, $_POST['wpcf']['group']['templates']);
$_POST['wpcf']['group']['fields'] = isset($_POST['wpcf']['fields']) ? $_POST['wpcf']['fields'] : array();
do_action('wpcf_save_group', $_POST['wpcf']['group']);
wpcf_admin_message_store(apply_filters('types_message_custom_fields_saved', __('Group saved', 'wpcf'), $_POST['wpcf']['group']['name'], $new_group ? false : true), 'custom');
wp_redirect(admin_url('admin.php?page=wpcf-edit&group_id=' . $group_id));
die;
} else {
wpcf_admin_message_store(__('Error saving group', 'wpcf'), 'error');
}
}
示例11: wpcf_admin_post_save_post_hook
/**
* save_post hook.
*
* @param type $post_ID
* @param type $post
*/
function wpcf_admin_post_save_post_hook($post_ID, $post)
{
// TODO Check if this prevents saving from outside of post form
if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'update-' . $post->post_type . '_' . $post_ID)) {
return false;
}
if (!in_array($post->post_type, array('revision', 'attachment', 'wp-types-group', 'view', 'view-template'))) {
// Get groups
$groups = wpcf_admin_post_get_post_groups_fields($post);
if (empty($groups)) {
return false;
}
$all_fields = array();
foreach ($groups as $group) {
// Process fields
$fields = wpcf_admin_post_process_fields($post, $group['fields'], true);
// Validate fields
$form = wpcf_form_simple_validate($fields);
$all_fields = $all_fields + $fields;
$error = $form->isError();
// Trigger form error
if ($error) {
wpcf_admin_message_store(__('Please check your input data', 'wpcf'), 'error');
}
}
// Save invalid elements so user can be informed after redirect
if (!empty($all_fields)) {
update_post_meta($post_ID, 'wpcf-invalid-fields', $all_fields);
}
// Save meta fields
if (!empty($_POST['wpcf'])) {
foreach ($_POST['wpcf'] as $field_slug => $field_value) {
// Don't save invalid
if (isset($all_fields[wpcf_types_get_meta_prefix(wpcf_admin_fields_get_field($field_slug)) . $field_slug]) && isset($all_fields[wpcf_types_get_meta_prefix(wpcf_admin_fields_get_field($field_slug)) . $field_slug]['#error'])) {
continue;
}
// Get field by slug
$field = wpcf_fields_get_field_by_slug($field_slug);
if (!empty($field)) {
// Apply filters
$field_value = apply_filters('wpcf_fields_value_save', $field_value, $field['type'], $field_slug);
$field_value = apply_filters('wpcf_fields_slug_' . $field_slug . '_value_save', $field_value);
$field_value = apply_filters('wpcf_fields_type_' . $field['type'] . '_value_save', $field_value);
// Save field
update_post_meta($post_ID, wpcf_types_get_meta_prefix($field) . $field_slug, $field_value);
do_action('wpcf_fields_slug_' . $field_slug . '_save', $field_value);
do_action('wpcf_fields_type_' . $field['type'] . '_save', $field_value);
}
}
}
// Process checkboxes
foreach ($all_fields as $field) {
if ($field['#type'] == 'checkbox' && !isset($_POST['wpcf'][$field['wpcf-slug']])) {
delete_post_meta($post_ID, wpcf_types_get_meta_prefix($field) . $field['wpcf-slug']);
}
}
}
}
示例12: wpcf_admin_custom_taxonomies_form_submit
//.........这里部分代码省略.........
// Sanitize data
if (isset($data['wpcf-tax'])) {
$update = true;
$data['wpcf-tax'] = sanitize_title($data['wpcf-tax']);
}
if (isset($data['slug'])) {
$data['slug'] = sanitize_title($data['slug']);
}
if (isset($data['rewrite']['slug'])) {
$data['rewrite']['slug'] = remove_accents($data['rewrite']['slug']);
$data['rewrite']['slug'] = strtolower($data['rewrite']['slug']);
$data['rewrite']['slug'] = trim($data['rewrite']['slug']);
}
// Set tax name
$tax = '';
if (!empty($data['slug'])) {
$tax = $data['slug'];
} else {
if (!empty($data['wpcf-tax'])) {
$tax = $data['wpcf-tax'];
} else {
if (!empty($data['labels']['singular_name'])) {
$tax = sanitize_title($data['labels']['singular_name']);
}
}
}
if (empty($tax)) {
wpcf_admin_message(__('Please set taxonomy name', 'wpcf'), 'error');
return false;
}
if (empty($data['labels']['singular_name'])) {
$data['labels']['singular_name'] = $tax;
}
$data['slug'] = $tax;
$custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
// Check reserved name
$reserved = wpcf_is_reserved_name($tax, 'taxonomy');
if (is_wp_error($reserved)) {
wpcf_admin_message($reserved->get_error_message(), 'error');
return false;
}
// Check if exists
if ($update && !array_key_exists($data['wpcf-tax'], $custom_taxonomies)) {
wpcf_admin_message(__("Custom taxonomy do not exist", 'wpcf'), 'error');
return false;
}
// Check overwriting
if (!$update && array_key_exists($tax, $custom_taxonomies)) {
wpcf_admin_message(__('Custom taxonomy already exists', 'wpcf'), 'error');
return false;
}
// Check if our tax overwrites some tax outside
$tax_exists = get_taxonomy($tax);
if (!$update && !empty($tax_exists)) {
wpcf_admin_message(__('Taxonomy already exists', 'wpcf'), 'error');
return false;
}
// Check if renaming
if ($update && $data['wpcf-tax'] != $tax) {
global $wpdb;
$wpdb->update($wpdb->term_taxonomy, array('taxonomy' => $tax), array('taxonomy' => $data['wpcf-tax']), array('%s'), array('%s'));
// Sync action
do_action('wpcf_taxonomy_renamed', $tax, $data['wpcf-tax']);
// Delete old type
unset($custom_taxonomies[$data['wpcf-tax']]);
}
// Check if active
if (isset($custom_taxonomies[$tax]['disabled'])) {
$data['disabled'] = $custom_taxonomies[$tax]['disabled'];
}
// Sync with post types
if (!empty($data['supports'])) {
$post_types = get_option('wpcf-custom-types', array());
foreach ($post_types as $id => $type) {
if (array_key_exists($id, $data['supports'])) {
if (empty($post_types[$id]['taxonomies'][$data['slug']])) {
$post_types[$id][TOOLSET_EDIT_LAST] = time();
}
$post_types[$id]['taxonomies'][$data['slug']] = 1;
} else {
if (!empty($post_types[$id]['taxonomies'][$data['slug']])) {
$post_types[$id][TOOLSET_EDIT_LAST] = time();
}
unset($post_types[$id]['taxonomies'][$data['slug']]);
}
}
update_option('wpcf-custom-types', $post_types);
}
$custom_taxonomies[$tax] = $data;
$custom_taxonomies[$tax][TOOLSET_EDIT_LAST] = time();
update_option('wpcf-custom-taxonomies', $custom_taxonomies);
// WPML register strings
wpcf_custom_taxonimies_register_translation($tax, $data);
wpcf_admin_message_store(apply_filters('types_message_custom_taxonomy_saved', __('Custom taxonomy saved', 'wpcf'), $data, $update), 'custom');
// Flush rewrite rules
flush_rewrite_rules();
// Redirect
wp_redirect(add_query_arg(array('page' => 'wpcf-edit-tax', 'wpcf-tax' => $tax, 'wpcf-rewrite' => 1, 'wpcf-message' => get_user_option('types-modal')), admin_url('admin.php')));
die;
}
示例13: wpcf_admin_general_settings_form_submit
function wpcf_admin_general_settings_form_submit($form)
{
$settings = wpcf_get_settings();
$data = $_POST['wpcf_settings'];
foreach (array('register_translations_on_import', 'help_box') as $setting) {
if (!isset($data[$setting])) {
$settings[$setting] = 0;
} else {
// @todo Add sanitization here
$settings[$setting] = $data[$setting];
}
}
update_option('wpcf_settings', $settings);
wpcf_admin_message_store(__('Settings saved', 'wpcf'));
}
示例14: on_term_update
public function on_term_update($term_id, $tt_id)
{
// Get an array of fields that we need to update. We don't care about their groups here.
$term = get_term_by('term_taxonomy_id', $tt_id);
if (!$term instanceof WP_Term) {
return;
}
$factory = Types_Field_Group_Term_Factory::get_instance();
$groups = $factory->get_groups_by_taxonomy($term->taxonomy);
if (empty($groups)) {
return;
}
$field_definitions = Types_Field_Utils::get_field_definitions_from_groups($groups);
$update_errors = $this->update_term_fields($term_id, $field_definitions);
// Display errors if we have any.
if (!empty($update_errors)) {
foreach ($update_errors as $update_error) {
wpcf_admin_message_store($update_error->get_error_message(), 'error');
}
wpcf_admin_message_store(sprintf('<strong>%s</strong>', __('There has been a problem while saving custom fields. Please fix it and try again.', 'wpcf')), 'error');
}
}
示例15: wpcf_admin_post_save_post_hook
/**
* save_post hook.
*
* @param type $post_ID
* @param type $post
*/
function wpcf_admin_post_save_post_hook($post_ID, $post)
{
if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'update-' . $post->post_type . '_' . $post_ID)) {
return false;
}
if (!in_array($post->post_type, array('revision', 'attachment', 'wp-types-group', 'view', 'view-template'))) {
// Get groups
$groups = wpcf_admin_post_get_post_groups_fields($post);
if (empty($groups)) {
return false;
}
$all_fields = array();
foreach ($groups as $group) {
// Process fields
// Fix duplicates for repetitive fields
foreach ($group['fields'] as $temp_field_id => $temp_field_data) {
if (isset($temp_field_data['data']['repetitive']) && isset($_REQUEST['wpcf'][$temp_field_id])) {
if (count($_POST['wpcf'][$temp_field_id]) < 2) {
continue;
}
$temp_check_duplicates_old_value = array();
$temp_check_duplicates_new_value = array();
foreach ($_POST['wpcf'][$temp_field_id] as $posted_field_key => $posted_field_value) {
$temp_old_value = base64_decode($posted_field_value['old_value']);
$temp_new_value = isset($posted_field_value['new_value']) ? $posted_field_value['new_value'] : serialize($posted_field_value);
$temp_field_key = wpcf_types_get_meta_prefix($temp_field_data) . $temp_field_id;
// Check new values
if (in_array(md5($temp_new_value), $temp_check_duplicates_new_value)) {
unset($_POST['wpcf'][$temp_field_id][$posted_field_key]);
if ($temp_old_value != '__wpcf_repetitive_new_field') {
// Rebuild
delete_post_meta($post_ID, $temp_field_key, $temp_old_value);
update_post_meta($post_ID, $temp_field_key, $temp_old_value);
}
} else {
if ($temp_old_value == '__wpcf_repetitive_new_field') {
$_POST['wpcf'][$temp_field_id][intval($posted_field_key) * 1000] = $_POST['wpcf'][$temp_field_id][$posted_field_key];
unset($_POST['wpcf'][$temp_field_id][$posted_field_key]);
continue;
}
$temp_check_duplicates_new_value[] = md5($temp_new_value);
}
// Check old values
// if ($temp_old_value != '__wpcf_repetitive_new_field') {
// if (in_array(md5($temp_old_value),
// $temp_check_duplicates_old_value)) {
// unset($_POST['wpcf'][$temp_field_id][$posted_field_key]);
// if ($temp_old_value != '__wpcf_repetitive_new_field') {
// // Rebuild
// delete_post_meta($post_ID, $temp_field_key,
// $temp_old_value);
// update_post_meta($post_ID, $temp_field_key,
// $temp_old_value);
// }
// } else {
// if ($temp_old_value == '__wpcf_repetitive_new_field') {
// $_POST['wpcf'][$temp_field_id][intval($posted_field_key) * 1000] = $_POST['wpcf'][$temp_field_id][$posted_field_key];
// unset($_POST['wpcf'][$temp_field_id][$posted_field_key]);
// continue;
// }
// $temp_check_duplicates_old_value[] = md5($temp_old_value);
// }
// }
}
}
}
$_REQUEST['wpcf'] = $_POST['wpcf'];
// Fix indexes for repetitive
foreach ($group['fields'] as $temp_field_id => $temp_field_data) {
if (isset($temp_field_data['data']['repetitive']) && isset($_REQUEST['wpcf'][$temp_field_id])) {
$temp_count = 1;
$temp_data = $_REQUEST['wpcf'][$temp_field_id];
unset($_REQUEST['wpcf'][$temp_field_id]);
$_REQUEST['wpcf'][$temp_field_id] = array();
foreach ($temp_data as $temp_post_key => $temp_post_data) {
$_REQUEST['wpcf'][$temp_field_id][$temp_count] = $temp_post_data;
$temp_count += 1;
}
}
}
$_POST['wpcf'] = $_REQUEST['wpcf'];
$fields = wpcf_admin_post_process_fields($post, $group['fields'], true, false, 'validation');
// Validate fields
$form = wpcf_form_simple_validate($fields);
$all_fields = $all_fields + $fields;
$error = $form->isError();
// Trigger form error
if ($error) {
wpcf_admin_message_store(__('Please check your input data', 'wpcf'), 'error');
}
}
// Save invalid elements so user can be informed after redirect
if (!empty($all_fields)) {
update_post_meta($post_ID, 'wpcf-invalid-fields', $all_fields);
//.........这里部分代码省略.........