I have an issue with my plugin. I run an function if the plugin is activating this function include a file. But if I activate the plugin the file is included twice. Is this normal or an bug in Wordpress? Is there an solution for this?

In the main file I do this

if ( file_exists ( dirname( __FILE__ ) . '/autoload/autoloader.php' ) )
    require_once dirname( __FILE__ ) . '/autoload/autoloader.php';
  • You'll need to share code to get feedback, the description is not enough. – Q Studio Dec 29 '20 at 20:45
  • I added the code what I use in the main file of the plugin. – Jop Dec 29 '20 at 20:49
  • Not sure about the issue you are having here, If you want code to run on plugin activation, check this hook - developer.wordpress.org/reference/functions/… – Q Studio Dec 29 '20 at 20:52
  • An autoloader would normally need to be run on every request. Why does this need to only run once, or only on activation? Also, under what circumstances would this file not exist? Why are you checking for its existence? – Jacob Peattie Dec 30 '20 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.