esc_url_raw( rest_url( 'aiss/v1/' ) ), 'restNonce' => wp_create_nonce( 'wp_rest' ), 'adminNonce' => wp_create_nonce( 'aiss_admin_nonce' ), 'nonce' => wp_create_nonce( 'aiss_admin_nonce' ), 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'adminUrl' => admin_url(), 'siteName' => get_bloginfo( 'name' ), 'vigiaActive' => is_plugin_active( 'vigia/vigia.php' ) ? '1' : '0', 'strings' => array( 'loading' => __( 'Loading...', 'ai-share-summarize' ), 'noData' => __( 'No data yet.', 'ai-share-summarize' ), 'loadMore' => __( 'Load more', 'ai-share-summarize' ), /* translators: %1$s = current count, %2$s = total count */ 'showingOf' => __( 'Showing %1$s of %2$s', 'ai-share-summarize' ), 'clicks' => __( 'Clicks', 'ai-share-summarize' ), 'aiCrawls' => __( 'AI Crawls', 'ai-share-summarize' ), 'edit' => __( 'Edit', 'ai-share-summarize' ), 'allTime' => __( 'All time', 'ai-share-summarize' ), 'today' => __( 'Today', 'ai-share-summarize' ), /* translators: %d = number of days */ 'lastDays' => __( 'Last %d days', 'ai-share-summarize' ), 'confirmDeleteAll' => __( 'Are you sure you want to delete ALL analytics data? This action cannot be undone.', 'ai-share-summarize' ), 'deleting' => __( 'Deleting...', 'ai-share-summarize' ), 'deleteSuccess' => __( 'All analytics data has been deleted.', 'ai-share-summarize' ), 'deleteError' => __( 'Error deleting data. Please try again.', 'ai-share-summarize' ), /* Translatable type labels for platforms table (v1.7.0) */ 'typeAI' => __( 'AI', 'ai-share-summarize' ), 'typeSocial' => __( 'Social', 'ai-share-summarize' ), /* Comparison and export strings (v1.7.0) */ 'previousPeriod' => __( 'Previous period', 'ai-share-summarize' ), 'currentPeriod' => __( 'Current period', 'ai-share-summarize' ), 'exportError' => __( 'Export failed. Please try again.', 'ai-share-summarize' ), /* translators: %1$s = range start, %2$s = range end, %3$s = total */ 'pagerRange' => __( '%1$s–%2$s of %3$s', 'ai-share-summarize' ), 'vs' => __( 'vs', 'ai-share-summarize' ), ), ) ); // Inline script for activation notice dismissal. wp_add_inline_script( 'jquery', ' jQuery(document).ready(function($) { $(document).on("click", ".notice[data-notice=\"ayudawp-aiss-activation\"] .notice-dismiss", function() { $.post(ajaxurl, { action: "ayudawp_dismiss_activation_notice", nonce: "' . esc_js( wp_create_nonce( 'ayudawp_dismiss_notice' ) ) . '" }); }); $(document).on("click", ".aiss-dismiss-ai-error", function() { var btn = $(this); var notice = btn.closest(".aiss-ai-error-notice"); $.post(ajaxurl, { action: "ayudawp_aiss_dismiss_ai_error", nonce: btn.data("nonce") }, function(response) { if (response && response.success) { notice.slideUp(180, function() { notice.remove(); }); } }); }); }); ' ); } /** * Add settings link to plugins page * * @param array $links Plugin action links. * @return array Modified links. */ public function ayudawp_add_settings_link( $links ) { // Add Analytics link. $analytics_link = '' . esc_html__( 'Analytics', 'ai-share-summarize' ) . ''; array_unshift( $links, $analytics_link ); // Add Settings link (appears first / leftmost). $settings_link = '' . esc_html__( 'Settings', 'ai-share-summarize' ) . ''; array_unshift( $links, $settings_link ); return $links; } /** * Show activation notice */ public function ayudawp_activation_notice() { if ( get_current_screen()->id !== 'plugins' || get_option( 'ayudawp_aiss_activation_notice_dismissed' ) ) { return; } if ( get_transient( 'ayudawp_aiss_just_activated' ) ) { ?>

ayudawp_register_settings_fields(); } /** * Register settings fields */ private function ayudawp_register_settings_fields() { $fields = array( 'default_prompt' => esc_html__( 'AIs Default Prompt', 'ai-share-summarize' ), 'enabled_buttons' => esc_html__( 'Enabled buttons', 'ai-share-summarize' ), 'display_locations' => esc_html__( 'Where to display the buttons', 'ai-share-summarize' ), 'auto_insert_position' => esc_html__( 'Automatic insertion position', 'ai-share-summarize' ), 'auto_insert_content_types' => esc_html__( 'Automatic insertion by content type', 'ai-share-summarize' ), 'seo_integration' => esc_html__( 'SEO Integration', 'ai-share-summarize' ), 'twitter_handle' => esc_html__( 'X handle to mention', 'ai-share-summarize' ), 'mastodon_instance' => esc_html__( 'Mastodon instance', 'ai-share-summarize' ), 'custom_text' => esc_html__( 'Custom text in prompts', 'ai-share-summarize' ), 'title_text' => esc_html__( 'Title text before buttons', 'ai-share-summarize' ), 'section_titles' => esc_html__( 'Section titles', 'ai-share-summarize' ), 'title_style' => esc_html__( 'Title style', 'ai-share-summarize' ), 'button_order' => esc_html__( 'Buttons order', 'ai-share-summarize' ), 'button_alignment' => esc_html__( 'Button alignment', 'ai-share-summarize' ), 'separators' => esc_html__( 'Separator lines', 'ai-share-summarize' ), 'button_colors' => esc_html__( 'Button style', 'ai-share-summarize' ), 'dark_mode_adaptation' => esc_html__( 'Dark mode adaptation', 'ai-share-summarize' ), 'button_size' => esc_html__( 'Button size', 'ai-share-summarize' ), 'show_icons' => esc_html__( 'Show icons', 'ai-share-summarize' ), 'icon_style' => esc_html__( 'Icons only style', 'ai-share-summarize' ), 'seo_button_type' => esc_html__( 'Button HTML Type', 'ai-share-summarize' ), 'data_retention' => esc_html__( 'Data retention', 'ai-share-summarize' ), ); foreach ( $fields as $field_id => $field_title ) { add_settings_field( $field_id, $field_title, array( $this, 'ayudawp_' . $field_id . '_callback' ), 'ayudawp_aiss_settings', 'ayudawp_aiss_main' ); } // AI Summary section fields (v2.0.0). $summary_fields = array( 'ai_summary_mode' => esc_html__( 'AI Summary generation', 'ai-share-summarize' ), 'ai_summary_model' => esc_html__( 'AI model', 'ai-share-summarize' ), 'ai_summary_content_types' => esc_html__( 'Summaries by content type', 'ai-share-summarize' ), 'ai_summary_position' => esc_html__( 'Summary position', 'ai-share-summarize' ), 'ai_summary_collapsed_default' => esc_html__( 'Collapsed by default', 'ai-share-summarize' ), 'ai_summary_label' => esc_html__( 'Summary block label', 'ai-share-summarize' ), 'ai_summary_style' => esc_html__( 'Summary block style', 'ai-share-summarize' ), 'ai_summary_icon_position' => esc_html__( 'Summary icon position', 'ai-share-summarize' ), 'ai_summary_sentences' => esc_html__( 'Summary length', 'ai-share-summarize' ), 'ai_summary_bullets' => esc_html__( 'Summary format', 'ai-share-summarize' ), 'ai_summary_frontend_button' => esc_html__( 'Frontend generation button', 'ai-share-summarize' ), 'ai_summary_generate_button_label' => esc_html__( 'Frontend button label', 'ai-share-summarize' ), 'ai_summary_frontend_force_extractive' => esc_html__( 'Frontend uses extractive only', 'ai-share-summarize' ), ); foreach ( $summary_fields as $field_id => $field_title ) { add_settings_field( $field_id, $field_title, array( $this, 'ayudawp_' . $field_id . '_callback' ), 'ayudawp_aiss_summary_settings', 'ayudawp_aiss_ai_summary' ); } } /** * Admin page content with tabs */ public function ayudawp_admin_page() { $active_tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : 'analytics'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $page_url = admin_url( 'options-general.php?page=ai-share-summarize' ); // Dynamic page title based on active tab. The buttons tab keeps the // legacy 'settings' slug so bookmarked/external links don't break; // only its visible label says "Share Buttons". $page_title = 'Share Buttons & AI-powered Summaries'; if ( 'analytics' === $active_tab ) { $page_title .= ' — ' . esc_html__( 'Analytics', 'ai-share-summarize' ); } elseif ( 'ai-summary' === $active_tab ) { $page_title .= ' — ' . esc_html__( 'AI Summary', 'ai-share-summarize' ); } elseif ( 'settings' === $active_tab ) { $page_title .= ' — ' . esc_html__( 'Share Buttons', 'ai-share-summarize' ); } ?>

ayudawp_render_summary_tab(); } else { $this->ayudawp_render_settings_tab(); } ?> render( 'horizontal' ); ?>
' . esc_html__( 'Configure how and where to display the share buttons. The inline AI summary has its own tab: AI Summary.', 'ai-share-summarize' ); echo ' (' . esc_html__( 'You can also customize display using shortcodes as described in the', 'ai-share-summarize' ) . ' ' . esc_html__( 'plugin page', 'ai-share-summarize' ) . ')'; echo '

'; } // ========================================== // Settings field callbacks // ========================================== /** * Default prompt field */ public function ayudawp_default_prompt_callback() { $options = get_option( 'ayudawp_aiss_options' ); $value = isset( $options['default_prompt'] ) ? $options['default_prompt'] : ayudawp_aiss_get_default_prompt(); ?>

'; foreach ( $buttons as $key => $label ) { $checked = in_array( $key, $enabled, true ) ? 'checked="checked"' : ''; $icon_preview = AyudaWP_AISS_Icons::ayudawp_get_icon( $key, 16 ); echo ''; } echo ''; echo '

' . esc_html__( 'Select which buttons to display on the frontend.', 'ai-share-summarize' ) . '

'; } /** * Display locations field */ public function ayudawp_display_locations_callback() { $options = get_option( 'ayudawp_aiss_options' ); $locations = isset( $options['display_locations'] ) ? $options['display_locations'] : array(); if ( ! is_array( $locations ) ) { $locations = array(); } $available_locations = array( 'posts' => esc_html__( 'Posts', 'ai-share-summarize' ), 'pages' => esc_html__( 'Pages', 'ai-share-summarize' ), 'archives' => esc_html__( 'Archives', 'ai-share-summarize' ), 'home' => esc_html__( 'Home', 'ai-share-summarize' ), 'cpt' => esc_html__( 'Custom Post Types', 'ai-share-summarize' ), ); echo '

' . esc_html__( 'Select in which types of content to display the buttons:', 'ai-share-summarize' ) . '

'; foreach ( $available_locations as $key => $label ) { $checked = in_array( $key, $locations, true ) ? 'checked="checked"' : ''; echo ''; } } /** * Auto insert position field */ public function ayudawp_auto_insert_position_callback() { $options = get_option( 'ayudawp_aiss_options' ); $position = isset( $options['auto_insert_position'] ) ? $options['auto_insert_position'] : 'after_content'; $positions = array( 'disabled' => esc_html__( 'Disabled (shortcode only mode)', 'ai-share-summarize' ), 'before_content' => esc_html__( 'Before the content', 'ai-share-summarize' ), 'after_content' => esc_html__( 'After the content', 'ai-share-summarize' ), 'both' => esc_html__( 'Before and after the content', 'ai-share-summarize' ), ); echo '

' . esc_html__( 'Select where to automatically insert the buttons:', 'ai-share-summarize' ) . '

'; foreach ( $positions as $key => $label ) { $checked = ( $position === $key ) ? 'checked="checked"' : ''; echo ''; } echo '

' . esc_html__( 'Note:', 'ai-share-summarize' ) . ' ' . esc_html__( 'When disabled, it will only be displayed using the shortcode [ayudawp_share_buttons].', 'ai-share-summarize' ) . '

'; } /** * Auto insert content types field */ public function ayudawp_auto_insert_content_types_callback() { $options = get_option( 'ayudawp_aiss_options' ); $content_types = isset( $options['auto_insert_content_types'] ) ? $options['auto_insert_content_types'] : array(); if ( ! is_array( $content_types ) ) { $content_types = array(); } $post_types = get_post_types( array( 'public' => true ), 'objects' ); echo '

' . esc_html__( 'Select the types of content in which to automatically insert the buttons:', 'ai-share-summarize' ) . '

'; echo '
'; foreach ( $post_types as $post_type ) { $checked = in_array( $post_type->name, $content_types, true ) ? 'checked="checked"' : ''; echo ''; } echo '
'; echo '

' . esc_html__( 'It will only be applied to singular content (not to lists or files).', 'ai-share-summarize' ) . '

'; } /** * SEO Integration callback */ public function ayudawp_seo_integration_callback() { $options = get_option( 'ayudawp_aiss_options' ); $exclude_noindex = isset( $options['exclude_noindex'] ) ? $options['exclude_noindex'] : true; $seo_plugin = AyudaWP_AISS_SEO_Integration::ayudawp_detect_seo_plugin(); $has_noindexer = class_exists( 'Noindexer_Frontend' ); $has_visibility = AyudaWP_AISS_SEO_Integration::ayudawp_has_visibility(); ?>

Yoast SEO, Rank Math, All in One SEO, SEOPress, The SEO Framework, Visibility, NoIndexer


esc_html__( 'Heading 3 (h3)', 'ai-share-summarize' ), 'h4' => esc_html__( 'Heading 4 (h4)', 'ai-share-summarize' ), 'h5' => esc_html__( 'Heading 5 (h5)', 'ai-share-summarize' ), 'h6' => esc_html__( 'Heading 6 (h6)', 'ai-share-summarize' ), 'span' => esc_html__( 'Span (plain text)', 'ai-share-summarize' ), ); echo '

' . esc_html__( 'Select the HTML element for the title:', 'ai-share-summarize' ) . '

'; foreach ( $styles as $key => $label ) { $checked = ( $style === $key ) ? 'checked="checked"' : ''; echo ''; } } /** * Button order field */ public function ayudawp_button_order_callback() { $options = get_option( 'ayudawp_aiss_options' ); $order = isset( $options['button_order'] ) ? $options['button_order'] : 'ayudawp_ai_first'; $orders = array( 'ayudawp_social_first' => esc_html__( 'Social media first', 'ai-share-summarize' ), 'ayudawp_ai_first' => esc_html__( 'AIs first', 'ai-share-summarize' ), 'ayudawp_mixed' => esc_html__( 'Mixed', 'ai-share-summarize' ), ); foreach ( $orders as $key => $label ) { $checked = ( $order === $key ) ? 'checked="checked"' : ''; echo ''; } // Two-column sortable for custom internal order within each group (v1.6.0). $custom_order_ai = isset( $options['button_custom_order_ai'] ) ? $options['button_custom_order_ai'] : array(); $custom_order_social = isset( $options['button_custom_order_social'] ) ? $options['button_custom_order_social'] : array(); $enabled = isset( $options['enabled_buttons'] ) ? $options['enabled_buttons'] : array(); $all_buttons = ayudawp_aiss_get_available_buttons(); $social_keys = ayudawp_aiss_get_social_buttons(); $ai_keys = ayudawp_aiss_get_ai_buttons(); // Build sorted lists per group. $sorted_ai = self::ayudawp_build_sorted_list( $custom_order_ai, $enabled, $ai_keys, $all_buttons ); $sorted_social = self::ayudawp_build_sorted_list( $custom_order_social, $enabled, $social_keys, $all_buttons ); $svg_kses = array( 'svg' => array( 'width' => array(), 'height' => array(), 'viewBox' => array(), 'fill' => array(), 'role' => array(), 'class' => array(), 'aria-hidden' => array() ), 'path' => array( 'd' => array(), 'fill' => array(), 'stroke' => array() ), 'circle' => array( 'cx' => array(), 'cy' => array(), 'r' => array(), 'fill' => array() ), 'rect' => array( 'x' => array(), 'y' => array(), 'width' => array(), 'height' => array(), 'rx' => array(), 'ry' => array() ), 'span' => array( 'class' => array() ), ); echo '
'; echo '

' . esc_html__( 'Drag and drop to reorder within each group:', 'ai-share-summarize' ) . '

'; echo '
'; // AI column. echo '
'; echo '' . esc_html__( 'AI platforms', 'ai-share-summarize' ) . ''; echo '
    '; foreach ( $sorted_ai as $btn ) { $icon = AyudaWP_AISS_Icons::ayudawp_get_icon( $btn, 14 ); echo '
  • '; echo ''; echo wp_kses( $icon, $svg_kses ); echo '' . esc_html( $all_buttons[ $btn ] ) . ''; echo ''; echo '
  • '; } echo '
'; // Social column. echo '
'; echo '' . esc_html__( 'Social platforms', 'ai-share-summarize' ) . ''; echo '
    '; foreach ( $sorted_social as $btn ) { $icon = AyudaWP_AISS_Icons::ayudawp_get_icon( $btn, 14 ); echo '
  • '; echo ''; echo wp_kses( $icon, $svg_kses ); echo '' . esc_html( $all_buttons[ $btn ] ) . ''; echo ''; echo '
  • '; } echo '
'; echo '
'; // grid. echo '
'; // wrapper. } /** * Build a sorted button list from custom order + enabled buttons * * @param array $custom_order Saved custom order. * @param array $enabled Currently enabled buttons. * @param array $group_keys Keys belonging to this group (ai or social). * @param array $all_buttons All available buttons. * @return array Sorted button keys. */ private static function ayudawp_build_sorted_list( $custom_order, $enabled, $group_keys, $all_buttons ) { $sorted = array(); if ( ! empty( $custom_order ) ) { foreach ( $custom_order as $btn ) { if ( in_array( $btn, $enabled, true ) && in_array( $btn, $group_keys, true ) && isset( $all_buttons[ $btn ] ) ) { $sorted[] = $btn; } } } foreach ( $enabled as $btn ) { if ( ! in_array( $btn, $sorted, true ) && in_array( $btn, $group_keys, true ) && isset( $all_buttons[ $btn ] ) ) { $sorted[] = $btn; } } return $sorted; } /** * Button alignment field */ public function ayudawp_button_alignment_callback() { $options = get_option( 'ayudawp_aiss_options' ); $alignment = isset( $options['button_alignment'] ) ? $options['button_alignment'] : 'left'; $alignments = array( 'left' => esc_html__( 'Left (default)', 'ai-share-summarize' ), 'center' => esc_html__( 'Centered', 'ai-share-summarize' ), ); foreach ( $alignments as $key => $label ) { $checked = ( $alignment === $key ) ? 'checked="checked"' : ''; echo ''; } echo '

' . esc_html__( 'This setting does not affect mobile devices, where buttons adapt automatically for better usability.', 'ai-share-summarize' ) . '

'; } /** * Separator lines field (v2.4.0) */ public function ayudawp_separators_callback() { $options = get_option( 'ayudawp_aiss_options' ); $separator_top = isset( $options['separator_top'] ) ? $options['separator_top'] : true; $separator_bottom = isset( $options['separator_bottom'] ) ? $options['separator_bottom'] : true; ?>

esc_html__( 'Minimal (default)', 'ai-share-summarize' ), 'brand' => esc_html__( 'Brand colors', 'ai-share-summarize' ), 'outline' => esc_html__( 'Outline (brand borders)', 'ai-share-summarize' ), 'dark' => esc_html__( 'For dark backgrounds', 'ai-share-summarize' ), 'custom' => esc_html__( 'Custom colors', 'ai-share-summarize' ), 'icons-only' => esc_html__( 'Icons only', 'ai-share-summarize' ), ); foreach ( $styles as $key => $label ) { $checked = ( $style === $key ) ? 'checked="checked"' : ''; echo ''; } // Custom color picker fields. $custom_bg = isset( $options['custom_color_bg'] ) ? $options['custom_color_bg'] : '#333333'; $custom_text = isset( $options['custom_color_text'] ) ? $options['custom_color_text'] : '#ffffff'; ?>
' . esc_html__( 'Select the visual style for the buttons. Icons only style shows only icons without text.', 'ai-share-summarize' ) . '

'; } /** * Dark mode adaptation field */ public function ayudawp_dark_mode_adaptation_callback() { $options = get_option( 'ayudawp_aiss_options' ); $mode = isset( $options['dark_mode_adaptation'] ) ? $options['dark_mode_adaptation'] : 'disabled'; $modes = array( 'disabled' => esc_html__( 'Disabled (default)', 'ai-share-summarize' ), 'auto' => esc_html__( 'Auto: detect dark backgrounds and adapt buttons', 'ai-share-summarize' ), ); foreach ( $modes as $key => $label ) { $checked = ( $mode === $key ) ? 'checked="checked"' : ''; echo ''; } echo '

' . esc_html__( 'Off by default since most themes don\'t offer a dark mode. Enable "Auto" if your theme does: a tiny script measures the real background of the buttons container and, only when it is dark, switches X, Threads and Grok to legible colors and adapts the Minimal/Outline text. The "Custom" and "For dark backgrounds" styles are never overridden (they are explicit choices).', 'ai-share-summarize' ) . '

'; } /** * Show icons field */ public function ayudawp_show_icons_callback() { $options = get_option( 'ayudawp_aiss_options' ); $show_icons = isset( $options['show_icons'] ) ? $options['show_icons'] : false; ?>

esc_html__( 'Square corners', 'ai-share-summarize' ), 'circular' => esc_html__( 'Circular', 'ai-share-summarize' ), ); echo '

' . esc_html__( 'Select the corner style for icons-only buttons:', 'ai-share-summarize' ) . '

'; foreach ( $styles as $key => $label ) { $checked = ( $icon_style === $key ) ? 'checked="checked"' : ''; echo ''; } echo '

' . esc_html__( 'This setting only affects the "Icons only" button style.', 'ai-share-summarize' ) . '

'; } /** * SEO button type field */ public function ayudawp_seo_button_type_callback() { $options = get_option( 'ayudawp_aiss_options' ); $seo_type = isset( $options['seo_button_type'] ) ? $options['seo_button_type'] : 'link'; ?>

__( '1 month', 'ai-share-summarize' ), '3_months' => __( '3 months', 'ai-share-summarize' ), '6_months' => __( '6 months', 'ai-share-summarize' ), '1_year' => __( '1 year', 'ai-share-summarize' ), 'forever' => __( 'Forever', 'ai-share-summarize' ), ); ?>



esc_html__( 'Compact', 'ai-share-summarize' ), 'normal' => esc_html__( 'Normal (default)', 'ai-share-summarize' ), 'large' => esc_html__( 'Large', 'ai-share-summarize' ), 'fluid' => esc_html__( 'Fluid (fill available width)', 'ai-share-summarize' ), ); foreach ( $sizes as $key => $label ) { $checked = ( $size === $key ) ? 'checked="checked"' : ''; echo ''; } echo '

' . esc_html__( 'Fluid mode makes buttons expand to fill the available space instead of using a fixed width.', 'ai-share-summarize' ) . '

'; } /** * AJAX handler: Delete all analytics data */ public function ayudawp_ajax_delete_all_data() { check_ajax_referer( 'aiss_admin_nonce', 'nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'message' => 'Permission denied.' ) ); } AyudaWP_AISS_Database::ayudawp_delete_all_data(); wp_send_json_success(); } /** * AJAX handler: Dismiss the "Last AI generation error" notice on Settings (v2.0.0) */ public function ayudawp_ajax_dismiss_ai_error() { check_ajax_referer( 'aiss_admin_nonce', 'nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'message' => 'Permission denied.' ) ); } if ( class_exists( 'AyudaWP_AISS_AI_Summary' ) ) { AyudaWP_AISS_AI_Summary::store_last_ai_error( null ); } else { delete_option( 'ayudawp_aiss_last_ai_error' ); } wp_send_json_success(); } // ========================================== // AI Summary section (v2.0.0) // ========================================== /** * AI Summary section callback — explains the feature and AI client status * * Since 2.3.0 this section lives on its own tab (&tab=ai-summary), which * is the stable deep-link target for the command palette, the Abilities * API and external docs (it replaces the old in-page anchor). */ public function ayudawp_ai_summary_section_callback() { echo '

' . esc_html__( 'Automatically generate a short summary of each post and display it inline alongside the share buttons.', 'ai-share-summarize' ) . '

'; // Loud, early warning when automatic generation is effectively off // because the content-type list is empty: since the buttons-list // fallback was removed (2.3.0), an empty list genuinely means "no // content types", and without this notice the only symptom would be // summaries silently not appearing. if ( ayudawp_aiss_is_summary_active() && array() === ayudawp_aiss_get_summary_post_types() ) { echo '
' . '

' . esc_html__( 'Automatic summaries are off for every content type.', 'ai-share-summarize' ) . ' ' . esc_html__( 'No content type is selected in "Summaries by content type" below, so no summary will be generated or displayed automatically. Manual regeneration from the editor keeps working.', 'ai-share-summarize' ) . '

' . '
'; } echo '
'; if ( function_exists( 'wp_ai_client_prompt' ) ) { $connectors_url = admin_url( 'options-connectors.php' ); echo '

' . esc_html__( 'WP AI Client is available.', 'ai-share-summarize' ) . ' ' . sprintf( /* translators: %s is a link to the Connectors settings screen. */ esc_html__( 'Configure your AI provider in %s to enable high-quality summaries.', 'ai-share-summarize' ), '' . esc_html__( 'Settings > Connectors', 'ai-share-summarize' ) . '' ) . '

'; // Surface the last AI Client error (if any) so the admin can act on it. // The optional "Possible cause" hint lives inside the same notice // so the dismiss button removes both lines together — keeping a // floating hint visible after the user has dismissed its parent // error would be confusing. if ( class_exists( 'AyudaWP_AISS_AI_Summary' ) ) { $last_error = AyudaWP_AISS_AI_Summary::get_last_ai_error(); if ( $last_error ) { $nonce = wp_create_nonce( 'aiss_admin_nonce' ); $show_hint = ayudawp_aiss_is_canonical_ai_plugin_active(); $approvals_url = admin_url( 'tools.php?page=ai-connector-approval' ); echo '
'; echo '
'; echo '

' . '' . esc_html__( 'Last AI generation error:', 'ai-share-summarize' ) . ' ' . esc_html( $last_error['message'] ) . ' ' . esc_html( $last_error['code'] ) . '' . '

'; // Heuristic hint: when the canonical AI plugin is active, // its Connector Approval system can silently block our // calls without a clear error code. Point the admin // straight at the approvals screen so they can unblock // us without us having to ship our own HTTP client. if ( $show_hint ) { echo '

' . '' . esc_html__( 'Possible cause:', 'ai-share-summarize' ) . ' ' . sprintf( /* translators: %1$s/%2$s wrap a link to Tools > Connector Approvals. */ esc_html__( 'The canonical AI plugin is active. Its Connector Approval system can silently block calls from plugins it has not approved yet. Open %1$sTools > Connector Approvals%2$s and enable the toggle next to "Share Buttons & AI-powered Summaries".', 'ai-share-summarize' ), '', '' ) . '

'; } echo '
'; // .flex column wrapper echo ''; echo '
'; // .aiss-ai-error-notice } } } else { echo '

' . esc_html__( 'WP AI Client not detected.', 'ai-share-summarize' ) . ' ' . esc_html__( 'Requires WordPress 7.0 or later. Without it, only the basic extractive fallback will be used.', 'ai-share-summarize' ) . '

'; } echo '
'; echo '

' . esc_html__( 'Summaries are generated asynchronously when a post is published or updated, on the post types selected in "Summaries by content type" below. This tab saves independently from the share buttons settings.', 'ai-share-summarize' ) . '

'; } /** * AI summary generation mode field (v2.2.0) * * Single explicit selector that replaces the former "Enable AI Summary" + * "Use extractive fallback" checkbox pair. */ public function ayudawp_ai_summary_mode_callback() { $mode = ayudawp_aiss_get_summary_mode(); $modes = array( 'ai_fallback' => esc_html__( 'AI with extractive fallback (recommended)', 'ai-share-summarize' ), 'ai_only' => esc_html__( 'AI only (no fallback)', 'ai-share-summarize' ), 'extractive_only' => esc_html__( 'Extractive only (never contacts an AI provider)', 'ai-share-summarize' ), 'disabled' => esc_html__( 'Disabled', 'ai-share-summarize' ), ); $descriptions = array( 'ai_fallback' => esc_html__( 'Generate with your AI provider; if it is unavailable, fall back to the on-server extractive summary.', 'ai-share-summarize' ), 'ai_only' => esc_html__( 'Generate with your AI provider only. If it fails, no summary is produced.', 'ai-share-summarize' ), 'extractive_only' => esc_html__( 'Always use the on-server extractive summarizer. Zero cost, never contacts an AI provider.', 'ai-share-summarize' ), 'disabled' => esc_html__( 'Do not generate summaries at all.', 'ai-share-summarize' ), ); foreach ( $modes as $key => $label ) { ?>

Connectors when no provider is configured. */ public function ayudawp_ai_summary_model_callback() { $options = ayudawp_aiss_get_summary_options(); $selected = isset( $options['ai_summary_model'] ) ? (string) $options['ai_summary_model'] : ''; $available = ayudawp_aiss_get_available_models(); if ( empty( $available ) ) { $connectors_url = admin_url( 'options-connectors.php' ); ?>

Connectors', 'ai-share-summarize' ); ?>

esc_html__( 'Right before the share buttons', 'ai-share-summarize' ), 'after_buttons' => esc_html__( 'Right after the share buttons', 'ai-share-summarize' ), 'before_content' => esc_html__( 'Before the content', 'ai-share-summarize' ), 'disabled' => esc_html__( 'Do not display (still generates the summary)', 'ai-share-summarize' ), ); echo '

' . esc_html__( 'Choose where to render the summary in the post:', 'ai-share-summarize' ) . '

'; foreach ( $positions as $key => $label ) { $checked = ( $position === $key ) ? 'checked="checked"' : ''; echo ''; } } /** * AI summary collapsed default field */ public function ayudawp_ai_summary_collapsed_default_callback() { $options = ayudawp_aiss_get_summary_options(); $collapsed = isset( $options['ai_summary_collapsed_default'] ) ? (bool) $options['ai_summary_collapsed_default'] : true; ?>

true ), 'objects' ); echo '

' . esc_html__( 'Select the post types where summaries should be generated and displayed:', 'ai-share-summarize' ) . '

'; // Marker so the sanitizer can tell "submitted with every checkbox // unchecked" apart from input that did not include this field at all. echo ''; echo '
'; foreach ( $post_types as $post_type ) { if ( 'attachment' === $post_type->name ) { continue; } $checked = in_array( $post_type->name, $selected, true ) ? 'checked="checked"' : ''; echo ''; } echo '
'; echo '

' . esc_html__( 'Fully independent from the share buttons content-type list. Unchecking every type turns automatic summaries off for the whole site.', 'ai-share-summarize' ) . '

'; } /** * Frontend generation button field (v2.0.0) */ public function ayudawp_ai_summary_frontend_button_callback() { $options = ayudawp_aiss_get_summary_options(); $enabled = isset( $options['ai_summary_frontend_button'] ) ? (bool) $options['ai_summary_frontend_button'] : false; ?>

esc_html__( 'Minimal (default)', 'ai-share-summarize' ), 'outline' => esc_html__( 'Outline', 'ai-share-summarize' ), 'brand' => esc_html__( 'Brand (filled)', 'ai-share-summarize' ), 'dark' => esc_html__( 'Dark', 'ai-share-summarize' ), 'custom' => esc_html__( 'Custom colors', 'ai-share-summarize' ), ); foreach ( $styles as $key => $label ) { $checked = ( $style === $key ) ? 'checked="checked"' : ''; echo ''; } $custom_bg = isset( $options['ai_summary_custom_bg'] ) ? $options['ai_summary_custom_bg'] : '#ffffff'; $custom_text = isset( $options['ai_summary_custom_text'] ) ? $options['ai_summary_custom_text'] : '#1a1a1a'; ?>
' . esc_html__( 'Visual style for the inline summary block and its Generate button. "Custom colors" uses the colors chosen above.', 'ai-share-summarize' ) . '

'; } /** * AI summary icon position field (v2.1.0) */ public function ayudawp_ai_summary_icon_position_callback() { $options = ayudawp_aiss_get_summary_options(); $position = isset( $options['ai_summary_icon_position'] ) ? $options['ai_summary_icon_position'] : 'left'; $positions = array( 'left' => esc_html__( 'Left (default)', 'ai-share-summarize' ), 'right' => esc_html__( 'Right', 'ai-share-summarize' ), 'hidden' => esc_html__( 'Hidden', 'ai-share-summarize' ), ); foreach ( $positions as $key => $label ) { $checked = ( $position === $key ) ? 'checked="checked"' : ''; echo ''; } echo '

' . esc_html__( 'Where the summary icon appears in the block header.', 'ai-share-summarize' ) . '

'; } /** * AI summary frontend button label field (v2.1.0) */ public function ayudawp_ai_summary_generate_button_label_callback() { $options = ayudawp_aiss_get_summary_options(); $value = isset( $options['ai_summary_generate_button_label'] ) ? $options['ai_summary_generate_button_label'] : ''; ?>