Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[WordPress] WordPress Widgets: Refactoring, Part 5
namespace WordPressWidgetBoilerplate;
use WordPressWidgetBoilerplate\Utilities\Registry;
// More to come...
// Setup a filter so we can retrieve the registry throughout the plugin.
$registry = new Registry();
add_filter('wpWidgetRegistry', function () use ($registry) {
return $registry;
// Retrieve the registry anywhere in the plugin.
$registry = apply_filters('wpWidgetRegistry', null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment