Actualizacion 7.1.2
This commit is contained in:
@@ -152,26 +152,29 @@ class LLMS_Txt {
|
||||
* @return void
|
||||
*/
|
||||
private function add_header_content() {
|
||||
$site_title = Helper::get_settings( 'titles.knowledgegraph_name', get_bloginfo( 'name' ) );
|
||||
$site_desc = Helper::get_settings( 'titles.organization_description', get_bloginfo( 'description' ) );
|
||||
$site_title .= $site_desc ? ': ' . $site_desc : '';
|
||||
|
||||
if ( ! $this->do_filter( 'llms_txt/remove_credit', false ) ) {
|
||||
$this->output_line( 'Generated by Rank Math SEO, this is an llms.txt file designed to help LLMs better understand and index this website.' );
|
||||
$this->output_line( '' );
|
||||
}
|
||||
|
||||
$this->output_line( '# ' . esc_html( $site_title ) );
|
||||
$site_title = $this->format_text( Helper::get_settings( 'titles.knowledgegraph_name', get_bloginfo( 'name' ) ) );
|
||||
$summary = $this->format_text( Helper::replace_vars( Helper::get_settings( 'general.llms_summary', '' ) ) );
|
||||
|
||||
$this->output_line( '# ' . $site_title );
|
||||
$this->output_line( '' );
|
||||
|
||||
if ( $summary ) {
|
||||
$this->output_line( '> ' . $summary );
|
||||
$this->output_line( '' );
|
||||
}
|
||||
|
||||
if ( ! Helper::is_module_active( 'sitemap' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->output_line( '' );
|
||||
$sitemap_url = Router::get_base_url( Sitemap::get_sitemap_index_slug() . '.xml' );
|
||||
$this->output_line( '## Sitemaps' );
|
||||
$this->output_line( '[XML Sitemap](' . esc_url( $sitemap_url ) . '): Includes all crawlable and indexable pages.' );
|
||||
// Add an extra blank line after the header content.
|
||||
$this->output_line( '- [XML Sitemap](' . esc_url_raw( $sitemap_url ) . '): Includes all crawlable and indexable pages.' );
|
||||
$this->output_line( '' );
|
||||
}
|
||||
|
||||
@@ -219,16 +222,16 @@ class LLMS_Txt {
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = get_post_type_object( $post_type )->labels->name;
|
||||
$this->output_line( '## ' . esc_html( $label ) );
|
||||
$label = $this->format_text( get_post_type_object( $post_type )->labels->name );
|
||||
$this->output_line( '## ' . $label );
|
||||
|
||||
foreach ( $posts as $object ) {
|
||||
if ( ! Helper::is_post_indexable( $object ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = get_the_title( $object );
|
||||
$link = get_permalink( $object );
|
||||
$title = $this->format_text( get_the_title( $object ) );
|
||||
$link = esc_url_raw( get_permalink( $object ) );
|
||||
$object->post_content = do_shortcode( $object->post_content );
|
||||
$desc = Helper::replace_vars( '%excerpt%', $object );
|
||||
|
||||
@@ -240,12 +243,12 @@ class LLMS_Txt {
|
||||
* @param \WP_Post $object The post object.
|
||||
* @return string Modified description.
|
||||
*/
|
||||
$desc = wp_strip_all_tags( $this->do_filter( 'llms_txt/post_description', $desc, $object ) );
|
||||
$desc = $this->format_text( $this->do_filter( 'llms_txt/post_description', $desc, $object ) );
|
||||
|
||||
$this->output_line(
|
||||
$desc
|
||||
? '- [' . esc_html( $title ) . '](' . esc_url( $link ) . '): ' . esc_html( $desc )
|
||||
: '- [' . esc_html( $title ) . '](' . esc_url( $link ) . ')'
|
||||
? '- [' . $title . '](' . $link . '): ' . $desc
|
||||
: '- [' . $title . '](' . $link . ')'
|
||||
);
|
||||
}
|
||||
$this->output_line( '' );
|
||||
@@ -291,13 +294,19 @@ class LLMS_Txt {
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = $tax_obj->labels->name;
|
||||
$this->output_line( '## ' . esc_html( $label ) );
|
||||
$label = $this->format_text( $tax_obj->labels->name );
|
||||
$this->output_line( '## ' . $label );
|
||||
foreach ( $terms as $term ) {
|
||||
if ( $term && Helper::is_term_indexable( $term ) ) {
|
||||
$name = $term->name;
|
||||
$link = get_term_link( $term );
|
||||
$this->output_line( '- [' . esc_html( $name ) . '](' . esc_url( $link ) . ')' );
|
||||
$name = $this->format_text( $term->name );
|
||||
$link = esc_url_raw( get_term_link( $term ) );
|
||||
$desc = $this->format_text( $term->description );
|
||||
|
||||
$this->output_line(
|
||||
$desc
|
||||
? '- [' . $name . '](' . $link . '): ' . $desc
|
||||
: '- [' . $name . '](' . $link . ')'
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->output_line( '' );
|
||||
@@ -319,17 +328,28 @@ class LLMS_Txt {
|
||||
*/
|
||||
$extra = $this->do_filter( 'llms_txt/extra_content', Helper::get_settings( 'general.llms_extra_content', '' ) );
|
||||
if ( ! empty( $extra ) ) {
|
||||
$this->output_line( esc_html( str_replace( "\n", "\n", $extra ) ) );
|
||||
$this->output_line( $this->format_text( $extra ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a line with a newline character (\n).
|
||||
* Normalizes text for plain-text output: strips tags, decodes entities.
|
||||
* Decode first, so an entity-encoded tag (e.g. <script>) can't survive stripping.
|
||||
*
|
||||
* @param string $content The content to output.
|
||||
* @param string $text The text to normalize.
|
||||
* @return string Normalized plain text.
|
||||
*/
|
||||
private function format_text( $text ) {
|
||||
return trim( wp_strip_all_tags( html_entity_decode( (string) $text, ENT_QUOTES, 'UTF-8' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a line with a trailing newline.
|
||||
*
|
||||
* @param string $content Plain text content; must already be sanitized (see format_text()).
|
||||
* @return void
|
||||
*/
|
||||
private function output_line( $content ) {
|
||||
echo esc_html( $content ) . "\n";
|
||||
echo $content . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Plain text, not HTML; see format_text().
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user