Skip to content

PHP Setup

Plugin Header

<?php
/**
* Plugin Name: My WPA Addon
* Description: Custom bookable type for WP Appointments.
* Version: 1.0.0
* Requires Plugins: wpappointments
* Author: Your Name
* Author URI: https://wppoland.com
* License: GPL-2.0-or-later
* Text Domain: my-wpa-addon
*/
declare(strict_types=1);

The Requires Plugins: wpappointments header ensures WordPress checks for the core plugin dependency.

Autoloading

Use Composer PSR-4 autoloading:

{
"autoload": {
"psr-4": {
"MyAddon\\": "src/"
}
}
}

Dependency Check

Always check that WP Appointments is active before using its APIs:

add_action('plugins_loaded', function () {
if (!class_exists('WPAppointments\Plugin')) {
return;
}
// Safe to use WP Appointments APIs here
require_once __DIR__ . '/vendor/autoload.php';
// Register your bookable type, availability layers, etc.
});

Hooks for Extension

HookWhen to Use
initRegister bookable types and availability layers
plugins_loadedCheck dependencies, load autoloader
rest_api_initRegister additional REST endpoints
admin_enqueue_scriptsEnqueue addon admin assets