{"id":19687287,"url":"https://github.com/wppunk/wpplugin","last_synced_at":"2025-07-14T01:02:34.216Z","repository":{"id":42639497,"uuid":"285926996","full_name":"wppunk/WPPlugin","owner":"wppunk","description":"Boilerplate for WordPress plugin using autoload, coding standard, webpack, PHP/JS tests, etc.","archived":false,"fork":false,"pushed_at":"2023-07-07T23:10:59.000Z","size":2483,"stargazers_count":146,"open_issues_count":6,"forks_count":25,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-20T01:04:14.222Z","etag":null,"topics":["autoload","dependency-injection","gh-actions","gh-templates","js-tests","php-tests","phpcs","phpcs-checked","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wppunk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-07T21:52:10.000Z","updated_at":"2025-04-11T05:33:58.000Z","dependencies_parsed_at":"2024-11-16T01:45:25.306Z","dependency_job_id":"ddc1ffde-9bd9-4b86-bb50-6a180a4f7dcd","html_url":"https://github.com/wppunk/WPPlugin","commit_stats":{"total_commits":183,"total_committers":6,"mean_commits":30.5,"dds":"0.060109289617486295","last_synced_commit":"5aae11f2b50d1485b3a79089f5342176c3ef2c07"},"previous_names":[],"tags_count":6,"template":true,"template_full_name":null,"purl":"pkg:github/wppunk/WPPlugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wppunk%2FWPPlugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wppunk%2FWPPlugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wppunk%2FWPPlugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wppunk%2FWPPlugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wppunk","download_url":"https://codeload.github.com/wppunk/WPPlugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wppunk%2FWPPlugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265228860,"owners_count":23731085,"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":["autoload","dependency-injection","gh-actions","gh-templates","js-tests","php-tests","phpcs","phpcs-checked","wordpress"],"created_at":"2024-11-11T18:33:35.055Z","updated_at":"2025-07-14T01:02:33.931Z","avatar_url":"https://github.com/wppunk.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP Plugin\n\n## Get Started\n\nOne-line install:\n```\ncomposer create-project wppunk/wpplugin your-plugin-directory\n```\n\nOr you can copy the archive or clone via Git and then run:\n```\ncomposer init-project\n```\n\n## Requirements\n\nMake sure all dependencies have been installed before moving on:\n\n- WordPress\n- PHP \u003e= 7.2.5 (You can easily downgrade it)\n    - DOM extension\n    - CURL extension\n- Composer\n- Node.js \u003e= 14.8\n- npm\n- ChromeDriver (for acceptance tests)\n\n## Structure\n\n```\nplugins/your-awesome-plugin/        # → Root of your plugin.\n├── .codeception/                   # → Codeception additional directories.\n│   ├── _config/                    # → Configs for DB connection.\n│   ├── _data/                      # → Folder for SQL dump.\n│   └── _support/                   # → Additional classes for the Codeception tests.\n├── .github/                        # → GitHub additional directories.\n│   └── workflows/                  # → Workflows.\n│       ├── plugin-name.conf        # → Config for the server.\n│       └── plugin-name.yml         # → Actions for GitHub.\n├── .tests/                         # → Tests.\n│   └── php                         # → PHP tests.\n│       ├── acceptance              # → PHP Acceptance tests.\n│       ├── unit                    # → PHP Unit tests.\n│       │   └── _bootstrap.php      # → Bootstrap file for PHP unit tests.\n│       ├── acceptance.suite.yml    # → Config file for the acceptance tests.\n│       └── unit.suite.yml          # → Config file for the unit tests.\n├── assets/                         # → Assets directory.\n│   ├── build/                      # → Assets build directory.\n│   └── src/                        # → Assets source directory.\n├── node_modules/                   # → JS packages (never edit).\n├── src/                            # → PHP directory. \n├── templates/                      # → Templates for plugin views.\n├── vendor/                         # → Composer packages (never edit).\n├── vendor_prefixes/                # → Prefixed composer packages for non-conflict mode (never edit).\n├── .codeception.yml                # → Main codeception config.\n├── .env.example                    # → Example for the .env.development and .env.production files\n├── .eslintignore                   # → JS Coding Standards ignore file.\n├── .eslintrc.js                    # → JS Coding Standards config.\n├── .gitconfig                      # → Config for git.\n├── .gitignore                      # → Git ignore file.\n├── .phpcs.xml                      # → Custom PHP Coding Standards.\n├── .scoper.inc.php                 # → Config for the PHP Scoper.\n├── .stylelintrc                    # → Config for the style linter.\n├── .webpack.mix.js                 # → Laravel Mix configuration file.\n├── CHANGELOG.md                    # → Changelog file for GH.\n├── composer.json                   # → Composer dependencies and scripts.\n├── composer.lock                   # → Composer lock file (never edit).\n├── LICENSE                         # → License file.\n├── package.json                    # → JS dependencies and scripts.\n├── package-lock.json               # → Package lock file (never edit).\n├── plugin-name.php                 # → Bootstrap plugin file.\n├── README.md                       # → Readme MD for GitHub repository.\n├── readme.txt                      # → Readme TXT for the wp.org repository.\n└── uninstall.php                   # → Uninstall file.\n```\n\n## Autoload\n\nWe use PSR-4 and composer autoload for PSR-4. You can find it in `composer.json` in directive `autoload`. \n\n## Coding Standards\n\nTo check all coding standards:\n```\nnpm run cs\n```\n\n### PHP Coding Standard (PHPCS)\n\nWe use a custom coding standard based on [WordPress Coding Standard](https://github.com/WordPress/WordPress-Coding-Standards). We disabled rules for the naming of WordPress files for using PSR-4 autoload. Also, we have a [feature](https://github.com/PHPCompatibility/PHPCompatibilityWP), which can allow testing your code using different PHP environments.\n\nCustom PHPCS your can find in the `.phpcs.xml`.\n\nYour can check PHPCS using a CLI:\n```\ncomposer cs\n```\nor\n```\nnpm run cs:php\n``` \n\nPay attention, tests have a bit another coding standards because testing libraries all using camelCase format for methods, function, variables, and properties.\n\nPHPCS checked before each commit, before the push, and in GH Actions.\n\n### JS Coding Standard (JSCS)\n\nWe use a default WordPress JSCS, but you can modify it in the `.eslintrc` file. \n\nYou can check JSCS using a CLI:\n\n```\nnpm run cs:js\n```\n\n### SCSS Coding Standard (SCSSCS)\n\nWe use a default standards for SCSS, but you can modify it in the `.stylelintrc` file.\n\nYou can check SCSSCS using a CLI:\n\n```\nnpm run cs:scss\n```\n\n## Environments\n\nFor any constants you can create the `.env.development` and `.env.production` files. For example, we use these constants from the `.env.example` file for the browserSync inside the Laravel Mix config and for acceptance tests.\n\n## Frontend\n\nAll assets are located in `assets/src/*`.\n\nAll builds are located in `assets/build/*`.\n\nCSS preprocessor is SCSS. \n\nWe use [Laravel Mix](https://laravel-mix.com/) for the assets build. You can modify it in `.webpack.mix.js` file.\n\nFor run Laravel mix you can use the next commands depend on situation:\n```\nnpm run build\nnpm run build:production\nnpm run start\n```\n\n## GitHub\n\n### GH Actions\nAll steps for GH Actions you can find in `.github/workflows/plugin-name.yml` file. Also, for wake up a webserver, we need to add `.github/workflows/plugin-name.conf` \n\n### GH Hooks\n\nJust make you GH repository clear. We use the [Husky](https://github.com/typicode/husky) library to add actions before commit, push, etc. This helps developers make their GH more clear.\n\n### GH Templates\n\nBasic GH templates for better security issues, support requests, bug reports, enhancements, feature requests, pull requests, and contributing templates.\n\n## Dependency injection container\n\nThe lightweight [Dependency Injection](https://github.com/rdlowrey/auryn) component implements a PSR-11 compatible service container that allows you to standardize and centralize the way objects are constructed in your application.\n\nAutomatic load your dependencies using the type hinting.\n\nYou can disable plugin hooks very easily using a DIC. Just get the plugin object from the dependency injection container `$container_builder-\u003eget( PluginName\\Front\\Front::class )`. Example just disabling frontend assets:\n```\nfunction remove_plugin_name_frontend_assets( $injector ) {\n    $front = $injector-\u003emake( PluginName\\Front\\Front::class );\n    if ( ! $front ) {\n        return;\n    }\n    remove_action( 'wp_enqueue_scripts', [ $front, 'enqueue_styles' ] );\n    remove_action( 'wp_enqueue_scripts', [ $front, 'enqueue_scripts' ] );\n}\n\nadd_action( 'plugin_name_init', 'remove_plugin_name_frontend_assets' );\n```\n\n## PHP Scoper\n\nYou need to add prefixes for each outside dependency because other plugins or themes can use the same dependencies, and it can conflict between packages.\n\n```\ncomposer scoper\n```\n\n## Automated testing\n\nWe are using for automated testing a Codeception library runs all types of PHP tests.\n\n### PHP unit tests\n\nFor running use a CLI command:\n```\ncomposer unit\n```\n\n- Main configuration file `.tests/php/unit.suite.yml`\n- Unit tests inside `.tests/php/unit/*` folder.\n- Bootstrap file `.tests/php/unit/_bootstrap.php`\n- Each filename for test class must have a suffix on `*Test.php`.\n- Each test class must extend a `PluginNameUnitTests\\TestCase` class.\n- You can also add some code to `PluginNameUnitTests\\TestCase.php`\n- Each test method must have prefix `test_`\n- Additional files for autoloading in tests running you can add to `.codeception/_support/*` folder.\n\nAlso, unit tests will be checked on a push to repository action and inside the GH Actions pipeline. \n\n### PHP acceptance tests\n\n**Warning!** The acceptance tests make REAL actions on your site. Before running need to create another database and create a `dump.sql` file with fresh WP install.\n\nBefore running, you need to (It needs to make just one time. I hope you can do it):\n1. Install a [ChromeDriver](https://chromedriver.chromium.org/downloads)\n2. Create a new database. For example, I named a database `codeception_db`\n3. Install a clear WordPress\n4. Export database to `dump.sql`\n5. Move a `dump.sql` file to the `.codeception/_data/` folder.\n6. Copy a file `.codeception/_config/params.example.php` to `.codeception/_config/params.local.php`.\n7. Update your connection information to the testing site connection in `.codeception/_config/params.local.php` file. \n8. Update your `wp-config.php` file:\n```php\nif ( \n    isset( $_SERVER['HTTP_X_TESTING'] )\n    || ( isset( $_SERVER['HTTP_USER_AGENT'] ) \u0026\u0026 $_SERVER['HTTP_USER_AGENT'] === 'wp-browser' )\n    || getenv( 'WPBROWSER_HOST_REQUEST' )\n) {\n    // Use the test database if the request comes from a test.\n    define( 'DB_NAME', 'codeception_db' );\n} else {\n    // Else use the default one (insert your local DB name here).\n    define( 'DB_NAME', 'local' );\n}\n```\n\nFor running use a CLI command:\n```\ncomposer acceptance\n```\n\n- Main configuration file `.tests/php/acceptance.suite.yml`\n- Unit tests inside `.tests/php/acceptace/*` folder.\n- Each filename for test class must have a suffix on `*Cest.php`.\n- Each test method must have prefix `test_`\n- Each test method must include `AcceptanceTester` as argument.\n- You can add some methods to AcceptanceTester in `.codeception/_support/AcceptanceTests.php`.\n- Additional files for autoload in tests running you can add to `.codeception/_support/*` folder.\n\n### JS unit tests\n\nFor running use a CLI command:\n```\nnpm run unit\n```\n\n- Main configuration inside `.tests/js/package.json` in directory `jest`\n- Unit tests inside `.tests/js/unit/*` folder.\n- Bootstrap file `.tests/js/setupTests.js`\n- Each filename for test class must have a suffix on `*.test.js`.\n- Just import your class for testing and write tests.\n\nAlso, unit tests will be checked on a push to repository action and inside the GH Actions pipeline.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwppunk%2Fwpplugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwppunk%2Fwpplugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwppunk%2Fwpplugin/lists"}