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

@@ 375-400 (lines=26) @@
372
	 *
373
	 * @return array
374
	 */
375
	public function get_donor_query() {
376
		$paged   = $this->get_paged();
377
		$offset  = $this->per_page * ( $paged - 1 );
378
		$search  = $this->get_search();
379
		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
380
		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
381
382
		$args = array(
383
			'number'  => $this->per_page,
384
			'offset'  => $offset,
385
			'order'   => $order,
386
			'orderby' => $orderby,
387
		);
388
389
		if ( $search ) {
390
			if ( is_email( $search ) ) {
391
				$args['email'] = $search;
392
			} elseif ( is_numeric( $search ) ) {
393
				$args['id'] = $search;
394
			} else {
395
				$args['name'] = $search;
396
			}
397
		}
398
399
		return $args;
400
	}
401
402
	/**
403
	 * Generates content for a single row of the table