vscode-wordpress-hooks
vscode-wordpress-hooks copied to clipboard
Bug: Callback prefix in a class method
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' ] );
}
Thanks, the callback generation in general is quite buggy. I need to revisit it.