Code Duplication    Length = 48-48 lines in 2 locations

classes/PodsUI.php 2 locations

@@ 4497-4544 (lines=48) @@
4494
	 *
4495
	 * @return bool|mixed
4496
	 */
4497
	public function callback_action() {
4498
4499
		$args = func_get_args();
4500
4501
		if ( empty( $args ) ) {
4502
			return false;
4503
		}
4504
4505
		$action = array_shift( $args );
4506
4507
		$deprecated = false;
4508
4509
		if ( is_bool( $action ) ) {
4510
			$deprecated = $action;
4511
4512
			$action = array_shift( $args );
4513
		}
4514
4515
		// Do hook
4516
		$callback_args = $args;
4517
		array_unshift( $callback_args, null );
4518
		array_unshift( $callback_args, 'action_' . $action );
4519
4520
		$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args );
4521
4522
		if ( null === $callback ) {
4523
			$callback = false;
4524
		}
4525
4526
		$args[] = $this;
4527
4528
		// Deprecated reverse arg order
4529
		if ( $deprecated ) {
4530
			$args = array_reverse( $args );
4531
		}
4532
4533
		if ( isset( $this->actions_custom[ $action ] ) ) {
4534
			if ( is_array( $this->actions_custom[ $action ] ) && isset( $this->actions_custom[ $action ][ 'callback' ] ) && is_callable( $this->actions_custom[ $action ][ 'callback' ] ) ) {
4535
				$callback = call_user_func_array( $this->actions_custom[ $action ][ 'callback' ], $args );
4536
			}
4537
			elseif ( is_callable( $this->actions_custom[ $action ] ) ) {
4538
				$callback = call_user_func_array( $this->actions_custom[ $action ], $args );
4539
			}
4540
		}
4541
4542
		return $callback;
4543
4544
	}
4545
4546
	/**
4547
	 * Check for a bulk action callback and run it
@@ 4551-4598 (lines=48) @@
4548
	 *
4549
	 * @return bool|mixed Callback result
4550
	 */
4551
	public function callback_bulk() {
4552
4553
		$args = func_get_args();
4554
4555
		if ( empty( $args ) ) {
4556
			return false;
4557
		}
4558
4559
		$action = array_shift( $args );
4560
4561
		$deprecated = false;
4562
4563
		if ( is_bool( $action ) ) {
4564
			$deprecated = $action;
4565
4566
			$action = array_shift( $args );
4567
		}
4568
4569
		// Do hook
4570
		$callback_args = $args;
4571
		array_unshift( $callback_args, null );
4572
		array_unshift( $callback_args, 'bulk_action_' . $action );
4573
4574
		$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args );
4575
4576
		if ( null === $callback ) {
4577
			$callback = false;
4578
		}
4579
4580
		$args[] = $this;
4581
4582
		// Deprecated reverse arg order
4583
		if ( $deprecated ) {
4584
			$args = array_reverse( $args );
4585
		}
4586
4587
		if ( isset( $this->actions_bulk[ $action ] ) ) {
4588
			if ( is_array( $this->actions_bulk[ $action ] ) && isset( $this->actions_bulk[ $action ][ 'callback' ] ) && is_callable( $this->actions_bulk[ $action ][ 'callback' ] ) ) {
4589
				$callback = call_user_func_array( $this->actions_bulk[ $action ][ 'callback' ], $args );
4590
			}
4591
			elseif ( is_callable( $this->actions_bulk[ $action ] ) ) {
4592
				$callback = call_user_func_array( $this->actions_bulk[ $action ], $args );
4593
			}
4594
		}
4595
4596
		return $callback;
4597
4598
	}
4599
4600
    /*
4601
        // Example code for use with $this->do_hook