From bfdff8064eed84b29434781efa4d71ae33bf9bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Fri, 24 Feb 2023 15:49:45 -0500 Subject: [PATCH] Add doing it wrong checks if incorrect callback value for apply_filters --- src/wp-includes/class-wp-hook.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php index 4796503dcc2a9..e851c9fa17039 100644 --- a/src/wp-includes/class-wp-hook.php +++ b/src/wp-includes/class-wp-hook.php @@ -301,6 +301,18 @@ public function apply_filters( $value, $args ) { $args[0] = $value; } + if ( ! isset( $the_['function'] ) ) { + _doing_it_wrong( 'apply_filters()', 'callback value can not be empty', '6.x' ); + + continue; + } + + if ( ! is_callable( $the_['function'] ) ) { + _doing_it_wrong( 'apply_filters()', 'filter callback value should be a valid callable function', '6.x' ); + + continue; + } + // Avoid the array_slice() if possible. if ( 0 == $the_['accepted_args'] ) { $value = call_user_func( $the_['function'] );