@@ 249-274 (lines=26) @@ | ||
246 | * |
|
247 | * @return array $options |
|
248 | */ |
|
249 | protected function get_user_options( $type ) { |
|
250 | /** |
|
251 | * Filter the default parameters when fetching users for a particular field. |
|
252 | * |
|
253 | * @param array $args The parameters, passed to get_users(). |
|
254 | */ |
|
255 | $filter_name = 'carbon_association_options_' . $this->get_name() . '_' . $type['type']; |
|
256 | $args = apply_filters( $filter_name, array( |
|
257 | 'fields' => 'ID', |
|
258 | ) ); |
|
259 | ||
260 | // fetch and prepare users as association items |
|
261 | $users = get_users( $args ); |
|
262 | foreach ( $users as &$u ) { |
|
263 | $u = array( |
|
264 | 'id' => $u, |
|
265 | 'title' => $this->get_title_by_type( $u, $type['type'] ), |
|
266 | 'type' => $type['type'], |
|
267 | 'subtype' => 'user', |
|
268 | 'label' => $this->get_item_label( $u, $type['type'] ), |
|
269 | 'is_trashed' => false, |
|
270 | 'edit_link' => $this->get_object_edit_link( $type, $u ), |
|
271 | ); |
|
272 | } |
|
273 | return $users; |
|
274 | } |
|
275 | ||
276 | /** |
|
277 | * Get comment options |
|
@@ 281-306 (lines=26) @@ | ||
278 | * |
|
279 | * @return array $options |
|
280 | */ |
|
281 | protected function get_comment_options( $type ) { |
|
282 | /** |
|
283 | * Filter the default parameters when fetching comments for a particular field. |
|
284 | * |
|
285 | * @param array $args The parameters, passed to get_comments(). |
|
286 | */ |
|
287 | $filter_name = 'carbon_association_options_' . $this->get_name() . '_' . $type['type']; |
|
288 | $args = apply_filters( $filter_name, array( |
|
289 | 'fields' => 'ids', |
|
290 | ) ); |
|
291 | ||
292 | // fetch and prepare comments as association items |
|
293 | $comments = get_comments( $args ); |
|
294 | foreach ( $comments as &$c ) { |
|
295 | $c = array( |
|
296 | 'id' => $c, |
|
297 | 'title' => $this->get_title_by_type( $c, $type['type'] ), |
|
298 | 'type' => $type['type'], |
|
299 | 'subtype' => 'comment', |
|
300 | 'label' => $this->get_item_label( $c, $type['type'] ), |
|
301 | 'is_trashed' => false, |
|
302 | 'edit_link' => $this->get_object_edit_link( $type, $c ), |
|
303 | ); |
|
304 | } |
|
305 | return $comments; |
|
306 | } |
|
307 | ||
308 | /** |
|
309 | * Generate the item options. |