[wp-hackers] add_options_page reference method in class?
Andrew Nacin
wp at andrewnacin.com
Thu May 6 20:49:09 UTC 2010
It needs callbacks. Generally, that would look like 'myplugin_adminform'.
For class methods, you need to do array($this, 'adminform').
On Thu, May 6, 2010 at 4:43 PM, Edward de Leau <e at leau.net> wrote:
> I have made an abstract class "EdlWPPluginAdmin" which contains the regular
> plugin admin code.
>
> The method "AdminForm" in there is a basic admin form.
>
> I'm trying to get add_options_page to work to call this method with:
>
> "function AddOptionMenu() {
> add_options_page($this->mStrPluginAdminPageTitle,
> $this->mStrPluginAdminMenuTitle,
> $this->mStrPluginAdminAccessLevel,
> $this->mStrPluginAdminFile,
> '$this->AdminForm');
> }"
>
> now... $this->AdminForm does not work.
>
> It gives me: *Warning*: call_user_func_array() expects parameter 1 to be a
> valid callback, function '$this->AdminForm' not found or invalid function
> name in*C:\temp\xamp\htdocs\wordpress\wp-includes\plugin.php* on line *339*
> *
> *
> I tried several combinations even self::, &$this->, calling it from the
> class the extends the admin class and the php page that instatiantiates the
> class but somehow I cant get this reference to this method to work.
>
> I think it should be something like &$this-> but whatever i try it does not
> work.
>
> Does anyone have a clue?
More information about the wp-hackers
mailing list