Below is a detailed description of the action hooks and filter hooks available in the Version Info plugin, tailored for advanced developers. Each hook includes its name, purpose, and usage example.

Hooks & Filters

Action Hooks

  1. vi_fs_loaded
  2. Purpose: Fires when the Freemius SDK is fully loaded and initialized.
  3. Usage: Use this hook to safely interact with the Freemius SDK instance for custom license checks or feature gates.
  4. Example:

    ```php add_action( 'vi_fs_loaded', 'check_version_info_license' );

    function check_version_info_license(): void { // Freemius SDK is now available if ( function_exists( 'vi_fs' ) && vi_fs()->is_paying() ) { // Custom logic for paying users } } `` 2. **version_info_version_changed` * Purpose: Fires when a version change is detected for WordPress, PHP, MySQL, a plugin, or a theme. * Usage: Execute custom logic in response to environment changes, such as logging, notifications, or triggering maintenance scripts. * Example**:

    ```php add_action( 'version_info_version_changed', 'log_version_changes' );

    function log_version_changes( array $changes ): void { foreach ( $changes as $change ) { error_log( sprintf( '[Version Info] %s changed from %s to %s at %s', $change['type'], $change['old_version'], $change['new_version'], current_time( 'mysql' ) ) ); } } `` 3. **version_info_before_resource_render` * Purpose: Fires before the System Resources tab content is rendered on the settings page. * Usage: Add custom content or notices above the resource monitoring section. * Example**:

    ```php add_action( 'version_info_before_resource_render', 'add_resource_notice' );

    function add_resource_notice(): void { echo '

    Resource data refreshes every 60 seconds.

    '; } `` 4. **version_info_after_resource_render` * Purpose: Fires after the System Resources tab content is rendered. * Usage: Append custom metrics or additional information below the built-in resource display. * Example**:

    ```php add_action( 'version_info_after_resource_render', 'add_custom_metric' );

    function add_custom_metric(): void { echo '

    Custom Metric

    '; echo '

    Disk Usage: ' . esc_html( disk_free_space( '/' ) ) . ' bytes free

    '; } `` 5. **version_info_render_tab_{$tab_id}** * **Purpose**: Dynamic hook for rendering custom tab content. Replace{$tab_id}` with your tab's slug. * Usage: Register and render entirely custom tabs on the Version Info settings page. * Example:

    ```php // First, add the tab add_filter( 'version_info_settings_tabs', 'add_custom_tab' );

    function add_custom_tab( array $tabs ): array { $tabs['my_custom_tab'] = 'My Custom Tab'; return $tabs; }

    // Then, render its content add_action( 'version_info_render_tab_my_custom_tab', 'render_custom_tab' );

    function render_custom_tab(): void { echo '

    Custom Tab Content

    '; echo '

    This is a custom settings tab.

    '; } ```

Filter Hooks

  1. version_info_footer_details
  2. Purpose: Filters the version string displayed in the admin footer.
  3. Usage: Modify, append to, or completely replace the footer output.
  4. Example:

    ```php add_filter( 'version_info_footer_details', 'append_hostname_to_footer' );

    function append_hostname_to_footer( string $footer ): string { return $footer . ' | Server: ' . gethostname(); } `` 2. **version_info_admin_bar_nodes` * Purpose: Filters the array of admin bar nodes before they are rendered. * Usage: Add, remove, or reorder the version info nodes in the admin bar. * Example**:

    ```php add_filter( 'version_info_admin_bar_nodes', 'add_custom_admin_bar_node' );

    function add_custom_admin_bar_node( array $nodes ): array { $nodes[] = [ 'id' => 'vi-disk-space', 'title' => 'Disk: ' . size_format( disk_free_space( '/' ) ), ]; return $nodes; } `` 3. **version_info_dashboard_widget_items` * Purpose: Filters the array of items displayed in the Dashboard Widget. * Usage: Add custom data points to the dashboard widget. * Example**:

    ```php add_filter( 'version_info_dashboard_widget_items', 'add_widget_item' );

    function add_widget_item( array $items ): array { $items['uptime'] = [ 'label' => 'Server Uptime', 'value' => shell_exec( 'uptime -p' ), ]; return $items; } `` 4. **version_info_wp_version` * Purpose: Filters the WordPress version string before display. * Usage: Append additional context or modify the version format. * Example**:

    ```php add_filter( 'version_info_wp_version', 'annotate_wp_version' );

    function annotate_wp_version( string $version ): string { return $version . ' (Multisite)'; } `` 5. **version_info_php_version` * Purpose: Filters the PHP version string before display. * Example**:

    php add_filter( 'version_info_php_version', function ( string $version ): string { return $version . ' (' . php_sapi_name() . ')'; } ); 6. version_info_mysql_version * Purpose: Filters the MySQL version string before display. * Example:

    php add_filter( 'version_info_mysql_version', function ( string $version ): string { if ( str_contains( $version, 'MariaDB' ) ) { return $version . ' (MariaDB)'; } return $version; } ); 7. version_info_server_software * Purpose: Filters the web server software string before display. * Example:

    php add_filter( 'version_info_server_software', function ( string $server ): string { // Simplify the server string if ( str_contains( $server, 'Apache' ) ) { return 'Apache'; } return $server; } ); 8. version_info_settings_tabs * Purpose: Filters the array of settings page tabs. * Usage: Add custom tabs to the Version Info settings interface. * Example: See the version_info_render_tab_{$tab_id} action hook above for a complete example. 9. version_info_system_export_data * Purpose: Filters the data array before it is encoded as JSON for the System Export download. * Usage: Add custom sections or remove sensitive data from the export. * Example:

    ```php add_filter( 'version_info_system_export_data', 'customize_export' );

    function customize_export( array $data ): array { $data['custom'] = [ 'hosting_provider' => 'Kinsta', 'cdn' => 'Cloudflare', ]; return $data; } `` 10. **version_info_allowed_roles` * Purpose: Filters the array of user roles that can view version information. * Usage: Programmatically grant or restrict access for specific roles. * Example**:

    ```php
    add_filter( 'version_info_allowed_roles', function ( array $roles ): array {
        // Also allow shop managers to see version info
        $roles[] = 'shop_manager';
        return array_unique( $roles );
    } );
    ```
    
    1. version_info_cache_ttl
    2. Purpose: Filters the default cache TTL for CPU and memory resource data.
    3. Default: 60 seconds.
    4. Example:

      php add_filter( 'version_info_cache_ttl', function ( int $seconds ): int { return 120; // Update every 2 minutes } ); 12. version_info_db_cache_ttl * Purpose: Filters the cache TTL for database size data. * Default: 43200 seconds (12 hours). * Example:

      php add_filter( 'version_info_db_cache_ttl', function ( int $seconds ): int { return 3600; // Cache DB size for 1 hour } );


This section provides advanced developers with a detailed understanding of the available hooks and filters in the Version Info plugin. If you need further elaboration on any specific hook or filter, feel free to contact support.