{"id":23129890,"url":"https://github.com/bernskiold/wp-plugin-scaffold","last_synced_at":"2025-08-17T06:32:58.209Z","repository":{"id":39753370,"uuid":"48291759","full_name":"bernskiold/wp-plugin-scaffold","owner":"bernskiold","description":"This is a simple plugin base for a WordPress plugin that we use at Bernskiold Media when creating custom plugin's for our clients.","archived":false,"fork":false,"pushed_at":"2025-02-21T09:44:42.000Z","size":1825,"stargazers_count":7,"open_issues_count":10,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-11T05:48:58.858Z","etag":null,"topics":["wordpress","wordpress-boilerplate","wordpress-development","wordpress-plugin","wordpress-plugin-boilerplate"],"latest_commit_sha":null,"homepage":"https://www.bernskioldmedia.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bernskiold.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"vendor_name"}},"created_at":"2015-12-19T17:54:53.000Z","updated_at":"2025-02-21T09:42:54.000Z","dependencies_parsed_at":"2025-04-09T15:39:09.814Z","dependency_job_id":null,"html_url":"https://github.com/bernskiold/wp-plugin-scaffold","commit_stats":{"total_commits":112,"total_committers":3,"mean_commits":"37.333333333333336","dds":0.1339285714285714,"last_synced_commit":"a195c0f0a4ca2a06a9e51aaa98bde55def855747"},"previous_names":["bernskiold/wp-plugin-scaffold","bernskioldmedia/wp-plugin-scaffold"],"tags_count":5,"template":true,"template_full_name":null,"purl":"pkg:github/bernskiold/wp-plugin-scaffold","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernskiold%2Fwp-plugin-scaffold","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernskiold%2Fwp-plugin-scaffold/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernskiold%2Fwp-plugin-scaffold/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernskiold%2Fwp-plugin-scaffold/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bernskiold","download_url":"https://codeload.github.com/bernskiold/wp-plugin-scaffold/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernskiold%2Fwp-plugin-scaffold/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270816060,"owners_count":24650748,"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-08-17T02:00:09.016Z","response_time":129,"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":["wordpress","wordpress-boilerplate","wordpress-development","wordpress-plugin","wordpress-plugin-boilerplate"],"created_at":"2024-12-17T10:11:24.471Z","updated_at":"2025-08-17T06:32:58.192Z","avatar_url":"https://github.com/bernskiold.png","language":"PHP","funding_links":["https://github.com/sponsors/vendor_name"],"categories":[],"sub_categories":[],"readme":"# BM WP Plugin Scaffold\n\nThis is a simple plugin base for a WordPress plugin that we use at Bernskiold Media when creating custom plugin's for our clients.\n\nThis base is kept extremely simple in order to just facilitate a quick start. The only code bits that we have included are for taxonomies and post types, which are almost always\nused in every new plugin.\n\nWe will add more (or less) to this plugin base as our development needs change.\n\nIn general, refer to our WP Plugin Base documentation for help on how to work with the scaffold.\n\n## Getting Started\n\nTo get started developing a plugin, it's easiest to use the `bmwp` CLI.\n\nWith it installed, place yourself in the plugins folder and run: `bmwp create:plugin plugin-name`, replacing plugin-name with your desired folder name. You will then be asked a\nseries of setup questions.\n\nAfter running it, remove this section from the README and update it to be more specific about the plugin project.\n\n## Development How-tos\n\n### How to add block editor support\n\nWe often find ourselves having to add block support for a plugin that offers a few additional block editor blocks.\n\nTo make this simple, we have abstracted a composer library, (Block Plugin Support)[https://github.com/bernskioldmedia/Block-Plugin-Support], that contains a Trait with helper\nfunctions.\n\nRefer to its documentation on how to add it.\n\n#### Where to place blocks?\n\nBlock code is expected to be placed in the `blocks/` directory. With a sub-folder for each block.\n\n#### Block Folder Structure\n\nAs a general guideline, each block should have the following structure. We prefer splitting into more files for cleanliness and brevity.\n\n```\nblock.json\nindex.js\nedit.js\nicon.js\ninspector.js\nsave.js\n```\n\n#### Server-side Rendered Block Base\n\nFor a server-side rendered block, we have a base block class that provides helpful methods. This is provided by the Block Plugin Support library.\n\nThis is how a bare block class could look, inheriting methods from the abstract Block class:\n\n```\nuse BernskioldMedia\\WP\\Block_Plugin_Support\\Block;\n\nclass My_Thing_Block extends Block {\n\n\t/**\n\t * Render the content\n\t *\n\t * @param  array  $attributes\n\t *\n\t * @return false|string\n\t */\n\t public static function render( $attributes ): string {\n\n\t \tob_start();\n\t \t?\u003e\n\t \t\t\u003c!-- My HTML Output Here --\u003e\n\t \t\u003c?php\n\t \treturn ob_get_clean();\n\n\t }\n\n}\n```\n\nThis file should be placed under: `src/Blocks/My_Thing_Block.php`.\n\n#### Metadata in REST API\n\nIt's helpful to make our ACF and other metadata available in the REST API. For this we have a series of helper methods that hook into the REST API to handle returning and updating\nmetadata.\n\nYou need to do two things:\n\n1. Connect the data store to the data class, by referecing the data class. `protected static $data_class = Namespace\\MyObject::class`.\n2. Set up an array of metadata to make available in the `public static $metadata = []` array. These should be the same keys as used by the getters/setters in the data class. For\n   example, if you have a `get_name()` method in the data class, add `name` to the metadata array.\n\n#### Modifying the default WP_Query for archive/listings.\n\nBy adding the method `public static query_modifications( \\WP_Query $query ): \\WP_Query` to the data store class, it will automatically be hooked in to `pre_get_posts`, allowing you\nto modify the main query for the data store easily.\n\nThis can be useful for example to set a specific sort order for the data store data.\n\nUse the function below here for a quick-start example:\n\n```\n/**\n * Modify the query.\n *\n * @param  \\WP_Query  $query\n *\n * @return \\WP_Query\n */\npublic static function query_modifications( \\WP_Query $query ) {\n\n\tif ( is_admin() \u0026\u0026 ! $query-\u003eis_main_query() ) {\n\t\treturn $query;\n\t}\n\n\tif ( $query-\u003eget( 'post_type' ) !== static::get_key() ) {\n\t\treturn $query;\n\t}\n\n\t// $query-\u003eset( 'prop', 'value' );\n\n\treturn $query;\n\n}\n```\n\n#### Setting Capabilities\n\nBy default, the data store will have a common-sense default permission structure. The abstract `Custom_Post_Type` and `Taxonomy` classes house the default settings.\n\nYou may override by setting a similarily structured `role =\u003e permissions` array on the `::$permissions` property. Anything in the permissions property will override the default\npermissions set by `::$default_permissions`.\n\nYou can load the capabilities array for the register function by calling `self::get_capabilities()`.\n\n## Coding Style\n\nWe exclusively try and use the WordPress coding practices for all languages, which includes PHP, HTML, CSS and JavaScript.\n\nThis base plugin is in part OOP based to both live in its own namespace, and to make extending, updating and maintaining code simple and easy.\n\n## Open Source\n\nThe reason we are open sourcing it is because it's the right thing to do. Perhaps someone finds a use out of it all, or parts. This is not going to be an actively developed \"master\nplugin base\" that is set out to be the next greatest thing in the WordPress community. It's just going to be what we use internally, just published for the world to see and use as\nyou see fit.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbernskiold%2Fwp-plugin-scaffold","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbernskiold%2Fwp-plugin-scaffold","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbernskiold%2Fwp-plugin-scaffold/lists"}