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

3.19 - Refactor features to use rocket_head new approach #7272

Open
wordpressfan opened this issue Feb 3, 2025 · 1 comment · Fixed by #7304
Open

3.19 - Refactor features to use rocket_head new approach #7272

wordpressfan opened this issue Feb 3, 2025 · 1 comment · Fixed by #7304
Assignees
Milestone

Comments

@wordpressfan
Copy link
Contributor

Is your feature request related to a problem? Please describe.
We started a discussion here with @remyperona to have an approach to unify the addition of link tags inside head directly after the closing tag of title but without any duplication, and we proposed a solution here

So we need to move forward with this approach (we may need to unify the way we insert link into the head using a trait or functions, this will make it more maintainable)

So the main goals of this issue are:

  1. Set the standard of the items being added into head, something like Priority 10 for link tags, priority 20 for styles, ...etc.
  2. Create the trait to insert the items into head, so instead of using the following code:
add_filter( 'rocket_head_items', function ( $items ) {
    $items[] = [
        'open_tag' => '<link',
        'rel' => 'preload',
        'href' => 'https://example.org/',
        'close_tag' => '/>',
    ];
    return $items;
} );

we can use something like:

add_filter( 'rocket_head_items', function ( $items ) {
    $items[] = $this->add_preload_link( 'https://example.org/' );
    return $items;
} );

and do the same with other types of link types and styles.
3. Refactor the other features like RUCSS, critical CSS, and any other feature that add items into the head (you can search for the closing title tag into the code to reach all instances) and then make sure that the features are working properly.

@wordpressfan
Copy link
Contributor Author

Moving this to QA Done, I did the QA and @jeawhanlee ran the e2e and seems like it's working properly so I merged it into the main branch because other features are depending on it.

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 a pull request may close this issue.

2 participants