I'm developing a plugin for wordpress and when I use object orientation to add a button in the post section it gives me the following error:
"Warning: call_user_func_array () expects parameter 1 to be a valid callback, function 'add_media_button' not found or invalid function name in /var/www/jovempan/wp-includes/class-wp-hook.php on line 286 "
NOTE: This error only appears when I use POO
My code:
class PostagensRelacionadas{
public function __construct(){
add_action('media_buttons', 'add_media_button');
}
public function add_media_button() {
$dados = printf( ' <a href="#TB_inline?&width=600&height=550&inlineId=my-content-id" class="button my-button my-custom-button" id="my-custom-button">' . '<span class="wp-media-buttons-icon dashicons dashicons-art"></span> %s' . '</a>', 'Notícias Relacionadas', __( 'Notícias relacionadas', 'textdomain' ) );
}
}
$class = new PostagensRelacionadas();
$class->add_media_button();