Skip to content
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

Use _get_block_template_file function and set $area variable. #52708

Merged
merged 2 commits into from
Jul 18, 2023

Conversation

spacedmonkey
Copy link
Member

@spacedmonkey spacedmonkey commented Jul 17, 2023

What?

Fix for #58770.

Use _get_block_template_file, the util function to get path of block template file. This function returns an array of data that includes the area. A valid area is needed for the following line.

$content = wp_filter_content_tags( $content, "template_part_{$area}" );

With a valid error type, this results in lazy loading attribute being added to header images.

For extra context
https://github.com/WordPress/wordpress-develop/blob/2e64ff87b847284a8235c190731266e620466206/src/wp-includes/media.php#L5682-L5687

WordPress/wordpress-develop@87c575a

Why?

How?

Testing Instructions

Taken from https://core.trac.wordpress.org/ticket/58770:

Images in block themes are not applying the image attributes correctly. While testing the following behaviours were noticed.

  • Site logos in header of page, having loading="lazy".
  • Image in header, not having fetch priority = high. Also not no lazy loading image.
  • Image block hardcode into patterns not either loading and fetch priority attributes.

Steps to replicate:

Activate TT2 theme.

Testing Instructions for Keyboard

Screenshots or screencast

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spacedmonkey Thanks for creating the PR! Similar to the core PR, LGTM. Just one small nit-pick here.

packages/block-library/src/template-part/index.php Outdated Show resolved Hide resolved
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
@github-actions
Copy link

Flaky tests detected in f5062f3.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5581614338
📝 Reported issues:

@spacedmonkey spacedmonkey added [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked. Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jul 18, 2023
@ramonjd
Copy link
Member

ramonjd commented Jul 18, 2023

Smoke tested header images

Before

Screenshot 2023-07-18 at 11 44 33 am

After

Screenshot 2023-07-18 at 11 44 38 am

🍺

@ramonjd ramonjd merged commit 211713c into trunk Jul 18, 2023
@ramonjd ramonjd deleted the fix/template-part branch July 18, 2023 01:52
@github-actions github-actions bot added this to the Gutenberg 16.3 milestone Jul 18, 2023
ramonjd pushed a commit that referenced this pull request Jul 18, 2023
* Use `_get_block_template_file` function and set $area variable.

* Update packages/block-library/src/template-part/index.php

Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>

---------

Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
@ramonjd
Copy link
Member

ramonjd commented Jul 18, 2023

I just cherry-picked this PR to the update/second-round-RC1 branch to get it included in the next release: 9c123c4

@ramonjd ramonjd removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 18, 2023
westonruter added a commit that referenced this pull request Jul 18, 2023
* trunk: (36 commits)
  Use `_get_block_template_file` function and set $area variable. (#52708)
  Change Delete page menu item to Move to trash. (#52641)
  Search block: Enqueue view script through block.json (#52552)
  Patterns: fix bug with Create Patterns menu not showing in site editor page editing (#52671)
  Github workflow: add a PHP backport changes action (#52096)
  Add layout API documentation. (#52673)
  Show uncategorized patterns on the Editor > Patterns page (#52633)
  Patterns: Remove `reusable` text from menu once rename hint has been dismissed (#52664)
  Update locked pattern tooltips (#52497)
  Rich Text/Footnotes: fix getRichTextValues for useInnerBlocksProps.save (#52682)
  Use posts instead of template parts for navigation color tests (#52654)
  Site Editor: Don't allow creating template part on the Patterns page for non-block themes (#52656)
  Site Editor: Fix incorrect 'useSelect' usage (#52683)
  Update issue gardening automation with new label (#52173)
  i18n: Make the tab labels of `ColorGradientSettingsDropdown` component translatable (#52669)
  Post Content link color should not be applied to placeholder component links (#52367)
  [Mobile] Update toolbar icons and colors (#52336)
  Avoid copying global style presets via the styles compatibility hook (#52640)
  Show warning on removal of Post Template block in the site editor. (#52666)
  Backport tools: sort PRs to be cherry picked by merged/closed date (#52667)
  ...
ramonjd added a commit that referenced this pull request Jul 18, 2023
* Try restoring the site editor animation (#51956)

* Try restoring the site editor animation

* fix header animation

* Remove accidental addition of layout prop

* tidy up formatting

* fix animate presence issue

* Fix animation between sidebar view and distraction free edit view

* Leave sidebar present and maintain canvas to
sidebar animation

The sidebar is necessary for routing on mobile so we have to maintain its presence in the DOM. Just hiding it isn't enough though, as it is still able to be reached with keyboard tabs and screen readers. Using the relatively new `inert` property disables the element from user interaction, so we add that when we don't want the sidebar to be shown.

* Fix mobile view for pattern library

On Mobile, the canvas mode wasn't being set to edit when using the pattern library. This updates it to use the showSidbar value instead, keeping it in sync with the inert setting.

---------

Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>
Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com>

* Change password input to type text so contents are visible. (#52622)

* Iframe: Silence style compat warnings when in a BlockPreview (#52627)

* Do not autofocus page title field in the Create new page modal dialog. (#52603)

* Use lowercase p in "Manage Patterns" (#52617)

* Remove theme patterns title (#52570)

* Block editor store: also attach private APIs to old store descriptor (#52088)

As a workaround, until #39632 is merged, make sure that private actions
and selectors can be unlocked from the original store descriptor (the
one created by `createReduxStore`) and not just the one registered in
the default registry (created by `registerStore`).

Without this workaround, specific setups will unexpectedly fail, such as
the action tests in the `reusable-blocks` package, due to the way that
those tests create their own registries in which they register stores
like `block-editor`.

Context: #51145 (comment)

Props jsnajdr

* Block removal prompt: let consumers pass their own rules (#51841)

* Block removal prompt: let consumers pass their own rules

Following up on #51145, this untangles `edit-site` from `block-editor`
by removing the hard-coded set of rules `blockTypePromptMessages` from
the generic `BlockRemovalWarningModal` component. Rules are now to be
passed to that component by whichever block editor is using it.

Names and comments have been updated accordingly and improved.

* Site editor: Add e2e test for block removal prompt

* Fix Shift+Tab to Block Toolbar (#52613)

* Fix Shift+Tab to Block Toolbar

* Add changelog entry

* Show warning on removal of Post Template block in the site editor. (#52666)

* Avoid copying global style presets via the styles compatibility hook (#52640)

* i18n: Make the tab labels of `ColorGradientSettingsDropdown` component translatable (#52669)

* Rich Text/Footnotes: fix getRichTextValues for useInnerBlocksProps.save (#52682)

* Rich Text/Footnotes: fix getRichTextValues for useInnerBlocksProps.save

* Address feedback

* Patterns: Remove `reusable` text from menu once rename hint has been dismissed (#52664)

* Show uncategorized patterns on the Editor > Patterns page (#52633)

* Patterns: fix bug with Create Patterns menu not showing in site editor page editing (#52671)

* Pass the root client id into the reusable blocks menu

* Check that clientIds array is defined

* Make check for array item more specific

* Search block: Enqueue view script through block.json (#52552)

* Search block: Enqueue view script through block.json

* Remove extra space

* Use `_get_block_template_file` function and set $area variable. (#52708)

* Use `_get_block_template_file` function and set $area variable.

* Update packages/block-library/src/template-part/index.php

Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>

---------

Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>

* Site Editor: Don't allow creating template part on the Patterns page for non-block themes (#52656)

* Don't allow template part to be created on the Patterns page for non-block themes

* Remove unnecessary theme directory name in E2E test

* Change Delete page menu item to Move to trash. (#52641)

* Use relative path internally to include packages in dependencies (#52712)

* Spacing Sizes: Fix zero size (#52711)

* DimensionsPanel: Fix unexpected value decoding/encoding (#52661)

---------

Co-authored-by: Daniel Richards <daniel.richards@automattic.com>
Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>
Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com>
Co-authored-by: Robert Anderson <robert@noisysocks.com>
Co-authored-by: Andrea Fercia <a.fercia@gmail.com>
Co-authored-by: Rich Tabor <hi@richtabor.com>
Co-authored-by: James Koster <james@jameskoster.co.uk>
Co-authored-by: Miguel Fonseca <150562+mcsf@users.noreply.github.com>
Co-authored-by: Haz <hazdiego@gmail.com>
Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Co-authored-by: Ella <4710635+ellatrix@users.noreply.github.com>
Co-authored-by: Glen Davies <glendaviesnz@users.noreply.github.com>
Co-authored-by: Carolina Nymark <myazalea@hotmail.com>
Co-authored-by: Petter Walbø Johnsgård <petter@dekode.no>
Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
@mburridge mburridge added [Type] Bug An existing feature does not function as intended [Package] Block library /packages/block-library labels Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants