本文整理汇总了PHP中wpcf_usermeta_get_user函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_usermeta_get_user函数的具体用法?PHP wpcf_usermeta_get_user怎么用?PHP wpcf_usermeta_get_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_usermeta_get_user函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: wpcf_fields_embed_editor_callback
/**
* Editor callback form.
*/
function wpcf_fields_embed_editor_callback($field, $data, $meta_type, $post)
{
// Get attachment
$attachment_id = false;
if (!empty($post->ID)) {
$file = get_post_meta($post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
if (empty($file)) {
$user_id = wpcf_usermeta_get_user();
$file = get_user_meta($user_id, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
}
if (!empty($file)) {
// Get attachment by guid
global $wpdb;
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}\n WHERE post_type = 'attachment' AND guid=%s", $file));
}
}
// Set data
$data['attachment_id'] = $attachment_id;
$data['file'] = !empty($file) ? $file : '';
return array('supports' => array(), 'tabs' => array('display' => array('menu_title' => __('Display', 'wpcf'), 'title' => __('Display', 'wpcf'), 'content' => WPCF_Loader::template('editor-modal-embed', $data))), 'settings' => $data);
}
示例3: wpcf_ajax_embedded
//.........这里部分代码省略.........
) );
} else {
echo json_encode( array(
'output' => $output,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;*/
/* Usermeta */
// Not used anywhere
/*case 'pr_sort_parent':
$output = 'Passed wrong parameters';
if ( isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
$output = $wpcf->relationship->child_meta_form(
intval( $_GET['post_id'] ), strval( $_GET['post_type'] )
);
}
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
echo json_encode( array(
'output' => $output,
) );
} else {
echo json_encode( array(
'output' => $output,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;*/
/* Usermeta */
case 'um_repetitive_add':
if (isset($_GET['user_id'])) {
$user_id = (int) $_GET['user_id'];
} else {
$user_id = wpcf_usermeta_get_user();
}
if (isset($_GET['field_id']) && current_user_can('edit_user', $user_id)) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
$field = wpcf_admin_fields_get_field(sanitize_text_field($_GET['field_id']), false, false, false, 'wpcf-usermeta');
global $wpcf;
$wpcf->usermeta_repeater->set($user_id, $field);
/*
*
* Force empty values!
*/
$wpcf->usermeta_repeater->cf['value'] = null;
$wpcf->usermeta_repeater->meta = null;
$form = $wpcf->usermeta_repeater->get_field_form(null, true);
echo json_encode(array('output' => wpcf_form_simple($form) . wpcf_form_render_js_validation('#your-profile', false)));
} else {
echo json_encode(array('output' => 'params missing'));
}
break;
case 'um_repetitive_delete':
if (isset($_POST['user_id']) && isset($_POST['field_id']) && current_user_can('edit_user', intval($_POST['user_id']))) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
$user_id = intval($_POST['user_id']);
$field = wpcf_admin_fields_get_field(sanitize_text_field($_POST['field_id']), false, false, false, 'wpcf-usermeta');
$meta_id = intval($_POST['meta_id']);
if (!empty($field) && !empty($user_id) && !empty($meta_id)) {
/*
*
*
* Changed.
* Since Types 1.2
示例4: wpcf_fields_image_editor_callback
/**
* Editor callback form.
*
* @global object $wpdb
*
*/
function wpcf_fields_image_editor_callback($field, $data, $context, $post)
{
// Get post_ID
$post_ID = !empty($post->ID) ? $post->ID : false;
// Get attachment
$image = false;
$attachment_id = false;
if ($post_ID) {
$image = get_post_meta($post_ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
if (empty($image)) {
$user_id = wpcf_usermeta_get_user();
$image = get_user_meta($user_id, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
}
if (!empty($image)) {
// Get attachment by guid
global $wpdb;
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s", $image));
}
}
$data['image'] = $image;
$data['attachment_id'] = $attachment_id;
// Set post type
$post_type = !empty($post->post_type) ? $post->post_type : '';
// Set image_data
$image_data = wpcf_fields_image_get_data($image);
if (!in_array($post_type, array('view', 'view-template'))) {
// We must ignore errors here and treat image as outsider
if (!empty($image_data['error'])) {
$image_data['is_outsider'] = 1;
$image_data['is_attachment'] = 0;
}
} else {
if (!empty($image_data['error'])) {
$image_data['is_outsider'] = 0;
$image_data['is_attachment'] = 0;
}
}
$data['preview'] = $attachment_id ? wp_get_attachment_image($attachment_id, 'thumbnail') : '';
// Title and Alt
if ($attachment_id) {
$alt = trim(strip_tags(get_post_meta($attachment_id, '_wp_attachment_image_alt', true)));
$attachment_post = get_post($attachment_id);
if (!empty($attachment_post)) {
$title = trim(strip_tags($attachment_post->post_title));
} else {
if (!empty($alt)) {
$title = $alt;
}
}
if (empty($alt)) {
$alt = $title;
}
if (!isset($data['title'])) {
$data['title'] = $title;
}
if (!isset($data['alt'])) {
$data['alt'] = $alt;
}
}
// Align options
$data['alignment_options'] = array('none' => __('None', 'wpcf'), 'left' => __('Left', 'wpcf'), 'center' => __('Center', 'wpcf'), 'right' => __('Right', 'wpcf'));
// Remote images settings
$fetch_remote = (bool) wpcf_get_settings('images_remote');
$data['warning_remote'] = false;
if (!types_is_repetitive($field) && $image_data['is_outsider'] && !$fetch_remote && !empty($data['image'])) {
$data['warning_remote'] = true;
}
// Size settings
$data['size_options'] = array('thumbnail' => sprintf(__('Thumbnail - %s', 'wpcf'), get_option('thumbnail_size_w') . 'x' . get_option('thumbnail_size_h')), 'medium' => sprintf(__('Medium - %s', 'wpcf'), get_option('medium_size_w') . 'x' . get_option('medium_size_h')), 'large' => sprintf(__('Large - %s', 'wpcf'), get_option('large_size_w') . 'x' . get_option('large_size_h')), 'full' => __('Original image', 'wpcf'));
$wp_image_sizes = (array) get_intermediate_image_sizes();
foreach ($wp_image_sizes as $wp_size) {
if ($wp_size != 'post-thumbnail' && !array_key_exists($wp_size, $data['size_options'])) {
$data['size_options'][$wp_size] = $wp_size;
}
}
$data['size_options']['wpcf-custom'] = __('Custom size...', 'wpcf');
// Get saved settings
$data = array_merge(wpcf_admin_fields_get_field_last_settings($field['id']), $data);
return array('supports' => array('styling', 'style'), 'tabs' => array('display' => array('menu_title' => __('Display options', 'wpcf'), 'title' => __('Display options for this field:', 'wpcf'), 'content' => WPCF_Loader::template('editor-modal-image', $data))), 'settings' => $data);
}
示例5: wpcf_admin_usermeta_form
//.........这里部分代码省略.........
/*
*
* Here we use unique function for all filters
* Since Types 1.1.4
*/
$form_users = _wpcf_filter_wrap('custom_post_types', __('Show For:', 'wpcf'), implode(', ', $users_currently_supported), __('Displayed for all users roles', 'wpcf'), $temp);
/*
* Now starting form
*/
$access_notification = '';
if (function_exists('wpcf_access_register_caps')) {
$access_notification = '<div class="message custom wpcf-notif"><span class="wpcf-notif-congrats">' . __('This groups visibility is also controlled by the Access plugin.', 'wpcf') . '</span></div>';
}
$form['supports-table-open'] = array('#type' => 'markup', '#markup' => '<table class="widefat"><thead><tr><th>' . __('Where to display this group', 'wpcf') . '</th></tr></thead><tbody><tr><td>' . '<p>' . __('Each usermeta group can display different fields for user roles.', 'wpcf') . $access_notification . '</p>');
/*
* Join filter forms
*/
// User Roles
$form['p_wrap_1_' . wpcf_unique_id(serialize($form_users))] = array('#type' => 'markup', '#markup' => '<p class="wpcf-filter-wrap">');
$form = $form + $form_users;
$form['supports-table-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table><br />');
/** Admin styles**/
$form['adminstyles-table-open'] = array('#type' => 'markup', '#markup' => '<table class="widefat" id="wpcf-admin-styles-box"><thead><tr><th>' . __('Styling Editor', 'wpcf') . '</th></tr></thead><tbody><tr><td>' . '<p>' . __('Customize Fields for admin panel.', 'wpcf') . '</p>');
$admin_styles_value = $preview_profile = $edit_profile = '';
if (isset($update['admin_styles'])) {
$admin_styles_value = $update['admin_styles'];
}
$temp = '';
if ($update) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
$user_id = wpcf_usermeta_get_user();
$preview_profile = wpcf_usermeta_preview_profile($user_id, $update, 1);
$group = $update;
$group['fields'] = wpcf_admin_usermeta_process_fields($user_id, $group['fields'], true, false);
$edit_profile = wpcf_admin_render_fields($group, $user_id, 1);
add_action('admin_enqueue_scripts', 'wpcf_admin_fields_form_fix_styles', PHP_INT_MAX);
}
$temp[] = array('#type' => 'radio', '#suffix' => '<br />', '#value' => 'edit_mode', '#title' => 'Edit mode', '#name' => 'wpcf[group][preview]', '#default_value' => '', '#before' => '<div class="wpcf-admin-css-preview-style-edit">', '#inline' => true, '#attributes' => array('onclick' => 'changePreviewHtml(\'editmode\')', 'checked' => 'checked'));
$temp[] = array('#type' => 'radio', '#title' => 'Read Only', '#name' => 'wpcf[group][preview]', '#default_value' => '', '#after' => '</div>', '#inline' => true, '#attributes' => array('onclick' => 'changePreviewHtml(\'readonly\')'));
$temp[] = array('#type' => 'textarea', '#name' => 'wpcf[group][admin_html_preview]', '#inline' => true, '#value' => '', '#id' => 'wpcf-form-groups-admin-html-preview', '#before' => '<h3>Field group HTML</h3>');
$temp[] = array('#type' => 'textarea', '#name' => 'wpcf[group][admin_styles]', '#inline' => true, '#value' => $admin_styles_value, '#default_value' => '', '#id' => 'wpcf-form-groups-css-fields-editor', '#after' => '
<div class="wpcf-update-preview-btn"><input type="button" value="Update preview" onclick="wpcfPreviewHtml()" style="float:right;" class="button-secondary"></div>
<h3>Field group preview</h3>
<div id="wpcf-update-preview-div">Preview here</div>
<script type="text/javascript">
var wpcfReadOnly = ' . json_encode($preview_profile) . ';
var wpcfEditMode = ' . json_encode($edit_profile) . ';
var wpcfDefaultCss = ' . json_encode($admin_styles_value) . ';
</script>
', '#before' => '<h3>Your CSS</h3>');
$admin_styles = _wpcf_filter_wrap('admin_styles', __('Admin styles for fields:', 'wpcf'), '', '', $temp, __('Open style editor', 'wpcf'));
$form['p_wrap_1_' . wpcf_unique_id(serialize($admin_styles))] = array('#type' => 'markup', '#markup' => '<p class="wpcf-filter-wrap">');
$form = $form + $admin_styles;
$form['adminstyles-table-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table><br />');
/** End admin Styles **/
// Group fields
$form['fields_title'] = array('#type' => 'markup', '#markup' => '<h2>' . __('Fields', 'wpcf') . '</h2>');
$show_under_title = true;
$form['ajax-response-open'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-fields-sortable" class="ui-sortable">');
// If it's update, display existing fields
$existing_fields = array();
if ($update && isset($update['fields'])) {
foreach ($update['fields'] as $slug => $field) {
示例6: 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;
}
示例7: types_render_usermeta_field
/**
* Calls view function for specific field type.
*
* @global object $wpdb
*
* @param type $field
* @param type $atts
* @return type
*/
function types_render_usermeta_field($field_id, $params, $content = null, $code = '')
{
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
global $wpcf, $post, $wpdb;
// HTML var holds actual output
$html = '';
// Set post ID
$post_id = $post->ID;
if (isset($params['post_id']) && !empty($params['post_id'])) {
$post_id = $params['post_id'];
}
// Get field
$field = wpcf_fields_get_field_by_slug($field_id, 'wpcf-usermeta');
// If field not found return empty string
if (empty($field)) {
// Log
if (!function_exists('wplogger')) {
require_once WPCF_EMBEDDED_ABSPATH . '/common/wplogger.php';
}
global $wplogger;
$wplogger->log('types_render_usermeta_field call for missing field \'' . $field_id . '\'', WPLOG_DEBUG);
return '';
}
//Get user By ID
if (isset($params['user_id'])) {
$user_id = $params['user_id'];
} else {
if (isset($params['user_name'])) {
//Get user by login
$user_id = $wpdb->get_var($wpdb->prepare("SELECT * FROM " . $wpdb->users . " WHERE user_login = %s", $params['user_name']));
} else {
if (isset($params['user_is_author'])) {
//Get Post author
$user_id = $post->post_author;
} else {
if (isset($params['user_current'])) {
//Get current logged user
$user_id = wpcf_usermeta_get_user();
} else {
//If empty get post author, if no post, return empty
if (!empty($post_id)) {
$user_id = $post->post_author;
} else {
return;
}
}
}
}
}
if (empty($user_id)) {
return;
}
// Set field
$wpcf->usermeta_field->set($user_id, $field);
// See if repetitive
if (wpcf_admin_is_repetitive($field)) {
$wpcf->usermeta_repeater->set($user_id, $field);
$_meta = $wpcf->usermeta_repeater->_get_meta();
$meta = $_meta['custom_order'];
// $meta = get_post_meta( $post_id,
// wpcf_types_get_meta_prefix( $field ) . $field['slug'], false );
// Sometimes if meta is empty - array(0 => '') is returned
if (count($meta) == 1) {
$meta_id = key($meta);
$_temp = array_shift($meta);
if (strval($_temp) == '') {
return '';
} else {
$params['field_value'] = $_temp;
return types_render_field_single($field, $params, $content, $code, $meta_id);
}
} else {
if (!empty($meta)) {
$output = '';
if (isset($params['index'])) {
$index = $params['index'];
} else {
$index = '';
}
// Allow wpv-for-each shortcode to set the index
$index = apply_filters('wpv-for-each-index', $index);
if ($index === '') {
$output = array();
foreach ($meta as $temp_key => $temp_value) {
$params['field_value'] = $temp_value;
$temp_output = types_render_field_single($field, $params, $content, $code, $temp_key);
if (!empty($temp_output)) {
$output[] = $temp_output;
}
}
if (!empty($output) && isset($params['separator'])) {
//.........这里部分代码省略.........
示例8: wpcf_ajax_embedded
//.........这里部分代码省略.........
) );
} else {
echo json_encode( array(
'output' => $output,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;*/
/* Usermeta */
// Not used anywhere
/*case 'pr_sort_parent':
$output = 'Passed wrong parameters';
if ( isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
$output = $wpcf->relationship->child_meta_form(
intval( $_GET['post_id'] ), strval( $_GET['post_type'] )
);
}
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
echo json_encode( array(
'output' => $output,
) );
} else {
echo json_encode( array(
'output' => $output,
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
) );
}
break;*/
/* Usermeta */
case 'um_repetitive_add':
if (isset($_GET['user_id'])) {
$user_id = $_GET['user_id'];
} else {
$user_id = wpcf_usermeta_get_user();
}
if (isset($_GET['field_id']) && current_user_can('edit_user', $user_id)) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
$field = wpcf_admin_fields_get_field(sanitize_text_field($_GET['field_id']), false, false, false, 'wpcf-usermeta');
global $wpcf;
$wpcf->usermeta_repeater->set($user_id, $field);
/*
*
* Force empty values!
*/
$wpcf->usermeta_repeater->cf['value'] = null;
$wpcf->usermeta_repeater->meta = null;
$form = $wpcf->usermeta_repeater->get_field_form(null, true);
echo json_encode(array('output' => wpcf_form_simple($form) . wpcf_form_render_js_validation('#your-profile', false)));
} else {
echo json_encode(array('output' => 'params missing'));
}
break;
case 'um_repetitive_delete':
if (isset($_POST['user_id']) && isset($_POST['field_id']) && current_user_can('edit_user', intval($_POST['user_id']))) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
$user_id = intval($_POST['user_id']);
$field = wpcf_admin_fields_get_field(sanitize_text_field($_POST['field_id']), false, false, false, 'wpcf-usermeta');
$meta_id = intval($_POST['meta_id']);
if (!empty($field) && !empty($user_id) && !empty($meta_id)) {
/*
*
*
* Changed.
* Since Types 1.2
示例9: 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);
}
//.........这里部分代码省略.........
示例10: wpv_layout_wizard_add_field
function wpv_layout_wizard_add_field()
{
// TODO this might need localization TODO this is seriously broken
if (!isset($_POST["wpnonce"]) || !wp_verify_nonce($_POST["wpnonce"], 'layout_wizard_nonce')) {
die("Undefined Nonce.");
}
global $WP_Views, $wpdb;
$settings = $WP_Views->get_view_settings($_POST["view_id"]);
$WP_Views->editor_addon = new Editor_addon('wpv-views', __('Insert Views Shortcodes', 'wpv-views'), WPV_URL . '/res/js/views_editor_plugin.js', WPV_URL . '/res/img/bw_icon16.png');
if ((string) $settings["query_type"][0] == 'posts') {
add_short_codes_to_js(array('body-view-templates', 'post', 'taxonomy', 'post-view', 'taxonomy-view', 'user-view'), $WP_Views->editor_addon);
} else {
if ((string) $settings["query_type"][0] == 'taxonomy') {
add_short_codes_to_js(array('post-view', 'taxonomy-view', 'user-view'), $WP_Views->editor_addon);
} else {
if ((string) $settings["query_type"][0] == 'users') {
}
}
}
$fields_list = $WP_Views->editor_addon->get_fields_list();
if (empty($fields_list)) {
$fields_list = array();
}
$fields_accos = array();
// Show taxonomy fields only if we are in Taxonomy mode
if ((string) $settings["query_type"][0] == 'taxonomy') {
$tax_fields = array();
$tax_fields[__('Taxonomy title', 'wpv-views')] = 'wpv-taxonomy-title';
$tax_fields[__('Taxonomy title with a link', 'wpv-views')] = 'wpv-taxonomy-link';
$tax_fields[__('Taxonomy URL', 'wpv-views')] = 'wpv-taxonomy-url';
$tax_fields[__('Taxonomy slug', 'wpv-views')] = 'wpv-taxonomy-slug';
$tax_fields[__('Taxonomy description', 'wpv-views')] = 'wpv-taxonomy-description';
$tax_fields[__('Taxonomy post count', 'wpv-views')] = 'wpv-taxonomy-post-count';
foreach ($tax_fields as $name => $value) {
$fields_accos[__('Taxonomy fields', 'wpv-views')][] = array($name, $value);
}
}
if ((string) $settings["query_type"][0] == 'users') {
$user_fields = array();
$user_fields[__('User ID', 'wpv-views')] = 'wpv-user field="ID"';
$user_fields[__('User Email', 'wpv-views')] = 'wpv-user field="user_email"';
$user_fields[__('User Login', 'wpv-views')] = 'wpv-user field="user_login"';
$user_fields[__('First Name', 'wpv-views')] = 'wpv-user field="user_firstname"';
$user_fields[__('Last Name', 'wpv-views')] = 'wpv-user field="user_lastname"';
$user_fields[__('Nickname', 'wpv-views')] = 'wpv-user field="nickname"';
$user_fields[__('Display Name', 'wpv-views')] = 'wpv-user field="display_name"';
$user_fields[__('Description', 'wpv-views')] = 'wpv-user field="description"';
$user_fields[__('Yahoo IM', 'wpv-views')] = 'wpv-user field="yim"';
$user_fields[__('Jabber', 'wpv-views')] = 'wpv-user field="jabber"';
$user_fields[__('AIM', 'wpv-views')] = 'wpv-user field="aim"';
$user_fields[__('User Url', 'wpv-views')] = 'wpv-user field="user_url"';
$user_fields[__('Registration Date', 'wpv-views')] = 'wpv-user field="user_registered"';
$user_fields[__('User Status', 'wpv-views')] = 'wpv-user field="user_status"';
$user_fields[__('User Spam Status', 'wpv-views')] = 'wpv-user field="spam"';
foreach ($user_fields as $name => $value) {
$fields_accos[__('Basic', 'wpv-views')][] = array($name, $value);
}
$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) . ')/';
$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;
}
$fields_accos[__('Users fields', 'wpv-views')][] = array($key, 'wpv-user field="' . $key . '"');
}
} else {
if (preg_match($exclude_these_hidden_var, $key)) {
continue;
}
$fields_accos[__('Users fields', 'wpv-views')][] = array($key, 'wpv-user field="' . $key . '"');
}
}
if (function_exists('wpcf_init')) {
// TODO do the same for wpcf-fields for posts
//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); */
$fields_accos[$group['name']][] = array($field['name'], 'types usermeta="' . $field['slug'] . '"][/types');
}
//.........这里部分代码省略.........