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

Bootstrap wp-admin before rendering widgets – they may rely on wp-admin functions being loaded. #33454

Merged
merged 5 commits into from
Jul 15, 2021

Conversation

adamziel
Copy link
Contributor

@adamziel adamziel commented Jul 15, 2021

Description

Improves the situation of #33443

This PR ensures that wp-admin is bootstrapped before rendering any widgets. Some plugins, such as the Compact Archives plugin, assume that wp-admin functions are loaded and available because they were in the classic widgets editor.

This is a "quick" solution so that we may ship functional 5.8 RC4. A "proper" solution is still being discussed in #33443.

How has this been tested?

  1. Install and activate Classic Widget plugin
  2. Install and activate plugin using an admin function in its widget code (eg, Compact Archives 4.0.0 (zip))
  3. Add the widget on the classic widget screen. Everything will work as expected 🌻
  4. Deactivate the Classic Widget plugin
  5. Add the widget on the new widget screen. Without this PR, an error alert will show in the browser and a fatal in the PHP logs. With this PR, there will be no error.

Types of changes

Bug fix (non-breaking change which fixes an issue)

@adamziel adamziel added [Feature] Widgets Screen The block-based screen that replaced widgets.php. Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta [Block] Legacy Widget Affects the Legacy Widget Block - used for displaying Classic Widgets [Package] Edit Widgets /packages/edit-widgets labels Jul 15, 2021
@adamziel adamziel requested a review from spacedmonkey as a code owner July 15, 2021 11:42
@adamziel adamziel self-assigned this Jul 15, 2021
Co-authored-by: Tonya Mork <hello@hellofromtonya.com>
Copy link
Contributor

@hellofromtonya hellofromtonya left a comment

Choose a reason for hiding this comment

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

I can reproduce the original reported problem. Applying this PR's changes to core resolves the issue.

@adamziel adamziel merged commit 3952888 into trunk Jul 15, 2021
@adamziel adamziel deleted the fix/load-admin-functions-before-rendering-widgets branch July 15, 2021 14:37
@github-actions github-actions bot added this to the Gutenberg 11.2 milestone Jul 15, 2021
youknowriad pushed a commit that referenced this pull request Jul 15, 2021
…in functions being loaded. (#33454)

* Bootstrap wp-admin before rendering widgets – they may rely on wp-admin functions being loaded.

* Bootstrap wp-admin function also in /wp/v2/widgets endpoint

* Add a dot at the end of the comment to satisfy linter requirements

* Move the require_once statement to encode_form_data to increase the size of the safety net it provides.

* Update lib/class-wp-rest-widget-types-controller.php

Co-authored-by: Tonya Mork <hello@hellofromtonya.com>

Co-authored-by: Tonya Mork <hello@hellofromtonya.com>
@youknowriad youknowriad 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 15, 2021
desrosj added a commit that referenced this pull request Jul 15, 2021
…n wp-admin functions being loaded. (#33454)"

This reverts commit 3952888.
desrosj added a commit that referenced this pull request Jul 15, 2021
…n wp-admin functions being loaded. (#33454)"

This reverts commit 9d7017f.
desrosj added a commit that referenced this pull request Jul 15, 2021
…n wp-admin functions being loaded. (#33454)" (#33472)

This reverts commit 3952888.
@hellofromtonya
Copy link
Contributor

This PR has been reverted. See the reasons why here #33443 (comment)

youknowriad pushed a commit that referenced this pull request Jul 15, 2021
…in functions being loaded. (#33454)

* Bootstrap wp-admin before rendering widgets – they may rely on wp-admin functions being loaded.

* Bootstrap wp-admin function also in /wp/v2/widgets endpoint

* Add a dot at the end of the comment to satisfy linter requirements

* Move the require_once statement to encode_form_data to increase the size of the safety net it provides.

* Update lib/class-wp-rest-widget-types-controller.php

Co-authored-by: Tonya Mork <hello@hellofromtonya.com>

Co-authored-by: Tonya Mork <hello@hellofromtonya.com>
youknowriad pushed a commit that referenced this pull request Jul 15, 2021
…n wp-admin functions being loaded. (#33454)"

This reverts commit 9d7017f.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Legacy Widget Affects the Legacy Widget Block - used for displaying Classic Widgets [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Package] Edit Widgets /packages/edit-widgets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants