__('Prompt copied to clipboard!', 'ai-share-summarize'), 'googleAiTooltipShort' => __('Google AI: Copy prompt & open', 'ai-share-summarize'), 'googleAiTooltipLong' => __('Copy prompt and open Google Gemini', 'ai-share-summarize'), 'platformNames' => array( 'twitter' => 'X (Twitter)', 'linkedin' => 'LinkedIn', 'facebook' => 'Facebook', 'telegram' => 'Telegram', 'whatsapp' => 'WhatsApp', 'email' => __('Email', 'ai-share-summarize'), 'raindrop' => 'Raindrop', 'claude' => 'Claude AI', 'chatgpt' => 'ChatGPT', 'grok' => 'Grok', 'perplexity' => 'Perplexity' ) ); wp_add_inline_script('jquery', ' var ayudawpAissL10n = ' . wp_json_encode($l10n_data) . '; function copyToClipboard(text) { if (navigator.clipboard && window.isSecureContext) { return navigator.clipboard.writeText(text); } else { var textArea = document.createElement("textarea"); textArea.value = text; textArea.style.position = "fixed"; textArea.style.left = "-999999px"; textArea.style.top = "-999999px"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); return new Promise((resolve, reject) => { try { document.execCommand("copy") ? resolve() : reject(); } catch (err) { reject(err); } finally { textArea.remove(); } }); } } function showNotification(message, type) { if (document.querySelector(".ayudawp-notification")) return; var notification = document.createElement("div"); notification.className = "ayudawp-notification ayudawp-notification-" + type; notification.textContent = message; notification.style.cssText = "position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:#333;color:white;padding:16px 24px;border-radius:8px;font-size:14px;font-weight:500;z-index:9999;box-shadow:0 8px 32px rgba(0,0,0,0.3);opacity:0;transition:all 0.4s ease;border:1px solid #555;"; document.body.appendChild(notification); setTimeout(function() { notification.style.opacity = "1"; }, 50); setTimeout(function() { notification.style.opacity = "0"; notification.style.transform = "translate(-50%,-50%) scale(0.9)"; setTimeout(function() { if (notification.parentNode) { notification.parentNode.removeChild(notification); } }, 400); }, 2500); } document.addEventListener("click", function(e) { var button = e.target.closest(".ayudawp-share-btn"); if (!button) return; e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); var url = button.getAttribute("data-url"); var platform = button.getAttribute("data-platform"); if (!platform) { var classes = button.className.split(" "); var platforms = ["twitter", "linkedin", "facebook", "telegram", "whatsapp", "email", "raindrop", "claude", "chatgpt", "google-ai", "grok", "perplexity"]; for (var i = 0; i < platforms.length; i++) { if (classes.indexOf(platforms[i]) !== -1) { platform = platforms[i]; break; } } } if (!url) { return false; } if (platform === "google-ai" || button.classList.contains("google-ai")) { try { var urlParts = url.split("?"); var queryString = urlParts.length > 1 ? urlParts[1] : ""; var urlParams = new URLSearchParams(queryString); var prompt = urlParams.get("prompt") || ""; if (prompt) { copyToClipboard(decodeURIComponent(prompt)).then(function() { showNotification(ayudawpAissL10n.promptCopied, "success"); setTimeout(function() { window.open("https://gemini.google.com/app", "_blank", "noopener,noreferrer"); }, 500); }).catch(function() { window.open("https://gemini.google.com/app", "_blank", "noopener,noreferrer"); }); } else { window.open("https://gemini.google.com/app", "_blank", "noopener,noreferrer"); } } catch (error) { window.open("https://gemini.google.com/app", "_blank", "noopener,noreferrer"); } return false; } if (platform === "twitter" || platform === "linkedin" || platform === "facebook" || platform === "telegram" || button.classList.contains("twitter") || button.classList.contains("linkedin") || button.classList.contains("facebook") || button.classList.contains("telegram")) { var width = 600, height = 400; var left = (screen.width / 2) - (width / 2); var top = (screen.height / 2) - (height / 2); window.open(url, "share", "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",scrollbars=yes,resizable=yes"); return false; } window.open(url, "_blank", "noopener,noreferrer"); return false; }, true); '); } } /** * Add share buttons to content * * @param string $content Post content * @return string Modified content with buttons */ public function ayudawp_add_share_buttons($content) { if (!ayudawp_aiss_should_display_buttons()) { return $content; } $options = get_option('ayudawp_aiss_options'); $insert_position = isset($options['auto_insert_position']) ? $options['auto_insert_position'] : 'after_content'; if ($insert_position === 'disabled') { return $content; } $buttons_html = AyudaWP_AISS_Buttons::ayudawp_generate_buttons_html(); switch ($insert_position) { case 'before_content': return $buttons_html . $content; case 'after_content': return $content . $buttons_html; case 'both': return $buttons_html . $content . $buttons_html; default: return $content . $buttons_html; } } }