Skip to content

Instantly share code, notes, and snippets.

@withinboredom
Last active October 23, 2017 16:08
Show Gist options
  • Save withinboredom/333d68b85f1295f8d93016a3bc37783b to your computer and use it in GitHub Desktop.
Save withinboredom/333d68b85f1295f8d93016a3bc37783b to your computer and use it in GitHub Desktop.
Using WordPress#
using WordPress.Includes;
namespace Example {
class ExampleClass {
public ExampleClass( WpHookManager hooks ) {
hooks.AddAction( "example", Callback, priority: 10, acceptedArgs: 0 );
}
private async Task<object> Callback(IEnumerable<object> args) {
return true;
}
}
class Program() {
public int Main() {
var hooks = new WpHookManager();
new ExampleClass( hooks );
hooks.DoAction( "example" ); /* this is async, don't forget to `await` in real life!! */
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment