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