|
@@ 4417-4464 (lines=48) @@
|
| 4414 |
|
* |
| 4415 |
|
* @return bool|mixed |
| 4416 |
|
*/ |
| 4417 |
|
public function callback_action() { |
| 4418 |
|
|
| 4419 |
|
$args = func_get_args(); |
| 4420 |
|
|
| 4421 |
|
if ( empty( $args ) ) { |
| 4422 |
|
return false; |
| 4423 |
|
} |
| 4424 |
|
|
| 4425 |
|
$action = array_shift( $args ); |
| 4426 |
|
|
| 4427 |
|
$deprecated = false; |
| 4428 |
|
|
| 4429 |
|
if ( is_bool( $action ) ) { |
| 4430 |
|
$deprecated = $action; |
| 4431 |
|
|
| 4432 |
|
$action = array_shift( $args ); |
| 4433 |
|
} |
| 4434 |
|
|
| 4435 |
|
// Do hook |
| 4436 |
|
$callback_args = $args; |
| 4437 |
|
array_unshift( $callback_args, null ); |
| 4438 |
|
array_unshift( $callback_args, 'action_' . $action ); |
| 4439 |
|
|
| 4440 |
|
$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args ); |
| 4441 |
|
|
| 4442 |
|
if ( null === $callback ) { |
| 4443 |
|
$callback = false; |
| 4444 |
|
} |
| 4445 |
|
|
| 4446 |
|
$args[] = $this; |
| 4447 |
|
|
| 4448 |
|
// Deprecated reverse arg order |
| 4449 |
|
if ( $deprecated ) { |
| 4450 |
|
$args = array_reverse( $args ); |
| 4451 |
|
} |
| 4452 |
|
|
| 4453 |
|
if ( isset( $this->actions_custom[ $action ] ) ) { |
| 4454 |
|
if ( is_array( $this->actions_custom[ $action ] ) && isset( $this->actions_custom[ $action ][ 'callback' ] ) && is_callable( $this->actions_custom[ $action ][ 'callback' ] ) ) { |
| 4455 |
|
$callback = call_user_func_array( $this->actions_custom[ $action ][ 'callback' ], $args ); |
| 4456 |
|
} |
| 4457 |
|
elseif ( is_callable( $this->actions_custom[ $action ] ) ) { |
| 4458 |
|
$callback = call_user_func_array( $this->actions_custom[ $action ], $args ); |
| 4459 |
|
} |
| 4460 |
|
} |
| 4461 |
|
|
| 4462 |
|
return $callback; |
| 4463 |
|
|
| 4464 |
|
} |
| 4465 |
|
|
| 4466 |
|
/** |
| 4467 |
|
* Check for a bulk action callback and run it |
|
@@ 4471-4518 (lines=48) @@
|
| 4468 |
|
* |
| 4469 |
|
* @return bool|mixed Callback result |
| 4470 |
|
*/ |
| 4471 |
|
public function callback_bulk() { |
| 4472 |
|
|
| 4473 |
|
$args = func_get_args(); |
| 4474 |
|
|
| 4475 |
|
if ( empty( $args ) ) { |
| 4476 |
|
return false; |
| 4477 |
|
} |
| 4478 |
|
|
| 4479 |
|
$action = array_shift( $args ); |
| 4480 |
|
|
| 4481 |
|
$deprecated = false; |
| 4482 |
|
|
| 4483 |
|
if ( is_bool( $action ) ) { |
| 4484 |
|
$deprecated = $action; |
| 4485 |
|
|
| 4486 |
|
$action = array_shift( $args ); |
| 4487 |
|
} |
| 4488 |
|
|
| 4489 |
|
// Do hook |
| 4490 |
|
$callback_args = $args; |
| 4491 |
|
array_unshift( $callback_args, null ); |
| 4492 |
|
array_unshift( $callback_args, 'bulk_action_' . $action ); |
| 4493 |
|
|
| 4494 |
|
$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args ); |
| 4495 |
|
|
| 4496 |
|
if ( null === $callback ) { |
| 4497 |
|
$callback = false; |
| 4498 |
|
} |
| 4499 |
|
|
| 4500 |
|
$args[] = $this; |
| 4501 |
|
|
| 4502 |
|
// Deprecated reverse arg order |
| 4503 |
|
if ( $deprecated ) { |
| 4504 |
|
$args = array_reverse( $args ); |
| 4505 |
|
} |
| 4506 |
|
|
| 4507 |
|
if ( isset( $this->actions_bulk[ $action ] ) ) { |
| 4508 |
|
if ( is_array( $this->actions_bulk[ $action ] ) && isset( $this->actions_bulk[ $action ][ 'callback' ] ) && is_callable( $this->actions_bulk[ $action ][ 'callback' ] ) ) { |
| 4509 |
|
$callback = call_user_func_array( $this->actions_bulk[ $action ][ 'callback' ], $args ); |
| 4510 |
|
} |
| 4511 |
|
elseif ( is_callable( $this->actions_bulk[ $action ] ) ) { |
| 4512 |
|
$callback = call_user_func_array( $this->actions_bulk[ $action ], $args ); |
| 4513 |
|
} |
| 4514 |
|
} |
| 4515 |
|
|
| 4516 |
|
return $callback; |
| 4517 |
|
|
| 4518 |
|
} |
| 4519 |
|
|
| 4520 |
|
/* |
| 4521 |
|
// Example code for use with $this->do_hook |