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' ) ) . '" }); }); }); ' ); } /** * 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' ), 'button_colors' => esc_html__( 'Button style', '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' ); } } /** * 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. $page_title = 'AI Share & Summarize'; if ( 'analytics' === $active_tab ) { $page_title .= ' — ' . esc_html__( 'Analytics', 'ai-share-summarize' ); } ?>

ayudawp_render_settings_tab(); } ?> render( 'horizontal' ); ?>
' . esc_html__( 'Configure how and where to display share buttons and generate summaries with AI.', '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(); ?>

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


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' ) . '

'; } /** * Button colors field */ public function ayudawp_button_colors_callback() { $options = get_option( 'ayudawp_aiss_options' ); $style = isset( $options['button_colors'] ) ? $options['button_colors'] : 'brand'; $styles = array( 'minimal' => 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' ) . '

'; } /** * 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(); } }