本文整理汇总了PHP中wpcf_form_render_js_validation函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_form_render_js_validation函数的具体用法?PHP wpcf_form_render_js_validation怎么用?PHP wpcf_form_render_js_validation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_form_render_js_validation函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wpcf_usermeta_add_user_templates
/**
* Renders templates on bottom of screen.
*/
function wpcf_usermeta_add_user_templates()
{
?>
<script type="text/html" id="tpl-wpcf-usermeta-add-user">
<?php
wpcf_admin_userprofile_init(-1);
?>
</script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#createuser .submit').prepend($('#tpl-wpcf-usermeta-add-user').html());
});
</script>
<?php
wpcf_form_render_js_validation('#createuser');
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:19,代码来源:usermeta-add-user.php
示例2: wpcf_ajax_embedded
//.........这里部分代码省略.........
/*
* Since Types 1.1.5
*
* We save new post
* CHECKPOINT
*/
$id = $wpcf->relationship->add_new_child($parent_post->ID, $post_type);
if (is_wp_error($id)) {
$output = '<tr>' . $id->get_error_message() . '</tr>';
} else {
/*
* Here we set Relationship
* CHECKPOINT
*/
$parent = get_post($parent_post_id);
$child = get_post($id);
if (!empty($parent->ID) && !empty($child->ID)) {
// Set post
$wpcf->post = $child;
// Set relationship :)
$wpcf->relationship->_set($parent, $child, $data);
// Render new row
$output = $wpcf->relationship->child_row($parent_post->ID, $id, $data);
} else {
$output = '<tr>' . __('Error creating post relationship', 'wpcf') . '</tr>';
}
}
} else {
$output = '<tr>' . __('Error getting parent post', 'wpcf') . '</tr>';
}
}
}
if (!defined('WPTOOLSET_FORMS_VERSION')) {
echo json_encode(array('output' => $output . wpcf_form_render_js_validation('#post', false), 'child_id' => $id));
} else {
echo json_encode(array('output' => $output, 'conditionals' => array('#post' => wptoolset_form_get_conditional_data('post')), 'child_id' => $id));
}
break;
case 'pr_save_all':
ob_start();
// Try to catch any errors
$output = '';
if (current_user_can('edit_posts') && isset($_POST['post_id'])) {
$parent_id = intval($_POST['post_id']);
$post_type = sanitize_text_field($_POST['post_type']);
if (isset($_POST['wpcf_post_relationship'][$parent_id])) {
$children = wpcf_sanitize_post_realtionship_input((array) $_POST['wpcf_post_relationship'][$parent_id]);
$wpcf->relationship->save_children($parent_id, $children);
$output = $wpcf->relationship->child_meta_form($parent_id, strval($post_type));
}
}
if (!defined('WPTOOLSET_FORMS_VERSION')) {
// TODO Move to conditional
$output .= '<script type="text/javascript">wpcfConditionalInit();</script>';
}
wpcf_show_admin_messages('echo');
$errors = ob_get_clean();
if (!defined('WPTOOLSET_FORMS_VERSION')) {
echo json_encode(array('output' => $output, 'errors' => $errors));
} else {
echo json_encode(array('output' => $output, 'conditionals' => array('#post' => wptoolset_form_get_conditional_data('post')), 'errors' => $errors));
}
break;
case 'pr_save_child_post':
ob_start();
// Try to catch any errors
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:67,代码来源:ajax.php
示例3: wpcf_admin_tax_form_js_validation
/**
* Adds JS validation script.
*/
function wpcf_admin_tax_form_js_validation()
{
wpcf_form_render_js_validation();
}
开发者ID:dewavi,项目名称:occupysandy.net,代码行数:7,代码来源:custom-taxonomies-form.php
示例4: wpcf_admin_post_js_validation
/**
* Renders JS validation script.
*/
function wpcf_admin_post_js_validation()
{
wpcf_form_render_js_validation('#post');
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:7,代码来源:fields-post.php
示例5: 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']) {
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':
require_once WPCF_INC_ABSPATH . '/fields.php';
$success = wpcf_admin_fields_activate_group(intval($_GET['group_id']));
if ($success) {
echo json_encode(array('output' => __('Group activated', 'wpcf'), 'execute' => 'jQuery("#wpcf-list-activate-' . intval($_GET['group_id']) . '").replaceWith(\'' . wpcf_admin_fields_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_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
wpcf_admin_fields_delete_group(intval($_GET['group_id']));
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 'deactivate_post_type':
if (!isset($_GET['wpcf-post-type'])) {
die;
}
require_once WPCF_INC_ABSPATH . '/custom-types.php';
$custom_types = get_option('wpcf-custom-types', array());
if (isset($custom_types[$_GET['wpcf-post-type']])) {
$custom_types[$_GET['wpcf-post-type']]['disabled'] = 1;
update_option('wpcf-custom-types', $custom_types);
echo json_encode(array('output' => __('Post type deactivated', 'wpcf'), 'execute' => 'jQuery("#wpcf-list-activate-' . $_GET['wpcf-post-type'] . '").replaceWith(\'' . wpcf_admin_custom_types_get_ajax_activation_link(esc_attr($_GET['wpcf-post-type'])) . '\');jQuery(".wpcf-table-column-active-' . $_GET['wpcf-post-type'] . '").html("' . __('No', 'wpcf') . '");', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
} else {
echo json_encode(array('output' => __('Error occured', 'wpcf')));
}
break;
case 'activate_post_type':
if (!isset($_GET['wpcf-post-type'])) {
die;
}
require_once WPCF_INC_ABSPATH . '/custom-types.php';
$custom_types = get_option('wpcf-custom-types', array());
if (isset($custom_types[$_GET['wpcf-post-type']])) {
$custom_types[$_GET['wpcf-post-type']]['disabled'] = 0;
update_option('wpcf-custom-types', $custom_types);
echo json_encode(array('output' => __('Post type activated', 'wpcf'), 'execute' => 'jQuery("#wpcf-list-activate-' . $_GET['wpcf-post-type'] . '").replaceWith(\'' . wpcf_admin_custom_types_get_ajax_deactivation_link($_GET['wpcf-post-type']) . '\');jQuery(".wpcf-table-column-active-' . $_GET['wpcf-post-type'] . '").html("' . __('Yes', 'wpcf') . '");', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
} else {
echo json_encode(array('output' => __('Error occured', 'wpcf')));
}
break;
case 'delete_post_type':
if (!isset($_GET['wpcf-post-type'])) {
die;
}
$custom_types = get_option('wpcf-custom-types', array());
unset($custom_types[$_GET['wpcf-post-type']]);
update_option('wpcf-custom-types', $custom_types);
echo json_encode(array('output' => '', 'execute' => 'jQuery("#wpcf-list-activate-' . $_GET['wpcf-post-type'] . '").parents("tr").css("background-color", "#FF0000").fadeOut();', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
break;
case 'deactivate_taxonomy':
if (!isset($_GET['wpcf-tax'])) {
die;
}
require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
$custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
if (isset($custom_taxonomies[$_GET['wpcf-tax']])) {
$custom_taxonomies[$_GET['wpcf-tax']]['disabled'] = 1;
update_option('wpcf-custom-taxonomies', $custom_taxonomies);
echo json_encode(array('output' => __('Taxonomy deactivated', 'wpcf'), 'execute' => 'jQuery("#wpcf-list-activate-' . $_GET['wpcf-tax'] . '").replaceWith(\'' . wpcf_admin_custom_taxonomies_get_ajax_activation_link($_GET['wpcf-tax']) . '\');jQuery(".wpcf-table-column-active-' . $_GET['wpcf-tax'] . '").html("' . __('No', 'wpcf') . '");', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
} else {
echo json_encode(array('output' => __('Error occured', 'wpcf')));
}
//.........这里部分代码省略.........
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:101,代码来源:ajax.php
示例6: 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
示例7: wpcf_admin_profile_js_validation
function wpcf_admin_profile_js_validation()
{
wpcf_form_render_js_validation('#your-profile');
}
开发者ID:sonvq,项目名称:passioninvestment,代码行数:4,代码来源:usermeta-post.php
示例8: wpcf_admin_fields_form_js_validation
/**
* Adds JS validation script.
*/
function wpcf_admin_fields_form_js_validation()
{
wpcf_form_render_js_validation();
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:7,代码来源:fields-form.php
示例9: wpcf_ajax_embedded
//.........这里部分代码省略.........
$data = $relationships[$parent_post_type][$post_type];
/*
* Since Types 1.1.5
*
* We save new post
* CHECKPOINT
*/
$id = $wpcf->relationship->add_new_child($parent_post->ID, $post_type);
if (is_wp_error($id)) {
$output = $id->get_error_message();
} else {
/*
* Here we set Relationship
* CHECKPOINT
*/
$parent = get_post($parent_post_id);
$child = get_post($id);
if (!empty($parent->ID) && !empty($child->ID)) {
// Set post
$wpcf->post = $child;
// Set relationship :)
$wpcf->relationship->_set($parent, $child, $data);
// Render new row
$output = $wpcf->relationship->child_row($parent_post->ID, $id, $data);
} else {
$output = __('Error creating post relationship', 'wpcf');
}
}
} else {
$output = __('Error getting parent post', 'wpcf');
}
}
if (!defined('WPTOOLSET_FORMS_VERSION')) {
echo json_encode(array('output' => $output . wpcf_form_render_js_validation('#post', false), 'child_id' => $id));
} else {
echo json_encode(array('output' => $output, 'conditionals' => array('#post' => wptoolset_form_get_conditional_data('post')), 'child_id' => $id));
}
break;
case 'pr_save_all':
$output = '';
if (current_user_can('edit_posts') && isset($_POST['post_id'])) {
$parent_id = intval($_POST['post_id']);
$post_type = sanitize_text_field($_POST['post_type']);
if (isset($_POST['wpcf_post_relationship'][$parent_id])) {
$children = wpcf_sanitize_post_realtionship_input((array) $_POST['wpcf_post_relationship'][$parent_id]);
$wpcf->relationship->save_children($parent_id, $children);
$output = $wpcf->relationship->child_meta_form($parent_id, strval($post_type));
}
}
if (!defined('WPTOOLSET_FORMS_VERSION')) {
// TODO Move to conditional
$output .= '<script type="text/javascript">wpcfConditionalInit();</script>';
}
if (!defined('WPTOOLSET_FORMS_VERSION')) {
echo json_encode(array('output' => $output));
} else {
echo json_encode(array('output' => $output, 'conditionals' => array('#post' => wptoolset_form_get_conditional_data('post'))));
}
break;
case 'pr_save_child_post':
ob_start();
// Try to catch any errors
$output = '';
if (current_user_can('edit_posts') && isset($_GET['post_id']) && isset($_GET['parent_id']) && isset($_GET['post_type_parent']) && isset($_GET['post_type_child']) && isset($_POST['wpcf_post_relationship'])) {
$parent_id = intval($_GET['parent_id']);
$child_id = intval($_GET['post_id']);
开发者ID:KryvunRoman,项目名称:yobko,代码行数:67,代码来源:ajax.php
示例10: wpcf_ajax_embedded
//.........这里部分代码省略.........
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if (isset($_GET['field']) && isset($_GET['sort']) && isset($_GET['post_id']) && isset($_GET['post_type'])) {
$post = get_post($_GET['post_id']);
$post_type = $_GET['post_type'];
$has = wpcf_pr_admin_get_has($post->post_type);
$output = wpcf_pr_admin_post_meta_box_has_form($post, $post_type, $has[$post_type], $post->post_type);
}
echo json_encode(array('output' => $output));
break;
case 'pr_save_all':
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = array();
if (isset($_POST['post_id']) && isset($_POST['wpcf_post_relationship'])) {
$output = wpcf_pr_admin_save_post_hook($_POST['post_id']);
}
echo json_encode(array('output' => $output));
break;
case 'repetitive_add':
if (isset($_GET['field_id'])) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
$field = wpcf_admin_fields_get_field($_GET['field_id']);
// Pass as normal
unset($field['data']['repetitive']);
$fields = array($_GET['field_id'] => $field);
$element = wpcf_admin_post_process_fields(false, $fields, false, false, 'repetitive');
if ($field['type'] == 'skype') {
$key = key($element);
unset($element[$key]['#title']);
echo json_encode(array('output' => wpcf_form_simple($element) . wpcf_form_render_js_validation('#post', false)));
} else {
$element = array_shift($element);
if (!in_array($field['type'], array('checkbox'))) {
unset($element['#title']);
}
echo json_encode(array('output' => wpcf_form_simple(array('repetitive' => $element)) . wpcf_form_render_js_validation('#post', false)));
}
} else {
echo json_encode(array('output' => 'params missing'));
}
break;
case 'repetitive_delete':
if (isset($_POST['post_id']) && isset($_POST['field_id']) && isset($_POST['old_value'])) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
$field = wpcf_admin_fields_get_field($_POST['field_id']);
if (!empty($field)) {
if ($field['type'] == 'date') {
delete_post_meta($_POST['post_id'], wpcf_types_get_meta_prefix($field) . $field['id'], strtotime(base64_decode($_POST['old_value'])));
} else {
if ($field['type'] == 'skype') {
delete_post_meta($_POST['post_id'], wpcf_types_get_meta_prefix($field) . $field['id'], unserialize(base64_decode($_POST['old_value'])));
} else {
delete_post_meta($_POST['post_id'], wpcf_types_get_meta_prefix($field) . $field['id'], base64_decode($_POST['old_value']));
}
}
echo json_encode(array('output' => 'deleted'));
} else {
echo json_encode(array('output' => 'field not found'));
}
} else {
echo json_encode(array('output' => 'params missing'));
}
开发者ID:sriram911,项目名称:pls,代码行数:67,代码来源:ajax.php
示例11: wpcf_admin_post_js_validation
/**
* Renders JS validation script.
*/
function wpcf_admin_post_js_validation()
{
wpcf_form_render_js_validation('#post');
?>
<script type="text/javascript">
//<![CDATA[
function wpcfFieldsEditorCallback(field_id) {
var url = "<?php
echo admin_url('admin-ajax.php');
?>
?action=wpcf_ajax&wpcf_action=editor_callback&_wpnonce=<?php
echo wp_create_nonce('editor_callback');
?>
&field_id="+field_id+"&keepThis=true&TB_iframe=true&height=400&width=400";
tb_show("<?php
_e('Insert field', 'wpcf');
?>
", url);
}
//]]>
</script>
<?php
}
开发者ID:rdbartlett,项目名称:kellyspencer.co.nz,代码行数:26,代码来源:fields-post.php
示例12: render_js_validation_data
/**
* Appends form-specific data for the JS validation script.
*
* @since 1.9
*/
public function render_js_validation_data()
{
wpcf_form_render_js_validation('.validate');
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:9,代码来源:term_field_editing.php
示例13: wpcf_ajax_embedded
/**
* All AJAX calls go here.
*/
function wpcf_ajax_embedded()
{
if (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], $_REQUEST['wpcf_action'])) {
die('Verification failed');
}
global $wpcf;
switch ($_REQUEST['wpcf_action']) {
case 'editor_insert_date':
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/date.php';
wpcf_fields_date_editor_form();
break;
case 'insert_skype_button':
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/skype.php';
wpcf_fields_skype_meta_box_ajax();
break;
case 'editor_callback':
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
$field = wpcf_admin_fields_get_field($_GET['field_id']);
if (!empty($field)) {
$function = 'wpcf_fields_' . $field['type'] . '_editor_callback';
if (function_exists($function)) {
call_user_func($function);
}
}
break;
case 'dismiss_message':
if (isset($_GET['id'])) {
$messages = get_option('wpcf_dismissed_messages', array());
$messages[] = $_GET['id'];
update_option('wpcf_dismissed_messages', $messages);
}
break;
case 'pr_add_child_post':
$output = 'Passed wrong parameters';
if (isset($_GET['post_id']) && isset($_GET['post_type_child']) && isset($_GET['post_type_parent'])) {
// Fix for Common Conditional check
$_POST['post_ID'] = $_GET['post_id'];
$relationships = get_option('wpcf_post_relationship', array());
$post = get_post(intval($_GET['post_id']));
if (!empty($post->ID)) {
$post_type = strval($_GET['post_type_child']);
$parent_post_type = strval($_GET['post_type_parent']);
$data = $relationships[$parent_post_type][$post_type];
/*
* Since Types 1.1.5
*
* We save new post
* CHECKPOINT
*/
$id = $wpcf->relationship->add_new_child($post->ID, $post_type);
if (!is_wp_error($id)) {
/*
* Here we set Relationship
* CHECKPOINT
*/
$parent = get_post(intval($_GET['post_id']));
$child = get_post($id);
if (!empty($parent->ID) && !empty($child->ID)) {
// Set post
$wpcf->post = $child;
// Set relationship :)
$wpcf->relationship->_set($parent, $child, $data);
// Render new row
$output = $wpcf->relationship->child_row($post->ID, $id, $data);
} else {
$output = __('Error creating post relationship', 'wpcf');
}
} else {
$output = $id->get_error_message();
}
} else {
$output = __('Error getting parent post', 'wpcf');
}
}
echo json_encode(array('output' => $output . wpcf_form_render_js_validation('#post', false)));
break;
case 'pr_save_all':
$output = '';
if (isset($_POST['post_id'])) {
// Fix for Common Conditional check
$_POST['post_ID'] = $_POST['post_id'];
$parent_id = intval($_POST['post_id']);
if (isset($_POST['wpcf_post_relationship'][$parent_id])) {
$wpcf->relationship->save_children($parent_id, (array) $_POST['wpcf_post_relationship'][$parent_id]);
$output = $wpcf->relationship->child_meta_form($parent_id, strval($_POST['post_type']));
}
}
// TODO Move to conditional
$output .= '<script type="text/javascript">wpcfConditionalInit();</script>';
echo json_encode(array('output' => $output));
break;
case 'pr_save_child_post':
ob_start();
// Try to catch any errors
$output = '';
if (isset($_GET['post_id']) && isset($_GET['parent_id']) && isset($_GET['post_type_parent']) && isset($_GET['post_type_child']) && isset($_POST['wpcf_post_relationship'])) {
// Fix for Common Conditional check
//.........这里部分代码省略.........
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:101,代码来源:ajax.php
示例14: wpcf_ajax
//.........这里部分代码省略.........
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) {
echo json_encode(array('output' => __('Group activated', 'wpcf'), 'execute' => 'reload', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
} else {
wpcf_ajax_helper_print_error_and_die();
die;
}
break;
case 'delete_usermeta_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
require_once WPCF_INC_ABSPATH . '/usermeta.php';
$redirect = wpcf_ajax_group_delete_redirect();
wpcf_admin_fields_delete_group(intval($_GET['group_id']), TYPES_USER_META_FIELD_GROUP_CPT_NAME);
echo json_encode($redirect);
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' => 'reload', 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
} else {
wpcf_ajax_helper_print_error_and_die();
}
break;
case 'activate_group':
require_once WPCF_INC_ABSPATH . '/fields.php';
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:67,代码来源:ajax.php
示例15: wpcf_pr_admin_post_meta_box_has_row
//.........这里部分代码省略.........
// Just render textfield
$value = get_post_meta($item->ID, $field_key, true);
$element = wpcf_form_simple(array('field' => array('#type' => 'textfield', '#id' => 'wpcf_post_relationship_' . $item->ID . '_' . $field_key, '#name' => 'wpcf_post_relationship[' . $item->ID . '][' . $field_key . ']', '#value' => $value, '#inline' => true)));
}
}
}
$row_data[] = $element;
}
// Get other parents
foreach ($item_parents as $parent => $temp_data) {
if ($parent == $parent_post_type) {
continue;
}
$meta = get_post_meta($item->ID, '_wpcf_belongs_' . $parent . '_id', true);
$meta = empty($meta) ? 0 : $meta;
$belongs_data = array('belongs' => array($parent => $meta));
$temp_form = wpcf_pr_admin_post_meta_box_belongs_form($item, $parent, $belongs_data);
unset($temp_form[$parent]['#suffix'], $temp_form[$parent]['#prefix'], $temp_form[$parent]['#title']);
$temp_form[$parent]['#name'] = 'wpcf_post_relationship[' . $item->ID . '][parents][' . $parent . ']';
$row_data[] = wpcf_form_simple($temp_form);
}
} else {
$groups = wpcf_admin_post_get_post_groups_fields($item, 'post_relationships');
if ($data['fields_setting'] == 'all_cf_standard') {
$element = wpcf_form_simple(array('field' => array('#type' => 'textarea', '#id' => 'wpcf_post_relationship_' . $item->ID . '_wp_body', '#name' => 'wpcf_post_relationship[' . $item->ID . '][_wp_body]', '#value' => $item->post_content, '#attributes' => array('style' => 'width:300px;height:100px;'), '#inline' => true)));
$row_data[] = $element;
}
foreach ($groups as $group) {
foreach ($group['fields'] as $field) {
// Date trigger
if ($field['type'] == 'date') {
$date_trigger = true;
}
// Get WPCF form
$element_org = wpcf_admin_post_process_fields($item, array('field' => $field), false, false, 'post_relationship');
$element = array_shift($element_org);
// @todo Check if this is needed for skype only
// if ($field['type'] == 'skype') {
// $temp_second_element = array_pop($element_org);
// if (!empty($temp_second_element['#validate'])) {
// $element['#validate'] = $temp_second_element['#validate'];
// }
//
// }
// TODO Monitor if may still be problem with IDs
if (!in_array($field['type'], array('image', 'file'))) {
$element['#id'] = 'wpcf_post_relationship_' . $item->ID . '_' . $field['id'];
}
$element['#name'] = 'wpcf_post_relationship[' . $item->ID . '][' . wpcf_types_get_meta_prefix($field) . $field['slug'] . ']';
$element['#inline'] = true;
unset($element['#title'], $element['#description']);
if (in_array($field['type'], array('wysiwyg'))) {
$element['#type'] = 'textarea';
$element['#attributes'] = array('style' => 'width:300px;height:100px;');
}
if (in_array($field['type'], array('checkbox'))) {
$element['#suffix'] = '<input type="hidden" name="wpcf_post_relationship_checkbox[' . $item->ID . '][' . wpcf_types_get_meta_prefix($field) . $field['slug'] . ']" value="1" />';
}
$value = get_post_meta($item->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
$element = array('field' => $element);
$element = wpcf_form_simple($element);
$row_data[] = $element;
}
}
// Get all parents
$item_parents = wpcf_pr_admin_get_belongs($post_type);
if ($item_parents) {
foreach ($item_parents as $parent => $temp_data) {
if ($parent == $parent_post_type) {
continue;
}
$meta = get_post_meta($item->ID, '_wpcf_belongs_' . $parent . '_id', true);
$meta = empty($meta) ? 0 : $meta;
$belongs_data = array('belongs' => array($parent => $meta));
$temp_form = wpcf_pr_admin_post_meta_box_belongs_form($item, $parent, $belongs_data);
unset($temp_form[$parent]['#suffix'], $temp_form[$parent]['#prefix'], $temp_form[$parent]['#title']);
$temp_form[$parent]['#name'] = 'wpcf_post_relationship[' . $item->ID . '][parents][' . $parent . ']';
$row_data[] = wpcf_form_simple($temp_form);
}
}
}
if (!empty($row_data)) {
$output = '';
$output .= '<tr><td>' . implode('</td><td>', $row_data) . '<input type="hidden" name="wpcf_post_relationship[' . $item->ID . '][post_type]" value="' . $post_type . '" /></td><td class="actions">' . '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&' . 'wpcf_action=pr_save_child_post&post_type_parent=' . $parent_post_type . '&post_id=' . $post->ID . '&post_type_child=' . $post_type . '&_wpnonce=' . wp_create_nonce('pr_save_child_post')) . '" class="wpcf-pr-save-ajax button-secondary">' . __('Save') . '</a>';
$output .= strpos($item->ID, 'new_') === false ? ' <a href="' . get_edit_post_link($item->ID) . '" class="button-secondary">' . __('Edit') . '</a>' : '';
$output .= strpos($item->ID, 'new_') === false ? ' <a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&' . 'wpcf_action=pr_delete_child_post' . '&post_id=' . $item->ID . '&_wpnonce=' . wp_create_nonce('pr_delete_child_post')) . '" class="wpcf-pr-delete-ajax button-secondary">' . __('Delete') . '</a>' : '';
if ($date_trigger) {
$output .= '<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function(){
wpcfFieldsDateInit("#wpcf-post-relationship");
});
//]]>
</script>';
}
$output .= wpcf_form_render_js_validation('#post', false) . '</td></tr>';
return $output;
}
return $output = '<tr><td><span style="color:Red;">' . __('Error occured', 'wpcf') . '</span></td></tr>';
}
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:101,代码来源:post-relationship.php
示例16: 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_fiel
|
请发表评论