Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #58894


Ignore:
Timestamp:
07/24/2023 06:50:23 PM (12 months ago)
Author:
flixos90
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #58894 – Description

    initial v1  
    11The `wp_get_loading_optimization_attributes()` function, which was introduced in 6.3 (see #58235) but inherited most of its logic from the now deprecated `wp_get_loading_attr_default()` function introduced in 5.5, relies on a `$context` parameter based on which it may alter its behavior and the attributes returned. At the moment, it only supports context values used within WordPress core.
    22
    3 While this made sense for a first implementation, it is technically not required and could easily be expanded in several areas to support custom context values. Having to use WordPress core contexts is limiting today when relying on the function in plugins or themes, as at the moment any custom context used would result in incorrect handling of the attributes. This leads to the awkward situation where we currently have to recommend always using one of the core context values, even when the function is actually used in a different context (see e.g. the [https://make.wordpress.org/core/2023/07/13/image-performance-enhancements-in-wordpress-6-3/ dev note post] which recommends using the `wp_get_attachment_image` context even though that function is never called in the example).
     3While this made sense for a first implementation, it is technically not required and could easily be expanded in several areas to support custom context values. Having to use WordPress core contexts is limiting today when relying on the function in plugins or themes, as at the moment any custom context used would result in incorrect handling of the attributes. This leads to the awkward situation where we currently have to recommend always using one of the core context values, even when the function is actually used in a different context (see e.g. the [https://make.wordpress.org/core/2023/07/13/image-performance-enhancements-in-wordpress-6-3/ dev note post] which recommends using the `wp_get_attachment_image` context even though that function is never called in the example). An actual example for the problem is [https://github.com/tomusborne/generatepress/pull/557/files this theme pull request] which, despite looking correct, would lead to incorrect behavior as of today.
    44
    55We should abstract certain clauses in the function away from specific contexts so that the function can also be ''correctly'' used with custom contexts.