' . esc_html__( 'AI Summary', 'ai-summary-generator' ) . '

' . esc_html( $summary ) . '

'; $content = $summary_html . $content; } } return $content; } /** * Override homepage summary * * @param string $excerpt Post excerpt. * @return string Modified excerpt */ public static function ai_summary_generator_override_homepage_summary( $excerpt ) { if ( ( is_home() || is_front_page() ) && in_the_loop() && is_main_query() ) { $override = get_option( 'ai_summary_homepage_override', 'no' ); if ( 'yes' === $override ) { $summary = AI_Summary_Generator_Core::get_summary( get_the_ID() ); if ( $summary ) { return '

' . esc_html( $summary ) . '

'; } } } return $excerpt; } /** * Get AI summary for a specific post (for theme developers) * * @param int $post_id Post ID. * @param bool $formatted Whether to return formatted HTML or plain text. * @return string|false AI summary or false if not available */ public static function get_post_summary( $post_id = null, $formatted = false ) { if ( ! $post_id ) { $post_id = get_the_ID(); } if ( ! $post_id ) { return false; } $summary = AI_Summary_Generator_Core::get_summary( $post_id ); if ( ! $summary ) { return false; } if ( $formatted ) { return '

' . esc_html__( 'AI Summary', 'ai-summary-generator' ) . '

' . esc_html( $summary ) . '

'; } return $summary; } }