1

By seeing the wordpress core I understand that plugin.php is being loaded way before plugins are loaded. But yet some plugins are loading it again. Any advantage of reloading the plugin.php?

And does'nt PHP through errors for including the same file with function definitions?

2 Answers 2

0

Some plugins use files that are called externally without beeing loaded by WordPress. By including some files from WordPress (wp-includes/plugin.php) is often among them they can then "load" up WordPress to do some WP-related stuff.

One example would be plugins that post some data from forms through their own files instead of the standard WordPress way.

I don't want to vote for the strategy being good or not but I would at least have a closer look if possible or surf the Web for information if they are probably doing nasty stuff with that.

0

If any plugin depends on the functions available in plugin.php file then to ensure that file is loaded before the plugin loads normally, developers use require_once() to make that file available.

Calling require_once()/include_once() multiple times does not throw errors because the file is already loaded. Since the file is loaded it ignores the next call or if not available then includes that file.

1
  • Wordpress will load that file anyway, So are they preparing the plugin for people who actually modified the core ? Because in one plugin, they are simply loading the plugin.php file without being attached to any actions or filters. Commented Jul 31, 2016 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.