Do plugin files have to follow a specific convention to be “picked up” by WordPress?

I developed a plugin using the normal convention of naming the main plugin file after the plugin folder (i.e. prefix-someplugin for the folder and prefix-someplugin.php for the file). However, I saw some plugins that use the following structure:

prefix-someplugin
 - plugin-loader.php // This file just loads src/prefix-someplugin.php
 - /src
    - prefix-someplugin.php

Obviously, if they used such structure, it means that it works. The issue is that I’m not sure how it works, hence my question. How does WP know which file to load as the main plugin file? I would have assumed that it looked for a file named after a folder, just adding .php as an extension, but it seems I was wrong.

Read More

Does WPjust scan wp-content/plugins for folders, and loads all the files it finds in them, or does it follow a different logic?

Thanks in advance for the answers.

Related posts

1 comment

  1. WordPress detects a file as plugin when there is a plugin header. So you can store multiple plugins in one directory, and they all will be recognized as different plugins.

    Each file with at least /* Plugin Name: something */ is a plugin.

    The reason is that WordPress scans all PHP files in the main directory of a plugin.

    You can use any name for the plugin file. Avoid non-plugin files in the main directory. They just eat runtime. Put all other PHP files into sub-directories.

Comments are closed.