本文整理汇总了PHP中wpcf_admin_fields_delete_field函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_fields_delete_field函数的具体用法?PHP wpcf_admin_fields_delete_field怎么用?PHP wpcf_admin_fields_delete_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_admin_fields_delete_field函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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;
}
if ($action == '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);
} else {
if ($action == '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);
} else {
if ($action == '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');
}
}
}
}
$url = add_query_arg(array('page' => 'wpcf-custom-fields-control', 'display_all' => isset($_REQUEST['display_all']) ? 1 : 0), admin_url('admin.php'));
wp_redirect($url);
die;
}
开发者ID:santikrass,项目名称:apache,代码行数:56,代码来源:fields-control.php
示例2: wpcf_admin_custom_fields_control_bulk_actions
/**
* Submitted Bulk actions.
*/
function wpcf_admin_custom_fields_control_bulk_actions($action = '')
{
if ($action == 'wpcf-deactivate-bulk') {
$fields = wpcf_admin_fields_get_fields();
foreach ($_POST['fields'] as $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);
} else {
if ($action == 'wpcf-activate-bulk') {
$fields = wpcf_admin_fields_get_fields();
$fields_bulk = wpcf_types_cf_under_control('add', array('fields' => $_POST['fields']));
foreach ($fields_bulk as $field_id) {
if (isset($fields[$field_id]) && empty($fields[$field_id]['data']['disabled_by_type'])) {
$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);
} else {
if ($action == 'wpcf-delete-bulk') {
require_once WPCF_INC_ABSPATH . '/fields.php';
$failed = array();
$success = array();
foreach ($_POST['fields'] as $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)));
}
}
}
}
wp_redirect($_SERVER['REQUEST_URI']);
die;
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:50,代码来源:fields-control.php
示例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;
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:79,代码来源:fields-control.php
示例4: wpcf_ajax
//.........这里部分代码省略.........
require_once WPCF_INC_ABSPATH . '/fields/select.php';
$element = wpcf_fields_select_get_option(urldecode($_GET['parent_name']));
echo json_encode(array('output' => wpcf_form_simple($element)));
break;
case 'group_form_collapsed':
require_once WPCF_INC_ABSPATH . '/fields-form.php';
$group_id = $_GET['group_id'];
$action = $_GET['toggle'];
$fieldset = $_GET['id'];
wpcf_admin_fields_form_save_open_fieldset($action, $fieldset, $group_id);
break;
case 'form_fieldset_toggle':
$action = $_GET['toggle'];
$fieldset = $_GET['id'];
wpcf_admin_form_fieldset_save_toggle($action, $fieldset);
break;
case 'group_update_post_types':
require_once WPCF_INC_ABSPATH . '/fields.php';
$post_types = empty($_GET['wpcf']['group']['supports']) ? array() : $_GET['wpcf']['group']['supports'];
if (!empty($_GET['group_id'])) {
wpcf_admin_fields_save_group_post_types($_GET['group_id'], $post_types);
$output = array();
foreach ($post_types as $post_type) {
$post_type = get_post_type_object($post_type);
if (!empty($post_type->label)) {
$output[] = $post_type->label;
}
}
if (empty($post_types)) {
$output[] = __('No post types associated', 'wpcf');
}
$output = implode(', ', $output);
} else {
$output = __('No post types associated', 'wpcf');
}
echo json_encode(array('output' => $output));
break;
case 'group_update_taxonomies':
require_once WPCF_INC_ABSPATH . '/fields.php';
$taxonomies_post = empty($_GET['wpcf']['group']['taxonomies']) ? array() : $_GET['wpcf']['group']['taxonomies'];
$terms = array();
foreach ($taxonomies_post as $taxonomy) {
foreach ($taxonomy as $tax => $term) {
$terms[] = $term;
}
}
if (!empty($_GET['group_id'])) {
wpcf_admin_fields_save_group_terms($_GET['group_id'], $terms);
$output = array();
foreach ($taxonomies_post as $taxonomy => $terms) {
$taxonomy = get_taxonomy($taxonomy);
if (!empty($taxonomy)) {
$title = $taxonomy->label . ': ';
foreach ($terms as $term_id) {
$term = get_term($term_id, $taxonomy->name);
$output[] = $title . $term->name;
$title = '';
}
}
}
if (empty($output)) {
$output[] = __('No taxonomies associated', 'wpcf');
}
$output = implode(', ', $output);
} else {
$output = __('No taxonomies associated', 'wpcf');
}
echo json_encode(array('output' => $output));
break;
case 'custom_fields_control_bulk':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/fields-control.php';
wpcf_admin_custom_fields_control_bulk_ajax();
break;
case 'fields_delete':
case 'delete_field':
require_once WPCF_INC_ABSPATH . '/fields.php';
if (isset($_GET['field_id'])) {
wpcf_admin_fields_delete_field($_GET['field_id']);
}
if (isset($_GET['field'])) {
wpcf_admin_fields_delete_field($_GET['field']);
}
echo json_encode(array('output' => ''));
break;
case 'remove_from_history':
require_once WPCF_INC_ABSPATH . '/fields.php';
$fields = wpcf_admin_fields_get_fields();
if (isset($_GET['field_id']) && isset($fields[$_GET['field_id']])) {
$fields[$_GET['field_id']]['data']['removed_from_history'] = 1;
wpcf_admin_fields_save_fields($fields, true);
}
echo json_encode(array('output' => ''));
break;
default:
break;
}
die;
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:101,代码来源:ajax.php
示例5: wpcf_ajax
/**
* All AJAX calls go here.
*
* @global object $wpdb
*
*/
function wpcf_ajax()
{
if (!current_user_can('manage_options') || (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], $_REQUEST['wpcf_action']))) {
die;
}
switch ($_REQUEST['wpcf_action']) {
/* User meta actions*/
case 'user_fields_control_bulk':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/fields-control.php';
require_once WPCF_INC_ABSPATH . '/usermeta-control.php';
wpcf_admin_user_fields_control_bulk_ajax();
break;
case 'usermeta_delete':
case 'delete_usermeta':
require_once WPCF_INC_ABSPATH . '/fields.php';
if (isset($_GET['field_id'])) {
$field_id = sanitize_text_field($_GET['field_id']);
wpcf_admin_fields_delete_field($field_id, 'wp-types-user-group', 'wpcf-usermeta');
}
if (isset($_GET['field'])) {
$field = sanitize_text_field($_GET['field']);
wpcf_admin_fields_delete_field($field, 'wp-types-user-group', 'wpcf-usermeta');
}
echo json_encode(array('output' => ''));
break;
case 'remove_from_history2':
require_once WPCF_INC_ABSPATH . '/fields.php';
$fields = wpcf_admin_fields_get_fields(true, true, false, 'wpcf-usermeta');
if (isset($_GET['field_id']) && isset($fields[$_GET['field_id']])) {
$fields[$_GET['field_id']]['data']['removed_from_history'] = 1;
wpcf_admin_fields_save_fields($fields, true, 'wpcf-usermeta');
}
echo json_encode(array('output' => ''));
break;
case 'deactivate_user_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/usermeta.php';
$success = wpcf_admin_fields_deactivate_group(intval($_GET['group_id']), 'wp-types-user-group');
if ($success) {
echo json_encode(array('output' => __('Group deactivated', 'wpcf'), 'execute' => 'location.reload();'));
} else {
echo json_encode(array('output' => __('Error occured', 'wpcf')));
}
break;
case 'activate_user_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/usermeta.php';
$success = wpcf_admin_fields_activate_group(intval($_GET['group_id']), 'wp-types-user-group');
if ($success) {
echo json_encode(array('output' => __('Group activated', 'wpcf'), 'execute' => 'location.reload();'));
} else {
echo json_encode(array('output' => __('Error occured', 'wpcf')));
}
break;
case 'delete_usermeta_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/usermeta.php';
wpcf_admin_fields_delete_group(intval($_GET['group_id']), 'wp-types-user-group');
echo json_encode(array('output' => '', 'execute' => 'location.reload();'));
break;
case 'usermeta_insert_existing':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/fields-form.php';
require_once WPCF_INC_ABSPATH . '/usermeta-form.php';
wpcf_usermeta_insert_existing_ajax();
wpcf_form_render_js_validation();
break;
/* End Usertmeta actions*/
/* End Usertmeta actions*/
case 'fields_insert':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/fields-form.php';
wpcf_fields_insert_ajax();
wpcf_form_render_js_validation();
break;
case 'fields_insert_existing':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/fields-form.php';
wpcf_fields_insert_existing_ajax();
wpcf_form_render_js_validation();
break;
case 'remove_field_from_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
if (isset($_GET['group_id']) && isset($_GET['field_id'])) {
wpcf_admin_fields_remove_field_from_group(intval($_GET['group_id']), sanitize_text_field($_GET['field_id']));
}
break;
case 'deactivate_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
$success = wpcf_admin_fields_deactivate_group(intval($_GET['group_id']));
if ($success) {
echo json_encode(array('output' => __('Group deactivated', 'wpcf'), 'execute' => 'location.reload();'));
//.........这里部分代码省略.........
开发者ID:SpencerNeitzke,项目名称:types,代码行数:101,代码来源:ajax.php
示例6: wpcf_ajax
//.........这里部分代码省略.........
case 'remove_field_from_group':
case 'add_radio_option':
case 'add_select_option':
case 'add_checkboxes_option':
case 'group_form_collapsed':
case 'form_fieldset_toggle':
case 'fields_delete':
case 'delete_field':
case 'remove_from_history':
case 'add_condition':
case 'pt_edit_fields':
case 'toggle':
case 'cb_save_empty_migrate':
if (!current_user_can('manage_options')) {
wpcf_ajax_helper_verification_failed_and_die();
}
/**
* do not check actions from other places
*/
break;
default:
return;
}
/**
* do actions
*/
switch ($_REQUEST['wpcf_action']) {
/* User meta actions*/
case 'usermeta_delete':
case 'delete_usermeta':
require_once WPCF_INC_ABSPATH . '/fields.php';
if (isset($_GET['field_id'])) {
$field_id = sanitize_text_field($_GET['field_id']);
wpcf_admin_fields_delete_field($field_id, TYPES_USER_META_FIELD_GROUP_CPT_NAME, 'wpcf-usermeta');
}
if (isset($_GET['field'])) {
$field = sanitize_text_field($_GET['field']);
wpcf_admin_fields_delete_field($field, TYPES_USER_META_FIELD_GROUP_CPT_NAME, 'wpcf-usermeta');
}
echo json_encode(array('output' => ''));
break;
case 'remove_from_history2':
require_once WPCF_INC_ABSPATH . '/fields.php';
$fields = wpcf_admin_fields_get_fields(true, true, false, 'wpcf-usermeta');
if (isset($_GET['field_id']) && isset($fields[$_GET['field_id']])) {
$fields[$_GET['field_id']]['data']['removed_from_history'] = 1;
wpcf_admin_fields_save_fields($fields, true, 'wpcf-usermeta');
}
echo json_encode(array('output' => ''));
break;
case 'deactivate_user_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/usermeta.php';
$success = wpcf_admin_fields_deactivate_group(intval($_GET['group_id']), TYPES_USER_META_FIELD_GROUP_CPT_NAME);
if ($success) {
echo json_encode(array('output' => __('Group deactivated', 'wpcf'), 'execute' => 'reload', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
} else {
wpcf_ajax_helper_print_error_and_die();
die;
}
break;
case 'activate_user_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/usermeta.php';
$success = wpcf_admin_fields_activate_group(intval($_GET['group_id']), TYPES_USER_META_FIELD_GROUP_CPT_NAME);
if ($success) {
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:67,代码来源:ajax.php
示例7: wpcf_ajax
/**
* All AJAX calls go here.
*/
function wpcf_ajax()
{
if (!current_user_can('manage_options') || (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], $_REQUEST['wpcf_action']))) {
die;
}
switch ($_REQUEST['wpcf_action']) {
/* User meta actions*/
case 'user_fields_control_bulk':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/fields-control.php';
require_once WPCF_INC_ABSPATH . '/usermeta-control.php';
wpcf_admin_user_fields_control_bulk_ajax();
break;
case 'usermeta_delete':
case 'delete_usermeta':
require_once WPCF_INC_ABSPATH . '/fields.php';
if (isset($_GET['field_id'])) {
wpcf_admin_fields_delete_field($_GET['field_id'], 'wp-types-user-group', 'wpcf-usermeta');
}
if (isset($_GET['field'])) {
wpcf_admin_fields_delete_field($_GET['field'], 'wp-types-user-group', 'wpcf-usermeta');
}
echo json_encode(array('output' => ''));
break;
case 'remove_from_history2':
require_once WPCF_INC_ABSPATH . '/fields.php';
$fields = wpcf_admin_fields_get_fields(true, true, false, 'wpcf-usermeta');
if (isset($_GET['field_id']) && isset($fields[$_GET['field_id']])) {
$fields[$_GET['field_id']]['data']['removed_from_history'] = 1;
wpcf_admin_fields_save_fields($fields, true, 'wpcf-usermeta');
}
echo json_encode(array('output' => ''));
break;
case 'deactivate_user_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/usermeta.php';
$success = wpcf_admin_fields_deactivate_group(intval($_GET['group_id']), 'wp-types-user-group');
if ($success) {
echo json_encode(array('output' => __('Group deactivated', 'wpcf'), 'execute' => 'jQuery("#wpcf-list-activate-' . intval($_GET['group_id']) . '").replaceWith(\'' . wpcf_admin_usermeta_get_ajax_activation_link(intval($_GET['group_id'])) . '\');jQuery(".wpcf-table-column-active-' . intval($_GET['group_id']) . '").html("' . __('No', 'wpcf') . '");', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
} else {
echo json_encode(array('output' => __('Error occured', 'wpcf')));
}
break;
case 'activate_user_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/usermeta.php';
$success = wpcf_admin_fields_activate_group(intval($_GET['group_id']), 'wp-types-user-group');
if ($success) {
echo json_encode(array('output' => __('Group activated', 'wpcf'), 'execute' => 'jQuery("#wpcf-list-activate-' . intval($_GET['group_id']) . '").replaceWith(\'' . wpcf_admin_usermeta_get_ajax_deactivation_link(intval($_GET['group_id'])) . '\');jQuery(".wpcf-table-column-active-' . intval($_GET['group_id']) . '").html("' . __('Yes', 'wpcf') . '");', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
} else {
echo json_encode(array('output' => __('Error occured', 'wpcf')));
}
break;
case 'delete_usermeta_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/usermeta.php';
wpcf_admin_fields_delete_group(intval($_GET['group_id']), 'wp-types-user-group');
echo json_encode(array('output' => '', 'execute' => 'jQuery("#wpcf-list-activate-' . intval($_GET['group_id']) . '").parents("tr").css("background-color", "#FF0000").fadeOut();', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
break;
case 'usermeta_insert_existing':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/fields-form.php';
require_once WPCF_INC_ABSPATH . '/usermeta-form.php';
wpcf_usermeta_insert_existing_ajax();
wpcf_form_render_js_validation();
break;
/* End Usertmeta actions*/
/* End Usertmeta actions*/
case 'fields_insert':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/fields-form.php';
wpcf_fields_insert_ajax();
wpcf_form_render_js_validation();
break;
case 'fields_insert_existing':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/fields-form.php';
wpcf_fields_insert_existing_ajax();
wpcf_form_render_js_validation();
break;
case 'remove_field_from_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
if (isset($_GET['group_id']) && isset($_GET['field_id'])) {
wpcf_admin_fields_remove_field_from_group($_GET['group_id'], $_GET['field_id']);
}
break;
case 'deactivate_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
$success = wpcf_admin_fields_deactivate_group(intval($_GET['group_id']));
if ($success) {
echo json_encode(array('output' => __('Group deactivated', 'wpcf'), 'execute' => 'jQuery("#wpcf-list-activate-' . intval($_GET['group_id']) . '").replaceWith(\'' . wpcf_admin_fields_get_ajax_activation_link(intval($_GET['group_id'])) . '\');jQuery(".wpcf-table-column-active-' . intval($_GET['group_id']) . '").html("' . __('No', 'wpcf') . '");', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
} else {
echo json_encode(array('output' => __('Error occured', 'wpcf')));
}
break;
case 'activate_group':
//.........这里部分代码省略.........
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:101,代码来源:ajax.php
示例8: wpcf_admin_fields_save_field
//.........这里部分代码省略.........
if (isset($_GET['group_id']) && isset($fields[$field['slug-pre-save']]) && count($belongs_to_groups) == 1 && isset($belongs_to_groups[$_GET['group_id']])) {
global $wpdb;
// as it's the only group with this field we can update the slug for all items
$wpdb->update($wpdb->postmeta, array('meta_key' => 'wpcf-' . $field['slug']), array('meta_key' => 'wpcf-' . $field['slug-pre-save']), array('%s'), array('%s'));
// change slug in field conditions
foreach ($fields as $key => &$single_field) {
if (isset($single_field['data']['conditional_display']['conditions'])) {
foreach ($single_field['data']['conditional_display']['conditions'] as &$single_condition) {
if ($single_condition['field'] == $field['slug-pre-save']) {
$single_condition['field'] = $field['slug'];
}
}
}
}
// get all group conditions which contain the old slug
$groups_conditions = $wpdb->get_results("\n SELECT post_id, meta_value\n FROM {$wpdb->postmeta}\n WHERE meta_key = '_wpcf_conditional_display'\n AND meta_value LIKE '%" . $field['slug-pre-save'] . "%'\n\t ");
if ($groups_conditions) {
foreach ($groups_conditions as $group_condition) {
$meta_value = unserialize($group_condition->meta_value);
// proper proof for slug
if (isset($meta_value['conditions'])) {
foreach ($meta_value['conditions'] as &$single_condition) {
if ($single_condition['field'] == $field['slug-pre-save']) {
// update conditions slug
$single_condition['field'] = $field['slug'];
update_post_meta($group_condition->post_id, '_wpcf_conditional_display', $meta_value);
break;
}
}
}
}
}
// delete field
wpcf_admin_fields_delete_field($field['slug-pre-save'], $post_type, $option_name);
unset($fields[$field['slug-pre-save']]);
// update items by post type
} elseif (isset($_GET['group_id'])) {
switch ($post_type) {
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
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:67,代码来源:fields.php
注:本文中的wpcf_admin_fields_delete_field函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论