Commit Graph

2020 Commits

Author SHA1 Message Date
jonsurrell
5e1414562a Scripts: Remove default type attribute from tags.
`SCRIPT`, `STYLE`, and stylesheet `LINK` tags do not require a type attribute since the HTML5 standard was released in 2008. Removing the type attribute simplifies logic and normalizes the produced HTML content.

Developed in https://github.com/WordPress/wordpress-develop/pull/10658.

Follow-up to [46164].

Props hardikhuptechdev, jonsurrell, dmsnell, westonruter.
Fixes #64428. See #59883, #64442.

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


git-svn-id: http://core.svn.wordpress.org/trunk@60723 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-12-26 13:16:34 +00:00
John Blackbourn
133d50d5a2 Docs: Miscellaneous improvements and corrections to inline documentation.
See #64224

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


git-svn-id: http://core.svn.wordpress.org/trunk@60699 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-12-16 20:21:37 +00:00
Weston Ruter
a49aba3014 Docs: Add missing descriptions and fix types for some @return tags.
Props huzaifaalmesbah, sabernhardt, westonruter.
See #64224.
Fixes #64262.

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


git-svn-id: http://core.svn.wordpress.org/trunk@60582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-11-19 06:17:32 +00:00
johnjamesjacoby
5cd43e9b41 Date/Time: Prevent a PHP exception when inserting posts with a partially malformed post_date.
This commit updates `wp_resolve_post_date()` to use a regular expression for parsing the date string into year, month, and day matches. This approach handles missing leading zeros more reliably than `substr()` while remaining performant (see #57683).

It also adds checks and type-casting to `wp_checkdate()` variables before passing them into PHP's `checkdate()` function to avoid the potential for a `TypeError` in PHP 8 and newer (see #54186).

Lastly, it includes 2 new unit tests (with data providers) to cover an array of valid and invalid date formats (YYYY-MM-DD, YYYY-MM-DD HH:MM:SS, ISO 8601, RSS, leap years, malformed inputs, etc...)

Props alordiel, desrosj, johnbillion, johnjamesjacoby, johnregan3, modius5150, nacin, pbearne.

Fixes #26798.
Built from https://develop.svn.wordpress.org/trunk@61172


git-svn-id: http://core.svn.wordpress.org/trunk@60508 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-11-06 23:37:31 +00:00
Sergey Biryukov
7065ba5866 Docs: Update MDN Web Docs link to avoid an extra redirect.
Follow-up to [41741], [59712].

See #63166.
Built from https://develop.svn.wordpress.org/trunk@60922


git-svn-id: http://core.svn.wordpress.org/trunk@60258 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-10 23:17:31 +00:00
Weston Ruter
8dc4b2a207 Script Loader: Add sourceURL comments to inline SCRIPT tags manually constructed in wp-includes.
This applies to tags constructed without `wp_get_inline_script_tag()`/`wp_print_inline_script_tag()`.

Developed in https://github.com/WordPress/wordpress-develop/pull/9955.

Props westonruter, jonsurrell.
See #63887.

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


git-svn-id: http://core.svn.wordpress.org/trunk@60245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-07 01:24:36 +00:00
Pascal Birchler
310424d1fc Code Modernization: Fix instances of using null as an array offset.
Addresses a new [https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_using_values_null_as_an_array_offset_and_when_calling_array_key_exists deprecation in PHP 8.5].

Props swissspidy.
Fixes #63957.
Built from https://develop.svn.wordpress.org/trunk@60809


git-svn-id: http://core.svn.wordpress.org/trunk@60145 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-09-29 16:29:35 +00:00
Sergey Biryukov
43018cae19 Docs: Clarify the description for get_temp_dir().
Includes a note that `sys_get_temp_dir()` honors the `TMPDIR` environment variable.

Follow-up to [17555], [22008], [28936].

Props TimoTijhof, SergeyBiryukov.
See #63711.
Built from https://develop.svn.wordpress.org/trunk@60776


git-svn-id: http://core.svn.wordpress.org/trunk@60112 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-09-17 13:37:39 +00:00
Sergey Biryukov
126fc3b4ca Code Modernization: Address no-op function deprecations in PHP 8.5.
Several PHP functions that have not been doing anything since PHP 8.0/8.1, specifically:

* `finfo_close()` since the `ext/fileinfo` migration in PHP 8.1
* `xml_parser_free()` since the `ext/xml` migration in PHP 8.0
* `curl_close()` since the `ext/curl` migration in PHP 8.0
* `curl_share_close()` since the `ext/curl` migration in PHP 8.0
* `imagedestroy()` since the `ext/gd` migration in PHP 8.0

will be deprecated in PHP 8.5 and will thus be throwing warnings.

This commit adds conditional checks to only call these functions on the relevant PHP versions.

Reference: [https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_no-op_functions_from_the_resource_to_object_conversion PHP RFC: Deprecations for PHP 8.5: Deprecate no-op functions from the resource to object conversion].

Props TobiasBg, SergeyBiryukov.
See #63061.
Built from https://develop.svn.wordpress.org/trunk@60703


git-svn-id: http://core.svn.wordpress.org/trunk@60039 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-09-03 12:18:31 +00:00
Sergey Biryukov
57f78b73af Docs: Clarify return value for wp_get_default_extension_for_mime_type().
Follow-up to [51653].

Props rollybueno, SergeyBiryukov.
See #63166.
Built from https://develop.svn.wordpress.org/trunk@60696


git-svn-id: http://core.svn.wordpress.org/trunk@60032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-08-31 18:55:26 +00:00
Sergey Biryukov
1de88be2d6 Docs: Improve grammar in some DocBlocks for more clarity and consistency.
Follow-up to [8215], [8598].

Props prab18hat, dhruvang21, swissspidy, SergeyBiryukov.
Fixes #63892.
Built from https://develop.svn.wordpress.org/trunk@60687


git-svn-id: http://core.svn.wordpress.org/trunk@60023 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-08-28 15:08:28 +00:00
Sergey Biryukov
aeb1e8f940 Security: Set the frame-ancestors directive in send_frame_options_header().
The `X-Frame-Options` HTTP response header is a way of controlling whether and how a document may be loaded inside of a child navigable. For sites using `Content-Security-Policy`, the `frame-ancestors` directive provides more granular control over the same situations.

Includes adding a `headers_sent()` check before sending the headers.

References:
* [https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options MDN Web Docs: X-Frame-Options header]
* [https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/frame-ancestors MDN Web Docs: Content-Security-Policy: frame-ancestors directive]

Follow-up to [17826].

Props danielbachhuber, killerbishop, callumbw95, josephscott, nacin, chriscct7, iandunn, SergeyBiryukov.
Fixes #29429.
Built from https://develop.svn.wordpress.org/trunk@60657


git-svn-id: http://core.svn.wordpress.org/trunk@59993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-08-23 14:08:30 +00:00
John Blackbourn
e00c5f086c Docs: Add a few missing @since tags.
See #63166
Built from https://develop.svn.wordpress.org/trunk@60416


git-svn-id: http://core.svn.wordpress.org/trunk@59752 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-07-06 11:57:35 +00:00
John Blackbourn
d68311701e Docs: Improve and standardise the format of placeholder strings that get replaced within email messages.
This prevents the strings being treated as h3 headings by the documentation parser on developer.wordpress.org.

See #63166
Built from https://develop.svn.wordpress.org/trunk@60178


git-svn-id: http://core.svn.wordpress.org/trunk@59514 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-21 11:49:31 +00:00
Sergey Biryukov
a4b3fa981f Coding Standards: Check for an empty address first on admin email change notification.
This follows a common best practice of checking for an empty value before doing a specific comparison.

Follow-up to [60122], [60129].

Props dilipbheda, Presskopp.
Fixes #63267.
Built from https://develop.svn.wordpress.org/trunk@60153


git-svn-id: http://core.svn.wordpress.org/trunk@59489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-13 16:48:30 +00:00
Sergey Biryukov
36f1464972 Coding Standards: Move wp_unique_id_from_values() next to wp_unique_id() and wp_unique_prefixed_id(), for consistency.
Follow-up to [60038].

See #63168.
Built from https://develop.svn.wordpress.org/trunk@60131


git-svn-id: http://core.svn.wordpress.org/trunk@59467 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-05 21:06:27 +00:00
John Blackbourn
d06ea932de Administration: Don't attempt to send a notification about a change of site admin or network admin email address when the old address is empty.
Props spenserhale.

Fixes #62211
Built from https://develop.svn.wordpress.org/trunk@60129


git-svn-id: http://core.svn.wordpress.org/trunk@59465 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-04 16:36:31 +00:00
Peter Wilson
f54720e6e5 Docs: Fix types for wp_cache_set_last_changed filter.
Corrects the type for the `$time` and `$previous_time` parameters in the filter to indicate the times are expressed as strings. The values are generated from a call to `microtime()` which returns the time as a string in the form `msec sec`.

Props tillkruess, westonruter.
Fixes #63194.



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


git-svn-id: http://core.svn.wordpress.org/trunk@59464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-03 20:49:31 +00:00
John Blackbourn
746ed91e1e Application Passwords: Correct the fallback behaviour for application passwords that don't use a generic hash.
Application passwords that aren't hashed using BLAKE2b should be checked using `wp_check_password()` rather than assuming they were hashed with phpass. This provides full back compat support for application passwords that were created via an overridden `wp_hash_password()` function that uses an alternative hashing algorithm.

Props snicco, debarghyabanerjee, peterwilsoncc, jorbin, johnbillion.

Fixes #63203
Built from https://develop.svn.wordpress.org/trunk@60123


git-svn-id: http://core.svn.wordpress.org/trunk@59459 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-03 13:53:28 +00:00
Sergey Biryukov
6f969c6c79 Docs: Correct documentation for current_time(), date_i18n(), and wp_date().
Includes:
* Standardizing on the `bool` type for the `$gmt` parameter between `current_time()` and `date_i18n()`.
* Documenting `null` as an acceptable value for `$timestamp` and `$timezone` parameters in `wp_date()`.
* Removing a redundant note on the `$gmt` parameter for the `date_i18n` filter, as defaults are normally only documented for function parameters.

Follow-up to [1001], [9616], [28109], [45901].

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


git-svn-id: http://core.svn.wordpress.org/trunk@59455 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-01 16:43:28 +00:00
audrasjb
73540ca808 Coding Standards: Use sprintf() for correct i18n in wp_unique_id_from_values().
Follow-up to [60075], [60079].

Fixes #62985.


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


git-svn-id: http://core.svn.wordpress.org/trunk@59421 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-25 14:31:31 +00:00
Joe McGill
98a3f5f11c Editor: Fix translators note in wp_unique_id_from_values().
Follow up to [60075] to fix a typo.

Props mukesh27, johnbillion.
See #62985.

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


git-svn-id: http://core.svn.wordpress.org/trunk@59415 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-25 12:54:22 +00:00
Peter Wilson
886fb31207 Editor: Tidy up _doing_it_wrong() call in wp_unique_id_from_values().
Adds a translator note not to translate the parameter name `$data` and removes an unused `sprintf()` that doesn't contain any placeholders.

Props peterwilsoncc, joemcgill.
Fixes #62985.

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


git-svn-id: http://core.svn.wordpress.org/trunk@59411 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-25 01:47:25 +00:00
Aaron Jorbin
e382a52cde Coding Standards: Fix alignment in wp_check_filetype_and_ext.
Follow-up to [59315].

See #62272, #62279.

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


git-svn-id: http://core.svn.wordpress.org/trunk@59385 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-18 23:41:26 +00:00
Joe McGill
1c43cd6743 Editor: Fix layout support classes to be generated with a stable ID.
This fixes a bug reported in https://github.com/WordPress/gutenberg/issues/67308 related to the Interactivity API's client-side navigation feature by replacing the incrementally generated IDs with stable hashes derived from the block's layout style definition.

Fixes #62985.
Props darerodz.

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


git-svn-id: http://core.svn.wordpress.org/trunk@59374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-18 12:43:24 +00:00
audrasjb
bd18318a94 General: Cast $public param to bool in do_robots().
This changeset properly casts the `$public` variable into `bool` in `do_robots()` for better consistency between code and docs.

Props SergeyBiryukov, shailu25, kapilpaul.
Fixes #63039.


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


git-svn-id: http://core.svn.wordpress.org/trunk@59288 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-06 15:36:26 +00:00
John Blackbourn
f2de6c15ca Security: Reduce the length of the hash returned by wp_fast_hash() so it can be used in the user_activation_key field when a legacy database schema is still in use.
This reduces the hash length from 32 bytes to 30 so the overall length of an activation key after encoding, prefixing, and prepending a timestamp fits into 60 bytes.

A key is also introduced for domain separation. This doesn't affect the output length.

Props dd32, paragoninitiativeenterprises, peterwilsoncc, johnbillion

Fixes #21022
Built from https://develop.svn.wordpress.org/trunk@59904


git-svn-id: http://core.svn.wordpress.org/trunk@59246 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-03 09:51:22 +00:00
Pascal Birchler
1d6b7d6fe8 General: Fix force_ssl_admin() to always return bool.
Props pbearne, costdev, autotutorial, debarghyabanerjee, swissspidy.
Fixes #60023.
Built from https://develop.svn.wordpress.org/trunk@59830


git-svn-id: http://core.svn.wordpress.org/trunk@59172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-17 15:32:22 +00:00
John Blackbourn
05770e25c3 Security: Switch to using bcrypt for hashing user passwords and BLAKE2b for hashing application passwords and security keys.
Passwords and security keys that were saved in prior versions of WordPress will continue to work. Each user's password will be opportunistically rehashed and resaved when they next subsequently log in using a valid password.

The following new functions have been introduced:

* `wp_password_needs_rehash()`
* `wp_fast_hash()`
* `wp_verify_fast_hash()`

The following new filters have been introduced:

* `password_needs_rehash`
* `wp_hash_password_algorithm`
* `wp_hash_password_options`

Props ayeshrajans, bgermann, dd32, deadduck169, desrosj, haozi, harrym, iandunn, jammycakes, joehoyle, johnbillion, mbijon, mojorob, mslavco, my1xt, nacin, otto42, paragoninitiativeenterprises, paulkevan, rmccue, ryanhellyer, scribu, swalkinshaw, synchro, th23, timothyblynjacobs, tomdxw, westi, xknown.

Additional thanks go to the Roots team, Soatok, Calvin Alkan, and Raphael Ahrens.

Fixes #21022, #44628
Built from https://develop.svn.wordpress.org/trunk@59828


git-svn-id: http://core.svn.wordpress.org/trunk@59170 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-17 11:24:21 +00:00
audrasjb
6309ca8f17 General: Error messages improvements in /wp-includes files.
This changeset improves a bunch of error messages, notably replacing the good old cryptic "Something went wrong" message with more helpful information.

Props peterwilsoncc, netweb, karmatosed, JoshuaWold, mrtortai, audrasjb, sukhendu2002, joedolson.
Fixes #43622.



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


git-svn-id: http://core.svn.wordpress.org/trunk@59132 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-08 16:00:19 +00:00
John Blackbourn
31c811c962 Security: Always include the no-store and private directives in the Cache-Control header when setting headers that prevent caching.
The intention of these headers is to prevent any form of caching, whether that's in the browser or in an intermediate cache such as a proxy server. These directives instruct an intermediate cache to not store the response in their cache for any user – not just for logged-in users.

This does not affect the caching behaviour of assets within a page such as images, CSS, and JavaScript files.

Props kkmuffme, devansh2002, johnbillion.

Fixes #61942
Built from https://develop.svn.wordpress.org/trunk@59724


git-svn-id: http://core.svn.wordpress.org/trunk@59066 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-01-28 23:22:22 +00:00
John Blackbourn
b7a73d6a45 Security: Enable the referrer policy header on the login screen.
This sets the same referrer policy of `strict-origin-when-cross-origin` that's used in the admin area to prevent a referrer being sent to other origins. This helps prevent unwanted exposure of potentially sensitive information that may be contained within the URL.

The header can be disabled if necessary by removing the `wp_admin_headers` action from the `login_init` hook.

Props kkmuffme, sagarlakhani, albatross10

Fixes #62273
See #42036
Built from https://develop.svn.wordpress.org/trunk@59712


git-svn-id: http://core.svn.wordpress.org/trunk@59054 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-01-27 14:41:22 +00:00
audrasjb
692f6d4b9e General: Stop direct loading of files in /wp-includes that should only be included.
This changeset restricts direct access call in `/wp-includes` and its sub directories.

Follow-up to [11768], [59678].

Props deepakrohilla.
Fixes #61314.



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


git-svn-id: http://core.svn.wordpress.org/trunk@59030 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-01-22 19:48:25 +00:00
Pascal Birchler
cbca77642b Plugins: Load wp-admin/includes/plugin.php earlier.
Partially reverts [59479] and [59461], which previously tried to move some functions from `wp-admin/includes/plugin.php` to `wp-includes/functions.php` so they are available early, so that `get_plugin_data()` can be used.

However, other functions from that file are often used by plugins without necessarily checking whether they are available, easily causing fatal errors. Requiring this file directly is a safer approach to avoid such errors.

Props peterwilsoncc, dd32, swissspidy, johnbillion.
Fixes #62244.
Built from https://develop.svn.wordpress.org/trunk@59488


git-svn-id: http://core.svn.wordpress.org/trunk@58874 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-12-05 12:13:17 +00:00
Pascal Birchler
789d1d9c2e Plugins: Make more plugin-related functions available early on.
This is a follow-up to [59461], which moved `get_plugin_data()` from `wp-admin/includes/plugin.php` to `wp-includes/functions.php` so it's available during the plugin loading process.

Related functions like `is_plugin_active()` are often used together and should therefore be moved as well, to improve backward compatibility for plugins which load `wp-admin/includes/plugin.php` only conditionally.

Props johnbillion, dd32, swissspidy.
See #62244.
Built from https://develop.svn.wordpress.org/trunk@59479


git-svn-id: http://core.svn.wordpress.org/trunk@58865 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-12-02 17:10:15 +00:00
Sergey Biryukov
dd967e2a2e Coding Standards: Cast gmdate( 'w' ) to int before using as integer.
This addresses several instances of `gmdate( 'w' )` being used directly as an integer, when it's actually a numeric string. The issue is remediated by casting the value to `int` before use.

Affected functions:
* `get_calendar()`
* `get_weekstartend()`

Follow-up to [508], [1632].

Props justlevine.
See #52217.
Built from https://develop.svn.wordpress.org/trunk@59471


git-svn-id: http://core.svn.wordpress.org/trunk@58857 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-11-28 22:52:17 +00:00
Pascal Birchler
117b935b89 I18N: Load translations just-in-time for custom themes and plugins.
In #34114, just-in-time (JIT) translation loading was implemented for projects hosted on WordPress.org. This is now expanded to all other plugins/themes.

Projects with a custom `Text Domain` and `Domain Path` header no longer need to call `load_plugin_textdomain()` or `load_theme_textdomain()`.

This reduces the risk of calling them too late, after some translation calls already happened, and generally makes it easier to properly internationalize a plugin or theme.

This moves the `get_plugin_data()` from `wp-admin/includes/plugin.php` to `wp-includes/functions.php` so it's available during the plugin loading process.

Props swissspidy.
Fixes #62244.
Built from https://develop.svn.wordpress.org/trunk@59461


git-svn-id: http://core.svn.wordpress.org/trunk@58847 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-11-26 10:16:17 +00:00
ramonopoly
3712752f76 Mime Types: support uploading wav files in Firefox
When uploading `wav` files in the editor, Chrome and other browsers identify the mime type of the file as `audio/wav`. Firefox, however, identifies the mime type as `audio/x-wav`.

This commit updates the `'wav'` mime type key in `wp_get_mime_types()` to support `x-wav` so that uploading wav files work in Firefox. Previously, the editor reported an unsupported mime type error.

Props imranh920, ramonopoly.
Fixes #61948.



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


git-svn-id: http://core.svn.wordpress.org/trunk@58775 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-11-12 00:53:18 +00:00
Andrew Ozz
a739bf28a1 Media: Fix variable name in wp_check_filetype_and_ext().
Props peterwilsoncc.
See #62272.
Built from https://develop.svn.wordpress.org/trunk@59358


git-svn-id: http://core.svn.wordpress.org/trunk@58744 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-11-06 00:39:18 +00:00
Andrew Ozz
152661c1e7 Media: Fix uploading of .heic images.
- Adds support for all HEIC/HEIF mime types: `image/heic`, `image/heif`, `image/heic-sequence`, and `image/heif-sequence`.
- Introduces `wp_is_heic_image_mime_type()`.

Props swissspidy, adamsilverstein, debarghyabanerjee, ironprogrammer, peterwilsoncc, apermo, azaozz.
Fixes #62272.
Built from https://develop.svn.wordpress.org/trunk@59315


git-svn-id: http://core.svn.wordpress.org/trunk@58701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-10-29 01:12:17 +00:00
Peter Wilson
9668bc0839 Networks and Sites: Relocate defintion of absint().
Relocate the defintion of `absint()` to `load.php` to allow it to be available to `get_current_blog_id()` and `get_current_network_id()`. These functions may be called by caching drop-ins, prior to the loading of `functions.php`.

Props flixos90, geekofshire, johnjamesjacoby, sergeybiryukov, wonderboymusic.
Fixes #40682.


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


git-svn-id: http://core.svn.wordpress.org/trunk@58634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-10-15 23:41:16 +00:00
Peter Wilson
a13d535628 General: Memoize the return value in wp_get_wp_version().
Cache the unmodified `$wp_version` value as a static. This retains the current behaviour during the upgrade process `$wp_version` referencing the version of WordPress being upgraded from.

Follow up to [58848].

Props Cybr, debarghyabanerjee, mukesh27, costdev, SergeyBiryukov, TobiasBg, desrosj, azaozz.
Fixes #61782.

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


git-svn-id: http://core.svn.wordpress.org/trunk@58587 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-10-07 21:13:16 +00:00
Peter Wilson
8c3dd2eb88 General: Remove noopener from links opening in a new tab.
Removes the automatic addition of `rel="noopener noreferrer"` from links targeting a new tab or window, `target='_blank'`. Since this was introduced, supported browsers have changed their security policies and no longer allow the opened link to have JavaScript access to the previous tab.

Deprecates:

* `wp_targeted_link_rel()`
* `wp_targeted_link_rel_callback()`
* `wp_init_targeted_link_rel_filters()`: converted to a noop function
* `wp_remove_targeted_link_rel_filters()`: converted to a noop function

The deprecated functions are retained in `formatting.php` as in `SHORTINIT` mode the file is included while `deprecated.php` is not.

This also removes the `noopener` from links hard coded within the WordPress dashboard linking to documentation and other resources.

Props audrasjb, azaozz, dhruval04, dorzki, neo2k23, presskopp, sabernhardt, swissspidy, tobiasbg.
Fixes #53843.

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


git-svn-id: http://core.svn.wordpress.org/trunk@58516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-09-30 05:19:16 +00:00
hellofromTonya
9160482cf3 Code Modernization: Fix trigger_error() with E_USER_ERROR deprecation in wp_trigger_error().
PHP 8.4 deprecates the use of `trigger_errror()` with `E_USER_ERROR` as the error level, as there are a number of gotchas to this way of creating a `Fatal Error` (`finally` blocks not executing, destructors not executing). The recommended replacements are either to use exceptions or to do a hard `exit`.

WP has its own `wp_trigger_error()` function, which under the hood calls `trigger_error()`. If passed `E_USER_ERROR` as the `$error_level`, this will hit the PHP 8.4 deprecation.

Now, there were basically three options:
* Silence the deprecation until PHP 9.0 and delay properly solving this until then. This would lead to an awkward solution, as prior to PHP 8.0, error silencing would apply to all errors, while, as of PHP 8.0, it will no longer apply to fatal errors. It also would only buy us some time and wouldn't actually solve anything.

* Use `exit($status)` when `wp_trigger_error()` is called with `E_USER_ERROR`. This would make the code untestable and would disable handling of these errors via custom error handlers, which makes this an undesirable solution.

* Throw an exception when `wp_trigger_error()` is called with `E_USER_ERROR`. This makes for the most elegant solution with the least BC-breaking impact, though it does open it up to the error potential being "caught" via a `try-catch`. That's not actually a bad thing and is likely to only happen for those errors which can be worked around, in which case, it's a bonus that that's now possible.

The third option is implemented which:
* Introduces a new `WP_Exception` class.
* Starts using `WP_Exception` in the `wp_trigger_error()` function when the `$error_level` is set to `E_USER_ERROR`.

This change is covered by pre-existing tests, which have been updated to expect the exception instead of a PHP error.

Why not use `WP_Error`?

Well, for one, this would lead to completely different behaviour (BC).

As `WP_Error` doesn't extend `Exception`, the program would not be stopped, but would continue running, which would be a much bigger breaking change and carries security risks. `WP_Error` also doesn't natively trigger displaying/logging of the error message, so in that case, it would still need an `exit` with the error message, bringing us back to point 2 above.

Introducing `WP_Exception` provides (essentially) the same behaviour in that it retains the fatal error and error message displaying/logging behaviors. It also introduces a base Exception class, from which future exception classes can extend.

References:
* https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error
* https://www.php.net/manual/en/migration80.incompatible.php

Follow-up to [56530].

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


git-svn-id: http://core.svn.wordpress.org/trunk@58503 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-09-27 19:28:14 +00:00
Sergey Biryukov
3cd067ee34 General: Add missing initial-scale value in viewport meta tags.
The viewport meta should include `initial-scale=1.0` to ensure that high DPI/mobile display works as expected.

References:
* [https://css-tricks.com/probably-use-initial-scale1/ CSS-Tricks: Probably Use initial-scale=1]
* [https://www.sitepoint.com/community/t/is-it-necessary-to-include-initial-scale-1-0-in-the-meta-viewport-tag/455119 SitePoint Forums: Is it necessary to include initial-scale=1.0 in the meta viewport tag?]

Follow-up to [59026].

Props dhruvang21, sabernhardt, kkmuffme, mukesh27, narenin, swissspidy, SergeyBiryukov.
Fixes #61988.
Built from https://develop.svn.wordpress.org/trunk@59027


git-svn-id: http://core.svn.wordpress.org/trunk@58423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-09-17 00:03:54 +00:00
Felix Arntz
4e167c593d Options, Meta APIs: Explicitly pass $autoload parameter to when potentially adding new options.
It is recommended that for every option it is explicitly set whether to autoload it or not. This changeset updates relevant `update_option()` and `add_option()` calls.

Note that the `$autoload` parameter is only needed for `update_option()` if the option is potentially not present yet, i.e. the call will pass through to `add_option()`. Since WordPress core adds the majority of its options to the database during installation, only `update_option()` calls for dynamically added options need to be modified, which is what this changeset does.

As part of revisiting the autoload values for dynamically added WordPress core options, this changeset modifies some options to no longer be autoloaded, since they are only accessed in a few specific places that are not relevant for a regular request. These options are:
* `recently_activated`
* `_wp_suggested_policy_text_has_changed`
* `{upgradeLock}.lock`
* `dashboard_widget_options`
* `ftp_credentials`
* `adminhash`
* `nav_menu_options`
* `wp_force_deactivated_plugins`
* `delete_blog_hash`
* `allowedthemes`
* `{sessionId}_paused_extensions`
* `recovery_keys`
* `https_detection_errors`
* `fresh_site`

An upgrade routine is present as well that sets those options to no longer autoload for existing sites.

Props pbearne, flixos90, mukesh27, swissspidy, SergeyBiryukov, joemcgill, adamsilverstein.
Fixes #61103.

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


git-svn-id: http://core.svn.wordpress.org/trunk@58371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-09-03 18:19:14 +00:00
Peter Wilson
78a0c7a5b3 Date/Time: Prevent type errors in current_time().
Prevents a potential type error when calling `current_time( 'timestamp' )` by casting `get_option( 'gmt_offset' )` to a float prior to performing calculations with the value.

This mainly accounts for incorrect storage of values, such as an empty string or city name.

Follow up to [45856], [55054], [55598].

Props hellofromtonya, peterwilsoncc, rarst, costdev, Nick_theGeek, SergeyBiryukov, johnbillion, desrosj, reputeinfosystems, audrasjb, oglekler.
Fixes #57035.

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


git-svn-id: http://core.svn.wordpress.org/trunk@58319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-08-22 23:27:24 +00:00
noisysocks
3a703f86cd Media: Automatically convert HEIC images to JPEG
Automatically create a JPEG version of uploaded HEIC images if the server has
a version of Imagick that supports HEIC. Conversion is done silently through
the existing `WP_Image_Editor` infrastructure that creates multiple sizes of
uploaded images.

This allows users to view HEIC images in WP Admin and use them in their posts
and pages regardless of whether their browser supports HEIC. Browser support
for HEIC is relatively low (only Safari) while the occurrence of HEIC images is
relatively common. The original HEIC image can be downloaded via a link on
the attachment page.

Props adamsilverstein, noisysocks, swissspidy, spacedmonkey, peterwilsoncc.
Fixes #53645.

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


git-svn-id: http://core.svn.wordpress.org/trunk@58245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-08-05 04:13:15 +00:00
Peter Wilson
066d83f670 General: Removing static from wp_get_wp_version().
Removes the static storing the version number in `wp_get_wp_version()` to ensure the version number is reported correctly after a WordPress upgrade is completed.

Reverts [58827].

Props costdev, SergeyBiryukov, Cybr.
See #61782.

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


git-svn-id: http://core.svn.wordpress.org/trunk@58244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-08-04 22:09:18 +00:00
Peter Wilson
6a559b739b General: Use clean WordPress version in is_wp_version_compatible().
Update `is_wp_version_compatible()` to use `wp_get_wp_version()` introduced in [58813] to ensure the value of `$wp_version` has not been modified by a theme or plugin.

Props costdev, mukesh27, Cybr, sergeybiryukov.
Fixes #61781.


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


git-svn-id: http://core.svn.wordpress.org/trunk@58239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-08-02 22:38:15 +00:00