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', 'platforms' => ayudawp_aiss_get_platforms_meta(), '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' ), /* Per-button breakdown in the platforms table (v2.6.0) */ 'showPosts' => __( 'Show the posts it was clicked from', 'ai-share-summarize' ), 'postsForButton' => __( 'Posts it was clicked from', 'ai-share-summarize' ), 'topPostsOnly' => __( 'Only the 20 posts with the most clicks are listed. The CSV export has all of them.', 'ai-share-summarize' ), 'loadError' => __( 'Could not load the data. Please try again.', 'ai-share-summarize' ), /* Floating bar preview (v2.8.0) */ /* translators: %1$s = buttons in sight, %2$s = buttons in the bar */ 'barVisible' => __( 'In sight: %1$s of %2$s', 'ai-share-summarize' ), /* translators: %s = buttons inside the panel that the bar opens */ 'barMore' => __( 'in the panel: %s', 'ai-share-summarize' ), /* translators: %s = height of the bar in pixels */ 'barTall' => __( '%s px tall', 'ai-share-summarize' ), /* translators: %s = width of the bar in pixels */ 'barWide' => __( '%s px wide', 'ai-share-summarize' ), 'barNone' => __( 'No buttons: the bar will not show.', 'ai-share-summarize' ), /* translators: %d = number of buttons inside the panel */ 'barMoreLabel' => __( 'More (%d)', 'ai-share-summarize' ), /* translators: %d = number of buttons inside the panel */ 'barShareLabel' => __( 'Share (%d)', 'ai-share-summarize' ), /* Block preview (v2.8.0). Same strings as the front-end toggle. */ 'compactLess' => __( 'Less', 'ai-share-summarize' ), 'compactClose' => __( 'Close', 'ai-share-summarize' ), 'blockUpdating' => __( 'Updating…', 'ai-share-summarize' ), 'blockError' => __( 'Could not update the preview.', 'ai-share-summarize' ), 'blockExpired' => __( 'The session has expired. Reload the page to update the preview.', 'ai-share-summarize' ), 'blockEmpty' => __( 'No buttons to show: the block will not appear.', 'ai-share-summarize' ), ), // Block preview (v2.8.0): the request that draws it, and the // front-end stylesheet its frame loads. 'blockPreviewNonce' => wp_create_nonce( 'aiss_block_preview' ), 'frontCss' => esc_url_raw( add_query_arg( 'ver', AYUDAWP_AISS_VERSION, AYUDAWP_AISS_PLUGIN_URL . 'assets/css/ai-share-summarize.css' ) ), ) ); // 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' ) ) { ?>

'
', 'after_section' => '
', 'section_class' => 'aiss-bar-section', ) ); add_settings_section( 'ayudawp_aiss_prompt', esc_html__( 'What is sent to the AI assistants', 'ai-share-summarize' ), '__return_false', 'ayudawp_aiss_settings' ); add_settings_section( 'ayudawp_aiss_advanced', esc_html__( 'Accounts and advanced', 'ai-share-summarize' ), '__return_false', 'ayudawp_aiss_settings' ); /* * The AI Summary tab gets the same treatment as the buttons one * (v2.5.0): grouped headings instead of thirteen flat rows, related * settings merged into two-column rows, and a live preview of the block * so the visual choices can be judged without saving. */ add_settings_section( 'ayudawp_aiss_ai_summary', esc_html__( 'Generation', 'ai-share-summarize' ), array( $this, 'ayudawp_ai_summary_section_callback' ), 'ayudawp_aiss_summary_settings' ); add_settings_section( 'ayudawp_aiss_summary_where', esc_html__( 'Where it appears', 'ai-share-summarize' ), '__return_false', 'ayudawp_aiss_summary_settings' ); add_settings_section( 'ayudawp_aiss_summary_block', esc_html__( 'The summary block', 'ai-share-summarize' ), '__return_false', 'ayudawp_aiss_summary_settings' ); add_settings_section( 'ayudawp_aiss_summary_visitor', esc_html__( 'Generation button for visitors', 'ai-share-summarize' ), '__return_false', 'ayudawp_aiss_summary_settings' ); add_settings_section( 'ayudawp_aiss_summary_custom', esc_html__( 'Custom content inside the box', 'ai-share-summarize' ), '__return_false', 'ayudawp_aiss_summary_settings' ); $this->ayudawp_register_settings_fields(); } /** * Register settings fields */ private function ayudawp_register_settings_fields() { // field id => [ label, section, optional row class ]. /* * The two places where buttons appear get the same six rows, in the * same order (v2.8.0). The label of "In sight" carries where it applies, * which is what tells the two apart: phones only in the content, * always in the bar. */ $on_phones = esc_html__( 'In sight', 'ai-share-summarize' ) . ' ' . esc_html__( 'On phones', 'ai-share-summarize' ) . ''; $always = esc_html__( 'In sight', 'ai-share-summarize' ) . ' ' . esc_html__( 'Always', 'ai-share-summarize' ) . ''; $fields = array( 'enabled_buttons' => array( esc_html__( 'Available buttons', 'ai-share-summarize' ), 'ayudawp_aiss_main' ), 'placements' => array( esc_html__( 'Where they appear', 'ai-share-summarize' ), 'ayudawp_aiss_placement' ), 'content_buttons' => array( esc_html__( 'Buttons and order', 'ai-share-summarize' ), 'ayudawp_aiss_placement' ), 'mobile_compact' => array( $on_phones, 'ayudawp_aiss_placement' ), 'content_look' => array( esc_html__( 'Appearance', 'ai-share-summarize' ), 'ayudawp_aiss_placement' ), 'layout' => array( esc_html__( 'Layout', 'ai-share-summarize' ), 'ayudawp_aiss_placement' ), 'content_preview' => array( esc_html__( 'Preview', 'ai-share-summarize' ), 'ayudawp_aiss_placement', 'aiss-preview-row' ), // Every row but the first folds away while the bar is off, so a // site without it sees one table. 'floating_bar' => array( esc_html__( 'Where it appears', 'ai-share-summarize' ), 'ayudawp_aiss_floating' ), 'floating_bar_buttons' => array( esc_html__( 'Buttons and order', 'ai-share-summarize' ), 'ayudawp_aiss_floating', 'aiss-bar-extra' ), 'floating_bar_compact' => array( $always, 'ayudawp_aiss_floating', 'aiss-bar-extra' ), 'floating_bar_look' => array( esc_html__( 'Appearance', 'ai-share-summarize' ), 'ayudawp_aiss_floating', 'aiss-bar-extra' ), 'floating_bar_behavior' => array( esc_html__( 'Behavior', 'ai-share-summarize' ), 'ayudawp_aiss_floating', 'aiss-bar-extra' ), 'floating_bar_preview' => array( esc_html__( 'Preview', 'ai-share-summarize' ), 'ayudawp_aiss_floating', 'aiss-bar-extra aiss-preview-row' ), 'prompt' => array( esc_html__( 'Prompt sent with every AI button', 'ai-share-summarize' ), 'ayudawp_aiss_prompt' ), 'accounts' => array( esc_html__( 'Accounts', 'ai-share-summarize' ), 'ayudawp_aiss_advanced' ), 'output' => array( esc_html__( 'Markup and campaign tracking', 'ai-share-summarize' ), 'ayudawp_aiss_advanced' ), 'seo_integration' => array( esc_html__( 'SEO integration', 'ai-share-summarize' ), 'ayudawp_aiss_advanced' ), 'data_retention' => array( esc_html__( 'Analytics data', 'ai-share-summarize' ), 'ayudawp_aiss_advanced' ), ); foreach ( $fields as $field_id => $field ) { add_settings_field( $field_id, $field[0], array( $this, 'ayudawp_' . $field_id . '_callback' ), 'ayudawp_aiss_settings', $field[1], isset( $field[2] ) ? array( 'class' => $field[2] ) : array() ); } // AI Summary fields, grouped since 2.5.0. field id => [ label, section ]. $summary_fields = array( 'ai_summary_mode' => array( esc_html__( 'How summaries are generated', 'ai-share-summarize' ), 'ayudawp_aiss_ai_summary' ), 'ai_summary_model' => array( esc_html__( 'AI model', 'ai-share-summarize' ), 'ayudawp_aiss_ai_summary' ), 'ai_summary_placement' => array( esc_html__( 'Content types and position', 'ai-share-summarize' ), 'ayudawp_aiss_summary_where' ), 'ai_summary_look' => array( esc_html__( 'Appearance', 'ai-share-summarize' ), 'ayudawp_aiss_summary_block' ), 'ai_summary_wording' => array( esc_html__( 'Label and format', 'ai-share-summarize' ), 'ayudawp_aiss_summary_block' ), 'ai_summary_visitor' => array( esc_html__( 'Let visitors generate it', 'ai-share-summarize' ), 'ayudawp_aiss_summary_visitor' ), 'ai_summary_custom' => array( esc_html__( 'Content below the summary', 'ai-share-summarize' ), 'ayudawp_aiss_summary_custom' ), ); foreach ( $summary_fields as $field_id => $field ) { add_settings_field( $field_id, $field[0], array( $this, 'ayudawp_' . $field_id . '_callback' ), 'ayudawp_aiss_summary_settings', $field[1] ); } } /** * 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 -- reading which settings tab to paint, not acting on anything; the value is only compared against a fixed list of tab slugs. $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 = 'AI Summaries & Share Buttons'; 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__( 'The ones your site offers. The two sections below pick from here.', 'ai-share-summarize' ) . '

'; } /** * "In-content buttons" section: where they go, the shortcode included (v2.8.0) */ public function ayudawp_section_callback() { /* translators: Plugin page URL. Change wordpress.org to your locale if needed (e.g., es.wordpress.org) */ $plugin_url = __( 'https://wordpress.org/plugins/ai-share-summarize/', 'ai-share-summarize' ); echo '

' . sprintf( /* translators: %s is the shortcode. */ esc_html__( 'Before or after the text of each post, and wherever you place the %s shortcode.', 'ai-share-summarize' ), '[ayudawp_share_buttons]' ); 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 '

'; } /** * A button as a small chip: its colour dot with the icon, and its name (v2.8.0) * * No style of its own: the catalog and the order lists are lists of * buttons, not samples, and the preview at the end of each section is where * the look shows. Until 2.7.x each one drew the real button in the block's * style, so the catalog changed size and colour with every style choice. * * @param string $key Button key. * @param string $label Button name. * @param int $size Icon size in pixels. */ private function ayudawp_render_chip_face( $key, $label, $size = 12 ) { $colors = ayudawp_aiss_get_platform_colors(); $color = isset( $colors[ $key ] ) ? $colors[ $key ] : '#50575e'; echo ''; echo '' . esc_html( $label ) . ''; } /** * Available buttons: the site's catalog (v2.8.0) * * Narrow chips grouped by kind, with two short notes below for the buttons * that behave unlike the rest. What is ticked here shows up at once in the * order lists of both sections, before saving. */ public function ayudawp_enabled_buttons_callback() { $options = get_option( 'ayudawp_aiss_options' ); $enabled = isset( $options['enabled_buttons'] ) && is_array( $options['enabled_buttons'] ) ? $options['enabled_buttons'] : array(); $buttons = ayudawp_aiss_get_available_buttons(); $actions = ayudawp_aiss_get_action_buttons(); $google = array( 'google_preferred' ); $groups = array( array( 'label' => __( 'Social networks', 'ai-share-summarize' ), 'keys' => array_values( array_diff( ayudawp_aiss_get_social_buttons(), $actions, $google ) ), ), array( 'label' => __( 'AI assistants', 'ai-share-summarize' ), 'keys' => ayudawp_aiss_get_ai_buttons(), ), array( 'label' => __( 'Browser actions', 'ai-share-summarize' ), 'keys' => $actions, ), array( 'label' => __( 'Google', 'ai-share-summarize' ), 'keys' => $google, ), ); echo '
'; foreach ( $groups as $group ) { echo '

' . esc_html( $group['label'] ) . '

'; foreach ( $group['keys'] as $key ) { if ( ! isset( $buttons[ $key ] ) ) { continue; } echo ''; } echo '
'; } echo '
'; /* * The two buttons that behave unlike the rest get one line each, side * by side, as plain descriptions. Until 2.7.x they were blue notice * boxes of a paragraph each. */ echo '
'; echo '

'; $this->ayudawp_render_note_dot( 'web_share' ); echo '' . esc_html__( 'Native share', 'ai-share-summarize' ) . ' ' . esc_html__( 'opens the share menu of the device. It only shows over HTTPS and in browsers that support it; where it cannot, it copies the link.', 'ai-share-summarize' ) . '

'; echo '

'; $this->ayudawp_render_note_dot( 'google_preferred' ); echo '' . esc_html__( 'Google preferred source', 'ai-share-summarize' ) . ' ' . esc_html__( 'takes readers to the Google tool that marks your site as a preferred source.', 'ai-share-summarize' ) . ' '; $google_domain = ayudawp_aiss_get_google_preferred_domain(); if ( '' === $google_domain ) { echo '' . esc_html__( 'This site cannot use it, so it will not be shown:', 'ai-share-summarize' ) . ' '; $home_path = wp_parse_url( home_url(), PHP_URL_PATH ); if ( (int) get_option( 'blog_public', 1 ) < 1 ) { echo esc_html__( 'the site asks search engines not to index it (Settings > Reading).', 'ai-share-summarize' ); } elseif ( is_string( $home_path ) && '' !== trim( $home_path, '/' ) ) { echo esc_html__( 'Google only accepts a domain or a subdomain, and the address of this site has a path.', 'ai-share-summarize' ); } else { echo esc_html__( 'a filter on this site hides it.', 'ai-share-summarize' ); } } else { /* translators: %s is the domain sent to Google, e.g. example.com */ echo esc_html( sprintf( __( 'Domain: %s', 'ai-share-summarize' ), $google_domain ) ); } echo '

'; echo '
'; } /** * The small icon of a button in front of its note (v2.8.0) * * @param string $key Button key. */ private function ayudawp_render_note_dot( $key ) { $colors = ayudawp_aiss_get_platform_colors(); $color = isset( $colors[ $key ] ) ? $colors[ $key ] : '#50575e'; echo ''; } /** * A group of native radios, stacked with
or in a row (v2.8.0) * * Core makes labels inside a fieldset of .form-table inline-block * (wp-admin/css/forms.css:966) and stacks them with a
, as on Settings > * Reading; the stacked lists here do the same, and the rows of the * appearance leave them side by side. The fieldset carries the name of the * group for screen readers: a legend, or the id of a visible label. * * @param string $field Option key. * @param array $choices Value => label, the default first. * @param string $current Current value. * @param string $legend Name of the group, for screen readers. * @param bool $inline Side by side instead of one per line. * @param string $labelledby Id of a visible label, instead of the legend. */ private function ayudawp_render_radios( $field, $choices, $current, $legend, $inline = false, $labelledby = '' ) { echo '
'; if ( '' === $labelledby ) { echo '' . esc_html( $legend ) . ''; } $first = true; foreach ( $choices as $value => $label ) { if ( ! $inline && ! $first ) { echo '
'; } $first = false; echo ''; } echo '
'; } /** * The order of the groups, one line (v2.8.0) * * @param string $field Option key. * @param array $choices Value => label. * @param string $current Current value. */ private function ayudawp_render_groups( $field, $choices, $current ) { $id = 'aiss-groups-' . str_replace( '_', '-', $field ); echo '
' . esc_html__( 'Groups:', 'ai-share-summarize' ) . ''; $this->ayudawp_render_radios( $field, $choices, $current, __( 'Order of the groups', 'ai-share-summarize' ), true, $id ); echo '
'; } /** * Two columns of buttons to tick and drag within their group (v2.8.0) * * One chip per button of the group, available or not, so ticking one in * the catalog makes it appear here before saving; the ones not available * are hidden. Every chip posts its place in the order, ticked or not, so * unticking one does not lose it, and a box that says whether it is chosen; * the box only shows while the section is set to choose. * * @param string $section 'content' or 'bar'. * @param array $enabled Available buttons. * @param array $orders Group => saved custom order of that group. * @param array $picked Buttons ticked. * @param bool $picking Whether the section is set to choose. * @param string $google_place Where the Google button goes. */ private function ayudawp_render_order_board( $section, $enabled, $orders, $picked, $picking, $google_place ) { $all = ayudawp_aiss_get_available_buttons(); $is_bar = 'bar' === $section; $names = array( 'picked' => $is_bar ? 'floating_bar_picked' : 'content_buttons_picked', 'ai' => $is_bar ? 'floating_bar_order_ai' : 'button_custom_order_ai', 'social' => $is_bar ? 'floating_bar_order_social' : 'button_custom_order_social', ); $columns = array( 'ai' => array( 'label' => __( 'AI assistants', 'ai-share-summarize' ), 'keys' => ayudawp_aiss_get_ai_buttons(), ), 'social' => array( 'label' => __( 'Social networks, actions and Google', 'ai-share-summarize' ), 'keys' => ayudawp_aiss_get_social_buttons(), ), ); echo '
'; foreach ( $columns as $group => $column ) { // The saved order, then the available ones as the front end adds // them, then the rest of the group. $order = self::ayudawp_build_sorted_list( isset( $orders[ $group ] ) ? (array) $orders[ $group ] : array(), $enabled, $column['keys'], $all ); $order = array_merge( $order, array_diff( $column['keys'], $order ) ); echo '

' . esc_html( $column['label'] ) . '

'; echo ''; if ( 'social' === $group ) { $google_notes = array( 'section' => __( 'Google preferred source goes in a section of its own, at the end of the block, whatever its place here.', 'ai-share-summarize' ), 'outside' => __( 'Google preferred source goes outside the block, only where you place its shortcode.', 'ai-share-summarize' ), ); foreach ( $google_notes as $place => $note ) { echo '

' . esc_html( $note ) . '

'; } } echo '
'; } echo '
'; } /** * The order of the groups, by the words of each section (v2.8.0) * * @return array Value => label for the content's `button_order`. */ private static function ayudawp_group_choices() { return array( 'ai' => __( 'AI first (default)', 'ai-share-summarize' ), 'social' => __( 'Social networks first', 'ai-share-summarize' ), 'mixed' => __( 'Mixed, one from each', 'ai-share-summarize' ), ); } /** * In-content buttons: which ones and their order (v2.8.0) * * One control for both, live: what is ticked in the catalog shows up here * at once to be ordered, which until 2.7.x needed a save first. */ public function ayudawp_content_buttons_callback() { $options = get_option( 'ayudawp_aiss_options' ); $enabled = isset( $options['enabled_buttons'] ) && is_array( $options['enabled_buttons'] ) ? $options['enabled_buttons'] : array(); $mode = isset( $options['content_buttons_mode'] ) && 'pick' === $options['content_buttons_mode'] ? 'pick' : 'all'; $picked = isset( $options['content_buttons_picked'] ) && is_array( $options['content_buttons_picked'] ) ? $options['content_buttons_picked'] : $enabled; $order = isset( $options['button_order'] ) ? (string) $options['button_order'] : 'ayudawp_ai_first'; $this->ayudawp_render_radios( 'content_buttons_mode', array( 'all' => __( 'All the available ones (default)', 'ai-share-summarize' ), 'pick' => __( 'Choose', 'ai-share-summarize' ), ), $mode, __( 'Buttons and order', 'ai-share-summarize' ) ); // The content keeps the values `button_order` always had. $groups = array(); foreach ( self::ayudawp_group_choices() as $value => $label ) { $groups[ 'ayudawp_' . $value . ( 'mixed' === $value ? '' : '_first' ) ] = $label; } $this->ayudawp_render_groups( 'button_order', $groups, $order ); $this->ayudawp_render_order_board( 'content', $enabled, array( 'ai' => isset( $options['button_custom_order_ai'] ) ? $options['button_custom_order_ai'] : array(), 'social' => isset( $options['button_custom_order_social'] ) ? $options['button_custom_order_social'] : array(), ), $picked, 'pick' === $mode, ayudawp_aiss_get_google_preferred_placement( $options ) ); echo '

' . esc_html__( 'Drag to order within each group. What you tick under "Available buttons" shows up here at once, before saving.', 'ai-share-summarize' ) . '

'; } /** * How many in sight: the three choices of both sections (v2.8.0) * * @param string $field Mode key. * @param string $count Key of the number of buttons in sight. * @param string $mode Current mode. * @param int $visible Current number. * @param string $legend Name of the group for screen readers. */ private function ayudawp_render_compact( $field, $count, $mode, $visible, $legend ) { echo '
' . esc_html( $legend ) . ''; echo ' '; echo ' ' . esc_html__( '(default)', 'ai-share-summarize' ) . '
'; echo '
'; echo ''; echo '
'; } /** * In-content buttons: how many in sight on phones (v2.5.0, v2.8.0) */ public function ayudawp_mobile_compact_callback() { $options = get_option( 'ayudawp_aiss_options' ); $mode = isset( $options['mobile_compact'] ) && in_array( $options['mobile_compact'], ayudawp_aiss_get_floating_bar_choices( 'compact' ), true ) ? $options['mobile_compact'] : 'partial'; $visible = isset( $options['mobile_compact_visible'] ) ? max( 1, min( 5, (int) $options['mobile_compact_visible'] ) ) : 3; $this->ayudawp_render_compact( 'mobile_compact', 'mobile_compact_visible', $mode, $visible, __( 'In sight on phones', 'ai-share-summarize' ) ); echo '

' . esc_html__( 'On desktop all of them show. The ones in sight are the first in the order above.', 'ai-share-summarize' ) . '

'; } /** * The rows of an appearance: one line per setting (v2.8.0) * * @param array $rows Field => [ label, choices, current ]. * @param string $prefix Prefix of the label ids. */ private function ayudawp_render_look_rows( $rows, $prefix ) { foreach ( $rows as $field => $row ) { $id = $prefix . '-' . str_replace( '_', '-', $field ); echo '
' . esc_html( $row[0] ) . ''; $this->ayudawp_render_radios( $field, $row[1], $row[2], $row[0], true, $id ); echo '
'; } } /** * The choices of each setting of the look, the default first (v2.8.0) * * @param string $setting 'colors', 'corners', 'size' or 'dark'. * @param bool $bar Whether the list is for the floating bar. * @return array Value => label. */ private static function ayudawp_look_labels( $setting, $bar = false ) { $labels = array( 'colors' => array( 'minimal' => __( 'Minimal (default)', 'ai-share-summarize' ), 'brand' => __( 'Brand colors', 'ai-share-summarize' ), 'outline' => __( 'Outline', 'ai-share-summarize' ), 'dark' => __( 'For dark backgrounds', 'ai-share-summarize' ), 'custom' => __( 'Custom colors', 'ai-share-summarize' ), ), 'corners' => array( 'rounded' => __( 'Rounded (default)', 'ai-share-summarize' ), 'circle' => __( 'Circular', 'ai-share-summarize' ), 'square' => __( 'Square', 'ai-share-summarize' ), ), 'size' => array( 'normal' => __( 'Normal (default)', 'ai-share-summarize' ), 'compact' => __( 'Compact', 'ai-share-summarize' ), 'large' => __( 'Large', 'ai-share-summarize' ), 'fluid' => __( 'Fluid: fill the available width', 'ai-share-summarize' ), ), 'dark' => array( 'disabled' => __( 'Disabled (default)', 'ai-share-summarize' ), 'auto' => __( 'Automatic', 'ai-share-summarize' ), ), ); $list = isset( $labels[ $setting ] ) ? $labels[ $setting ] : array(); if ( $bar && 'size' === $setting ) { unset( $list['fluid'] ); } return $list; } /** * In-content buttons: appearance (v2.8.0) * * One line per setting, label on the left and the radios in a row. "Icons * only" is now what a button carries, not a colour, and the corners apply * to every button. */ public function ayudawp_content_look_callback() { $options = get_option( 'ayudawp_aiss_options' ); $look = ayudawp_aiss_get_button_look( $options ); echo '
'; $this->ayudawp_render_look_rows( array( 'button_content' => array( __( 'Button', 'ai-share-summarize' ), array( 'text' => __( 'Text only (default)', 'ai-share-summarize' ), 'both' => __( 'Icon and text', 'ai-share-summarize' ), 'icon' => __( 'Icon only', 'ai-share-summarize' ), ), $look['content'], ), 'button_colors' => array( __( 'Color', 'ai-share-summarize' ), self::ayudawp_look_labels( 'colors' ), $look['colors'] ), ), 'aiss-look' ); // Custom colour pickers: shown while the content or the bar uses them. $custom_bg = isset( $options['custom_color_bg'] ) ? $options['custom_color_bg'] : '#333333'; $custom_text = isset( $options['custom_color_text'] ) ? $options['custom_color_text'] : '#ffffff'; $bar_look = ayudawp_aiss_get_floating_bar_look( $options ); $show_custom = 'custom' === $look['colors'] || 'custom' === $bar_look['colors']; ?>
>
ayudawp_render_look_rows( array( 'button_corners' => array( __( 'Corners', 'ai-share-summarize' ), self::ayudawp_look_labels( 'corners' ), $look['corners'] ), 'button_size' => array( __( 'Size', 'ai-share-summarize' ), self::ayudawp_look_labels( 'size' ), $look['size'] ), 'dark_mode_adaptation' => array( __( 'Dark backgrounds', 'ai-share-summarize' ), self::ayudawp_look_labels( 'dark' ), $look['dark'] ), ), 'aiss-look' ); echo '
'; echo '

' . esc_html__( 'Automatic measures the real background behind the buttons and adapts the ones that would disappear on it. It costs a small script on the page.', 'ai-share-summarize' ) . '

'; } /** * In-content buttons: what only the content has (v2.8.0) * * Alignment, separator lines, the titles and where the Google button goes, * which until 2.7.x were spread over three rows of two sections. */ public function ayudawp_layout_callback() { $options = get_option( 'ayudawp_aiss_options' ); $alignment = isset( $options['button_alignment'] ) ? $options['button_alignment'] : 'left'; $separator_top = isset( $options['separator_top'] ) ? $options['separator_top'] : true; $separator_bottom = isset( $options['separator_bottom'] ) ? $options['separator_bottom'] : true; $text = isset( $options['title_text'] ) ? $options['title_text'] : ''; $style = isset( $options['title_style'] ) ? $options['title_style'] : 'span'; $ai_title = isset( $options['ai_section_title'] ) ? $options['ai_section_title'] : ''; $social_title = isset( $options['social_section_title'] ) ? $options['social_section_title'] : ''; $google_place = ayudawp_aiss_get_google_preferred_placement( $options ); $google_title = isset( $options['google_section_title'] ) ? (string) $options['google_section_title'] : ''; $styles = array( 'span' => __( 'Span, plain text (default)', 'ai-share-summarize' ), 'h3' => __( 'Heading 3 (h3)', 'ai-share-summarize' ), 'h4' => __( 'Heading 4 (h4)', 'ai-share-summarize' ), 'h5' => __( 'Heading 5 (h5)', 'ai-share-summarize' ), 'h6' => __( 'Heading 6 (h6)', 'ai-share-summarize' ), ); $google_opts = array( 'social' => __( 'With the social networks', 'ai-share-summarize' ), 'section' => __( 'In a section of its own, at the end of the block', 'ai-share-summarize' ), 'outside' => __( 'Outside the block, only where you place the shortcode', 'ai-share-summarize' ), ); ?>
ayudawp_render_radios( 'button_alignment', array( 'left' => __( 'Left (default)', 'ai-share-summarize' ), 'center' => __( 'Centered', 'ai-share-summarize' ), ), $alignment, __( 'Alignment', 'ai-share-summarize' ), false, 'aiss-layout-align' ); ?>

>

[ayudawp_share_buttons buttons="google_preferred"]

'; echo '
'; // Not settings: they only pick which sample to draw, and options.php // ignores fields outside the plugin's option. echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; /* * Sandboxed with same origin and no scripts (v2.8.0): nothing inside the * sample runs, and this page can still reach into it to open the compact * mode, add the dark background class and reveal the native share. */ echo ''; echo '

' . esc_html__( 'The block as these settings draw it, before you save. Your theme may change the fonts and the spacing.', 'ai-share-summarize' ) . '

'; echo ''; } /** * Floating bar section: what it is (v2.8.0) */ public function ayudawp_floating_section_callback() { echo '

' . esc_html__( 'Pinned to an edge of the screen while reading. It can appear where the content buttons do not, and the other way round.', 'ai-share-summarize' ) . '

'; } /** * Floating bar: where it appears (v2.5.0, own section v2.8.0) * * Same table as the buttons, with the positions the bar actually has: an * edge of the viewport, not a place in the content. That is also how it is * switched on — a row ticked is a page where the bar shows — so there is no * separate on/off radio. */ public function ayudawp_floating_bar_callback() { $this->ayudawp_placements_callback( array( 'key' => 'floating_bar_placements' ) ); echo '

' . esc_html__( 'With nothing ticked the bar is off and the rest of this section folds away.', 'ai-share-summarize' ) . '

'; } /** * Floating bar: which buttons and their order (v2.8.0) * * As in the content, or its own: then the groups and the chips show up, * starting from the content's list the first time. */ public function ayudawp_floating_bar_buttons_callback() { $options = get_option( 'ayudawp_aiss_options' ); $settings = ayudawp_aiss_get_floating_bar_settings( $options ); $enabled = isset( $options['enabled_buttons'] ) && is_array( $options['enabled_buttons'] ) ? $options['enabled_buttons'] : array(); $fresh = null === $settings['picked']; $this->ayudawp_render_radios( 'floating_bar_buttons', array( 'inherit' => __( 'As in the content (default)', 'ai-share-summarize' ), 'pick' => __( 'Choose and order its own', 'ai-share-summarize' ), ), $settings['buttons'], __( 'Buttons and order', 'ai-share-summarize' ) ); /* * Never saved: the bar's own list starts as the content's, with its * groups and its order. The script copies them again from the form as * it is when "Choose" is first picked, so that is what is seen. */ if ( $fresh ) { $content_groups = array( 'ayudawp_social_first' => 'social', 'ayudawp_mixed' => 'mixed', ); $button_order = isset( $options['button_order'] ) ? (string) $options['button_order'] : ''; $groups = isset( $content_groups[ $button_order ] ) ? $content_groups[ $button_order ] : 'ai'; $picked = ayudawp_aiss_get_content_ordered_buttons( (array) $options ); } else { $groups = $settings['groups']; $picked = $settings['picked']; } echo '
'; $this->ayudawp_render_groups( 'floating_bar_groups', self::ayudawp_group_choices(), $groups ); $this->ayudawp_render_order_board( 'bar', $enabled, array( 'ai' => null !== $settings['order_ai'] ? $settings['order_ai'] : ( isset( $options['button_custom_order_ai'] ) ? $options['button_custom_order_ai'] : array() ), 'social' => null !== $settings['order_social'] ? $settings['order_social'] : ( isset( $options['button_custom_order_social'] ) ? $options['button_custom_order_social'] : array() ), ), $picked, true, ayudawp_aiss_get_google_preferred_placement( $options ) ); echo '

' . esc_html__( 'Tick the ones the bar shows and drag them to order them. They start from the content\'s list.', 'ai-share-summarize' ) . '

'; echo '
'; } /** * Floating bar: how many in sight, always (v2.8.0) */ public function ayudawp_floating_bar_compact_callback() { $settings = ayudawp_aiss_get_floating_bar_settings(); $this->ayudawp_render_compact( 'floating_bar_compact', 'floating_bar_compact_visible', $settings['compact'], $settings['compact_visible'], __( 'In sight in the bar', 'ai-share-summarize' ) ); echo '

' . esc_html__( 'The rest open in a panel beside the bar, which does not grow. When only one would be left over, it is shown.', 'ai-share-summarize' ) . '

'; } /** * Floating bar: appearance, the content's or its own (v2.8.0) * * The same rows and words as the content, without "Button" (the bar is * always icons) and without "Fluid". */ public function ayudawp_floating_bar_look_callback() { $options = get_option( 'ayudawp_aiss_options' ); $settings = ayudawp_aiss_get_floating_bar_settings( $options ); $content = ayudawp_aiss_get_button_look( $options ); $fresh = ! isset( $options['floating_bar_color'] ); $this->ayudawp_render_radios( 'floating_bar_look', array( 'inherit' => __( 'As in the content (default)', 'ai-share-summarize' ), 'own' => __( 'Its own', 'ai-share-summarize' ), ), $settings['look'], __( 'Appearance', 'ai-share-summarize' ) ); // Never saved: its own look starts as the content's. $own = array( 'color' => $fresh ? $content['colors'] : $settings['color'], 'corners' => $fresh ? $content['corners'] : $settings['corners'], 'size' => $fresh ? ( 'fluid' === $content['size'] ? 'normal' : $content['size'] ) : $settings['size'], 'dark' => $fresh ? $content['dark'] : $settings['dark'], ); echo '
'; $this->ayudawp_render_look_rows( array( 'floating_bar_color' => array( __( 'Color', 'ai-share-summarize' ), self::ayudawp_look_labels( 'colors', true ), $own['color'] ), 'floating_bar_corners' => array( __( 'Corners', 'ai-share-summarize' ), self::ayudawp_look_labels( 'corners', true ), $own['corners'] ), 'floating_bar_size' => array( __( 'Size', 'ai-share-summarize' ), self::ayudawp_look_labels( 'size', true ), $own['size'] ), 'floating_bar_dark' => array( __( 'Dark backgrounds', 'ai-share-summarize' ), self::ayudawp_look_labels( 'dark', true ), $own['dark'] ), ), 'aiss-bar-look' ); echo '
'; echo '

' . esc_html__( 'The bar is always icons. As in the content, it takes the color, the corners, the size and the dark backgrounds setting from there. Custom colors are the two set in the content\'s appearance.', 'ai-share-summarize' ) . '

'; } /** * Floating bar: the preview, last row of the section (v2.8.0) * * A sample bar on a page of grey blocks, drawn by the script from the * form as it is now. Hidden until the script fills it. */ public function ayudawp_floating_bar_preview_callback() { $views = array( 'right' => __( 'Right edge', 'ai-share-summarize' ), 'left' => __( 'Left edge', 'ai-share-summarize' ), 'bottom' => __( 'Bottom', 'ai-share-summarize' ), 'phone' => __( 'Phone', 'ai-share-summarize' ), ); echo '
'; echo '
'; // Not settings: they only pick which sample to draw. echo ''; foreach ( $views as $value => $label ) { echo ''; } echo ''; echo ''; echo '
'; echo ''; echo '

'; echo '

' . esc_html__( 'A sample, not your theme. It follows these rows and the content section as you change them, before you save.', 'ai-share-summarize' ) . '

'; // One sample of every button, for the script to copy into the preview. echo ''; echo '
'; } // ========================================== // Settings field callbacks // ========================================== /** * 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

ayudawp_placements_field_name( $key ); $listing_keys = array_intersect_key( $targets, array( 'home' => 1, 'archive' => 1 ) ); $singular = array_diff_key( $targets, $listing_keys ); $groups = array( array( 'label' => esc_html__( 'Single content', 'ai-share-summarize' ), 'targets' => $singular, ), ); if ( ! empty( $listing_keys ) ) { // WordPress calls these archives, so the screen does too. $groups[] = array( 'label' => esc_html__( 'Archives', 'ai-share-summarize' ), 'targets' => $listing_keys, ); } /* * Two columns: a site with several public post types plus the archives * makes for a tall single column, and this screen paints the table * twice (buttons and floating bar). */ /* * Marker for the sanitizer (v2.8.0): this table came, so a destination * that is not ticked is off. Without it, a save that does not carry the * table keeps the stored one. The summary's table posts elsewhere. */ if ( 'ai_summary_placements' !== $key ) { echo ''; } echo '
'; foreach ( $groups as $group ) { echo '
'; echo '

' . esc_html( $group['label'] ) . '

'; foreach ( $group['targets'] as $target => $label ) { $on = isset( $placements[ $target ] ); $position = $on ? $placements[ $target ] : ayudawp_aiss_get_default_placement_position( $key ); $id = 'aiss-placement-' . $key . '-' . $target; ?>
>
'; } echo '
'; if ( 'placements' === $key ) { echo '

' . sprintf( /* translators: %s is the shortcode name. */ esc_html__( 'With nothing ticked, the buttons only appear where you place the %s shortcode.', 'ai-share-summarize' ), '[ayudawp_share_buttons]' ) . '

'; } } /** * Which option a placements table posts into (v2.5.0) * * The summary keeps its own option since 2.3.0, so its table has to post * there and not into the buttons one. * * @param string $key Placements map key. * @return string Option name. */ private function ayudawp_placements_field_name( $key ) { return ( 'ai_summary_placements' === $key ) ? 'ayudawp_aiss_summary_options' : 'ayudawp_aiss_options'; } /** * Floating bar: behaviour, the three checkboxes it had since 2.5.0 */ public function ayudawp_floating_bar_behavior_callback() { $options = get_option( 'ayudawp_aiss_options' ); $autohide = ! empty( $options['floating_bar_autohide'] ); $hide_mobile = ! isset( $options['floating_bar_hide_mobile'] ) || ! empty( $options['floating_bar_hide_mobile'] ); $hide_inline = ! empty( $options['floating_bar_hide_with_inline'] ); ?>

__( 'Forever (default)', 'ai-share-summarize' ), '1_month' => __( '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' ), ); ?>

' . esc_html__( 'Tick the content types that get a summary, and where it goes on each. Nothing ticked means no summaries are generated automatically.', 'ai-share-summarize' ) . '

'; $this->ayudawp_placements_callback( array( 'key' => 'ai_summary_placements' ) ); echo '

' . esc_html__( 'The positions relative to the buttons fall back to the start of the content on posts where the buttons are not shown. This list is independent from where the buttons appear.', 'ai-share-summarize' ) . '

'; } /** * Appearance of the summary block, with a live preview (v2.5.0) * * Five styles times three icon positions times open or closed is more * combinations than anyone wants to discover by saving and reloading, so the * sample below is rendered with the front-end stylesheet and repainted as * the controls change. */ public function ayudawp_ai_summary_look_callback() { $options = ayudawp_aiss_get_summary_options(); $style = isset( $options['ai_summary_style'] ) ? $options['ai_summary_style'] : 'minimal'; $icon_pos = isset( $options['ai_summary_icon_position'] ) ? $options['ai_summary_icon_position'] : 'left'; $collapsed = isset( $options['ai_summary_collapsed_default'] ) ? $options['ai_summary_collapsed_default'] : true; $label = ! empty( $options['ai_summary_label'] ) ? $options['ai_summary_label'] : __( 'TL;DR (AI Generated)', 'ai-share-summarize' ); $styles = array( 'minimal' => 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' ), ); $icon_positions = array( 'left' => esc_html__( 'Left (default)', 'ai-share-summarize' ), 'right' => esc_html__( 'Right', 'ai-share-summarize' ), 'hidden' => esc_html__( 'Hidden', 'ai-share-summarize' ), ); $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'; ?>
$style_label ) : ?>
$icon_label ) : ?>

ayudawp_render_summary_preview( $style, $icon_pos, $collapsed, $label, $custom_bg, $custom_text ); ?>

ayudawp-aiss-custom', 'ayudawp_aiss_custom_visible' ); ?>

'Permission denied.' ) ); } AyudaWP_AISS_Database::ayudawp_delete_all_data(); wp_send_json_success(); } /** * AJAX handler: the buttons block as a visitor would see it, from the unsaved form (v2.8.0) * * Read-only: it saves nothing and touches nothing. The values go through * the same sanitizer as the Save button and the same renderer as the front * end, so the preview is the block itself and not a copy of its logic that * could drift from it. Only the keys that shape the block are read; the * rest of the form (prompt, accounts, analytics) is ignored, and so are the * shortcode-only keys, which the sanitizer never returns. */ public function ayudawp_ajax_block_preview() { check_ajax_referer( 'aiss_block_preview', 'nonce' ); // The capability of the settings page that sends it. if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'message' => 'Permission denied.' ), 403 ); } $raw = ( isset( $_POST['options'] ) && is_array( $_POST['options'] ) ) ? map_deep( wp_unslash( $_POST['options'] ), 'sanitize_text_field' ) : array(); $keys = array( 'enabled_buttons', // Which of them and the look, since 2.8.0. 'content_buttons_mode', 'content_buttons_picked', 'button_content', 'button_colors', 'button_corners', 'button_size', 'button_alignment', 'separator_top', 'separator_bottom', 'button_order', 'button_custom_order_ai', 'button_custom_order_social', 'title_text', 'title_style', 'ai_section_title', 'social_section_title', 'google_preferred_placement', 'google_section_title', 'mobile_compact', 'mobile_compact_visible', 'custom_color_bg', 'custom_color_text', 'seo_button_type', ); $options = ayudawp_aiss_validate_options( array_intersect_key( $raw, array_flip( $keys ) ) ); $html = AyudaWP_AISS_Buttons::ayudawp_generate_buttons_html( isset( $options['enabled_buttons'] ) ? $options['enabled_buttons'] : array(), $options, home_url( '/' ), __( 'Sample post', 'ai-share-summarize' ), 0 ); // Same allowlist as the block printed on the front end. wp_send_json_success( array( 'html' => wp_kses( $html, ayudawp_aiss_kses_content_blocks() ) ) ); } /** * 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 "AI Summaries & Share Buttons".', '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' ); ?>