Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active January 1, 2019 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/c3617efbbfd2a47c432f69dd41ce312c to your computer and use it in GitHub Desktop.
Save tommcfarlin/c3617efbbfd2a47c432f69dd41ce312c to your computer and use it in GitHub Desktop.
[WordPress] WordPress Widgets: Refactoring, Part 5
<?php
namespace WordPressWidgetBoilerplate;
use WordPressWidgetBoilerplate\Utilities\Registry;
// More to come...
<?php
// Setup a filter so we can retrieve the registry throughout the plugin.
$registry = new Registry();
add_filter('wpWidgetRegistry', function () use ($registry) {
return $registry;
});
<?php
// 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