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

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/class-wp-rest-widget-types-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,6 @@ public function encode_form_data( $request ) {
);
}

// Third-party widgets may rely on wp-admin functions. So let's load them before working with the widget object.
require_once ABSPATH . 'wp-admin/includes/admin.php';

// Set the widget's number so that the id attributes in the HTML that we
// return are predictable.
if ( isset( $request['number'] ) && is_numeric( $request['number'] ) ) {
Expand Down
6 changes: 0 additions & 6 deletions lib/class-wp-rest-widgets-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,16 +544,10 @@ public function prepare_item_for_response( $item, $request ) {
rest_is_field_included( 'rendered', $fields ) &&
'wp_inactive_widgets' !== $sidebar_id
) {
// Some third-party widgets rely on wp-admin functions.
require_once ABSPATH . 'wp-admin/includes/admin.php';

$prepared['rendered'] = trim( wp_render_widget( $widget_id, $sidebar_id ) );
}

if ( rest_is_field_included( 'rendered_form', $fields ) ) {
// Some third-party widgets rely on wp-admin functions.
require_once ABSPATH . 'wp-admin/includes/admin.php';

$rendered_form = wp_render_widget_control( $widget_id );
if ( ! is_null( $rendered_form ) ) {
$prepared['rendered_form'] = trim( $rendered_form );
Expand Down