Do not call the `prepare_links` methods in core REST API controllers, unless the `_links` or `_embedded` fields are requested. There is no need to prepare links if they are never returned in the response. This saves resources, as many calls to `prepare_links` methods perform database queries.
Props Spacedmonkey, timothyblynjacobs, rachelbaker, desrosj, dlh, hellofromTonya.
Fixes#52992.
Built from https://develop.svn.wordpress.org/trunk@53760
git-svn-id: http://core.svn.wordpress.org/trunk@53319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Add new function called `wp_get_lastest_revision_id_and_total_count`, that performs an optimized query to get the last revision and total and use it in `WP_REST_Posts_Controller` class.
Props Spacedmonkey, timothyblynjacobs, furi3r, peterwilsoncc.
Fixes#55857.
Built from https://develop.svn.wordpress.org/trunk@53759
git-svn-id: http://core.svn.wordpress.org/trunk@53318 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This brings consistency to similar code fragments that evolved in slightly different ways over the years:
* A check that the list of functions is not empty now exists in both editors.
* "Function Name..." is an option label, not an attribute, so `esc_html__()` is the correct function here.
* `esc_attr( urlencode( $function ) )` in the theme editor is replaced with `esc_attr( $function )`.
* `htmlspecialchars( $function )` in the theme editor is replaced with `esc_html( $function )`.
Follow-up to [10607], [10879], [11110], [11173], [11204], [11671], [14989].
Props aristath, justinahinon, poena, audrasjb, pratiweb, SergeyBiryukov.
Fixes#56007.
Built from https://develop.svn.wordpress.org/trunk@53758
git-svn-id: http://core.svn.wordpress.org/trunk@53317 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This avoids a fatal error if the file is included directly outside of WordPress core, e.g. by HyperDB.
Additionally, replace `WPINC` with `wp-includes`, as the constant may not be defined yet in that context.
Follow-up to [53749], [53750].
See #56268, #55647.
Built from https://develop.svn.wordpress.org/trunk@53755
git-svn-id: http://core.svn.wordpress.org/trunk@53314 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset adds Unicode sequence normalization from NFD to NFC, via the `normalizer_normalize()` PHP function which is available with the recommended `intl` PHP extension.
This fixes an issue where NFD characters were not properly sanitized. It also provides a unit test for NFD sequences (alternate Unicode representations of the same characters).
Props NumidWasNotAvailable, targz, nacin, nunomorgadinho, p_enrique, gitlost, SergeyBiryukov, markoheijnen, mikeschroder, ocean90, pento, helen, rodrigosevero, zodiac1978, ironprogrammer, audrasjb, azaozz, laboiteare, nuryko, virgar, dxd5001, onnimonni, johnbillion.
Fixes#24661, #47763, #35951.
See #30130, #52654.
Built from https://develop.svn.wordpress.org/trunk@53754
git-svn-id: http://core.svn.wordpress.org/trunk@53313 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Add the loaded php extensions as well as whether the server's image libraries support WebP and AVIF image formats to the data payload sent during upgrade checks. Collecting this data with the WordPress.org API will help the project make more data driven decisions about feature support. Note that all data can still be filtered with the `core_version_check_query_args` filter for privacy reasons.
Props dd32, SergeyBiryukov, mikeschroder, pbiron.
Fixes#48116.
Built from https://develop.svn.wordpress.org/trunk@53753
git-svn-id: http://core.svn.wordpress.org/trunk@53312 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset adds the capability for core media uploads to generate sub sized images in more than a single mime type. The output formats for each mime type can be controlled through a filter. WebP is used as an additional output format for JPEG images by default to improve front end performance.
When generating additional mime types, only images which are smaller than the respective original are retained. By default, additional mime type images are only generated for the built-in core image sizes and any custom sizes that have opted in.
Image meta is updated with a new 'sources' array containing file details for each mime type. Each image size in the 'sizes' array also gets a new 'sources' array that contains the image file details for each mime type.
This change also increases image upload retries to accommodate additional image sizes. It also adds a `$mime_type` parameter to the `wp_get_missing_image_subsizes` function and filter.
This change adds three new filters to enable full control of secondary mime image generation and output:
* A new filter `wp_image_sizes_with_additional_mime_type_support` that filters the sizes that support secondary mime type output. Developers can use this to control the output of additional mime type sub-sized images on a per size basis.
* A new filter `wp_upload_image_mime_transforms` that filters the output mime types for a given input mime type. Developers can use this to control generation of additional mime types for a given input mime type or even override the original mime type.
* A new filter `wp_content_image_mimes` which controls image mime type output selection and order for frontend content. Developers can use this to control the mime type output preference order for content images. Content images inserted from the media library will use the available image versions based on the order from this filter.
Thanks to the many contributors who helped develop, test and give feedback on this feature.
A haiku to summarize:
Upload a JPEG
Images of all sizes
Output as WebPs
Props flixos90, MatthiasReinholz, studiolxv, markhowellsmead, eatingrules, pbiron, mukesh27, joegrainger, mehulkaklotar, tweetythierry, akshitsethi, peterwilsoncc, eugenemanuilov, mitogh, shetheliving, clarkeemily, codekraft, mikeschroder, clorith, kasparsd, spacedmonkey, trevorpfromsandee, jb510, scofennellgmailcom, seedsca, cagsmith, karinclimber, dainemawer, baxbridge, grapplerulrich, sobatkras, chynnabenton, tonylocalword, barneydavey, kwillmorth, garymatthews919, olliejones, imarkinteractive, jeffpaul, feastdesignco, webbeetle, masteradhoc.
See #55443.
Built from https://develop.svn.wordpress.org/trunk@53751
git-svn-id: http://core.svn.wordpress.org/trunk@53310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This renames the file containing the `wpdb` class to conform to the coding standards.
This commit also includes:
* A new `wp-db.php` that loads the new file, for anyone that may have been including the file directly.
* Replacing references to the old filename with the new filename.
Fixes#56268. See #55647.
Built from https://develop.svn.wordpress.org/trunk@53749
git-svn-id: http://core.svn.wordpress.org/trunk@53308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset improves admin forms accessibility by adding labels to the following read-only form fields:
- Network setup screen: new visible label to the four textareas for code users need to paste into their wp-config file and the server configuration file (web.config or .htaccess).
- `setup-config.php`: new visible label to one textarea for code to include in the `wp-config` file manually.
- Admin toolbar: adds an `arial-label` attribute to the old "shortlink" feature (not used anymore but still activable by plugins).
Props sabernhardt, audrasjb, ryokuhi, joedolson.
Fixes#54302.
Built from https://develop.svn.wordpress.org/trunk@53745
git-svn-id: http://core.svn.wordpress.org/trunk@53304 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset introduces the `get_header_image` filter, which can be used to modify header image URL returned by `get_header_image()`, in themes that support the Header Image feature.
Props hztyfoon, audrasjb, mukesh27, SergeyBiryukov, costdev.
Fixes#56180.
Built from https://develop.svn.wordpress.org/trunk@53741
git-svn-id: http://core.svn.wordpress.org/trunk@53300 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This improves the tag pattern matching for GitHub Action workflows to be more specific. The `*` wildcard in the current patterns matches any character except slash (`/`). While this correctly matches a version like `X.Y.Z`, it could also match non-numeric characters.
This changes patterns to use the `+` character, which matches one or more of the preceding characters (`[0-9]` in this case).
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53736
git-svn-id: http://core.svn.wordpress.org/trunk@53295 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When trying to determine the outcome of the previous run for a GitHub Action workflow, the current run is included in the list fetched from the GitHub API.
This adjusts the logic checking for the previous run to account for that and fixes notifications for the first workflow runs of a new branch or tag.
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53735
git-svn-id: http://core.svn.wordpress.org/trunk@53294 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The function was erroneously calling `is_wp_error()` on the result of a `get_post()` call, which returns `null` on failure, and never returns a `WP_Error` object.
Previously, passing a non-existing post ID to the function would result in a home URL being returned and a few `Attempt to read property "post_type, post_name, hierarchical..." on null` PHP warnings.
This commit ensures `get_post_permalink()` returns `false` on failure, which brings parity with `get_permalink()`.
Includes a unit test to confirm the correct behavior.
Follow-up to [12923], [13023], [32606].
Props renegeuze, manzoorwani.jk.
Fixes#45329.
Built from https://develop.svn.wordpress.org/trunk@53733
git-svn-id: http://core.svn.wordpress.org/trunk@53292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This removes all CSS definitions related to the `.icon16` class. Research shows that current ecosystem usage of this class is extremely minimal.
This selector was used for the Welcome Panel and Welcome Screen in WordPress 3.3 (see [19163] and [19197]. The icons were removed for WordPress 3.5 in [22018], but the related CSS remained, and were also included when the MP6 admin re-skinning was merged in [26072].
Props afercia, mmaumio, isabel_brison, sabernhardt, audrasjb, desrosj.
Fixes#35717.
Built from https://develop.svn.wordpress.org/trunk@53731
git-svn-id: http://core.svn.wordpress.org/trunk@53290 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `wp_new_comment()`, `wp_update_comment()`, and `wp_filter_comment()` functions already normalize the `user_ID` parameter internally to `user_id`, which matches the database field name.
This commit aims to bring some consistency when passing the parameter in core.
The corresponding `$user_ID` variable is also renamed to `$user_id` to match the other variables when not referring to the `$user_ID` global, which has an exception in the WordPress coding standards.
Follow-up to [8543], [8720], [12267], [12300], [26491], [28915], [28922], [34799], [49303].
See #55647, #56244.
Built from https://develop.svn.wordpress.org/trunk@53729
git-svn-id: http://core.svn.wordpress.org/trunk@53288 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset replaces `#d63638` (contrast ratio: 4.40) with `#b32d2e` (contrast ratio: 5.87) in Plugins screen row action links when the site is in recovery mode.
Props kebbet, mukesh27, joedolson, audrasjb.
Fixes#56190.
Built from https://develop.svn.wordpress.org/trunk@53726
git-svn-id: http://core.svn.wordpress.org/trunk@53285 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This moves the `::prepare_links()` methods in REST API classes next to `::prepare_item_for_response()` where they are used, to bring some consistency across the classes and make code navigation easier.
Includes wrapping some long lines for better readability.
Follow-up to [52079], [52051], [52342], [53721], [53722].
See #55647.
Built from https://develop.svn.wordpress.org/trunk@53724
git-svn-id: http://core.svn.wordpress.org/trunk@53283 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This fixes two WPCS warnings:
* `Variable "$comment_post_ID" is not in valid snake_case format`
* `Variable "$comment_author_IP" is not in valid snake_case format`
While matching the database fields of the same name, these variables did not follow the WordPress coding standards, and are now renamed to address that.
Note: The name change only affects internal variables and parameters for a few actions receiving a comment post ID:
* `edit_comment`
* `comment_id_not_found`
* `comment_closed`
* `comment_on_trash`
* `comment_on_draft`
* `comment_on_password_protected`
* `pre_comment_on_post`
The change does not affect parameters for functions receiving an array of comment data:
* `wp_insert_comment()`
* `wp_new_comment()`
* `wp_update_comment()`
* `wp_handle_comment_submission()`
The associated array keys still match the database fields: `comment_post_ID` and `comment_author_IP`.
Follow-up to [1706], [2894], [8720], [28427], [28437], [28457], [34799], [53720],
See #55647, #56244.
Built from https://develop.svn.wordpress.org/trunk@53723
git-svn-id: http://core.svn.wordpress.org/trunk@53282 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This fixes a `Variable "$comment_post_ID" is not in valid snake_case format` WPCS warning.
`$comment_post_ID`, while matching the database field of the same name, does not follow the WordPress coding standards, so the variable is now renamed to `$comment_post_id`.
Additionally, these variables are renamed for clarity:
* `$tb_id` to `$post_id` (this was not the trackback ID)
* `$tb_url` to `$trackback_url`
Follow-up to [172], [637], [1616],
See #55647, #56244.
Built from https://develop.svn.wordpress.org/trunk@53719
git-svn-id: http://core.svn.wordpress.org/trunk@53278 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When registering block through PHP, using `register_block_type` function, newly introduced `ancestor` block setting in `block.json` was not recognised. It worked though, when block is registered from JavaScript.
Props lovor, annezazu.
Fixes#56184.
Built from https://develop.svn.wordpress.org/trunk@53718
git-svn-id: http://core.svn.wordpress.org/trunk@53277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Includes:
* Wrapping longer lines and reducing alignment levels to fit more data on the screen.
* Restoring `esc_attr()` for input values, which may include translatable parts.
* Adding comments to closing `</div>` tags and PHP `endif` statements.
* Reducing the context switching between HTML and PHP.
* Balancing PHP conditionals to better reflect the structure.
* Removing repeated function calls to improve performance.
* Renaming some variables for clarity and consistency.
Follow-up to [470], [601], [963], [1227], [1664], [2746], [3029], [6976], [7230], [11350], [14051], [14553], [21891], [34691], [34749], [37747], [38066], [41182], [41986], [42343], [43571], [48710], [50830], [51892], [53706].
See #55647.
Built from https://develop.svn.wordpress.org/trunk@53710
git-svn-id: http://core.svn.wordpress.org/trunk@53269 1a063a9b-81f0-0310-95a4-ce76da25c4cd