build_full() : $this->build_index(); status_header( 200 ); header( 'Content-Type: text/plain; charset=utf-8' ); header( 'X-Robots-Tag: noindex' ); echo $body; // phpcs:ignore WordPress.Security.EscapeOutput -- plain text endpoint, content built internally. exit; } private function included_post_types() { $types = get_option( 'atba_post_types', array( 'post', 'page' ) ); return apply_filters( 'atba_post_types', (array) $types ); } private function build_index() { $cached = get_transient( 'atba_llms_index' ); if ( false !== $cached ) { return $cached; } $out = '# ' . get_bloginfo( 'name' ) . "\n\n"; $desc = get_option( 'atba_site_summary', get_bloginfo( 'description' ) ); if ( $desc ) { $out .= '> ' . wp_strip_all_tags( $desc ) . "\n\n"; } foreach ( $this->included_post_types() as $type ) { $obj = get_post_type_object( $type ); if ( ! $obj ) { continue; } $posts = get_posts( array( 'post_type' => $type, 'post_status' => 'publish', 'posts_per_page' => (int) apply_filters( 'atba_index_limit', 200 ), 'orderby' => 'modified', 'order' => 'DESC', ) ); if ( ! $posts ) { continue; } $out .= '## ' . $obj->labels->name . "\n\n"; foreach ( $posts as $p ) { $excerpt = $p->post_excerpt ? $p->post_excerpt : wp_trim_words( wp_strip_all_tags( $p->post_content ), 25, '' ); $out .= sprintf( "- [%s](%s): %s\n", $p->post_title, get_permalink( $p ), trim( $excerpt ) ); } $out .= "\n"; } $out .= "## Sitemaps\n\n- [XML Sitemap](" . home_url( '/sitemap.xml' ) . ")\n"; set_transient( 'atba_llms_index', $out, DAY_IN_SECONDS ); return $out; } private function build_full() { $cached = get_transient( 'atba_llms_full' ); if ( false !== $cached ) { return $cached; } $out = '# ' . get_bloginfo( 'name' ) . " — full content\n\n"; foreach ( $this->included_post_types() as $type ) { $posts = get_posts( array( 'post_type' => $type, 'post_status' => 'publish', 'posts_per_page' => (int) apply_filters( 'atba_full_limit', 100 ), 'orderby' => 'modified', 'order' => 'DESC', ) ); foreach ( $posts as $p ) { $out .= '## ' . $p->post_title . "\n"; $out .= 'URL: ' . get_permalink( $p ) . "\n"; $out .= 'Updated: ' . get_the_modified_date( 'Y-m-d', $p ) . "\n\n"; $out .= trim( wp_strip_all_tags( strip_shortcodes( $p->post_content ) ) ) . "\n\n---\n\n"; } } set_transient( 'atba_llms_full', $out, DAY_IN_SECONDS ); return $out; } }