Developer Guide
Hooks, filters, and the PHP API — for the person who opened functions.php on purpose.
There is no WP-CLI command. Use PHP in a must-use plugin, theme
functions.php, or your own plugin. If you arrived here from the User
Guide looking for a button: there isn’t one, and that is intentional.
Filters vs actions
Filters change data Tivlo is about to use. Actions fire after a write, delete, enqueue, or serve so you can side-effect (purge a proxy, log, ping a deploy). Filters = rewrite the recipe. Actions = “the cake is out of the oven, now tell the CDN.”
Programmatic API
// Enqueue one URL (priority: lower number = sooner)
Tivlo_SSG_Queue::enqueue( home_url( '/about/' ), 1 );
// Enqueue full site (false = do not clear existing files first)
Tivlo_SSG_Generator::enqueue_full_rebuild( false );
// Process a batch now
Tivlo_SSG_Generator::process_queue();
// Rebuild one URL synchronously
$result = Tivlo_SSG_Generator::rebuild_url( home_url( '/' ) );Add custom URLs to every full rebuild
add_filter( 'tivlo_ssg_all_urls', function ( $urls ) {
$urls[] = home_url( '/custom-landing/' );
return array_unique( $urls );
} );tivlo_ssg_grouped_urls receives the same URLs in buckets (front_page,
posts_page, content, archives, taxonomies, dates, authors,
not_found). tivlo_ssg_related_urls adjusts the incremental set for a
post ID.
Change output directory
add_filter( 'tivlo_ssg_static_dir', function () {
return WP_CONTENT_DIR . '/cache/tivlo-static';
} );
add_filter( 'tivlo_ssg_static_url', function () {
return content_url( '/cache/tivlo-static/' );
} );Ensure the directory is writable. Recreate or clear via the admin after changing it.
Generation HTTP
add_filter( 'tivlo_ssg_fetch_args', function ( $args, $url ) {
$args['timeout'] = 60;
return $args;
}, 10, 2 );
add_filter( 'tivlo_ssg_sslverify', function () {
return true; // default is false (local-friendly)
} );HTML after fetch and after optimize
add_filter( 'tivlo_ssg_html', function ( $html, $url ) {
return $html;
}, 10, 2 );
add_filter( 'tivlo_ssg_optimized_html', function ( $html, $url ) {
return $html;
}, 10, 2 );Serving
add_filter( 'tivlo_ssg_should_serve', function ( $serve ) {
return $serve;
} );
add_filter( 'tivlo_ssg_serve_path', function ( $path, $url ) {
return $path;
}, 10, 2 );
add_filter( 'tivlo_ssg_serve_not_found_path', function ( $path ) {
return $path;
} );
add_filter( 'tivlo_ssg_dynamic_cookie_prefixes', function ( $prefixes ) {
$prefixes[] = 'my_session_';
return $prefixes;
} );Exportable types and hard exclusions
add_filter( 'tivlo_ssg_exportable_post_types', function ( $types ) {
return $types;
} );
add_filter( 'tivlo_ssg_hard_excluded_post_ids', function ( $ids ) {
$ids[] = 123; // never export this page
return $ids;
} );Also available: tivlo_ssg_exportable_taxonomies,
tivlo_ssg_archive_capable_post_types, tivlo_ssg_hard_excluded_pages,
tivlo_ssg_exclude_patterns, tivlo_ssg_public_base_url,
tivlo_ssg_site_folder_slug.
Actions
| Action | When |
|---|---|
tivlo_ssg_url_rebuilt | After HTML is written ($url, $path) |
tivlo_ssg_url_removed | After a static file is deleted ($url) |
tivlo_ssg_urls_enqueued | After URLs are added to the queue ($urls) |
tivlo_ssg_before_serve | Just before the file is sent ($path) |
tivlo_ssg_cache_invalidated | After ETag/cache version bump ($version) |
add_action( 'tivlo_ssg_url_rebuilt', function ( $url, $path ) {
// e.g. notify an external purge
}, 10, 2 );Use filters to add URLs, move the output directory, tweak HTTP, reshape HTML, or skip serving for a request.
How is this guide?