Commit Graph

3278 Commits

Author SHA1 Message Date
Sergey Biryukov
e5bee4ef68 Docs: Format multi-line comment in [46180] per the documentation standards.
See #45066.

git-svn-id: https://develop.svn.wordpress.org/trunk@46181 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-19 11:39:01 +00:00
Sergey Biryukov
a87122688b Tests: Update unit tests to account for the removal of old wp-a11y from the loaded scripts in [46179].
Props sstoqnov.
See #45066, #48071.

git-svn-id: https://develop.svn.wordpress.org/trunk@46180 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-19 11:14:38 +00:00
Boone Gorges
48e280db32 Improve do_enclose() logic on post publish.
Removing the direct SQL query in `do_all_pings()` improves filterability.

As part of this change, the signature of `do_enclose()` is changed so that
a null `$content` parameter can be passed, with the `$content` then inferred
from the `$post` passed in the second parameter. In addition, the second
parameter was modified so that a post ID or a `WP_Post` object can be
provided. These changes make it possible to trigger enclosure checks with
a post ID alone (as in `do_all_pings()`) and also brings the function
signature in line with `do_trackbacks()` and `pingback()`.

Props dshanske, spacedmonkey, janw.oostendorp, mrmadhat, birgire.
See #36824.

git-svn-id: https://develop.svn.wordpress.org/trunk@46175 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-19 01:48:54 +00:00
Jake Spurlock
3d40bbeef5 Add SMS to the list of allowed protocols.
This commit expands the list of allowed protocols. It adds the `sms://` which can be used to open meessaging clients for mobile users.

Props rilwis, kraftbj

Fixes #39415


git-svn-id: https://develop.svn.wordpress.org/trunk@46172 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-18 23:37:08 +00:00
Jake Spurlock
b8533a19b8 Accesibility: Replace wp-a11y.js with @wordpress/a11y package
Continuation of [46167]. This fixes the tests that ended up broken following the previous commit.

We've extracted wp-includes/wp-a11y.js to a reusable package wordpress/a11y which is published on NPM. Let's make sure this package is also 
used in WordPress core. Once all the JavaScript is built using webpack, we can also import this package wherever it is used and configure 
webpack to load is an external.

Props, garrett-eclipse

Fixes #45066



git-svn-id: https://develop.svn.wordpress.org/trunk@46169 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-18 22:29:53 +00:00
Jake Spurlock
8029e23ffe Accessibility: Replace wp-a11y.js with @wordpress/a11y package
We've extracted wp-includes/wp-a11y.js to a reusable package wordpress/a11y which is published on NPM. Let's make sure this package is also used in WordPress core. Once all the JavaScript is built using webpack, we can also import this package wherever it is used and configure webpack to load is an external.

Props omarreiss, herregroen, desrosj, ocean90, afercia, sstoqnov



git-svn-id: https://develop.svn.wordpress.org/trunk@46167 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-18 17:40:35 +00:00
Sergey Biryukov
5fdf48c0ec Script Loader: Introduce HTML5 support for scripts and styles.
When a theme declares HTML5 support for script and styles via `add_theme_support( 'html5', array( 'script', 'style' ) )`, the `type="text/javascript"` and `type="text/css"` attributes are omitted.

These attributes are unnecessary in HTML5 and cause warnings in the W3C Markup Validation Service.

Props sasiddiqui, swissspidy, knutsp, SergeyBiryukov.
See #42804.

git-svn-id: https://develop.svn.wordpress.org/trunk@46164 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-18 14:49:30 +00:00
Jonathan Desrosiers
65ec280a54 Posts, Post Types: Allow support arguments to be specified when registering post types.
The `add_post_type_support()` function accepts an optional third parameter that allows extra arguments to be supplied to configure post type support for a given feature. However, because of how `register_post_type()` and `WP_Post_Type->add_supports()` work, it is currently impossible to pass these additional arguments when initially registering a post type with `register_post_type()`.

This change makes it possible to supply additional arguments for a feature using the `supports` argument of `register_post_type()`.

Props MaximeCulea, seuser, desrosj, johnbillion.
Fixes #40413.

git-svn-id: https://develop.svn.wordpress.org/trunk@46160 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-17 19:57:18 +00:00
Jonathan Desrosiers
5e38f8219b Build/Test Tools: Improve test coverage for wp_validate_boolean().
This change also reworks the test class to use a data provider.

Props pbearne, desrosj
Fixes #39868

git-svn-id: https://develop.svn.wordpress.org/trunk@46159 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-17 18:48:27 +00:00
Sergey Biryukov
5928234d05 Date/Time: Introduce get_post_datetime() to retrieve post published or modified time as a DateTimeImmutable object instance.
Introduce `get_post_timestamp()` to retrieve post published or modified time as a Unix timestamp.

Use `get_post_datetime()` in `get_post_time()` and `get_post_modified_time()` to return correct GMT time if default timezone is changed from UTC.

Props Rarst, johnregan3.
Fixes #25002.

git-svn-id: https://develop.svn.wordpress.org/trunk@46154 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-17 11:13:25 +00:00
Sergey Biryukov
802c23e059 Code Modernisation: Replace call_user_func_array() in tests/phpunit/tests/db.php with dynamic function calls.
Props jrf.
See #47678.

git-svn-id: https://develop.svn.wordpress.org/trunk@46145 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-15 11:55:42 +00:00
Sergey Biryukov
fd05ea0de9 Code Modernisation: Replace call_user_func_array() in wp-admin/includes/widgets.php and associated unit tests with a direct function call.
Props jrf.
See #47678.

git-svn-id: https://develop.svn.wordpress.org/trunk@46138 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-15 11:40:08 +00:00
Sergey Biryukov
3ae54e84da Code Modernisation: Introduce the spread operator in tests/phpunit/*.
Rather than relying `func_get_args()` to retrieve arbitrary function arguments, we can now use the spread operator to assign them directly to a variable.

Props jrf.
See #47678.

git-svn-id: https://develop.svn.wordpress.org/trunk@46127 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-15 11:03:45 +00:00
Sergey Biryukov
7b8c666b72 Mail: Add a unit test to make sure wp_mail() does not duplicate the MIME-Version header added automatically by PHPMailer.
See #43542.

git-svn-id: https://develop.svn.wordpress.org/trunk@46118 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-14 21:34:51 +00:00
Sergey Biryukov
a70be65d1f Coding Standards: Fix WPCS issue in [46107].
See #46631.

git-svn-id: https://develop.svn.wordpress.org/trunk@46108 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-14 15:18:10 +00:00
Sergey Biryukov
0b48fd2493 HTTP API: Add a unit test for get_status_header_desc().
Props pbearne.
Fixes #46631.

git-svn-id: https://develop.svn.wordpress.org/trunk@46107 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-14 14:53:45 +00:00
Jonathan Desrosiers
50a0d6c7a9 Menus: Nav menu locations should not be integers.
When nav menu location slugs are integers, some hard to debug results can occur. `register_nav_menus()` utilizes `array_merge()` which renumbers numeric indexes, starting from 0. Because of this, numeric menu locations will almost always be changed.

This change introduces a `_doing_it_wrong()` notice to inform developers that nav menu locations should always be strings.

Props audrasjb, desrosj, welcher.
Fixes #45361.

git-svn-id: https://develop.svn.wordpress.org/trunk@46102 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-13 17:57:57 +00:00
Adam Silverstein
2b4cecf316 Multisite: improve sites_pre_query and networks_pre_query filters, avoiding db queries.
Improve the `pre_query` filters in multisite classes introduced in r44983. Return (non null) values immediately,
avoiding the database queries entirely, similar to other `pre_query` filters.

Props spacedmonkey, SergeyBiryukov, felipeelia.
Fixes #47599.



git-svn-id: https://develop.svn.wordpress.org/trunk@46100 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-12 22:16:08 +00:00
K. Adam White
b979a99355 REST API: Accept string path in rest_ensure_request.
Update `rest_ensure_request()` to accept a string path, permitting a string path to be passed to `rest_do_request()` as is indicated (previously inaccurately) in that method's PHPDoc.

Props TimothyBlynJacobs, kadamwhite.
Fixes #40614.


git-svn-id: https://develop.svn.wordpress.org/trunk@46099 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-12 21:46:41 +00:00
K. Adam White
ee69f54b8a REST API: Return term resources in "edit" context after PUT or POST request.
Props westonruter, dlh.
Fixes #41411.



git-svn-id: https://develop.svn.wordpress.org/trunk@46098 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-12 21:28:14 +00:00
Sergey Biryukov
8005d291a3 Accessibility: Comments: In comment_form(), remove aria-describedby attribute from the email field if there's no associated description in the comment_notes_before argument.
The attribute is meant to communicate to user agents and assistive technologies that the element has a description. If the referenced description is missing, it will be flagged as failure by any automated accessibility checker tool and, most importantly, is potentially confusing for assistive technologies users.

Props afercia, joedolson, dinhtungdu, donmhico, SergeyBiryukov.
Fixes #47975.

git-svn-id: https://develop.svn.wordpress.org/trunk@46090 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-11 01:50:23 +00:00
Sergey Biryukov
159c78c853 Docs: Fix placement of some duplicate hook references.
Hook documentation should be on the line directly above the line containing the `do_action()` or `apply_filters()` call. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of duplicate hook references.

Includes minor code layout fixes.

See #47110.

git-svn-id: https://develop.svn.wordpress.org/trunk@46088 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-10 19:22:07 +00:00
Adam Silverstein
4ba54c2104 Comments: add a new comments_pre_query filter to short circuit WP_Comment_Query 'get_comments' queries.
Return a non-null value to bypass WordPress's default comment queries.

Props felipeelia, spacedmonkey.
Fixes #45800.



git-svn-id: https://develop.svn.wordpress.org/trunk@46086 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-10 18:41:03 +00:00
Sergey Biryukov
d48d56e101 Posts, Post Types: Revert [46079] pending test failure investigation.
See #47824.

git-svn-id: https://develop.svn.wordpress.org/trunk@46080 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-07 19:32:42 +00:00
Sergey Biryukov
69054687be Posts, Post Types: Avoid a PHP warning when the_content() is called outside of the loop.
Fixes #47824.

git-svn-id: https://develop.svn.wordpress.org/trunk@46079 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-07 14:32:23 +00:00
Andrew Ozz
ba033e4c6f Media: Improve handling of cases where an uploaded image matches exactly a defined intermediate size. In most of these cases the original image has been edited by the user and is "web ready", there is no need for an identical intermediate image.
Introduces the `wp_image_resize_identical_dimensions` filter so plugins and themes can determine whether a new image with identical dimensions should be created, defaults to false.

Props wpdennis, HKandulla, galbaras, azaozz.
See #32437.

git-svn-id: https://develop.svn.wordpress.org/trunk@46077 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-07 01:33:16 +00:00
Andrew Ozz
58dd5e793f Fix (unrelated) test after [46066].
See #43524.

git-svn-id: https://develop.svn.wordpress.org/trunk@46067 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-05 22:52:29 +00:00
Sergey Biryukov
bd299597d5 Coding Standards: Fix WPCS issue in [45990].
git-svn-id: https://develop.svn.wordpress.org/trunk@46019 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-04 18:40:13 +00:00
Jonathan Desrosiers
cda102f72f Fix for URL sanitization that can lead to cross-site scripting (XSS) attacks.
Props irsdl, sstoqnov, whyisjake.

git-svn-id: https://develop.svn.wordpress.org/trunk@45997 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-04 17:51:33 +00:00
Sergey Biryukov
b91c405069 Improve handling the existing rel attribute in wp_rel_nofollow_callback().
Props xknown, sstoqnov.

git-svn-id: https://develop.svn.wordpress.org/trunk@45990 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-04 17:36:46 +00:00
Jake Spurlock
c957e2573e Update wp.a11y.speak() to sanitize HTML before display.
Props iandunn, adamsilverstein, sstoqnov, peterwilsoncc


git-svn-id: https://develop.svn.wordpress.org/trunk@45979 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-04 17:11:22 +00:00
Jake Spurlock
7f033deee5 Remove _convert_urlencoded_to_entities() from the get_the_content() callback.
Props vortfu, whyisjake, peterwilsoncc


git-svn-id: https://develop.svn.wordpress.org/trunk@45935 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-04 16:03:56 +00:00
Andrea Fercia
e12f3793d5 Accessibility: Audit usage of abbreviations.
Title attributes on abbreviations are only available to a minority of users. The
best option is to avoid unnecessary abbreviations when possible. In the other cases,
use an `<abbr>` element (which provides a hint to user agents on how to announce
and display the abbreviation) and provide an expansion in plain text on first use.

- `readme.html`: improves abbreviations and removes unnecessary `title` attributes
- options-general: removes unnecessary abbreviations and improves the remaining ones
- customizer schedule changeset date: removes unnecessary abbreviations and improves the remaining ones
- posts table date: uses a `span` element instead of an `abbr` element because this is not an abbreviation

Fixes #46980.


git-svn-id: https://develop.svn.wordpress.org/trunk@45930 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-02 21:43:39 +00:00
Felix Arntz
ac2df4e8db Formatting: Improve accuracy of force_balance_tags() and add support for custom element tags.
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
2019-09-02 10:24:18 +00:00
Peter Wilson
122cb2864b #43590: Use robots meta tag to better discourage search engines.
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
2019-09-02 02:26:55 +00:00
Sergey Biryukov
56d4e7fb86 Date/Time: Restore the previous behavior of date_i18n() where invalid input would result in current time.
Make `wp_date()` return `false` on invalid timestamp input, for consistency with upstream PHP `date()` function.

Props Rarst.
Fixes #28636.

git-svn-id: https://develop.svn.wordpress.org/trunk@45914 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-29 23:17:30 +00:00
Sergey Biryukov
355d93d977 Date/Time: Update XML-RPC tests for invalid date input to account for a more consistent mysql2date() error handling in [45908].
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
2019-08-29 16:43:28 +00:00
Felix Arntz
4572bb0988 Multisite: Improve performance by caching not found lookups for sites and networks.
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
2019-08-29 12:41:45 +00:00
Sergey Biryukov
71697aefc0 Date/Time: Revamp mysql2date() to use wp_date() and handle invalid input in a consistent manner.
Add unit tests, improve documentation.

Props Rarst, pbearne.
Fixes #28992.

git-svn-id: https://develop.svn.wordpress.org/trunk@45908 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-29 05:06:15 +00:00
Sergey Biryukov
f490fb924d Coding Standards: Fix WPCS issue in [45906].
See #45322.

git-svn-id: https://develop.svn.wordpress.org/trunk@45907 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-29 02:39:21 +00:00
Sergey Biryukov
c3e89c2190 XML-RPC: Make sure editing a draft post with wp.editPost does not unintentionally cause its published date to be set.
Props redsweater.
Fixes #45322.

git-svn-id: https://develop.svn.wordpress.org/trunk@45906 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-29 02:09:42 +00:00
K. Adam White
2d0cb482ed REST API: Only cast scalar types to string when comparing new & old meta values.
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
2019-08-28 03:07:03 +00:00
Sergey Biryukov
dfe51f6069 Date/Time: Correct delta comparison in test_should_return_wp_timestamp().
See #25768.

git-svn-id: https://develop.svn.wordpress.org/trunk@45902 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-28 02:19:46 +00:00
Boone Gorges
c2c8a6848d Taxonomy: Fix unique-slug check for terms with parents.
`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
2019-08-26 15:18:40 +00:00
Boone Gorges
3e704473e7 Taxonomy: Ensure consistency of hide_empty in term queries when taxonomy is excluded.
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
2019-08-23 16:04:07 +00:00
Sergey Biryukov
ae2b4f9add Date/Time: Rewrite and simplify get_gmt_from_date(), get_date_from_gmt(), and iso8601_to_datetime() using wp_timezone().
Improve unit test coverage.

Props Rarst, goodevilgenius.
Fixes #31809.

git-svn-id: https://develop.svn.wordpress.org/trunk@45887 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-23 11:02:51 +00:00
Sergey Biryukov
67f7d1f4c7 Date/Time: Rewrite and simplify date_i18n() using wp_timezone() to address multiple issues with certain date formats and timezones, while preserving some extra handling for legacy use cases.
Improve unit test coverage.

Props Rarst, remcotolsma, raubvogel.
Fixes #25768.

git-svn-id: https://develop.svn.wordpress.org/trunk@45882 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-23 00:56:21 +00:00
Sergey Biryukov
4e129d1506 Date/Time: Use wp_timezone() in WP_Date_Query::build_mysql_datetime() to address timezone issues.
Improve unit test coverage.

Props Rarst, Biranit, birgire, jave.web, SergeyBiryukov.
Fixes #41782.

git-svn-id: https://develop.svn.wordpress.org/trunk@45876 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-22 03:10:05 +00:00
Sergey Biryukov
1ba44554be Users: Adjust [45708] to make sure wp_update_user() does not issue a WP_Error if a single site was previously set up as Multisite and there's still a spam field in the user table.
Add a unit test.

Props azaozz, SergeyBiryukov.
Fixes #45747.

git-svn-id: https://develop.svn.wordpress.org/trunk@45874 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-22 01:52:16 +00:00
Sergey Biryukov
7fbabd505d Administration: Adjust [45814] to address a backward compatibility issue for plugins passing multiple CSS classes to add_settings_error().
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
2019-08-22 00:21:49 +00:00