Extensibility
Overview
MAC Core exposes a small extension surface on purpose. The supported way to extend the plugin is through documented filters and public wrapper functions, not by patching private methods or vendored code.
Use these hooks when you need to:
- add runtime services
- add settings modules
- add admin tabs
- override the SureCart public token
- extend
FormatDatetime
Public Hooks
| Hook | Purpose | Expected shape |
|---|---|---|
mac_core_services | Append runtime services during kernel bootstrap. | array<int, Service> |
mac_core_settings_sections | Add settings modules and fields. | array<string,array<string,mixed>> |
mac_core_admin_tabs | Add admin tabs to the MAC Core screen. | array<string,array{label:string,callback:callable}> |
mac_core_surecart_public_token | Override the SureCart licensing public token. | string |
mac_core_format_datetime_config | Override the default preset and view. | array{default_preset:string,default_view:string} |
mac_core_format_datetime_presets | Add or override datetime presets. | array<string,array<string,mixed>> |
mac_core_format_datetime_views | Add or override datetime views. | array<string,array<string,mixed>> |
Add Runtime Services
Use mac_core_services to append instantiated services that implement the shared Service contract.
<?php
use MacCore\Contracts\Service;
final class MyMacCoreAddon implements Service {
public function register(): void {
add_action( 'init', function (): void {
// Custom runtime behavior.
} );
}
}
add_filter(
'mac_core_services',
function ( array $services ): array {
$services[] = new MyMacCoreAddon();
return $services;
}
);
Recommended use:
- self-contained add-on behavior
- site-level modules that belong beside
MAC Core
Do not use this hook to replace the plugin kernel or remove built-in services.
Add Settings Modules
Use mac_core_settings_sections to add new modules that follow the same schema shape as the built-in sections.
Each module should define:
titledescriptionfields
Each field should define at minimum:
typelabeldescriptiondefault
Example:
Add Admin Tabs
Use mac_core_admin_tabs to append tabs to the existing MAC Core admin page.
Each tab entry must provide:
labelcallback
Example:
<?php
add_filter(
'mac_core_admin_tabs',
function ( array $tabs ): array {
$tabs['example'] = [
'label' => 'Example',
'callback' => static function (): void {
echo '<p>Example admin content.</p>';
},
];
return $tabs;
}
);
Override the Licensing Token
MAC Core ships with a default constant, but the supported override point is the mac_core_surecart_public_token filter.
<?php
add_filter(
'mac_core_surecart_public_token',
function (): string {
return 'pt_your_public_token_here';
}
);
Use this instead of editing the plugin or modifying the vendored SureCart runtime.
Extend FormatDatetime
FormatDatetime exposes three dedicated hooks:
mac_core_format_datetime_configmac_core_format_datetime_presetsmac_core_format_datetime_views
The common pattern is:
- add a preset that maps your field names
- add one or more output views
- optionally change the default preset or view for the site
See Utils / Format Datetime for working examples.
Public vs Internal Surface
Treat these as public:
- the documented hooks above
mac_format_datetime()- the documented global
mac_*utility wrappers
Treat these as internal:
- private methods on services and utilities
- the exact internal service registration order
- vendored SureCart SDK internals
- implementation details not exposed through a documented hook or wrapper