WordPress.org

Ready to get started?Download WordPress

Forums

Access Class From Included File? (2 posts)

  1. cillosis
    Member
    Posted 2 years ago #

    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:

    <?php
    
    	//VARIABLES
    	//****************
    	$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'];
    
    	}
    
    ?>
  2. cillosis
    Member
    Posted 2 years ago #

    Any ideas? If I need to clarify my question just let me know.

Topic Closed

This topic has been closed to new replies.

About this Topic