Skip to content

Commit 49d5975

Browse files
authored
Workflow
1 parent 64a8b16 commit 49d5975

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

.github/workflows/php74-latest-wp-test.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)