• Resolved cogmios

    (@cogmios)


    I’m rewriting my plugin to use classes. The core code works fine but the admin class gives me still some errors. one of them is:

    Fatal error: Call to undefined function register_setting() in

    the method i have written is:

    /*
     *	register plugin settings
     */
    function RegisterPluginSettings()
    {
    // WP: http://codex.wordpress.org/Function_Reference/register_setting
    register_setting($this->mPluginSettingsGroup, $this->mStrPluginOptionsName);
    }

    do I need to add a global WP variable in this method? I thought register_setting would be available everywhere?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter cogmios

    (@cogmios)

    well… i dont know if its nice but

    global $new_whitelist_options;
    $new_whitelist_options[ $this->PluginSettingsGroup ][] = $this->mStrPluginOptionsName;

    seems to work 🙂

    Thread Starter cogmios

    (@cogmios)

    now the next…

    Call to undefined function add_options_page

    Thread Starter cogmios

    (@cogmios)

    ok… what global do i have to include to have my classes know about wp functions like register_setting and add_options_page without me copying the core code in the classes?

    Thread Starter cogmios

    (@cogmios)

    require_once(ABSPATH . ‘/wp-admin/includes/plugin.php’);
    require_once(ABSPATH . WPINC . ‘/pluggable.php’);

    seems to help.

    Adding the options page still does not work, i try:

    add_options_page($this->mStrSpecificPluginAdminPageTitle, $this->mStrSpecificPluginAdminMenuTitle, $this->mStrSpecificPluginAdminAccessLevel, $this->mStrSpecificPluginAdminFile,
    'parent::AdminForm');

    I tried ‘self::AdminForm’, ‘$this->AdminForm’ etc… but it is actually in the parent of the class calling add_options_page.

    Thread Starter cogmios

    (@cogmios)

    call_user_func_array() expects parameter 1 to be a valid callback, cannot access parent:: when no class scope is active in

    hmm?

    Thread Starter cogmios

    (@cogmios)

    Using $this when not in object context

    Thread Starter cogmios

    (@cogmios)

    basically… I dont know what function call to add in the “add_options_page” when I’m using classes and methods. They all seem to fail or get a out of scope of class.

    They all seem ot fail.

    I think the method “AdminForm” should work it just displays the form, but somehow I can’t get the thing to work either with self::, this->, parent::, <name_of_class>, <name_of_instance> etc…

    Thread Starter cogmios

    (@cogmios)

    solved: lists.automattic.com/pipermail/wp-hackers/2010-May/031802.html

    thanks andrewnacin.com !

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Fatal error: Call to undefined function register_setting() in’ is closed to new replies.