Skip to main content

Modules

Modules are reusable, self contained sections. All assets are packaged with the module. As a consumer, you only need to do is install the module (with composer) and require it in your functions.php, the build system handles the rest.

Prerequisites

  • fx-classes >= v3.3.0
  • wp-blank-scripts >= v1.2.1

Creating a Module

Always use the same naming convention: fx-module-{kebab-case-name}

  1. Create a new directory and copy the files and folder structure from an exisiting module
  2. Update the name in the files with the new module name
  3. Create a repsitory in the Fx Modules project
  4. Setup the repository locally as explained by Bitbucket
  5. Follow the steps for developing a module to test with an exisiting project

Documentation

To enable automatic doc syncing (to the fx-classes website), make sure Bitbucket Pipelines is enabled. The project should already include a bitbucket-pipelines.yml config file.

  1. Enable Pipelines for the repository (Repository Settings > Pipelines > Settings)
  2. Add the fx-module SSH keys (from Ben) (Repository Settings > Pipelines > SSH keys)

Developing a Module

When working locally, you can use the copyFx method to override the module source directory. When enabled, you can develop a module and the changes will be reflected in your project automatically.

You can also use this pattern to work on new modules. Just add the name and path like usual.

// tasks/overrides.js
exports.copyFx = () => {
return {
'fx-module-name': '../../relative/path/to/module',
};
};

See the wp-blank-scripts docs for more information.