From b36ed916e82962454e866c93233355645cb3b2e3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 24 Oct 2017 13:24:43 +0000 Subject: [PATCH] Formatting: Make sure `wp_allowed_protocols()` is filterable until `wp_loaded` has fired. Fixes the issue with plugins not being able to use the `kses_allowed_protocols` filter if `esc_url()` was called too early. Props turtlepod, SergeyBiryukov. Fixes #36033. git-svn-id: https://develop.svn.wordpress.org/trunk@41990 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index de0042ff32..0962da02f8 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -5077,7 +5077,9 @@ function wp_allowed_protocols() { if ( empty( $protocols ) ) { $protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp', 'webcal', 'urn' ); + } + if ( ! did_action( 'wp_loaded' ) ) { /** * Filters the list of protocols allowed in HTML attributes. * @@ -5085,7 +5087,7 @@ function wp_allowed_protocols() { * * @param array $protocols Array of allowed protocols e.g. 'http', 'ftp', 'tel', and more. */ - $protocols = apply_filters( 'kses_allowed_protocols', $protocols ); + $protocols = array_unique( (array) apply_filters( 'kses_allowed_protocols', $protocols ) ); } return $protocols;