本文整理汇总了PHP中wpcf_pr_admin_post_meta_box_belongs_form函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_pr_admin_post_meta_box_belongs_form函数的具体用法?PHP wpcf_pr_admin_post_meta_box_belongs_form怎么用?PHP wpcf_pr_admin_post_meta_box_belongs_form使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_pr_admin_post_meta_box_belongs_form函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf_pr_admin_post_meta_box_output
/**
* Meta boxes contents output.
*
* @param type $post
* @param type $args
*/
function wpcf_pr_admin_post_meta_box_output($post, $args)
{
if (empty($post) || empty($post->ID)) {
return array();
}
global $wpcf;
$output = '';
$relationships = $args;
$post_id = !empty($post->ID) ? $post->ID : -1;
$current_post_type = wpcf_admin_get_edited_post_type($post);
/*
* Render has form (child form)
*/
if (!empty($relationships['has'])) {
foreach ($relationships['has'] as $post_type => $data) {
if (isset($data['fields_setting']) && 'only_list' == $data['fields_setting']) {
$output .= $wpcf->relationship->child_list($post, $post_type, $data);
} else {
$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;
}
}
}
foreach ($relationships['belongs'] as $post_type => $data) {
$parent_post_type_object = get_post_type_object($post_type);
$output .= '<div class="belongs">';
$form = wpcf_pr_admin_post_meta_box_belongs_form($post, $post_type, $belongs);
if (isset($form[$post_type])) {
$form[$post_type]['#before'] = sprintf('<p>%s %s</p>', sprintf(__('This <em>%s</em> belongs to <em>%s</em>', 'wpcf'), get_post_type_object($current_post_type)->labels->singular_name, $parent_post_type_object->labels->singular_name), sprintf(' <a href="%s" class="button disabled">%s</a>', get_edit_post_link($form[$post_type]['#value']), $parent_post_type_object->labels->edit_item));
}
if ($x = wpcf_form_simple($form)) {
$output .= $x;
} else {
$output .= $parent_post_type_object->labels->not_found;
}
$output .= '</div>';
unset($parent_post_type_object);
}
}
return $output;
}
示例2: _parent_form
/**
* Content for choose parent column.
*
* @return boolean
*/
function _parent_form($post_parent = '')
{
$item_parents = wpcf_pr_admin_get_belongs($this->child_post_type);
if ($item_parents) {
foreach ($item_parents as $parent => $temp_data) {
// Skip if only current available
if ($parent == $this->parent_post_type) {
continue;
}
if (!empty($post_parent) && $parent != $post_parent) {
continue;
}
// Get parent ID
$meta = get_post_meta($this->child->ID, '_wpcf_belongs_' . $parent . '_id', true);
$meta = empty($meta) ? 0 : $meta;
// Get form
$belongs_data = array('belongs' => array($parent => $meta));
$temp_form = wpcf_pr_admin_post_meta_box_belongs_form($this->child, $parent, $belongs_data);
if (empty($temp_form)) {
return '<span class="types-small-italic">' . __('No parents available', 'wpcf') . '</span>';
}
unset($temp_form[$parent]['#suffix'], $temp_form[$parent]['#prefix'], $temp_form[$parent]['#title']);
$temp_form[$parent]['#name'] = 'wpcf_post_relationship[' . $this->parent->ID . '][' . $this->child->ID . '][parents][' . $parent . ']';
// Return HTML formatted output
return wpcf_form_simple($temp_form);
}
}
return '<span class="types-small-italic">' . __('No parents available', 'wpcf') . '</span>';
}
示例3: wpcf_pr_admin_post_meta_box_has_row
/**
* Has form table row.
*
* @param type $post
* @param type $post_type
* @param type $data
* @param type $parent_post_type
* @param stdClass $item
* @return string
*/
function wpcf_pr_admin_post_meta_box_has_row($post, $post_type, $data, $parent_post_type, $item)
{
$new_item = false;
$date_trigger = false;
// Set item
if (empty($item)) {
$item = new stdClass();
$item->ID = 'new_' . mt_rand();
$item->post_title = '';
$item->post_content = '';
$item->post_type = $post_type;
$new_item = true;
}
// Cleanup data
if (empty($data['fields_setting'])) {
$data['fields_setting'] = 'all_cf';
}
$item_parents = isset($data['fields']['_wpcf_pr_parents']) ? $data['fields']['_wpcf_pr_parents'] : array();
unset($data['fields']['_wpcf_pr_parents']);
$row_data = array();
$wpcf_fields = wpcf_admin_fields_get_fields();
$row_data[] = wpcf_form_simple(array('field' => array('#type' => 'textfield', '#id' => 'wpcf_post_relationship_' . $item->ID . '_wp_title', '#name' => 'wpcf_post_relationship[' . $item->ID . '][_wp_title]', '#value' => $item->post_title, '#inline' => true, '#attributes' => $new_item || $data['fields_setting'] == 'all_cf_standard' || isset($data['fields']['_wp_title']) ? array() : array('readonly' => 'readonly'))));
if ($data['fields_setting'] == 'specific' && !empty($data['fields'])) {
foreach ($data['fields'] as $field_key => $true) {
if ($field_key == '_wp_title') {
continue;
} else {
if ($field_key == '_wp_body') {
$value = wp_trim_words($item->post_content, 10, null);
$element = wpcf_form_simple(array('field' => array('#type' => 'textarea', '#id' => 'wpcf_post_relationship_' . $item->ID . '_' . $field_key, '#name' => 'wpcf_post_relationship[' . $item->ID . '][' . $field_key . ']', '#value' => $item->post_content, '#attributes' => array('style' => 'width:300px;height:100px;'), '#inline' => true)));
} else {
$wpcf_key = str_replace(WPCF_META_PREFIX, '', $field_key);
if (strpos($field_key, WPCF_META_PREFIX) === 0 && isset($wpcf_fields[$wpcf_key])) {
// Date trigger
if ($wpcf_fields[$wpcf_key]['type'] == 'date') {
$date_trigger = true;
}
// Get WPCF form
$element = wpcf_admin_post_process_fields($item, array('field' => $wpcf_fields[$wpcf_key]), false, false, 'post_relationship');
$element = array_shift($element);
// TODO There may still be problem with IDs
if (!in_array($wpcf_fields[$wpcf_key]['type'], array('image', 'file'))) {
$element['#id'] = 'wpcf_post_relationship_' . $item->ID . '_' . $wpcf_key;
}
$element['#name'] = 'wpcf_post_relationship[' . $item->ID . '][' . $field_key . ']';
$element['#inline'] = true;
unset($element['#title'], $element['#description']);
if (in_array($wpcf_fields[$wpcf_key]['type'], array('wysiwyg'))) {
$element['#type'] = 'textarea';
$element['#attributes'] = array('style' => 'width:300px;height:100px;');
}
if (in_array($wpcf_fields[$wpcf_key]['type'], array('checkbox'))) {
$element['#suffix'] = '<input type="hidden" name="wpcf_post_relationship_checkbox[' . $item->ID . '][' . $wpcf_key . ']" value="1" />';
}
$value = get_post_meta($item->ID, $field_key, true);
$element = wpcf_form_simple(array('field' => $element));
} else {
// 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;
}
//.........这里部分代码省略.........
示例4: wpcf_pr_admin_post_meta_box_output
/**
* Meta boxes contents output.
*
* @param type $post
* @param type $args
*/
function wpcf_pr_admin_post_meta_box_output($post, $args)
{
if (empty($post) || empty($post->ID)) {
return array();
}
global $wpcf;
$output = '';
$relationships = $args;
$post_id = !empty($post->ID) ? $post->ID : -1;
$current_post_type = wpcf_admin_get_edited_post_type($post);
/*
* Render has form (child form)
*/
if (!empty($relationships['has'])) {
foreach ($relationships['has'] as $post_type => $data) {
if (isset($data['fields_setting']) && 'only_list' == $data['fields_setting']) {
$output .= $wpcf->relationship->child_list($post, $post_type, $data);
} else {
$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;
}
}
}
foreach ($relationships['belongs'] as $post_type => $data) {
$output .= '<div style="margin: 20px 0 10px 0">';
if ($x = wpcf_form_simple(wpcf_pr_admin_post_meta_box_belongs_form($post, $post_type, $belongs))) {
$output .= sprintf(__('This <i>%s</i> belongs to:', 'wpcf'), get_post_type_object($current_post_type)->labels->singular_name);
$output .= $x;
} else {
$output .= get_post_type_object($post_type)->labels->not_found;
}
$output .= '</div>';
}
}
return $output;
}
示例5: wpcf_pr_admin_post_meta_box_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 array();
}
global $wpcf;
$output = '';
$relationships = $args;
$post_id = !empty($post->ID) ? $post->ID : -1;
$current_post_type = wpcf_admin_get_edited_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)) {
$types_existing = get_option('wpcf-custom-types', array());
$output .= '<div style="margin: 20px 0 10px 0">';
$output .= sprintf(__('This <i>%s</i> belongs to:', 'wpcf'), $types_existing[$current_post_type]['labels']['singular_name']);
$output .= '</div>' . $output_temp;
}
}
return $output;
}