@@ 328-353 (lines=26) @@ | ||
325 | * |
|
326 | * @return array $options |
|
327 | */ |
|
328 | protected function get_user_options( $type ) { |
|
329 | /** |
|
330 | * Filter the default parameters when fetching users for a particular field. |
|
331 | * |
|
332 | * @param array $args The parameters, passed to get_users(). |
|
333 | */ |
|
334 | $filter_name = 'carbon_fields_association_field_options_' . $this->get_base_name() . '_' . $type['type']; |
|
335 | $args = apply_filters( $filter_name, array( |
|
336 | 'fields' => 'ID', |
|
337 | ) ); |
|
338 | ||
339 | // fetch and prepare users as association items |
|
340 | $users = get_users( $args ); |
|
341 | foreach ( $users as &$u ) { |
|
342 | $u = array( |
|
343 | 'id' => intval( $u ), |
|
344 | 'title' => $this->get_title_by_type( $u, $type['type'] ), |
|
345 | 'type' => $type['type'], |
|
346 | 'subtype' => 'user', |
|
347 | 'label' => $this->get_item_label( $u, $type['type'] ), |
|
348 | 'is_trashed' => false, |
|
349 | 'edit_link' => $this->get_object_edit_link( $type, $u ), |
|
350 | ); |
|
351 | } |
|
352 | return $users; |
|
353 | } |
|
354 | ||
355 | /** |
|
356 | * Get comment options |
|
@@ 360-385 (lines=26) @@ | ||
357 | * |
|
358 | * @return array $options |
|
359 | */ |
|
360 | protected function get_comment_options( $type ) { |
|
361 | /** |
|
362 | * Filter the default parameters when fetching comments for a particular field. |
|
363 | * |
|
364 | * @param array $args The parameters, passed to get_comments(). |
|
365 | */ |
|
366 | $filter_name = 'carbon_fields_association_field_options_' . $this->get_base_name() . '_' . $type['type']; |
|
367 | $args = apply_filters( $filter_name, array( |
|
368 | 'fields' => 'ids', |
|
369 | ) ); |
|
370 | ||
371 | // fetch and prepare comments as association items |
|
372 | $comments = get_comments( $args ); |
|
373 | foreach ( $comments as &$c ) { |
|
374 | $c = array( |
|
375 | 'id' => intval( $c ), |
|
376 | 'title' => $this->get_title_by_type( $c, $type['type'] ), |
|
377 | 'type' => $type['type'], |
|
378 | 'subtype' => 'comment', |
|
379 | 'label' => $this->get_item_label( $c, $type['type'] ), |
|
380 | 'is_trashed' => false, |
|
381 | 'edit_link' => $this->get_object_edit_link( $type, $c ), |
|
382 | ); |
|
383 | } |
|
384 | return $comments; |
|
385 | } |
|
386 | ||
387 | /** |
|
388 | * Generate the item options. |