When I add a hook to a class method;
- If I have a namspace,
__NAMESPACE__ is prefixed the callback name:
<?php
declare( strict_types = 1 );
namespace Soderlind\Test;
class Test {
public function __construct() {
add_filter('the_content',__NAMESPACE__ . '\\filter_the_content' );
add_action('init',__NAMESPACE__ . '\\action_init' );
}
.
.
.
}
- If I don't have a namespace:
public function __construct() {
add_filter('the_content','filter_the_content' );
add_action('init','action_init' );
}
In both cases, the correct is
public function __construct() {
add_filter('the_content', [ $this, 'filter_the_content' ] );
add_action('init', [ $this,'action_init' ] );
}
When I add a hook to a class method;
__NAMESPACE__is prefixed the callback name:In both cases, the correct is