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