Code Duplication    Length = 26-26 lines in 2 locations

core/Field/Association_Field.php 2 locations

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