Skip to content

Improvement: Introducing new filter using which theme authors can modify whether the current theme supports FSE or not.#35616

Closed
premanshup wants to merge 5 commits intoWordPress:trunkfrom
premanshup:gutenberg-is-fse-theme-filter
Closed

Improvement: Introducing new filter using which theme authors can modify whether the current theme supports FSE or not.#35616
premanshup wants to merge 5 commits intoWordPress:trunkfrom
premanshup:gutenberg-is-fse-theme-filter

Conversation

@premanshup
Copy link
Copy Markdown

Description

This PR introduces a new filter gutenberg_is_fse_theme inside function gutenberg_is_fse_theme using which theme developers can filter whether the theme supports FSE or not.

Update FSE support -

add_filter( 'gutenberg_is_fse_theme', '__return_false' );
add_filter( 'gutenberg_is_fse_theme', '__return_true' );

How has this been tested?

Tested by adding the above filters and checking if they update the output for the function gutenberg_is_fse_theme or not. The function's value is updated, so the filter seems to be working as expected.

Screenshots

Types of changes

Improvement (non-breaking change which adds functionality).

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

…ify whether the current theme supports FSE or not.
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 14, 2021
@github-actions
Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @premanshup! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@draganescu
Copy link
Copy Markdown
Contributor

Howdy! What is the filter for? The function allows a theme or plugin to know if it is FSE enabled or not. Filtering this can lead to false negatives or false positives.

@premanshup
Copy link
Copy Markdown
Author

Howdy! What is the filter for? The function allows a theme or plugin to know if it is FSE enabled or not. Filtering this can lead to false negatives or false positives.

@draganescu I was thinking of this filter from the legacy ( non-FSE ) themes perspective, what if they could implement both HTML and PHP file/folder structure?

I'm thinking of a scenario where a theme could provide an option for users to switch from legacy theme to FSE theme or vice-versa.

From my finding, I think this is the main function ( gutenberg_is_fse_theme ) that enables/disables FSE support by checking if the index.html file exists or not.

https://github.com/WordPress/gutenberg/blob/trunk/lib/full-site-editing/full-site-editing.php#L14

I was wondering if we can implement this filter so that legacy themes could be converted to FSE themes if needed or required by the users. I think the folder/file structure for FSE and legacy themes is different. One uses .html files and the other one uses .php files ( from what I have understood ). Adding this filter could open up new possibilities for existing themes? ( or I could be completely wrong ). My apologies if I'm missing anything here.

@premanshup
Copy link
Copy Markdown
Author

@draganescu Howdy! In addition to this, I have not yet checked how theme.json can be handled in both cases. I think there will be a need to handle the loading of the theme.json file. I will check in detail and see if that can be loaded conditionally as well?

Copy link
Copy Markdown
Member

@oandregal oandregal left a comment

Choose a reason for hiding this comment

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

Hey Premanshu, I don't think adding a filter to change whether the theme.json exists is a good idea: either it does or doesn't. If you can share your specific needs, someone can probably help to identify how that can be done, what needs to be adapted if anything, etc.

@premanshup
Copy link
Copy Markdown
Author

Hello @oandregal ! Thank you so much for your feedback. I have mentioned my concern here in the issue. Please let me know if we can implement the filter for theme.json based on the two points I have shared in the issue.

@Mamaduka
Copy link
Copy Markdown
Member

Mamaduka commented Apr 7, 2025

These methods are now part of WP core. Any related documentation should be improved, which probably has been fixed during code sync.

I'm going to close the PR. Thanks for contributing, @premanshup!

@Mamaduka Mamaduka closed this Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants