From 53713d8ad4d220f5f68ce5e3bd593255412af0c9 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Wed, 19 Feb 2025 18:01:50 +0100 Subject: [PATCH] Fix editing widgets in a block theme --- friends.php | 2 ++ includes/class-frontend.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/friends.php b/friends.php index 01c74de9..239b5e54 100644 --- a/friends.php +++ b/friends.php @@ -73,6 +73,8 @@ add_action( 'wp_initialize_site', array( __NAMESPACE__ . '\Friends', 'activate_for_blog' ) ); // Register widgets. +add_filter( 'customize_loaded_components', array( __NAMESPACE__ . '\Frontend', 'ensure_widget_editing' ) ); + require_once __DIR__ . '/widgets/class-widget-base-friends-list.php'; require_once __DIR__ . '/widgets/class-widget-refresh.php'; add_action( 'widgets_init', array( __NAMESPACE__ . '\Widget_Refresh', 'register' ) ); diff --git a/includes/class-frontend.php b/includes/class-frontend.php index 54ed1b28..b334f71a 100644 --- a/includes/class-frontend.php +++ b/includes/class-frontend.php @@ -117,7 +117,6 @@ private function register_hooks() { add_action( 'wp_untrash_post_status', array( $this, 'untrash_post_status' ), 10, 2 ); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'template_redirect', array( $this, 'load_theme' ) ); - add_action( 'customize_loaded_components', array( $this, 'ensure_widget_editing' ) ); add_action( 'friends_load_theme_default', array( $this, 'default_theme' ) ); add_action( 'friends_template_paths', array( $this, 'friends_template_paths' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'dequeue_scripts' ), 99999 ); @@ -242,7 +241,7 @@ public function register_friends_sidebar() { } } - public function ensure_widget_editing( $components ) { + public static function ensure_widget_editing( $components ) { if ( ! is_array( $components ) ) { $components = array(); }