PHPackages                             bernskioldmedia/wp-plugin-scaffold - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bernskioldmedia/wp-plugin-scaffold

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

bernskioldmedia/wp-plugin-scaffold
==================================

A WordPress plugin scaffold that we use at Bernskiold Media when developing client specific plugins.

1.3.0(1y ago)8602[1 issues](https://github.com/bernskiold/wp-plugin-scaffold/issues)[10 PRs](https://github.com/bernskiold/wp-plugin-scaffold/pulls)GPL-3.0+PHPPHP ^8.0CI failing

Since Nov 13Pushed 1w ago2 watchersCompare

[ Source](https://github.com/bernskiold/wp-plugin-scaffold)[ Packagist](https://packagist.org/packages/bernskioldmedia/wp-plugin-scaffold)[ GitHub Sponsors](https://github.com/:vendor_name)[ RSS](/packages/bernskioldmedia-wp-plugin-scaffold/feed)WikiDiscussions main Synced today

READMEChangelog (5)DependenciesVersions (29)Used By (0)

BM WP Plugin Scaffold
=====================

[](#bm-wp-plugin-scaffold)

This is a simple plugin base for a WordPress plugin that we use at Bernskiold Media when creating custom plugin's for our clients.

This 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 used in every new plugin.

We will add more (or less) to this plugin base as our development needs change.

In general, refer to our WP Plugin Base documentation for help on how to work with the scaffold.

Getting Started
---------------

[](#getting-started)

To get started developing a plugin, it's easiest to use the `bmwp` CLI.

With 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 series of setup questions.

After running it, remove this section from the README and update it to be more specific about the plugin project.

Development How-tos
-------------------

[](#development-how-tos)

### How to add block editor support

[](#how-to-add-block-editor-support)

We often find ourselves having to add block support for a plugin that offers a few additional block editor blocks.

To make this simple, we have abstracted a composer library, (Block Plugin Support)\[\], that contains a Trait with helper functions.

Refer to its documentation on how to add it.

#### Where to place blocks?

[](#where-to-place-blocks)

Block code is expected to be placed in the `blocks/` directory. With a sub-folder for each block.

#### Block Folder Structure

[](#block-folder-structure)

As a general guideline, each block should have the following structure. We prefer splitting into more files for cleanliness and brevity.

```
block.json
index.js
edit.js
icon.js
inspector.js
save.js

```

#### Server-side Rendered Block Base

[](#server-side-rendered-block-base)

For a server-side rendered block, we have a base block class that provides helpful methods. This is provided by the Block Plugin Support library.

This is how a bare block class could look, inheriting methods from the abstract Block class:

```
use BernskioldMedia\WP\Block_Plugin_Support\Block;

class My_Thing_Block extends Block {

	/**
	 * Render the content
	 *
	 * @param  array  $attributes
	 *
	 * @return false|string
	 */
	 public static function render( $attributes ): string {

	 	ob_start();
	 	?>
