aboutsummaryrefslogtreecommitdiff
path: root/documentation/examples/hooks/register
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/examples/hooks/register')
-rw-r--r--documentation/examples/hooks/register/advanced.php23
-rw-r--r--documentation/examples/hooks/register/all.php8
-rw-r--r--documentation/examples/hooks/register/basic.php14
-rw-r--r--documentation/examples/hooks/register/basic.php.out0
-rw-r--r--documentation/examples/hooks/register/emit.php6
5 files changed, 51 insertions, 0 deletions
diff --git a/documentation/examples/hooks/register/advanced.php b/documentation/examples/hooks/register/advanced.php
new file mode 100644
index 000000000..48cddd480
--- /dev/null
+++ b/documentation/examples/hooks/register/advanced.php
@@ -0,0 +1,23 @@
+<?php
+
+// the output:page hook is triggered by page_draw().
+register_plugin_hook('output', 'page', 'example_plugin_hook_handler', 600)
+register_plugin_hook('output', 'page', 'example_plugin_hook_handler_2', 601);
+
+function example_plugin_hook_handler($event, $type, $value, $params) {
+ // change A to @
+ $value = str_replace('A', '@', $value);
+
+ return $value
+}
+
+function example_plugin_hook_handler($event, $type, $value, $params) {
+ // change S to $
+ $value = str_replace('S', '$', $value);
+
+ return $value
+}
+
+$content = 'This is some Sample Content.';
+
+page_draw('Title', $content);
diff --git a/documentation/examples/hooks/register/all.php b/documentation/examples/hooks/register/all.php
new file mode 100644
index 000000000..f2e4407a6
--- /dev/null
+++ b/documentation/examples/hooks/register/all.php
@@ -0,0 +1,8 @@
+<?php
+
+register_plugin_hook('all', 'system', 'example_plugin_hook_handler');
+
+// This function will be called for any event of type 'object'
+function example_plugin_hook_handler($hook, $type, $value, $params) {
+ // logic here.
+}
diff --git a/documentation/examples/hooks/register/basic.php b/documentation/examples/hooks/register/basic.php
new file mode 100644
index 000000000..957e82743
--- /dev/null
+++ b/documentation/examples/hooks/register/basic.php
@@ -0,0 +1,14 @@
+<?php
+
+register_plugin_hook('forward', 'system', 'example_plugin_hook_handler');
+
+function example_plugin_hook_handler($event, $type, $value, $params) {
+ var_dump($event);
+ var_dump($type);
+ var_dump($value);
+ var_dump($params):
+
+ return true;
+}
+
+
diff --git a/documentation/examples/hooks/register/basic.php.out b/documentation/examples/hooks/register/basic.php.out
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/documentation/examples/hooks/register/basic.php.out
diff --git a/documentation/examples/hooks/register/emit.php b/documentation/examples/hooks/register/emit.php
new file mode 100644
index 000000000..bcf991794
--- /dev/null
+++ b/documentation/examples/hooks/register/emit.php
@@ -0,0 +1,6 @@
+<?php
+
+register_elgg_event_handler('test', 'example', 'example_init_system_callback');
+
+$params = new ElggObject();
+trigger_elgg_event('test', 'example', $params);