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