Skip to content

Commit

Permalink
Revert "Bootstrap wp-admin before rendering widgets – they may rely o…
Browse files Browse the repository at this point in the history
…n wp-admin functions being loaded. (#33454)"

This reverts commit 3952888.
  • Loading branch information
desrosj authored Jul 15, 2021
1 parent 705a264 commit f36003a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 9 deletions.
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

0 comments on commit f36003a

Please sign in to comment.