[wp-hackers] Should I always use reference when calling add_filter?

Ryan Chan ryanchan404 at gmail.com
Sat Apr 21 18:34:47 UTC 2012


It seems with the reference, the code also work

E.g.

http://codex.wordpress.org/Function_Reference/add_filter

Change:

<?php add_filter('media_upload_newtab', array(&$this,
'media_upload_mycallback')); ?>

To:

<?php add_filter('media_upload_newtab', array($this,
'media_upload_mycallback')); ?>

Why I am passing $this as reference if I do not expect it modify the
value of $this? (I suppose it is bad), right?


More information about the wp-hackers mailing list