Skip to content

Instantly share code, notes, and snippets.

@manchumahara
Created February 24, 2019 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manchumahara/78701afe68b8c9714ba398137cd7cec2 to your computer and use it in GitHub Desktop.
Save manchumahara/78701afe68b8c9714ba398137cd7cec2 to your computer and use it in GitHub Desktop.
<?php
//action
do_action('tagname');
do_action('tagname2', 'asdasd', 2);
add_action('tagname', 'callback_function');
add_action('tagname2', 'callback_function2', 10, 2);
function callback_function()
{
# code...
}
function callback_function2(a, b)
{
# code...
}
class TestClass{
function __construct(){
add_action('tagname', array($this, 'callback_function'));
add_action('tagname2', array($this, 'callback_function2'), 10, 2);
$t2 = new TestClass2();
add_filter('tagname', array($t2, 'callback_function3'), 10, 3);
}
public function callback_function()
{
# code...
//
}
public function callback_function2(a, b)
{
# code...
}
}
class TestClass2{
public function callback_function3(x, y, x){
x = 2+y*z;
return x;
}
}
$object = new TestClass();
//filter
$a = apply_filders('mytag', 2 , 'b', 10);
//add_filter('mytag', 'callback_function', 10, 3);
function callback_function(x, y, x){
x = 2+y*z;
return x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment