Support » Plugins » Access Class From Included File?

  • I am developing a custom dictionary plugin and have run into an issue I can’t figure out.

    My main file consists of my class primarily. In the same file, but outside of the class, I create an object from my class to get the ball rolling and also have a couple activation/deactivation hooks registered.

    In my class, using the add_action function with the ‘admin_menu’ hook, I include() an external PHP file that has the display and $POST code for the admin settings page.

    I need to call a function (declared public) that is in the class from my included file but when I do, I receive the following error:

    Fatal error: Call to undefined method MyPlugin::GetDictionary() in C:\xampplite\htdocs\www\WordPress\wp-content\plugins\MyPlugin\myplugin_admin.php on line 63

    NOTE: I’m not really using “MyPlugin” as a name.

    Here is a snippet of the code in my external PHP file:

    	$c_MyPlugin = new MyPlugin;
    	$myplugin_words_array = array();
    	$myplugin_words_array = $c_MyPlugin->GetDictionary();
    	foreach ($myplugin_words_array as $myplugin_result) {
    		$myplugin_word = $myplugin_result['word'];
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Access Class From Included File?’ is closed to new replies.