'; // Add title if not empty and not icons-only style if (!empty(trim($title_text)) && $color_style !== 'icons-only') { $html .= '<' . esc_attr($title_style) . ' class="ayudawp-title">' . esc_html($title_text) . '' . esc_attr($title_style) . '>'; } $html .= '
'; return $html; } /** * Generate individual button HTML * * @param string $button Button type * @param string $url Current URL * @param string $title Current title * @param array $options Plugin options * @param bool $show_icons Whether to show icons * @param string $color_style Color style * @param string $seo_button_type Button HTML type ('link' or 'button') * @return string Button HTML */ public static function ayudawp_get_button_html($button, $url, $title, $options, $show_icons = false, $color_style = 'default', $seo_button_type = 'link') { $twitter_handle = isset($options['twitter_handle']) ? $options['twitter_handle'] : ''; $custom_text = isset($options['custom_text']) ? $options['custom_text'] : ''; $prompt = isset($options['default_prompt']) ? $options['default_prompt'] : ayudawp_aiss_get_default_prompt(); $full_prompt = $prompt; if (!empty($custom_text)) { $full_prompt .= ' ' . $custom_text; } $full_prompt .= ' Source: ' . $url; $buttons_config = array( 'twitter' => array( 'label' => 'Twitter (X)', 'url' => 'https://twitter.com/intent/tweet?text=' . urlencode($title . ' ' . $twitter_handle) . '&url=' . urlencode($url), 'class' => 'twitter' ), 'linkedin' => array( 'label' => 'LinkedIn', 'url' => 'https://www.linkedin.com/sharing/share-offsite/?url=' . urlencode($url), 'class' => 'linkedin' ), 'facebook' => array( 'label' => 'Facebook', 'url' => 'https://www.facebook.com/sharer/sharer.php?u=' . urlencode($url), 'class' => 'facebook' ), 'telegram' => array( 'label' => 'Telegram', 'url' => 'https://t.me/share/url?url=' . urlencode($url) . '&text=' . urlencode($title), 'class' => 'telegram' ), 'whatsapp' => array( 'label' => 'WhatsApp', 'url' => 'https://api.whatsapp.com/send?text=' . urlencode($title . ' ' . $url), 'class' => 'whatsapp' ), 'email' => array( 'label' => 'Email', 'url' => 'mailto:?subject=' . urlencode($title) . '&body=' . urlencode($url), 'class' => 'email' ), 'raindrop' => array( 'label' => 'Raindrop', 'url' => 'https://app.raindrop.io/add?link=' . urlencode($url) . '&title=' . urlencode($title), 'class' => 'raindrop' ), 'reddit' => array( 'label' => 'Reddit', 'url' => 'https://www.reddit.com/submit?url=' . urlencode($url) . '&title=' . urlencode($title), 'class' => 'reddit' ), 'bluesky' => array( 'label' => 'Bluesky', 'url' => 'https://bsky.app/intent/compose?text=' . urlencode($title . ' ' . $url), 'class' => 'bluesky' ), 'line' => array( 'label' => 'LINE', 'url' => 'https://social-plugins.line.me/lineit/share?url=' . urlencode($url), 'class' => 'line' ), 'claude' => array( 'label' => 'Claude', 'url' => 'https://claude.ai/new?q=' . urlencode($full_prompt), 'class' => 'claude ai' ), 'chatgpt' => array( 'label' => 'ChatGPT', 'url' => 'https://chatgpt.com/?q=' . urlencode($full_prompt), 'class' => 'chatgpt ai' ), 'google_ai' => array( 'label' => 'Google AI', 'url' => 'https://www.google.com/search?udm=50&aep=11&q=' . urlencode($full_prompt), 'class' => 'google-ai ai' ), 'gemini' => array( 'label' => 'Gemini', 'url' => 'https://gemini.google.com/app?prompt=' . urlencode($full_prompt), 'class' => 'gemini ai' ), 'grok' => array( 'label' => 'Grok', 'url' => 'https://grok.com/?q=' . urlencode($full_prompt), 'class' => 'grok ai' ), 'perplexity' => array( 'label' => 'Perplexity', 'url' => 'https://www.perplexity.ai/?q=' . urlencode($full_prompt), 'class' => 'perplexity ai' ), // DeepSeek: Uses prompt parameter for copy-to-clipboard behavior (no direct URL support) 'deepseek' => array( 'label' => 'DeepSeek', 'url' => 'https://chat.deepseek.com/?prompt=' . urlencode($full_prompt), 'class' => 'deepseek ai' ), 'mistral' => array( 'label' => 'Mistral', 'url' => 'https://chat.mistral.ai/chat?q=' . urlencode($full_prompt), 'class' => 'mistral ai' ), // Copilot: Uses prompt parameter for copy-to-clipboard behavior (q= parameter no longer works) 'copilot' => array( 'label' => 'Copilot', 'url' => 'https://copilot.microsoft.com/?prompt=' . urlencode($full_prompt), 'class' => 'copilot ai' ) ); if (!isset($buttons_config[$button])) { return ''; } $config = $buttons_config[$button]; // Get icon if needed $icon_html = ''; if ($show_icons) { $icon_size = ($color_style === 'icons-only') ? 20 : 16; $icon_html = AyudaWP_AISS_Icons::ayudawp_get_button_icon($button, $icon_size); } // Build button content $button_content = $icon_html; if ($color_style !== 'icons-only') { if (!empty($icon_html)) { $button_content .= ''; } else { $button_content = esc_html($config['label']); } } // Generate HTML based on seo_button_type if ($seo_button_type === 'button') { return sprintf( '', esc_attr($config['class']), esc_attr($config['url']), esc_attr($button), // translators: %s is the button label esc_attr(sprintf(__('Share in %s', 'ai-share-summarize'), $config['label'])), $button_content ); } else { // Default: generate elements WITH data attributes for JavaScript handling return sprintf( '%s', esc_url($config['url']), esc_attr($config['class']), esc_attr($config['url']), esc_attr($button), // translators: %s is the button label esc_attr(sprintf(__('Share in %s', 'ai-share-summarize'), $config['label'])), $button_content ); } } /** * Order buttons according to configuration * * @param array $buttons List of buttons * @param string $order Order type * @return array Ordered buttons */ public static function ayudawp_order_buttons($buttons, $order) { $social_buttons = ayudawp_aiss_get_social_buttons(); $ai_buttons = ayudawp_aiss_get_ai_buttons(); switch ($order) { case 'ayudawp_ai_first': $social = array_intersect($buttons, $social_buttons); $ai = array_intersect($buttons, $ai_buttons); return array_merge($ai, $social); case 'ayudawp_mixed': $social = array_values(array_intersect($buttons, $social_buttons)); $ai = array_values(array_intersect($buttons, $ai_buttons)); $mixed = array(); $max_length = max(count($social), count($ai)); for ($i = 0; $i < $max_length; $i++) { if (isset($social[$i])) $mixed[] = $social[$i]; if (isset($ai[$i])) $mixed[] = $ai[$i]; } return $mixed; case 'ayudawp_social_first': default: $social = array_intersect($buttons, $social_buttons); $ai = array_intersect($buttons, $ai_buttons); return array_merge($social, $ai); } } }