Make WordPress Core

Ticket #35293: 35293.2.diff

File 35293.2.diff, 2.8 KB (added by pento, 9 years ago)
  • Gruntfile.js

     
    591591                                dest: '.'
    592592                        }
    593593                },
     594                replace: {
     595                        emojiRegex: {
     596                                options: {
     597                                        patterns: [
     598                                                {
     599                                                        match: /\/\/ START: emoji regex[\S\s]*\/\/ END: emoji regex/g,
     600                                                        replacement: function () {
     601                                                                var twemoji = grunt.file.read( SOURCE_DIR + 'wp-includes/js/twemoji.js' );
     602                                                                var found = twemoji.match( /re = \/(.*)\/g,/ );
     603                                                                var emojiRegex = found[1];
     604
     605                                                                // Magically transform emojiRegex into a PHP-friendly regex here.
     606
     607                                                                return "// START: emoji regex\n\treturn 'lol';\n\t// END: emoji regex";
     608                                                        }
     609                                                }
     610                                        ]
     611                                },
     612                                files: [
     613                                        {
     614                                                expand: true,
     615                                                flatten: true,
     616                                                src: [
     617                                                        SOURCE_DIR + 'wp-includes/formatting.php'
     618                                                ],
     619                                                dest: SOURCE_DIR + 'wp-includes/'
     620                                        }
     621                                ]
     622                        }
     623                },
    594624                _watch: {
    595625                        all: {
    596626                                files: [
     
    687717                'phpunit'
    688718        ] );
    689719
     720        grunt.registerTask( 'precommit:emoji', [
     721                'replace:emojiRegex'
     722        ] );
     723
    690724        grunt.registerTask( 'precommit', 'Runs test and build tasks in preparation for a commit', function() {
    691725                var done = this.async();
    692726                var map = {
     
    752786                                                        taskList.push( 'precommit:' + extension );
    753787                                                }
    754788                                        } );
     789
     790                                        if ( [ 'twemoji.js' ].some( testPath ) ) {
     791                                                grunt.log.writeln( 'twemoji.js has updated. Running `precomitt:emoji.' );
     792                                                taskList.push( 'precommit:emoji' );
     793                                        }
    755794                                }
    756795
    757796                                grunt.task.run( taskList );
  • package.json

     
    2727    "grunt-legacy-util": "^0.2.0",
    2828    "grunt-patch-wordpress": "~0.4.0",
    2929    "grunt-postcss": "~0.7.1",
     30    "grunt-replace": "~1.0.1",
    3031    "grunt-rtlcss": "~2.0.1",
    3132    "grunt-sass": "~1.1.0",
    3233    "matchdep": "~1.0.0"
  • src/wp-includes/formatting.php

     
    52095209}
    52105210
    52115211/**
     5212 * Returns a regex string to match all emoji that WordPress recognises.
     5213 *
     5214 * This regex is automatically built from the regex in twemoji.js - if it needs to be updated,
     5215 * you should update the regex there, then run the `grunt precommit:emoji` job.
     5216 *
     5217 * @since 4.6.0
     5218 *
     5219 * @return string A regex to match all emoji that WordPress recognises.
     5220 */
     5221function wp_emoji_regex() {
     5222        // Do not remove the START/END comments - they're used to find where to insert the regex.
     5223
     5224        // START: emoji regex
     5225        return 'lol';
     5226        // END: emoji regex
     5227}
     5228
     5229/**
    52125230 * Shorten a URL, to be used as link text.
    52135231 *
    52145232 * @since 1.2.0