forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add/enqueue stored block supports styles #1
Closed
ramonjd
wants to merge
66
commits into
ramonjd:add/enqueue-stored-block-supports-styles
from
ockham:add/enqueue-stored-block-supports-styles
Closed
Add/enqueue stored block supports styles #1
ramonjd
wants to merge
66
commits into
ramonjd:add/enqueue-stored-block-supports-styles
from
ockham:add/enqueue-stored-block-supports-styles
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The `safecss_filter_attr()` function allows using custom CSS variables like `color: var(--color)`. However, it did not allow assigning values to CSS variables like `--color: #F00`, which is common in Global Styles and Gutenberg. This commit adds support for assigning values to CSS variables, so that the function can be used consistently in Global Styles and the future Style Engine in Gutenberg. Follow-up to [50923], [54100]. Props aristath, ramonopoly, SergeyBiryukov. Fixes #56353. git-svn-id: https://develop.svn.wordpress.org/trunk@54117 602fd350-edb4-49c9-b593-d223f7449a82
This commit backports the original PRs from Gutenberg repository: * [WordPress/gutenberg#40260 #40260 Add support for button elements to theme.json] * [WordPress/gutenberg#40889 #40889 Theme Json: Don't output double selectors for elements inside blocks] * [WordPress/gutenberg#41140 #41140 Global Styles: Add support for caption elements] * [WordPress/gutenberg#41160 #41160 Global Styles: Load block CSS conditionally] * [WordPress/gutenberg#41240 #41240 Global Styles: Button Element: update button element selector] * [WordPress/gutenberg#41335 #41335 Duotone: Fix CSS Selectors rendered by theme.json duotone/filter settings for blocks on public pages] * [WordPress/gutenberg#41446 #41446 Block styles: Account for style block nodes that have no name] * [WordPress/gutenberg#41696 #41696 Global Styles: Allow references to values in other locations in the tree] * [WordPress/gutenberg#41753 #41753 Elements: Add an API make it easier to get class names] * [WordPress/gutenberg#41786 #41786 Support pseudo selectors on elements in theme json] * [WordPress/gutenberg#41822 #41822 Elements: Button - Fix element selectors] * [WordPress/gutenberg#41981 #41981 Global Styles: Add support for heading elements] * [WordPress/gutenberg#42072 #42072 Fix link element hover bleeding into button element default styles] * [WordPress/gutenberg#42096 #42096 Add visited to link element allowed pseudo selector list] * [WordPress/gutenberg#42669 #42669 Link elements: Add a :where selector to the :not to lower specificity] * [WordPress/gutenberg#42776 #42776 Theme JSON: Add a static $blocks_metadata data definition to the Gutenberg instance of WP_Theme_JSON] * [WordPress/gutenberg#43088 #43088 Pseudo elements supports on button elements] * [WordPress/gutenberg#43167 #43167 Theme_JSON: Use existing append_to_selector for pseudo elements] * [WordPress/gutenberg#43988 #43988 Styles API: Fixed selectors for nested elements] Props onemaggie, bernhard-reiter, cbravobernal, mmaattiiaass, scruffian, andraganescu, dpcalhoun, get_dave, Mamaduka, SergeyBiryukov. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54118 602fd350-edb4-49c9-b593-d223f7449a82
* `$blog_id` global was replaced with `get_current_blog_id()` and is no longer used directly. * `$wp_roles` global usage was previously undocumented. Follow-up to [32637], [38457], [51943]. Props shoaibkarimali. Fixes #56543. git-svn-id: https://develop.svn.wordpress.org/trunk@54119 602fd350-edb4-49c9-b593-d223f7449a82
Functionally, `add_action` and `add_filter` are essentially the same, but semantically they are not. Props Drivingralle. Fixes #56285. git-svn-id: https://develop.svn.wordpress.org/trunk@54120 602fd350-edb4-49c9-b593-d223f7449a82
Props get_dave, spacedmonkey. Fixes #56472. git-svn-id: https://develop.svn.wordpress.org/trunk@54121 602fd350-edb4-49c9-b593-d223f7449a82
This fixes an issue where metaboxes fail to save after a session expires and a user logs in again via the heartbeat API. Props LinSoftware. Fixes #52584. git-svn-id: https://develop.svn.wordpress.org/trunk@54122 602fd350-edb4-49c9-b593-d223f7449a82
This brings support for the `include` and `exclude` collection parameters to the Search Controller. This can be used to find an item by id when it's subtype is unknown. Props kadamwhite. Fixes #56546. git-svn-id: https://develop.svn.wordpress.org/trunk@54123 602fd350-edb4-49c9-b593-d223f7449a82
Using NPM 7+ currently causes a number of issues. In order to improve developer experience, we should prevent a developer from going down the road of using incompatible engines. See also: WordPress/gutenberg#29204 and WordPress/gutenberg#23600. Props rcorrales. Fixes #56547. git-svn-id: https://develop.svn.wordpress.org/trunk@54124 602fd350-edb4-49c9-b593-d223f7449a82
… enabled This prevents erroneously replacing the `data-customize-partial-id` when only the `id` attribute should be replaced. Props dlh, costdev, nikeo, greenshady. Fixes #39451. git-svn-id: https://develop.svn.wordpress.org/trunk@54125 602fd350-edb4-49c9-b593-d223f7449a82
…e()`. `wp_resolve_post_date()` extracts year/month/day from a post date (which is a string) and passes it to `wp_checkdate` (and from there to `checkdate()`), which requires `int`s. Casting the strings to integers avoids PHP notices due to incorrect argument types. Props hilayt24. Fixes #54186 git-svn-id: https://develop.svn.wordpress.org/trunk@54126 602fd350-edb4-49c9-b593-d223f7449a82
…PRINT. Add support for a "_pretty" meta-parameter on all REST controllers which instructs WordPress to return pretty-printed JSON, for better readability when inspecting endpoint responses in curl output or certain developer tools. Introduce the "rest_json_encode_options" filter to permit site owners to control this behavior globally. Props Viper007Bond, TimothyBlynJacobs, chrisguitarguy, johnbillion, swissspidy, adamsilverstein, danielbachhuber, rmccue. Fixes #41998. git-svn-id: https://develop.svn.wordpress.org/trunk@54127 602fd350-edb4-49c9-b593-d223f7449a82
This change allows for the muted property to be used in video elements which solves for content that wishes to `autoPlay` when a page is viewed. Adding `muted` to video elements adhears to the requirements browsers have to honor `autoPlay` functionality. Props prokium, peterwilsoncc, costdev, johnbillion, Benouare. Fixes #54788. git-svn-id: https://develop.svn.wordpress.org/trunk@54128 602fd350-edb4-49c9-b593-d223f7449a82
Props swissspidy Fixes #55771 git-svn-id: https://develop.svn.wordpress.org/trunk@54129 602fd350-edb4-49c9-b593-d223f7449a82
…ked from editing. Previously when a user was locked from editing a post in the block editor, autosave functionality was allowed to overwrite changes made by the editor that has taken control. This patch honors the lock status keeping autosave from conflicitng with other content editors. Props jhart35, adamsilverstein, sathyapulse, chanthaboune, primetimejas, joemcgill, kadamwhite. Fixes #55659. git-svn-id: https://develop.svn.wordpress.org/trunk@54130 602fd350-edb4-49c9-b593-d223f7449a82
…perties. This switches the Settings Controller to use `rest_default_additional_properties_to_false` and deprecates its own method. Props anna.bansaghi. Fixes #56493. git-svn-id: https://develop.svn.wordpress.org/trunk@54131 602fd350-edb4-49c9-b593-d223f7449a82
New `render` field in `block.json` file that accepts a string value. It allows to pass a path to the PHP file that is going to be used to render the block on the server. Related PR in Gutenberg: WordPress/gutenberg#42430. Props spacedmonkey, luisherranz, welcher, noisysocks, matveb, fabiankaegy, aristath, zieladam. Fixes #53148. git-svn-id: https://develop.svn.wordpress.org/trunk@54132 602fd350-edb4-49c9-b593-d223f7449a82
…rent) classes. Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0. There are a number of ways to mitigate this: * If it is an accidental typo for a declared property: fix the typo. * For known properties: declare them on the class. * For unknown properties: add the magic `__get()`, `__set()`, et al. methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods built in. * For unknown ''use'' of dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes. Trac ticket #56034 is open to investigate and handle the third and fourth type of situations, however it has become clear this will need more time and will not be ready in time for WP 6.1. To reduce “noise” in the meantime, both in the error logs of WP users moving onto PHP 8.2, in the test run logs of WP itself, in test runs of plugins and themes, as well as to prevent duplicate tickets from being opened for the same issue, this commit adds the `#[AllowDynamicProperties]` attribute to all “parent” classes in WP. The logic used for this commit is as follows: * If a class already has the attribute: no action needed. * If a class does not `extend`: add the attribute. * If a class does `extend`: - If it extends `stdClass`: no action needed (as `stdClass` supports dynamic properties). - If it extends a PHP native class: add the attribute. - If it extends a class from one of WP's external dependencies: add the attribute. * In all other cases: no action — the attribute should not be needed as child classes inherit from the parent. Whether or not a class contains magic methods has not been taken into account, as a review of the currently existing magic methods has shown that those are generally not sturdy enough and often even set dynamic properties (which they should not). See the [https://www.youtube.com/watch?v=vDZWepDQQVE live stream from August 16, 2022] for more details. This commit only affects classes in the `src` directory of WordPress core. * Tests should not get this attribute, but should be fixed to not use dynamic properties instead. Patches for this are already being committed under ticket #56033. * While a number bundled themes (2014, 2019, 2020, 2021) contain classes, they are not a part of this commit and may be updated separately. Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties]. Follow-up to [53922]. Props jrf, hellofromTonya, markjaquith, peterwilsoncc, costdev, knutsp, aristath. See #56513, #56034. git-svn-id: https://develop.svn.wordpress.org/trunk@54133 602fd350-edb4-49c9-b593-d223f7449a82
PHP 8.2 deprecates string interpolation patterns that place the dollar sign outside the curly braces: {{{ echo "Hello ${name}"; }}} This commit fixes such patterns by replacing them with proper curly braced patterns: {{{ echo "Hello {$name}"; }}} This addresses `Deprecated: Using ${var} in strings is deprecated, use {$var} instead` notices when running tests on PHP 8.2. References: * [https://php.watch/versions/8.2/$%7Bvar%7D-string-interpolation-deprecated PHP.Watch: PHP 8.2: ${var} string interpolation deprecated] * [https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation PHP RFC: Deprecate ${} string interpolation] Follow-up to [10584], [31733], [42360], [53922]. Props ayeshrajans, jrf. Fixes #55787. git-svn-id: https://develop.svn.wordpress.org/trunk@54134 602fd350-edb4-49c9-b593-d223f7449a82
…ize_Manager::get_return_url()`. This particular code block only makes sense to run when `$this->return_url` is not null. Previously, it caused a "passing null to non-nullable" deprecation notice on PHP 8.1. By moving the code into the `if ( $this->return_url )` condition block, the code will only be run when `$this->return_url` contains a non-falsey/non-null value. No additional tests added as this issue was found via the existing tests for the function containing the bug. This solves the following two PHP 8.1 test errors: {{{ 1) Tests_WP_Customize_Manager::test_return_url parse_url(): Passing null to parameter #1 ($url) of type string is deprecated /var/www/src/wp-includes/class-wp-customize-manager.php:4696 /var/www/tests/phpunit/tests/customize/manager.php:2975 /var/www/vendor/bin/phpunit:123 2) Tests_WP_Customize_Manager::test_customize_pane_settings parse_url(): Passing null to parameter #1 ($url) of type string is deprecated /var/www/src/wp-includes/class-wp-customize-manager.php:4696 /var/www/src/wp-includes/class-wp-customize-manager.php:4898 /var/www/tests/phpunit/tests/customize/manager.php:3085 /var/www/vendor/bin/phpunit:123 }}} Follow-up to [46754]. Props jrf, costdev. See #55656. git-svn-id: https://develop.svn.wordpress.org/trunk@54135 602fd350-edb4-49c9-b593-d223f7449a82
…omment template. This changeset removes `aria-hidden="true"` attribute used for required fields in comments template, for better accessibility. It removes the attribute from both `wp_required_field_indicator()` and `wp_required_field_message()` patterns. Follow-up to [53888]. Props juliemoynat, audrasjb, joedolson, sabernhardt, afercia, costdev. Fixes #55717. git-svn-id: https://develop.svn.wordpress.org/trunk@54136 602fd350-edb4-49c9-b593-d223f7449a82
…_message()` output filterable. This changeset introduces two new hooks: - `wp_required_field_indicator` allows developers to filter the HTML output of the `wp_required_field_indicator()` function. - `wp_required_field_message` does the same for the `wp_required_field_message()` function. The changeset also adds new phpunit tests for these filters. Follow-up to [53888], [54136]. Props kebbet, audrasjb, sabernhardt, costdev, mukesh27. Fixes #56389. See #54394. git-svn-id: https://develop.svn.wordpress.org/trunk@54137 602fd350-edb4-49c9-b593-d223f7449a82
…ogy. This changeset adss an `aria-hidden="true"` attribute to the optional arrows/chevron characters to the Query Loop and to the Comments Query Loop blocks pagination links. These characters are text, so they're read out by assistive technologies. For better accessibility, it's best to reduce noise for screen reader users and prevent them to be rendered, using the `aria-hidden="true"` attribute. Follow-up to [52057]. Props afercia, sabernhardt, kamig478, zieladam, audrasjb, joedolson, costdev. Fixes #56067. git-svn-id: https://develop.svn.wordpress.org/trunk@54138 602fd350-edb4-49c9-b593-d223f7449a82
This changeset replaces `white-space: nowrap` with `white-space: preline` to ensure long text used in the button block correctly wraps to a second line. Follow-up to [44148]. Props robertghetau, bhrugesh12, sabernhardt, mukesh27. Fixes #55783. git-svn-id: https://develop.svn.wordpress.org/trunk@54139 602fd350-edb4-49c9-b593-d223f7449a82
This changeset adds a file description for `theme.json`. This description is notably used in the Theme File Editor. Props ocean90, kapilpaul, poena. Fixes #55325. git-svn-id: https://develop.svn.wordpress.org/trunk@54140 602fd350-edb4-49c9-b593-d223f7449a82
This changeset ensures alignement settings are correctly reflected for the Post Title block in the Editor. Props smit08, kajalgohel, devtanbir, sabernhardt, audrasjb. Fixes #56167. git-svn-id: https://develop.svn.wordpress.org/trunk@54141 602fd350-edb4-49c9-b593-d223f7449a82
…WP_Scripts::localize()`. This function was previously already problematic as it does not do proper input validation, and it has already received tweaks related to PHP 8.0 in [50408] / #52534, which also introduced a `_doing_it_wrong()` notice and added tests. The short of it is: * The function expects to receive an `array` for the `$l10n` parameter; * ...but silently supported the parameter being passed as a `string`; * ...and would expect PHP to gracefully handle everything else or throw appropriate warnings/errors. In the previous fix, a `_doing_it_wrong()` notice was added for any non-array inputs. The function would also cause a PHP native "Cannot use a scalar value as an array" warning (PHP < 8.0) or error (PHP 8.0+) for all scalar values, except `false`. PHP 8.1 deprecated autovivification from `false` to `array`, so now `false` starts throwing an "Automatic conversion of false to array is deprecated" notice. By rights, the function should just throw an exception when a non-array/string input is received, but that would be a backward compatibility break. So the current change will maintain the previous behavior, but will prevent both the "Cannot use a scalar value as an array" warning/error as well as the "Automatic conversion of false to array" deprecation notice for invalid inputs. Invalid inputs ''will'' still receive a `_doing_it_wrong()` notice, which is the reason this fix is considered acceptable. Includes: * Adding a test passing an empty array. * Adding a test to the data provider for a `null` input to make sure that the function will not throw a PHP 8.1 "passing null to non-nullable" notice. This solves the following PHP 8.1 test error: {{{ Tests_Dependencies_Scripts::test_wp_localize_script_data_formats with data set WordPress#8 (false, '[""]') Automatic conversion of false to array is deprecated /var/www/src/wp-includes/class.wp-scripts.php:514 /var/www/src/wp-includes/functions.wp-scripts.php:221 /var/www/tests/phpunit/tests/dependencies/scripts.php:1447 /var/www/vendor/bin/phpunit:123 }}} Reference: [https://www.php.net/manual/en/migration81.deprecated.php#migration81.deprecated.core.autovivification-false PHP Manual: PHP 8.1 Deprecations: Autovivification from false]. Follow-up to [7970], [18464], [18490], [19217], [50408]. Props jrf, costdev. See #55656. git-svn-id: https://develop.svn.wordpress.org/trunk@54142 602fd350-edb4-49c9-b593-d223f7449a82
WordPress 3.2 introduced several enhancements to the `copy_dir()` function: * No more re-installing Akismet upon upgrade. * Respect custom `WP_CONTENT_DIR` for bundled plugins/theme installation. * Respect custom `WP_CONTENT_DIR`/`WP_LANG_DIR` for language files when upgrading. * Add an exclusion list to `copy_dir()` as well as `WP_Filesystem_Base::wp_lang_dir()`. * Standardize `WP_Filesystem` path method returns. However, the version of `copy_dir()` that runs during the upgrade process is the one from the older install, not the newer, which means that these enhancements would only be available after upgrading to WordPress 3.2 first, e.g. in a subsequent upgrade to WordPress 3.3. In order to make these enhancements immediately available in WordPress 3.2, specifically to take advantage of skip lists and avoid re-installing Akismet if it was previously deleted, a temporary copy of the function was utilized, with the intention to remove it in WordPress 3.3 or a later release. With further enhancements made to the Upgrade API to support partial and no-content builds, this temporary copy is no longer relevant and can be safely removed. Follow-up to [17576], [17580], [17581], [18225]. Props afragen, costdev, dd32, peterwilsoncc, SergeyBiryukov. Fixes #55712. See #17173. git-svn-id: https://develop.svn.wordpress.org/trunk@54143 602fd350-edb4-49c9-b593-d223f7449a82
Props pbiron, joyously, audrasjb, robinwpdeveloper. Fixes 53392. git-svn-id: https://develop.svn.wordpress.org/trunk@54144 602fd350-edb4-49c9-b593-d223f7449a82
Although a `pre_option_{$option}` filter already exists, this change adds a more general `pre_option` filter that will run on every `get_option` call. This brings the control flow into similar flow as `update_option`. Props flixos90, NathanAtmoz, desrosj, spacedmonkey, pbearne. Fixes #37930. git-svn-id: https://develop.svn.wordpress.org/trunk@54145 602fd350-edb4-49c9-b593-d223f7449a82
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. git-svn-id: https://develop.svn.wordpress.org/trunk@54146 602fd350-edb4-49c9-b593-d223f7449a82
…cordingly in the Editor. This brings consistency between block editor and front-end rendering. Props smit08, mukesh27, sabernhardt, multidots1896. Fixes #56175. git-svn-id: https://develop.svn.wordpress.org/trunk@54166 602fd350-edb4-49c9-b593-d223f7449a82
This fixes an alignment issue with the Social Links block used in the context of a widget area. Props grandeljay, sabernhardt. Fixes #56474. git-svn-id: https://develop.svn.wordpress.org/trunk@54167 602fd350-edb4-49c9-b593-d223f7449a82
A cross-team consensus has been reached to allow Twenty Twenty-Two to be tagged as "Accessibility Ready" on the WordPress Themes repository. Props bph, kjellr, utz119, ryokuhi, joedolson, audrasjb, mikeschroder, poena, annezazu. Fixes #55172. git-svn-id: https://develop.svn.wordpress.org/trunk@54168 602fd350-edb4-49c9-b593-d223f7449a82
- Add a check to `wp_check_php_version()` whether the current PHP version is lower than the next (desired) minimum version. - Set the next desired minimum PHP version to 7.2. - Use that check to update the warnings in the `wp_dashboard_php_nag()` widget, and on the Site Health screen. Props Clorith, SergeyBiryukov, ironprogrammer, azaozz. See #56199. git-svn-id: https://develop.svn.wordpress.org/trunk@54169 602fd350-edb4-49c9-b593-d223f7449a82
The selectors for Twenty Twenty-One's default `max-width` have used the `.woocommerce` class since the theme's [WordPress/twentytwentyone@956a317#diff-b757cb999144a1bc7e14604bc6d4bab7d87ea1a3bf5000c33937e490d75b9d92R3-R9 initial commit]. This changeset removes all WooCommerce CSS selector from the theme, as they would need to be supported forever. The change was tested with WooCommerce installed and no issues were raised. Props sabernhardt, audrasjb, davidbaumwald, tahmidulkarim, mukesh27. Fixes #56366. git-svn-id: https://develop.svn.wordpress.org/trunk@54170 602fd350-edb4-49c9-b593-d223f7449a82
This changeset adds `text-decoration-thickness: 2px;` to all underlined link to ensure that underline thickness stay consistent across browsers. This fixes an issue where the underline style on links using the Hoefler Text font was too thin in Firefox. Props allancole, sabernhardt, danfarrow, audrasjb, neychok, multidots1896, maartenj. Fixes #45925. git-svn-id: https://develop.svn.wordpress.org/trunk@54171 602fd350-edb4-49c9-b593-d223f7449a82
Props bengreeley, audrasjb, desrosj, mukesh27. Fixes #56206. See #55646. git-svn-id: https://develop.svn.wordpress.org/trunk@54172 602fd350-edb4-49c9-b593-d223f7449a82
…ons, as per docblocks standards. See #55646. git-svn-id: https://develop.svn.wordpress.org/trunk@54173 602fd350-edb4-49c9-b593-d223f7449a82
This changeset backports the `wp_theme_element_class_name()` alias for the "internal" `WP_Theme_JSON::get_element_class_name()` function. This is a backport of [WordPress/gutenberg#44099 gutenberg/PR44099]. Note: this changeset doesn't replace calls to `WP_Theme_JSON::get_element_class_name` in the tests, since those are specifically for the `WP_Theme_JSON` class. Props bernhard-reiter, cbravobernal, costdev. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54174 602fd350-edb4-49c9-b593-d223f7449a82
…enberg repository. This changeset backports changes from the following Gutenberg pull requests: - [WordPress/gutenberg#43590 gutenberg#43590] Add a filter to `build_query_vars_from_query_block` - [WordPress/gutenberg#40933 gutenberg#40933] Block Library - Query Loop: Add parents filter Props ntsekouras, bernhard-reiter. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54175 602fd350-edb4-49c9-b593-d223f7449a82
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.[WordPress/gutenberg#42729 See WordPress/gutenberg PR 42729]. Follow-up to [52330], [52069], [52178]. Props mamaduka, fabiankaegy, poena, scruffian, manfcarlo, bernhard-reiter, hellofromTonya. See #56467. git-svn-id: https://develop.svn.wordpress.org/trunk@54176 602fd350-edb4-49c9-b593-d223f7449a82
Backporting block supports filter callback and registrations
ramonjd
changed the base branch from
trunk
to
add/enqueue-stored-block-supports-styles
September 19, 2022 04:35
ramonjd
pushed a commit
that referenced
this pull request
Sep 29, 2022
…pc_server::mw_newPost()`. The `wp_xmlrpc_server::mw_newPost()` method creates a new post via `wp_insert_post()`, but the default/fallback values used in the function were not in line with the default/fallback values used in the `wp_insert_post()` function. The `wp_insert_post()` function does a `wp_parse_args()` (array merge) of the received arguments with the defaults. If any of the received arguments are `null`, this would overwrite the default value, as seen in [https://3v4l.org/bfVlv array_merge() example], and lead to "passing null to non-nullable" deprecation notices on PHP 8.1 for certain arguments. This commit: * Ensures that all arguments are defined before they are `compact()`'ed together to the arguments array. * Verifies that the default/fallback value of the arguments as set within the `wp_xmlrpc_server::mw_newPost()` method are the same as the default/fallback values used in the `wp_insert_post()` function. * Verifies that arguments which do not have a default/fallback value defined in the `wp_insert_post()` function are handled correctly. * This was not the case for `$post_name`, which would previously already get an empty string default value in the `wp_xmlrpc_server::mw_newPost()` function, but then in the `wp_insert_post()` function, this would prevent the slug generation from being activated. Fixed now by setting the default in the `wp_xmlrpc_server::mw_newPost()` function to `null`. * The `page_template` argument was handled, but not documented in the `wp_insert_post()` function. The argument is now documented in the `wp_insert_post()` function DocBlock. Note: There are more than likely several other potential arguments missing from that list, but verifying the whole list is outside the scope of this particular commit. Includes minor simplifications, such as: * Setting a default ahead of an `if`, instead of in an `else` clause (as long as no function call is needed to set the default). * Removing the unnecessary logic duplication in the `$post_status` switch. * Using a combined concatenation + assignment operator for adding `$post_more`. Fixes various errors along the lines of: {{{ 1) Tests_XMLRPC_mw_editPost::test_draft_not_prematurely_published strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated /var/www/src/wp-includes/formatting.php:2497 /var/www/src/wp-includes/class-wp-hook.php:308 /var/www/src/wp-includes/plugin.php:205 /var/www/src/wp-includes/post.php:2835 /var/www/src/wp-includes/post.php:2720 /var/www/src/wp-includes/post.php:4066 /var/www/src/wp-includes/class-wp-xmlrpc-server.php:5616 /var/www/tests/phpunit/tests/xmlrpc/mw/editPost.php:315 ... 23) Tests_XMLRPC_mw_editPost::test_draft_not_prematurely_published json_decode(): Passing null to parameter #1 ($json) of type string is deprecated /var/www/src/wp-includes/kses.php:2074 /var/www/src/wp-includes/class-wp-hook.php:307 /var/www/src/wp-includes/plugin.php:205 /var/www/src/wp-includes/post.php:2835 /var/www/src/wp-includes/post.php:2720 /var/www/src/wp-includes/post.php:4066 /var/www/src/wp-includes/class-wp-xmlrpc-server.php:5615 /var/www/tests/phpunit/tests/xmlrpc/mw/editPost.php:315 /var/www/vendor/bin/phpunit:123 }}} Follow-up to [1563], [4793], [7900], [16824], [19848], [40677], [51968]. Props jrf. See #55656. git-svn-id: https://develop.svn.wordpress.org/trunk@54320 602fd350-edb4-49c9-b593-d223f7449a82
ramonjd
pushed a commit
that referenced
this pull request
Sep 29, 2022
…pc_server::_insert_post()`. The `wp_xmlrpc_server::_insert_post()` method creates a new post via `wp_insert_post()` or updates an existing one via `wp_update_post()`, which subsequently calls `wp_insert_post()`. However, the default/fallback values used in the function were not in line with the default/fallback values used in the `wp_insert_post()` function. The `wp_insert_post()` function does a `wp_parse_args()` (array merge) of the received arguments with the defaults. If any of the received arguments are `null`, this would overwrite the default value, as seen in [https://3v4l.org/bfVlv array_merge() example], and lead to "passing null to non-nullable" deprecation notices on PHP 8.1 for certain arguments. Unfortunately, the conditional logic within the `wp_xmlrpc_server::_insert_post()` function itself often uses an `isset()` to trigger certain code blocks, so syncing the defaults with those used in the `wp_insert_post()` function was not an option. This commit: * Updates the default/fallback values in the `$defaults` array only for those values where this would not lead to a change in the behavior of the function. * Adds a safeguard function, filtering out all remaining `null` values from the `$post_data` array before it is passed on to the `wp_insert_post()` or `wp_update_post()` functions. Removing those values is safe as this means that these array keys will now: * either be set to the default/fallback value as defined in `wp_insert_post()`. * or not be set and for those values which don't have a default/fallback value in `wp_insert_post()`, the function does an `! empty()` or `isset()` check anyway and those array keys not being defined means that the result of those checks will remain the same. Includes * Removing a couple of conditions which are now redundant. * Removing an `expectDeprecation()` in the `Tests_Date_XMLRPC` test class, which is now no longer needed. Fixes various errors along the lines of: {{{ 36) Tests_XMLRPC_wp_newPost::test_no_content json_decode(): Passing null to parameter #1 ($json) of type string is deprecated /var/www/src/wp-includes/kses.php:2074 /var/www/src/wp-includes/class-wp-hook.php:307 /var/www/src/wp-includes/plugin.php:205 /var/www/src/wp-includes/post.php:2835 /var/www/src/wp-includes/post.php:2720 /var/www/src/wp-includes/post.php:4066 /var/www/src/wp-includes/class-wp-xmlrpc-server.php:1683 /var/www/src/wp-includes/class-wp-xmlrpc-server.php:1347 /var/www/tests/phpunit/tests/xmlrpc/wp/newPost.php:25 /var/www/vendor/bin/phpunit:123 }}} Follow-up to [1563], [4793], [7900], [16824], [19848], [19873], [20632], [40677], [51968], [54320]. Props jrf. See #55656. git-svn-id: https://develop.svn.wordpress.org/trunk@54321 602fd350-edb4-49c9-b593-d223f7449a82
ramonjd
pushed a commit
that referenced
this pull request
Sep 29, 2022
…ions path. The `$path` parameter of `load_script_textdomain()` had a default value of `null`, but would be passed onto the `untrailingslashit()` function without any input validation, even though the latter explicitly only expects/supports a string input. This commit changes the default value for `$path` to an empty string, and adds an `is_string()` check before passing the value to `untrailingslashit()` to fix the issue at the point where the invalid input is incorrectly (not) validated. Note: Changing the `untrailingslashit()` function is outside the scope of this commit. Includes: * Adding a dedicated unit test for this issue. * Correcting the default value for `$path` from `null` to an empty string in a few related methods and functions: * `WP_Dependency::set_translations()` * `WP_Scripts::set_translations()` * `wp_set_script_translations()` * `load_script_textdomain()` This fix also allows to remove a couple of calls to `expectDeprecation()` in unrelated tests. Fixes an error when running the test suite: {{{ 4) Tests_Dependencies_Scripts::test_wp_external_wp_i18n_print_order rtrim(): Passing null to parameter #1 ($string) of type string is deprecated /var/www/src/wp-includes/formatting.php:2782 /var/www/src/wp-includes/l10n.php:1068 /var/www/src/wp-includes/class.wp-scripts.php:605 /var/www/src/wp-includes/class.wp-scripts.php:320 /var/www/src/wp-includes/class.wp-dependencies.php:136 /var/www/src/wp-includes/functions.wp-scripts.php:109 /var/www/tests/phpunit/tests/dependencies/scripts.php:1505 /var/www/tests/phpunit/includes/utils.php:436 /var/www/tests/phpunit/tests/dependencies/scripts.php:1507 /var/www/vendor/bin/phpunit:123 }}} Follow-up to [44169], [44607], [51968]. Props jrf, ocean90, Chouby, swissspidy, lovor, iviweb, meysamnorouzi, DarkoG, oneearth27, SergeyBiryukov. Fixes #55967. See #55656. git-svn-id: https://develop.svn.wordpress.org/trunk@54349 602fd350-edb4-49c9-b593-d223f7449a82
ramonjd
pushed a commit
that referenced
this pull request
Sep 30, 2022
…_JSON::get_property_value()`. This commit aims to fix errors caused by incorrect usage of the `strncmp()` function inside the `WP_Theme_JSON::get_property_value()` method on PHP 8.1 and above. Some history of the affected code: * [50973] introduced the `WP_Theme_JSON::get_property_value()` method. * [54162] removed the `$default` parameter from the `_wp_array_get()` call in the method. With the latter change, the default value that is returned if the path does not exist within the array, or if `$array` or `$path` are not arrays, became `null` instead of an empty string. Since `null` would then be unintentionally passed to the `strncmp()` function further in the code, this caused ~35 errors in the test suite along the lines of: {{{ 1) Tests_Blocks_Editor::test_get_block_editor_settings_theme_json_settings strncmp(): Passing null to parameter #1 ($string1) of type string is deprecated /var/www/src/wp-includes/class-wp-theme-json.php:1754 /var/www/src/wp-includes/class-wp-theme-json.php:1641 /var/www/src/wp-includes/class-wp-theme-json.php:2066 /var/www/src/wp-includes/class-wp-theme-json.php:1002 /var/www/src/wp-includes/class-wp-theme-json.php:898 /var/www/src/wp-includes/global-styles-and-settings.php:140 /var/www/src/wp-includes/block-editor.php:421 /var/www/tests/phpunit/tests/blocks/editor.php:388 /var/www/vendor/bin/phpunit:123 }}} This commit includes: * Restoring the `$default` value for `_wp_array_get()` call. * Adding an early return if the value is an empty string or `null`. * Adding a dedicated unit test to ensure that the method returns a string for invalid paths or `null` values. Follow-up to [50973], [54162]. Props antonvlasenko, jrf, imadarshakshat, SergeyBiryukov. Fixes #56620. git-svn-id: https://develop.svn.wordpress.org/trunk@54362 602fd350-edb4-49c9-b593-d223f7449a82
ramonjd
pushed a commit
that referenced
this pull request
Oct 5, 2022
…L10n`. These three tests for `wp_dashboard_recent_drafts()` would run into a PHP 8.1 "passing null to non-nullable" deprecation for the call to `ltrim()` when the result of `get_edit_post_link()` is passed to `esc_url()`. Setting a deprecation expectation would not solve this as the returned value would still not match the expected value(s). The recent drafts list is only displayed on the Dashboard screen for users with the `edit_posts` capability. By setting the current user to Editor, the prerequisites for `wp_dashboard_recent_drafts()` are met, which means the deprecation notice is avoided and the assertions will succeed. This commit addresses a few errors in the test suite along the lines of: {{{ 1) Tests_L10n::test_length_of_draft_should_be_counted_by_words ltrim(): Passing null to parameter #1 ($string) of type string is deprecated /var/www/src/wp-includes/formatting.php:4376 /var/www/src/wp-admin/includes/dashboard.php:657 /var/www/tests/phpunit/tests/l10n.php:449 /var/www/vendor/bin/phpunit:123 }}} Follow-up to [45505], [52253], [52259]. Props jrf, desrosj, SergeyBiryukov. See #56681, #55652, #55656. git-svn-id: https://develop.svn.wordpress.org/trunk@54365 602fd350-edb4-49c9-b593-d223f7449a82
ramonjd
pushed a commit
that referenced
this pull request
Apr 2, 2023
The `$credentials['user_login']` and `$credentials['user_password']` parameters are passed by reference to the `wp_authenticate` action, and are at that point [https://www.php.net/manual/en/language.references.pass.php#124383 created as null] if they don't exist in the array. This commit sets those values to an empty string, resolving two PHP 8.1 deprecation notices: * One from `preg_replace()` in `wp_strip_all_tags()` via `sanitize_user()` in `wp_authenticate()`: {{{ Deprecated: preg_replace(): Passing null to parameter WordPress#3 ($subject) of type array|string is deprecated }}} * One from `trim()` in `wp_authenticate()` itself: {{{ Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated }}} Includes documenting the `$credentials` parameter using hash notation. Follow-up to [6643], [37697]. Props lenasterg, TobiasBg, ocean90, afragen, lkraav, SergeyBiryukov. Fixes #56850. git-svn-id: https://develop.svn.wordpress.org/trunk@55301 602fd350-edb4-49c9-b593-d223f7449a82
ramonjd
pushed a commit
that referenced
this pull request
Apr 2, 2023
…air screen. The table is no longer created by core as of WordPress 3.0, and support for global terms was removed in WordPress 6.1, so `$wpdb->sitecategories` is unset by default. This commit resolves a "passing null to non-nullable" deprecation notice on PHP 8.1: {{{ Deprecated: addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated in wp-includes/class-wpdb.php on line 1804 }}} The `tables_to_repair` filter is available for plugins to readd the table or include any additional tables to repair. Follow-up to [14854], [14880], [54240]. Props ipajen, chiragrathod103, SergeyBiryukov. Fixes #57762. git-svn-id: https://develop.svn.wordpress.org/trunk@55421 602fd350-edb4-49c9-b593-d223f7449a82
ramonjd
pushed a commit
that referenced
this pull request
Oct 4, 2023
…om next_posts(). The `esc_url()` function expects to a string for `$url` parameter. There is no input validation within that function. The function contains a `ltrim()` which also expects a string. Passing `null` to this parameter results in `Deprecated: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1+. Tracing the stack back, a `null` is being passed to it within `next_posts()` when `get_next_posts_page_link()` returns `null` (it can return a string or `null`). On PHP 7.0 to PHP 8.x, an empty string is returned from `esc_url()` when `null` is passed to it. The change in this changeset avoids the deprecation notice by not invoking `esc_url()` when `get_next_posts_page_link()` returns `null` and instead sets the `$output` to an empty string, thus maintain the same behavior as before (minus the deprecation notice). Adds a test to validate an empty string is returned and the absence of the deprecation (when running on PHP 8.1+). Follow-up to [11383], [9632]. Props codersantosh, nihar007, hellofromTonya, mukesh27, oglekler, rajinsharwar. Fixes #59154. git-svn-id: https://develop.svn.wordpress.org/trunk@56740 602fd350-edb4-49c9-b593-d223f7449a82
ramonjd
pushed a commit
that referenced
this pull request
Aug 5, 2024
…Info screen. This resolves a fatal error if `strict_types` PHP setting is enabled: {{{ Argument #1 ($num) must be of type float, string given }}} Since the goal of the Site Health Info screen is to display raw values where possible, the `number_format()` call here does not seem to provide any benefit. Props krishneup, sabernhardt, audrasjb, SergeyBiryukov. Fixes #60364. git-svn-id: https://develop.svn.wordpress.org/trunk@58847 602fd350-edb4-49c9-b593-d223f7449a82
ramonjd
pushed a commit
that referenced
this pull request
Oct 28, 2024
…ord()`. This resolves a "passing null to non-nullable" deprecation notice on PHP 8.1+: {{{ Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated }}} Follow-up to [50129], [54477]. Props afragen, peterwilsoncc, SergeyBiryukov. Fixes #62298. git-svn-id: https://develop.svn.wordpress.org/trunk@59312 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎼 So much fresh, So much clean 🎶
Sorry. That was an experiment gone wrong.