Guest User

Untitled

a guest
Oct 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. class MyClass {
  2. function __construct() {
  3. add_action( 'init',array( $this, 'getStuffDone' ) );
  4. }
  5. function getStuffDone() {
  6. // .. This is where stuff gets done ..
  7. }
  8. }
  9. $var = new MyClass();
  10.  
  11. namespace NS{
  12. class MyClass {
  13. public function __construct() {
  14. add_action( 'init',array( $this, 'getStuffDone' ) );
  15. }
  16. public function getStuffDone() {
  17. // .. This is where stuff gets done ..
  18. }
  19. }
  20. }
  21.  
  22. $var = new MyClass();
  23.  
  24. add_action('init',function(){
  25. $lat = new NSClassopac();
  26. $lath->getStuffDone();
  27. });
  28.  
  29. class MyClass {
  30. public function __construct() {
  31. }
  32.  
  33. public function hooks() {
  34. add_action( 'admin_init', array( $this, 'doAdminTest' ) );
  35. add_action( 'init', array( $this, 'doGeneralTest' ) );
  36. }
  37.  
  38. public function doAdminTest() {
  39. die( 'We are in the admin area.' );
  40. }
  41.  
  42. public function doGeneralTest() {
  43. die( 'We are in the init hook.' );
  44. }
  45. }
  46.  
  47. $var = new MyClass();
  48.  
  49. add_action( 'plugins_loaded', array( $var, 'hooks' ) );
Add Comment
Please, Sign In to add comment