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

Prepare for rocket head ordering #7304

Merged
merged 30 commits into from
Feb 20, 2025
Merged

Conversation

wordpressfan
Copy link
Contributor

@wordpressfan wordpressfan commented Feb 12, 2025

Description

Fixes #7272

Every thing is mentioned in the issue itself.

Type of change

  • New feature (non-breaking change which adds functionality).
  • Enhancement (non-breaking change which improves an existing functionality).

Detailed scenario

Here we refactor how our features add items into the head directly after title closing tag </title>.

Technical description

Documentation

We introduced here a filter to print anything needed in the head part and its usage is as follows:

add_filter( 'rocket_head_items', function( $items ) {
    return $items;
} );

and this $items is an array of array variable with the following structure:

$items = [
    'open_tag' => '<style',
    'close_tag' => '</style>',
    'inner_content' => 'h1{color: red;}',
    'id' => 'any_id',
..... any html attribute as key => value
];

and if u need to add HTML attribute without value, something like crossorigin, you can add its key as a numeric, something like:

1 => 'crosorigin',

Also we introduced a helper trait called ElementTrait to help in inserting the common head elements like preload, preconnect, style, noscript, ...etc.

Also as a standard, we will use the following filter priorities:

Priority 10: preconnect
Priority 30: preload
Priority 50: styles, noscripts, scripts, ...etc.

New dependencies

No

Risks

We validated the e2e and it works, also most of tests passed, just had an issue with one test that it fails for the first time, that we need to revisit later on.

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

Unticked items justification

If some mandatory items are not relevant, explain why in this section.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

@wordpressfan wordpressfan linked an issue Feb 12, 2025 that may be closed by this pull request
@wordpressfan wordpressfan changed the base branch from feature/preload-fonts to feature/3.19 February 20, 2025 10:32
@wordpressfan wordpressfan marked this pull request as ready for review February 20, 2025 11:07
Copy link

codacy-production bot commented Feb 20, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for d4ad5341 39.00% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d4ad534) Report Missing Report Missing Report Missing
Head commit (11d44ef) 39247 17108 43.59%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7304) 241 94 39.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@wordpressfan
Copy link
Contributor Author

created a followup issue here:
#7315
not to forget to fix the skipped tests.

@wordpressfan wordpressfan merged commit fc03b07 into feature/3.19 Feb 20, 2025
11 of 13 checks passed
@wordpressfan wordpressfan deleted the feature/add-rocket-head branch February 20, 2025 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.19 - Refactor features to use rocket_head new approach
1 participant