WordPress.org

Ready to get started?Download WordPress

Forums

Plugin interoperability (3 posts)

  1. Jonathan Lau
    Member
    Posted 3 years ago #

    What is the best practice to allow Plugin2 to call the functions of Plugin1?

    // PLUGIN_1.PHP ///////////////////
    
    function helloworld($data){
      // saves $data to DB
    }
    // PLUGIN_2.PHP ////////////////////
    
    helloworld('testing!');

    However, plugin_2.php might be called by WordPress first, and this would return an undefined function! I can't use if(function_exists()) because I need to make sure the helloworld() function is called. Any solutions?

  2. gig
    Member
    Posted 3 years ago #

    use if function exists in plugin2

    in plugin 1 check if plugin2 was called already. if not call it manually.

    ighhhh. oh my god, i didnt write this, bit at least it should work ;-)

  3. Jonathan Lau
    Member
    Posted 3 years ago #

    But I don't want to have other functions redeclared twice.

Topic Closed

This topic has been closed to new replies.

About this Topic