From a89fdc393590e937caa6ad2373f0df8d77911c5a Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Wed, 29 Jun 2016 13:21:24 +0000 Subject: [PATCH] Plugins: Return the original value in `apply_filters_deprecated()` if no filter is registered for the tag. Props flixos90. Fixes #10441. git-svn-id: https://develop.svn.wordpress.org/trunk@37911 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/plugin.php | 2 +- tests/phpunit/tests/filters.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php index 44c45a6d7f..e01b0e2fe4 100644 --- a/src/wp-includes/plugin.php +++ b/src/wp-includes/plugin.php @@ -674,7 +674,7 @@ function remove_all_actions($tag, $priority = false) { */ function apply_filters_deprecated( $tag, $args, $version, $replacement = false, $message = null ) { if ( ! has_filter( $tag ) ) { - return; + return $args[0]; } _deprecated_hook( $tag, $version, $replacement, $message ); diff --git a/tests/phpunit/tests/filters.php b/tests/phpunit/tests/filters.php index b0bfcfb547..88fa71340c 100644 --- a/tests/phpunit/tests/filters.php +++ b/tests/phpunit/tests/filters.php @@ -359,4 +359,13 @@ class Tests_Filters extends WP_UnitTestCase { return $p1; } + + /** + * @ticket 10441 + */ + public function test_apply_filters_deprecated_without_filter() { + $val = 'Foobar'; + + $this->assertSame( $val, apply_filters_deprecated( 'tests_apply_filters_deprecated', array( $val ), '4.6' ) ); + } }