Skip to content
Daniel M. Hendricks edited this page Aug 26, 2017 · 21 revisions

Welcome to the wiki page for wordpress-base-plugin.

More documentation will be added as the plugin evolves.

Dependencies

Carbon Fields

This plugin uses Carbon Fields to handle custom fields and plugin settings. In order for it to work, you will either need to add it as a Composer dependency or install a compatible Carbon Fields Loader plugin.

Loader Plugin

To avoid conflicts caused by multiple versions of Carbon Fields being loaded, it is recommended that you use a Carbon Fields Loader plugin.

Simply clone/download it to your plugins folder an activate.

Composer Dependency

Alternatively, you may also load Carbon Fields as a Composer dependency.

  1. Add "htmlburger/carbon-fields": "^2.0.0", to the require section of composer.json.
  2. Run composer update.
  3. This plugin also uses TGMPA to show a notice when the Carbon Fields Loader is not detected. You can remove this check by commenting out the TGMPA line in app/Plugin.php or by modifying app/TGMPA.php to exclude it as a requirement.

Getting Started

Once you have cloned/downloaded the base plugin, follow these steps to make it your own.

Install Node Modules

Change to the directory where the plugin is located and run the following to install NPM dependencies:

npm install

Rename Files and Strings

  1. Edit the package.json file. In the config section, change the slug from "wordpress-base-plugin" to your own (if you're not sure, set it to what you intend to name the plugin directory).
  2. Change the namespace from "VendorName\\PluginName" to your own namespace.
  3. Change the javascript_object from WPBP_NS to something unique to your plugin.
  4. Save the file.

At the command prompt, run:

npm run rename

This will replace the namespaces, slugs and filenames to your new strings.

Finally, open composer.json and change the autoload psr-4 namespace from "VendorName\\PluginName\\" to your own namespace, paying attention to the double backslashes. Save changes.

Install Composer Dependencies

Important: See Dependencies for important information about Carbon Fields. If you are not going to usae the Carbon Fields Loader, you must add Carbon Fields as a dependency to your composer.json file first.

To install Composer dependencies, run:

composer install

Other Changes

Edit the following files and change the names, descriptions, versions, etc as necessary:

  • composer.json
  • package.json
  • plugin.json
  • readme.txt
  • The main plugin PHP file in the plugin root directory (initially wordpress-base-plugin.php before running the npm run rename command.

Gulp

Gulp is used to automatic SASS & JavaScript processing. If you do not already have Gulp installed, see here.

Assuming that you have already run npm install, the gulpfile.js will monitor changes in your SASS/JavaScript files in ./src and compiled them into the ./assets directory. To have Gulp watch your file changes, run the following from your plugin directory:

gulp

Note: It is required that you run Gulp in order to have the "Clear Cache" link from the admin bar dropdown example work. If you do not, you will receive 404 console errors that the enqueued scripts are not found.

Translation

Translation language files can be created automatically using wp-pot-cli.

Assuming the you have already run npm install, you can run the following command to create a translation file in the languages directory:

npm run translate
Clone this wiki locally