Action Hooks Reference
Viscribe provides 5 action hooks that fire at key moments during execution.
Lifecycle Hooks
viscribe_services_loaded Since v1.0.0
Fires after all internal services (Encryption, Template Engine, Groq) have been created but before the admin UI and upload handler are initialized.
- Parameters:
(\Viscribe\Plugin $plugin)— The plugin instance. - Source:
Plugin::init()
php
add_action( 'viscribe_services_loaded', function( $plugin ) {
// Services are ready — Pro can hook in here.
} );viscribe_loaded Since v1.0.0
Fires after the plugin is fully initialized and all WordPress hooks are registered.
- Parameters:
(\Viscribe\Plugin $plugin)— The plugin instance. - Source:
Plugin::init()
php
add_action( 'viscribe_loaded', function( $plugin ) {
// Everything is ready — add your features here.
} );API Hooks
viscribe_api_response Since v1.0.0
Fires immediately after a response is received from the Groq API, regardless of success or failure.
- Parameters:
(array|null $decoded, int $code, string $image_path)$decoded— The decoded JSON body, ornull.$code— The HTTP status code (e.g., 200, 401).$image_path— Path to the image that was analyzed.
- Source:
Groq_Service::generate_description()
php
add_action( 'viscribe_api_response', function( $decoded, $code, $image_path ) {
error_log( sprintf( 'Viscribe API: %d for %s', $code, basename( $image_path ) ) );
}, 10, 3 );Processing Hooks
viscribe_image_renamed Since v1.0.0
Fires after an image file has been successfully renamed with the AI-generated name.
- Parameters:
(string $new_filename, string $original_name, string $description, array $file) - Source:
Image_Uploader::process_upload()
php
add_action( 'viscribe_image_renamed', function( $new, $original, $desc, $file ) {
// Log rename events, notify external services, etc.
}, 10, 4 );Admin Hooks
viscribe_register_settings_fields Since v1.0.0
Fires after all core settings fields have been registered. Use this to add custom sections and fields.
- Parameters:
(string $page_slug)— The settings page slug. - Source:
Settings_Page::register_settings()
php
add_action( 'viscribe_register_settings_fields', function( $page_slug ) {
add_settings_field( 'my_field', 'My Field', 'my_field_callback', $page_slug, 'default' );
} );