From ecec228c5070878e143e28803efae2b131b503ee Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 14 Jul 2017 12:45:44 +0000 Subject: [PATCH] Emoji: Store the results of the `emoji_url` and `emoji_ext` filters in statics. Previously, these filters were being run once per post, but the changes in [41043] caused them to be run once per emoji found. We will not stand idly by while this kind of unfair performance penalty is placed on the emoji literate. The filters are now run once only, emoji aficionados everywhere can rest easy, knowing their posts will be just as performant as their emoji-less cousins. Props ocean90 for noticing this severe oversight. See #35293. Built from https://develop.svn.wordpress.org/trunk@41046 git-svn-id: http://core.svn.wordpress.org/trunk@40896 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 18 ++++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index fd01b551bb..824552e380 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -5192,15 +5192,25 @@ function wp_staticize_emoji( $text ) { * @since 4.8.1 * @access private * + * @see wp_staticize_emoji() + * @staticvar string $cdn_url The CDN url returned by the {@see 'emoji_url'} filter. + * @staticvar string $ext The file extension returned by the {@see 'emoji_ext'} filter. + * * @param array $matches The matched data. * @return string HTML for the static emoji image. */ function _wp_staticize_emoji( $matches ) { - /** This filter is documented in wp-includes/formatting.php */ - $cdn_url = apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/2.3/72x72/' ); + static $cdn_url; + if ( ! $cdn_url ) { + /** This filter is documented in wp-includes/formatting.php */ + $cdn_url = apply_filters( 'emoji_url', 'https://s.w.org/images/core/emoji/2.3/72x72/' ); + } - /** This filter is documented in wp-includes/formatting.php */ - $ext = apply_filters( 'emoji_ext', '.png' ); + static $ext; + if ( ! $ext ) { + /** This filter is documented in wp-includes/formatting.php */ + $ext = apply_filters( 'emoji_ext', '.png' ); + } $char = str_replace( ';&#x', '-', $matches[1] ); $char = str_replace( array( '&#x', ';'), '', $char ); diff --git a/wp-includes/version.php b/wp-includes/version.php index c5f945efe4..c268353105 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41045'; +$wp_version = '4.9-alpha-41046'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.