File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -211,26 +211,19 @@ jobs:
211211 * @package Simple_WP_Optimizer
212212 */
213213
214- // Define global $wp_widget_factory to prevent null reference errors
215- global $wp_widget_factory;
216- $wp_widget_factory = (object) ['widgets' => []];
217-
218- // Add a mock register_widget function that works with our fake widget factory
219- if (!function_exists('register_widget')) {
220- function register_widget($widget) {
221- global $wp_widget_factory;
222- $wp_widget_factory->widgets[] = $widget;
223- return true;
224- }
225- }
226-
227214 // Give access to tests_add_filter() function.
228215 require_once '/tmp/wordpress-tests-lib/includes/functions.php';
229216
230217 /**
231218 * Manually load the plugin being tested.
232219 */
233220 function _manually_load_plugin() {
221+ // Make sure widget registration won't throw errors
222+ add_filter('widgets_init', function() {
223+ // Empty the action to prevent widget registration errors
224+ return;
225+ }, 0);
226+
234227 require dirname( dirname( __FILE__ ) ) . '/simple-wp-optimizer.php';
235228 }
236229
You can’t perform that action at this time.
0 commit comments