WordPress.org

Ready to get started?Download WordPress

Forums

First plugin (5 posts)

  1. SFMichael
    Member
    Posted 1 year ago #

    Hello,

    currently developing my first plugin.. pretty much done.

    However i would like to include wordpress functions within my plugins do i simply include wp-load.php are is there a better option?

  2. halferdev
    Member
    Posted 1 year ago #

    Your plugin should be called only after that file is included, so you should be able to use WP functions without including anything else. What function specifically do you want to use?

  3. SFMichael
    Member
    Posted 1 year ago #

    trying to use get_blog_list and the likes of is_main_site

  4. bcworkz
    Member
    Posted 1 year ago #

    You really should find a different way than use get_blog_list(). It is depreciated and could disappear from an upgrade at any time. As halferdev said, you should be able to call is_main_site() or any other WP function without including anything because your plugin code is typically hooked into a filter or action. Thus the WP environment is already loaded for the filter or action to fire. Since your code is called from WP, you have access to the functions, objects, etc.

    The one reason to include wp-load.php is if you have a separate file that is requested via a browser link that needs to interface with WP. Since this starts a new process, you would initiate the WP environment by including wp-load.php.

  5. SFMichael
    Member
    Posted 1 year ago #

    Ok thanks for the replies and advice. I'll have another look into it.

    I wasn't aware get_blog_list has been depreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags