本文整理汇总了PHP中wpcf_admin_get_groups_by_post_type函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_get_groups_by_post_type函数的具体用法?PHP wpcf_admin_get_groups_by_post_type怎么用?PHP wpcf_admin_get_groups_by_post_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_admin_get_groups_by_post_type函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: prepare_field_select_screen
/**
* Summary.
*
* Description.
*
* @since x.x.x
* @access (for functions: only use if private)
*
* @see Function/method/class relied on
* @link URL
* @global type $varname Description.
* @global type $varname Description.
*
* @param type $var Description.
* @param type $var Optional. Description.
* @return type Description.
*/
public function prepare_field_select_screen()
{
/**
* check nonce
*/
if (0 || !isset($_REQUEST['_wpnonce']) || !isset($_REQUEST['parent']) || !isset($_REQUEST['child']) || !wp_verify_nonce($_REQUEST['_wpnonce'], $this->get_nonce('child-post-fields', $_REQUEST['parent'], $_REQUEST['child']))) {
$this->verification_failed_and_die();
}
$parent = $_REQUEST['parent'];
$child = $_REQUEST['child'];
$post_type_parent = get_post_type_object($parent);
$post_type_child = get_post_type_object($child);
if (empty($post_type_parent) || empty($post_type_child)) {
die(__('Wrong post types', 'wpcf'));
}
$relationships = get_option('wpcf_post_relationship', array());
if (!isset($relationships[$parent][$child])) {
$this->print_notice_and_die(__('Please save Post Type first to edit these fields.', 'wpcf'));
}
$repetitive_warning_markup = array();
$data = $relationships[$parent][$child];
$form = array();
$form['repetitive_warning_markup'] = $repetitive_warning_markup;
$form['select'] = array('#type' => 'radios', '#name' => 'fields_setting', '#options' => array(__('Title, all custom fields and parents', 'wpcf') => 'all_cf', __('Do not show management options for this post type', 'wpcf') => 'only_list', __('All fields, including the standard post fields', 'wpcf') => 'all_cf_standard', __('Specific fields', 'wpcf') => 'specific'), '#attributes' => array('display' => 'ul'), '#default_value' => empty($data['fields_setting']) ? 'all_cf' : $data['fields_setting']);
/**
* check default, to avoid missing configuration
*/
if (!in_array($form['select']['#default_value'], $form['select']['#options'])) {
$form['select']['#default_value'] = 'all_cf';
}
/**
* Specific options
*/
$groups = wpcf_admin_get_groups_by_post_type($child);
$options_cf = array();
$repetitive_warning = false;
$repetitive_warning_txt = __('Repeating fields should not be used in child posts. Types will update all field values.', 'wpcf');
foreach ($groups as $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id']);
foreach ($fields as $key => $cf) {
$__key = wpcf_types_cf_under_control('check_outsider', $key) ? $key : WPCF_META_PREFIX . $key;
$options_cf[$__key] = array('#title' => $cf['name'], '#name' => 'fields[' . $__key . ']', '#default_value' => isset($data['fields'][$__key]) ? 1 : 0, '#inline' => true, '#before' => '<li>', '#after' => '</li>');
// Repetitive warning
if (wpcf_admin_is_repetitive($cf)) {
if (!$repetitive_warning) {
$repetitive_warning_markup = array('#type' => 'markup', '#markup' => '<div class="message error" style="display:none;" id="wpcf-repetitive-warning"><p>' . $repetitive_warning_txt . '</p></div>');
}
$repetitive_warning = true;
$options_cf[$__key]['#after'] = !isset($data['fields'][$__key]) ? '<div class="message error" style="display:none;"><p>' : '<div class="message error"><p>';
$options_cf[$__key]['#after'] .= $repetitive_warning_txt;
$options_cf[$__key]['#after'] .= '</p></div></li>';
$options_cf[$__key]['#attributes'] = array('onclick' => 'jQuery(this).parent().find(\'.message\').toggle();', 'disabled' => 'disabled');
}
}
}
/**
* build options for "Specific fields"
*/
$options = array();
/**
* check and add built-in properites
*/
require_once WPCF_INC_ABSPATH . '/post-relationship.php';
$supports = wpcf_post_relationship_get_supported_fields_by_post_type($child);
foreach ($supports as $child_field_key => $child_field_data) {
$options[$child_field_data['name']] = array('#title' => $child_field_data['title'], '#name' => sprintf('fields[%s]', $child_field_data['name']), '#default_value' => isset($data['fields'][$child_field_data['name']]) ? 1 : 0, '#inline' => true, '#before' => '<li>', '#after' => '</li>');
}
/**
* add custom fields
*/
$options = $options + $options_cf;
$temp_belongs = wpcf_pr_admin_get_belongs($child);
foreach ($temp_belongs as $temp_parent => $temp_data) {
if ($temp_parent == $parent) {
continue;
}
$temp_parent_type = get_post_type_object($temp_parent);
$options[$temp_parent] = array('#title' => $temp_parent_type->label, '#name' => 'fields[_wpcf_pr_parents][' . $temp_parent . ']', '#default_value' => isset($data['fields']['_wpcf_pr_parents'][$temp_parent]) ? 1 : 0, '#inline' => true, '#before' => '<li>', '#after' => '</li>');
}
/**
* remove "Specific fields" if there is no fields
*/
if (empty($options)) {
//.........这里部分代码省略.........
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:101,代码来源:class.types.admin.edit.post.type.php
示例2: wpcf_pr_admin_edit_fields
/**
* Edit fields form.
*
* @param type $parent
* @param type $child
*/
function wpcf_pr_admin_edit_fields($parent, $child)
{
$post_type_parent = get_post_type_object($parent);
$post_type_child = get_post_type_object($child);
if (empty($post_type_parent) || empty($post_type_child)) {
die(__('Wrong post types', 'wpcf'));
}
$relationships = get_option('wpcf_post_relationship', array());
if (!isset($relationships[$parent][$child])) {
die(__('Relationship do not exist', 'wpcf'));
}
$data = $relationships[$parent][$child];
wp_enqueue_script('jquery');
wp_enqueue_style('types');
wpcf_admin_ajax_head('Edit fields', 'wpcf');
// Process submit
if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'pt_edit_fields')) {
$relationships[$parent][$child]['fields_setting'] = sanitize_text_field($_POST['fields_setting']);
// @todo Maybe sanitization here
$relationships[$parent][$child]['fields'] = isset($_POST['fields']) ? $_POST['fields'] : array();
update_option('wpcf_post_relationship', $relationships);
?>
<script type="text/javascript">
window.parent.jQuery('#TB_closeWindowButton').trigger('click');
window.parent.location.reload();
</script>
<?php
die;
}
$groups = wpcf_admin_get_groups_by_post_type($child);
$options_cf = array();
$repetitive_warning = false;
$repetitive_warning_markup = array();
$repetitive_warning_txt = __('Repeating fields should not be used in child posts. Types will update all field values.', 'wpcf');
foreach ($groups as $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id']);
foreach ($fields as $key => $cf) {
$__key = wpcf_types_cf_under_control('check_outsider', $key) ? $key : WPCF_META_PREFIX . $key;
$options_cf[$__key] = array();
$options_cf[$__key]['#title'] = $cf['name'];
$options_cf[$__key]['#name'] = 'fields[' . $__key . ']';
$options_cf[$__key]['#default_value'] = isset($data['fields'][$__key]) ? 1 : 0;
// Repetitive warning
if (wpcf_admin_is_repetitive($cf)) {
if (!$repetitive_warning) {
$repetitive_warning_markup = array('#type' => 'markup', '#markup' => '<div class="message error" style="display:none;" id="wpcf-repetitive-warning"><p>' . $repetitive_warning_txt . '</p></div>');
}
$repetitive_warning = true;
$options_cf[$__key]['#after'] = !isset($data['fields'][$__key]) ? '<div class="message error" style="display:none;"><p>' : '<div class="message error"><p>';
$options_cf[$__key]['#after'] .= $repetitive_warning_txt;
$options_cf[$__key]['#after'] .= '</p></div>';
$options_cf[$__key]['#attributes'] = array('onclick' => 'jQuery(this).parent().find(\'.message\').toggle();', 'disabled' => 'disabled');
}
}
}
$form = array();
$form['repetitive_warning_markup'] = $repetitive_warning_markup;
$form['select'] = array('#type' => 'radios', '#name' => 'fields_setting', '#options' => array(__('Title, all custom fields and parents', 'wpcf') => 'all_cf', __('Do not show management options for this post type', 'wpcf') => 'only_list', __('All fields, including the standard post fields', 'wpcf') => 'all_cf_standard', __('Specific fields', 'wpcf') => 'specific'), '#default_value' => empty($data['fields_setting']) ? 'all_cf' : $data['fields_setting']);
/**
* check default, to avoid missing configuration
*/
if (!in_array($form['select']['#default_value'], $form['select']['#options'])) {
$form['select']['#default_value'] = 'all_cf';
}
/**
* build options for "Specific fields"
*/
$options = array();
/**
* check and add build-in properites
*/
$check_support = array('title' => array('name' => '_wp_title', 'title' => __('Post title', 'wpcf')), 'editor' => array('name' => '_wp_body', 'title' => __('Post body', 'wpcf')), 'excerpt' => array('name' => '_wp_excerpt', 'title' => __('Post excerpt', 'wpcf')), 'thumbnail' => array('name' => '_wp_featured_image', 'title' => __('Post featured image', 'wpcf')));
foreach ($check_support as $child_field_key => $child_field_data) {
if (!post_type_supports($child, $child_field_key)) {
continue;
}
$options[$child_field_data['name']] = array('#title' => $child_field_data['title'], '#name' => sprintf('fields[%s]', $child_field_data['name']), '#default_value' => isset($data['fields'][$child_field_data['name']]) ? 1 : 0);
}
/**
* add custom fields
*/
$options = $options + $options_cf;
$temp_belongs = wpcf_pr_admin_get_belongs($child);
foreach ($temp_belongs as $temp_parent => $temp_data) {
if ($temp_parent == $parent) {
continue;
}
$temp_parent_type = get_post_type_object($temp_parent);
$options[$temp_parent] = array();
$options[$temp_parent]['#title'] = $temp_parent_type->label;
$options[$temp_parent]['#name'] = 'fields[_wpcf_pr_parents][' . $temp_parent . ']';
$options[$temp_parent]['#default_value'] = isset($data['fields']['_wpcf_pr_parents'][$temp_parent]) ? 1 : 0;
}
/**
//.........这里部分代码省略.........
开发者ID:aarongillett,项目名称:B22-151217,代码行数:101,代码来源:post-relationship.php
示例3: wpcf_pr_admin_edit_fields
/**
* Edit fields form.
*
* @global type $wpdb
* @param type $parent
* @param type $child
*/
function wpcf_pr_admin_edit_fields($parent, $child)
{
global $wpdb;
$post_type_parent = get_post_type_object($parent);
$post_type_child = get_post_type_object($child);
if (empty($post_type_parent) || empty($post_type_child)) {
die(__('Wrong post types'));
}
$relationships = get_option('wpcf_post_relationship', array());
if (!isset($relationships[$parent][$child])) {
die(__('Relationship do not exist'));
}
$data = $relationships[$parent][$child];
wp_enqueue_script('jquery');
wpcf_admin_ajax_head('Edit fields', 'wpcf');
// Process submit
if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'pt_edit_fields')) {
$relationships[$parent][$child]['fields_setting'] = $_POST['fields_setting'];
$relationships[$parent][$child]['fields'] = isset($_POST['fields']) ? $_POST['fields'] : array();
update_option('wpcf_post_relationship', $relationships);
?>
<script type="text/javascript">
window.parent.jQuery('#TB_closeWindowButton').trigger('click');
window.parent.location.reload();
</script>
<?php
die;
}
$form = array();
$form['select'] = array('#type' => 'radios', '#name' => 'fields_setting', '#options' => array(__('Title, all custom fields and parents', 'wpcf') => 'all_cf', __('All fields, including the standard post fields', 'wpcf') => 'all_cf_standard', __('Specific fields', 'wpcf') => 'specific'), '#default_value' => empty($data['fields_setting']) ? 'all_cf' : $data['fields_setting']);
$options = array();
$options['_wp_title'] = array('#title' => __('Post title', 'wpcf'), '#name' => 'fields[_wp_title]', '#default_value' => isset($data['fields']['_wp_title']) ? 1 : 0);
$options['_wp_body'] = array('#title' => __('Post body', 'wpcf'), '#name' => 'fields[_wp_body]', '#default_value' => isset($data['fields']['_wp_body']) ? 1 : 0);
// $wpcf_fields = wpcf_admin_fields_get_fields(true);
$groups = wpcf_admin_get_groups_by_post_type($child);
foreach ($groups as $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id']);
foreach ($fields as $key => $cf) {
$options[WPCF_META_PREFIX . $key] = array();
$options[WPCF_META_PREFIX . $key]['#title'] = $cf['name'];
$options[WPCF_META_PREFIX . $key]['#name'] = 'fields[' . WPCF_META_PREFIX . $key . ']';
$options[WPCF_META_PREFIX . $key]['#default_value'] = isset($data['fields'][WPCF_META_PREFIX . $key]) ? 1 : 0;
}
}
$temp_belongs = wpcf_pr_admin_get_belongs($child);
foreach ($temp_belongs as $temp_parent => $temp_data) {
if ($temp_parent == $parent) {
continue;
}
$temp_parent_type = get_post_type_object($temp_parent);
$options[$temp_parent] = array();
$options[$temp_parent]['#title'] = $temp_parent_type->label;
$options[$temp_parent]['#name'] = 'fields[_wpcf_pr_parents][' . $temp_parent . ']';
$options[$temp_parent]['#default_value'] = isset($data['fields']['_wpcf_pr_parents'][$temp_parent]) ? 1 : 0;
}
// foreach ($wpcf_fields as $key => $cf) {
// $options[WPCF_META_PREFIX . $key] = array();
// $options[WPCF_META_PREFIX . $key]['#title'] = $cf['name'];
// $options[WPCF_META_PREFIX . $key]['#name'] = 'fields[' . WPCF_META_PREFIX . $key . ']';
// $options[WPCF_META_PREFIX . $key]['#default_value'] = isset($data['fields'][WPCF_META_PREFIX . $key]) ? 1 : 0;
// }
// $cf_all = $wpdb->get_results("
// SELECT meta_id, meta_key
// FROM $wpdb->postmeta
// GROUP BY meta_key
// HAVING meta_key NOT LIKE '\_%'
// ORDER BY meta_key");
// foreach ($cf_all as $key => $cf) {
// if (isset($options[$cf->meta_key])) {
// continue;
// }
// $options[$key] = array();
// $options[$key]['#title'] = $cf->meta_key;
// $options[$key]['#name'] = 'fields[' . $cf->meta_key . ']';
// $options[$key]['#default_value'] = isset($data['fields'][$cf->meta_key]) ? 1 : 0;
// }
$form['specific'] = array('#type' => 'checkboxes', '#name' => 'fields', '#options' => $options, '#default_value' => isset($data['fields']), '#before' => '<div id="wpcf-specific" style="display:none;margin:10px 0 0 20px;">', '#after' => '</div>');
$form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Save'), '#attributes' => array('class' => 'button-primary'));
echo '<form method="post" action="">';
echo wpcf_form_simple($form);
echo wp_nonce_field('pt_edit_fields');
echo '</form>';
?>
<script type="text/javascript">
jQuery(document).ready(function(){
if (jQuery('input[name="fields_setting"]:checked').val() == 'specific') {
jQuery('#wpcf-specific').show();
}
jQuery('input[name="fields_setting"]').change(function(){
if (jQuery(this).val() == 'specific') {
jQuery('#wpcf-specific').slideDown();
} else {
jQuery('#wpcf-specific').slideUp();
//.........这里部分代码省略.........
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:101,代码来源:post-relationship.php
示例4: add_view_template_parent_groups
function add_view_template_parent_groups($items)
{
global $post;
// get current View ID
$view_template_id = $post->ID;
// get all view templates attached in the Settings page for single view
$view_template_relations = $this->get_view_template_settings();
// find view template groups and get their parents
$current_types = array();
$parent_types = array();
foreach ($view_template_relations as $relation => $value) {
if ($value == $view_template_id) {
$current_types[] = $relation;
if (function_exists('wpcf_pr_get_belongs')) {
$parent_types[] = wpcf_pr_get_belongs($relation);
}
}
}
// get parent groups
$all_parent_groups = array();
foreach ($parent_types as $type) {
foreach ($type as $typename => $typeval) {
$parent_groups = wpcf_admin_get_groups_by_post_type($typename);
}
}
}
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:26,代码来源:editor-addon.class.php
示例5: wpcf_pr_admin_edit_fields
/**
* Edit fields form.
*
* @global type $wpdb
* @param type $parent
* @param type $child
*/
function wpcf_pr_admin_edit_fields($parent, $child)
{
global $wpdb;
$post_type_parent = get_post_type_object($parent);
$post_type_child = get_post_type_object($child);
if (empty($post_type_parent) || empty($post_type_child)) {
die(__('Wrong post types'));
}
$relationships = get_option('wpcf_post_relationship', array());
if (!isset($relationships[$parent][$child])) {
die(__('Relationship do not exist'));
}
$data = $relationships[$parent][$child];
wp_enqueue_script('jquery');
wpcf_admin_ajax_head('Edit fields', 'wpcf');
// Process submit
if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'pt_edit_fields')) {
$relationships[$parent][$child]['fields_setting'] = $_POST['fields_setting'];
$relationships[$parent][$child]['fields'] = isset($_POST['fields']) ? $_POST['fields'] : array();
update_option('wpcf_post_relationship', $relationships);
?>
<script type="text/javascript">
window.parent.jQuery('#TB_closeWindowButton').trigger('click');
window.parent.location.reload();
</script>
<?php
die;
}
$groups = wpcf_admin_get_groups_by_post_type($child);
$options_cf = array();
$repetitive_warning = false;
$repetitive_warning_markup = array();
$repetitive_warning_txt = __('Repeating fields should not be used in child posts. Types will update all field values.', 'wpcf');
foreach ($groups as $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id']);
foreach ($fields as $key => $cf) {
$options_cf[WPCF_META_PREFIX . $key] = array();
$options_cf[WPCF_META_PREFIX . $key]['#title'] = $cf['name'];
$options_cf[WPCF_META_PREFIX . $key]['#name'] = 'fields[' . WPCF_META_PREFIX . $key . ']';
$options_cf[WPCF_META_PREFIX . $key]['#default_value'] = isset($data['fields'][WPCF_META_PREFIX . $key]) ? 1 : 0;
// Repetitive warning
if (wpcf_admin_is_repetitive($cf)) {
if (!$repetitive_warning) {
$repetitive_warning_markup = array('#type' => 'markup', '#markup' => '<div class="message error" style="display:none;" id="wpcf-repetitive-warning"><p>' . $repetitive_warning_txt . '</p></div>');
}
$repetitive_warning = true;
$options_cf[WPCF_META_PREFIX . $key]['#after'] = !isset($data['fields'][WPCF_META_PREFIX . $key]) ? '<div class="message error" style="display:none;"><p>' : '<div class="message error"><p>';
$options_cf[WPCF_META_PREFIX . $key]['#after'] .= $repetitive_warning_txt;
$options_cf[WPCF_META_PREFIX . $key]['#after'] .= '</p></div>';
$options_cf[WPCF_META_PREFIX . $key]['#attributes'] = array('onclick' => 'jQuery(this).parent().find(\'.message\').toggle();');
}
}
}
$form = array();
$form['repetitive_warning_markup'] = $repetitive_warning_markup;
$form['select'] = array('#type' => 'radios', '#name' => 'fields_setting', '#options' => array(__('Title, all custom fields and parents', 'wpcf') => 'all_cf', __('All fields, including the standard post fields', 'wpcf') => 'all_cf_standard', __('Specific fields', 'wpcf') => 'specific'), '#default_value' => empty($data['fields_setting']) ? 'all_cf' : $data['fields_setting']);
$options = array();
$options['_wp_title'] = array('#title' => __('Post title', 'wpcf'), '#name' => 'fields[_wp_title]', '#default_value' => isset($data['fields']['_wp_title']) ? 1 : 0);
$options['_wp_body'] = array('#title' => __('Post body', 'wpcf'), '#name' => 'fields[_wp_body]', '#default_value' => isset($data['fields']['_wp_body']) ? 1 : 0);
$options = $options + $options_cf;
$temp_belongs = wpcf_pr_admin_get_belongs($child);
foreach ($temp_belongs as $temp_parent => $temp_data) {
if ($temp_parent == $parent) {
continue;
}
$temp_parent_type = get_post_type_object($temp_parent);
$options[$temp_parent] = array();
$options[$temp_parent]['#title'] = $temp_parent_type->label;
$options[$temp_parent]['#name'] = 'fields[_wpcf_pr_parents][' . $temp_parent . ']';
$options[$temp_parent]['#default_value'] = isset($data['fields']['_wpcf_pr_parents'][$temp_parent]) ? 1 : 0;
}
$form['specific'] = array('#type' => 'checkboxes', '#name' => 'fields', '#options' => $options, '#default_value' => isset($data['fields']), '#before' => '<div id="wpcf-specific" style="display:none;margin:10px 0 0 20px;">', '#after' => '</div>');
$form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary'));
echo '<form method="post" action="">';
echo wpcf_form_simple($form);
echo wp_nonce_field('pt_edit_fields');
echo '</form>';
?>
<script type="text/javascript">
jQuery(document).ready(function(){
if (jQuery('input[name="fields_setting"]:checked').val() == 'specific') {
jQuery('#wpcf-specific').show();
} else {
<?php
if ($repetitive_warning) {
?>
jQuery('#wpcf-repetitive-warning').show();
<?php
}
?>
}
jQuery('input[name="fields_setting"]').change(function(){
if (jQuery(this).val() == 'specific') {
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:post-relationship.php
示例6: wpcf_admin_get_allowed_fields_by_post_type
/**
* Get active fields by post type
*
* Get active fields by post type chosing it from active groups and this
* groups which are connected to certain post type.
*
* @since: 1.7
*
* @param string $post_type post type
*
* @return array allowed meta keys
*/
function wpcf_admin_get_allowed_fields_by_post_type($post_type)
{
$allowed_fields = $active_groups = array();
$all_groups = wpcf_admin_get_groups_by_post_type($post_type);
foreach ($all_groups as $group_id => $group_data) {
$active_groups[] = $group_data['slug'];
}
$all_groups = wpcf_admin_fields_get_groups(TYPES_CUSTOM_FIELD_GROUP_CPT_NAME, true, true);
foreach ($all_groups as $group) {
if (!in_array($group['slug'], $active_groups)) {
continue;
}
foreach ($group['fields'] as $field_key => $field_data) {
$allowed_fields[] = $field_data['meta_key'];
}
}
return $allowed_fields;
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:30,代码来源:fields.php
示例7: wpcf_admin_post_get_post_groups_fields
//.........这里部分代码省略.........
if ($post_type_filter == -1 && $taxonomy_filter == -1 && $template_filter == -1) {
$passed = 1;
} else {
if ($groups_all[$temp_key]['filters_association'] == 'any') {
$passed = $post_type_filter == 1 || $taxonomy_filter == 1 || $template_filter == 1;
} else {
$passed = $post_type_filter != 0 && $taxonomy_filter != 0 && $template_filter != 0;
}
}
if (!$passed) {
unset($groups_all[$temp_key]);
} else {
$groups_all[$temp_key]['fields'] = wpcf_admin_fields_get_fields_by_group($temp_group['id'], 'slug', true, false, true);
}
}
$groups = apply_filters('wpcf_post_groups', $groups_all, $post);
return $groups;
// TODO Remove
// Get by taxonomy
$distinct_terms = array();
if ($post) {
$taxonomies = get_taxonomies('', 'objects');
if (!empty($taxonomies)) {
foreach ($taxonomies as $tax_slug => $tax) {
$terms = wp_get_post_terms($post->ID, $tax_slug, array('fields' => 'ids'));
foreach ($terms as $term_id) {
$groups_by_term = wpcf_admin_fields_get_groups_by_term($term_id, true, $post_type);
if (!empty($groups_by_term)) {
foreach ($groups_by_term as $group) {
if (!isset($groups[$group['id']])) {
$groups[$group['id']] = $group;
$groups[$group['id']]['fields'] = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
}
$groups[$group['id']]['__wpcf_terms'] = 1;
}
}
$distinct_terms[] = $term_id;
}
}
// Fetch displayed on all
$groups_by_term = wpcf_admin_fields_get_groups_by_term(false, true, $post_type);
if (!empty($groups_by_term)) {
foreach ($groups_by_term as $group) {
if (!isset($groups[$group['id']])) {
$groups[$group['id']] = $group;
$groups[$group['id']]['fields'] = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
}
$groups[$group['id']]['__wpcf_terms'] = 1;
}
}
}
} else {
$groups_by_term = wpcf_admin_fields_get_groups_by_term(false, true, $post_type);
if (!empty($groups_by_term)) {
foreach ($groups_by_term as $group) {
if (!isset($groups[$group['id']])) {
$groups[$group['id']] = $group;
$groups[$group['id']]['fields'] = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
}
$groups[$group['id']]['__wpcf_terms'] = 1;
}
}
}
// Get by post_type
$groups_by_post_type = wpcf_admin_get_groups_by_post_type($post_type, true, $distinct_terms);
if (!empty($groups_by_post_type)) {
foreach ($groups_by_post_type as $key => $group) {
if (!isset($groups[$group['id']])) {
$groups[$group['id']] = $group;
$groups[$group['id']]['fields'] = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
}
$groups[$group['id']]['__wpcf_types'] = 1;
}
}
// Get by template
if (empty($post)) {
$templates = array('_wp_page_template' => 'default');
} else {
$templates = array('_wp_page_template' => get_post_meta($post->ID, '_wp_page_template', true), '_views_template' => get_post_meta($post->ID, '_views_template', true));
}
$groups_by_template = wpcf_admin_get_groups_by_template($templates, false);
if (!empty($groups_by_template)) {
foreach ($groups_by_template as $key => $group) {
if (!isset($groups[$group['id']])) {
$groups[$group['id']] = $group;
$groups[$group['id']]['fields'] = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
}
$groups[$group['id']]['__wpcf_templates'] = 1;
}
}
foreach ($groups as $group_id => $group) {
if (!empty($group['filters_association'])) {
if ($group['filters_association'] == 'all' && (empty($group['__wpcf_templates']) || empty($group['__wpcf_terms']) || empty($group['__wpcf_types']))) {
unset($groups[$group_id]);
}
}
}
$groups = apply_filters('wpcf_post_groups', $groups, $post);
return $groups;
}
开发者ID:rdbartlett,项目名称:kellyspencer.co.nz,代码行数:101,代码来源:fields-post.php
示例8: wpcf_post_relationship_get_specific_fields_keys
/**
* Get allowed keys
*
* Function colect proper keys of all fields - built-in and CF's
*
* @since 1.9.0
*
* @param string $child post type slug
* @return array array of allowed slugs
*/
function wpcf_post_relationship_get_specific_fields_keys($child)
{
$options = array();
$groups = wpcf_admin_get_groups_by_post_type($child);
foreach ($groups as $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id']);
foreach ($fields as $key => $cf) {
$__key = wpcf_types_cf_under_control('check_outsider', $key) ? $key : WPCF_META_PREFIX . $key;
$options[$__key] = 1;
}
}
$supports = wpcf_post_relationship_get_supported_fields_by_post_type($child);
foreach ($supports as $child_field_key => $child_field_data) {
$options[$child_field_data['name']] = 1;
}
return $options;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:27,代码来源:post-relationship.php
示例9: wpcf_admin_post_get_post_groups_fields
/**
* Gets all groups and fields for post.
*
* @param type $post_ID
* @return type
*/
function wpcf_admin_post_get_post_groups_fields($post = false)
{
// Get post_type
if ($post) {
$post_type = get_post_type($post);
} else {
if (!isset($_GET['post_type'])) {
$post_type = 'post';
} else {
if (in_array($_GET['post_type'], get_post_types(array('show_ui' => true)))) {
$post_type = $_GET['post_type'];
} else {
return false;
}
}
}
$groups = array();
// Get by taxonomy
$distinct_terms = array();
if ($post) {
$taxonomies = get_taxonomies('', 'objects');
if (!empty($taxonomies)) {
foreach ($taxonomies as $tax_slug => $tax) {
$terms = wp_get_post_terms($post->ID, $tax_slug, array('fields' => 'ids'));
foreach ($terms as $term_id) {
$groups_by_term = wpcf_admin_fields_get_groups_by_term($term_id, true, $post_type);
if (!empty($groups_by_term)) {
foreach ($groups_by_term as $group) {
if (!isset($groups[$group['id']])) {
$groups[$group['id']] = $group;
$groups[$group['id']]['fields'] = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
}
$groups[$group['id']]['__wpcf_terms'] = 1;
}
}
$distinct_terms[] = $term_id;
}
}
// Fetch displayed on all
$groups_by_term = wpcf_admin_fields_get_groups_by_term(false, true, $post_type);
if (!empty($groups_by_term)) {
foreach ($groups_by_term as $group) {
if (!isset($groups[$group['id']])) {
$groups[$group['id']] = $group;
$groups[$group['id']]['fields'] = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
}
}
$groups[$group['id']]['__wpcf_terms'] = 1;
}
}
} else {
$groups_by_term = wpcf_admin_fields_get_groups_by_term(false, true, $post_type);
if (!empty($groups_by_term)) {
foreach ($groups_by_term as $group) {
if (!isset($groups[$group['id']])) {
$groups[$group['id']] = $group;
$groups[$group['id']]['fields'] = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
}
$groups[$group['id']]['__wpcf_terms'] = 1;
}
}
}
// Get by post_type
$groups_by_post_type = wpcf_admin_get_groups_by_post_type($post_type, true, $distinct_terms);
if (!empty($groups_by_post_type)) {
foreach ($groups_by_post_type as $key => $group) {
if (!isset($groups[$group['id']])) {
$groups[$group['id']] = $group;
$groups[$group['id']]['fields'] = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
}
$groups[$group['id']]['__wpcf_types'] = 1;
}
}
// Get by template
if (empty($post)) {
$templates = array('_wp_page_template' => 'default');
} else {
$templates = array('_wp_page_template' => get_post_meta($post->ID, '_wp_page_template', true), '_views_template' => get_post_meta($post->ID, '_views_template', true));
}
$groups_by_template = wpcf_admin_get_groups_by_template($templates, true);
if (!empty($groups_by_template)) {
foreach ($groups_by_template as $key => $group) {
if (!isset($groups[$group['id']])) {
$groups[$group['id']] = $group;
$groups[$group['id']]['fields'] = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
}
$groups[$group['id']]['__wpcf_templates'] = 1;
}
}
foreach ($groups as $group_id => $group) {
if (!empty($group['filters_association'])) {
if ($group['filters_association'] == 'all' && (empty($group['__wpcf_templates']) || empty($group['__wpcf_terms']) || empty($group['__wpcf_types']))) {
unset($groups[$group_id]);
}
//.........这里部分代码省略.........
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:101,代码来源:fields-post.php
注:本文中的wpcf_admin_get_groups_by_post_type函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论