class-llms.php

LLMs.txt auto-generation (N8).

Source includes/Compatibility/class-llms.php4 min readPart of Performance Optimisation

includes/Compatibility/class-llms.php

LLMs.txt auto-generation (N8).

Namespace: PerformanceOptimise\\Inc · Lines: 777

Class Llms

LLMs.txt generator and virtual-file router.

Source: includes/Compatibility/class-llms.php, line 26

class Llms

Tags: @since 2.0.0

Constants

ConstantVisibilityValueLine
FILEpublic\'llms.txt\'28
FILE_FULLpublic\'llms-full.txt\'29

publicstatic is_enabled()

public static function is_enabled(): bool

Whether LLMs.txt generation is enabled.

Return: bool.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 37

privatestatic base_dir()

private static function base_dir(): string

Base directory for LLMs files (blog-scoped on multisite).

Return: string.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 55

publicstatic get_file_path()

public static function get_file_path(string=\'llms\' $which): string

Absolute file path for the requested variant.

ParameterTypeDefaultDescription
$whichstring=\'llms\'—\’llms\’ or \’full\’.

Return: string.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 70

publicstatic register_rewrite()

public static function register_rewrite(): void

Register rewrite rules for virtual /llms.txt and /llms-full.txt.

Return: void.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 81

publicstatic add_query_vars()

public static function add_query_vars(array $vars): array

Register query vars for the rewrite rules.

ParameterTypeDefaultDescription
$varsarray—Existing query vars.

Return: array.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 99

publicstatic serve()

public static function serve(): void

Serve the virtual LLMs file on template_redirect.

Return: void.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 113

public static function emit_link_header(): void

Emit Link header for discovery.

Return: void.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 238

public static function emit_head_link(): void

Emit <link> in wp_head.

Return: void.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 259

publicstatic generate()

public static function generate(): bool

Generate llms.txt and llms-full.txt files.

Return: bool — True if files written.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 276

privatestatic cap_content()

private static function cap_content(string $content, int $max_bytes): string

Cap content at word boundary.

ParameterTypeDefaultDescription
$contentstring—Content.
$max_bytesint—Max bytes.

Return: string.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 370

privatestatic normalize_docs_post()

private static function normalize_docs_post($value): ?\\WP_Post

Normalize a WP_Post or numeric post ID for test and runtime callers.

ParameterTypeDefaultDescription
$valuemixed—Candidate post value.

Return: WP_Post|null.

Tags: @since NEXT

Source: includes/Compatibility/class-llms.php, line 389

privatestatic collect_docs_urls()

private static function collect_docs_urls(int=40 $cap): array

Collect the public documentation entry points and first-level pages.

ParameterTypeDefaultDescription
$capint=40—Maximum documentation URLs to return.

Return: string[].

Tags: @since NEXT

Source: includes/Compatibility/class-llms.php, line 411

privatestatic published_docs_url_set()

private static function published_docs_url_set(): array

Return every currently published documentation permalink.

Return: array<string,bool>.

Tags: @since NEXT

Source: includes/Compatibility/class-llms.php, line 498

privatestatic collect_urls()

private static function collect_urls(int=50 $limit, string=\'both\' $source): array

Collect URLs for the generated llms.txt index.

ParameterTypeDefaultDescription
$limitint=50—Maximum URLs.
$sourcestring=\'both\'—Source filter.

Return: string[].

Source: includes/Compatibility/class-llms.php, line 525

privatestatic collect_sitemap_urls()

private static function collect_sitemap_urls(int=50 $cap): array

Collect URLs from sitemap (local only).

ParameterTypeDefaultDescription
$capint=50—Max URLs.

Return: string[].

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 612

privatestatic build_markdown()

private static function build_markdown(array $urls, string $site_name, string $site_desc, string $home_url, bool=false $is_full): string

Build markdown content.

ParameterTypeDefaultDescription
$urlsarray—List of URLs.
$site_namestring—Site name.
$site_descstring—Site description.
$home_urlstring—Home URL.
$is_fullbool=false—Whether full variant.

Return: string.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 708

publicstatic on_settings_update()

public static function on_settings_update($old_value, $new_value): void

React to wppo_settings changes (flush rewrite, regenerate).

ParameterTypeDefaultDescription
$old_valuemixed—Old option value.
$new_valuemixed—New option value.

Return: void.

Tags: @since 2.0.0

Source: includes/Compatibility/class-llms.php, line 744

Hooks

Hooks referenced in includes/Compatibility/class-llms.php:

HookTypeLineNotes
wppo_llms_txt_enabledfilter46@param ×1
wppo_llms_txt_contentfilter313@param ×2
wppo_llms_txt_contentfilter321@param ×2