This is the Modern Tribe Extension Template. It allows you to easily extend our plugins: The Events Calendar, Event Tickets, and their associated add-on plugins.
The primary benefits of using this template is that it's gets you up-and-running quicker than building a custom plugin yourself, and it's best to extend one plugin via another plugin instead of adding custom code to your child theme's functions.php
file.
We ensure your new extension does not run if its required base plugin is not activated, which helps avoid fatal errors and means fewer class_exists()
checks are applicable.
Extensions have been available since The Events Calendar version 4.3.3 (November 16, 2016). If you try to use this template to work with versions before this date, your extension will not run at all.
If you want to suggest an edit to this template, submit a pull request to this repo.
- Create your own new repository, prefixing its name with the required
tribe-ext-
prefix (or else your extension will not run at all, even if activated). - Download the
master
branch of this template as a .zip and unzip it. - Because you cannot make a new branch until you have an initial commit to your own new repo's
master
branch, copy this template'slicense.txt
file and commit it to your repo'smaster
branch. - Create a new branch called
initial
orv1
or whatever is appropriate and check out this branch. - Place the remainder of this template's files in your repo's new branch.
- Find and replace these strings throughout all file names and file contents:
- Extension plugin's slug:
tribe-ext-extension-template
[Base Plugin Name] Extension: [Extension Name]
:[Base Plugin Name]
should be something likeThe Events Calendar
[Extension Name]
should be the name of your extension, such asRemove Export Links
[Extension Description]
with your extension plugin's short description.- PHP namespace:
Tribe\Extensions\Example
(must be unique among all extensions)
- Extension plugin's slug:
- Set
Plugin URI
accordingly. - Set
GitHub Plugin URI
accordingly. - Set
Author:
andAuthor URI:
accordingly if not being authored by Modern Tribe. - Set the
== Description ==
section ofreadme.txt
- Add your required plugin(s) via
$this->add_required_plugin()
.- You should have at least one required plugin and/or conditionally-required plugin(s), making use of
Tribe__Dependency
. - If you're requiring a specific version, add a small code comment why this version is required. You should probably also mention this in
readme.txt
.
- You should have at least one required plugin and/or conditionally-required plugin(s), making use of
- Remove the starter bits that don't apply to your extension, such as required PHP version comments.
- Look for
TODO
comments to identify some things to modify or remove, as applicable. For example, remove the entiresrc
directory and theTribe__Autoloader
code if you do not have any settings to add to the admin UI and do not need the autoloader for any other purpose. - It might be advisable to leave the PHP version checking logic (and matching part of readme.txt) unmodified until one of your last commits to ensure you correctly determine the required version.
- Look for
- Add your filters and actions in the
init()
method, creating your custom methods as needed. - Remove all unused/unnecessary code and comments, as this template may handle edge cases that do not apply to your extension.
- Sanitize all input and escape all output, as appropriate.
- Double-check your plugin's slug, name, and descriptions still apply to the end result of what your code actually accomplishes.
- Generate your .pot file by running this WP-CLI command:
wp i18n make-pot . languages/tribe-ext-extension-template.pot --headers='{"Report-Msgid-Bugs-To":"Modern Tribe, Inc. <https://support.theeventscalendar.com/>"}'
- Set the
== Changelog ==
section ofreadme.txt
. - Delete this
README.md
file. - Zip and release your plugin!