Commit Graph

45 Commits

Author SHA1 Message Date
Sergey Biryukov 1ce5dc7444 Code Modernization: Replace usage of `strpos()` with `str_contains()`.
`str_contains()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).

WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of WordPress 5.9.

This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.

Follow-up to [52039], [52040], [52326], [55703], [55710], [55987].

Props Soean, spacedmonkey, costdev, dingo_d, azaozz, mikeschroder, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes #58206.
Built from https://develop.svn.wordpress.org/trunk@55988


git-svn-id: http://core.svn.wordpress.org/trunk@55500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 14:36:26 +00:00
Sergey Biryukov 2ec23a82ed Code Modernization: Replace usage of `strpos()` with `str_starts_with()`.
`str_starts_with()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins with the given substring (needle).

WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.

This commit replaces `0 === strpos( ... )` with `str_starts_with()` in core files, making the code more readable and consistent, as well as improving performance.

While `strpos()` is slightly faster than the polyfill on PHP < 8.0, `str_starts_with()` is noticeably faster on PHP 8.0+, as it is optimized to avoid unnecessarily searching along the whole haystack if it does not find the needle.

Follow-up to [52039], [52040], [52326].

Props spacedmonkey, costdev, sabernhardt, mukesh27, desrosj, jorbin, TobiasBg, ayeshrajans, lgadzhev, SergeyBiryukov.
Fixes #58012.
Built from https://develop.svn.wordpress.org/trunk@55703


git-svn-id: http://core.svn.wordpress.org/trunk@55215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 15:45:22 +00:00
Pascal Birchler 5edb22187d I18N: Introduce `switch_to_user_locale()`.
This new function makes it easier to switch to a specific user’s locale by reducing duplicate code and storing the user’s ID as additional context for plugins to consume. Existing usage of `switch_to_locale()` in core has been replaced with `switch_to_user_locale()` where appropriate.

Also, this change ensures `WP_Locale_Switcher` properly filters `determine_locale` so that anyyone using the `determine_locale()` function will get the correct locale information when switching is in effect.

Props costdev.
Fixes #57123.
See #26511.
Built from https://develop.svn.wordpress.org/trunk@55161


git-svn-id: http://core.svn.wordpress.org/trunk@54694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-30 10:27:16 +00:00
Sergey Biryukov 3ba44120d0 Coding Standards: Always use parentheses when instantiating an object.
Note: This will be enforced by WPCS 3.0.0.

Props jrf.
See #56791.
Built from https://develop.svn.wordpress.org/trunk@54891


git-svn-id: http://core.svn.wordpress.org/trunk@54443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-29 15:51:14 +00:00
Sergey Biryukov 01d172b581 General: Replace all `esc_url_raw()` calls in core with `sanitize_url()`.
This aims to improve performance by calling `sanitize_url()` directly, instead of the `esc_url_raw()` wrapper. As of WordPress 6.1, `sanitize_url()` is the recommended function for sanitizing a URL for database or redirect usage.

Follow-up to [11383], [13096], [51597], [53452].

Props benjgrolleau, peterwilsoncc, SergeyBiryukov.
Fixes #55852.
Built from https://develop.svn.wordpress.org/trunk@53455


git-svn-id: http://core.svn.wordpress.org/trunk@53044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-01 18:14:10 +00:00
hellofromTonya ab252fb910 Coding Standards: Fix indentation and remove `ignore` annotation in `wp_privacy_send_personal_data_export_email()`.
Follow-up to [51129], [51410].

Props jrf, hellofromTonya.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51662


git-svn-id: http://core.svn.wordpress.org/trunk@51268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 14:05:58 +00:00
antpb 06cddbd3b3 Privacy: Improve naming of user confimed action email filters.
The filters `user_confirmed_action_email_content`, `user_erasure_complete_email_subject`, and `user_erasure_complete_email_headers` have been deprecated.

They have been replaced with `user_erasure_fulfillment_email_content`, `user_erasure_fulfillment_email_subject`, and `user_erasure_fulfillment_email_headers`.

Props desrosj, garrett-eclipse, birgire, DrewAPicture, lifeforceinst, ocean90, pbiron, pento, coffee2code, TZ-Media, SergeyBiryukov, johnbillion, audrasjb, davidbaumwald, hellofromTonya, helen, xkon, antpb, peterwilsoncc, lukecarbis.
Fixes #44314.


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


git-svn-id: http://core.svn.wordpress.org/trunk@50738 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-09 01:35:58 +00:00
davidbaumwald b7280388d6 Privacy: Ensure "Export Personal Data" does not generate invalid JSON.
Previously, when exporting personal data, if the JSON encoding of the data failed, the invalid JSON was still written to `export.json`.  This change captures the JSON encoding failure and adds a notice to the UI.  

Props hellofromTonya, jrf, SergeyBiryukov.
Fixes #52892.
Built from https://develop.svn.wordpress.org/trunk@50713


git-svn-id: http://core.svn.wordpress.org/trunk@50322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-04-14 21:28:08 +00:00
Sergey Biryukov 69a7063a49 Code Modernization: Check if the `_export_data_grouped` post meta is an array when generating a personal data export file.
This avoids a fatal error on PHP 8 in `wp_privacy_generate_personal_data_export_file()` if the `_export_data_grouped` post meta exists but is not an array.

Additionally, refactor unit tests for the function to:
* Reduce redundant code
* Switch to data provider
* Test on the full HTML output instead of select pieces of the output
* Expand unhappy path coverage

Follow-up to [43012], [44786], [47146], [47278].

Props hellofromTonya, jrf, xknown.
See #51423.
Built from https://develop.svn.wordpress.org/trunk@50613


git-svn-id: http://core.svn.wordpress.org/trunk@50226 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-29 19:37:04 +00:00
Sergey Biryukov a80f705d97 Privacy: Rename the `$send_confirmation_email` parameter of `wp_create_user_request()` to `$status`, for clarity.
Follow-up to [50159], [50165].

Props xkon, TimothyBlynJacobs.
Fixes #52430. See #43890.
Built from https://develop.svn.wordpress.org/trunk@50230


git-svn-id: http://core.svn.wordpress.org/trunk@49891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-05 15:50:05 +00:00
Sergey Biryukov 8984e4ef8c Docs: Update documentation for `wp_create_user_request()` per the documentation standards.
Add a `@since` note for the `$send_confirmation_email` parameter.

Follow-up to [50159].

See #43890.
Built from https://develop.svn.wordpress.org/trunk@50165


git-svn-id: http://core.svn.wordpress.org/trunk@49844 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-02 20:42:03 +00:00
antpb 64bb29d087 Privacy: Allow Admin to Skip e-mail confirmation for Export.
This adds a form option to skip the admin email alert when exporting personal data.

Props xkon, azaozz, TZ-Media, iandunn, desrosj, iprg, allendav, wesselvandenberg, karmatosed, birgire, davidbaumwald, estelaris, paaljoachim, hellofromTonya.
Fixes #43890.

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


git-svn-id: http://core.svn.wordpress.org/trunk@49838 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-02 19:45:03 +00:00
Sergey Biryukov 6f2bba08d9 Privacy: Add newlines to the `index.php` file in `wp-personal-data-exports` directory, for consistency with other similar files.
Follow-up to [50037].

See #52299.
Built from https://develop.svn.wordpress.org/trunk@50055


git-svn-id: http://core.svn.wordpress.org/trunk@49756 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-28 12:58:58 +00:00
whyisjake 5f532382aa Privacy: Ensure that exported user data reports can't be found with directory listings.
By moving from `.html` to `.php` files, we can prevent directory listings, and ensure that WordPress can load.

Fixes #52299.

Props lucasbustamante, xkon, freewebmentor, SergeyBiryukov, whyisjake. 

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


git-svn-id: http://core.svn.wordpress.org/trunk@49738 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-27 23:46:58 +00:00
Sergey Biryukov 4104f92d7f Privacy: Use more consistent wording for strings related to personal data requests.
This replaces "user privacy" in various error messages with "personal data", for consistency with other existing strings.

Follow-up to [49090].

Props xkon, transl8or.
Fixes #51849.
Built from https://develop.svn.wordpress.org/trunk@49970


git-svn-id: http://core.svn.wordpress.org/trunk@49671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-17 17:46:06 +00:00
John Blackbourn dfe1f9b322 Docs: Promote many `bool` types to `true` or `false` where only that value is used.
See #51800

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


git-svn-id: http://core.svn.wordpress.org/trunk@49626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-03 22:04:04 +00:00
Sergey Biryukov a2d42351c5 Text Changes: Unify various "Back to..." vs. "Return to..." vs. "Go to..." strings.
Standardize on "Go to..." as a more appropriate option for most cases.

Props garrett-eclipse, kharisblank, audrasjb, ramiy, valentinbora.
Fixes #47235.
Built from https://develop.svn.wordpress.org/trunk@49539


git-svn-id: http://core.svn.wordpress.org/trunk@49277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-09 10:53:10 +00:00
Helen Hou-Sandí f4f72498c0 Privacy: Show notices for both failed and successful bulk actions.
Props javorszky, garrett-eclipse, hellofromTonya.
Fixes #44081.

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


git-svn-id: http://core.svn.wordpress.org/trunk@49092 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-27 17:47:08 +00:00
Sergey Biryukov 1651342d2b Privacy: Improve clarity of privacy error strings.
Primarily this adds "user privacy" to the strings for privacy requests, so they are more easily distinguished from other system actions within logs.

Props garrett-eclipse, carike, birgire.
Fixes #51351.
Built from https://develop.svn.wordpress.org/trunk@49090


git-svn-id: http://core.svn.wordpress.org/trunk@48852 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-04 03:23:09 +00:00
Sergey Biryukov 29c0edfbba Privacy: Check if the accumulated data in `wp_privacy_process_personal_data_export_page()` is not empty.
This avoids an error on PHP 8 caused by passing an empty string to `array_merge()`, instead of an array.

See #50913.
Built from https://develop.svn.wordpress.org/trunk@49026


git-svn-id: http://core.svn.wordpress.org/trunk@48788 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-21 13:51:03 +00:00
Sergey Biryukov c40a645510 Docs: Correct `@see` references for privacy hooks:
* `wp_privacy_personal_data_export_page`
* `wp_privacy_personal_data_erasure_page`

Hooks should be single-quoted when referenced.

Props pbiron, coffee2code.
See #49572, #meta5318.
Built from https://develop.svn.wordpress.org/trunk@48616


git-svn-id: http://core.svn.wordpress.org/trunk@48378 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-25 19:14:03 +00:00
John Blackbourn 57a3f803ae Docs: First pass at some inline docs fixes mostly made by PHPCBF.
See #49572, #50744
Built from https://develop.svn.wordpress.org/trunk@48586


git-svn-id: http://core.svn.wordpress.org/trunk@48348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 20:01:04 +00:00
John Blackbourn 0bf9b04c53 Docs: Various formatting improvements to inline docblocks.
See #49572
Built from https://develop.svn.wordpress.org/trunk@48574


git-svn-id: http://core.svn.wordpress.org/trunk@48336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 00:52:05 +00:00
Sergey Biryukov 8a815f22e7 Privacy: Simplify the logic for updating the meta values for personal data export requests from absolute to relative paths.
Follow-up to [48127].

See #44038.
Built from https://develop.svn.wordpress.org/trunk@48330


git-svn-id: http://core.svn.wordpress.org/trunk@48099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-06 00:34:04 +00:00
Sergey Biryukov 6adad022e2 Docs: Correct spelling of "backward compatibility" per the Core Contributor Handbook glossary.
Follow-up to [45232].

See #49572.
Built from https://develop.svn.wordpress.org/trunk@48302


git-svn-id: http://core.svn.wordpress.org/trunk@48071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-04 20:42:06 +00:00
Andrea Fercia c4f6669d69 Accessibility: Privacy: Accessibility improvements for the Privacy Policy Guide page.
Improves accessibility of the "Copy this section" button and "Return to Top" link:
- uses `setTimeout()` and `clearTimeout()` to properly handle the "Copied!" text
- simplifies the button text by removing the redundant visually hidden text
- fixes the mismatching visual and DOM order of the Copy button and the "Return to Top" link 
- improves the "Return to Top" links by providing real page fragment identifiers, when possible
- hides the "Return to Top" up arrow from assistive technologies
- minor coding standards

Props afercia, garrett-eclipse.
See #48463, #50322.
Fixes #50335.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48003 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-30 13:56:03 +00:00
whyisjake 84f39df101 Privacy: Use relative paths for exported personal data.
Ensures back-compat while moving to paths off of the /exports directory.

Fixes: #44038.

Props: allendav, mrTall, desrosj, garrett-eclipse, cameronamcintyre, nmenescardi, xkon, whyisjake, davidbaumwald.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47896 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-22 22:40:11 +00:00
John Blackbourn 1a77bb81d8 Docs: Remove unnecessary variables names from `@return` tags.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48100


git-svn-id: http://core.svn.wordpress.org/trunk@47869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-19 22:55:12 +00:00
whyisjake 1e3d4921fb Privacy: Revert use relative paths for exported personal data.
Tests need to be updated to pass.

See: #44038.

Unprops: whyisjake.


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


git-svn-id: http://core.svn.wordpress.org/trunk@47855 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-18 23:02:10 +00:00
whyisjake 2d514c83d5 Privacy: Use relative paths for exported personal data.
Ensures back-compat while moving to paths off of the `/exports` directory.

Fixes: #44038.

Props: allendav, mrTall, desrosj, garrett-eclipse, cameronamcintyre, nmenescardi, xkon, whyisjake. 


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


git-svn-id: http://core.svn.wordpress.org/trunk@47854 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-18 21:40:14 +00:00
Sergey Biryukov 652966a2a5 Privacy: Introduce filters for the headers of all the privacy-related e-mails:
* `wp_privacy_personal_data_email_headers`
* `user_request_confirmed_email_headers`
* `user_erasure_complete_email_headers`
* `user_request_action_email_headers`

Props xkon, garrett-eclipse, zaffarn, desrosj.
Fixes #44501.
Built from https://develop.svn.wordpress.org/trunk@47279


git-svn-id: http://core.svn.wordpress.org/trunk@47079 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-11 21:43:07 +00:00
Sergey Biryukov e6d01e007c Privacy: Add a table of contents to Personal Data Export report for easier navigation.
Props xkon, garrett-eclipse, birgire, karmatosed.
Fixes #46894.
Built from https://develop.svn.wordpress.org/trunk@47278


git-svn-id: http://core.svn.wordpress.org/trunk@47078 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-11 21:28:05 +00:00
Sergey Biryukov 3342aafe5e Privacy: Rename `wp_get_user_request_data()` to `wp_get_user_request()` for clarity; deprecate the old function.
The function returns an instance of the `WP_User_Request` object itself, not its `$request_data` property.

Follow-up to [44606].

Props garrett-eclipse.
Fixes #46302.
Built from https://develop.svn.wordpress.org/trunk@47245


git-svn-id: http://core.svn.wordpress.org/trunk@47045 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-10 19:57:05 +00:00
Sergey Biryukov 641c632b0c Coding Standards: Use Yoda conditions where appropriate.
See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 16:55:09 +00:00
Sergey Biryukov 06979c6597 Docs: Document the addition of `$json_report_pathname` parameter to the `wp_privacy_personal_data_export_file_created` action.
Follow-up to [47146].

Props xkon.
Fixes #49029.
Built from https://develop.svn.wordpress.org/trunk@47150


git-svn-id: http://core.svn.wordpress.org/trunk@46950 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-01 04:17:05 +00:00
Sergey Biryukov 39cef6947a Privacy: Introduce a JSON file into the personal data export.
The produced ZIP archive will now include an `export.json` file along with the current `index.html`.

Props xkon.
Fixes #49029. See #46424.
Built from https://develop.svn.wordpress.org/trunk@47146


git-svn-id: http://core.svn.wordpress.org/trunk@46946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-31 01:36:05 +00:00
Sergey Biryukov eafc40be6d Privacy: Remove user's email address from personal data export filename.
Use `wp_unique_filename()` to avoid potential collisions instead.

Props xkon, garrett-eclipse, donmhico, Ov3rfly, Clorith, allendav.
Fixes #44197.
Built from https://develop.svn.wordpress.org/trunk@47144


git-svn-id: http://core.svn.wordpress.org/trunk@46944 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-31 00:58:06 +00:00
Sergey Biryukov 001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Sergey Biryukov 5955f0938b Privacy: Introduce `wp_privacy_personal_data_email_to` and `wp_privacy_personal_data_email_subject` filters.
Pass email data to the `wp_privacy_personal_data_email_content` filter.

Props garrett-eclipse, thakkarhardik, birgire.
Fixes #46303.
Built from https://develop.svn.wordpress.org/trunk@46265


git-svn-id: http://core.svn.wordpress.org/trunk@46077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-23 19:25:57 +00:00
Sergey Biryukov d2ebf7d0e4 Privacy: Display group items count in the personal data export file if there's more than one item in the group.
Props birgire, garrett-eclipse, pputzer.
Fixes #46895.
Built from https://develop.svn.wordpress.org/trunk@46209


git-svn-id: http://core.svn.wordpress.org/trunk@46021 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-20 20:30:58 +00:00
Sergey Biryukov e199663322 I18N: Capitalize translator comments consistently, add trailing punctuation.
Includes minor code layout fixes.

See #44360.
Built from https://develop.svn.wordpress.org/trunk@45932


git-svn-id: http://core.svn.wordpress.org/trunk@45743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-03 00:41:05 +00:00
Sergey Biryukov d9954ed4cb Privacy: Add descriptions for sections in a personal data export file.
Props garrett-eclipse, Venutius, karmatosed.
Fixes #45491.
Built from https://develop.svn.wordpress.org/trunk@45825


git-svn-id: http://core.svn.wordpress.org/trunk@45636 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-18 02:07:57 +00:00
Sergey Biryukov be6bbe4b5d Administration: Replace legacy `updated` message type in `add_settings_error()` calls with `success`.
See #44640.
Built from https://develop.svn.wordpress.org/trunk@45818


git-svn-id: http://core.svn.wordpress.org/trunk@45629 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-16 00:39:55 +00:00
Andrew Ozz d0c1b77cda Privacy tools:
- Move the (remaining) privacy tools related functions from `wp-admin/includes/file.php` to `wp-admin/includes/privacy-tools.php`.
- Move the `WP_User_Request` class to a separate file.

See #43895.
Built from https://develop.svn.wordpress.org/trunk@45519


git-svn-id: http://core.svn.wordpress.org/trunk@45330 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-06-10 23:54:53 +00:00
Andrew Ozz 87acdab81d Privacy tools: Organize privacy functions into logical files and classes.
Props xkon, birgire, desrosj, garrett-eclipse, azaozz.
See #43895.
Built from https://develop.svn.wordpress.org/trunk@45448


git-svn-id: http://core.svn.wordpress.org/trunk@45259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-26 20:50:53 +00:00