{"id":19107820,"url":"https://github.com/alleyinteractive/wp-plugin-loader","last_synced_at":"2025-04-14T05:40:50.270Z","repository":{"id":182891655,"uuid":"669281269","full_name":"alleyinteractive/wp-plugin-loader","owner":"alleyinteractive","description":"Code-enabled WordPress plugin loading.","archived":false,"fork":false,"pushed_at":"2025-03-10T20:15:33.000Z","size":97,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":20,"default_branch":"develop","last_synced_at":"2025-03-12T21:48:23.621Z","etag":null,"topics":["wordpress","wordpress-package","wordpress-php-library"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alleyinteractive.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-21T20:00:37.000Z","updated_at":"2025-03-10T20:01:16.000Z","dependencies_parsed_at":"2024-02-09T19:25:13.381Z","dependency_job_id":"a9d97cd3-f361-4fa7-891d-85d5627985a8","html_url":"https://github.com/alleyinteractive/wp-plugin-loader","commit_stats":null,"previous_names":["alleyinteractive/wp-plugin-loader"],"tags_count":7,"template":false,"template_full_name":"alleyinteractive/create-wordpress-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alleyinteractive%2Fwp-plugin-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alleyinteractive%2Fwp-plugin-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alleyinteractive%2Fwp-plugin-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alleyinteractive%2Fwp-plugin-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alleyinteractive","download_url":"https://codeload.github.com/alleyinteractive/wp-plugin-loader/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248694722,"owners_count":21146947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["wordpress","wordpress-package","wordpress-php-library"],"created_at":"2024-11-09T04:14:04.698Z","updated_at":"2025-04-14T05:40:50.252Z","avatar_url":"https://github.com/alleyinteractive.png","language":"PHP","readme":"# WP Plugin Loader\n\nCode-enabled WordPress plugin loading package.\n\n## Installation\n\nYou can install the package via Composer:\n\n```bash\ncomposer require alleyinteractive/wp-plugin-loader\n```\n\n## Usage\n\nLoad the package via Composer and use it like so:\n\n```php\nuse Alley\\WP\\WP_Plugin_Loader;\n\nnew WP_Plugin_Loader( [\n\t'plugin/plugin.php',\n\t'plugin-name-without-file',\n] );\n```\n\nThe plugin loader will load the specified plugins, be it files or folders under\n`plugins`/`client-mu-plugins`, and mark them as activated on the plugins screen.\nYou can pass files or plugin folders that the package will attempt to determine\nthe main plugin file from and load.\n\nSee [APCu Caching](#apcu-caching) for more information on caching.\n\n### Fluent Loading\n\nThe package supports a fluent API for loading plugins with the `create()` method:\n\n```php\nuse Alley\\WP\\WP_Plugin_Loader;\n\nWP_Plugin_Loader::create()\n\t-\u003eadd( 'plugin/plugin.php' )\n\t-\u003eadd( [\n\t\t'plugin-name-without-file',\n\t\t'another-plugin',\n\t] )\n\t-\u003eload();\n```\n\nYou can also use the `when()` method to conditionally load plugins:\n\n```php\nuse Alley\\WP\\WP_Plugin_Loader;\n\nWP_Plugin_Loader::create()\n\t-\u003eadd( 'plugin/plugin.php' )\n\t-\u003ewhen( fn () =\u003e 'production' !== wp_get_environment_type(), 'logger' )\n\t-\u003eload();\n```\n\nThis pairs nicely with named arguments:\n\n```php\nuse Alley\\WP\\WP_Plugin_Loader;\n\nWP_Plugin_Loader::create()\n\t-\u003eadd( 'plugin/plugin.php' )\n\t-\u003ewhen(\n\t\tcondition: fn () =\u003e 'production' !== wp_get_environment_type(),\n\t\tplugin: 'logger',\n\t)\n\t-\u003eload();\n```\n\nWhen using fluent loading you must call the `load()` method to load the plugins\nat the end of the chain.\n\n### Plugin Directories\n\nOut of the box, the package will attempt to load your plugin from\n`wp-content/plugins`. When it is found, the package will attempt to load your\nplugin from `wp-content/client-mu-plugins`. For non-WordPress VIP sites, the\nplugin will also load plugins from `wp-content/mu-plugins`.\n\n### Preventing Activations\n\nThe package supports preventing activations of plugins via the plugins screen\n(useful to fully lock down the plugins enabled on site):\n\n```php\nuse Alley\\WP\\WP_Plugin_Loader;\n\n( new WP_Plugin_Loader( [ ... ] )-\u003eprevent_activations();\n```\n\nPlugin activations will be prevented on the plugin screen as well as with a\ncapability check.\n\n### APCu Caching\n\nWhen a plugin is loaded by a directory name the package will attempt to\ndetermine the main plugin file from the directory. This can be a semi-expensive\noperation that can be cached with APCu. To enable caching, pass `$cache` to the\nconstructor with a boolean or string prefix:\n\n```php\nuse Alley\\WP\\WP_Plugin_Loader;\n\nnew WP_Plugin_Loader( plugins: [ ... ], cache: true );\n\nnew WP_Plugin_Loader( plugins: [ ... ], cache: 'my-prefix' );\n```\n\nNote: caching will only be enabled if APCu is available.\n\n## Testing\n\nRun `composer test` to run tests against PHPUnit and the PHP code in the plugin.\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Credits\n\nThis project is actively maintained by [Alley\nInteractive](https://github.com/alleyinteractive). Like what you see? [Come work\nwith us](https://alley.com/careers/).\n\n- [Sean Fisher](https://github.com/srtfisher)\n- [All Contributors](../../contributors)\n\n## License\n\nThe GNU General Public License (GPL) license. Please see [License File](LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falleyinteractive%2Fwp-plugin-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falleyinteractive%2Fwp-plugin-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falleyinteractive%2Fwp-plugin-loader/lists"}