|
@@ 5155-5202 (lines=48) @@
|
| 5152 |
|
* |
| 5153 |
|
* @return bool|mixed |
| 5154 |
|
*/ |
| 5155 |
|
public function callback_action() { |
| 5156 |
|
|
| 5157 |
|
$args = func_get_args(); |
| 5158 |
|
|
| 5159 |
|
if ( empty( $args ) ) { |
| 5160 |
|
return false; |
| 5161 |
|
} |
| 5162 |
|
|
| 5163 |
|
$action = array_shift( $args ); |
| 5164 |
|
|
| 5165 |
|
$deprecated = false; |
| 5166 |
|
|
| 5167 |
|
if ( is_bool( $action ) ) { |
| 5168 |
|
$deprecated = $action; |
| 5169 |
|
|
| 5170 |
|
$action = array_shift( $args ); |
| 5171 |
|
} |
| 5172 |
|
|
| 5173 |
|
// Do hook |
| 5174 |
|
$callback_args = $args; |
| 5175 |
|
array_unshift( $callback_args, null ); |
| 5176 |
|
array_unshift( $callback_args, 'action_' . $action ); |
| 5177 |
|
|
| 5178 |
|
$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args ); |
| 5179 |
|
|
| 5180 |
|
if ( null === $callback ) { |
| 5181 |
|
$callback = false; |
| 5182 |
|
} |
| 5183 |
|
|
| 5184 |
|
$args[] = $this; |
| 5185 |
|
|
| 5186 |
|
// Deprecated reverse arg order |
| 5187 |
|
if ( $deprecated ) { |
| 5188 |
|
$args = array_reverse( $args ); |
| 5189 |
|
} |
| 5190 |
|
|
| 5191 |
|
if ( isset( $this->actions_custom[ $action ] ) ) { |
| 5192 |
|
if ( is_array( $this->actions_custom[ $action ] ) && isset( $this->actions_custom[ $action ]['callback'] ) && is_callable( $this->actions_custom[ $action ]['callback'] ) ) { |
| 5193 |
|
$callback = call_user_func_array( $this->actions_custom[ $action ]['callback'], $args ); |
| 5194 |
|
} elseif ( is_callable( $this->actions_custom[ $action ] ) ) { |
| 5195 |
|
$callback = call_user_func_array( $this->actions_custom[ $action ], $args ); |
| 5196 |
|
} |
| 5197 |
|
} |
| 5198 |
|
|
| 5199 |
|
return $callback; |
| 5200 |
|
|
| 5201 |
|
} |
| 5202 |
|
|
| 5203 |
|
/** |
| 5204 |
|
* Check for a bulk action callback and run it |
| 5205 |
|
* |
|
@@ 5208-5255 (lines=48) @@
|
| 5205 |
|
* |
| 5206 |
|
* @return bool|mixed Callback result |
| 5207 |
|
*/ |
| 5208 |
|
public function callback_bulk() { |
| 5209 |
|
|
| 5210 |
|
$args = func_get_args(); |
| 5211 |
|
|
| 5212 |
|
if ( empty( $args ) ) { |
| 5213 |
|
return false; |
| 5214 |
|
} |
| 5215 |
|
|
| 5216 |
|
$action = array_shift( $args ); |
| 5217 |
|
|
| 5218 |
|
$deprecated = false; |
| 5219 |
|
|
| 5220 |
|
if ( is_bool( $action ) ) { |
| 5221 |
|
$deprecated = $action; |
| 5222 |
|
|
| 5223 |
|
$action = array_shift( $args ); |
| 5224 |
|
} |
| 5225 |
|
|
| 5226 |
|
// Do hook |
| 5227 |
|
$callback_args = $args; |
| 5228 |
|
array_unshift( $callback_args, null ); |
| 5229 |
|
array_unshift( $callback_args, 'bulk_action_' . $action ); |
| 5230 |
|
|
| 5231 |
|
$callback = call_user_func_array( array( $this, 'do_hook' ), $callback_args ); |
| 5232 |
|
|
| 5233 |
|
if ( null === $callback ) { |
| 5234 |
|
$callback = false; |
| 5235 |
|
} |
| 5236 |
|
|
| 5237 |
|
$args[] = $this; |
| 5238 |
|
|
| 5239 |
|
// Deprecated reverse arg order |
| 5240 |
|
if ( $deprecated ) { |
| 5241 |
|
$args = array_reverse( $args ); |
| 5242 |
|
} |
| 5243 |
|
|
| 5244 |
|
if ( isset( $this->actions_bulk[ $action ] ) ) { |
| 5245 |
|
if ( is_array( $this->actions_bulk[ $action ] ) && isset( $this->actions_bulk[ $action ]['callback'] ) && is_callable( $this->actions_bulk[ $action ]['callback'] ) ) { |
| 5246 |
|
$callback = call_user_func_array( $this->actions_bulk[ $action ]['callback'], $args ); |
| 5247 |
|
} elseif ( is_callable( $this->actions_bulk[ $action ] ) ) { |
| 5248 |
|
$callback = call_user_func_array( $this->actions_bulk[ $action ], $args ); |
| 5249 |
|
} |
| 5250 |
|
} |
| 5251 |
|
|
| 5252 |
|
return $callback; |
| 5253 |
|
|
| 5254 |
|
} |
| 5255 |
|
|
| 5256 |
|
/* |
| 5257 |
|
// Example code for use with $this->do_hook |
| 5258 |
|
public function my_filter_function ($args, $obj) { |