Commit Graph

2942 Commits

Author SHA1 Message Date
Sergey Biryukov f1862cd98c Date/Time: Make sure `current_time()` always calculates the offset from GMT/UTC.
Previously, UTC context was implied, but could be unreliable due to being affected by plugins.

Props Rarst, rahulsprajapati, marco.marsala.
Fixes #37440.

git-svn-id: https://develop.svn.wordpress.org/trunk@43594 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-30 12:12:55 +00:00
Sergey Biryukov 9364b6ed87 Date/Time: Make `get_the_date()` call `get_post_time()` for consistency with `get_the_time()`.
Props Rarst.
Fixes #44490.

git-svn-id: https://develop.svn.wordpress.org/trunk@43591 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-30 08:49:40 +00:00
Felix Arntz aa5b179247 REST API: Fix failing tests after [43584] and [43585].
See #40510.


git-svn-id: https://develop.svn.wordpress.org/trunk@43586 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-28 13:04:07 +00:00
Felix Arntz 65cadaab62 REST API: Fix failing tests after [43584].
See #40510.


git-svn-id: https://develop.svn.wordpress.org/trunk@43585 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-28 12:43:50 +00:00
Felix Arntz e5d6ddfeee REST API: Support pagination, order, search and other common query parameters for revisions.
The original REST API revisions controller relied on `wp_get_post_revisions()`, getting all revisions of a post without any possibility to restrict the result. This changeset replaces that function call with a proper `WP_Query` setup, replicating how `wp_get_post_revisions()` works while offering parameters to alter the default behavior.

Props adamsilverstein, birgire, flixos90.
Fixes #40510.


git-svn-id: https://develop.svn.wordpress.org/trunk@43584 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-28 12:22:48 +00:00
Gary Pendergast 63acd3caaa Tests: Revert `wp-api-generated.js` change added in [43571].
The fixtures file was accidentally included in [43571], but that caused other tests to fail.

See #39122.



git-svn-id: https://develop.svn.wordpress.org/trunk@43572 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-17 04:11:48 +00:00
Gary Pendergast a75d153eee 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-17 01:50:26 +00:00
Sergey Biryukov c5d013bf95 Privacy: Ensure the user request email is sent in the requested user's locale (or the site's default locale if they are not a registered user) when the administrator creating the request uses a different locale.
Props desrosj, Chouby, iandunn, lbenicio, birgire, earnjam, swissspidy, garrett-eclipse.
Fixes #43985.

git-svn-id: https://develop.svn.wordpress.org/trunk@43568 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-13 16:31:31 +00:00
K. Adam White 20ab5ca79e Tests: Improve coverage for REST API term meta registration.
Introduce tests to validate that register_meta and register_term_meta work as expected in WP_REST_Terms_Controller.

props timmydcrawford.
Fixes #39122.


git-svn-id: https://develop.svn.wordpress.org/trunk@43567 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-12 00:05:39 +00:00
Sergey Biryukov 244f435e22 Script/Style Dependencies: Make sure that inline scripts for handles without a source are printed.
See [36550] for `WP_Styles`.

Props bpayton.
Fixes #44551.

git-svn-id: https://develop.svn.wordpress.org/trunk@43565 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-11 17:41:29 +00:00
Sergey Biryukov 3b4b754f2a Tests: Avoid a race condition in `test_date_i18n_handles_shorthand_formats()` by using a delta for comparing timestamps.
See #20973, #38381.

git-svn-id: https://develop.svn.wordpress.org/trunk@43562 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-11 13:28:26 +00:00
Sergey Biryukov 4ce3db3e8d Build/Test Tools: Add documentation for `tests_add_filter()`, `_test_filter_build_unique_id()`, `_delete_all_data()`, `_delete_all_posts()`.
Props andizer.
Fixes #44703.

git-svn-id: https://develop.svn.wordpress.org/trunk@43555 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-02 22:35:10 +00:00
Felix Arntz c29d019762 Multisite: Complete the new CRUD API for managing sites.
New functions `wp_insert_site( $data )`, `wp_update_site( $id, $data )` and `wp_delete_site( $id )` are introduced to manage site rows in the `wp_blogs` table, forming the new CRUD API together with the existing `get_site()` / `get_sites()`. The new API provides various benefits over the previously existing API, fixing several cache invalidation issues and being hook-driven so that normalization and validation of the passed data can be fully customized.

New hooks introduced as part of this are the actions `wp_insert_site`, `wp_update_site`, `wp_delete_site`, `wp_validate_site_data` and the filter `wp_normalize_site_data`.

At this point, `wp_insert_site()` does not handle setting up the site's database tables, and `wp_delete_site()` does not handle dropping the site's database tables, so the two can not yet be used directly as full replacements of `wpmu_create_blog()` and `wpmu_delete_blog()`. Managing the site's database tables will be added via hooks as part of the follow-up ticket #41333.

The existing functions `wpmu_create_blog()`, `update_blog_details()`, and `wpmu_delete_blog()` make use of the respective new counterpart and will be obsolete once #41333 has been completed.

Props flixos90, jeremyfelt, spacedmonkey.
Fixes #40364.


git-svn-id: https://develop.svn.wordpress.org/trunk@43548 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-01 13:05:44 +00:00
Peter Wilson a32ea2d35d Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.

`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.

Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.

Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.

Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.



git-svn-id: https://develop.svn.wordpress.org/trunk@43540 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-27 02:22:50 +00:00
Sergey Biryukov ddc8f803c6 Privacy: Revert [43525].
The commenter cookies checkbox is not legally required, so should be disabled by default.

Fixes #44373.

git-svn-id: https://develop.svn.wordpress.org/trunk@43531 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-24 17:05:56 +00:00
Sergey Biryukov 0f7e947546 REST API: Ensure attachments created with `WP_REST_Attachments_Controller::create_item()` on Windows have a relative path.
Props ocean90, SergeyBiryukov, redcastor.
Fixes #40861.

git-svn-id: https://develop.svn.wordpress.org/trunk@43529 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-24 16:51:09 +00:00
Sergey Biryukov 335b69cedc Privacy: Remove the setting to enable comment cookies consent added in [43469].
This needs some more work to ensure expected behaviour.

See #44373.

git-svn-id: https://develop.svn.wordpress.org/trunk@43525 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-24 12:50:55 +00:00
Sergey Biryukov 8a0aac2ccb Comments: Ensure that themes overriding default `comment_form()` fields still display the cookies consent checkbox.
The `comment_form_default_fields` filter can be used to remove the checkbox.

Props pross, SergeyBiryukov.
Fixes #44126.

git-svn-id: https://develop.svn.wordpress.org/trunk@43518 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-20 00:37:40 +00:00
Sergey Biryukov 2075b3d921 Tests: Introduce `Tests_HTTP_Functions::skipTestOnTimeout()`, mirroring the same `WP_HTTP_UnitTestCase` method.
See #44613.

git-svn-id: https://develop.svn.wordpress.org/trunk@43512 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-19 19:52:41 +00:00
Sergey Biryukov 0ba13ec260 Tests: Use `WP_HTTP_UnitTestCase::skipTestOnTimeout()` in more HTTP tests.
Adjust it to handle more types of timeouts, e.g. "Resolving timed out", "Connection timed out".

See #44613.

git-svn-id: https://develop.svn.wordpress.org/trunk@43511 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-19 19:09:56 +00:00
Sergey Biryukov a1f6ba5477 Privacy: Use the actual Privacy Policy page title in `get_the_privacy_policy_link()`.
Props desrosj, birgire, ianbelanger, Ov3rfly.
Fixes #44192.

git-svn-id: https://develop.svn.wordpress.org/trunk@43506 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-18 11:49:46 +00:00
Sergey Biryukov 9daa08da8e Filesystem API: Skip `https://` test for `wp_is_stream()` if `openssl` extension is not loaded.
See #44533.

git-svn-id: https://develop.svn.wordpress.org/trunk@43503 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-18 09:51:53 +00:00
Sergey Biryukov 6f0218d8bc Filesystem API: Add basic tests for `wp_is_stream()`.
Props JPry.
See #44533.

git-svn-id: https://develop.svn.wordpress.org/trunk@43501 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-18 01:01:28 +00:00
Sergey Biryukov b2d63fd056 Privacy: Add unit tests for `_wp_privacy_send_request_confirmation_notification()`, introduced in [43211].
Props birgire, desrosj, garrett-eclipse.
Fixes #43967.

git-svn-id: https://develop.svn.wordpress.org/trunk@43499 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-17 22:55:51 +00:00
Andrew Ozz 590d18844b Customize: Do not attempt to count uncountable value.
Props dlh.
Fixes #44104.

git-svn-id: https://develop.svn.wordpress.org/trunk@43480 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-17 14:37:21 +00:00
Andrew Ozz c1ce7d134b Privacy: Fix tests after [43467].
See #44141.


git-svn-id: https://develop.svn.wordpress.org/trunk@43471 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-17 09:57:57 +00:00
Andrew Ozz b33deaf1b5 Privacy: Don't replace comment author URL and email with anything.
Props TZ-Media, desrosj, birgire.
Fixes #44141.

git-svn-id: https://develop.svn.wordpress.org/trunk@43467 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-17 08:59:30 +00:00
Gary Pendergast 66f537e702 REST API: Attachments controller should respect upload limits.
When the REST API is in use on WordPress multisite, the `WP_REST_Attachments_Controller` should respect the "Max upload file size" and "Site upload space" site options.

Props flixos90, danielbachhuber.
Fixes #43751.



git-svn-id: https://develop.svn.wordpress.org/trunk@43462 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-17 07:21:50 +00:00
Gary Pendergast 4c8daa87bd REST API: Update the test fixture generator following [43439]
As [43439] added data that contains object IDs, it can cause `wp-api-generated.js` to be unnecessarily regenerated.

Regenerating our list of fixtures that need normalising rectifies this.

See #44321.



git-svn-id: https://develop.svn.wordpress.org/trunk@43441 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-13 04:45:35 +00:00
Gary Pendergast 46c238ca78 REST API: Tweak permission checks for taxonomy and term endpoints
To match behaviour in the Classic Editor, we need to slightly loosen permissions on taxonomy and term endpoints. This allows users to create terms to assign to a post that they're editing.

Props danielbachhuber.
Fixes #44096.



git-svn-id: https://develop.svn.wordpress.org/trunk@43440 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-13 04:23:35 +00:00
Gary Pendergast 585c862faf REST API: Expose revision count and last revision ID on Post response
So that REST API clients can show appropriate UI for a post's revisions, it needs to know how many revisions the post has, and what the latest revision ID is.

Props kadamwhite, danielbachhuber, birgire, TimothyBlynJacobs.
Fixes #44321.



git-svn-id: https://develop.svn.wordpress.org/trunk@43439 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-13 04:06:23 +00:00
Gary Pendergast 81d2390d29 REST API: Declare user capabilities using JSON Hyper Schema's "targetSchema".
There are a variety of operations a WordPress user can only perform if they have the correct capabilities. A REST API client should only display UI for one of these operations if the WordPress user can perform the operation.

Rather than requiring REST API clients to calculate whether to display UI based on potentially complicated combinations of user capabilities, `targetSchema` allows us to expose a single flag to show whether the corresponding UI should be displayed.

This change also includes flags on post objects for the following actions:

- `action-publish`: The current user can publish this post.
- `action-sticky`: The current user can make this post sticky, and the post type supports sticking.
- `action-assign-author': The current user can change the author on this post.
- `action-assign-{$taxonomy}`: The current user can assign terms from the "$taxonomy" taxonomy to this post.
- `action-create-{$taxonomy}`: The current user can create terms int the "$taxonomy" taxonomy.

Props TimothyBlynJacobs, danielbachhuber.
Fixes #44287.



git-svn-id: https://develop.svn.wordpress.org/trunk@43437 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-11 06:22:10 +00:00
John Blackbourn f584b5755a Date/Time: Add support for the `c` and `r` shorthand formats in `date_i18n()`.
Props Rarst, pbearne

Fixes #20973


git-svn-id: https://develop.svn.wordpress.org/trunk@43434 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-05 23:10:01 +00:00
Felix Arntz b4d8e87464 Tests: Fix failing test after [43388].
Fixes #44396.


git-svn-id: https://develop.svn.wordpress.org/trunk@43390 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-05 08:52:06 +00:00
Felix Arntz 21190f2eac Date/Time: Fix usage of `$gmt` parameter in `date_i18n()` and clarify its behavior.
The docs for `date_i18n()` and its filter now correctly state that the `$gmt` parameter is only taken into account if no timestamp is provided. Furthermore, a bug with that parameter is fixed, as it is now ensured that the timezone used with it is `UTC`.

Props Rarst.
Fixes #38771.


git-svn-id: https://develop.svn.wordpress.org/trunk@43389 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-04 23:42:59 +00:00
Felix Arntz d448c448ca Date/Time: Add support for `gmt_offset` to `date_i18n()`.
Prior to this change, `date_i18n()` only supported the `timezone_string` option, causing incorrect timezones to appear in formatted dates on sites that still rely on the `gmt_offset` option.

Props Rarst.
Fixes #34835.


git-svn-id: https://develop.svn.wordpress.org/trunk@43387 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-03 15:58:58 +00:00
Felix Arntz d3a198df34 Taxonomy: Introduce `is_taxonomy_viewable()`.
This utility function allows for easy detection whether terms for a taxonomy are considered publicly viewable.

Props andizer.
Fixes #44466.


git-svn-id: https://develop.svn.wordpress.org/trunk@43386 602fd350-edb4-49c9-b593-d223f7449a82
2018-07-03 10:28:39 +00:00
Felix Arntz d399bcce30 Role/Capability: Rename `upgrade_php` capability to more suitable `update_php`.
This brings the name in line with user-facing language and similar names of existing related capabilities. Since the capability has not been part of any WordPress release, it can be renamed without any backward-compatibility implications.

Also missing props benhuberman for [43006].

Fixes #44457.


git-svn-id: https://develop.svn.wordpress.org/trunk@43381 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-26 15:04:26 +00:00
K. Adam White a830dbcab3 REST API: Support meta registration for specific object subtypes.
Introduce an `object_subtype` argument to the args array for `register_meta()` which can be used to limit meta registration to a single subtype (e.g. a custom post type or taxonomy, vs all posts or taxonomies).

Introduce `register_post_meta()` and `register_term_meta()` wrapper methods for `register_meta` to provide a convenient interface for the common case of registering meta for a specific taxonomy or post type. These methods work the way plugin developers have often expected `register_meta` to function, and should be used in place of direct `register_meta` where possible.

Props flixos90, tharsheblows, spacedmonkey.
Fixes #38323.



git-svn-id: https://develop.svn.wordpress.org/trunk@43378 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-21 21:06:50 +00:00
Gary Pendergast cdd9910f01 Emoji: Update Twemoji to version 11.0.
🦹

Props kraftbj,
Fixes #44339.



git-svn-id: https://develop.svn.wordpress.org/trunk@43377 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-20 04:20:32 +00:00
Andrew Ozz acbbd28d0e Privacy: add `esc_html` to assertion in test_wp_comments_personal_data_exporter.
Props mermel, 1naveengiri.
Fixes #44113.

git-svn-id: https://develop.svn.wordpress.org/trunk@43371 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-18 16:09:55 +00:00
John Blackbourn 1e88432e34 Build/Test Tools: Introduce support for a `WP_TESTS_CONFIG_FILE_PATH` constant to override the test suite config file location.
This can be used in phpunit.xml:

{{{
<php>
	<const name="WP_TESTS_CONFIG_FILE_PATH" value="/path/to/wp-tests-config.php" />
</php>
}}}

Props clarinetlord

Fixes #39734


git-svn-id: https://develop.svn.wordpress.org/trunk@43369 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-16 14:21:18 +00:00
John Blackbourn 5aa5e5c131 I18N: Introduce unit tests for the Japanese language in order to facilitate future improvements.
Props ryotsun

Fixes #43829


git-svn-id: https://develop.svn.wordpress.org/trunk@43359 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-16 12:44:46 +00:00
Sergey Biryukov 4d5b00da46 Docs: Update `@since` versions in Community Events class added in [42726].
See #41112.

git-svn-id: https://develop.svn.wordpress.org/trunk@43356 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-16 10:38:27 +00:00
Felix Arntz 07f3c7097e REST API: Improve test coverage by providing tests for term meta.
See #38323.


git-svn-id: https://develop.svn.wordpress.org/trunk@43340 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-11 17:54:19 +00:00
Felix Arntz 9e38c2847e Tests: Improve performance of post meta tests.
See #38323.


git-svn-id: https://develop.svn.wordpress.org/trunk@43339 602fd350-edb4-49c9-b593-d223f7449a82
2018-06-11 16:32:32 +00:00
John Blackbourn 58a71dc610 Build/Test Tools: Allow the unit test framework to be used without the data directory in place.
Fixes #43982

git-svn-id: https://develop.svn.wordpress.org/trunk@43315 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-25 22:42:11 +00:00
Boone Gorges 39fb88f961 Taxonomy: Improve cache handling when querying for terms using `all_with_object_id`.
When a term query using `fields=all_with_object_id` hits the cache, the
cached `stdClass` objects must be converted to `WP_Term` objects. This
was overlooked when `WP_Term_Query` was refactored to support object
queries in [38667].

Props dlh.
Fixes #44221.

git-svn-id: https://develop.svn.wordpress.org/trunk@43313 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-25 01:22:44 +00:00
John Blackbourn f4fbba188d Build/Test Tools: Roses are red, this fixes stuff.
Update the test infrastructure so that third party plugins, themes, and projects that use the core testing framework continue to operate from the `src` directory and do not require a build step.

Props mboynes, danielbachhuber, schlessera

See #43055


git-svn-id: https://develop.svn.wordpress.org/trunk@43311 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-23 17:54:44 +00:00
Gary Pendergast ef37f002ee Once upon a midnight dreary, while I coded, weak and weary,
In many a strange and curious file of forgotten lore—
While I pondered, blaming Nacin, my notifications suddenly awakened,
As of someone quietly DMing;—DMing me, I can’t ignore.
“’Tis some contributor,” I muttered, “DMing me an idea or four—
            Only this and nothing more.”

Ah, distinctly I remember, at WordCamp US, last December;
A mad proposal nearly laid me—down out cold—upon the floor.
Curious, I listened closely;—to a plan I agreed with, mostly—
A way to make our JavaScript—JavaScript which was a chore—
Maintainable, extendable, for the future, is what I saw.
            Guten-ready for evermore.

Open here I switch to Slack, when, with many a patch and hack,
In there stepped Omar, a JavaScript developer hardcore;
Pronouncing all the changes fit; ready now to be commit;
“There’s nothing else for us to do,” DMing me, “It’s done!” he swore—
“No longer random guessing at which file need next be explored—
            Let’s move on, we’re all aboard.”

Moved all together, grouped and managed, in folders all is packaged,
The code had all been cleaned and tidied, important parts moved to the fore,
“Though this change be useful here,” I said, “it is too large, I fear,
We couldn’t manage such a patch, we’ve done nothing like this before—
Tell me where doth go this change, change to make our codebase soar!”
            Quoth Omar, “In WordPress Core.”

Props omarreis for shepherding this significant change.
Props adamsilverstein, aduth, atimmer, dingo_bastard, frank-klein, gziolo, herregroen, jaswrks, jeremyfelt, jipmoors, jorbin, netweb, ocean90, pento, tjnowell, and youknowriad for testing, feedback, discussion, encouragement, commiserations, etc.
I make no apologies for this commit message.
Fixes #43055.



git-svn-id: https://develop.svn.wordpress.org/trunk@43309 602fd350-edb4-49c9-b593-d223f7449a82
2018-05-23 10:04:22 +00:00