I have to pass function $MyClass->MyStyle as parameter to add_action() but don’t know how to do it. I have tried:
<?php
add_action( 'admin_menu', $MyClass->MyStyle );
add_action( 'admin_menu', " . $MyClass->MyStyle . " );
add_action( 'admin_menu', "$MyClass->MyStyle" );
?>
but none works.
What is the right syntax to do it?
Thanks in advance
Here is an example:
UPDATED:
I was checking the documentation for the syntax and here it is:
“The function must be referenced in one of two ways:
if the function is a member of a class within the plugin it should be referenced as
array( $this, 'function_name' )if the class is instantiated as an object or array( CLASS, ‘function_name’ ) if its called statically.
In all other cases, using the function name itself is sufficient