'X (Twitter)', 'linkedin' => 'LinkedIn', 'facebook' => 'Facebook', 'telegram' => 'Telegram', 'whatsapp' => 'WhatsApp', 'email' => 'Email', 'raindrop' => 'Raindrop', 'reddit' => 'Reddit', 'bluesky' => 'Bluesky', 'line' => 'LINE', 'mastodon' => 'Mastodon', 'threads' => 'Threads', 'pinterest' => 'Pinterest', 'claude' => 'Claude AI', 'chatgpt' => 'ChatGPT', 'google_ai' => 'Google AI', 'gemini' => 'Gemini', 'grok' => 'Grok', 'perplexity' => 'Perplexity', 'deepseek' => 'DeepSeek', 'mistral' => 'Mistral AI', 'copilot' => 'Microsoft Copilot', 'qwen' => 'Qwen', 'meta_ai' => 'Meta AI', ); } /** * Get social media buttons list * * @return array Social media button keys. */ function ayudawp_aiss_get_social_buttons() { return array( 'twitter', 'linkedin', 'facebook', 'telegram', 'whatsapp', 'email', 'raindrop', 'reddit', 'bluesky', 'line', 'mastodon', 'threads', 'pinterest' ); } /** * Get AI buttons list * * @return array AI button keys. */ function ayudawp_aiss_get_ai_buttons() { return array( 'claude', 'chatgpt', 'google_ai', 'gemini', 'grok', 'perplexity', 'deepseek', 'mistral', 'copilot', 'qwen', 'meta_ai' ); } /** * Sanitize a title_style value against an allowlist of HTML tag names. * * The value is emitted in tag-name position (`<{$tag}>`), where `esc_attr()` * is not enough: it does not encode spaces or `=`, so an attacker could turn * the opening tag into an arbitrary element with event-handler attributes. * Anything outside the allowlist falls back to `span`. * * @since 2.0.4 * @param string $value Untrusted tag name. * @return string Safe tag name from the allowlist. */ function ayudawp_aiss_sanitize_title_style( $value ) { $allowed = array( 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span', 'div' ); $value = is_string( $value ) ? strtolower( trim( $value ) ) : ''; return in_array( $value, $allowed, true ) ? $value : 'span'; } /** * Validate and sanitize plugin options * * @param array $input Raw input data. * @return array Validated and sanitized options. */ function ayudawp_aiss_validate_options( $input ) { $validated = array(); // Text fields. $text_fields = array( 'auto_insert_position', 'twitter_handle', 'title_text', 'title_style', 'button_order', 'button_alignment', 'button_colors', 'icon_style', 'seo_button_type', 'data_retention', 'button_size', 'ai_section_title', 'social_section_title', 'mastodon_instance', 'custom_color_bg', 'custom_color_text', 'dark_mode_adaptation', 'ai_summary_position', ); $textarea_fields = array( 'default_prompt', 'custom_text' ); $array_fields = array( 'enabled_buttons', 'display_locations', 'auto_insert_content_types', 'button_custom_order_ai', 'button_custom_order_social', 'ai_summary_content_types' ); $boolean_fields = array( 'show_icons', 'delete_data_on_uninstall', 'exclude_noindex', 'ai_summary_enabled', 'ai_summary_use_extractive_fallback', 'ai_summary_collapsed_default', 'ai_summary_frontend_button', 'ai_summary_frontend_force_extractive', ); foreach ( $text_fields as $field ) { if ( isset( $input[ $field ] ) ) { $validated[ $field ] = sanitize_text_field( $input[ $field ] ); } } // title_style is emitted in tag-name position; restrict it to an allowlist. if ( isset( $validated['title_style'] ) ) { $validated['title_style'] = ayudawp_aiss_sanitize_title_style( $validated['title_style'] ); } foreach ( $textarea_fields as $field ) { if ( isset( $input[ $field ] ) ) { $validated[ $field ] = sanitize_textarea_field( $input[ $field ] ); } } foreach ( $array_fields as $field ) { if ( isset( $input[ $field ] ) && is_array( $input[ $field ] ) ) { $validated[ $field ] = array_map( 'sanitize_text_field', $input[ $field ] ); } else { $validated[ $field ] = array(); } } foreach ( $boolean_fields as $field ) { $validated[ $field ] = isset( $input[ $field ] ) ? (bool) $input[ $field ] : false; } // Validate seo_button_type. if ( isset( $validated['seo_button_type'] ) && ! in_array( $validated['seo_button_type'], array( 'link', 'button' ), true ) ) { $validated['seo_button_type'] = 'link'; } // Validate button_alignment. if ( isset( $validated['button_alignment'] ) && ! in_array( $validated['button_alignment'], array( 'left', 'center' ), true ) ) { $validated['button_alignment'] = 'left'; } // Validate data_retention. $valid_retention = array( '1_month', '3_months', '6_months', '1_year', 'forever' ); if ( isset( $validated['data_retention'] ) && ! in_array( $validated['data_retention'], $valid_retention, true ) ) { $validated['data_retention'] = 'forever'; } // Validate button_size. $valid_sizes = array( 'compact', 'normal', 'large', 'fluid' ); if ( isset( $validated['button_size'] ) && ! in_array( $validated['button_size'], $valid_sizes, true ) ) { $validated['button_size'] = 'normal'; } // Validate button_colors. $valid_styles = array( 'minimal', 'brand', 'outline', 'dark', 'icons-only', 'custom' ); if ( isset( $validated['button_colors'] ) && ! in_array( $validated['button_colors'], $valid_styles, true ) ) { $validated['button_colors'] = 'minimal'; } // Validate dark_mode_adaptation. $valid_dark_modes = array( 'disabled', 'auto' ); if ( isset( $validated['dark_mode_adaptation'] ) && ! in_array( $validated['dark_mode_adaptation'], $valid_dark_modes, true ) ) { $validated['dark_mode_adaptation'] = 'disabled'; } // Validate ai_summary_position (v2.0.0). $valid_summary_positions = array( 'before_buttons', 'after_buttons', 'before_content', 'disabled' ); if ( isset( $validated['ai_summary_position'] ) && ! in_array( $validated['ai_summary_position'], $valid_summary_positions, true ) ) { $validated['ai_summary_position'] = 'before_buttons'; } // Validate ai_summary_sentences (v2.0.0) — integer in 1..5. $validated['ai_summary_sentences'] = isset( $input['ai_summary_sentences'] ) ? max( 1, min( 5, absint( $input['ai_summary_sentences'] ) ) ) : 3; // Sanitize hex colors. if ( isset( $validated['custom_color_bg'] ) ) { $validated['custom_color_bg'] = sanitize_hex_color( $validated['custom_color_bg'] ); } if ( isset( $validated['custom_color_text'] ) ) { $validated['custom_color_text'] = sanitize_hex_color( $validated['custom_color_text'] ); } // Sanitize mastodon instance URL. if ( isset( $validated['mastodon_instance'] ) ) { $validated['mastodon_instance'] = sanitize_text_field( wp_unslash( $validated['mastodon_instance'] ) ); // Remove protocol and trailing slashes. $validated['mastodon_instance'] = preg_replace( '#^https?://#', '', $validated['mastodon_instance'] ); $validated['mastodon_instance'] = rtrim( $validated['mastodon_instance'], '/' ); } return $validated; } /** * Check if buttons should be displayed in current context * * @return bool True if buttons should be displayed. */ function ayudawp_aiss_should_display_buttons() { $options = get_option( 'ayudawp_aiss_options' ); $locations = isset( $options['display_locations'] ) ? $options['display_locations'] : array(); $content_types = isset( $options['auto_insert_content_types'] ) ? $options['auto_insert_content_types'] : array(); if ( empty( $locations ) ) { return false; } if ( is_singular() ) { $post_type = get_post_type(); if ( 'post' === $post_type && in_array( 'posts', $locations, true ) && in_array( 'post', $content_types, true ) ) { return true; } if ( 'page' === $post_type && in_array( 'pages', $locations, true ) && in_array( 'page', $content_types, true ) ) { return true; } if ( 'post' !== $post_type && 'page' !== $post_type && in_array( 'cpt', $locations, true ) && in_array( $post_type, $content_types, true ) ) { return true; } } if ( ( is_archive() || is_category() || is_tag() ) && in_array( 'archives', $locations, true ) ) { return true; } if ( is_home() && in_array( 'home', $locations, true ) ) { return true; } return false; } /** * Check if a specific post is excluded from showing buttons * * Checks both the meta box exclusion and SEO noindex status. * * @since 1.4.0 * @param int $post_id Post ID to check. * @return bool True if post is excluded, false otherwise. */ function ayudawp_aiss_is_post_excluded( $post_id ) { if ( ! $post_id ) { return false; } // Check meta box exclusion. if ( class_exists( 'AyudaWP_AISS_Meta_Box' ) && AyudaWP_AISS_Meta_Box::ayudawp_is_post_excluded( $post_id ) ) { return true; } // Check SEO noindex exclusion if enabled. $options = get_option( 'ayudawp_aiss_options' ); $exclude_noindex = isset( $options['exclude_noindex'] ) ? $options['exclude_noindex'] : true; if ( $exclude_noindex && class_exists( 'AyudaWP_AISS_SEO_Integration' ) ) { if ( AyudaWP_AISS_SEO_Integration::ayudawp_is_post_noindex( $post_id ) ) { return true; } } return false; } /** * Detect whether the canonical "AI" plugin (wordpress.org/plugins/ai/) is active * * Used to surface a hint when AI generation starts failing silently, * because that plugin ships an opt-in Connector approval system * (Tools > Connector Approvals) that intercepts and blocks calls to * `wp_ai_client_prompt()` from plugins it hasn't approved yet — without * exposing a programmatic filter for plugins to request approval, so the * only signal we have is a generic call failure when the canonical plugin * is around. * * @since 2.0.0 * @return bool */ function ayudawp_aiss_is_canonical_ai_plugin_active() { if ( ! function_exists( 'is_plugin_active' ) ) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; } return is_plugin_active( 'ai/ai.php' ); } /** * Resolve the post types where the AI summary feature applies (v2.0.0) * * Independent from the buttons' `auto_insert_content_types` so the admin * can choose, for example, to render buttons on posts only but generate * summaries on posts + products. Falls back to the buttons list when the * dedicated option has not been set yet (covers pre-migration sites). * * @since 2.0.0 * @return array List of post type slugs. */ function ayudawp_aiss_get_summary_post_types() { $options = get_option( 'ayudawp_aiss_options', array() ); if ( isset( $options['ai_summary_content_types'] ) && is_array( $options['ai_summary_content_types'] ) ) { return array_values( array_filter( array_map( 'strval', $options['ai_summary_content_types'] ) ) ); } if ( isset( $options['auto_insert_content_types'] ) && is_array( $options['auto_insert_content_types'] ) ) { return array_values( array_filter( array_map( 'strval', $options['auto_insert_content_types'] ) ) ); } return array( 'post' ); } /** * Check whether the AI summary feature applies to a given post (v2.0.0) * * Combines the per-post exclusion (meta box / noindex) with the new * `ai_summary_content_types` post-type whitelist. Centralised here so * the meta registration, save-post handler, frontend renderer and REST * endpoint all agree on the rule. * * @since 2.0.0 * @param int $post_id Post ID to check. * @return bool True when the summary should be generated and shown. */ function ayudawp_aiss_should_apply_summary( $post_id ) { $post_id = (int) $post_id; if ( ! $post_id ) { return false; } if ( ayudawp_aiss_is_post_excluded( $post_id ) ) { return false; } $post_type = get_post_type( $post_id ); if ( ! $post_type ) { return false; } $allowed = ayudawp_aiss_get_summary_post_types(); return in_array( $post_type, $allowed, true ); } /** * Get platform brand colors configuration * * Centralized color definitions used across CSS, JS, and admin. * * @since 1.6.0 * @return array Platform colors as key => hex pairs. */ function ayudawp_aiss_get_platform_colors() { return array( 'twitter' => '#000000', 'linkedin' => '#0077b5', 'facebook' => '#1877f2', 'telegram' => '#26A5E4', 'whatsapp' => '#25d366', 'email' => '#6c757d', 'raindrop' => '#0F66E3', 'reddit' => '#FF4500', 'bluesky' => '#0085FF', 'line' => '#00C300', 'mastodon' => '#6364FF', 'threads' => '#000000', 'pinterest' => '#BD081C', 'claude' => '#D97757', 'chatgpt' => '#10a37f', 'google_ai' => '#E84430', 'gemini' => '#8E75B2', 'grok' => '#000000', 'perplexity' => '#20808D', 'deepseek' => '#4D6BFE', 'mistral' => '#F7D046', 'copilot' => '#6264A7', 'qwen' => '#615CED', 'meta_ai' => '#0081FB', ); } /** * Enqueue frontend CSS, JS and localized data * * Centralised helper so both auto-insert (class-frontend) and * shortcode (class-shortcode) share the same enqueue logic. * Safe to call multiple times — assets are only loaded once. * * @since 1.7.2 */ function ayudawp_aiss_enqueue_frontend_assets() { if ( wp_style_is( 'ayudawp-aiss-styles', 'enqueued' ) ) { return; } wp_enqueue_style( 'ayudawp-aiss-styles', AYUDAWP_AISS_PLUGIN_URL . 'assets/css/ai-share-summarize.css', array(), AYUDAWP_AISS_VERSION ); wp_enqueue_script( 'ayudawp-aiss-scripts', AYUDAWP_AISS_PLUGIN_URL . 'assets/js/ai-share-summarize.js', array( 'jquery' ), AYUDAWP_AISS_VERSION, true ); $options = get_option( 'ayudawp_aiss_options', array() ); $dark_adapt_mode = isset( $options['dark_mode_adaptation'] ) ? $options['dark_mode_adaptation'] : 'disabled'; wp_localize_script( 'ayudawp-aiss-scripts', 'ayudawpAissL10n', array( 'promptCopied' => __( 'Prompt copied to clipboard!', 'ai-share-summarize' ), // Generic copy-prompt tooltips. 'copyPromptShort' => __( 'Copy prompt & open', 'ai-share-summarize' ), 'copyPromptLong' => __( 'Copy prompt and open', 'ai-share-summarize' ), // Gemini specific tooltips. 'geminiTooltipShort' => __( 'Copy prompt & open', 'ai-share-summarize' ), 'geminiTooltipLong' => __( 'Copy prompt and open Gemini', 'ai-share-summarize' ), // DeepSeek specific tooltips. 'deepseekTooltipShort' => __( 'Copy prompt & open', 'ai-share-summarize' ), 'deepseekTooltipLong' => __( 'Copy prompt and open DeepSeek', 'ai-share-summarize' ), // Copilot specific tooltips. 'copilotTooltipShort' => __( 'Copy prompt & open', 'ai-share-summarize' ), 'copilotTooltipLong' => __( 'Copy prompt and open Copilot', 'ai-share-summarize' ), // Platform names for tooltips. 'platformNames' => array( 'twitter' => 'X (Twitter)', 'linkedin' => 'LinkedIn', 'facebook' => 'Facebook', 'telegram' => 'Telegram', 'whatsapp' => 'WhatsApp', 'email' => __( 'Email', 'ai-share-summarize' ), 'raindrop' => 'Raindrop', 'reddit' => 'Reddit', 'bluesky' => 'Bluesky', 'line' => 'LINE', 'claude' => 'Claude AI', 'chatgpt' => 'ChatGPT', 'google_ai' => 'Google AI', 'gemini' => 'Gemini', 'grok' => 'Grok', 'perplexity' => 'Perplexity', 'deepseek' => 'DeepSeek', 'mistral' => 'Mistral AI', 'copilot' => 'Microsoft Copilot', ), // Analytics click tracking (v1.5.0) - no nonce needed for public counter. 'trackUrl' => esc_url_raw( rest_url( 'aiss/v1/track' ) ), // Dark-mode adaptation: 'disabled' (default) or 'auto' // ('auto' enables the JS background detector that toggles .is-on-dark). 'darkAdaptMode' => $dark_adapt_mode, // Public AI summary generation (v2.0.0). 'publicGenerateUrl' => esc_url_raw( rest_url( 'aiss/v1/summary/generate' ) ), 'summaryGenerating' => __( 'Generating…', 'ai-share-summarize' ), 'summaryGenerateError' => __( 'Generation failed. Try again.', 'ai-share-summarize' ), ) ); } /** * Clean HTML/block content for summarization (v2.0.0) * * `wp_strip_all_tags()` on raw post content concatenates table cells and * code blocks without separators, producing nonsense like: * "NombreDescripcionCategoriaJardinBilbaoRevisado..." * * This helper preprocesses the HTML so the sentence splitter has natural * breakpoints to work with: * * 1. Strips WordPress block comments (``). * 2. Removes entire blocks that are usually noise for prose summarization * (tables, code, captions, forms, navigation, embeds). * 3. Replaces block-level tag boundaries with ". " so sentences from * different paragraphs/list-items don't get concatenated. * 4. Strips remaining inline tags via wp_strip_all_tags(). * 5. Normalizes whitespace and collapses runs of dots. * * Applied by both the extractive summarizer and the AI Client prompt so * the LLM also receives clean text instead of table soup. * * @since 2.0.0 * @param string $html Raw HTML / block content. * @return string Cleaned plain text ready to summarize. */ function ayudawp_aiss_clean_html_for_summary( $html ) { $html = (string) $html; if ( '' === $html ) { return ''; } // 0. Remove shortcodes wholesale BEFORE anything else, so the summary // never includes raw shortcode markup like `[gallery ids="1,2,3"]`, // `[caption ...]...[/caption]` or any plugin-defined shortcode. We // cannot `do_shortcode()` here because that would inject the whole // rendered gallery/embed back into the prose we want to summarize. $html = strip_shortcodes( $html ); // 1. Strip block comments (Gutenberg leaves them in post_content). $html = preg_replace( '##s', '', $html ); // 2. Remove noisy elements wholesale. Filterable so themes/plugins // can add custom ones (e.g. an "advertisement" shortcode wrapper). $noisy = apply_filters( 'ayudawp_aiss_summary_noisy_tags', array( 'table', 'pre', 'code', 'figcaption', 'figure', 'form', 'button', 'nav', 'script', 'style', 'iframe', 'svg', 'audio', 'video' ) ); if ( ! empty( $noisy ) ) { $pattern = '#<(' . implode( '|', array_map( 'preg_quote', $noisy ) ) . ')\b[^>]*>.*?#is'; $html = preg_replace( $pattern, ' ', $html ); } // 3. Replace block-level tag boundaries (open AND close) with a // sentence separator so prose from different blocks doesn't get // concatenated by wp_strip_all_tags(). $boundaries = 'p|h[1-6]|li|div|td|th|tr|br|hr|blockquote|aside|section|article|header|footer|dd|dt'; $html = preg_replace( '#]*)?/?>#i', '. ', $html ); // 4. Strip the rest. $text = wp_strip_all_tags( $html ); // 5. Whitespace normalization + collapse repeated punctuation runs. $text = preg_replace( '/\s+/u', ' ', $text ); $text = preg_replace( '/(\s*\.\s*){2,}/', '. ', $text ); // ". . . " → ". " $text = preg_replace( '/\s+\./', '.', $text ); // " ." → "." $text = preg_replace( '/\.{2,}/', '.', $text ); // ".." → "." return trim( $text ); } /** * Generate an extractive summary from post content (v2.0.0) * * Picks the top N sentences scored by token-frequency (excluding stopwords), * with a bonus for title words and a lead-position bonus for the first two * sentences. Returns sentences in their original order so the summary reads * naturally. * * Used as a fallback when WP AI Client is not available, or when the call * to wp_ai_client_prompt() fails. * * @since 2.0.0 * @param string $content Raw post content (HTML accepted, will be stripped). * @param string $title Post title — its words get a 2x weight bonus. * @param int $n Target sentence count (clamped to 1..5). * @return string Summary text, or '' if the content is too short to summarize. */ function ayudawp_aiss_extractive_summary( $content, $title, $n = 3 ) { $text = ayudawp_aiss_clean_html_for_summary( (string) $content ); if ( '' === $text ) { return ''; } $sentences = preg_split( '/(?<=[.!?])\s+(?=[A-ZÁÉÍÓÚÑ¿¡"\'])/u', $text ); if ( ! is_array( $sentences ) || count( $sentences ) < 3 ) { return ''; } $stopwords = apply_filters( 'ayudawp_aiss_extractive_stopwords', ayudawp_aiss_get_stopwords() ); /** * Tunable weights. Filterable so themes/plugins can adjust them without * forking the algorithm. * * - lead_bonus: multiplier applied to the first two sentences. Lowered * from the previous 1.3 because it made the first sentence always * "win", giving the impression the summarizer hadn't done anything. * - title_weight: how much extra each title word contributes to its * frequency score. Raised from 2x to 3x so title-relevant sentences * stand out more reliably. * - min_words: discard sentences shorter than this (likely headings * leaked from the markup, navigation labels, etc). * - similarity_threshold: Jaccard similarity above which a candidate * sentence is considered redundant with one already selected. * * @since 2.0.0 */ $weights = apply_filters( 'ayudawp_aiss_extractive_weights', array( 'lead_bonus' => 1.1, 'title_weight' => 3, 'min_words' => 5, 'similarity_threshold' => 0.5, ) ); // Tokenize once per sentence and reuse — Jaccard needs token sets too. $sentence_tokens = array(); foreach ( $sentences as $i => $sentence ) { $tokens = preg_split( '/\W+/u', mb_strtolower( $sentence, 'UTF-8' ) ); $tokens = is_array( $tokens ) ? array_values( array_filter( $tokens, 'strlen' ) ) : array(); $sentence_tokens[ $i ] = $tokens; } // Build word-frequency table over content-bearing tokens. $freq = array(); foreach ( $sentence_tokens as $tokens ) { foreach ( $tokens as $token ) { if ( isset( $stopwords[ $token ] ) || mb_strlen( $token, 'UTF-8' ) < 3 ) { continue; } $freq[ $token ] = isset( $freq[ $token ] ) ? $freq[ $token ] + 1 : 1; } } // Title words boost their frequency weight. $title_tokens = preg_split( '/\W+/u', mb_strtolower( (string) $title, 'UTF-8' ) ); if ( is_array( $title_tokens ) ) { foreach ( $title_tokens as $token ) { if ( isset( $freq[ $token ] ) ) { $freq[ $token ] *= (float) $weights['title_weight']; } } } // Score sentences and remember which are eligible (have enough words). $scored = array(); $eligible = array(); $jaccard_set = array(); // Per-sentence content-token set used for similarity comparison. foreach ( $sentence_tokens as $i => $tokens ) { if ( count( $tokens ) < (int) $weights['min_words'] ) { continue; } $score = 0.0; $set = array(); foreach ( $tokens as $token ) { if ( isset( $stopwords[ $token ] ) || mb_strlen( $token, 'UTF-8' ) < 3 ) { continue; } if ( isset( $freq[ $token ] ) ) { $score += $freq[ $token ]; } $set[ $token ] = 1; } if ( $i < 2 ) { $score *= (float) $weights['lead_bonus']; } $scored[ $i ] = $score; $eligible[ $i ] = true; $jaccard_set[ $i ] = $set; } if ( empty( $scored ) ) { return ''; } arsort( $scored ); $n = max( 1, min( 5, (int) $n ) ); // Greedy MMR-style selection: walk candidates by score descending and // skip any that are too similar (Jaccard >= threshold) to a sentence // already picked. Falls back to plain top-N if Jaccard filtering would // leave us with fewer than N selections. $threshold = (float) $weights['similarity_threshold']; $selected = array(); foreach ( array_keys( $scored ) as $idx ) { if ( count( $selected ) >= $n ) { break; } $is_redundant = false; foreach ( $selected as $picked ) { $intersection = count( array_intersect_key( $jaccard_set[ $idx ], $jaccard_set[ $picked ] ) ); $union = count( $jaccard_set[ $idx ] + $jaccard_set[ $picked ] ); $similarity = $union > 0 ? ( $intersection / $union ) : 0; if ( $similarity >= $threshold ) { $is_redundant = true; break; } } if ( ! $is_redundant ) { $selected[] = $idx; } } // Backfill if the similarity filter was too aggressive. if ( count( $selected ) < $n ) { foreach ( array_keys( $scored ) as $idx ) { if ( count( $selected ) >= $n ) { break; } if ( ! in_array( $idx, $selected, true ) ) { $selected[] = $idx; } } } // Restore original sentence order in the output. sort( $selected ); $pieces = array(); foreach ( $selected as $index ) { if ( isset( $sentences[ $index ] ) ) { $pieces[] = $sentences[ $index ]; } } return trim( implode( ' ', $pieces ) ); } /** * Get the stopwords lookup table for the extractive summarizer (v2.0.0) * * Returns an associative array (`'the' => 1`) so callers can use * `isset( $stopwords[ $token ] )` for O(1) membership checks. * * Covers English and Spanish — extend via the `ayudawp_aiss_extractive_stopwords` * filter to support additional languages. * * @since 2.0.0 * @return array Associative array of stopwords. */ function ayudawp_aiss_get_stopwords() { $words = array( // English. 'the', 'and', 'for', 'are', 'but', 'not', 'you', 'all', 'can', 'her', 'was', 'one', 'our', 'out', 'day', 'get', 'has', 'him', 'his', 'how', 'man', 'new', 'now', 'old', 'see', 'two', 'way', 'who', 'boy', 'did', 'its', 'let', 'put', 'say', 'she', 'too', 'use', 'with', 'this', 'that', 'from', 'they', 'have', 'were', 'been', 'will', 'your', 'what', 'when', 'make', 'like', 'time', 'just', 'know', 'take', 'into', 'some', 'them', 'than', 'then', 'look', 'only', 'come', 'over', 'also', 'back', 'after', 'work', 'first', 'well', 'even', 'want', 'because', 'these', 'give', 'most', 'about', 'which', 'their', 'would', 'there', 'could', 'other', 'should', 'where', 'while', 'being', 'does', 'each', 'such', 'very', 'much', 'many', 'more', 'made', 'said', 'here', // Spanish. 'los', 'las', 'una', 'uno', 'del', 'que', 'por', 'con', 'para', 'pero', 'sus', 'sin', 'son', 'mas', 'muy', 'ese', 'esa', 'eso', 'este', 'esta', 'esto', 'hay', 'fue', 'ser', 'han', 'has', 'como', 'cuando', 'donde', 'porque', 'sobre', 'entre', 'desde', 'hasta', 'también', 'tambien', 'cada', 'todo', 'todos', 'todas', 'algo', 'algun', 'alguna', 'mucho', 'mucha', 'muchos', 'muchas', 'otro', 'otra', 'otros', 'otras', 'mismo', 'misma', 'tanto', 'tanta', 'poco', 'poca', 'nada', 'ante', 'bajo', 'cabe', 'contra', 'segun', 'según', 'durante', 'mediante', 'hacia', 'aqui', 'aquí', 'alli', 'allí', 'ahi', 'ahí', 'asi', 'así', 'aun', 'aún', 'ya', 'si', 'sí', 'siempre', 'nunca', 'jamás', 'jamas', 'antes', 'despues', 'después', 'luego', 'entonces', 'estaba', 'estaban', 'estamos', 'estar', 'estado', 'estos', 'estas', 'eran', 'era', 'eres', 'haber', 'había', 'habia', 'habían', 'habian', 'hace', 'hacer', 'hecho', 'puede', 'pueden', 'porqué', 'porque', 'cual', 'cuál', 'quien', 'quién', 'cuanto', 'cuánto', ); return array_fill_keys( $words, 1 ); }