(Background: I’m trying to automate the setup of some WP blogs by writing directly to the active_plugins
row in wp_options
, and I’m having an issue in determining the primary PHP file for some plugins.)
The main PHP file for most plugins is simply the name of the stub, with .php
appended; for example, plugin-name/plugin-name.php
.
However that’s not the case for all plugins. WP Super Cache for example has the following structure:
wp-super-cache
├── Changelog.txt
├── advanced-cache.php
├── languages
├── ossdl-cdn.php
├── plugins
├── readme.txt
├── wp-cache-base.php
├── wp-cache-config-sample.php
├── wp-cache-phase1.php
├── wp-cache-phase2.php
├── wp-cache.php
└── wp-super-cache.pot
If you go look in the Plugin admin panel, this plugin can be activated with the following link:
'http://localhost/testing/wp-admin/plugins.php?action=activate&plugin=wp-super-cache%2Fwp-cache.php&plugin_status=all&paged=1&s&_wpnonce=cbc0e620a3'
/* Note how WP has determined: plugin=wp-super-cache/wp-cache.php */
My question is, how does WP determine which PHP file in a plugin directory is the main PHP file?
Or in other words, if I wanted to manually update the active_plugins
option_value
in the wp_options
table, how would I know what PHP file to reference?
I’ve tried to figure this out by digging through the code, but it’s very convoluted and I’m getting lost. I thought WP might look at the first X lines of every file to find the one with the banner info (Author, Plugin Name etc…) but that seems very awkward.