ID)) { return $content; } $options = get_option('ahmaipsu_settings', array()); $global_enabled = isset($options['ahmaipsu_global_enable']) ? $options['ahmaipsu_global_enable'] : false; $supported_post_types = isset($options['ahmaipsu_post_types']) ? $options['ahmaipsu_post_types'] : ['post']; // Check if current post type is supported if (!in_array($post->post_type, $supported_post_types)) { return $content; } $post_enabled = get_post_meta($post->ID, '_ahmaipsu_enabled', true); $summary = get_post_meta($post->ID, '_ahmaipsu_content', true); $content_type = get_post_meta($post->ID, '_ahmaipsu_content_type', true) ?: 'summary'; if (!$global_enabled || !$post_enabled || empty($summary)) { return $content; } // Manual block or shortcode placement: do not also prepend. if (has_block('ahm-ai-post-summary/summary', $content) || has_shortcode($content, 'ahm_ai_post_summary') || has_shortcode($content, 'ahmaipsu')) { return $content; } // Get disclaimer text and theme from settings $disclaimer = isset($options['ahmaipsu_disclaimer']) ? $options['ahmaipsu_disclaimer'] : 'This summary was generated by AI and may contain inaccuracies or omissions. Please refer to the full article for complete information.'; $theme = isset($options['ahmaipsu_theme']) ? $options['ahmaipsu_theme'] : 'classic'; $summary_html = ahmaipsu_render_summary($summary, $disclaimer, $theme, $content_type); return $summary_html . $content; } function ahmaipsu_render_summary($summary, $disclaimer, $theme = 'classic', $content_type = 'summary', $show_title = true, $show_disclaimer = true) { $options = get_option('ahmaipsu_settings', array()); $theme_classes = array( 'classic' => 'ahmaipsu-theme-classic', 'minimal' => 'ahmaipsu-theme-minimal', 'modern' => 'ahmaipsu-theme-modern', 'elegant' => 'ahmaipsu-theme-elegant', 'card' => 'ahmaipsu-theme-card' ); $theme_titles = array( 'classic' => 'đ Summary', 'minimal' => 'Summary', 'modern' => 'đ¤ Summary', 'elegant' => 'Summary', 'card' => 'đ Summary' ); // Adjust title for key takeaways if ($content_type === 'key_takeaways') { $theme_titles = array( 'classic' => 'đ Key Takeaways', 'minimal' => 'Key Takeaways', 'modern' => 'đ¯ Key Takeaways', 'elegant' => 'Key Takeaways', 'card' => 'đ Key Takeaways' ); } // Use custom titles if set if ($content_type === 'summary' && !empty($options['ahmaipsu_custom_summary_title'])) { $theme_title = $options['ahmaipsu_custom_summary_title']; } elseif ($content_type === 'key_takeaways' && !empty($options['ahmaipsu_custom_key_takeaways_title'])) { $theme_title = $options['ahmaipsu_custom_key_takeaways_title']; } else { $theme_title = isset($theme_titles[$theme]) ? $theme_titles[$theme] : $theme_titles['classic']; } $theme_class = isset($theme_classes[$theme]) ? $theme_classes[$theme] : $theme_classes['classic']; // Format content based on type if ($content_type === 'key_takeaways') { $formatted_content = wp_kses_post($summary); if (strpos($formatted_content, '
' . esc_html($theme_title) . '
'; } $html .= '