I just pee my feet in Wordpress, and I'm trying to write a very simple plugin using OOP methods. I follow this guide: http://www.yaconiello.com/blog/how-to-write-wordpress-plugin/ . So far, I feel like I understand most of what is happening, but I'm a little puzzled by statements like this:
add_action('init', array(&$this, 'init'));
After reading the Wordpress documentation add_action () and PHP, I think the second argument is the class instance method. But I do not understand why it $thisshould be passed by reference .
This note was discovered in PHP docs about calling messages that I suspect might have something to do with it, but it's still hard for me to turn my head around, what is the difference:
Note. In PHP 4, you had to use a link to create a callback pointing to the actual object, not a copy of it. For more information, see the Links section.
If I have PHP 5, am I just using array($this,'init')?
Perhaps related: add_action in Wordpress using OOP?
source
share