Mecha CMS

Mecha CMS blog and documentation.

Dynamic Shortcodes

Updated: Sunday, 07 August 2016

Creating dynamic shortcodes from a file.

You can add more shortcodes dynamically by creating a file named as shortcodes.php, stored in a folder named as workers. This applies to shields and plugins:

Example for shield:

your-shield-name/
 ├── workers/
 │   └── shortcodes.php
 ├── …
 ├── …
 └── …

Example for plugin:

your-plugin-name/
 ├── workers/
 │   └── shortcodes.php
 ├── about.txt
 └── launch.php

The shortcodes.php file only contains array of shortcodes data:

<?php

return array(
    '{{foo}}' => 'bar',
    '{{baz:%s}}' => 'qux $1'
);

The shortcodes data above will be enabled automatically so that you don’t have to tell the users to add such required shortcodes manually from the Shortcodes manager.

Donation and Email Subscription