This changeset includes a major iteration on the regular expression used to balance tags, with comprehensive test coverage to ensure that all scenarios are supported or unsupported as expected.
Props dmsnell, westonruter, birgire.
Fixes#47014.
git-svn-id: https://develop.svn.wordpress.org/trunk@45929 602fd350-edb4-49c9-b593-d223f7449a82
This changes the "discourage search engines" option to output a `noindex, nofollow` robots meta tag. `Disallow: /` is removed from the `robots.txt` to allow search engines to discover they are requested not to index the site.
Disallowing search engines from accessing a site in the `robots.txt` file can result in search engines listing a site with a fragment (a listing without content).
Props donmhico, jonoaldersonwp.
Fixes#43590.
git-svn-id: https://develop.svn.wordpress.org/trunk@45928 602fd350-edb4-49c9-b593-d223f7449a82
The tests were meant to check for the lack of a fatal error in case of invalid date input, not specifically mark a particular outcome as the correct one.
Props Rarst.
Fixes#28992.
git-svn-id: https://develop.svn.wordpress.org/trunk@45911 602fd350-edb4-49c9-b593-d223f7449a82
With this change, the result of a site or network lookup by ID will be cached even if the ID does not exist. When a new site or network is created, the cache for the respective new ID is cleared.
Props mnelson4, nielsdeblaauw.
Fixes#42251.
git-svn-id: https://develop.svn.wordpress.org/trunk@45910 602fd350-edb4-49c9-b593-d223f7449a82
Newly-supported array and object meta types should not be cast to strings.
Props TimothyBlynJacobs, caercam.
Fixes#47928.
git-svn-id: https://develop.svn.wordpress.org/trunk@45903 602fd350-edb4-49c9-b593-d223f7449a82
`wp_unique_term_slug()` appends numeric suffixes when the requested slug is
already in use by a sibling term. Changes introduced in [32837] inadvertently
caused this suffixing to be skipped in cases where the requested slug is
suffixed with the parent slug, so that it became possible to have two terms
`childslug-parentslug` underneath to the same `parentslug`. We fix this
regression by ensuring that the numeric-suffix routine runs in all cases.
Props yashar_hv, saskak, dlh.
Fixes#46431.
git-svn-id: https://develop.svn.wordpress.org/trunk@45893 602fd350-edb4-49c9-b593-d223f7449a82
When querying for terms in hierarchical categories using `hide_empty=true`,
results have historically included parent terms which are themselves
unattached to any objects (are "empty") but which have non-empty descendent
terms. Because this process involves walking the descendant tree, we avoid it
when we detect that the queried taxonomies are not hierarchical. (This
behavior was introduced in [5525].)
When the `taxonomy` parameter of `get_terms()` was made optional - see #35495,
[36614] - it affected the mechanism for avoiding unneccessary tree walks,
since there may not be any explicitly declared taxonomies to run through
`is_taxonomy_hierarchical()`. As a result, term queries excluding `taxonomy`
did not check descendants, and empty parents with non-empty children were not
included in `hide_empty` results.
We correct the behavior by crawling term descendants when the `taxonomy`
argument is absent, which means that we're querying for terms in all taxonomies.
Props smerriman.
Fixes#37728.
git-svn-id: https://develop.svn.wordpress.org/trunk@45888 602fd350-edb4-49c9-b593-d223f7449a82
Only add the `notice-` prefix for `error`, `success`, `warning`, `info` CSS classes, keep other classes as is.
Add unit tests for `settings_errors()`.
Props afercia, SergeyBiryukov.
Fixes#44941.
git-svn-id: https://develop.svn.wordpress.org/trunk@45873 602fd350-edb4-49c9-b593-d223f7449a82
* Restore default timezone before performing assertions to avoid affecting other tests in case of failure.
* Use delta comparison for timestamps to avoid race conditions.
Props SergeyBiryukov, desrosj.
Fixes#45821.
git-svn-id: https://develop.svn.wordpress.org/trunk@45857 602fd350-edb4-49c9-b593-d223f7449a82
Only use the legacy WP timestamp approach (a sum of timestamp and timezone offset) for `timestamp` and `U` formats without the `$gmt` flag.
Otherwise, make sure the function returns correct local time for any format.
Props Rarst, jdgrimes.
Fixes#40653.
git-svn-id: https://develop.svn.wordpress.org/trunk@45856 602fd350-edb4-49c9-b593-d223f7449a82
* `wp_timezone_string()` retrieves the timezone from current settings as a string. Uses the `timezone_string` option to get a proper timezone if available, otherwise falls back to an offset.
* `wp_timezone()` retrieves the timezone from current settings as a `DateTimeZone` object. Timezone can be based on a PHP timezone string or a `±HH:MM` offset.
Props Rarst, remcotolsma, johnjamesjacoby, rmccue.
Fixes#24730.
git-svn-id: https://develop.svn.wordpress.org/trunk@45853 602fd350-edb4-49c9-b593-d223f7449a82
These tests are now also run as their own part of the Travis build, to ensure performance of other tests isn't affected by the presence of xdebug.
Fixes#40532.
git-svn-id: https://develop.svn.wordpress.org/trunk@45827 602fd350-edb4-49c9-b593-d223f7449a82
Prevents a non-sequential post type array such as [ 0 => 'post', 2 => 'page' ] from being improperly converted to an object in the taxonomy endpoint's response JSON.
Props TimothyBlynJacobs, birgire, spectacula.
Fixes#42209.
git-svn-id: https://develop.svn.wordpress.org/trunk@45813 602fd350-edb4-49c9-b593-d223f7449a82
Allowing the client to delete revisions breaks the "audit trail" functionality. This is not allowed in WordPress and shouldn't be allowed through the API.
While not recommended, a plugin may opt-in to the previous behavior by setting a custom 'delete_post' capability for the revisions post type.
Props dlh, danielbachhuber, TimothyBlynJacobs, azaozz, kadamwhite.
Fixes#43709.
git-svn-id: https://develop.svn.wordpress.org/trunk@45812 602fd350-edb4-49c9-b593-d223f7449a82
Caches the output of get_item_schema() to avoid redundant recomputation of translatable strings and other computed values. This method is called many times per item in each REST request, and the results of the method should not vary between calls.
Additional schema fields are not cached.
Props kadamwhite, joehoyle, TimothyBlynJacobs.
Fixes#47871.
git-svn-id: https://develop.svn.wordpress.org/trunk@45811 602fd350-edb4-49c9-b593-d223f7449a82
Status code 204 should indicate no response body is sent. Previously, a "null" string was sent, which MacOS Safari would try to parse as JSON and thereby fail to complete the request.
Props TimothyBlynJacobs, andizer, matthias.thiel.
Fixes#43691.
git-svn-id: https://develop.svn.wordpress.org/trunk@45809 602fd350-edb4-49c9-b593-d223f7449a82
Extends meta registration to support complex schema values, mirroring the functionality in the settings controller.
Error when trying to modify a meta key containing schema-nonconformant data.
Props @TimothyBlynJacobs, @birgire, @mnelson4, @flixos90.
Fixes#43392.
git-svn-id: https://develop.svn.wordpress.org/trunk@45807 602fd350-edb4-49c9-b593-d223f7449a82
Include the post's permalink when generating reply links in `get_comment_reply_link()` to account for comments displayed on index and archive pages.
This reapplies [32786] which was inadvertently reverted in [42360].
Props justinahinon, donmhico.
See #33383.
Fixes#47174.
git-svn-id: https://develop.svn.wordpress.org/trunk@45787 602fd350-edb4-49c9-b593-d223f7449a82
Additionally, there are a handful of related minor changes in this commit:
- `.travis.yml` has been tidied up a little.
- [45745] was incorrectly marking Travis jobs as passed when some PHPUnit runs failed.
- Add the `LOCAL_PHP_MEMCACHED` environment variable, for enabling Memcached.
- Add the `env:pull` NPM script, for refreshing Docker images.
See #47767.
git-svn-id: https://develop.svn.wordpress.org/trunk@45762 602fd350-edb4-49c9-b593-d223f7449a82
In `WP_REST_Controller::get_fields_for_response()`, exclude fields which are not registered to appear in the request's context.
In conjunction with r45705 this prevents the unnecessary computation of the sample permalink when making a request that is not context=edit.
Props dlh.
Fixes#45605.
git-svn-id: https://develop.svn.wordpress.org/trunk@45706 602fd350-edb4-49c9-b593-d223f7449a82
Plugins may not be on the same host/path as the rest of the content. To support loading translations for this setup check if the script source matches `plugins_url()`.
Also fixes an undefined index notice when a custom content URL has no path.
Props odminstudios, ocean90.
Fixes#46336, #46387.
git-svn-id: https://develop.svn.wordpress.org/trunk@45685 602fd350-edb4-49c9-b593-d223f7449a82
This renames the file containing the `WP_oEmbed` class to conform to the coding standards.
This commit also includes:
- A new `class-oembed.php` that includes the new file, for anyone that may've been including the file directly.
- Replaces references to the old filename with the new filename.
See #47632.
git-svn-id: https://develop.svn.wordpress.org/trunk@45663 602fd350-edb4-49c9-b593-d223f7449a82
This renames the file containing the `Custom_Image_Header` class to conform to the coding standards.
This commit also includes:
- A new `custom-header.php` that includes the new file, for anyone that may've been including the file directly.
- Replaces references to the old filename with the new filename.
See #47632.
git-svn-id: https://develop.svn.wordpress.org/trunk@45654 602fd350-edb4-49c9-b593-d223f7449a82
PHP 7.4 addes a warning when trying access a null/bool/int/float/resource (everything but array, string and object) as if it were an array.
This change fixes all of these warnings visible in unit tests.
Props jrf.
See #47704.
git-svn-id: https://develop.svn.wordpress.org/trunk@45639 602fd350-edb4-49c9-b593-d223f7449a82
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
`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
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
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
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
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
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
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
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
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
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
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
* 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
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
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
`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
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
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
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
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
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