本文整理汇总了PHP中wpcf_admin_fields_get_fields_by_group函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_fields_get_fields_by_group函数的具体用法?PHP wpcf_admin_fields_get_fields_by_group怎么用?PHP wpcf_admin_fields_get_fields_by_group使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_admin_fields_get_fields_by_group函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buddyforms_types_create_new_form_builder_form_element
function buddyforms_types_create_new_form_builder_form_element($form_fields, $form_slug, $field_type, $field_id)
{
global $field_position;
switch ($field_type) {
case 'wp-types':
//unset($form_fields);
$boom = wpcf_admin_fields_get_fields_by_group(258);
echo '<pre>';
print_r($boom);
echo '</pre>';
$form_fields['general']['html'] = new Element_HTML('Hallo');
break;
}
return $form_fields;
}
示例2: wpv_filters_add_filter_usermeta_field
static function wpv_filters_add_filter_usermeta_field($filters)
{
$basic = array(array(__('First Name', 'wpv-views'), 'first_name', 'Basic', ''), array(__('Last Name', 'wpv-views'), 'last_name', 'Basic', ''), array(__('Nickname', 'wpv-views'), 'nickname', 'Basic', ''), array(__('Description', 'wpv-views'), 'description', 'Basic', ''), array(__('Yahoo IM', 'wpv-views'), 'yim', 'Basic', ''), array(__('Jabber', 'wpv-views'), 'jabber', 'Basic', ''), array(__('AIM', 'wpv-views'), 'aim', 'Basic', ''));
foreach ($basic as $b_filter) {
$filters['usermeta-field-basic-' . str_replace(' ', '_', $b_filter[1])] = array('name' => sprintf(__('User field - %s', 'wpv-views'), $b_filter[0]), 'present' => 'usermeta-field-' . $b_filter[1] . '_compare', 'callback' => array('WPV_Usermeta_Field_Filter', 'wpv_add_new_filter_usermeta_field_list_item'), 'args' => array('name' => 'usermeta-field-' . $b_filter[1]), 'group' => __('User data', 'wpv-views'));
}
// @todo review this for gods sake!!!!!!!!!!!!!!!!!!!!!!!!
if (function_exists('wpcf_admin_fields_get_groups')) {
$groups = wpcf_admin_fields_get_groups('wp-types-user-group');
$user_id = wpcf_usermeta_get_user();
$add = array();
if (!empty($groups)) {
foreach ($groups as $group_id => $group) {
if (empty($group['is_active'])) {
continue;
}
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true, 'wp-types-user-group', 'wpcf-usermeta');
if (!empty($fields)) {
foreach ($fields as $field_id => $field) {
$add[] = $field['meta_key'];
$filters['usermeta-field-' . str_replace(' ', '_', $field['meta_key'])] = array('name' => sprintf(__('User field - %s', 'wpv-views'), $field['name']), 'present' => 'usermeta-field-' . $field['meta_key'] . '_compare', 'callback' => array('WPV_Usermeta_Field_Filter', 'wpv_add_new_filter_usermeta_field_list_item'), 'args' => array('name' => 'usermeta-field-' . $field['meta_key']));
}
}
}
}
$cf_types = wpcf_admin_fields_get_fields(true, true, false, 'wpcf-usermeta');
foreach ($cf_types as $cf_id => $cf) {
if (!in_array($cf['meta_key'], $add)) {
$filters['usermeta-field-' . str_replace(' ', '_', $cf['meta_key'])] = array('name' => sprintf(__('User field - %s', 'wpv-views'), $cf['name']), 'present' => 'usermeta-field-' . $cf['meta_key'] . '_compare', 'callback' => array('WPV_Usermeta_Field_Filter', 'wpv_add_new_filter_usermeta_field_list_item'), 'args' => array('name' => 'usermeta-field-' . $cf['meta_key']));
}
}
}
$meta_keys = get_user_meta_keys();
foreach ($meta_keys as $key) {
$key_nicename = '';
if (stripos($key, 'wpcf-') === 0) {
if (function_exists('wpcf_admin_fields_get_groups')) {
continue;
}
} else {
$key_nicename = $key;
}
$filters['usermeta-field-' . str_replace(' ', '_', $key)] = array('name' => sprintf(__('User field - %s', 'wpv-views'), $key_nicename), 'present' => 'usermeta-field-' . $key . '_compare', 'callback' => array('WPV_Usermeta_Field_Filter', 'wpv_add_new_filter_usermeta_field_list_item'), 'args' => array('name' => 'usermeta-field-' . $key));
}
return $filters;
}
示例3: editorDropdownFilter
/**
* Adds items to view dropdown.
*
* @param type $items
* @return type
*/
public static function editorDropdownFilter($items)
{
$post = wpcf_admin_get_edited_post();
if (empty($post)) {
$post = (object) array('ID' => -1);
}
$groups = wpcf_admin_fields_get_groups('wp-types-group', 'group_active');
$all_post_types = implode(' ', get_post_types(array('public' => true)));
$add = array();
if (!empty($groups)) {
// $group_id is blank therefore not equal to $group['id']
// use array for item key and CSS class
$item_styles = array();
foreach ($groups as $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
if (!empty($fields)) {
// code from Types used here without breaking the flow
// get post types list for every group or apply all
$post_types = get_post_meta($group['id'], '_wp_types_group_post_types', true);
if ($post_types == 'all') {
$post_types = $all_post_types;
}
$post_types = trim(str_replace(',', ' ', $post_types));
$item_styles[$group['name']] = $post_types;
foreach ($fields as $field) {
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $post->ID . ')';
$add[$group['name']][stripslashes($field['name'])] = array(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
// TODO Remove - it's not post edit screen (meta box JS and CSS)
WPCF_Fields::enqueueScript($field['type']);
WPCF_Fields::enqueueStyle($field['type']);
}
}
}
}
$search_key = '';
// Iterate all items to be displayed in the "V" menu
foreach ($items as $key => $item) {
if ($key == __('Basic', 'wpv-views')) {
$search_key = 'found';
continue;
}
if ($search_key == 'found') {
$search_key = $key;
}
if ($key == __('Field', 'wpv-views') && isset($item[trim(wpcf_types_get_meta_prefix(), '-')])) {
unset($items[$key][trim(wpcf_types_get_meta_prefix(), '-')]);
}
}
if (empty($search_key) || $search_key == 'found') {
$search_key = count($items);
}
$insert_position = array_search($search_key, array_keys($items));
$part_one = array_slice($items, 0, $insert_position);
$part_two = array_slice($items, $insert_position);
$items = $part_one + $add + $part_two;
// apply CSS styles to each item based on post types
foreach ($items as $key => $value) {
if (isset($item_styles[$key])) {
$items[$key]['css'] = $item_styles[$key];
} else {
$items[$key]['css'] = $all_post_types;
}
}
return $items;
}
示例4: wpcf_admin_post_editor_addon_menus_filter
/**
* Adds items to view dropdown.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @todo Remove (to WPCF_WPViews)
*
* @param type $menu
* @return type
*/
function wpcf_admin_post_editor_addon_menus_filter($menu)
{
global $wpcf;
$post = wpcf_admin_get_edited_post();
if (empty($post)) {
$post = (object) array('ID' => -1);
}
$groups = wpcf_admin_fields_get_groups('wp-types-group', 'group_active');
$all_post_types = implode(' ', get_post_types(array('public' => true)));
$add = array();
if (!empty($groups)) {
// $group_id is blank therefore not equal to $group['id']
// use array for item key and CSS class
$item_styles = array();
foreach ($groups as $group_id => $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
if (!empty($fields)) {
// code from Types used here without breaking the flow
// get post types list for every group or apply all
$post_types = get_post_meta($group['id'], '_wp_types_group_post_types', true);
if ($post_types == 'all') {
$post_types = $all_post_types;
}
$post_types = trim(str_replace(',', ' ', $post_types));
$item_styles[$group['name']] = $post_types;
foreach ($fields as $field_id => $field) {
// Use field class
$wpcf->field->set($wpcf->post, $field);
// Get field data
$data = (array) $wpcf->field->config;
// Get inherited field
if (isset($data['inherited_field_type'])) {
$inherited_field_data = wpcf_fields_type_action($data['inherited_field_type']);
}
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $post->ID . ')';
$menu[$group['name']][stripslashes($field['name'])] = array(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
/*
* Since Types 1.2
* We use field class to enqueue JS and CSS
*/
$wpcf->field->enqueue_script();
$wpcf->field->enqueue_style();
}
}
}
}
/*
$search_key = '';
// Iterate all items to be displayed in the "V" menu
foreach ( $items as $key => $item ) {
if ( $key == __( 'Basic', 'wpv-views' ) ) {
$search_key = 'found';
continue;
}
if ( $search_key == 'found' ) {
$search_key = $key;
}
if ( $key == __( 'Field', 'wpv-views' ) && isset( $item[trim( wpcf_types_get_meta_prefix(),
'-' )] ) ) {
unset( $items[$key][trim( wpcf_types_get_meta_prefix(), '-' )] );
}
}
if ( empty( $search_key ) || $search_key == 'found' ) {
$search_key = count( $items );
}
$insert_position = array_search( $search_key, array_keys( $items ) );
$part_one = array_slice( $items, 0, $insert_position );
$part_two = array_slice( $items, $insert_position );
$items = $part_one + $add + $part_two;
// apply CSS styles to each item based on post types
foreach ( $items as $key => $value ) {
if ( isset( $item_styles[$key] ) ) {
$items[$key]['css'] = $item_styles[$key];
} else {
$items[$key]['css'] = $all_post_types;
}
}
*/
return $menu;
}
示例5: wpcf_admin_usermeta_get_groups_fields
/**
* Gets all groups and fields for post.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @param type $post_ID
* @return type
*/
function wpcf_admin_usermeta_get_groups_fields()
{
wpcf_enqueue_scripts();
$post = array();
// Filter groups
$groups = array();
$groups_all = wpcf_admin_fields_get_groups(TYPES_USER_META_FIELD_GROUP_CPT_NAME);
foreach ($groups_all as $temp_key => $temp_group) {
if (empty($temp_group['is_active'])) {
unset($groups_all[$temp_key]);
continue;
}
$passed = 1;
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, TYPES_USER_META_FIELD_GROUP_CPT_NAME, 'wpcf-usermeta');
}
}
$groups = $groups_all;
return $groups;
}
示例6: wpcf_admin_usermeta_form
/**
* Generates form data.
*/
function wpcf_admin_usermeta_form()
{
global $wpcf;
wpcf_admin_add_js_settings('wpcf_nonce_toggle_group', '\'' . wp_create_nonce('group_form_collapsed') . '\'');
wpcf_admin_add_js_settings('wpcf_nonce_toggle_fieldset', '\'' . wp_create_nonce('form_fieldset_toggle') . '\'');
$default = array();
global $wpcf_button_style;
global $wpcf_button_style30;
// If it's update, get data
$update = false;
if (isset($_REQUEST['group_id'])) {
$update = wpcf_admin_fields_get_group(intval($_REQUEST['group_id']), 'wp-types-user-group');
if (empty($update)) {
$update = false;
wpcf_admin_message(sprintf(__("Group with ID %d do not exist", 'wpcf'), intval($_REQUEST['group_id'])));
} else {
$update['fields'] = wpcf_admin_fields_get_fields_by_group($_REQUEST['group_id'], 'slug', false, true, false, 'wp-types-user-group', 'wpcf-usermeta');
$update['show_for'] = wpcf_admin_get_groups_showfor_by_group($_REQUEST['group_id']);
$update['admin_styles'] = wpcf_admin_get_groups_admin_styles_by_group($_REQUEST['group_id']);
}
}
$form = array();
$form['#form']['callback'] = array('wpcf_admin_save_usermeta_groups_submit');
// Form sidebars
$form['open-sidebar'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-form-fields-align-right">');
// Set help icon
$form['help-icon'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-admin-fields-help"><img src="' . WPCF_EMBEDDED_RELPATH . '/common/res/images/question.png" style="position:relative;top:2px;" /> <a href="http://wp-types.com/documentation/user-guides/using-custom-fields/" target="_blank">' . __('Usermeta help', 'wpcf') . '</a></div>');
$form['submit2'] = array('#type' => 'submit', '#name' => 'save', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'));
$form['fields'] = array('#type' => 'fieldset', '#title' => __('Available fields', 'wpcf'));
// Get field types
$fields_registered = wpcf_admin_fields_get_available_types();
foreach ($fields_registered as $filename => $data) {
$form['fields'][basename($filename, '.php')] = array('#type' => 'markup', '#markup' => '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax&wpcf_action=fields_insert' . '&field=' . basename($filename, '.php') . '&page=wpcf-edit-usermeta') . '&_wpnonce=' . wp_create_nonce('fields_insert') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary">' . $data['title'] . '</a> ');
// Process JS
if (!empty($data['group_form_js'])) {
foreach ($data['group_form_js'] as $handle => $script) {
if (isset($script['inline'])) {
add_action('admin_footer', $script['inline']);
continue;
}
$deps = !empty($script['deps']) ? $script['deps'] : array();
$in_footer = !empty($script['in_footer']) ? $script['in_footer'] : false;
wp_register_script($handle, $script['src'], $deps, WPCF_VERSION, $in_footer);
wp_enqueue_script($handle);
}
}
// Process CSS
if (!empty($data['group_form_css'])) {
foreach ($data['group_form_css'] as $handle => $script) {
if (isset($script['src'])) {
$deps = !empty($script['deps']) ? $script['deps'] : array();
wp_enqueue_style($handle, $script['src'], $deps, WPCF_VERSION);
} else {
if (isset($script['inline'])) {
add_action('admin_head', $script['inline']);
}
}
}
}
}
// Get fields created by user
$fields = wpcf_admin_fields_get_fields(true, true, false, 'wpcf-usermeta');
if (!empty($fields)) {
$form['fields-existing'] = array('#type' => 'fieldset', '#title' => __('User created fields', 'wpcf'), '#id' => 'wpcf-form-groups-user-fields');
foreach ($fields as $key => $field) {
if (isset($update['fields']) && array_key_exists($key, $update['fields'])) {
continue;
}
if (!empty($field['data']['removed_from_history'])) {
continue;
}
$form['fields-existing'][$key] = array('#type' => 'markup', '#markup' => '<div id="wpcf-user-created-fields-wrapper-' . $field['id'] . '" style="float:left; margin-right: 10px;"><a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&page=wpcf-edit' . '&wpcf_action=usermeta_insert_existing' . '&field=' . $field['id']) . '&_wpnonce=' . wp_create_nonce('usermeta_insert_existing') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary" onclick="jQuery(this).parent().fadeOut();" ' . 'data-slug="' . $field['id'] . '">' . htmlspecialchars(stripslashes($field['name'])) . '</a>' . '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&wpcf_action=remove_from_history2' . '&field_id=' . $field['id']) . '&_wpnonce=' . wp_create_nonce('remove_from_history2') . '&wpcf_warning=' . sprintf(__('Are you sure that you want to remove field %s from history?', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '&wpcf_ajax_update=wpcf-user-created-fields-wrapper-' . $field['id'] . '" title="' . sprintf(__('Remove field %s', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '" class="wpcf-ajax-link"><img src="' . WPCF_RES_RELPATH . '/images/delete-2.png" style="postion:absolute;margin-top:5px;margin-left:-4px;" /></a></div>');
}
}
$form['close-sidebar'] = array('#type' => 'markup', '#markup' => '</div>');
// Group data
$form['open-main'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-form-fields-main">');
$form['title'] = array('#type' => 'textfield', '#name' => 'wpcf[group][name]', '#id' => 'wpcf-group-name', '#value' => $update ? $update['name'] : __('Enter group title', 'wpcf'), '#inline' => true, '#attributes' => array('style' => 'width:100%;margin-bottom:10px;'), '#validate' => array('required' => array('value' => true)));
if (!$update) {
$form['title']['#attributes']['data-label'] = addcslashes(__('Enter group title', 'wpcf'), '"');
$form['title']['#attributes']['onfocus'] = 'if (jQuery(this).val() == jQuery(this).data(\'label\')) { jQuery(this).val(\'\'); }';
$form['title']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(jQuery(this).data(\'label\')) }';
}
$form['description'] = array('#type' => 'textarea', '#id' => 'wpcf-group-description', '#name' => 'wpcf[group][description]', '#value' => $update ? $update['description'] : __('Enter a description for this group', 'wpcf'));
if (!$update) {
$form['description']['#attributes']['data-label'] = addcslashes(__('Enter a description for this group', 'wpcf'), '"');
$form['description']['#attributes']['onfocus'] = 'if (jQuery(this).val() == jQuery(this).data(\'label\')) { jQuery(this).val(\'\'); }';
$form['description']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(jQuery(this).data(\'label\')) }';
}
// Show Fields for
global $wp_roles;
$options = array();
$users_currently_supported = array();
$form_types = array();
foreach ($wp_roles->role_names as $role => $name) {
$options[$role]['#name'] = 'wpcf[group][supports][' . $role . ']';
$options[$role]['#title'] = ucwords($role);
//.........这里部分代码省略.........
示例7: wpcf_admin_post_add_usermeta_to_editor_js
/**
* Add User Fields to editor
*
* @author Gen gen.i@icanlocalize.com
* @since Types 1.3
*/
function wpcf_admin_post_add_usermeta_to_editor_js($menu, $views_callback = false)
{
global $wpcf;
$post = apply_filters('wpcf_filter_wpcf_admin_get_current_edited_post', null);
if (!$post) {
$post = (object) array('ID' => -1);
}
$groups = wpcf_admin_fields_get_groups(TYPES_USER_META_FIELD_GROUP_CPT_NAME);
$user_id = wpcf_usermeta_get_user();
if (!empty($groups)) {
$item_styles = array();
foreach ($groups as $group_id => $group) {
if (empty($group['is_active'])) {
continue;
}
$group_name = sprintf(__('%s (Usermeta fields)', 'wpcf'), $group['name']);
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true, TYPES_USER_META_FIELD_GROUP_CPT_NAME, 'wpcf-usermeta');
if (!empty($fields)) {
foreach ($fields as $field_id => $field) {
// Use field class
$wpcf->usermeta_field->set($user_id, $field);
// Get field data
$data = (array) $wpcf->usermeta_field->config;
// Get inherited field
if (isset($data['inherited_field_type'])) {
$inherited_field_data = wpcf_fields_type_action($data['inherited_field_type']);
}
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'usermeta\', ' . $post->ID . ')';
// Added for Views:users filter Vicon popup
if ($views_callback) {
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'views-usermeta\', ' . $post->ID . ')';
}
$menu[$group_name][stripslashes($field['name'])] = array(stripslashes(wp_kses_post($field['name'])), trim(wpcf_usermeta_get_shortcode($field), '[]'), $group_name, $callback);
}
/*
* Since Types 1.2
* We use field class to enqueue JS and CSS
*/
$wpcf->usermeta_field->enqueue_script();
$wpcf->usermeta_field->enqueue_style();
}
}
}
return $menu;
}
示例8: 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();
//.........这里部分代码省略.........
示例9: editorDropdownFilter
/**
* Adds items to view dropdown.
*
* @param type $items
* @return type
*/
public static function editorDropdownFilter($menu)
{
$post = wpcf_admin_get_edited_post();
if (empty($post)) {
$post = (object) array('ID' => -1);
}
$groups = wpcf_admin_fields_get_groups('wp-types-group', 'group_active');
$all_post_types = implode(' ', get_post_types(array('public' => true)));
$add = array();
if (!empty($groups)) {
// $group_id is blank therefore not equal to $group['id']
// use array for item key and CSS class
$item_styles = array();
foreach ($groups as $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
if (!empty($fields)) {
// code from Types used here without breaking the flow
// get post types list for every group or apply all
$post_types = get_post_meta($group['id'], '_wp_types_group_post_types', true);
if ($post_types == 'all') {
$post_types = $all_post_types;
}
$post_types = trim(str_replace(',', ' ', $post_types));
$item_styles[$group['name']] = $post_types;
foreach ($fields as $field) {
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $post->ID . ')';
$menu[$group['name']][stripslashes($field['name'])] = array(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
// TODO Remove - it's not post edit screen (meta box JS and CSS)
WPCF_Fields::enqueueScript($field['type']);
WPCF_Fields::enqueueStyle($field['type']);
}
}
}
}
return $menu;
}
示例10: wpcf_admin_post_editor_addon_menus_filter
/**
* Adds items to view dropdown.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @todo Remove (to WPCF_WPViews)
*
* @param type $menu
* @return type
*/
function wpcf_admin_post_editor_addon_menus_filter($menu)
{
global $wpcf;
$post = wpcf_admin_get_edited_post();
if (empty($post)) {
$post = (object) array('ID' => -1);
}
$groups = wpcf_admin_fields_get_groups(TYPES_CUSTOM_FIELD_GROUP_CPT_NAME, 'group_active');
$all_post_types = implode(' ', get_post_types(array('public' => true)));
$add = array();
if (!empty($groups)) {
// $group_id is blank therefore not equal to $group['id']
// use array for item key and CSS class
$item_styles = array();
foreach ($groups as $group_id => $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
if (!empty($fields)) {
// code from Types used here without breaking the flow
// get post types list for every group or apply all
$post_types = get_post_meta($group['id'], '_wp_types_group_post_types', true);
if ($post_types == 'all') {
$post_types = $all_post_types;
}
$post_types = trim(str_replace(',', ' ', $post_types));
$item_styles[$group['name']] = $post_types;
foreach ($fields as $field_id => $field) {
// Use field class
$wpcf->field->set($wpcf->post, $field);
// Get field data
$data = (array) $wpcf->field->config;
// Get inherited field
if (isset($data['inherited_field_type'])) {
$inherited_field_data = wpcf_fields_type_action($data['inherited_field_type']);
}
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $post->ID . ')';
$menu[$group['name']][stripslashes($field['name'])] = array(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
/*
* Since Types 1.2
* We use field class to enqueue JS and CSS
*/
$wpcf->field->enqueue_script();
$wpcf->field->enqueue_style();
}
}
}
}
return $menu;
}
示例11: wpcf_admin_post_editor_addon_menus_filter
/**
* Adds items to view dropdown.
*
* @param type $items
* @return type
*/
function wpcf_admin_post_editor_addon_menus_filter($items)
{
$groups = wpcf_admin_fields_get_groups();
$add = array();
if (!empty($groups)) {
foreach ($groups as $group_id => $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
if (!empty($fields)) {
foreach ($fields as $field_id => $field) {
// Get field data
$data = wpcf_fields_type_action($field['type']);
// Get inherited field
if (isset($data['inherited_field_type'])) {
$inherited_field_data = wpcf_fields_type_action($data['inherited_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'] . '\')' : '';
}
$add[$group['name']][stripslashes($field['name'])] = array(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
// Process JS
if (!empty($data['meta_box_js'])) {
foreach ($data['meta_box_js'] as $handle => $data_script) {
if (isset($data_script['inline'])) {
add_action('admin_footer', $data_script['inline']);
continue;
}
$deps = !empty($data_script['deps']) ? $data_script['deps'] : array();
wp_enqueue_script($handle, $data_script['src'], $deps, WPCF_VERSION);
}
}
// Process CSS
if (!empty($data['meta_box_css'])) {
foreach ($data['meta_box_css'] as $handle => $data_script) {
$deps = !empty($data_script['deps']) ? $data_script['deps'] : array();
if (isset($data_script['inline'])) {
add_action('admin_header', $data_script['inline']);
continue;
}
wp_enqueue_style($handle, $data_script['src'], $deps, WPCF_VERSION);
}
}
}
}
}
}
$search_key = '';
foreach ($items as $key => $item) {
if ($key == __('Basic', 'wpv-views')) {
$search_key = 'found';
continue;
}
if ($search_key == 'found') {
$search_key = $key;
}
if ($key == __('Field', 'wpv-views') && isset($item[trim(wpcf_types_get_meta_prefix(), '-')])) {
unset($items[$key][trim(wpcf_types_get_meta_prefix(), '-')]);
}
}
if (empty($search_key) || $search_key == 'found') {
$search_key = count($items);
}
$insert_position = array_search($search_key, array_keys($items));
$part_one = array_slice($items, 0, $insert_position);
$part_two = array_slice($items, $insert_position);
$items = $part_one + $add + $part_two;
return $items;
}
示例12: wpcf_admin_post_editor_addon_menus_filter
/**
* Adds items to view dropdown.
*
* @param type $items
* @return type
*/
function wpcf_admin_post_editor_addon_menus_filter($items)
{
$groups = wpcf_admin_fields_get_groups();
$add = array();
if (!empty($groups)) {
// $group_id is blank therefore not equal to $group['id']
// use array for item key and CSS class
$item_styles = array();
$all_post_types = implode(' ', get_post_types(array('public' => true)));
foreach ($groups as $group_id => $group) {
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true);
if (!empty($fields)) {
// code from Types used here without breaking the flow
// get post types list for every group or apply all
$post_types = get_post_meta($group['id'], '_wp_types_group_post_types', true);
if ($post_types == 'all') {
$post_types = $all_post_types;
}
$post_types = trim(str_replace(',', ' ', $post_types));
$item_styles[$group['name']] = $post_types;
foreach ($fields as $field_id => $field) {
// Get field data
$data = wpcf_fields_type_action($field['type']);
// Get inherited field
if (isset($data['inherited_field_type'])) {
$inherited_field_data = wpcf_fields_type_action($data['inherited_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'] . '\')' : '';
}
$add[$group['name']][stripslashes($field['name'])] = array(stripslashes($field['name']), trim(wpcf_fields_get_shortcode($field), '[]'), $group['name'], $callback);
// Process JS
if (!empty($data['meta_box_js'])) {
foreach ($data['meta_box_js'] as $handle => $data_script) {
if (isset($data_script['inline'])) {
add_action('admin_footer', $data_script['inline']);
continue;
}
$deps = !empty($data_script['deps']) ? $data_script['deps'] : array();
wp_enqueue_script($handle, $data_script['src'], $deps, WPCF_VERSION);
}
}
// Process CSS
if (!empty($data['meta_box_css'])) {
foreach ($data['meta_box_css'] as $handle => $data_script) {
$deps = !empty($data_script['deps']) ? $data_script['deps'] : array();
if (isset($data_script['inline'])) {
add_action('admin_header', $data_script['inline']);
continue;
}
wp_enqueue_style($handle, $data_script['src'], $deps, WPCF_VERSION);
}
}
}
}
}
}
$search_key = '';
// Iterate all items to be displayed in the "V" menu
foreach ($items as $key => $item) {
if ($key == __('Basic', 'wpv-views')) {
$search_key = 'found';
continue;
}
if ($search_key == 'found') {
$search_key = $key;
}
if ($key == __('Field', 'wpv-views') && isset($item[trim(wpcf_types_get_meta_prefix(), '-')])) {
unset($items[$key][trim(wpcf_types_get_meta_prefix(), '-')]);
}
}
if (empty($search_key) || $search_key == 'found') {
$search_key = count($items);
}
$insert_position = array_search($search_key, array_keys($items));
$part_one = array_slice($items, 0, $insert_position);
$part_two = array_slice($items, $insert_position);
$items = $part_one + $add + $part_two;
// apply CSS styles to each item based on post types
foreach ($items as $key => $value) {
if (isset($item_styles[$key])) {
$items[$key]['css'] = $item_styles[$key];
} else {
$items[$key]['css'] = $all_post_types;
}
}
return $items;
}
示例13: 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;
}
示例14: add_users_form_button
/**
* Adding a "V" button to the menu (for user fields)
* @param string $context
* @param string $text_area
* @param boolean $standard_v is this a standard V button
*/
function add_users_form_button($context, $text_area = 'textarea#content', $codemirror_button = false)
{
global $wp_version, $sitepress, $wpdb, $WP_Views;
$standard_v = true;
// WP 3.3 changes ($context arg is actually a editor ID now)
if (version_compare($wp_version, '3.1.4', '>') && !empty($context)) {
$text_area = $context;
}
//print_r($this->items);exit;
$this->items = array();
$unused_field = array('comment_shortcuts', 'managenav-menuscolumnshidden', 'dismissed_wp_pointers', 'meta-box-order_dashboard', 'nav_menu_recently_edited', 'primary_blog', 'rich_editing', 'source_domain', 'use_ssl', 'user_level', 'user-settings-time', 'user-settings', 'dashboard_quick_press_last_post_id', 'capabilities', 'new_date', 'show_admin_bar_front', 'show_welcome_panel', 'show_highlight', 'admin_color', 'language_pairs', 'first_name', 'last_name', 'name', 'nickname', 'description', 'yim', 'jabber', 'aim');
$exclude_these_hidden_var = '/(' . implode('|', $unused_field) . ')/';
$this->items = array(array(__('User ID', 'wpv-views'), 'wpv-user field="ID"', __('Basic', 'wpv-views'), ''), array(__('User Email', 'wpv-views'), 'wpv-user field="user_email"', __('Basic', 'wpv-views'), ''), array(__('User Login', 'wpv-views'), 'wpv-user field="user_login"', __('Basic', 'wpv-views'), ''), array(__('First Name', 'wpv-views'), 'wpv-user field="user_firstname"', __('Basic', 'wpv-views'), ''), array(__('Last Name', 'wpv-views'), 'wpv-user field="user_lastname"', __('Basic', 'wpv-views'), ''), array(__('Nickname', 'wpv-views'), 'wpv-user field="nickname"', __('Basic', 'wpv-views'), ''), array(__('Display Name', 'wpv-views'), 'wpv-user field="display_name"', __('Basic', 'wpv-views'), ''), array(__('Description', 'wpv-views'), 'wpv-user field="description"', __('Basic', 'wpv-views'), ''), array(__('Yahoo IM', 'wpv-views'), 'wpv-user field="yim"', __('Basic', 'wpv-views'), ''), array(__('Jabber', 'wpv-views'), 'wpv-user field="jabber"', __('Basic', 'wpv-views'), ''), array(__('AIM', 'wpv-views'), 'wpv-user field="aim"', __('Basic', 'wpv-views'), ''), array(__('User Url', 'wpv-views'), 'wpv-user field="user_url"', __('Basic', 'wpv-views'), ''), array(__('Registration Date', 'wpv-views'), 'wpv-user field="user_registered"', __('Basic', 'wpv-views'), ''), array(__('User Status', 'wpv-views'), 'wpv-user field="user_status"', __('Basic', 'wpv-views'), ''), array(__('User Spam Status', 'wpv-views'), 'wpv-user field="spam"', __('Basic', 'wpv-views'), ''));
if (isset($sitepress) && function_exists('wpml_string_shortcode')) {
$this->items[] = array(__('Translatable string', 'wpv-views'), 'wpml-string', __('Basic', 'wpv-views'), 'wpv_insert_translatable_string_popup()');
}
$meta_keys = get_user_meta_keys();
$all_types_fields = get_option('wpcf-fields', array());
foreach ($meta_keys as $key) {
$key_nicename = '';
if (function_exists('wpcf_init')) {
if (stripos($key, 'wpcf-') === 0) {
//
} else {
if (preg_match($exclude_these_hidden_var, $key)) {
continue;
}
$this->items[] = array($key, 'wpv-user field="' . $key . '"', __('Users fields', 'wpv-views'), '');
}
} else {
if (preg_match($exclude_these_hidden_var, $key)) {
continue;
}
$this->items[] = array($key, 'wpv-user field="' . $key . '"', __('User fields', 'wpv-views'), '');
}
}
if (function_exists('wpcf_init')) {
//Get types groups and fields
$groups = wpcf_admin_fields_get_groups('wp-types-user-group');
$user_id = wpcf_usermeta_get_user();
$add = array();
if (!empty($groups)) {
foreach ($groups as $group_id => $group) {
if (empty($group['is_active'])) {
continue;
}
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true, 'wp-types-user-group', 'wpcf-usermeta');
if (!empty($fields)) {
foreach ($fields as $field_id => $field) {
$add[] = $field['meta_key'];
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'views-usermeta\', -1)';
$this->items[] = array($field['name'], 'types usermeta="' . $field['meta_key'] . '"][/types', $group['name'], $callback);
}
}
}
}
//Get unused types fields
$cf_types = wpcf_admin_fields_get_fields(true, true, false, 'wpcf-usermeta');
foreach ($cf_types as $cf_id => $cf) {
if (!in_array($cf['meta_key'], $add)) {
$callback = 'wpcfFieldsEditorCallback(\'' . $cf['id'] . '\', \'views-usermeta\', -1)';
$this->items[] = array($cf['name'], 'types usermeta="' . $cf['meta_key'] . '"][/types', __('Types fields', 'wpv-views'), $callback);
}
}
}
$view_available = $wpdb->get_results("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type='view' AND post_status in ('publish')");
foreach ($view_available as $view) {
$view_settings = get_post_meta($view->ID, '_wpv_settings', true);
if (isset($view_settings['query_type'][0]) && $view_settings['query_type'][0] == 'posts' && !$WP_Views->is_archive_view($view->ID)) {
$this->items[] = array($view->post_title, $view->post_title, __('Post View', 'wpv-views'), '');
}
}
$out = array();
$menus = array();
$sub_menus = array();
if ($this->items) {
foreach ($this->items as $item) {
$parts = explode('-!-', $item[2]);
$menu_level =& $menus;
foreach ($parts as $part) {
if ($part != '') {
if (!array_key_exists($part, $menu_level)) {
$menu_level[$part] = array();
}
$menu_level =& $menu_level[$part];
}
}
$menu_level[$item[0]] = $item;
}
}
// Sort menus
if (is_array($menus)) {
$menus = $this->sort_menus_alphabetically($menus);
}
//.........这里部分代码省略.........
示例15: wpcf_admin_fields_get_groups_by_field
/**
* Gets all groups that contain specified field.
*
* @static $cache
* @param type $field_id
*/
function wpcf_admin_fields_get_groups_by_field($field_id, $post_type = 'wp-types-group')
{
static $cache = array();
$groups = wpcf_admin_fields_get_groups($post_type);
$meta_name = $post_type == 'wp-types-group' ? 'wpcf-fields' : 'wpcf-usermeta';
$return = array();
foreach ($groups as $group_id => $group) {
if (isset($cache['groups'][$group_id])) {
$fields = $cache['groups'][$group_id];
} else {
$fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', false, false, false, $post_type, $meta_name);
}
if (array_key_exists($field_id, $fields)) {
$return[$group['id']] = $group;
}
$cache['groups'][$group_id] = $fields;
}
return $return;
}