本文整理汇总了PHP中wpcf_pr_admin_update_belongs函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_pr_admin_update_belongs函数的具体用法?PHP wpcf_pr_admin_update_belongs怎么用?PHP wpcf_pr_admin_update_belongs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_pr_admin_update_belongs函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf_pr_admin_save_post_hook
/**
* Save post hook.
*
* @param type $parent_post_id
* @return string
*/
function wpcf_pr_admin_save_post_hook($parent_post_id)
{
global $wpcf;
/*
* TODO https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/159760120/comments#225005357
* Problematic This should be done once per save (on saving main post)
* remove_action( 'save_post', 'wpcf_pr_admin_save_post_hook', 11);
*/
static $cached = array();
/*
*
* TODO Monitor this
*/
// Remove main hook?
// CHECKPOINT We remove temporarily main hook
if (!isset($cached[$parent_post_id])) {
if (isset($_POST['wpcf_post_relationship'][$parent_post_id])) {
$wpcf->relationship->save_children($parent_post_id, (array) $_POST['wpcf_post_relationship'][$parent_post_id]);
}
// Save belongs if any
if (isset($_POST['wpcf_pr_belongs'][intval($parent_post_id)])) {
wpcf_pr_admin_update_belongs(intval($parent_post_id), $_POST['wpcf_pr_belongs'][intval($parent_post_id)]);
}
// WPML
wpcf_wpml_relationship_save_post_hook($parent_post_id);
$cached[$parent_post_id] = true;
}
}
示例2: wpcf_ajax_embedded
//.........这里部分代码省略.........
$fields = wpcf_sanitize_post_relationship_input_fields((array) $_POST['wpcf_post_relationship'][$parent_id][$child_id]);
$wpcf->relationship->save_child($parent_id, $child_id, $fields);
$output = $wpcf->relationship->child_row($parent_id, $child_id, $wpcf->relationship->settings($parent_post_type, $child_post_type));
if (!defined('WPTOOLSET_FORMS_VERSION')) {
// TODO Move to conditional
$output .= '<script type="text/javascript">wpcfConditionalInit(\'#types-child-row-' . $child_id . '\');</script>';
}
}
}
$errors = ob_get_clean();
if (!defined('WPTOOLSET_FORMS_VERSION')) {
echo json_encode(array('output' => $output, 'errors' => $errors));
} else {
echo json_encode(array('output' => $output, 'errors' => $errors, 'conditionals' => array('#post' => wptoolset_form_get_conditional_data('post'))));
}
break;
case 'pr_delete_child_post':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if (current_user_can('edit_posts') && isset($_GET['post_id'])) {
$output = wpcf_pr_admin_delete_child_item(intval($_GET['post_id']));
}
echo json_encode(array('output' => $output));
break;
case 'pr-update-belongs':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if (current_user_can('edit_posts') && isset($_POST['post_id']) && isset($_POST['wpcf_pr_belongs'][$_POST['post_id']])) {
$parent_post_id = intval($_POST['post_id']);
$belongs_assignments = array();
foreach ($_POST['wpcf_pr_belongs'][$parent_post_id] as $post_type_raw => $post_id_raw) {
$belongs_assignments[sanitize_text_field($post_type_raw)] = intval($post_id_raw);
}
$updated = wpcf_pr_admin_update_belongs($parent_post_id, $belongs_assignments);
$output = is_wp_error($updated) ? $updated->get_error_message() : $updated;
}
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_pagination':
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 = 'Passed wrong parameters';
if (current_user_can('edit_posts') && isset($_GET['post_id']) && isset($_GET['post_type'])) {
global $wpcf;
$parent = get_post(intval($_GET['post_id']));
$child_post_type = sanitize_text_field($_GET['post_type']);
if (!empty($parent->ID)) {
// Set post in loop
$wpcf->post = $parent;
// Save items_per_page
$wpcf->relationship->save_items_per_page($parent->post_type, $child_post_type, intval($_GET[$wpcf->relationship->items_per_page_option_name]));
$output = $wpcf->relationship->child_meta_form($parent->ID, $child_post_type);
}
}
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_sort':
示例3: types_create_relationship
/**
* Create post relationship.
*
* @param integer $post_id
* @param array $posts array( $post_type => $post_id )
* @param string $action set_child | set_parent
*/
function types_create_relationship($post_id, $posts = array(), $error = false)
{
$updated = wpcf_pr_admin_update_belongs($post_id, $posts);
if (is_wp_error($updated)) {
return $error ? $updated : FALSE;
}
return TRUE;
}
示例4: wpcf_ajax_embedded
/**
* All AJAX calls go here.
*/
function wpcf_ajax_embedded()
{
if (!current_user_can('manage_options') || (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], $_REQUEST['wpcf_action']))) {
die('Verification failed');
}
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)) {
// TODO Remove
// $file = WPCF_EMBEDDED_INC_ABSPATH . '/fields/' . $field['type'] . '.php';
// if (file_exists($file)) {
// require_once $file;
$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':
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 = 'Passed wrong parameters';
if (isset($_GET['post_id']) && isset($_GET['post_type_child']) && isset($_GET['post_type_parent'])) {
$relationships = get_option('wpcf_post_relationship', array());
$post = get_post($_GET['post_id']);
$post_type = $_GET['post_type_child'];
$parent_post_type = $_GET['post_type_parent'];
$data = $relationships[$parent_post_type][$post_type];
$output = wpcf_pr_admin_post_meta_box_has_row($post, $post_type, $data, $parent_post_type, false);
}
echo json_encode(array('output' => $output));
break;
case 'pr_save_child_post':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = array();
if (isset($_GET['post_id']) && isset($_GET['post_type_child'])) {
$post = get_post($_GET['post_id']);
$post_type = $_GET['post_type_child'];
// $output = wpcf_pr_admin_save_child_item($post, $post_type,
// $_POST);
$output = wpcf_pr_admin_save_post_hook($_GET['post_id']);
}
echo json_encode(array('output' => $output));
break;
case 'pr_delete_child_post':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if (isset($_GET['post_id'])) {
$output = wpcf_pr_admin_delete_child_item($_GET['post_id']);
}
echo json_encode(array('output' => $output));
break;
case 'pr-update-belongs':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if (isset($_POST['post_id']) && isset($_POST['wpcf_pr_belongs'])) {
$output = wpcf_pr_admin_update_belongs($_POST['post_id'], $_POST['wpcf_pr_belongs']);
}
echo json_encode(array('output' => $output));
break;
case 'pr_pagination':
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 = 'Passed wrong parameters';
if (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_sort':
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 = 'Passed wrong parameters';
//.........这里部分代码省略.........
示例5: wpcf_pr_admin_save_post_hook
/**
* Save post hook.
*
* @param type $parent_post_id
* @return string
*/
function wpcf_pr_admin_save_post_hook($parent_post_id)
{
global $wpcf;
/*
* TODO https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/159760120/comments#225005357
* Problematic This should be done once per save (on saving main post)
* remove_action( 'save_post', 'wpcf_pr_admin_save_post_hook', 11);
*/
static $cached = array();
/*
*
* TODO Monitor this
*/
// Remove main hook?
// CHECKPOINT We remove temporarily main hook
if (!isset($cached[$parent_post_id])) {
if (isset($_POST['wpcf_post_relationship'][$parent_post_id])) {
$wpcf->relationship->save_children($parent_post_id, (array) $_POST['wpcf_post_relationship'][$parent_post_id]);
}
// Save belongs if any
if (isset($_POST['wpcf_pr_belongs'][intval($parent_post_id)])) {
wpcf_pr_admin_update_belongs(intval($parent_post_id), $_POST['wpcf_pr_belongs'][intval($parent_post_id)]);
}
// WPML
wpcf_wpml_relationship_save_post_hook($parent_post_id);
/**
* Temporary workaround until https://core.trac.wordpress.org/ticket/17817 is fixed.
*
* Saving child posts cancels all save_post actions for the parent post that would otherwise come
* after this one.
*
* @since 2.2
*/
do_action('types_finished_saving_child_posts', $parent_post_id);
$cached[$parent_post_id] = true;
}
}
示例6: 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');
}
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':
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 = 'Passed wrong parameters';
if (isset($_GET['post_id']) && isset($_GET['post_type_child']) && isset($_GET['post_type_parent'])) {
$relationships = get_option('wpcf_post_relationship', array());
$post = get_post($_GET['post_id']);
$post_type = $_GET['post_type_child'];
$parent_post_type = $_GET['post_type_parent'];
$data = $relationships[$parent_post_type][$post_type];
$output = wpcf_pr_admin_post_meta_box_has_row($post, $post_type, $data, $parent_post_type, false);
}
echo json_encode(array('output' => $output));
break;
case 'pr_save_child_post':
ob_start();
// Try to catch any errors
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = array();
if (isset($_GET['post_id']) && isset($_GET['post_type_child'])) {
$post = get_post($_GET['post_id']);
$post_type = $_GET['post_type_child'];
$output = wpcf_pr_admin_save_post_hook($_GET['post_id']);
}
$errors = ob_get_clean();
echo json_encode(array('output' => $output, 'errors' => $errors));
break;
case 'pr_delete_child_post':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if (isset($_GET['post_id'])) {
$output = wpcf_pr_admin_delete_child_item($_GET['post_id']);
}
echo json_encode(array('output' => $output));
break;
case 'pr-update-belongs':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if (isset($_POST['post_id']) && isset($_POST['wpcf_pr_belongs'])) {
$output = wpcf_pr_admin_update_belongs($_POST['post_id'], $_POST['wpcf_pr_belongs']);
}
echo json_encode(array('output' => $output));
break;
case 'pr_pagination':
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 = 'Passed wrong parameters';
if (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_sort':
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 = '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);
//.........这里部分代码省略.........
示例7: wpcf_ajax_embedded
//.........这里部分代码省略.........
// 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
$_POST['post_ID'] = $_POST['post_id'];
$parent_id = intval($_GET['parent_id']);
$child_id = intval($_GET['post_id']);
$parent_post_type = strval($_GET['post_type_parent']);
$child_post_type = strval($_GET['post_type_child']);
if (isset($_POST['wpcf_post_relationship'][$parent_id][$child_id])) {
$fields = (array) $_POST['wpcf_post_relationship'][$parent_id][$child_id];
$wpcf->relationship->save_child($parent_id, $child_id, $fields);
$output = $wpcf->relationship->child_row($parent_id, $child_id, $wpcf->relationship->settings($parent_post_type, $child_post_type));
// TODO Move to conditional
$output .= '<script type="text/javascript">wpcfConditionalInit(\'#types-child-row-' . $child_id . '\');</script>';
}
}
$errors = ob_get_clean();
echo json_encode(array('output' => $output, 'errors' => $errors));
break;
case 'pr_delete_child_post':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if (isset($_GET['post_id'])) {
$output = wpcf_pr_admin_delete_child_item(intval($_GET['post_id']));
}
echo json_encode(array('output' => $output));
break;
case 'pr-update-belongs':
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
$output = 'Passed wrong parameters';
if (isset($_POST['post_id']) && isset($_POST['wpcf_pr_belongs'][$_POST['post_id']])) {
$post_id = intval($_POST['post_id']);
$output = wpcf_pr_admin_update_belongs($post_id, $_POST['wpcf_pr_belongs'][$post_id]);
}
echo json_encode(array('output' => $output));
break;
case 'pr_pagination':
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 = 'Passed wrong parameters';
if (isset($_GET['post_id']) && isset($_GET['post_type'])) {
global $wpcf;
$parent = get_post(esc_attr($_GET['post_id']));
$child_post_type = esc_attr($_GET['post_type']);
if (!empty($parent->ID)) {
// Set post in loop
$wpcf->post = $parent;
// Save items_per_page
$wpcf->relationship->save_items_per_page($parent->post_type, $child_post_type, intval($_GET[$wpcf->relationship->items_per_page_option_name]));
$output = $wpcf->relationship->child_meta_form($parent->ID, $child_post_type);
}
}
echo json_encode(array('output' => $output));
break;
case 'pr_sort':
$output = 'Passed wrong parameters';
if (isset($_GET['field']) && isset($_GET['sort']) && isset($_GET['post_id']) && isset($_GET['post_type'])) {
$output = $wpcf->relationship->child_meta_form(intval($_GET['post_id']), strval($_GET['post_type']));
}
echo json_encode(array('output' => $output));
break;
case 'pr_sort_parent':
$output = 'Passed wrong parameters';
if (isset($_GET['field']) && isset($_GET['sort']) && isset($_GET['post_id']) && isset($_GET['post_type'])) {
示例8: wpcf_pr_admin_save_post_hook
/**
* Save post hook.
*
* @param type $parent_post_id
* @return string
*/
function wpcf_pr_admin_save_post_hook($parent_post_id)
{
global $wpcf;
/*
*
* TODO Monitor this
*/
// Remove main hook?
// CHECKPOINT We remove temporarily main hook
// remove_action( 'save_post', 'wpcf_admin_save_post_hook', 10, 2 );
// This should be done once per save
remove_action('save_post', 'wpcf_pr_admin_save_post_hook', 11, 2);
if (isset($_POST['wpcf_post_relationship'][$parent_post_id])) {
$wpcf->relationship->save_children($parent_post_id, (array) $_POST['wpcf_post_relationship'][$parent_post_id]);
}
// Save belongs if any
if (isset($_POST['wpcf_pr_belongs'][intval($parent_post_id)])) {
wpcf_pr_admin_update_belongs(intval($parent_post_id), $_POST['wpcf_pr_belongs'][intval($parent_post_id)]);
}
// WPML
wpcf_wpml_relationship_save_post_hook($parent_post_id);
// Restore main hook?
// add_action( 'save_post', 'wpcf_admin_save_post_hook', 10, 2 );
}