Code Duplication    Length = 48-48 lines in 2 locations

classes/PodsUI.php 2 locations

@@ 4534-4581 (lines=48) @@
4531
	 *
4532
	 * @return bool|mixed
4533
	 */
4534
	public function callback_action() {
4535
4536
		$args = func_get_args();
4537
4538
		if ( empty( $args ) ) {
4539
			return false;
4540
		}
4541
4542
		$action = array_shift( $args );
4543
4544
		$deprecated = false;
4545
4546
		if ( is_bool( $action ) ) {
4547
			$deprecated = $action;
4548
4549
			$action = array_shift( $args );
4550
		}
4551
4552
		// Do hook
4553
		$callback_args = $args;
4554
		array_unshift( $callback_args, null );
4555
		array_unshift( $callback_args, 'action_' . $action );
4556
4557
		$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args );
4558
4559
		if ( null === $callback ) {
4560
			$callback = false;
4561
		}
4562
4563
		$args[] = $this;
4564
4565
		// Deprecated reverse arg order
4566
		if ( $deprecated ) {
4567
			$args = array_reverse( $args );
4568
		}
4569
4570
		if ( isset( $this->actions_custom[ $action ] ) ) {
4571
			if ( is_array( $this->actions_custom[ $action ] ) && isset( $this->actions_custom[ $action ][ 'callback' ] ) && is_callable( $this->actions_custom[ $action ][ 'callback' ] ) ) {
4572
				$callback = call_user_func_array( $this->actions_custom[ $action ][ 'callback' ], $args );
4573
			}
4574
			elseif ( is_callable( $this->actions_custom[ $action ] ) ) {
4575
				$callback = call_user_func_array( $this->actions_custom[ $action ], $args );
4576
			}
4577
		}
4578
4579
		return $callback;
4580
4581
	}
4582
4583
	/**
4584
	 * Check for a bulk action callback and run it
@@ 4588-4635 (lines=48) @@
4585
	 *
4586
	 * @return bool|mixed Callback result
4587
	 */
4588
	public function callback_bulk() {
4589
4590
		$args = func_get_args();
4591
4592
		if ( empty( $args ) ) {
4593
			return false;
4594
		}
4595
4596
		$action = array_shift( $args );
4597
4598
		$deprecated = false;
4599
4600
		if ( is_bool( $action ) ) {
4601
			$deprecated = $action;
4602
4603
			$action = array_shift( $args );
4604
		}
4605
4606
		// Do hook
4607
		$callback_args = $args;
4608
		array_unshift( $callback_args, null );
4609
		array_unshift( $callback_args, 'bulk_action_' . $action );
4610
4611
		$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args );
4612
4613
		if ( null === $callback ) {
4614
			$callback = false;
4615
		}
4616
4617
		$args[] = $this;
4618
4619
		// Deprecated reverse arg order
4620
		if ( $deprecated ) {
4621
			$args = array_reverse( $args );
4622
		}
4623
4624
		if ( isset( $this->actions_bulk[ $action ] ) ) {
4625
			if ( is_array( $this->actions_bulk[ $action ] ) && isset( $this->actions_bulk[ $action ][ 'callback' ] ) && is_callable( $this->actions_bulk[ $action ][ 'callback' ] ) ) {
4626
				$callback = call_user_func_array( $this->actions_bulk[ $action ][ 'callback' ], $args );
4627
			}
4628
			elseif ( is_callable( $this->actions_bulk[ $action ] ) ) {
4629
				$callback = call_user_func_array( $this->actions_bulk[ $action ], $args );
4630
			}
4631
		}
4632
4633
		return $callback;
4634
4635
	}
4636
4637
    /*
4638
        // Example code for use with $this->do_hook