Code Duplication    Length = 26-26 lines in 2 locations

includes/admin/reports/class-donor-reports-table.php 1 location

@@ 338-363 (lines=26) @@
335
	 * @access public
336
	 * @return array
337
	 */
338
	public function get_donor_query() {
339
		$paged   = $this->get_paged();
340
		$offset  = $this->per_page * ( $paged - 1 );
341
		$search  = $this->get_search();
342
		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
343
		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
344
345
		$args = array(
346
			'number'  => $this->per_page,
347
			'offset'  => $offset,
348
			'order'   => $order,
349
			'orderby' => $orderby,
350
		);
351
352
		if( $search ) {
353
			if ( is_email( $search ) ) {
354
				$args['email'] = $search;
355
			} elseif ( is_numeric( $search ) ) {
356
				$args['id'] = $search;
357
			} else {
358
				$args['name'] = $search;
359
			}
360
		}
361
362
		return $args;
363
	}
364
365
	/**
366
	 * Setup the final data for the table

includes/admin/donors/class-donor-table.php 1 location

@@ 424-449 (lines=26) @@
421
	 *
422
	 * @return array
423
	 */
424
	public function get_donor_query() {
425
		$paged   = $this->get_paged();
426
		$offset  = $this->per_page * ( $paged - 1 );
427
		$search  = $this->get_search();
428
		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
429
		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
430
431
		$args = array(
432
			'number'  => $this->per_page,
433
			'offset'  => $offset,
434
			'order'   => $order,
435
			'orderby' => $orderby,
436
		);
437
438
		if ( $search ) {
439
			if ( is_email( $search ) ) {
440
				$args['email'] = $search;
441
			} elseif ( is_numeric( $search ) ) {
442
				$args['id'] = $search;
443
			} else {
444
				$args['name'] = $search;
445
			}
446
		}
447
448
		return $args;
449
	}
450
451
	/**
452
	 * Setup the final data for the table.