Commit Graph

3029 Commits

Author SHA1 Message Date
Gary Pendergast c6c78490e2 Coding Standards: Fix the remaining issues in `/tests`.
All PHP files in `/tests` now conform to the PHP coding standards, or have exceptions appropriately marked.

Travis now also runs `phpcs` on the `/tests` directory, any future changes to these files must conform entirely to the WordPress PHP coding standards. 🎉

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45607 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-08 00:55:20 +00:00
Gary Pendergast 18ec05e23a Coding Standards: Fix all `WordPress.DB.PreparedSQLPlaceholders` issues.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45603 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-05 05:42:57 +00:00
Gary Pendergast 6acb0c6402 Coding Standards: Fix all `WordPress.WhiteSpace.PrecisionAlignment` issues.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45602 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-05 05:20:52 +00:00
Gary Pendergast a00c69458b Formatting: Revert the changes to `wpautop()` in [45585,45587].
See #27350.


git-svn-id: https://develop.svn.wordpress.org/trunk@45589 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 11:21:53 +00:00
Gary Pendergast fe28df65e3 Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `tests`.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45588 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 04:43:01 +00:00
Gary Pendergast 8298f9dad0 Clean up stray `<p>` tags added by `wpautop()` inside block level tags.
`autop()` can sometimes get confused and not clean up stray `<p>` or `</p>` tags inside block level elements, which produces sub-optimal HTML. While browsers can generally handle it, there's no need to make things harder for them if we don't have to.

Props pento, ayubi, pbearne, jond, azaozz, 1994rstefan, dionysous, MikeHansenMe, jorbin, miqrogroove, niallkennedy.
Fixes #27350.




git-svn-id: https://develop.svn.wordpress.org/trunk@45585 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 01:30:15 +00:00
Adam Silverstein b97899a07f Taxonomy: add a new 'terms_pre_query' filter to short circuit WP_Term_Query 'get_terms' queries.
Add a new `terms_pre_query` filter which returns null by default. Return a non-null value to bypass WordPress's default `get_terms` queries.

Props jarocks, boonebgorges, spacedmonkey.
Fixes #41246.



git-svn-id: https://develop.svn.wordpress.org/trunk@45584 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 20:47:21 +00:00
Gary Pendergast ef5a9dfda6 Coding Standards: Fix/ignore the `WordPress.NamingConventions.ValidFunctionName` violations.
See #47632



git-svn-id: https://develop.svn.wordpress.org/trunk@45580 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 08:00:12 +00:00
Gary Pendergast 78e096fe98 Formatting: Trim leading whitespace in `esc_url()`.
Props toszcze.
Fixes #36369.



git-svn-id: https://develop.svn.wordpress.org/trunk@45578 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 03:28:21 +00:00
Gary Pendergast 77f9bf0aeb Formatting: Don't add `<p>` tags inside `<svg>` tags.
Inline `<svg>`s should generally work, as browsers should just ignore `<p>` or `<br/>` tags that shouldn't be inside the `<svg>`. To keep things neat, however, it's better not add them in the first place.

Props jared_smith, nacin, pento.
Fixes #9437.



git-svn-id: https://develop.svn.wordpress.org/trunk@45577 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 03:18:28 +00:00
Gary Pendergast 77764a5754 Formatting: Add correct `<p>` tags near `<hr>` tags.
It can be tricky to know when `wpautop()` should add `<p>` tags, but one thing we can be certain about is that they really shouldn't be anywhere near `<hr>` tags.

Now they aren't.

Props solarissmoke, MattyRob, pento.
Fixes #14674.



git-svn-id: https://develop.svn.wordpress.org/trunk@45574 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-28 07:15:31 +00:00
Gary Pendergast b9cd66f483 Formatting: Add support for seconds to `human_time_diff()`.
The web has gotten so much faster since `human_time_diff()` was created, we need to be able to measure time differences with much finer granularity. Now, we can.

Props johnjamesjacoby, pento.
Fixes #35655.



git-svn-id: https://develop.svn.wordpress.org/trunk@45573 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-28 06:43:27 +00:00
Gary Pendergast 3202f9f37e Formatting: Don't convert smilies in ignored tags that have attributes.
Smilies in ignored tags are not supposed to be converted to emoji, but this can malfunction if the tag has attributes. For example, the Preformatted block with add a `class` to the `<pre>` tag.

Props pento, jikamens.
Fixes #47489.



git-svn-id: https://develop.svn.wordpress.org/trunk@45569 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-27 02:04:17 +00:00
Sergey Biryukov e283457e45 Date/Time: Add more supported formats to `wp_maybe_decline_date()`.
Props SergeyBiryukov, Rarst.
Fixes #37411.

git-svn-id: https://develop.svn.wordpress.org/trunk@45555 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-20 13:46:20 +00:00
Peter Wilson 66f7cee321 Site health: Introduce `view_site_health_checks` capability.
Introduces the faux primitive capability `view_site_health_checks` available to single site admins and multisite super-admin to view the site health page within the admin.

The capability is mapped to the `install_plugins` capability without being dependent on the file system being writable. This fixes a bug where the feature couldn't be used by sites unable to write to the file system or managed through version control.

The capability is granted on the `user_has_cap` filter.

Props birgire, Clorith, palmiak, peterwilsoncc, spacedmonkey.
Fixes #46957.



git-svn-id: https://develop.svn.wordpress.org/trunk@45507 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-10 07:41:12 +00:00
John Blackbourn 393960b182 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


git-svn-id: https://develop.svn.wordpress.org/trunk@45505 602fd350-edb4-49c9-b593-d223f7449a82
2019-06-08 18:41:08 +00:00
Sergey Biryukov af0c73b10b Build/Test Tools: Add `$current_screen` to the list of globals to unset in `WP_UnitTestCase_Base::go_to()`.
Props mauteri.
Fixes #47439.

git-svn-id: https://develop.svn.wordpress.org/trunk@45486 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-31 14:06:27 +00:00
Andrew Ozz 3337e709ee Fix unit tests after [45456]. The query string is a bit different but the results are the same.
See #45346.

git-svn-id: https://develop.svn.wordpress.org/trunk@45458 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-28 04:18:53 +00:00
John Blackbourn 814aa7149f 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


git-svn-id: https://develop.svn.wordpress.org/trunk@45445 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-26 19:34:24 +00:00
Sergey Biryukov 10855438ea 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@45424 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-26 00:11:37 +00:00
John Blackbourn b64f812a59 Docs: Switch to the more common syntax for variadic function documentation.
See #37402


git-svn-id: https://develop.svn.wordpress.org/trunk@45418 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-25 21:58:18 +00:00
Sergey Biryukov cfd2e38db3 Docs: Remove full stop from ticket number.
See #46402.

git-svn-id: https://develop.svn.wordpress.org/trunk@45409 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-25 12:08:11 +00:00
Sergey Biryukov bda3af14b0 Formatting: Don't run `wp_targeted_link_rel()` on entirely serialized content.
Props birgire, elliotcondon.
Fixes #46402.

git-svn-id: https://develop.svn.wordpress.org/trunk@45408 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-25 12:04:28 +00:00
Sergey Biryukov 2a163fa733 Date/Time: Return early from `the_weekday()` and `the_weekday_date()` if we're not in the loop.
Restore `$previousweekday` global usage in `the_weekday_date()`, so it could still be used simultaneously with `the_date()`.

Partially reverts [45378].
See #47354.

git-svn-id: https://develop.svn.wordpress.org/trunk@45379 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-23 00:37:56 +00:00
Sergey Biryukov 48fb69f013 Date/Time: Bring some consistency to `the_date()` and `the_weekday_date()`:
* Make `the_date()` always apply the the filter and return a value.
* Use `is_new_day()` in `the_weekday_date()`.
* Add a unit test for `the_weekday_date()`.

Fixes #47354.

git-svn-id: https://develop.svn.wordpress.org/trunk@45378 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-22 21:57:29 +00:00
Sergey Biryukov 6491746559 Date/Time: Use strict comparison in `is_new_day()`, add a unit test.
Props pbearne.
Fixes #46627.

git-svn-id: https://develop.svn.wordpress.org/trunk@45375 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-22 17:52:22 +00:00
Jonathan Desrosiers f9e4f60577 General: Add missing unit tests for `wp_array_slice_assoc()`.
Props pbearne, desrosj.
Fixes #46638.

git-svn-id: https://develop.svn.wordpress.org/trunk@45371 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-21 14:47:58 +00:00
Peter Wilson b9e6f18350 KSES: Add `flex` and related long form properties to safe CSS.
Allow `flex`, `flex-grow`, `flex-shrink` and `flex-basis` to be used in inline CSS. As of WordPress 5.3 the block editor is expected to use `flex-basis` inline to set the width in the column block.

Props aduth.
Fixes #47281.
See #37248.



git-svn-id: https://develop.svn.wordpress.org/trunk@45363 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-18 04:33:27 +00:00
Sergey Biryukov a36aa1b078 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@45348 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-17 12:08:50 +00:00
Alex Shiels 85a90cb244 Upgrade/Install: Don't run signature verify on slow 32-bit systems.
The sodium_compat library can be very slow for certain operations on 32-bit architectures, which can lead to web server timeouts while attempting to verify an update. This adds a runtime speed check to skip signature verification on systems that would otherwise time out. Includes simple unit tests.

Props dd32, paragoninitiativeenterprises.
See #47186.


git-svn-id: https://develop.svn.wordpress.org/trunk@45345 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-17 11:05:45 +00:00
Andrew Ozz 96649a5ad1 Fix `setup_postdata()` to set the (inside the loop) globals before `the_post` action is fired. Follow-up from #42814 and [44941].
Props david.binda, spacedmonkey, boonebgorges, birgire, jorbin, azaozz.
Fixes #47114 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@45285 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-04 20:59:11 +00:00
Gary Pendergast 3491bfc7e5 Media: Revert [44947].
`get_available_post_mime_types()` uses a query that's extremely slow on sites with lots of posts. The original fix can be revisited after those performance issues are tackled.

See #43658.


git-svn-id: https://develop.svn.wordpress.org/trunk@45270 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-26 00:43:50 +00:00
Andrew Ozz 71832fe328 Fix parsing of inner blocks when auto-generating an excerpt. Helps to prevent cases where dynamic inner blocks may cause an infinite loop if trying to auto-generate an excerpt.
Props desrosj, pento, gziolo, azaozz.
Fixes #46133.

git-svn-id: https://develop.svn.wordpress.org/trunk@45265 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-24 21:38:21 +00:00
Andrew Ozz 361333e7e2 Remove the `core/more` block delimiters when splitting post_content on the `<!--more-->` tag.
Fixes:
- Parsing of blocks in the second half of post_content.
- Outputting malformed HTML when `the_content( null, true )` or  `<!--noteaser-->` is used.

Props lukecarbis, garrett-eclipse, birgire.
Fixes #46471.

git-svn-id: https://develop.svn.wordpress.org/trunk@45261 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-24 05:40:01 +00:00
Adam Silverstein 9e3c57c2ff Feeds: improve structure and naming of feed build date helper function.
Simplify overall code structure by passing the required format to the helper function.
Clarify functionality by renaming `get_last_build_date` to `get_feed_build_date`.

Props pento, spacedmonkey.
Fixes #4575.



git-svn-id: https://develop.svn.wordpress.org/trunk@45247 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-18 17:07:07 +00:00
Jonathan Desrosiers d575d70fe9 Administration: Improve the accuracy of `is_block_editor()`.
Currently, there are a number of scenarios where `is_block_editor()` (and `WP_Screen::is_block_editor`) would incorrectly indicate block editor support at different points of the loading process. Most notably, checking `is_block_editor` when hooking into the `current_screen` action will always result in `false`, even when the block editor is being loaded. This is because `is_block_editor` is not set to `true` until `edit-form-blocks.php` is included.

This change adds logic to `WP_Screen` to ensure the accuracy of `is_block_editor` on block editor pages earlier in the load process.

While edit screens will now be accurate 100% of the time from `current_screen` on, there are still a few edge cases where `is_block_editor` could contain an incorrect value when creating a new post.

Because a `WP_Post` object is a required parameter for the `replace_editor` filter and `use_block_editor_for_post()` function, `WP_Screen` will fall back to the value returned by `use_block_editor_for_post_type()` for the post being created. To eliminate these edge cases, the `use_block_editor_for_post_type` filter can be used to return the appropriate boolean value to indicate support.

Props Chouby, desrosj, aduth, johnbillion.
Fixes #46195.

git-svn-id: https://develop.svn.wordpress.org/trunk@45224 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-17 01:55:21 +00:00
Felix Arntz aa377f582d Bootstrap/Load: Allow more than one recovery link to be valid at a time.
While currently a recovery link is only made available via the admin email address, this will be expanded in the future. In order to accomplish that, the mechanisms to store and validate recovery keys must support multiple keys to be valid at the same time.

This changeset adds that support, adding an additional token parameter which is part of a recovery link in addition to the key. A key itself is always associated with a token, so the two are only valid in combination. These associations are stored in a new `recovery_keys` option, which is regularly cleared in a new Cron hook, to prevent potential cluttering from unused recovery keys.

This changeset does not have any user-facing implications otherwise.

Props pbearne, timothyblynjacobs.
Fixes #46595. See #46130.


git-svn-id: https://develop.svn.wordpress.org/trunk@45211 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-16 05:08:16 +00:00
Sergey Biryukov 80817d3209 Bootstrap/Load: After [45016], make sure `wp_die()` does not cause `_doing_it_wrong()` notices if called before `$wp_query` global is set.
Props tmdesigned, TimothyBlynJacobs.
Fixes #46813.

git-svn-id: https://develop.svn.wordpress.org/trunk@45206 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-15 23:48:11 +00:00
John Blackbourn dde307d4c9 Build/Test tools: Add some docs to the test functions.
Props andizer

Fixes #46501


git-svn-id: https://develop.svn.wordpress.org/trunk@45160 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-11 17:29:20 +00:00
Gary Pendergast 6dddce67fc Privacy: Only mark a personal data export as complete when the user downloads it.
An admin may download an export to check that it's all correct, but this action shouldn't mark the request as complete.

Props garrett-eclipse, JoshuaWold, birgire.
Fixes #44644.



git-svn-id: https://develop.svn.wordpress.org/trunk@45148 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-09 00:03:07 +00:00
Gary Pendergast cfebdd3752 Widgets: Add `rel="noopener noreferrer"` to links with `target="_blank"` in the Image widget.
Props audrasjb, welcher, afercia.
Fixes #43280.



git-svn-id: https://develop.svn.wordpress.org/trunk@45144 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 23:22:14 +00:00
Gary Pendergast 5dfdc9b9c4 Widgets: Add `rel="noopener noreferrer"` to links with `target="_blank"` in the Text and HTML widgets.
Props audrasjb, birgire, mukesh27.
Fixes #46421.



git-svn-id: https://develop.svn.wordpress.org/trunk@45143 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 23:17:35 +00:00
Gary Pendergast 466a7443a6 Menus: Add `rel="noopener"` to `target="_blank"` links by default in menus.
This expands upon `rel="noopener"` being previously added to links in the content.

Props audrasjb, welcher.
Fixes #43290.



git-svn-id: https://develop.svn.wordpress.org/trunk@45141 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 23:05:22 +00:00
Gary Pendergast edd6a1f129 Blocks: Allow for nested `the_content` calls within `do_blocks()`.
When `do_blocks()` is run, it sets up some special handling of the `wpautop` filter, as we don't want `wpautop` to run on block content, but we do want it to be available for subsequent runs of `the_content`, which may be happening on non-block content.

As we set this up before rendering dynamic blocks, however, a dynamic block choosing to run `the_content` will cause unintentially structural deficiences in this particular recursive block tower.

Moving this handling to after dynamic blocks are rendered makes our tower lean a little less.

Props aldavigdis, pento.
Fixes #45495.



git-svn-id: https://develop.svn.wordpress.org/trunk@45139 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 06:53:14 +00:00
Gary Pendergast 3652d05fcf HTTP: Add support for the `host-only` flag to `Wp_Http_Cookie`.
Props soulseekah.
Fixes #43231.


git-svn-id: https://develop.svn.wordpress.org/trunk@45135 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 05:31:35 +00:00
Gary Pendergast 11e97aae1e Emoji: Update Twemoji to version 12.0.0.
Props pento, superpoincare.
Fixes #46404, #46805.


git-svn-id: https://develop.svn.wordpress.org/trunk@45134 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 05:21:49 +00:00
Gary Pendergast 65e057daa2 Canonical: Ensure redirect query keys are URL encoded.
This prevents an infinite redirect loop when a request containing URL-encoded characters triggers `is_404()`.

Props soulseekah, wrwrwr0.
Fixes #43745.


git-svn-id: https://develop.svn.wordpress.org/trunk@45133 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-08 01:09:01 +00:00
Sergey Biryukov f6f02a327f Docs: Remove an empty line between `@param` and `@return` in the tests added in [45101], per documentation coding standards.
See #45029.

git-svn-id: https://develop.svn.wordpress.org/trunk@45103 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-02 22:21:19 +00:00
Sergey Biryukov ffbc0e3b4e Widgets: Make sure changes to media widgets' instance schema via `widget_{$this->id_base}_instance_schema` filter are not overridden by subclasses.
Add unit tests missed in [45100].

Props Toro_Unit, birgire.
See #45029.

git-svn-id: https://develop.svn.wordpress.org/trunk@45101 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-02 22:14:19 +00:00
Sergey Biryukov ee5f858436 PHPCS: Fix WPCS violation in [45088].
See #38168.

git-svn-id: https://develop.svn.wordpress.org/trunk@45090 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-01 16:48:32 +00:00