Commit Graph

667 Commits

Author SHA1 Message Date
John Blackbourn
c9b51df3d0 I18N: Allow the length of automatically generated excerpts to be localized.
This introduces three new strings that can be used to control the maximum length of automatically generated excerpts for posts, comments, and draft post previews in the dashboard. Optionally combined with the existing word count type control this allows languages which include many multibyte characters to specify more appropriate maximum excerpt lengths.

Props miyauchi, birgire, johnbillion

Fixes #44541

Built from https://develop.svn.wordpress.org/trunk@45505


git-svn-id: http://core.svn.wordpress.org/trunk@45316 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-06-08 18:42:52 +00:00
John Blackbourn
27365c4ec4 Build/Test Tools: Remove the dependency on a globally installed Grunt.
The existing `"grunt": "grunt"` script in `package.json` allows for the use of `npm run grunt ...` which uses the local `grunt` binary in the project's `node_modules`.

Fixes #47380

Built from https://develop.svn.wordpress.org/trunk@45445


git-svn-id: http://core.svn.wordpress.org/trunk@45256 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-26 19:35:51 +00:00
Sergey Biryukov
c77e771c84 Date/Time: Replace all instances of date() with gmdate().
Use of `date()` in core depends on PHP timezone set to UTC and not changed by third party code (which cannot be guaranteed).

`gmdate()` is functionally equivalent, but is not affected by PHP timezone setting: it's always UTC, which is the exact behavior the core needs.

Props nielsdeblaauw, Rarst.
Fixes #46438. See #44491.
Built from https://develop.svn.wordpress.org/trunk@45424


git-svn-id: http://core.svn.wordpress.org/trunk@45235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-26 00:12:54 +00:00
John Blackbourn
9c6393e967 Docs: Switch to the more common syntax for variadic function documentation.
See #37402

Built from https://develop.svn.wordpress.org/trunk@45418


git-svn-id: http://core.svn.wordpress.org/trunk@45229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-25 21:59:51 +00:00
Sergey Biryukov
a81dfbdf0e Formatting: Don't run wp_targeted_link_rel() on entirely serialized content.
Props birgire, elliotcondon.
Fixes #46402.
Built from https://develop.svn.wordpress.org/trunk@45408


git-svn-id: http://core.svn.wordpress.org/trunk@45219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-25 12:05:52 +00:00
Sergey Biryukov
c1f6c6877c Formatting: Adjust wp_targeted_link_rel() to ensure JSON format is preserved and correct quotes are used when adding the missing rel attribute.
Props birgire, TobiasBg, fierevere, audrasjb, SergeyBiryukov.
Fixes #46316, #47244.
Built from https://develop.svn.wordpress.org/trunk@45348


git-svn-id: http://core.svn.wordpress.org/trunk@45159 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-17 12:10:02 +00:00
Gary Pendergast
699f028f21 Emoji: Upgrade Twemoji to 12.0.1.
As this point release doesn't modify any images, only adding a few missing ones, we don't need to change the CDN location.

Props earnjam.
Fixes #46805.


Built from https://develop.svn.wordpress.org/trunk@45240


git-svn-id: http://core.svn.wordpress.org/trunk@45049 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-18 02:11:52 +00:00
Sergey Biryukov
3ab2803af2 Docs: Add missing @since tags for wp_targeted_link_rel() and wp_targeted_link_rel_callback().
See #43187, #46543.
Built from https://develop.svn.wordpress.org/trunk@45163


git-svn-id: http://core.svn.wordpress.org/trunk@44972 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-11 21:16:51 +00:00
Gary Pendergast
a125989772 Emoji: Update Twemoji to version 12.0.0.
Props pento, superpoincare.
Fixes #46404, #46805.

Built from https://develop.svn.wordpress.org/trunk@45134


git-svn-id: http://core.svn.wordpress.org/trunk@44943 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 05:22:51 +00:00
Boone Gorges
05fa2363ab Posts: Avoid the use of globals in get_the_content() and related functions.
This changeset introduces `$post` parameters to `get_the_content()` and
`wp_trim_excerpt()`. When a `$post` object is passed to one of these functions,
the functions will operate on the data from that object, rather than from the
post globals (`$authordata`, `$page`, etc). This ensures that the functions work
in a predictable manner when used outside of the regular post loop.

The global-mismatch problem is surfaced in cases where `get_the_excerpt()` is
called outside of the post loop, on posts that don't have a defined excerpt. In
these cases, the post globals - used to generate a fallback excerpt - may refer
to the incorrect object, resulting in PHP notices or other unpredictable
behavior. See #36934 for a related issue.

Props spacedmonkey, kraftbj, Shital Patel.
Fixes #42814.
Built from https://develop.svn.wordpress.org/trunk@44941


git-svn-id: http://core.svn.wordpress.org/trunk@44772 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-20 15:49:49 +00:00
Sergey Biryukov
c4f8bc468d PHPCS: Fix errors introduced in [44833].
Built from https://develop.svn.wordpress.org/trunk@44858


git-svn-id: http://core.svn.wordpress.org/trunk@44690 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-12 22:56:49 +00:00
Sergey Biryukov
2504efcf94 Formatting: Improve rel="nofollow" handling in comments.
Built from https://develop.svn.wordpress.org/trunk@44833


git-svn-id: http://core.svn.wordpress.org/trunk@44665 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-12 22:15:50 +00:00
Gary Pendergast
cddee8b72e Formatting: Loosen the type checking in _sanitize_text_fields().
[44618] added strict type checking to `_sanitize_text_fields()`, which has caused some compat issues with plugins.

We can loosen the type checking to only reject objects and arrays, and cast other types to string.

Props Nick_theGeek, pento.
Fixes #41450.


Built from https://develop.svn.wordpress.org/trunk@44731


git-svn-id: http://core.svn.wordpress.org/trunk@44562 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-02-07 23:35:49 +00:00
Peter Wilson
d9a1f99d9c Customize: Remove wp_targeted_link_rel pre-save filter from change-sets.
The pre-save filters added to links in [43732] could invalidate JSON data when saving Customizer change-sets.

This removes the filters when saving and publishing change-sets.

Props peterwilsoncc, nikeo for testing.
See #45292.


Built from https://develop.svn.wordpress.org/trunk@44714


git-svn-id: http://core.svn.wordpress.org/trunk@44545 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-29 21:29:50 +00:00
Peter Wilson
24e8467c6f Formatting: Prevent wp_targeted_link_rel() adding an empty attribute.
Bypass adding a `rel` attribute when the `wp_targeted_link_rel` filter returns an empty string or other falsy result.

Props mcmwebsol, spartank, meatman89fs.
Fixes #45352.

Built from https://develop.svn.wordpress.org/trunk@44691


git-svn-id: http://core.svn.wordpress.org/trunk@44522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-22 21:55:51 +00:00
Gary Pendergast
0ee053758e Emoji: Upgrade Twemoji to 11.2.0.
This upgrade includes general improvements to the style of a variety of emoji.

Full changelog: https://github.com/twitter/twemoji/compare/v11.0.0...v11.2.0

Props desrosj, pento.
Fixes #45133.


Built from https://develop.svn.wordpress.org/trunk@44644


git-svn-id: http://core.svn.wordpress.org/trunk@44475 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-18 01:42:50 +00:00
Gary Pendergast
dcdfd7f412 Docs: Fix the last handful of incorrect @since 5.0.0 docblock tags.
Props peterwilsoncc.
Fixes #45543.


Built from https://develop.svn.wordpress.org/trunk@44635


git-svn-id: http://core.svn.wordpress.org/trunk@44466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-17 06:46:50 +00:00
Gary Pendergast
077af6e47d Docs: Improve the sanitize_email filter.
- Remove duplicate parameter names.
- Fix the wrong value being passed in the second parameter.
- Correct the type of the `$message` parameter.

Props ChriCo.
Fixes #45595.


Built from https://develop.svn.wordpress.org/trunk@44620


git-svn-id: http://core.svn.wordpress.org/trunk@44451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-16 06:16:49 +00:00
Gary Pendergast
0bbb277ee4 Formatting: Add type checking to _sanitize_text_fields().
When a non-string value is passed, return an empty string.

Props Mte90.
Fixes #41450.


Built from https://develop.svn.wordpress.org/trunk@44618


git-svn-id: http://core.svn.wordpress.org/trunk@44449 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-16 06:05:49 +00:00
Gary Pendergast
10c66fb426 Formatting: Remove soft hyphens when sanitising titles.
Props andg.
Fixes #45378.


Built from https://develop.svn.wordpress.org/trunk@44579


git-svn-id: http://core.svn.wordpress.org/trunk@44410 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-14 05:39:51 +00:00
Gary Pendergast
4f861b9548 Coding Standards: Fix the Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace violations.
See #45934.


Built from https://develop.svn.wordpress.org/trunk@44566


git-svn-id: http://core.svn.wordpress.org/trunk@44397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-11 06:40:50 +00:00
Gary Pendergast
8e623691c0 Emoji: Fix a code formatting error introduced in [44554].
See #45930.


Built from https://develop.svn.wordpress.org/trunk@44556


git-svn-id: http://core.svn.wordpress.org/trunk@44387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-10 23:40:49 +00:00
Gary Pendergast
92146fe52b Emoji: Improve performance when encoding or staticizing emoji.
Both `wp_encode_emoji()` and `wp_staticize_emoji()` perform a PHP version check when deciding how to apply their behaviour, but this check only needs to happen once, rather than every time in their internal looks.

Moving the check outside of the loop reduces processing time by 50%.

Props johnbillion.
Fixes #45930.


Built from https://develop.svn.wordpress.org/trunk@44554


git-svn-id: http://core.svn.wordpress.org/trunk@44385 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-10 23:20:52 +00:00
desrosj
9d7aa3436e Block Editor: Update @wordpress dependencies.
Changes of note:

- Includes the new Annotations API package.
- `wp-polyfill-ecmascript.js` is renamed to `wp-polyfill.js`.
- `strip_dynamic_blocks()` has been removed in favor of `excerpt_remove_blocks()`.
- The PHP block parser is now syncing from the `block-serialization-default-parser` package.
- `do_blocks()` uses the new parser.
- The `do_block` filter has been removed from `do_blocks()`, in favor of a `render_block` filter in `render_block()`.

Also, a little cleanup to `render_block()`. Always normalize `$block['attrs’]` to array in `’render_block’` filter.
Props pento, azaozz.

Merges [43884] and [43888] to trunk.

See #45145, #45190, #45264, #45282.
Built from https://develop.svn.wordpress.org/trunk@44261


git-svn-id: http://core.svn.wordpress.org/trunk@44091 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-17 04:52:00 +00:00
Jeremy Felt
7509965a56 Formatting: Ensure wpautop() isn't run on content generated from blocks.
As `do_blocks()` is run before `wpautop()` in the_content filter, we can remove in a Just In Time fashion, before that filter is run.

After `wpautop()`s original priority has passed, we can re-add it in a Just Too Late fashion, to ensure it's available if `the_content` filter is run multiple times on a page load.

Merges [43879] and [43881] from the 5.0 branch to trunk.

Props pento, nerrad.
Fixes #45290.

Built from https://develop.svn.wordpress.org/trunk@44226


git-svn-id: http://core.svn.wordpress.org/trunk@44056 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-17 03:06:12 +00:00
desrosj
c2f3636e4a Blocks: Parse blocks when displaying posts.
Posts containing blocks are now correctly handled when displaying on the front end, including dynamic blocks and nested blocks.

Props pento.

Merges [43752] to trunk.

See #45109.
Built from https://develop.svn.wordpress.org/trunk@44118


git-svn-id: http://core.svn.wordpress.org/trunk@43948 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-13 22:22:38 +00:00
Gary Pendergast
56c162fbc9 Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.


Built from https://develop.svn.wordpress.org/trunk@43571


git-svn-id: http://core.svn.wordpress.org/trunk@43400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-08-17 01:51:36 +00:00
Gary Pendergast
0db068da94 Emoji: Update Twemoji to version 11.0.
{U+01F9B9}

Props kraftbj,
Fixes #44339.


Built from https://develop.svn.wordpress.org/trunk@43377


git-svn-id: http://core.svn.wordpress.org/trunk@43205 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-06-28 02:42:55 +00:00
Sergey Biryukov
4848a09b35 I18N: Use the actual placeholder instead of a number in translator comments if the corresponding string does not use numbered placeholders.
Add missing translator comments in `WP_Theme_Install_List_Table` and `wp_notify_postauthor()`.
Add missing commas in some translator comments.

Fixes #43523.
Built from https://develop.svn.wordpress.org/trunk@42827


git-svn-id: http://core.svn.wordpress.org/trunk@42657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-11 16:44:34 +00:00
Sergey Biryukov
4e9c3f916f Docs: Fix typos in _wp_emoji_list() description.
See #42505.
Built from https://develop.svn.wordpress.org/trunk@42821


git-svn-id: http://core.svn.wordpress.org/trunk@42651 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-10 01:50:30 +00:00
Andrew Ozz
de8936588c Add pre-save content filter to make target=_blank always secure.
Props notnownikki, iseulde, azaozz
Fixes #43187
Built from https://develop.svn.wordpress.org/trunk@42770


git-svn-id: http://core.svn.wordpress.org/trunk@42600 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-02 14:42:31 +00:00
Gary Pendergast
7d9c47d536 Emoji: Tweak the generated emoji arrays to not cause coding standards errors.
Props netweb, jrf.
Fixes #43150.


Built from https://develop.svn.wordpress.org/trunk@42610


git-svn-id: http://core.svn.wordpress.org/trunk@42439 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-01-25 01:06:31 +00:00
Peter Wilson
6bb7fcebf4 Emoji: Update Emoji browser support tests for Twemoji v2.4.0
Really, following [42598].

Fixes #42862 for trunk, really.

Built from https://develop.svn.wordpress.org/trunk@42602


git-svn-id: http://core.svn.wordpress.org/trunk@42431 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-01-24 22:02:30 +00:00
Sergey Biryukov
ee58ffcbe7 Emoji: Update emoji base URL in _print_emoji_detection_script() and wp_staticize_emoji().
Props pento.
Fixes #42862.
Built from https://develop.svn.wordpress.org/trunk@42590


git-svn-id: http://core.svn.wordpress.org/trunk@42419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-01-24 16:51:30 +00:00
Peter Wilson
09432d1aa6 Emoji: Update emoji regex for Twemoji to 2.4.0.
Build `src/wp-includes/formatting.php` following [42566].

Fixes #42862.


Built from https://develop.svn.wordpress.org/trunk@42579


git-svn-id: http://core.svn.wordpress.org/trunk@42408 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-01-23 21:12:31 +00:00
Pascal Birchler
5ecd978e74 Formatting: Fix typo in inline documentation of _deep_replace().
Props ixkaito.
Fixes #43134.

Built from https://develop.svn.wordpress.org/trunk@42530


git-svn-id: http://core.svn.wordpress.org/trunk@42359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-01-20 13:32:32 +00:00
Gary Pendergast
fbb1f9162b Formatting: Fix capital_P_dangit() not capital P-ing, dangit.
Unfortunately, in my overzealous desire to fix all the un-capitalised Ps, [42343] capitalled some Ps that intentionally should not be capitals.

This commit fixes the incorrectly capitalling of Ps, as well as including unit tests and PHPCS instructions to ensure we never capitulate to capitalisationing them again.

Props superdav42.
Fixes #43040.
Fixes #43041.


Built from https://develop.svn.wordpress.org/trunk@42429


git-svn-id: http://core.svn.wordpress.org/trunk@42259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-01-08 10:36:51 +00:00
Gary Pendergast
aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
Gary Pendergast
882db52bdd General: Add inline PHPCS options to leave regex indentation.
We have a handful of super long regexen that are written over multiple lines, as a collection of strings concatenated together. Each string is indented appropriately for the regex, but PHPCS doesn't recognised this, so defaults to removing the extra whitespace.

Disabling the `Squiz.Strings.ConcatenationSpacing.PaddingFound` rule for these blocks stops the extra whitespace from being removed.

See #41057.


Built from https://develop.svn.wordpress.org/trunk@42249


git-svn-id: http://core.svn.wordpress.org/trunk@42078 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-28 04:24:57 +00:00
Gary Pendergast
c90cfa3b50 General: Fix some precision alignment formatting warnings.
The WPCS `WordPress.WhiteSpace.PrecisionAlignment` rule throws warnings for a bunch of code that will likely cause issues for `wpcbf`. Fixing these manually beforehand gives us better auto-fixed results later.

See #41057.


Built from https://develop.svn.wordpress.org/trunk@42228


git-svn-id: http://core.svn.wordpress.org/trunk@42057 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-26 23:57:55 +00:00
Gary Pendergast
a2693fd860 Database: Restore numbered placeholders in wpdb::prepare().
[41496] removed support for numbered placeholders in queries send through `wpdb::prepare()`, which, despite being undocumented, were quite commonly used.

This change restores support for numbered placeholders (as well as a subset of placeholder formatting), while also adding extra checks to ensure the correct number of arguments are being passed to `wpdb::prepare()`, given the number of placeholders.

See #41925.


Built from https://develop.svn.wordpress.org/trunk@42056


git-svn-id: http://core.svn.wordpress.org/trunk@41885 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-31 12:00:49 +00:00
Gary Pendergast
369ad06c82 Emoji: Fix incorrect emoji encoding in PHP < 5.4.
[41701] included a bug with PHP < 5.4. Prior to then, `html_entity_decode()` decoded into `ISO-8859-1`, when we actually need it to use `UTF-8`.

Fixes #35293.


Built from https://develop.svn.wordpress.org/trunk@41702


git-svn-id: http://core.svn.wordpress.org/trunk@41536 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 09:57:47 +00:00
Gary Pendergast
a7a57df525 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. 🤞🏻


Built from https://develop.svn.wordpress.org/trunk@41701


git-svn-id: http://core.svn.wordpress.org/trunk@41535 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 07:12:50 +00:00
Peter Wilson
8294b40161 Emoji: Refactor browser support tests.
Moves the repeated code in the emoji browser support test to a function to reduced the potential for errors and follow DRY principles.

Renames the "emoji4" test "emoji" as unicode version specific tests were removed in [38869].

Props peterwilsoncc, pento for code review.
Fixes #41156.


Built from https://develop.svn.wordpress.org/trunk@41669


git-svn-id: http://core.svn.wordpress.org/trunk@41503 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 04:00:48 +00:00
Peter Wilson
10970701d7 Emoji: Invert value returned by UN test for accuracy.
The JavaScript testing for UN flag support was passing when it failed, and failing when it passes.

This inverts the result to take more traditional approach of returning the correct result.

Unprops Pento.
Fixes #41852.


Built from https://develop.svn.wordpress.org/trunk@41386


git-svn-id: http://core.svn.wordpress.org/trunk@41219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-17 22:52:47 +00:00
Sergey Biryukov
98995d46d1 Formatting: In sanitize_title_with_dashes(), convert forward slash to hyphen on save.
Props corvidism, jtsternberg, GhostToast, alxndr.
Fixes #10792.
Built from https://develop.svn.wordpress.org/trunk@41318


git-svn-id: http://core.svn.wordpress.org/trunk@41149 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-25 23:28:45 +00:00
Sergey Biryukov
3946198df8 Docs: Add @staticvar entries for get_html_split_regex() and _get_wptexturize_split_regex().
Props ajayghaghretiya1.
Fixes #41385.
Built from https://develop.svn.wordpress.org/trunk@41109


git-svn-id: http://core.svn.wordpress.org/trunk@40949 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-20 13:38:44 +00:00
Gary Pendergast
ecec228c50 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
2017-07-14 12:45:44 +00:00
Gary Pendergast
0fcd27ec31 Emoji: Fix some failing unit tests in PHP 5.2 and 5.3.
- Older versions of PHP don't know how to `html_entity_decode()` emoji.
- The fall back regex was a little too broad, catching characters that aren't emoji.

See #35293.


Built from https://develop.svn.wordpress.org/trunk@41045


git-svn-id: http://core.svn.wordpress.org/trunk@40895 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-14 11:50:43 +00:00
Gary Pendergast
b13bab3e53 Emoji: Port the Twemoji regex to PHP.
Previously, `wp_encode_emoji()` and `wp_staticize_emoji()` used inaccurate regular expressions to find emoji, and transform then into HTML entities or `<img>`s, respectively. This would result in emoji not being correctly transformed, or occasionally, non-emoji being incorrectly transformed.

This commit adds a new `grunt` task - `grunt precommit:emoji`. It finds the regex in `twemoji.js`, transforms it into a PHP-friendly version, and adds it to `formatting.php`. This task is also automatically run by `grunt precommit`, when it detects that `twemoji.js` has changed.

The new regex requires features introduced in PCRE 8.32, which was introduced in PHP 5.4.14, though it was also backported to later releases of the PHP 5.3 series. For versions of PHP that don't support this, it will fall back to an updated version of the loose-matching regex.

For short posts, the performance difference between the old and new regex is negligible. As the posts get longer, however, the new method is exponentially faster.

Fixes #35293.


Built from https://develop.svn.wordpress.org/trunk@41043


git-svn-id: http://core.svn.wordpress.org/trunk@40893 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-14 05:47:49 +00:00