| @@ -9,13 +9,20 @@ | ||
| 9 | 9 | |
| 10 | 10 | public const DEFAULT_LIMIT = 100; |
| 11 | 11 | public const HOSTINGER_LLMSTXT_SIGNATURE = '[comment]: # (Generated by Hostinger Tools Plugin)'; |
| 12 | 12 | |
| 13 | + protected LlmsTxtSummaryProvider $summary_provider; | |
| 14 | + | |
| 15 | + public function __construct( LlmsTxtSummaryProvider $summary_provider ) { | |
| 16 | + $this->summary_provider = $summary_provider; | |
| 17 | + } | |
| 18 | + | |
| 13 | 19 | public function get_by_post_type( string $post_type, int $limit = self::DEFAULT_LIMIT, int $offset = 0 ): array { |
| 14 | 20 | $limit = apply_filters( 'hostinger_batch_item_limit', $limit ); |
| 15 | 21 | $args = array( |
| 16 | 22 | 'post_type' => $post_type, |
| 17 | 23 | 'post_status' => 'publish', |
| 24 | + 'has_password' => false, | |
| 18 | 25 | 'fields' => 'ids', |
| 19 | 26 | 'posts_per_page' => $limit, |
| 20 | 27 | 'offset' => $offset, |
| 21 | 28 | ); |
| @@ -28,13 +35,13 @@ | ||
| 28 | 35 | foreach ( $items as $item ) { |
| 29 | 36 | $post = get_post( $item ); |
| 30 | 37 | $title = $post->post_title; |
| 31 | 38 | $permalink = get_permalink( $post ); |
| 32 | - $excerpt = $this->prepare_excerpt( $post ); | |
| 39 | + $summary = $this->summary_provider->get_summary( $post ); | |
| 33 | 40 | |
| 34 | 41 | $content .= "- [$title]($permalink)"; |
| 35 | - if ( $excerpt ) { | |
| 36 | - $content .= ": $excerpt"; | |
| 42 | + if ( $summary ) { | |
| 43 | + $content .= ": $summary"; | |
| 37 | 44 | } |
| 38 | 45 | |
| 39 | 46 | $content .= "\n"; |
| 40 | 47 | } |
| @@ -83,10 +90,6 @@ | ||
| 83 | 90 | $output .= implode( "\n", $entries ); |
| 84 | 91 | } |
| 85 | 92 | |
| 86 | 93 | return $output; |
| 87 | - } | |
| 88 | - | |
| 89 | - public function prepare_excerpt( \WP_Post $item ): string { | |
| 90 | - return str_replace( array( "\r", "\n" ), ' ', strip_tags( wp_trim_excerpt( $item->post_excerpt, $item ) ) ); | |
| 91 | 94 | } |
| 92 | 95 | } |