本文整理汇总了PHP中wpcf_admin_post_get_post_groups_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_post_get_post_groups_fields函数的具体用法?PHP wpcf_admin_post_get_post_groups_fields怎么用?PHP wpcf_admin_post_get_post_groups_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_admin_post_get_post_groups_fields函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wpcf_admin_post_add_postmeta_to_editor_on_demand
public static function wpcf_admin_post_add_postmeta_to_editor_on_demand($editor)
{
add_action('admin_footer', 'wpcf_admin_post_js_validation');
wpcf_enqueue_scripts();
wp_enqueue_script('toolset-colorbox');
wp_enqueue_style('toolset-colorbox');
$current_post = wpcf_admin_get_edited_post();
if (empty($current_post)) {
$current_post = (object) array('ID' => -1);
}
$fields = wpcf_admin_post_add_to_editor('get');
$groups = wpcf_admin_post_get_post_groups_fields($current_post);
if (!empty($fields) && !empty($groups)) {
foreach ($groups as $group) {
if (empty($group['fields'])) {
continue;
}
foreach ($group['fields'] as $group_field_id => $group_field) {
if (isset($fields[$group_field_id])) {
$field = $fields[$group_field_id];
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $current_post->ID . ')';
$editor->add_insert_shortcode_menu(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
}
}
}
}
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:27,代码来源:wpviews.php
示例2: valid
public function valid()
{
$post_type = Types_Helper_Condition::get_post_type();
// false if we have no post type
if (!isset($post_type->name)) {
return false;
}
// query a post
$query = new WP_Query('post_type=' . $post_type->name . '&posts_per_page=1');
if ($query->have_posts()) {
$post = $query->posts[0];
// for the case no post created yet (post fields group edit page / post type edit page)
} else {
$post = new stdClass();
$post->ID = -1;
$post->post_type = $post_type->name;
}
if (!function_exists('wpcf_admin_post_get_post_groups_fields')) {
include_once WPCF_EMBEDDED_ABSPATH . '/includes/fields-post.php';
}
$fields = wpcf_admin_post_get_post_groups_fields($post);
if (isset($fields) && is_array($fields) && !empty($fields)) {
return true;
}
return false;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:26,代码来源:fields_assigned.php
示例3: valid
public function valid()
{
$post_type = Types_Helper_Condition::get_post_type();
$query = new WP_Query('post_type=' . $post_type->name . '&posts_per_page=1');
if ($query->have_posts()) {
if (!function_exists('wpcf_admin_post_get_post_groups_fields')) {
include_once WPCF_EMBEDDED_ABSPATH . '/includes/fields-post.php';
}
$fields = wpcf_admin_post_get_post_groups_fields($query->posts[0]);
}
if (isset($fields) && is_array($fields) && !empty($fields)) {
return true;
}
return false;
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:15,代码来源:fields_assigned.php
示例4: row
//.........这里部分代码省略.........
// Skip parents
if (in_array($field_key, array('_wp_title', '_wp_body', '_wp_excerpt', '_wpcf_pr_parents', '_wpcf_pr_taxonomies'))) {
continue;
}
/**
* check field
*/
if (!in_array($field_key, $allowed_fields)) {
continue;
}
/*
* Set field
*/
$this->cf->set($this->child, $field_key);
$row[] = $this->field_form();
$this->_field_triggers();
// Add to header
$this->headers[] = $field_key;
}
// Add parent forms
if (!empty($this->data['fields']['_wpcf_pr_parents'])) {
$_temp = (array) $this->data['fields']['_wpcf_pr_parents'];
foreach ($_temp as $_parent => $_true) {
$row[] = $this->_parent_form($_parent);
// Add to header
$this->headers['__parents'][$_parent] = $_true;
}
}
// Add taxonomies forms
if (!empty($this->data['fields']['_wpcf_pr_taxonomies'])) {
$_temp = (array) $this->data['fields']['_wpcf_pr_taxonomies'];
foreach ($_temp as $taxonomy => $_true) {
$_taxonomy = get_taxonomy($taxonomy);
if (!empty($_taxonomy)) {
$row[] = $this->taxonomy_form($_taxonomy);
// Add to header
$this->headers['__taxonomies'][$taxonomy] = $_taxonomy->label;
}
}
}
/*
*
*
*
*
* DEFAULT SETTINGS
*/
} else {
// Set title
$row[] = $this->title();
$this->headers[] = '_wp_title';
// Set body if needed
if ($this->data['fields_setting'] == 'all_cf_standard') {
$this->headers[] = '_wp_body';
$row[] = $this->body();
$this->headers[] = '_wp_excerpt';
$row[] = $this->excerpt();
}
/*
* Loop over groups and fields
*/
// Get groups
$groups = wpcf_admin_post_get_post_groups_fields($this->child, 'post_relationships');
foreach ($groups as $group) {
if (empty($group['fields'])) {
continue;
}
/*
* Loop fields
*/
foreach ($group['fields'] as $field_key => $field) {
/*
* Set field
*/
$field_key = $this->cf->__get_slug_no_prefix($field_key);
$this->cf->set($this->child, $field_key);
$row[] = $this->field_form();
$this->_field_triggers();
// Add to header{
$this->headers[] = WPCF_META_PREFIX . $field_key;
}
}
// Add parent forms
if ($this->data['fields_setting'] == 'all_cf') {
$this->data['fields']['_wpcf_pr_parents'] = wpcf_pr_admin_get_belongs($this->child_post_type);
if (!empty($this->data['fields']['_wpcf_pr_parents'])) {
$_temp = (array) $this->data['fields']['_wpcf_pr_parents'];
foreach ($_temp as $_parent => $_true) {
if ($_parent == $this->parent_post_type) {
continue;
}
$row[] = $this->_parent_form($_parent);
// Add to header
$this->headers['__parents'][$_parent] = $_true;
}
}
}
}
return $row;
}
开发者ID:phuocdungit,项目名称:fundy,代码行数:101,代码来源:form-child.php
示例5: wpcf_admin_post_add_to_editor_js
/**
* Renders JS for editor menu.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @return type
*/
function wpcf_admin_post_add_to_editor_js()
{
// since 1.3 we do not use global $post
$post = wpcf_admin_get_edited_post();
if (empty($post)) {
$post = (object) array('ID' => -1);
}
$fields = wpcf_admin_post_add_to_editor('get');
$groups = wpcf_admin_post_get_post_groups_fields($post);
if (empty($fields) || empty($groups)) {
return false;
}
$editor_addon = new Editor_addon('types', __('Insert Types Shortcode', 'wpcf'), WPCF_EMBEDDED_RES_RELPATH . '/js/types_editor_plugin.js', '', true, 'icon-types-logo ont-icon-18 ont-color-gray');
foreach ($groups as $group) {
if (empty($group['fields'])) {
continue;
}
foreach ($group['fields'] as $group_field_id => $group_field) {
if (!isset($fields[$group_field_id])) {
continue;
}
$field = $fields[$group_field_id];
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $post->ID . ')';
$editor_addon->add_insert_shortcode_menu(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
}
}
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:35,代码来源:fields-post.php
示例6: types_child_posts
/**
* Gets posts that belongs to current post.
*
* @global type $post
* @param type $post_type
* @param type $args
* @return type
*/
function types_child_posts($post_type, $args = array())
{
static $cache = array();
if (isset($args['post_id'])) {
$post = $args['post_id'] != '0' ? get_post($args['post_id']) : null;
} else {
global $post;
}
if (empty($post->ID)) {
return array();
}
$cache_key = md5($post->ID . serialize(func_get_args()));
if (isset($cache[$cache_key])) {
return $cache[$cache_key];
}
global $wp_post_types;
// WP allows querying inactive post types
if (!isset($wp_post_types[$post_type]) || !$wp_post_types[$post_type]->publicly_queryable) {
return array();
}
$defaults = array('post_status' => array('publish'));
$args = wp_parse_args($args, $defaults);
WPCF_Loader::loadModel('relationship');
WPCF_Loader::loadInclude('fields-post');
$child_posts = WPCF_Relationship_Model::getChildrenByPostType($post, $post_type, array(), array(), $args);
foreach ($child_posts as $child_post_key => $child_post) {
$child_posts[$child_post_key]->fields = array();
$groups = wpcf_admin_post_get_post_groups_fields($child_post);
foreach ($groups as $group) {
if (!empty($group['fields'])) {
// Process fields
foreach ($group['fields'] as $k => $field) {
$data = null;
if (types_is_repetitive($field)) {
$data = wpcf_get_post_meta($child_post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], false);
// get all field instances
} else {
$data = wpcf_get_post_meta($child_post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
// get single field instance
// handle checkboxes which are one value serialized
if ($field['type'] == 'checkboxes' && !empty($data)) {
$data = maybe_unserialize($data);
}
}
if (!is_null($data)) {
$child_posts[$child_post_key]->fields[$k] = $data;
}
}
}
}
}
$cache[$cache_key] = $child_posts;
return $child_posts;
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:62,代码来源:api.php
示例7: wpcf_custom_fields_to_be_copied
/**
* wpcf_custom_fields_to_be_copied
*
* Hook the copy custom fields from WPML and remove any of the fields
* that wpcf will copy.
*/
function wpcf_custom_fields_to_be_copied($copied_fields, $original_post_id)
{
// see if this is one of our fields.
$groups = wpcf_admin_post_get_post_groups_fields(get_post($original_post_id));
foreach ($copied_fields as $id => $copied_field) {
foreach ($groups as $group) {
foreach ($group['fields'] as $field) {
if ($copied_field == wpcf_types_get_meta_prefix($field) . $field['slug']) {
unset($copied_fields[$id]);
}
}
}
}
return $copied_fields;
}
开发者ID:sriram911,项目名称:pls,代码行数:21,代码来源:admin.php
示例8: row
//.........这里部分代码省略.........
}
}
if (!$_continue) {
continue;
}
// Skip parents
if (in_array($field_key, array('_wp_title', '_wp_body', '_wpcf_pr_parents', '_wpcf_pr_taxonomies'))) {
continue;
} else {
/*
* Set field
*/
// $field_key = $this->cf->__get_slug_no_prefix( $field_key );
$this->cf->set($this->child, $field_key);
$row[] = $this->field_form();
$this->_field_triggers();
// Add to header
// $this->headers[] = WPCF_META_PREFIX . $field_key;
$this->headers[] = $field_key;
}
}
// Add parent forms
if (!empty($this->data['fields']['_wpcf_pr_parents'])) {
$_temp = (array) $this->data['fields']['_wpcf_pr_parents'];
foreach ($_temp as $_parent => $_true) {
$row[] = $this->_parent_form($_parent);
// Add to header
$this->headers['__parents'][$_parent] = $_true;
}
}
// Add taxonomies forms
if (!empty($this->data['fields']['_wpcf_pr_taxonomies'])) {
$_temp = (array) $this->data['fields']['_wpcf_pr_taxonomies'];
foreach ($_temp as $taxonomy => $_true) {
$_taxonomy = get_taxonomy($taxonomy);
if (!empty($_taxonomy)) {
$row[] = $this->taxonomy_form($_taxonomy);
// Add to header
$this->headers['__taxonomies'][$taxonomy] = $_taxonomy->label;
}
}
}
/*
*
*
*
*
* DEFAULT SETTINGS
*/
} else {
// Set title
$row[] = $this->title();
$this->headers[] = '_wp_title';
// Set body if needed
if ($this->data['fields_setting'] == 'all_cf_standard') {
$this->headers[] = '_wp_body';
$row[] = $this->body();
}
/*
* Loop over groups and fields
*/
// Get groups
$groups = wpcf_admin_post_get_post_groups_fields($this->child, 'post_relationships');
foreach ($groups as $group) {
if (empty($group['fields'])) {
continue;
}
/*
* Loop fields
*/
foreach ($group['fields'] as $field_key => $field) {
/*
* Set field
*/
$field_key = $this->cf->__get_slug_no_prefix($field_key);
$this->cf->set($this->child, $field_key);
$row[] = $this->field_form();
$this->_field_triggers();
// Add to header{
$this->headers[] = WPCF_META_PREFIX . $field_key;
}
}
// Add parent forms
if ($this->data['fields_setting'] == 'all_cf') {
$this->data['fields']['_wpcf_pr_parents'] = wpcf_pr_admin_get_belongs($this->child_post_type);
if (!empty($this->data['fields']['_wpcf_pr_parents'])) {
$_temp = (array) $this->data['fields']['_wpcf_pr_parents'];
foreach ($_temp as $_parent => $_true) {
if ($_parent == $this->parent_post_type) {
continue;
}
$row[] = $this->_parent_form($_parent);
// Add to header
$this->headers['__parents'][$_parent] = $_true;
}
}
}
}
return $row;
}
开发者ID:MiquelAdell,项目名称:miqueladell,代码行数:101,代码来源:form-child.php
示例9: wpcf_admin_post_add_to_editor_js
/**
* Renders JS for editor menu.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @return type
*/
function wpcf_admin_post_add_to_editor_js()
{
global $post;
$fields = wpcf_admin_post_add_to_editor('get');
$groups = wpcf_admin_post_get_post_groups_fields($post);
if (empty($fields) || empty($groups)) {
return false;
}
$editor_addon = new Editor_addon('types', __('Insert Types Shortcode', 'wpcf'), WPCF_EMBEDDED_RES_RELPATH . '/js/types_editor_plugin.js', WPCF_EMBEDDED_RES_RELPATH . '/images/bw-logo-16.png');
foreach ($groups as $group) {
if (empty($group['fields'])) {
continue;
}
foreach ($group['fields'] as $group_field_id => $group_field) {
if (!isset($fields[$group_field_id])) {
continue;
}
$field = $fields[$group_field_id];
$data = wpcf_fields_type_action($field['type']);
$callback = '';
if (isset($data['editor_callback'])) {
$callback = sprintf($data['editor_callback'], $field['id']);
} else {
// Set callback if function exists
$function = 'wpcf_fields_' . $field['type'] . '_editor_callback';
$callback = function_exists($function) ? 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\')' : '';
}
$editor_addon->add_insert_shortcode_menu(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
}
}
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:39,代码来源:fields-post.php
示例10: types_child_posts
/**
* Gets posts that belongs to current post.
*
* @global type $post
* @param type $post_type
* @param type $args
* @return type
*/
function types_child_posts($post_type, $args = array())
{
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
global $post, $wp_post_types;
// WP allows querying inactive post types
if (!isset($wp_post_types[$post_type]) || !$wp_post_types[$post_type]->publicly_queryable) {
return array();
}
$defaults = array('post_type' => $post_type, 'numberposts' => -1, 'post_status' => null, 'meta_key' => '_wpcf_belongs_' . $post->post_type . '_id', 'meta_value' => $post->ID, 'suppress_filters' => false);
$args = wp_parse_args($args, $defaults);
$args = apply_filters('types_child_posts_args', $args);
$child_posts = get_posts($args);
foreach ($child_posts as $child_post_key => $child_post) {
$child_posts[$child_post_key]->fields = array();
$groups = wpcf_admin_post_get_post_groups_fields($child_post);
foreach ($groups as $group) {
if (!empty($group['fields'])) {
// Process fields
foreach ($group['fields'] as $k => $field) {
$child_posts[$child_post_key]->fields[$k] = get_post_meta($child_post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
}
}
}
}
return $child_posts;
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:35,代码来源:types.php
示例11: types_child_posts
/**
* Gets posts that belongs to current post.
*
* @global type $post
* @param type $post_type
* @param type $args
* @return type
*/
function types_child_posts($post_type, $args = array())
{
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
global $post;
$defaults = array('post_type' => $post_type, 'numberposts' => -1, 'post_status' => null, 'meta_key' => '_wpcf_belongs_' . $post->post_type . '_id', 'meta_value' => $post->ID);
$args = wp_parse_args($args, $defaults);
$child_posts = get_posts($args);
foreach ($child_posts as $child_post_key => $child_post) {
$child_posts[$child_post_key]->fields = array();
$groups = wpcf_admin_post_get_post_groups_fields($child_post);
foreach ($groups as $group) {
if (!empty($group['fields'])) {
// Process fields
foreach ($group['fields'] as $k => $field) {
$child_posts[$child_post_key]->fields[$k] = get_post_meta($child_post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
}
}
}
}
return $child_posts;
}
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:29,代码来源:types.php
示例12: types_child_posts
/**
* Gets posts that belongs to current post.
*
* @global type $post
* @param type $post_type
* @param type $args
* @return type
*/
function types_child_posts($post_type, $args = array())
{
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
global $post, $wp_post_types;
// WP allows querying inactive post types
if (!isset($wp_post_types[$post_type]) || !$wp_post_types[$post_type]->publicly_queryable) {
return array();
}
$defaults = array('post_type' => $post_type, 'numberposts' => -1, 'post_status' => null, 'meta_key' => '_wpcf_belongs_' . $post->post_type . '_id', 'meta_value' => $post->ID, 'suppress_filters' => false);
$args = wp_parse_args($args, $defaults);
$args = apply_filters('types_child_posts_args', $args);
$child_posts = get_posts($args);
foreach ($child_posts as $child_post_key => $child_post) {
if ($child_posts[$child_post_key]->post_status == 'trash') {
unset($child_posts[$child_post_key]);
continue;
}
$child_posts[$child_post_key]->fields = array();
$groups = wpcf_admin_post_get_post_groups_fields($child_post);
foreach ($groups as $group) {
if (!empty($group['fields'])) {
// Process fields
foreach ($group['fields'] as $k => $field) {
if (isset($field['data']['repetitive']) && $field['data']['repetitive']) {
$child_posts[$child_post_key]->fields[$k] = get_post_meta($child_post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], false);
} else {
$child_posts[$child_post_key]->fields[$k] = get_post_meta($child_post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
}
// get single field instance
// handle checkboxes which are one value serialized
if ($field['type'] == 'checkboxes' && isset($child_posts[$child_post_key]->fields[$k])) {
$child_posts[$child_post_key]->fields[$k] = maybe_unserialize($child_posts[$child_post_key]->fields[$k]);
}
}
}
}
}
return $child_posts;
}
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:48,代码来源:functions.php
示例13: 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;
}
//.........这里部分代码省略.........
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:101,代码来源:post-relationship.php
示例14: row
/**
* Returns HTML formatted row
*
* While generating rows we collect headers too.
*
* @return type
*/
function row()
{
/*
* Start output.
* Output is returned as array - each element is <td> content.
*/
$row = array();
/*
* LOOP over fields
* Custom settings (specific)
*/
if ($this->data['fields_setting'] == 'specific' && !empty($this->data['fields'])) {
// Set title
if (isset($this->data['fields']['_wp_title'])) {
$this->headers[] = '_wp_title';
$row[] = $this->title();
}
// Set body
if (isset($this->data['fields']['_wp_body'])) {
$this->headers[] = '_wp_body';
$row[] = $this->body();
}
// Loop over Types fields
foreach ($this->data['fields'] as $field_key => $true) {
// Skip parents
if (in_array($field_key, array('_wp_title', '_wp_body', '_wpcf_pr_parents'))) {
continue;
} else {
/*
* Set field
*/
$field_key = $this->cf->__get_slug_no_prefix($field_key);
$this->cf->set($this->child, $field_key);
$row[] = $this->field_form();
$this->_field_triggers();
// Add to header
$this->headers[] = $field_key;
}
}
// Add parent forms
if (!empty($this->data['fields']['_wpcf_pr_parents'])) {
$_temp = (array) $this->data['fields']['_wpcf_pr_parents'];
foreach ($_temp as $_parent => $_true) {
$row[] = $this->_parent_form($_parent);
// Add to header
$this->headers['__parents'][$_parent] = $_true;
}
}
/*
*
*
*
*
* DEFAULT SETTINGS
*/
} else {
// Set title
$row[] = $this->title();
$this->headers[] = '_wp_title';
/*
* Loop over groups and fields
*/
// Get groups
$groups = wpcf_admin_post_get_post_groups_fields($this->child, 'post_relationships');
foreach ($groups as $group) {
/*
* Loop fields
*/
foreach ($group['fields'] as $field_key => $field) {
/*
* Set field
*/
$field_key = $this->cf->__get_slug_no_prefix($field_key);
$this->cf->set($this->child, $field_key);
$row[] = $this->field_form();
$this->_field_triggers();
// Add to header{
$this->headers[] = $field_key;
}
}
}
return $row;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:90,代码来源:form-child.php
示例15: conditionalVerify
/**
* Process AJAX conditional verify.
*
* @global type $wpcf
* @param type $data
* @return boolean|string
*/
public static function conditionalVerify($data)
{
WPCF_Loader::loadInclude('fields');
WPCF_Loader::loadInclude('fields-post');
WPCF_Loader::loadInclude('conditional-display');
global $wpcf;
$js_execute = '';
$_flag_relationship = false;
/*
*
* Determine post.
*/
if (empty($data['wpcf']) && !empty($data['wpcf_post_relationship'])) {
/*
* Relationship case
*/
$_temp = $data['wpcf_post_relationship'];
$parent_id = key($_temp);
$_data = array_shift($_temp);
$post_id = key($_data);
$post = get_post($post_id);
$posted_fields = $_data[$post_id];
$_flag_relationship = true;
/*
*
* Regular submission
*/
} else {
if (isset($data['wpcf_main_post_id'])) {
$post_id = intval($data['wpcf_main_post_id']);
$post = get_post($post_id);
}
}
// No post
if (empty($post->ID)) {
return false;
}
// Get Groups (Fields) for current post
$groups = wpcf_admin_post_get_post_groups_fields($post);
$_processed = array();
foreach ($groups as $group) {
if (!empty($group['fields'])) {
foreach ($group['fields'] as $field_id => $field) {
// Check if already processed
if (isset($_processed[$field_id])) {
continue;
}
if ($wpcf->conditional->is_conditional($field_id)) {
if ($_flag_relationship) {
// Process only submitted fields
if (!isset($posted_fields[WPCF_META_PREFIX . $field_id])) {
continue;
}
$wpcf->conditional->set($post, $field_id);
$wpcf->conditional->context = 'relationship';
$_relationship_name = false;
// Set name and other values processed by hooks
$parent = get_post($parent_id);
if (!empty($parent->ID)) {
$wpcf->relationship->set($parent, $post);
$wpcf->relationship->cf->set($post, $field_id);
$_child = $wpcf->relationship->get_child();
$_child->form->cf->set($post, $field_id);
$_relationship_name = $_child->form->alter_form_name('wpcf[' . $wpcf->conditional->cf['id'] . ']');
}
if (!$_relationship_name) {
continue;
}
/*
* BREAKPOINT
* Adds filtering regular evaluation (not wpv_conditional)
*/
add_filter('types_field_get_submitted_data', 'wpcf_relationship_ajax_data_filter', 10, 2);
$name = $_relationship_name;
} else {
$wpcf->conditional->set($post, $field_id);
$name = 'wpcf[' . $wpcf->conditional->cf['id'] . ']';
}
// Evaluate
$passed = $wpcf->conditional->evaluate();
if ($passed) {
$js_execute .= 'jQuery(\'[name^="' . $name . '"]\').parents(\'.' . 'wpcf-conditional' . '\').show().removeClass(\'' . 'wpcf-conditional' . '-failed\').addClass(\'' . 'wpcf-conditional' . '-passed\');' . " ";
$js_execute .= 'jQuery(\'[name^="' . $name . '"]\').parents(\'.wpcf-repetitive-wrapper\').show();';
} else {
$js_execute .= 'jQuery(\'[name^="' . $name . '"]\').parents(\'.wpcf-repetitive-wrapper\').hide();';
$js_execute .= 'jQuery(\'[name^="' . $name . '"]\').parents(\'.' . 'wpcf-conditional' . '\').hide().addClass(\'' . 'wpcf-conditional' . '-failed\').removeClass(\'' . 'wpcf-conditional' . '-passed\');' . " ";
}
}
$_processed[$field_id] = true;
}
}
}
return $js_execute;
//.........这里部分代码省略.........
开发者ID:santikrass,项目名称:apache,代码行数:101,代码来源:helper.ajax.php
注:本文中的wpcf_admin_post_get_post_groups_fields函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论