$info Existing debug info sections. * @return array */ public function add_debug_info( array $info ): array { $info['webcalendar'] = [ 'label' => __( 'WebCalendar', 'agenticdaisy-calendar' ), 'fields' => $this->get_version_fields(), ]; return $info; } /** * Build the version fields array. * * @return array */ public function get_version_fields(): array { $fields = []; $fields['plugin-version'] = [ 'label' => __( 'Plugin version', 'agenticdaisy-calendar' ), 'value' => defined( 'WEBCALENDAR_WP_VERSION' ) ? WEBCALENDAR_WP_VERSION : __( 'Unknown', 'agenticdaisy-calendar' ), ]; $fields['core-version'] = [ 'label' => __( 'webcalendar-core', 'agenticdaisy-calendar' ), 'value' => self::get_package_version( 'craigk5n/webcalendar-core' ), ]; $fields['icalendar-version'] = [ 'label' => __( 'php-icalendar-core', 'agenticdaisy-calendar' ), 'value' => self::get_package_version( 'craigk5n/php-icalendar-core' ), ]; $fields['php-version'] = [ 'label' => __( 'PHP version', 'agenticdaisy-calendar' ), 'value' => PHP_VERSION, ]; return $fields; } /** * Get the installed version of a Composer package. * * @param string $package Package name (e.g. "craigk5n/webcalendar-core"). */ public static function get_package_version( string $package ): string { if ( ! class_exists( InstalledVersions::class ) ) { return __( 'Unknown', 'agenticdaisy-calendar' ); } if ( ! InstalledVersions::isInstalled( $package ) ) { return __( 'Not installed', 'agenticdaisy-calendar' ); } $version = InstalledVersions::getPrettyVersion( $package ); if ( $version === null ) { return __( 'Unknown', 'agenticdaisy-calendar' ); } // For dev-main, append the short commit ref for clarity. $ref = InstalledVersions::getReference( $package ); if ( str_starts_with( $version, 'dev-' ) && $ref !== null ) { return $version . ' (' . substr( $ref, 0, 7 ) . ')'; } return $version; } }