-
-
Save tommcfarlin/c3617efbbfd2a47c432f69dd41ce312c to your computer and use it in GitHub Desktop.
[WordPress] WordPress Widgets: Refactoring, Part 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace WordPressWidgetBoilerplate; | |
use WordPressWidgetBoilerplate\Utilities\Registry; | |
// More to come... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Setup a filter so we can retrieve the registry throughout the plugin. | |
$registry = new Registry(); | |
add_filter('wpWidgetRegistry', function () use ($registry) { | |
return $registry; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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