add_action usually calls the function you pass with at the point where the hook is called.
- ajax, , ? , .
, functions.php, .
, , add_action( 'admin_init', array( $this, 'someFunction' ) ); add_action, , __construct .
, :
class helloWorld
{
function __construct()
{
add_action( 'admin_init', array( $this, 'echoItOut' ) );
}
function echoItOut()
{
echo 'Hello World';
}
}
$helloWorld = new helloWorld;
:
class helloWorld
{
function echoItOut()
{
echo 'Hello World';
}
}
$helloWorld = new helloWorld;
add_action( 'admin_init', array( $helloWorld, 'echoItOut' ) );
:
function echoItOut()
{
echo 'Hello World';
}
add_action( 'admin_init', 'echoItOut' );
, functions.php, , , "Hello World" , ( ).