/** * Meta boxes contents output. * * @param type $post * @param type $args */ function wpcf_pr_admin_post_meta_box_output($post, $args) { $output = ''; $relationships = $args; $post_id = !empty($post->ID) ? $post->ID : -1; $current_post_type = wpcf_admin_get_post_type($post); if (!empty($relationships['has'])) { foreach ($relationships['has'] as $post_type => $data) { $output_temp = wpcf_pr_admin_post_meta_box_has_form($post, $post_type, $data, $relationships['post_type']); if (!empty($output_temp)) { $post_type_object = get_post_type_object($post_type); $output .= '<div class="wpcf-pr-has-entries">' . '<div class="wpcf-pr-has-title">' . $post_type_object->label . '</div>' . '<a class="button-primary wpcf-pr-save-all-link" href="' . admin_url('admin-ajax.php?action=wpcf_ajax&wpcf_action=pr_save_all' . '&post_id=' . $post->ID . '&post_type=' . $post_type . '&_wpnonce=' . wp_create_nonce('pr_save_all')) . '">' . __('Save All', 'wpcf') . '</a>' . '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&' . 'wpcf_action=pr_add_child_post&post_type_parent=' . $relationships['post_type'] . '&post_id=' . $post_id . '&post_type_child=' . $post_type . '&_wpnonce=' . wp_create_nonce('pr_add_child_post')) . '" style="line-height:40px;" class="wpcf-pr-ajax-link button-secondary">' . $post_type_object->labels->add_new_item . '</a>' . '<div class="wpcf-pr-pagination-update">' . $output_temp . '</div>' . '</div>'; } } } if (!empty($relationships['belongs'])) { $meta = get_post_custom($post_id); $belongs = array('belongs' => array(), 'posts' => array()); foreach ($meta as $meta_key => $meta_value) { if (strpos($meta_key, '_wpcf_belongs_') === 0) { $temp_post = get_post($meta_value[0]); if (!empty($temp_post)) { $belongs['posts'][$temp_post->ID] = $temp_post; $belongs['belongs'][$temp_post->post_type] = $temp_post->ID; } } } $output_temp = ''; foreach ($relationships['belongs'] as $post_type => $data) { $output_temp .= wpcf_form_simple(wpcf_pr_admin_post_meta_box_belongs_form($post, $post_type, $belongs)); } if (!empty($output_temp)) { $output .= '<div style="margin: 20px 0 10px 0">' . sprintf(__('This %s belongs to:', 'wpcf'), $current_post_type) . '</div>' . $output_temp; } } return $output; }
/** * Meta boxes contents output. * * @param type $post * @param type $args */ function wpcf_pr_admin_post_meta_box_output($post, $args) { if (empty($post->ID)) { return false; } global $wpcf; $output = ''; $relationships = $args; $post_id = !empty($post->ID) ? $post->ID : -1; $current_post_type = wpcf_admin_get_post_type($post); /* * * * * Render has form (child form) */ if (!empty($relationships['has'])) { foreach ($relationships['has'] as $post_type => $data) { $output .= $wpcf->relationship->child_meta_form($post, $post_type, $data); } } /* * * * * Render belongs form (parent form) */ if (!empty($relationships['belongs'])) { $meta = get_post_custom($post_id); $belongs = array('belongs' => array(), 'posts' => array()); foreach ($meta as $meta_key => $meta_value) { if (strpos($meta_key, '_wpcf_belongs_') === 0) { $temp_post = get_post($meta_value[0]); if (!empty($temp_post)) { $belongs['posts'][$temp_post->ID] = $temp_post; $belongs['belongs'][$temp_post->post_type] = $temp_post->ID; } } } $output_temp = ''; foreach ($relationships['belongs'] as $post_type => $data) { $output_temp .= wpcf_form_simple(wpcf_pr_admin_post_meta_box_belongs_form($post, $post_type, $belongs)); } if (!empty($output_temp)) { $output .= '<div style="margin: 20px 0 10px 0">' . sprintf(__('This %s belongs to:', 'wpcf'), $current_post_type) . '</div>' . $output_temp; } } return $output; }