Code Duplication    Length = 26-26 lines in 2 locations

core/Field/Association_Field.php 2 locations

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