Code Duplication    Length = 26-26 lines in 2 locations

core/Field/Association_Field.php 2 locations

@@ 284-309 (lines=26) @@
281
	 *
282
	 * @return array $options
283
	 */
284
	protected function get_user_options( $type ) {
285
		/**
286
		 * Filter the default parameters when fetching users for a particular field.
287
		 *
288
		 * @param array $args The parameters, passed to get_users().
289
		 */
290
		$filter_name = 'carbon_association_options_' . $this->get_name() . '_' . $type['type'];
291
		$args = apply_filters( $filter_name, array(
292
			'fields' => 'ID',
293
		) );
294
295
		// fetch and prepare users as association items
296
		$users = get_users( $args );
297
		foreach ( $users as &$u ) {
298
			$u = array(
299
				'id' => intval( $u ),
300
				'title' => $this->get_title_by_type( $u, $type['type'] ),
301
				'type' => $type['type'],
302
				'subtype' => 'user',
303
				'label' => $this->get_item_label( $u, $type['type'] ),
304
				'is_trashed' => false,
305
				'edit_link' => $this->get_object_edit_link( $type, $u ),
306
			);
307
		}
308
		return $users;
309
	}
310
311
	/**
312
	 * Get comment options
@@ 316-341 (lines=26) @@
313
	 *
314
	 * @return array $options
315
	 */
316
	protected function get_comment_options( $type ) {
317
		/**
318
		 * Filter the default parameters when fetching comments for a particular field.
319
		 *
320
		 * @param array $args The parameters, passed to get_comments().
321
		 */
322
		$filter_name = 'carbon_association_options_' . $this->get_name() . '_' . $type['type'];
323
		$args = apply_filters( $filter_name, array(
324
			'fields' => 'ids',
325
		) );
326
327
		// fetch and prepare comments as association items
328
		$comments = get_comments( $args );
329
		foreach ( $comments as &$c ) {
330
			$c = array(
331
				'id' => intval( $c ),
332
				'title' => $this->get_title_by_type( $c, $type['type'] ),
333
				'type' => $type['type'],
334
				'subtype' => 'comment',
335
				'label' => $this->get_item_label( $c, $type['type'] ),
336
				'is_trashed' => false,
337
				'edit_link' => $this->get_object_edit_link( $type, $c ),
338
			);
339
		}
340
		return $comments;
341
	}
342
343
	/**
344
	 * Generate the item options.