Make WordPress Core


Ignore:
Timestamp:
10/03/2017 07:11:28 AM (8 years ago)
Author:
pento
Message:

Emoji: Bring Twemoji compatibility to PHP.

This was previously attempted in [41043], which unfortunately had severe performance issues, the regex it used was fatally slow on long posts.

This version now uses an array of all emoji that Twemoji supports, which maintains the accuracy of [41043], while being the same speed or only a few ms slower than the code prior to [41043].

As with [41043], the grunt precommit:emoji task detects when twemoji.js has changed, and regenerates the array.

Props jmdodd for feedback, suggestions, and insults where appropriate.
Fixes #35293. 🤞🏻

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/Emoji.php

    r41045 r41701  
    6363
    6464    /**
    65      * @ticket 35293
     65     * @ticket 41501
    6666     */
    67     public function test_wp_emoji_regex_returns_regexen() {
    68         $default = wp_emoji_regex();
     67    public function test_wp_emoji_list_returns_data() {
     68        $default = _wp_emoji_list();
    6969        $this->assertNotEmpty( $default );
    7070
    71         $codepoints = wp_emoji_regex( 'codepoints' );
    72         $this->assertNotEmpty( $codepoints );
    73 
    74         $this->assertSame( $default, $codepoints );
    75 
    76         $entities = wp_emoji_regex( 'entities' );
     71        $entities = _wp_emoji_list( 'entities' );
    7772        $this->assertNotEmpty( $entities );
    7873
    79         $this->assertNotSame( $default, $entities );
     74        $this->assertSame( $default, $entities );
     75
     76        $partials = _wp_emoji_list( 'partials' );
     77        $this->assertNotEmpty( $partials );
     78
     79        $this->assertNotSame( $default, $partials );
    8080    }
    8181
Note: See TracChangeset for help on using the changeset viewer.