Skip to content

Instantly share code, notes, and snippets.

@bueltge
Last active April 21, 2016 13:57
Show Gist options
  • Save bueltge/e395766c2a86f5f5c0d31237c6aeb616 to your computer and use it in GitHub Desktop.
Save bueltge/e395766c2a86f5f5c0d31237c6aeb616 to your computer and use it in GitHub Desktop.
WordPress Antipattern, no good classes
// @see http://dnaber.de/blog/2015/wordpress-antipattern-filter-im-constructor-zuweisen/
class MetaBoxRegistrar {
private $metaBox;
public function __construct( MetaBoxInterface $metaBox ) {
$this->metaBox = $metaBox;
}
public function register() {
add_action(
'add_meta_boxes',
[ $this->metaBox, 'addMetaBox' ]
);
add_action(
'save_post',
[ $this->metaBox, 'savePost' ]
);
}
}
@bueltge
Copy link
Author

bueltge commented Apr 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment