Posted By

kreamweb on 09/22/11


Tagged

wordpress addaction addfilter


Versions (?)

wordpress - Call add_filter or add_action inside a class


 / Published in: PHP
 

  1. //call add_filter or add_action inside a class
  2. add_filter('posts_where', array( &$this, 'filter_where' ));
  3.  
  4.  
  5. //example
  6. class IP_Ban {
  7.  
  8. function IP_Ban()
  9. {
  10. $this->__construct();
  11. } // function
  12.  
  13. function __construct()
  14. {
  15. new IP_Ban_Options;
  16.  
  17. add_action( 'admin_init', array( &$this, 'admin_init' ) );
  18. add_action( 'init', array( &$this, 'init' ) );
  19. } // function
  20.  
  21. function admin_init()
  22. {
  23. # perform your code here
  24. } // function
  25.  
  26. function init()
  27. {
  28. # perform your code here
  29. } // function
  30.  
  31. }

Report this snippet  

You need to login to post a comment.