C:\xampp\htdocs\landing\wp-content\plugins\penci-framework\lib\meta-box\inc\fields\user.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
 * The user select field.
 *
 * @package Meta Box
 */

/**
 * User field class.
 */
class RWMB_User_Field extends RWMB_Object_Choice_Field {
    
/**
     * Normalize parameters for field.
     *
     * @param array $field Field parameters.
     *
     * @return array
     */
    
public static function normalize$field ) {
        
// Set default field args.
        
$field parent::normalize$field );

        
// Prevent select tree for user since it's not hierarchical.
        
$field['field_type'] = 'select_tree' === $field['field_type'] ? 'select' $field['field_type'];

        
// Set to always flat.
        
$field['flatten'] = true;

        
// Set default placeholder.
        
$field['placeholder'] = empty( $field['placeholder'] ) ? __'Select an user''meta-box' ) : $field['placeholder'];

        
// Set default query args.
        
$field['query_args'] = wp_parse_args$field['query_args'], array(
            
'orderby' => 'display_name',
            
'order'   => 'asc',
            
'role'    => '',
            
'fields'  => 'all',
        ) );

        return 
$field;
    }

    
/**
     * Get users.
     *
     * @param array $field Field parameters.
     *
     * @return array
     */
    
public static function get_options$field ) {
        
$query = new WP_User_Query$field['query_args'] );
        return 
$query->get_results();
    }

    
/**
     * Get field names of object to be used by walker.
     *
     * @return array
     */
    
public static function get_db_fields() {
        return array(
            
'parent' => 'parent',
            
'id'     => 'ID',
            
'label'  => 'display_name',
        );
    }

    
/**
     * Get option label.
     *
     * @param array  $field Field parameters.
     * @param string $value Option value.
     *
     * @return string
     */
    
public static function get_option_label$field$value ) {
        
$user  get_userdata$value );
        return 
'<a href="' get_author_posts_url$value ) . '">' $user->display_name '</a>';
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586