Tip
Make sure you've read the core concepts before extending the plugin.
Safe Publish provides hooks, filters, and extensibility points to customize its behavior. Whether you need to modify the import process, add custom validation, or integrate with other systems, the plugin offers flexible options for developers.
The plugin provides WordPress actions and filters at key points in the import process:
- Hooks and Filters Reference - Complete list of available hooks
Learn how to enable import support for custom post types:
- Custom Post Type Support - Registering and configuring custom post types
Extend the plugin's REST API capabilities. The REST API surface is intentionally small; most extension points are WordPress hooks and filters.
- REST API Extension - Custom endpoints and authentication
- Control import sanitization — use
safe_publish_import_ksesto enable kses sanitization, andsafe_publish_import_kses_allowed_htmlto customize allowed tags. - Add custom request headers — use
safe_publish_request_argsto inject authentication headers or other HTTP arguments. - Migrate ACF/SCF field values — use
safe_publish_source_post_metato fold the sourceacfobject into imported meta. See Migrating ACF and Secure Custom Fields Values. - Migrate Yoast SEO meta — expose the
_yoast_wpseo_*keys for REST on the source so they enter the coremetaobject. See Migrating Yoast SEO Meta.
See the Hooks and Filters Reference for full parameter documentation and examples.
- Event notifications — use
safe_publish_event_loggedto react to any plugin event (e.g. send a Slack message on failure).
See the Hooks and Filters Reference for full parameter documentation and examples.
Set up a development environment for testing your extensions:
- Local Development Guide - Development environment setup
- Use actions for side effects (notifications, logging).
- Use filters for modifying data (validation, transformation).
- Check hook priority if order matters.
Always handle errors gracefully:
add_filter( 'safe_publish_request_args', function( array $args, string $url ): array {
try {
// Your custom logic
return $args;
} catch ( Exception $e ) {
error_log( 'Safe Publish Extension Error: ' . $e->getMessage() );
return $args; // Return unchanged on error
}
}, 10, 2 );- Avoid expensive operations in filters that run frequently.
- Use caching where appropriate.
- Be mindful of source API calls.
When extending Safe Publish on WordPress VIP:
- Follow VIP coding standards.
- Avoid filesystem writes.
- Use
vip_safe_wp_remote_get()for external requests. - Test thoroughly in VIP environments.
- Hooks Reference - Complete list of actions and filters
- Custom Post Types - Adding post type support
- ACF and SCF Values - Migrating custom field values
- Yoast SEO Meta - Migrating Yoast SEO settings
- REST API - Extending the API
- Troubleshooting - Common issues
- Check the hooks documentation for available extension points.
- Review example code in this guide.
- Report issues or request features via GitHub Issues.