Commit Graph

1866 Commits

Author SHA1 Message Date
audrasjb
89804fb0db General: Validate host on "Are you sure?" screen.
Props voldemortensen, xknown, peterwiloncc.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-17 11:04:12 +00:00
audrasjb
c985972791 Posts, Post Types: Ensure all entries in the list returned by wp_parse_list() are scalar.
This changeset fixes a warning where `strip_tags()` expected its first parameter to be a string rather than an array. It contains the following changes:

- Removal of sanitize_callback to allow the REST API to handle the validation natively, this also causes the proper error to be output for `?slug[0][1]=2` that it's an invalid value.
- Ensure that `wp_parse_list()` only returns a single-dimensioned array, even if passed a multi-dimension array, which fits the functions expected use case and resolves warnings in code that expects the function to return a single-dimensioned array.

Props dd32, TimothyBlynJacobs.
Fixes #55838.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54035 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-11 13:25:11 +00:00
audrasjb
d95f088a3e General: Remove instances of _wp_http_referer from GET forms in the admin.
This changeset removes all instances of `_wp_http_referer` variable from the URL when creating a hidden input for `_wp_http_referer`. It prevents the hidden field from having an additional version of `_wp_http_referer` each time the form is submitted.

Props msolution, justinahinon, pbearne, mikeschroder, mukesh27, audrasjb, Clorith, chaion07, robinwpdeveloper, hztyfoon, davidbaumwald, costdev, adamsilverstein.
Fixes #54106.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-10 18:59:11 +00:00
Sergey Biryukov
aaffa2bcff General: Remove file_exists() checks after calling realpath().
`realpath()` already checks if the file exists, and returns `false` on failure. The additional `file_exists()` check is not necessary and can be removed, improving the performance.

This commit simplifies the checks in two functions:
* `register_block_type_from_metadata()`
* `wp_json_file_decode()`

Note: In both of these cases, the values are passed through `wp_normalize_path()` after `realpath()`, so if the file does not exist, the `false` value gets converted to an empty string. The updated checks work both for `false` and `''` values.

Though this is a small tweak, it saves a lot of checks since one of the places we do this is when registering block styles, so it runs quite a few times on each page load.

Reference: [https://www.php.net/manual/en/function.realpath.php PHP Manual: realpath()].

Follow-up to [51599], [54132], [54290], [54291].

Props aristath.
Fixes #56654.
Built from https://develop.svn.wordpress.org/trunk@54309


git-svn-id: http://core.svn.wordpress.org/trunk@53868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-26 13:07:14 +00:00
Sergey Biryukov
3d245c574e General: Correct the fallback logic in apache_mod_loaded().
If the `apache_get_modules()` function is redeclared to return an empty array, `apache_mod_loaded()` would assume that no Apache modules are installed and activated, which may not be correct.

This commit improves the logic by using pre-existing `phpinfo()` fallback to check for loaded modules in that case.

Includes replacing a hardcoded number passed as a flag to `phpinfo()` with the `INFO_MODULES` predefined constant for clarity.

Follow-up to [7441], [7508], [29330].

Props engahmeds3ed, audrasjb, Clorith, SergeyBiryukov.
Fixes #56010.
Built from https://develop.svn.wordpress.org/trunk@54299


git-svn-id: http://core.svn.wordpress.org/trunk@53858 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-24 13:53:13 +00:00
davidbaumwald
1b463c4601 Docs: Correct @see reference to deprecated_function_run in the _deprecated_function docblock.
In the docblock for `_deprecated_function`, there is a `@see` reference to the `deprecated_function_run` hook run inside `_deprecated_function`.  However, the `@see` reference includes the word "hook" inside the quotes which is generating a bad link at https://developer.wordpress.org/reference/functions/_deprecated_function/.

This change simply moves the word "hook" outside the `@see` reference to correct the link parsing on https://developer.wordpress.org.

Props Camwynsp, kebbet, SergeyBiryukov, hilayt24.
Fixes #56625.
Built from https://develop.svn.wordpress.org/trunk@54292


git-svn-id: http://core.svn.wordpress.org/trunk@53851 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-23 16:20:09 +00:00
John Blackbourn
c117e5ae74 Docs: Various improvements and corrections to inline docs.
See #55646

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


git-svn-id: http://core.svn.wordpress.org/trunk@53826 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 20:32:09 +00:00
desrosj
7d87ce12c8 Networks and Sites: Officially remove global terms.
Global terms was a feature from the WordPress MU days where multisite and single site installs used different code bases.

In WordPress 3.0, WordPress MU was merged into one location and the UI [14854] and “on” switch [14880] for global terms were completely removed.

Even before this merge, global terms was bug infested and unreliable. After [14854]/[14880], the feature was no longer maintained and became increasingly broken as taxonomies progressed without it (term splitting and term meta do not work at all). At this point, the feature has not worked in 12+ years and there’s no hope for saving it.

This deprecates the remaining global terms related code and no-ops the functions.

Global terms, you don’t have to go home, but you can’t stay here.

Props scribu, wonderboymusic, SergeyBiryukov, nacin, pento, desrosj, johnjamesjacoby, johnbillion, dd32.
Fixes #21734.
Built from https://develop.svn.wordpress.org/trunk@54240


git-svn-id: http://core.svn.wordpress.org/trunk@53799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 02:51:09 +00:00
Sergey Biryukov
526dba25c2 Date/Time: Correct timezone dropdown list creation in wp_timezone_choice().
This fixes a bug where if the `timezone_string` is set to a timezone name which has since been deprecated, no option would be (pre-)selected in the generated dropdown list and when the form using the dropdown list is submitted, the “old”, originally saved value would be lost as the form would submit without a value being selected for the `timezone_string` field.

The fix is a little hacky: it basically checks ahead of generating the actual dropdown list whether the `$selected_zone` value would be recognized and set to “selected” and if not, verifies that the value ''is'' a valid but outdated timezone name and if so, adds an extra dropdown entry to the top of the list with the original value and sets this value to “selected”.

See the extensive write-up about this in ticket #56468.

Also see: [https://www.php.net/manual/en/datetimezone.listidentifiers.php PHP Manual: timezone_identifiers_list()].

Note: There are no pre-existing tests at all for this method and adding a complete set of tests for this method is outside the scope of this ticket, so this fix does not contain any tests.

Follow-up to [54207], [54217], [54227], [54229], [54230], [54232].

Props jrf, costdev, marcyoast.
See #56468.
Built from https://develop.svn.wordpress.org/trunk@54233


git-svn-id: http://core.svn.wordpress.org/trunk@53792 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 01:02:10 +00:00
davidbaumwald
5eb0223369 Media: Revert WebP generation.
Given [https://make.wordpress.org/core/2022/09/11/webp-in-core-for-6-1/ Matt's recent post about removing WebP from core] and possibly implementing the feature in a future [https://make.wordpress.org/core/2022/09/11/canonical-plugins-revisited/ "Canonical Plugin"], this change reverts changesets [54086], [54094], and [54097].  Additionally, [54210] contained a coding standards follow-up in one of the affected files that is no longer needed.

Reverts [54086], [54094], and [54097].

Props SergeyBiryukov.
See #55443.
Built from https://develop.svn.wordpress.org/trunk@54226


git-svn-id: http://core.svn.wordpress.org/trunk@53785 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-19 22:53:10 +00:00
hellofromTonya
f3ff15edfc Themes: Introduces block-based template parts for Classic themes.
Allows Classic / Hybrid themes to use block-based template parts without using complete block-based templates.

* Exposes the Site Editor's template parts UI
* Adds Appearance > "Template Parts" menu
* Enabled within the theme via adding a theme support for `'block-template-parts'`
{{{#!php
add_theme_support( 'block-template-parts' );
}}}

This is a backport from Gutenberg.[https://github.com/WordPress/gutenberg/pull/42729 See WordPress/gutenberg PR 42729].

Follow-up to [52330], [52069], [52178].

Props mamaduka, fabiankaegy, poena, scruffian, manfcarlo, bernhard-reiter, hellofromTonya.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54176


git-svn-id: http://core.svn.wordpress.org/trunk@53735 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-15 12:20:09 +00:00
Sergey Biryukov
a2aa01cdac Docs: Correct @return value for wp_get_http_headers().
Following the update to replace the HTTP API internals with Requests library in WordPress 4.6, the return value of `wp_remote_retrieve_headers()` has changed from a simple array to an object which implements `ArrayAccess`.

Since `wp_get_http_headers()` directly returns the result of `wp_remote_retrieve_headers()`, its return value should reflect that change.

Includes:
* Updating the return value for the deprecated `wp_get_http()` function, which also directly returns the result of `wp_remote_retrieve_headers()`.
* Minor DocBlock formatting changes for some other HTTP API functions per the documentation standards.

Follow-up to [2416], [6390], [8092], [9013], [37428], [37989], [38730].

Props mhkuu.
See #54225, #55646.
Built from https://develop.svn.wordpress.org/trunk@54157


git-svn-id: http://core.svn.wordpress.org/trunk@53716 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-14 13:08:14 +00:00
davidbaumwald
1db23fca3f General: Correct path replacement regex in wp_guess_url.
In `wp_guess_url`, the regex to check for wp-login.php in the URL is slightly too permissive, not escaping `.` in "wp-login.php".  `.` is a token in regex that matches any character.

This change simply escapes the `.` and adds unit test coverage for `wp_guess_url`.

Props cfinke, ocean90, jrf, voldemortensen, jdgrimes, curdin, netweb, petitphp, SergeyBiryukov, costdev.
Fixes #36827.
Built from https://develop.svn.wordpress.org/trunk@54146


git-svn-id: http://core.svn.wordpress.org/trunk@53705 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-13 19:50:12 +00:00
Felix Arntz
610d2d6a44 Media: Generate WebP only for certain registered image sizes.
The existing filter `image_editor_output_format` receives an additional parameter `$size_name` which is populated whenever it controls the output format for a specific registered image size to create. Otherwise, it remains empty. In order to achieve this, a low level change has been added in bringing a new `$size_name` class property to the `WP_Image_Editor` base class, which is introduced in a backward compatible way that will not cause conflicts with custom implementations.

This parameter is then used in new logic inside the `wp_default_image_output_mapping()` callback function for the filter, controlling whether `image/jpeg` should map to `image/webp` output or not. By default, this is enabled for all WordPress core image sizes by default, and this list can be modified using a new `wp_image_sizes_with_additional_mime_type_support` filter, e.g. to remove core sizes or add custom sizes.

The customization per image size may be further enhanced by providing a more declarative API via a new parameter on the `add_image_size()` function.

Props eugenemanuilov, flixos90, adamsilverstein, joegrainger.

Fixes #56526.
See #55443, #56288.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53656 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-07 21:45:14 +00:00
antpb
6a03ea5001 Coding Standards: Use strict comparisons in path_is_absolute().
This patch adjusts conditions to use strict comparisons when comparing `realpath()` in `path_is_absolute()`.

Props jrf.
See #36308.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-26 18:59:13 +00:00
Peter Wilson
ba9dd1d7d7 Cache API, Docs: Remove private delegation from cache priming functions.
Remove the private delegation from the following cache priming functions for various object types:

- `_prime_post_caches()`
- `_prime_term_caches()`
- `_prime_comment_caches()`
- `_prime_network_caches()`
- `_prime_site_caches()`
- `_get_non_cached_ids() `

Plugins and themes are now encouraged to use these functions to improve the performance of their code by reducing the number of database queries.

Props robinwpdeveloper, desrosj, SergeyBiryukov, mukesh27, costdev.
Fixes #56386.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53503 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-26 01:03:14 +00:00
antpb
0406a3ffd7 Media: Account for Windows when normalizing file paths.
Previously, Windows paths in the `path_is_absolute` function resulted in incorrect URIs. This patch adjusts for forward slashes and adds tests for the `get_attached_file` function.
Props Whissi, SergeyBiryukov, desrosj, stevenlinx, birgire, davidbaumwald, costdev, peterwilsoncc, audrasjb, hellofromTonya, johnbillion.
Fixes #36308.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-23 19:59:14 +00:00
audrasjb
32879ad1e6 Docs: Use third-person singular verbs for function descriptions in wp-includes/functions.php, as per docblocks standards.
See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-12 09:53:11 +00:00
audrasjb
05f7d32a83 Formatting: Add support for Enums in is_serialized().
This changeset adds support for Enums in `is_serialized()`. It also adds new unit tests for this function.

Props ayeshrajans, konradyoast, peterwilsoncc, costdev, dennisatyoast, mukesh27.
Fixes #53299.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53445 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-12 09:26:12 +00:00
John Blackbourn
77bf28a1b7 Docs: Miscellaneous inline documentation improvements.
See #55646

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


git-svn-id: http://core.svn.wordpress.org/trunk@53437 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 14:11:08 +00:00
audrasjb
46c1425601 Docs: Improve the description of param $list in wp_list_sort() docblock.
Props audrasjb, rherault.
Fixes #56324.
See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53370 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-02 14:50:12 +00:00
Sergey Biryukov
749720d897 Text Changes: Improve consistency of punctuation in some strings.
* Move the colon inside the `<strong>` tags in some `Error:` prefixes, to match other strings.
* Move the full stop at the end of some sentences outside of the `<strong>` tags used for individual phrases.

Follow-up to [11669], [23844], [53118], [53458], [53476].

Props NekoJonez, Presskopp.
Fixes #56027.
Built from https://develop.svn.wordpress.org/trunk@53700


git-svn-id: http://core.svn.wordpress.org/trunk@53259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-14 14:10:11 +00:00
Sergey Biryukov
1d2e969b50 General: Remove redundant ltrim() from path_join().
If the path starts with a slash, it will be considered absolute and returned as is earlier in the function.

It it's not absolute, then it does not start with a slash, so there is nothing to trim.

This change is covered by existing unit tests.

Follow-up to [6984], [53457].

Props karlijnbk.
See #55897.
Built from https://develop.svn.wordpress.org/trunk@53460


git-svn-id: http://core.svn.wordpress.org/trunk@53049 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-02 15:31:08 +00:00
Sergey Biryukov
40fc19024f Code Modernization: Replace phpversion() function calls with PHP_VERSION constant.
`phpversion()` return value and `PHP_VERSION` constant value are identical, but the latter is several times faster because it is a direct constant value lookup compared to a function call.

Props ayeshrajans, jrf, mukesh27, costdev, hellofromTonya, SergeyBiryukov.
Fixes #55680.
Built from https://develop.svn.wordpress.org/trunk@53426


git-svn-id: http://core.svn.wordpress.org/trunk@53015 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-05-20 17:38:14 +00:00
Peter Wilson
8545c4493b Media: Remove error suppression in wp_filesize().
Replace error suppressing in `wp_filesize()` with a `file_exists()` check before calling the native PHP `filesize()` function.

Follow up to [52837].

Props Cybr, johnbillion, spacedmonkey, antpb, azouamauriac, ironprogrammer, mukesh27, costdev, audrasjb, dlh.
Fixes #55678.
See #49412.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52961 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-05-10 05:02:11 +00:00
John Blackbourn
cd9aade1bd Docs: Formatting corrections for various docblocks.
See #54729

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


git-svn-id: http://core.svn.wordpress.org/trunk@52906 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-29 19:24:09 +00:00
John Blackbourn
6aa053dc01 Docs: Various docblock improvements.
See #54729

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


git-svn-id: http://core.svn.wordpress.org/trunk@52888 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-28 09:46:21 +00:00
Sergey Biryukov
752429a58e Code Modernization: Rename parameters that use reserved keywords in wp_die_*_handler filters.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit renames the `$function` parameter to `$callback` in `wp_die_*_handler` filters, which aims to make it easier to use a non-reserved parameter name for anyone utilizing these filters.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.
Built from https://develop.svn.wordpress.org/trunk@53243


git-svn-id: http://core.svn.wordpress.org/trunk@52832 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-22 10:43:20 +00:00
audrasjb
b6c2df9325 Docs: Update MDN link in send_frame_options_header() docblock.
The X-Frame-Options MDN documentation has been moved to `/docs/Web/HTTP/Headers/X-Frame-Options`. This changeset updates the link accordingly.

See #54729.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52791 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-18 10:18:10 +00:00
audrasjb
f087315090 Text Changes: Fix various inconsistent capitalization issues.
Props Presskopp, arpitgshah, mukesh27, desrosj, audrasjb, marybaum.
Fixes #53028.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52775 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-15 11:58:10 +00:00
gziolo
9e3c5a4215 Editor: Add functionality required for theme export in the site editor
This bring across changes to theme export functionality, and related code, and tests. Relates issue in Gutenberg: https://github.com/WordPress/gutenberg/issues/39889.

Props scruffian, timothyblynjacobs, oandregal, ajlende, zieleadam.
See #55505.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52718 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-11 10:38:00 +00:00
audrasjb
f680e20156 General: add missing strong tag to some error messages.
Props NekoJonez, oakesjosh.
Fixes #54437.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52707 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-10 19:47:02 +00:00
Sergey Biryukov
9fb5112732 Docs: Add missing description for $pagenow global in various functions.
See #54729, #55499.
Built from https://develop.svn.wordpress.org/trunk@53060


git-svn-id: http://core.svn.wordpress.org/trunk@52649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-04 18:26:06 +00:00
Peter Wilson
14e965a8d6 General: Validate input of wp_list_pluck().
`wp_list_pluck()` is used by WordPress to pluck items from a list. Of course, this requires a list. This validates the input of `wp_list_pluck()` to ensure it is a list.

This matches the behaviour of `wp_list_sort()` and `wp_filter_object_list()`.

Props marv2, davidbaumwald, mkox, SergeyBiryukov, dd32.
Fixes #54751.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-01 05:56:06 +00:00
Peter Wilson
33b6697191 Formatting: Account for HTML entities in wp_extract_urls().
Prevent `wp_extract_urls()` trimming HTML entities within URLs. Correctly escaped URLs such as https://youtube.com/watch?v=dQw4w9WgXcQ&amp;t=1 will now be extracted as https://youtube.com/watch?v=dQw4w9WgXcQ&t=1 rather than truncated.

Props trex005, voldemortensen, johnbillion, ironprogrammer, costdev, hellofromtonya.
Fixes #30580


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


git-svn-id: http://core.svn.wordpress.org/trunk@52633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-01 03:40:02 +00:00
audrasjb
6a97b83d01 Docs: Typo correction in wp_fuzzy_number_match DocBlock.
Props costdev, kebbet.
Fixes #55493.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-31 08:17:06 +00:00
audrasjb
31c9e9452a Administration: Do not specify menu order for the Widgets menu when the active theme is a block theme.
When using a block theme that declares Widgets support, it's better to not specify a menu order for the Widgets menu to avoid conflicts between menu items order.

Props Rufus87, ironprogrammer, audrasjb, hellofromTonya, davidbaumwald.
Fixes #54916.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52609 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-29 15:59:22 +00:00
Sergey Biryukov
8dc9fafcb6 Users: Move get_user_count() and related functions to wp-includes/user.php.
The new location is next to the pre-existing `count_users()` function, along with other user-specific functions, and should be a more appropriate place in terms of consistency.

This affects:
* `get_user_count()`
* `wp_maybe_update_user_counts()`
* `wp_update_user_counts()`
* `wp_schedule_update_user_counts()`
* `wp_is_large_user_count()`

Follow-up to [53011], [53016].

See #38741.
Built from https://develop.svn.wordpress.org/trunk@53018


git-svn-id: http://core.svn.wordpress.org/trunk@52607 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-29 13:53:14 +00:00
Sergey Biryukov
cd8db5e05f I18N: Move code out of a translatable string in get_user_count() and related functions.
Follow-up to [53011].

See #38741.
Built from https://develop.svn.wordpress.org/trunk@53016


git-svn-id: http://core.svn.wordpress.org/trunk@52605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-29 13:38:09 +00:00
spacedmonkey
e2e15f1876 Users: Introduce the concept of a large site to single site installations.
Currently in WordPress multisite there is a concept of large networks. The function `wp_is_large_network` is used to determine if a network has a large number of sites or users. If a network is marked as large, then 
expensive queries to calculate user counts are not run on page load but deferred to scheduled events. However there are a number of places in a single site installation where this functionality would also be useful, as 
expensive calls to count users and roles can make screens in the admin extremely slow.

In this change, the `get_user_count` function and related functionality around it is ported to be available in a single site context. This means that expensive calls to the `count_users` function are replaced with 
calls to `get_user_count`. This change also includes a new function called `wp_is_large_user_count` and a filter of the same name, to mark if a site is large.

Props johnbillion, Spacedmonkey, Mista-Flo, lumpysimon, tharsheblows, obenland, miss_jwo, jrchamp, flixos90, macbookandrew, pento, desrosj, johnjamesjacoby, jb510, davidbaumwald, costdev. 
Fixes #38741.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52600 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-29 12:42:13 +00:00
John Blackbourn
7f9c9dc731 Formatting: Add support for formatting sizes as PB, EB, ZB, and YB.
Props henry.wright, Presskopp

Fixes #40875

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


git-svn-id: http://core.svn.wordpress.org/trunk@52544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-18 20:48:02 +00:00
Sergey Biryukov
0d747500ba I18N: Move wp_get_list_item_separator() to a more appropriate place.
Follow-up to [52929].

See #39733.
Built from https://develop.svn.wordpress.org/trunk@52933


git-svn-id: http://core.svn.wordpress.org/trunk@52522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-14 18:01:02 +00:00
hellofromTonya
316aa2544f Media: Relocate wp_filesize() function for use in frontend and backend.
A new function `wp_filesize()` was added with [52837]. The function lived in the `wp-admin/includes/file.php` file. However, this admin specific function is not loaded into memory when hitting `media/edit` endpoint. The result was a `500` Internal Server Error. Why? The function is invoked with that endpoint, but the function does not exist in memory.

This commit relocates the new function to the `wp-includes/functions.php` file. In doing so, the function is available for both the frontend and backend.

Follow-up to [52837].

Props talldanwp, spacedmonkey, costdev, antonvlasenko.
Fixes #55367.
Built from https://develop.svn.wordpress.org/trunk@52932


git-svn-id: http://core.svn.wordpress.org/trunk@52521 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-14 16:32:06 +00:00
audrasjb
30a77d5fa4 i18n: Define List item separator as a WP_Locale property.
The list item separator is a locale property, and it doesn't make much sense to translate it separately in multiple projects. This changeset implements the following modifications:

- Define list item separator as a new WP_Locale property
- Add `wp_get_list_item_separator()` as a wrapper for `WP_Locale::get_list_item_separator`
- Replace `$wp_locale->get_list_item_separator()` calls with `wp_get_list_item_separator()`
- Added a compatibility layer for bundled themes

Props SergeyBiryukov, swissspidy, rsiddharth, johnbillion, audrasjb.
Fixes #39733.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52518 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-13 20:03:01 +00:00
Peter Wilson
a793be201b Media: Revert query string support for wp_check_filetype().
Revert [52829] due to fatal errors in some Multisite configurations.

Props dd32, SergeyBiryukov, audrasjb.
See #30377.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52421 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-09 00:48:05 +00:00
audrasjb
28f7345fce Media: Allow wp_check_filetype() to support query strings in URLs.
This changeset adjusts the regex in `wp_check_filetype()` to support query strings in URLs.

Follow-up to [30640], [32172].

Props voldemortensen, johnbillion, layotte, dd32, atomicjack, supercleanse, spencercameron, ianmjones, audrasjb.
Fixes #30377.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-07 22:52:05 +00:00
Sergey Biryukov
77b1aa0cf3 Docs: Fix typo in a comment in wp_get_image_mime().
Follow-up to [39831].

Props dilipbheda.
Fixes #55154.
Built from https://develop.svn.wordpress.org/trunk@52719


git-svn-id: http://core.svn.wordpress.org/trunk@52308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-12 14:45:00 +00:00
Sergey Biryukov
734960733e Code Modernization: Use file_get_contents() in wp_get_image_mime().
`file_get_contents()` is faster than `fread()`, because the PHP core can decide how to best read the remaining file; it could decide to issue just one `read()` call or `mmap()` the file first.

Per the PHP manual, `file_get_contents()` or `stream_get_contents()` is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by the OS to enhance performance.

Reference: [https://www.php.net/manual/en/function.file-get-contents.php PHP Manual: file_get_contents()].

Follow-up to [50810], [52696], [52698].

Props maxkellermann.
See #55069.
Built from https://develop.svn.wordpress.org/trunk@52701


git-svn-id: http://core.svn.wordpress.org/trunk@52290 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-11 15:50:05 +00:00
Sergey Biryukov
8a62f7dc05 Code Modernization: Use file_get_contents() in get_file_data().
`file_get_contents()` is faster than `fread()`, because the PHP core can decide how to best read the remaining file; it could decide to issue just one `read()` call or `mmap()` the file first.

Per the PHP manual, `file_get_contents()` or `stream_get_contents()` is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by the OS to enhance performance.

Reference: [https://www.php.net/manual/en/function.file-get-contents.php PHP Manual: file_get_contents()].

Follow-up to [12044], [49073], [52696].

Props maxkellermann.
See #55069.
Built from https://develop.svn.wordpress.org/trunk@52698


git-svn-id: http://core.svn.wordpress.org/trunk@52287 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-10 15:03:04 +00:00
Sergey Biryukov
2eaeae58ff Docs: Update spelling for inline comments in a few files.
Per the [https://make.wordpress.org/core/handbook/best-practices/spelling/ spelling] and [https://make.wordpress.org/docs/style-guide/language-grammar/word-choice/ word choice] documentation guidelines, American (US) spelling should be preferred.

Props mohadeseghasemi, subrataemfluence, rehanali, SergeyBiryukov.
Fixes #46837.
Built from https://develop.svn.wordpress.org/trunk@52640


git-svn-id: http://core.svn.wordpress.org/trunk@52229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-25 13:55:05 +00:00