PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 3.0.5
Admin Columns v3.0.5
7.1.4 7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Settings / Column / User.php
codepress-admin-columns / classes / Settings / Column Last commit date
BeforeAfter 8 years ago ActionIcons.php 8 years ago AttachmentDisplay.php 8 years ago BeforeAfter.php 8 years ago CharacterLimit.php 8 years ago CommentCount.php 8 years ago CustomField.php 8 years ago CustomFieldType.php 8 years ago Date.php 8 years ago ExifData.php 8 years ago Image.php 8 years ago Images.php 8 years ago Label.php 8 years ago LinkLabel.php 8 years ago LinkToMenu.php 8 years ago Message.php 8 years ago Meta.php 8 years ago MissingImageSize.php 8 years ago NumberOfItems.php 8 years ago Password.php 8 years ago PathScope.php 8 years ago Post.php 8 years ago PostFormatIcon.php 8 years ago PostLink.php 8 years ago PostType.php 8 years ago Separator.php 8 years ago StatusIcon.php 8 years ago StringLimit.php 8 years ago Taxonomy.php 8 years ago Term.php 8 years ago Toggle.php 8 years ago Type.php 8 years ago User.php 8 years ago Width.php 8 years ago WordLimit.php 8 years ago WordsPerMinute.php 8 years ago
User.php
188 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class AC_Settings_Column_User extends AC_Settings_Column
8 implements AC_Settings_FormatValueInterface {
9
10 /**
11 * @var string
12 */
13 private $display_author_as;
14
15 /**
16 * @var string
17 */
18 private $user_link_to;
19
20 protected function set_name() {
21 $this->name = 'user';
22 }
23
24 protected function define_options() {
25 return array( 'display_author_as', 'user_link_to' );
26 }
27
28 /**
29 * @return AC_View
30 */
31 public function create_view() {
32 $select = $this->create_element( 'select', 'display_author_as' )
33 ->set_attribute( 'data-refresh', 'column' )
34 ->set_options( $this->get_display_options() );
35
36 $display_format = new AC_View( array(
37 'label' => __( 'Display', 'codepress-admin-columns' ),
38 'setting' => $select,
39 'for' => $select->get_id(),
40 ) );
41
42 $select = $this->create_element( 'select', 'user_link_to' )
43 ->set_attribute( 'data-refresh', 'column' )
44 ->set_options( $this->get_link_options() );
45
46 $link_format = new AC_View( array(
47 'label' => __( 'Link To', 'codepress-admin-columns' ),
48 'setting' => $select,
49 'for' => $select->get_id(),
50 ) );
51
52 $view = new AC_View( array(
53 'label' => __( 'User', 'codepress-admin-columns' ),
54 'sections' => array( $display_format, $link_format ),
55 ) );
56
57 return $view;
58 }
59
60 /**
61 * @param int $user_id
62 *
63 * @return false|string
64 */
65 public function get_user_name( $user_id ) {
66 return ac_helper()->user->get_display_name( $user_id, $this->get_display_author_as() );
67 }
68
69 /**
70 * @param $user_id
71 *
72 * @return bool|string
73 */
74 private function get_user_link( $user_id ) {
75 $link = false;
76
77 switch ( $this->get_user_link_to() ) {
78
79 case 'edit_user' :
80 $link = get_edit_user_link( $user_id );
81
82 break;
83 case 'view_user_posts' :
84 $link = add_query_arg( array(
85 'post_type' => $this->column->get_post_type(),
86 'author' => get_the_author_meta( 'ID' ),
87 ), 'edit.php' );
88
89 break;
90 case 'view_author' :
91 $link = get_author_posts_url( $user_id );
92
93 break;
94 case 'email_user' :
95 if ( $email = get_the_author_meta( 'email', $user_id ) ) {
96 $link = 'mailto:' . $email;
97 }
98
99 break;
100 }
101
102 return $link;
103 }
104
105 /**
106 * @return array
107 */
108 private function get_display_options() {
109 $options = array(
110 'display_name' => __( 'Display Name', 'codepress-admin-columns' ),
111 'first_name' => __( 'First Name', 'codepress-admin-columns' ),
112 'last_name' => __( 'Last Name', 'codepress-admin-columns' ),
113 'nickname' => __( 'Nickname', 'codepress-admin-columns' ),
114 'user_login' => __( 'User Login', 'codepress-admin-columns' ),
115 'user_email' => __( 'User Email', 'codepress-admin-columns' ),
116 'ID' => __( 'User ID', 'codepress-admin-columns' ),
117 'first_last_name' => __( 'First and Last Name', 'codepress-admin-columns' ),
118 'user_nicename' => __( 'User Nicename', 'codepress-admin-columns' ),
119 'roles' => __( 'Roles', 'codepress-admin-columns' ),
120 );
121
122 // resort for possible translations
123 natcasesort( $options );
124
125 return $options;
126 }
127
128 /**
129 * @return array
130 */
131 private function get_link_options() {
132 $options = array(
133 'edit_user' => __( 'Edit User Profile', 'codepress-admin-columns' ),
134 'email_user' => __( 'User Email', 'codepress-admin-columns' ),
135 'view_user_posts' => __( 'View User Posts', 'codepress-admin-columns' ),
136 'view_author' => __( 'View Public Author Page', 'codepress-admin-columns' ),
137 );
138
139 // resort for possible translations
140 natcasesort( $options );
141
142 $options = array_merge( array( '' => __( 'None' ) ), $options );
143
144 return $options;
145 }
146
147 /**
148 * @return string
149 */
150 public function get_display_author_as() {
151 return $this->display_author_as;
152 }
153
154 /**
155 * @param string $display_author_as
156 *
157 * @return bool
158 */
159 public function set_display_author_as( $display_author_as ) {
160 $this->display_author_as = $display_author_as;
161
162 return true;
163 }
164
165 /**
166 * @return string
167 */
168 public function get_user_link_to() {
169 return $this->user_link_to;
170 }
171
172 /**
173 * @param string $user_link_to
174 *
175 * @return bool
176 */
177 public function set_user_link_to( $user_link_to ) {
178 $this->user_link_to = $user_link_to;
179
180 return true;
181 }
182
183 public function format( $value, $original_value ) {
184 return ac_helper()->html->link( $this->get_user_link( $value ), $this->get_user_name( $value ) );
185 }
186
187 }
188