forked from datawrapper/datawrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Extending Datawrapper
gka edited this page Jun 11, 2013
·
3 revisions
You can extend Datawrapper by creating a new plugin. Our plugin architecture was heavily inspired by the way Wordpress plugins work.
Called by the plugins who want the hook_function to be executed by the core on certain occasions.
Example plugin that hooks into mail sending process:
function mymail($to, $subject, $body, $headers) {
return mail($to, $subject, $body, $headers);
}
DatawrapperHooks::register('send_email', 'mymail');
Called by the core to allow plugins execute their own code. This executes any function that has been registered for a hook.
Example code that sends mail via hook functions:
DatawrapperHooks::execute(
"send_email",
"[email protected]",
"Hello world",
"Hi John, hope you're fine."
);
Allows plugins to register new visualizations. With the first argument the plugin should pass a reference to itself, the second argument is the array that used to be stored in the visualizations meta.json.
DatawrapperVisualization::register($this, array(
"id" => "pie-chart",
"extends" => "raphael-chart"
));