{"id":19144375,"url":"https://github.com/piotrpress/wordpress-plugin","last_synced_at":"2026-02-13T00:38:29.026Z","repository":{"id":57041813,"uuid":"432004855","full_name":"PiotrPress/wordpress-plugin","owner":"PiotrPress","description":"This library is WordPress plugin singleton base class with methods to get data from plugin's header fields.","archived":false,"fork":false,"pushed_at":"2024-09-15T22:00:13.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-14T14:27:44.960Z","etag":null,"topics":["php","plugin","plugins","wordpress","wordpress-pl","wordpress-plugin","wordpress-plugin-boilerplate","wordpress-plugin-development","wordpress-plugin-framework","wordpress-plugin-library","wordpress-plugin-starter","wordpress-plugin-template","wordpress-plugins"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PiotrPress.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","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":"2021-11-25T23:51:00.000Z","updated_at":"2024-09-15T22:00:01.000Z","dependencies_parsed_at":"2024-11-09T07:36:24.829Z","dependency_job_id":"ed6bd2bb-6d4e-4c6c-ac9a-f2fae44e8a69","html_url":"https://github.com/PiotrPress/wordpress-plugin","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"1775b1d38319fd564fc4aca7e251394a76aa973b"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/PiotrPress/wordpress-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Fwordpress-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Fwordpress-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Fwordpress-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Fwordpress-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PiotrPress","download_url":"https://codeload.github.com/PiotrPress/wordpress-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiotrPress%2Fwordpress-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274568349,"owners_count":25309281,"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","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["php","plugin","plugins","wordpress","wordpress-pl","wordpress-plugin","wordpress-plugin-boilerplate","wordpress-plugin-development","wordpress-plugin-framework","wordpress-plugin-library","wordpress-plugin-starter","wordpress-plugin-template","wordpress-plugins"],"created_at":"2024-11-09T07:34:41.805Z","updated_at":"2026-02-13T00:38:28.582Z","avatar_url":"https://github.com/PiotrPress.png","language":"PHP","readme":"# WordPress Plugin\n\nThis library is WordPress plugin singleton base class with methods to get data from [plugin's header fields](https://developer.wordpress.org/plugins/plugin-basics/header-requirements/). \n\n## Installation\n\n```console\ncomposer require piotrpress/wordpress-plugin\n```\n\n## Usage\n\n```php\n/**\n * Plugin Name:       Example Plugin\n * Plugin URI:        https://example.com/plugin/\n * Description:       Example Plugin description.\n * Version:           1.0.0\n * Requires at least: 6.2.2\n * Requires PHP:      7.4\n * Author:            John Smith\n * Author URI:        https://example.com/plugin/author/\n * License:           GPL v3 or later\n * License URI:       https://www.gnu.org/licenses/gpl-3.0.txt\n * Update URI:        https://example.com/plugin/update/\n * Text Domain:       example-plugin\n * Domain Path:       /languages\n */\n\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse PiotrPress\\WordPress\\Plugin;\n\nclass Example extends Plugin {\n    public function activation() : void {}\n    public function deactivation() : void {}\n}\n\nExample::getInstance( __FILE__ );\n\necho Example::getName();\n```\n\n**NOTE:** Plugin's translations are loaded automatically according to `Text Domain` and `Domain Path` plugin's header fields. \n\n## Methods\n\n### Basic static methods handling plugin's default header fields\n\n* `getName()` - returns `string` with the name of the plugin from `Plugin Name` header field\n* `getPluginURI()` - returns `string` with the home page of the plugin or empty `string` if `Plugin URI` header field is not set\n* `getVersion()` - returns `string` with the current version number of the plugin or empty `string` if `Version` header field is not set\n* `getDescription()` - returns `string` with a short description of the plugin or empty `string` if `Description` header field is not set\n* `getAuthor()` - returns `string` with the name of the plugin author or empty `string` if `Author` header field is not set\n* `getAuthorURI()` - returns `string` with the website of the plugin's author or empty `string` if `Author URI` header field is not set\n* `getTextDomain()` - returns `string` with the gettext text domain of the plugin or directory name of the plugin if `Text Domain` header field is not set\n* `getDomainPath()` - returns `string` with the path to translations directory or empty `string` if `Domain Path` header field is not set\n* `getNetwork()` - returns `bool` whether the plugin can only be activated network-wide according to `Network` header field\n* `getRequiresWP()` - returns `string` with the lowest WordPress version that the plugin will work on or empty `string` if `Requires at least` header field is not set\n* `getRequiresPHP()` - returns `string` with the minimum required PHP version or empty `string` if `Requires PHP` header field is not set\n* `getUpdateURI()` - returns `string` with third-party plugin's update server or empty `string` if `Update URI` header field is not set\n* `RequiresPlugins()` - returns `string` with the comma-separated list of WordPress.org-formatted slugs for its dependencies or empty `string` if `Requires Plugins` header field is not set\n\n### Additional static methods handling plugin's paths\n\n* `getSlug()` - returns `string` with the sanitized name of the plugin\n* `getPrefix()` - returns `string` with the prefix for plugin's hooks\n* `getFile()` - returns `string` with the path to main plugin's file\n* `getDir()` - returns `string` with the path to plugin's directory\n* `getUrl()` - returns `string` with the url to plugin's directory\n* `getBaseName()` - returns `string` with the basename of the plugin\n* `getDirName()` - returns `string` with the directory name of the plugin\n\n### Inherited Singleton's static methods\n\n* `getInstance()` - returns the instance of the Plugin class\n\n### Abstract methods handling plugin's de/activation \n\n* `activation()` - executed while plugin activation\n* `deactivation()` - executed while plugin deactivation\n\n### Handling custom plugin's header fields\n\n1. Add WordPress support for extra plugin's header fields using `extra_plugin_headers` filter:\n\n```php\nadd_filter( 'extra_plugin_headers', function () {\n    return [ 'License', 'License URI' ];\n} );\n```\n\n2. Add methods to handle extra plugin's header fields:\n\n```php\nclass Example extends Plugin {\n    public static function getLicenseURI() {\n        return self::get( 'License URI' );\n    }\n}\n```\n\n**NOTE:** `get` prefixed methods are automagically created for plugin's header fields that meet valid function name rules. e.g. `getLicense()` method.\n\n## Requirements\n\nPHP \u003e= `7.4` version.\n\n## License\n\n[GPL 3.0](license.txt)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrpress%2Fwordpress-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiotrpress%2Fwordpress-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrpress%2Fwordpress-plugin/lists"}