'true', 'ai4seo_execute_cron_job_sooner_nonce' => wp_create_nonce( $ai4seo_execute_sooner_nonce_action ), ) ); $ai4seo_execute_sooner_button = ai4seo_get_small_a_tag_icon_button_tag( $ai4seo_execute_sooner_text_link_url, '', '', 'bolt', __( 'Execute sooner!', 'ai-for-seo' ), '', 'ai4seo_add_loading_html_to_element(this); ai4seo_show_full_page_loading_screen();' ); } // === CREDITS BALANCE ======================================================================= \\ $ai4seo_account_readiness = ai4seo_get_account_readiness(); $ai4seo_current_credits_balance = $ai4seo_account_readiness['credits'] ?? 0; $ai4seo_metadata_credits_cost_per_post = ai4seo_calculate_metadata_credits_cost_per_post(); $ai4seo_attachment_attributes_credits_cost_per_attachment_post = ai4seo_calculate_attachment_attributes_credits_cost_per_attachment_post(); $ai4seo_is_robhub_account_synced = $ai4seo_account_readiness['credits_ready']; $ai4seo_heavy_db_operations_disabled = (bool) ai4seo_get_setting( AI4SEO_SETTING_DISABLE_HEAVY_DB_OPERATIONS ); // next free credits. $ai4seo_next_free_credits_timestamp = ai4seo_robhub_api()->read_environmental_variable( ai4seo_robhub_api()::ENVIRONMENTAL_VARIABLE_NEXT_FREE_CREDITS_TIMESTAMP ); $ai4seo_free_plan_credits_amount = ai4seo_get_plan_credits( 'free' ); $ai4seo_next_free_credits_seconds_left = ai4seo_get_time_difference_in_seconds( $ai4seo_next_free_credits_timestamp ); // === CHECK BULK GENERATION STATUS ========================================================== \\ // Normalize enabled post types through the shared accessor before exact UI comparisons. $ai4seo_active_bulk_generation_post_types = ai4seo_get_enabled_bulk_generation_post_types(); $ai4seo_bulk_generation_duration = (int) ai4seo_get_setting( AI4SEO_SETTING_BULK_GENERATION_DURATION ); $ai4seo_is_any_bulk_generation_enabled = ! empty( $ai4seo_active_bulk_generation_post_types ); $ai4seo_should_auto_queue_bulk_generation_entries = ai4seo_should_auto_queue_bulk_generation_entries(); // Credit-aware queue eligibility feeds the chart without changing Autopilot's existing excavation rules. $ai4seo_can_auto_queue_metadata_entries = ( $ai4seo_should_auto_queue_bulk_generation_entries && $ai4seo_current_credits_balance >= $ai4seo_metadata_credits_cost_per_post ); $ai4seo_can_auto_queue_attachment_attribute_entries = ( $ai4seo_should_auto_queue_bulk_generation_entries && $ai4seo_current_credits_balance >= $ai4seo_attachment_attributes_credits_cost_per_attachment_post ); $ai4seo_bulk_generation_queue_count = ai4seo_get_bulk_generation_queue_count(); $ai4seo_bulk_generation_processing_count = ai4seo_get_bulk_generation_processing_count(); // Manual queue guidance applies only when neither queued nor actively processing work remains. $ai4seo_is_waiting_for_manual_queue_entries = ( $ai4seo_is_any_bulk_generation_enabled && ! $ai4seo_should_auto_queue_bulk_generation_entries && 0 === $ai4seo_bulk_generation_queue_count && 0 === $ai4seo_bulk_generation_processing_count ); $ai4seo_background_job = ai4seo_get_background_job_readiness( AI4SEO_BULK_GENERATION_CRON_JOB_NAME ); $ai4seo_bulk_queue_presentation = null; $ai4seo_bulk_queue_warnings = ai4seo_get_bulk_generation_queue_warnings( $ai4seo_bulk_queue_presentation ); $ai4seo_autopilot_item_notice = ai4seo_get_autopilot_item_notice( $ai4seo_bulk_queue_presentation, $ai4seo_background_job ); $ai4seo_background_job = ai4seo_get_autopilot_dashboard_presentation( $ai4seo_background_job ); $ai4seo_selection_continuation_warnings = array_intersect_key( $ai4seo_bulk_queue_warnings, $ai4seo_bulk_queue_presentation['continuation'] ); $ai4seo_bulk_queue_warnings = array_intersect_key( $ai4seo_bulk_queue_warnings, $ai4seo_bulk_queue_presentation['operational'] ); $ai4seo_last_bulk_generation_update_time = $ai4seo_background_job['updated_at']; $ai4seo_next_cron_job_call = wp_next_scheduled( AI4SEO_BULK_GENERATION_CRON_JOB_NAME ); $ai4seo_next_cron_job_call_diff = ( $ai4seo_next_cron_job_call ? $ai4seo_next_cron_job_call - time() : null ); // === NEW OR EXISTING FILTER =============================================================== \\ // check if we should only generate data for new or existing posts. // Resolve the shared state once so statistics and filter notices use the queue contract. $ai4seo_bulk_generation_date_filter_state = ai4seo_get_current_bulk_generation_date_filter_state(); // === POST TYPES =========================================================================== \\ $ai4seo_supported_post_types = ai4seo_get_supported_post_types(); $ai4seo_supported_attachment_post_types = ai4seo_get_supported_attachment_post_types(); $ai4seo_all_supported_post_types = array_merge( $ai4seo_supported_post_types, $ai4seo_supported_attachment_post_types ); $ai4seo_dashboard_taxonomies = ai4seo_get_taxonomy_content_navigation_entries(); $ai4seo_public_taxonomies = ai4seo_get_public_archive_taxonomies(); // Explain configured exclusions only on the page load following a successful manual refresh. $ai4seo_statistics_filter_labels = array(); if ( $ai4seo_can_administer_plugin && ! wp_doing_ajax() && ! wp_doing_cron() && isset( $_GET['ai4seo-statistics-refreshed'] ) && is_string( $_GET['ai4seo-statistics-refreshed'] ) && '1' === sanitize_text_field( wp_unslash( $_GET['ai4seo-statistics-refreshed'] ) ) ) { // Date guidance is meaningful only when a valid filter applies to at least one supported content type. if ( $ai4seo_all_supported_post_types && ! empty( $ai4seo_bulk_generation_date_filter_state['is_valid'] ) ) { if ( 'new' === $ai4seo_bulk_generation_date_filter_state['filter'] ) { $ai4seo_statistics_filter_labels[] = sprintf( /* translators: %s: reference date and time. */ __( 'New or existing entries: New only, after %s', 'ai-for-seo' ), ai4seo_format_unix_timestamp( (int) $ai4seo_bulk_generation_date_filter_state['reference_timestamp'] ) ); } elseif ( 'existing' === $ai4seo_bulk_generation_date_filter_state['filter'] ) { $ai4seo_statistics_filter_labels[] = sprintf( /* translators: %s: reference date and time. */ __( 'New or existing entries: Existing only, on or before %s', 'ai-for-seo' ), ai4seo_format_unix_timestamp( (int) $ai4seo_bulk_generation_date_filter_state['reference_timestamp'] ) ); } } // Reuse cached type discovery while distinguishing disabled types from disabled metadata fields. $ai4seo_unfiltered_post_types = ai4seo_get_supported_post_types( false ); $ai4seo_disabled_post_types = ai4seo_get_setting( AI4SEO_SETTING_DISABLED_POST_TYPES ); // Ignore disabled type names that do not occur in this site's supported content. if ( is_array( $ai4seo_disabled_post_types ) && array_intersect( $ai4seo_unfiltered_post_types, ai4seo_deep_sanitize( $ai4seo_disabled_post_types, 'sanitize_key' ) ) ) { $ai4seo_statistics_filter_labels[] = __( 'Active Post Types', 'ai-for-seo' ); } // Distinguish an empty metadata selection from an absence of supported post types. if ( $ai4seo_unfiltered_post_types && ! ai4seo_get_active_meta_tags() ) { $ai4seo_statistics_filter_labels[] = __( 'Active Meta Tags: None selected', 'ai-for-seo' ); } // Attachment type availability already incorporates the active media-attribute selection. if ( ! $ai4seo_supported_attachment_post_types ) { $ai4seo_statistics_filter_labels[] = __( 'Active Media Attributes: None selected', 'ai-for-seo' ); } // Author exclusions use separate settings for metadata and media statistics. if ( $ai4seo_supported_post_types && ai4seo_get_disabled_post_author_ids() ) { $ai4seo_statistics_filter_labels[] = __( 'Active Authors', 'ai-for-seo' ); } // Media author restrictions matter only while attachment generation is available. if ( $ai4seo_supported_attachment_post_types && ai4seo_get_disabled_attachment_post_author_ids() ) { $ai4seo_statistics_filter_labels[] = __( 'Active Media Authors', 'ai-for-seo' ); } // Match the queue's any-term versus all-terms exclusion rule in the displayed explanation. if ( $ai4seo_supported_post_types && ai4seo_get_enforced_disabled_taxonomy_terms() ) { $ai4seo_statistics_filter_labels[] = ai4seo_should_exclude_posts_if_any_disabled_taxonomy_term_matches() ? __( 'Active Categories (taxonomy terms): Exclude when any assigned category is disabled', 'ai-for-seo' ) : __( 'Active Categories (taxonomy terms): Exclude when all assigned categories covered by the filter are disabled', 'ai-for-seo' ); } // Metadata language restrictions apply only to supported metadata content. if ( $ai4seo_supported_post_types && ai4seo_get_disabled_metadata_wpml_language_codes() ) { $ai4seo_statistics_filter_labels[] = __( 'Active Languages (metadata)', 'ai-for-seo' ); } // Media languages have their own selection and must be explained independently. if ( $ai4seo_supported_attachment_post_types && ai4seo_get_disabled_attachment_attributes_wpml_language_codes() ) { $ai4seo_statistics_filter_labels[] = __( 'Active Languages (media)', 'ai-for-seo' ); } } // === CHANGE LOG ============================================================================ \\ $ai4seo_change_log = ai4seo_get_change_log(); // check if the anchor "ai4seo_recent_plugin_updates" parameter is in the URL. $ai4seo_pre_open_recent_plugin_updates = isset( $_GET['ai4seo_recent_plugin_updates'] ) && sanitize_text_field( wp_unslash( $_GET['ai4seo_recent_plugin_updates'] ) ) === 'true'; // === NOTIFICATIONS ========================================================================= \\ $ai4seo_notifications = ai4seo_get_displayable_notifications(); if ( $ai4seo_can_administer_plugin ) { // Notification read state is shared site-wide and therefore administrative. ai4seo_mark_all_displayable_notifications_as_read(); } // ___________________________________________________________________________________________ \\ // === OUTPUT ================================================================================ \\ // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ \\ // Keep notifications and the card grid in one response boundary without changing the established card container. echo '
'; // === NOTIFICATIONS ================================================================================= \\ // Render server-managed notices outside the card diff while retaining them in the dashboard refresh response. echo "
"; if ( null !== $ai4seo_execute_sooner_result ) { $ai4seo_scheduling_messages = array( 'scheduled' => __( 'The next execution has been scheduled.', 'ai-for-seo' ), 'already-scheduled' => __( 'An execution is already scheduled shortly.', 'ai-for-seo' ), 'scheduled-with-fallback' => __( 'The next execution is scheduled. The previous fallback event was retained.', 'ai-for-seo' ), 'deferred' => __( 'Execution could not be brought forward while another request owns the background lock. Please try again shortly.', 'ai-for-seo' ), 'disabled' => __( 'Background execution is disabled.', 'ai-for-seo' ), 'blocked' => __( 'The background state cannot be read safely. Existing jobs have been retained.', 'ai-for-seo' ), 'failed' => __( 'The requested execution could not be verified. Please try again or check the cron configuration.', 'ai-for-seo' ), ); $ai4seo_scheduling_toast_types = array( 'scheduled' => 'success', 'already-scheduled' => 'info', 'scheduled-with-fallback' => 'info', 'deferred' => 'warning', 'failed' => 'error', ); if ( isset( $ai4seo_scheduling_toast_types[ $ai4seo_execute_sooner_result['status'] ] ) ) { echo ''; } else { echo '

' . esc_html( $ai4seo_scheduling_messages[ $ai4seo_execute_sooner_result['status'] ] ) . '

'; } } if ( $ai4seo_notifications ) { // Display the notifications. foreach ( $ai4seo_notifications as $ai4seo_this_notification_index => $ai4seo_this_notification ) { ai4seo_echo_notice_from_notification( $ai4seo_this_notification_index, $ai4seo_this_notification ); } } if ( $ai4seo_can_administer_plugin && ! isset( $ai4seo_notifications['unfinished-posts-table-analysis'] ) ) { // Required update problems remain visible when optional notifications are hidden or unavailable. $ai4seo_update_presentation = ai4seo_get_analysis_update_presentation(); if ( $ai4seo_update_presentation['warning'] ) { // A stable notification identity lets the normal refresh update and remove this read-only fallback. echo '
'; ai4seo_echo_wp_kses( ai4seo_get_sooz_logo_image_tag( 'sooz-oo' ) ); echo '

' . esc_html__( 'Some update steps are still pending', 'ai-for-seo' ) . '

'; ai4seo_echo_wp_kses( ai4seo_get_plugin_update_notice_html( true, $ai4seo_update_presentation ) ); echo '
'; } } echo '
'; // Preserve the dashboard class because its styles and the incremental card diff both target this container. echo "
"; // === STATISTICS ============================================================================ \\ // Keep the statistics card available for filter guidance even when every content type is excluded. if ( $ai4seo_all_supported_post_types || $ai4seo_dashboard_taxonomies || $ai4seo_statistics_filter_labels ) { $ai4seo_total_num_pending_posts = 0; $ai4seo_total_num_pending_metadata_posts = 0; $ai4seo_total_num_pending_attachment_posts = 0; $ai4seo_num_finished_posts_by_post_type = ai4seo_get_num_finished_posts_by_post_type(); $ai4seo_num_failed_posts_by_post_type = ai4seo_get_num_failed_posts_by_post_type(); $ai4seo_num_pending_posts_by_post_type = ai4seo_get_num_pending_posts_by_post_type(); $ai4seo_num_processing_posts_by_post_type = ai4seo_get_num_processing_posts_by_post_type(); $ai4seo_num_missing_posts_by_post_type = ai4seo_get_num_missing_posts_by_post_type(); /* translators: %s: post type name */ $ai4seo_retry_all_failed_metadata_generations_link_label = __( 'Retry all failed generations for %s', 'ai-for-seo' ); $ai4seo_retry_all_failed_attachment_attributes_generations_link_label = __( 'Retry all failed media attribute generations', 'ai-for-seo' ); $ai4seo_retry_all_failed_metadata_button_tags = array(); $ai4seo_retry_all_failed_attachment_attributes_generations_link_tag = ''; echo "
"; echo "
"; echo "
"; echo '

' . esc_html__( 'SEO completion', 'ai-for-seo' ) . '

'; ai4seo_echo_wp_kses( ai4seo_get_icon_with_tooltip_tag( esc_html__( 'Each percentage shows the share of included items with all enabled SEO fields filled in. For example, 2/8 complete means that 2 of 8 included items have every enabled field. This measures field completion; content quality and search performance require separate review.', 'ai-for-seo' ) . '

' . esc_html__( 'Your Settings determine which SEO fields and content are included. Content types, authors, categories, languages, and new or existing entry filters can affect the totals. Use Review missing fields beneath a chart to inspect incomplete items.', 'ai-for-seo' ) . '

' . esc_html__( 'If entries seem missing, or the figures look wrong or incomplete, check Settings to make sure the fields and content you expect are included. After saving any changes, use Refresh statistics when available to recalculate the figures.', 'ai-for-seo' ), '', 'circle-question', __( 'SEO completion: Help', 'ai-for-seo' ) ) ); echo '
'; if ( $ai4seo_can_administer_plugin && ! $ai4seo_heavy_db_operations_disabled && 'completed' === $ai4seo_posts_table_analysis_state ) { echo "
"; ai4seo_echo_wp_kses( ai4seo_get_small_icon_button_tag( 'rotate', __( 'Refresh statistics', 'ai-for-seo' ), '', 'ai4seo_refresh_dashboard_statistics(this); return false;' ) ); echo '
'; } echo '
'; // Keep diagnostics available when the banner is absent, without repeating a visible notification. if ( 'completed' !== $ai4seo_posts_table_analysis_state || $ai4seo_posts_table_analysis_status['warning'] || ! empty( $ai4seo_posts_table_analysis_status['background'] ) ) { if ( ! isset( $ai4seo_notifications['unfinished-posts-table-analysis'] ) || ( ! empty( $ai4seo_posts_table_analysis_status['background'] ) && 'incomplete' === $ai4seo_posts_table_analysis_status['status'] && empty( $ai4seo_posts_table_analysis_status['readiness']['blocked_options'] ) ) ) { echo '
'; ai4seo_echo_wp_kses( ai4seo_get_posts_table_analysis_notice_message( $ai4seo_posts_table_analysis_status ) ); echo '
'; } if ( 'completed' !== $ai4seo_posts_table_analysis_state ) { ai4seo_echo_wp_kses( ai4seo_get_dashboard_preliminary_results_notice( $ai4seo_posts_table_analysis_status ) ); } // Fast refresh is useful only while another bounded analysis attempt can make progress. if ( ! $ai4seo_heavy_db_operations_disabled && 'incomplete' === $ai4seo_posts_table_analysis_status['status'] && empty( $ai4seo_posts_table_analysis_status['background'] ) ) { echo "
"; } } // Default chart values keep the legend order stable before post-type data is available. $ai4seo_chart_values = ai4seo_get_seo_coverage_chart_values(); // Keep one accumulator for the shared legend because the per-post-type chart variable is replaced in the loop. $ai4seo_chart_legend_values = $ai4seo_chart_values; $ai4seo_could_output_any_chart = false; foreach ( $ai4seo_all_supported_post_types as $ai4seo_this_post_type ) { $ai4seo_chart_context = in_array( $ai4seo_this_post_type, $ai4seo_supported_attachment_post_types, true ) ? AI4SEO_BULK_GENERATION_QUEUE_CONTEXT_ATTACHMENT_ATTRIBUTES : AI4SEO_BULK_GENERATION_QUEUE_CONTEXT_METADATA; $ai4seo_chart_options = ai4seo_get_bulk_generation_queue_options_by_context( $ai4seo_chart_context ); if ( array_intersect( array_values( $ai4seo_chart_options ), $ai4seo_analysis_readiness['blocked_options'] ) ) { $ai4seo_could_output_any_chart = true; echo '
' . esc_html( ai4seo_get_post_type_translation( $ai4seo_this_post_type, true ) ) . ': ' . esc_html__( 'Status breakdown unavailable because queue or exclusion data could not be read.', 'ai-for-seo' ) . '
'; continue; } $ai4seo_this_original_post_type = $ai4seo_this_post_type; $ai4seo_this_num_finished_post_ids = $ai4seo_num_finished_posts_by_post_type[ $ai4seo_this_post_type ] ?? 0; $ai4seo_this_num_failed_post_ids = $ai4seo_num_failed_posts_by_post_type[ $ai4seo_this_post_type ] ?? 0; $ai4seo_this_num_pending_post_ids = $ai4seo_num_pending_posts_by_post_type[ $ai4seo_this_post_type ] ?? 0; $ai4seo_this_num_processing_post_ids = $ai4seo_num_processing_posts_by_post_type[ $ai4seo_this_post_type ] ?? 0; $ai4seo_this_num_missing_post_ids = $ai4seo_num_missing_posts_by_post_type[ $ai4seo_this_post_type ] ?? 0; $ai4seo_this_num_eligible_for_auto_queue_post_ids = 0; if ( $ai4seo_can_administer_plugin && $ai4seo_this_num_failed_post_ids > 0 ) { if ( 'attachment' === $ai4seo_this_original_post_type ) { $ai4seo_retry_all_failed_attachment_attributes_generations_link_tag = ai4seo_get_small_icon_button_tag( 'rotate', $ai4seo_retry_all_failed_attachment_attributes_generations_link_label, 'ai4seo-ignore-during-dashboard-refresh', 'ai4seo_retry_all_failed_attachment_attributes(this); return false;' ); } elseif ( ! isset( $ai4seo_retry_all_failed_metadata_button_tags[ $ai4seo_this_original_post_type ] ) ) { $ai4seo_retry_all_failed_metadata_button_tags[ $ai4seo_this_original_post_type ] = ai4seo_get_small_icon_button_tag( 'rotate', sprintf( $ai4seo_retry_all_failed_metadata_generations_link_label, ai4seo_get_post_type_translation( $ai4seo_this_original_post_type, true ) ), 'ai4seo-ignore-during-dashboard-refresh', "ai4seo_retry_all_failed_metadata(this, '" . esc_js( $ai4seo_this_original_post_type ) . "'); return false;" ); } } // Remove failed, pending, and processing entries from the coverage analyzer's missing total. $ai4seo_this_num_missing_post_ids -= $ai4seo_this_num_failed_post_ids; $ai4seo_this_num_missing_post_ids -= $ai4seo_this_num_pending_post_ids; $ai4seo_this_num_missing_post_ids -= $ai4seo_this_num_processing_post_ids; if ( $ai4seo_this_num_missing_post_ids < 0 ) { $ai4seo_this_num_missing_post_ids = 0; } // Attachment classification selects both the relevant credit cost and the pending-status subtotal. $ai4seo_this_is_attachment_post_type = in_array( $ai4seo_this_original_post_type, $ai4seo_supported_attachment_post_types, true ); $ai4seo_this_can_auto_queue_entries = in_array( $ai4seo_this_original_post_type, $ai4seo_active_bulk_generation_post_types, true ) && ( $ai4seo_this_is_attachment_post_type ? $ai4seo_can_auto_queue_attachment_attribute_entries : $ai4seo_can_auto_queue_metadata_entries ); // Split immediately queueable entries from truly missing SEO without changing the chart total. if ( $ai4seo_this_can_auto_queue_entries ) { $ai4seo_this_num_eligible_for_auto_queue_post_ids = $ai4seo_this_num_missing_post_ids; $ai4seo_this_num_missing_post_ids = 0; } // Status-card totals include every incomplete entry for enabled post types, independent of chart segmentation. if ( in_array( $ai4seo_this_post_type, $ai4seo_active_bulk_generation_post_types, true ) ) { $ai4seo_this_num_pending_generation_posts = ( $ai4seo_this_num_missing_post_ids + $ai4seo_this_num_eligible_for_auto_queue_post_ids + $ai4seo_this_num_pending_post_ids + $ai4seo_this_num_processing_post_ids ); $ai4seo_total_num_pending_posts += $ai4seo_this_num_pending_generation_posts; // Reuse the attachment classification that also selected the correct auto-queue credit cost above. if ( $ai4seo_this_is_attachment_post_type ) { $ai4seo_total_num_pending_attachment_posts += $ai4seo_this_num_pending_generation_posts; } else { $ai4seo_total_num_pending_metadata_posts += $ai4seo_this_num_pending_generation_posts; } } // Queued combines all pending queue entries with entries currently being processed. $ai4seo_this_num_queued_post_ids = $ai4seo_this_num_pending_post_ids + $ai4seo_this_num_processing_post_ids; // Build each chart through the shared status-order helper used by the aggregate legend. $ai4seo_chart_values = ai4seo_get_seo_coverage_chart_values( $ai4seo_this_num_finished_post_ids, $ai4seo_this_num_queued_post_ids, $ai4seo_this_num_eligible_for_auto_queue_post_ids, $ai4seo_this_num_missing_post_ids, $ai4seo_this_num_failed_post_ids ); // The shared legend aggregates every post-type chart while retaining the same semantic key order. foreach ( $ai4seo_chart_values as $ai4seo_chart_status => $ai4seo_chart_status_info ) { $ai4seo_chart_legend_values[ $ai4seo_chart_status ]['value'] += $ai4seo_chart_status_info['value']; } // get total value, and continue if it is 0. $ai4seo_total_value = array_sum( array_column( $ai4seo_chart_values, 'value' ) ); // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- Treat integer and floating-point zero totals equivalently. if ( 0 == $ai4seo_total_value ) { continue; } $ai4seo_could_output_any_chart = true; // attachment -> media workaround. if ( 'attachment' === $ai4seo_this_post_type ) { $ai4seo_this_post_type = 'media'; } $ai4seo_supported_post_type_label = ai4seo_get_dashicon_tag_for_navigation( $ai4seo_this_post_type ); $ai4seo_supported_post_type_label .= ucfirst( ai4seo_get_post_type_translation( $ai4seo_this_post_type, true ) ); // Link to the existing missing-field scope, including queued/failed items with incomplete fields. $ai4seo_review_missing_fields_url = ''; if ( 'completed' === $ai4seo_posts_table_analysis_state && $ai4seo_this_num_finished_post_ids < $ai4seo_total_value ) { $ai4seo_review_missing_fields_query_args = array( 'ai4seo_page' => 1, 'ai4seo_filter_status' => 'missing', 'ai4seo_content_type_filter_nonce' => wp_create_nonce( 'ai4seo_content_type_filter_form' ), ); if ( ! $ai4seo_this_is_attachment_post_type ) { $ai4seo_review_missing_fields_query_args['ai4seo_post_type'] = $ai4seo_this_original_post_type; } $ai4seo_review_missing_fields_url = ai4seo_get_subpage_url( $ai4seo_this_is_attachment_post_type ? 'media' : 'post', $ai4seo_review_missing_fields_query_args ); } ai4seo_echo_half_donut_chart_with_headline_and_percentage( $ai4seo_supported_post_type_label, $ai4seo_chart_values, $ai4seo_this_num_finished_post_ids, $ai4seo_total_value, $ai4seo_posts_table_analysis_state, $ai4seo_this_post_type, $ai4seo_review_missing_fields_url ); } // Taxonomies retain their own identities and list routes, outside the public post-type registry. $ai4seo_enabled_dashboard_taxonomies = ai4seo_get_enabled_bulk_generation_taxonomies(); $ai4seo_taxonomy_option_inspections = array(); $ai4seo_taxonomy_blocked_options = array_intersect( array_values( ai4seo_get_bulk_generation_queue_options_by_context( AI4SEO_BULK_GENERATION_QUEUE_CONTEXT_METADATA ) ), $ai4seo_analysis_readiness['blocked_options'] ); $ai4seo_has_unavailable_taxonomy_chart = false; foreach ( $ai4seo_dashboard_taxonomies as $ai4seo_taxonomy_name => $ai4seo_taxonomy_entry ) { if ( empty( $ai4seo_taxonomy_entry['has_entries'] ) || is_wp_error( $ai4seo_public_taxonomies ) || ! isset( $ai4seo_public_taxonomies[ $ai4seo_taxonomy_name ] ) ) { continue; } $ai4seo_taxonomy_summary = ai4seo_read_taxonomy_generation_counts( $ai4seo_taxonomy_name, true, $ai4seo_taxonomy_option_inspections ); $ai4seo_taxonomy_headline = ai4seo_get_dashicon_tag_for_navigation( $ai4seo_taxonomy_name ) . esc_html( rtrim( $ai4seo_taxonomy_entry['label'], " \t\n\r\0\x0B:" ) ); if ( is_wp_error( $ai4seo_taxonomy_summary ) || $ai4seo_taxonomy_blocked_options || 'completed' !== $ai4seo_posts_table_analysis_state ) { $ai4seo_has_unavailable_taxonomy_chart = true; $ai4seo_taxonomy_is_preparing = ! is_wp_error( $ai4seo_taxonomy_summary ) && ! $ai4seo_taxonomy_blocked_options && 'incomplete' === $ai4seo_posts_table_analysis_status['status'] && empty( $ai4seo_posts_table_analysis_status['background'] ); $ai4seo_taxonomy_status_label = $ai4seo_taxonomy_is_preparing ? __( 'Status is being prepared', 'ai-for-seo' ) : __( 'Status is currently unavailable', 'ai-for-seo' ); ai4seo_echo_half_donut_chart_with_headline_and_percentage( $ai4seo_taxonomy_headline, array(), 0, 0, $ai4seo_posts_table_analysis_state, 'taxonomy-' . $ai4seo_taxonomy_name, '', $ai4seo_taxonomy_status_label ); continue; } // Count each archive once, even while a complete entry is queued for regeneration. $ai4seo_taxonomy_complete = $ai4seo_taxonomy_summary['complete']; $ai4seo_taxonomy_queued = $ai4seo_taxonomy_summary['queued']; $ai4seo_taxonomy_failed = $ai4seo_taxonomy_summary['failed']; $ai4seo_taxonomy_missing = $ai4seo_taxonomy_summary['missing']; // Status and credit totals also include complete archives explicitly queued for regeneration. if ( in_array( $ai4seo_taxonomy_name, $ai4seo_enabled_dashboard_taxonomies, true ) ) { $ai4seo_taxonomy_pending_count = $ai4seo_taxonomy_summary['pending']; $ai4seo_total_num_pending_posts += $ai4seo_taxonomy_pending_count; $ai4seo_total_num_pending_metadata_posts += $ai4seo_taxonomy_pending_count; } // Missing fields alone do not prove automatic eligibility: archive content may be too short. $ai4seo_chart_values = ai4seo_get_seo_coverage_chart_values( $ai4seo_taxonomy_complete, $ai4seo_taxonomy_queued, 0, $ai4seo_taxonomy_missing, $ai4seo_taxonomy_failed ); $ai4seo_total_value = array_sum( array_column( $ai4seo_chart_values, 'value' ) ); if ( 0 === $ai4seo_total_value ) { continue; } $ai4seo_could_output_any_chart = true; foreach ( $ai4seo_chart_values as $ai4seo_chart_status => $ai4seo_chart_status_info ) { $ai4seo_chart_legend_values[ $ai4seo_chart_status ]['value'] += $ai4seo_chart_status_info['value']; } $ai4seo_review_missing_fields_url = ''; if ( 'completed' === $ai4seo_posts_table_analysis_state && $ai4seo_taxonomy_complete < $ai4seo_total_value ) { $ai4seo_review_missing_fields_url = add_query_arg( array( 'ai4seo_page' => 1, 'ai4seo_taxonomy_availability' => 'active', 'ai4seo_filter_status' => 'missing', ), $ai4seo_taxonomy_entry['url'] ); } ai4seo_echo_half_donut_chart_with_headline_and_percentage( $ai4seo_taxonomy_headline, $ai4seo_chart_values, $ai4seo_taxonomy_complete, $ai4seo_total_value, $ai4seo_posts_table_analysis_state, 'taxonomy-' . $ai4seo_taxonomy_name, $ai4seo_review_missing_fields_url ); } // chart legend container. if ( $ai4seo_could_output_any_chart && ! $ai4seo_analysis_has_queue_restrictions ) { echo "
"; ai4seo_echo_chart_legend( $ai4seo_chart_legend_values, $ai4seo_is_any_bulk_generation_enabled ); echo '
'; } // Keep the refresh explanation inside the card, below every chart and the shared legend. ai4seo_echo_wp_kses( ai4seo_get_dashboard_analysis_refresh_notice( ai4seo_get_dashboard_analysis_refresh_pause( $ai4seo_posts_table_analysis_status ), $ai4seo_can_administer_plugin ) ); // no data message. if ( ! $ai4seo_could_output_any_chart && ! $ai4seo_has_unavailable_taxonomy_chart && empty( $ai4seo_posts_table_analysis_status['progress']['warnings']['count'] ) && 'completed' === $ai4seo_posts_table_analysis_state ) { echo "
"; echo "
"; echo '' . esc_html__( 'Note:', 'ai-for-seo' ) . ' '; echo esc_html__( 'No data to display yet. Please review your settings. It looks like all entries are currently excluded from analysis based on your configuration.', 'ai-for-seo' ); echo '
'; echo '
'; } // Surface invalid persisted state instead of silently presenting statistics the queue cannot reproduce. if ( empty( $ai4seo_bulk_generation_date_filter_state['is_valid'] ) ) { echo "
"; echo "
"; echo '' . esc_html__( 'SEO Autopilot paused:', 'ai-for-seo' ) . ' '; echo esc_html( ai4seo_get_invalid_bulk_generation_date_filter_message() ); echo '
'; echo '
'; } // Escape each setting label before combining it with the notice's allowed emphasis markup. if ( $ai4seo_statistics_filter_labels ) { echo "
"; echo "
"; ai4seo_echo_wp_kses( sprintf( /* translators: %s: list of active settings that may exclude entries, with each label in bold. */ __( 'Some entries may be excluded from these statistics by: %s.', 'ai-for-seo' ), '' . implode( '; ', array_map( 'esc_html', $ai4seo_statistics_filter_labels ) ) . '' ) ); echo '
'; echo '
'; } if ( $ai4seo_can_administer_plugin && ( $ai4seo_retry_all_failed_metadata_button_tags || $ai4seo_retry_all_failed_attachment_attributes_generations_link_tag ) ) { echo "
"; if ( $ai4seo_retry_all_failed_metadata_button_tags ) { foreach ( $ai4seo_retry_all_failed_metadata_button_tags as $ai4seo_this_retry_button_tag ) { ai4seo_echo_wp_kses( $ai4seo_this_retry_button_tag ); } } if ( $ai4seo_retry_all_failed_attachment_attributes_generations_link_tag ) { ai4seo_echo_wp_kses( $ai4seo_retry_all_failed_attachment_attributes_generations_link_tag ); } echo '
'; } echo '
'; // If manual queueing is enabled but no active post type has anything left to generate, show the normal finished state. if ( $ai4seo_is_waiting_for_manual_queue_entries && 0 === $ai4seo_total_num_pending_posts ) { $ai4seo_is_waiting_for_manual_queue_entries = false; } } // force line break // echo "
";. // === CREDITS ========================================================================== \\ // Calculate backlog coverage separately from "can generate anything" so large sites with <1% coverage do not show a false insufficiency warning. $ai4seo_can_afford_at_least_one_generation = true; if ( ! $ai4seo_analysis_has_queue_restrictions && isset( $ai4seo_total_num_pending_posts ) && $ai4seo_total_num_pending_posts ) { $ai4seo_pending_generation_costs = array(); if ( $ai4seo_total_num_pending_metadata_posts > 0 && $ai4seo_metadata_credits_cost_per_post > 0 ) { $ai4seo_pending_generation_costs[] = $ai4seo_metadata_credits_cost_per_post; } if ( $ai4seo_total_num_pending_attachment_posts > 0 && $ai4seo_attachment_attributes_credits_cost_per_attachment_post > 0 ) { $ai4seo_pending_generation_costs[] = $ai4seo_attachment_attributes_credits_cost_per_attachment_post; } if ( $ai4seo_pending_generation_costs ) { $ai4seo_min_credits_cost_for_pending_generation = min( $ai4seo_pending_generation_costs ); $ai4seo_max_credits_cost_for_pending_generation = max( $ai4seo_pending_generation_costs ); $ai4seo_can_afford_at_least_one_generation = ( $ai4seo_current_credits_balance >= $ai4seo_min_credits_cost_for_pending_generation ); if ( $ai4seo_can_afford_at_least_one_generation ) { $ai4seo_total_required_credits = max( 1, ( $ai4seo_total_num_pending_posts * $ai4seo_max_credits_cost_for_pending_generation ) ); $ai4seo_raw_credits_percentage = ( $ai4seo_current_credits_balance / $ai4seo_total_required_credits ) * 100; $ai4seo_credits_percentage = min( 100, max( 1, floor( $ai4seo_raw_credits_percentage ) ) ); } else { $ai4seo_credits_percentage = 0; } } else { $ai4seo_credits_percentage = 100; } } else { $ai4seo_credits_percentage = 100; } echo "
"; if ( $ai4seo_can_administer_plugin ) { // Refreshing account data is an administrative operation. echo "
"; ai4seo_echo_wp_kses( ai4seo_get_small_icon_button_tag( 'rotate', __( 'Resync account', 'ai-for-seo' ), '', 'ai4seo_refresh_robhub_account(this); return false;' ) ); echo '
'; } // credits balance. echo "
"; echo "

"; echo esc_html__( 'Credits', 'ai-for-seo' ); echo '

'; echo "
"; if ( null !== $ai4seo_account_readiness['credits'] ) { echo esc_html( ai4seo_format_number_i18n( $ai4seo_current_credits_balance ) ); } else { echo '' . esc_html__( 'Unavailable', 'ai-for-seo' ) . ''; } echo '
'; echo '
'; ai4seo_echo_wp_kses( ai4seo_get_account_quality_notice( false ) ); // next free credits container. if ( $ai4seo_is_robhub_account_synced && $ai4seo_next_free_credits_timestamp > time() && $ai4seo_current_credits_balance < $ai4seo_free_plan_credits_amount ) { echo "
"; $ai4seo_credits_badge_html = sprintf( '+%1$s %2$s', esc_html( ai4seo_format_number_i18n( AI4SEO_DAILY_FREE_CREDITS_AMOUNT ) ), esc_html__( 'Credits', 'ai-for-seo' ) ); $ai4seo_countdown_html = sprintf( '%2$s', esc_attr( $ai4seo_next_free_credits_seconds_left ), esc_html( ai4seo_format_seconds_to_hhmmss_or_days_hhmmss( $ai4seo_next_free_credits_seconds_left ) ) ); $ai4seo_next_free_credits_time_html = sprintf( '%s', $ai4seo_countdown_html ); ai4seo_echo_wp_kses( sprintf( /* translators: 1: credits badge HTML, 2: countdown HTML (wrapped in ) */ __( 'Next %1$s in %2$s', 'ai-for-seo' ), $ai4seo_credits_badge_html, $ai4seo_next_free_credits_time_html ) ); $ai4seo_free_credits_tooltip = sprintf( /* translators: 1: number of free credits, 2: free plan credits amount */ __( 'We provide you with %1$s free Credits each day if your balance falls below %2$s Credits. Simply keep using the plugin to receive them automatically.', 'ai-for-seo' ), esc_html( ai4seo_format_number_i18n( AI4SEO_DAILY_FREE_CREDITS_AMOUNT ) ), esc_html( ai4seo_format_number_i18n( $ai4seo_free_plan_credits_amount ) ), ); ai4seo_echo_wp_kses( ai4seo_get_icon_with_tooltip_tag( $ai4seo_free_credits_tooltip ) ); echo '
'; } if ( $ai4seo_can_administer_plugin ) { echo "
"; if ( $ai4seo_is_robhub_account_synced ) { // current discount. ai4seo_echo_current_discount(); // Turn Buy credits button. echo "
"; ai4seo_echo_wp_kses( ai4seo_get_icon_button_tag( 'circle-plus', esc_html__( 'Get more Credits', 'ai-for-seo' ), ( $ai4seo_current_credits_balance < AI4SEO_BLUE_GET_MORE_CREDITS_BUTTON_THRESHOLD || $ai4seo_credits_percentage < 100 ? 'ai4seo-primary-button' : '' ), 'ai4seo_open_get_more_credits_modal();' ) ); echo '
'; } else { // go to Account Settings. echo "
"; ai4seo_echo_wp_kses( ai4seo_get_a_tag_icon_button_tag( ai4seo_get_subpage_url( 'account' ), '', '', 'key', esc_html__( 'Account Settings', 'ai-for-seo' ), 'ai4seo-primary-button' ) ); } echo '
'; } // costs breakdown. echo "
"; ai4seo_echo_cost_breakdown_section( $ai4seo_credits_percentage, $ai4seo_can_afford_at_least_one_generation ); echo '
'; echo '
'; // ___________________________________________________________________________________________ \\ // === SEO AUTOPILOT ========================================================================= \\ // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ \\ $ai4seo_is_waiting_for_cron_trigger = ! $ai4seo_background_job['active'] && $ai4seo_background_job['next_run'] && $ai4seo_background_job['next_run'] <= time(); $ai4seo_additional_sub_status_text = '
'; $ai4seo_show_execute_sooner_button = false; // Add the last cron job call in a readable format. if ( $ai4seo_last_bulk_generation_update_time ) { // Use the shared formatter so relative and absolute execution-time messages stay consistent. $ai4seo_additional_sub_status_text .= ' ' . ai4seo_get_last_execution_time_text( $ai4seo_last_bulk_generation_update_time ); } elseif ( 'missing' === $ai4seo_background_job['time_quality'] ) { $ai4seo_additional_sub_status_text .= ' ' . esc_html__( 'The SEO Autopilot has never been executed yet.', 'ai-for-seo' ); } else { $ai4seo_additional_sub_status_text .= ' ' . esc_html__( 'The last execution time is unknown.', 'ai-for-seo' ); } // find proper task scheduler status text. if ( null === $ai4seo_next_cron_job_call_diff ) { $ai4seo_additional_sub_status_text .= ' ' . esc_html__( 'No execution is currently scheduled.', 'ai-for-seo' ); } elseif ( $ai4seo_next_cron_job_call_diff >= 10 ) { $ai4seo_next_cron_job_call_diff_minutes = ceil( $ai4seo_next_cron_job_call_diff / 60 ); $ai4seo_additional_sub_status_text .= ' ' . sprintf( /* translators: %s: time until the next scheduled automatic check. */ esc_html__( 'The next automatic check is scheduled within %s.', 'ai-for-seo' ), sprintf( /* translators: %s: number of minutes */ _n( '%s minute', '%s minutes', $ai4seo_next_cron_job_call_diff_minutes, 'ai-for-seo' ), ai4seo_format_number_i18n( $ai4seo_next_cron_job_call_diff_minutes ) ), ); } elseif ( ! $ai4seo_is_waiting_for_cron_trigger ) { $ai4seo_additional_sub_status_text .= ' ' . esc_html__( 'The next automatic check is due shortly.', 'ai-for-seo' ); } // Emphasize the existing automatic refresh behavior because the manual refresh fallback is no longer shown. $ai4seo_additional_sub_status_text .= ' ' . esc_html__( 'This page will refresh automatically.', 'ai-for-seo' ) . ''; $ai4seo_additional_sub_status_text .= '
'; $ai4seo_can_execute_sooner = $ai4seo_can_administer_plugin && ( null === $ai4seo_next_cron_job_call_diff || $ai4seo_next_cron_job_call_diff >= 70 ); // CARD. echo "
"; echo "

" . esc_html__( 'SEO Autopilot (Bulk Generation)', 'ai-for-seo' ) . '

'; echo "
"; if ( ! $ai4seo_account_readiness['credits_ready'] ) { echo ""; echo '
' . esc_html__( 'Account data needs attention', 'ai-for-seo' ) . '
'; ai4seo_echo_wp_kses( ai4seo_get_account_quality_notice() ); } elseif ( ! $ai4seo_is_any_bulk_generation_enabled ) { echo ""; echo "
"; echo esc_html__( 'Off', 'ai-for-seo' ); echo '
'; echo "
"; echo esc_html__( 'SEO Autopilot has not been set up yet.', 'ai-for-seo' ); echo '
'; } elseif ( $ai4seo_background_job['needs_attention'] ) { echo ""; ai4seo_echo_wp_kses( ai4seo_get_background_job_status_html( $ai4seo_background_job ) ); if ( ! $ai4seo_is_waiting_for_cron_trigger ) { $ai4seo_show_execute_sooner_button = $ai4seo_can_administer_plugin; } } elseif ( $ai4seo_bulk_queue_warnings && ! $ai4seo_background_job['active'] ) { echo ""; $ai4seo_queue_label = ! in_array( true, $ai4seo_bulk_queue_presentation['operational'], true ) ? $ai4seo_bulk_queue_presentation['label'] : __( 'Some Autopilot tasks are restricted', 'ai-for-seo' ); echo '
' . esc_html( $ai4seo_queue_label ) . '
'; echo '
' . esc_html( implode( ' ', array_unique( $ai4seo_bulk_queue_warnings ) ) ) . '
'; ai4seo_echo_wp_kses( $ai4seo_additional_sub_status_text ); $ai4seo_show_execute_sooner_button = $ai4seo_can_execute_sooner; } elseif ( $ai4seo_analysis_has_queue_restrictions && ! $ai4seo_background_job['active'] ) { echo ""; echo '
' . esc_html__( 'Automatic queue entries restricted', 'ai-for-seo' ) . '
'; echo '
' . esc_html( $ai4seo_posts_table_analysis_status['warning'] ) . '
'; } elseif ( $ai4seo_is_waiting_for_manual_queue_entries && ! $ai4seo_background_job['active'] ) { echo ""; echo "
"; echo esc_html__( 'Empty queue', 'ai-for-seo' ); echo '
'; echo "
"; echo esc_html__( 'Auto Queue Entries is disabled and the queue is empty. Add entries to the queue manually from the Posts or Media lists so SEO Autopilot can continue.', 'ai-for-seo' ); echo '
'; } elseif ( 'completed' !== $ai4seo_posts_table_analysis_state && ! $ai4seo_background_job['active'] ) { // Autopilot waits on the same analysis outcome shown above the coverage charts. echo ""; echo "
"; if ( ! empty( $ai4seo_posts_table_analysis_status['preparing'] ) ) { echo esc_html__( 'Preparing analysis', 'ai-for-seo' ); } else { echo 'incomplete' === $ai4seo_posts_table_analysis_status['status'] ? esc_html__( 'Analyzing...', 'ai-for-seo' ) : esc_html__( 'Analysis needs attention', 'ai-for-seo' ); } echo '
'; echo "
"; echo esc_html( $ai4seo_posts_table_analysis_status['message'] ); echo '
'; } elseif ( isset( $ai4seo_total_num_pending_posts ) && 0 === $ai4seo_total_num_pending_posts && 0 === $ai4seo_bulk_generation_processing_count && ! $ai4seo_background_job['active'] && ! $ai4seo_autopilot_item_notice['all_tokens'] && ! $ai4seo_selection_continuation_warnings ) { echo ""; echo "
"; echo esc_html__( 'All done & idle', 'ai-for-seo' ); echo '
'; echo "
"; echo esc_html__( 'Waiting for new entries to process.', 'ai-for-seo' ); echo '
'; } elseif ( ! $ai4seo_can_afford_at_least_one_generation && ! $ai4seo_background_job['active'] ) { echo ""; // triangle-exclamation on the top right corner. echo "
"; ai4seo_echo_wp_kses( ai4seo_get_svg_tag( 'triangle-exclamation' ) ); echo '
'; echo "
"; echo esc_html__( 'Insufficient Credits', 'ai-for-seo' ); echo '
'; echo "
"; echo esc_html__( 'Not enough Credits available. Please get more Credits.', 'ai-for-seo' ); echo '
'; } elseif ( ! $ai4seo_background_job['active'] ) { echo ""; ai4seo_echo_wp_kses( ai4seo_get_background_job_status_html( $ai4seo_background_job ) ); if ( ! $ai4seo_is_waiting_for_cron_trigger ) { ai4seo_echo_wp_kses( $ai4seo_additional_sub_status_text ); $ai4seo_show_execute_sooner_button = $ai4seo_can_execute_sooner; } } else { echo "
"; echo ""; echo ""; echo '
'; echo "
"; echo esc_html__( 'Processing...', 'ai-for-seo' ); echo '
'; echo "
"; echo esc_html__( 'Please wait and check the "Recent Activity" section for results.', 'ai-for-seo' ); // Reinforce that the processing state will update without requiring a manual reload. echo ' ' . esc_html__( 'This page will refresh automatically.', 'ai-for-seo' ) . ''; echo '
'; } // Item diagnostics supplement the live execution state and never replace its schedule or animation. if ( $ai4seo_bulk_queue_warnings && ( $ai4seo_background_job['active'] || $ai4seo_background_job['needs_attention'] ) ) { echo '
' . esc_html( implode( ' ', array_unique( $ai4seo_bulk_queue_warnings ) ) ) . '
'; } if ( $ai4seo_autopilot_item_notice['tokens'] ) { echo '
'; echo '' . esc_html__( 'Some items need review', 'ai-for-seo' ) . ''; echo '

' . esc_html( implode( ' ', $ai4seo_autopilot_item_notice['messages'] ) ) . '

'; ai4seo_echo_wp_kses( ai4seo_get_a_tag_icon_button_tag( '#ai4seo-recent-activity', '', '', 'list', esc_html__( 'View Recent Activity', 'ai-for-seo' ), 'ai4seo-small-button' ) ); ai4seo_echo_wp_kses( ai4seo_get_small_icon_button_tag( 'xmark', esc_html__( 'Dismiss', 'ai-for-seo' ), '', 'ai4seo_dismiss_autopilot_item_notice(this);' ) ); echo '
'; } if ( $ai4seo_show_execute_sooner_button ) { echo '
'; ai4seo_echo_wp_kses( $ai4seo_execute_sooner_button ); echo '
'; } echo '
'; if ( $ai4seo_can_administer_plugin ) { // Bulk Generation controls change site-wide automation settings. echo "
"; echo "
"; if ( $ai4seo_is_any_bulk_generation_enabled ) { // stop SEO Autopilot. ai4seo_echo_wp_kses( ai4seo_get_abort_button_tag( 'stop-circle', esc_html__( 'Stop SEO Autopilot', 'ai-for-seo' ), '', 'ai4seo_stop_bulk_generation(this);' ) ); } // setup SEO Autopilot. ai4seo_echo_wp_kses( ai4seo_get_icon_button_tag( 'paper-plane', esc_html__( 'Set up SEO Autopilot', 'ai-for-seo' ), '', 'ai4seo_open_modal_from_schema("seo-autopilot", {modal_size: "small", unsaved_changes_warnings: true});' ) ); echo '
'; echo '
'; } echo '
'; // === Recent Activity ========================================================================== \\ $ai4seo_latest_activity = ai4seo_get_option( AI4SEO_LATEST_ACTIVITY_OPTION_NAME, array() ); $ai4seo_latest_activity = is_array( $ai4seo_latest_activity ) ? ai4seo_filter_latest_activity_entries_for_current_user( $ai4seo_latest_activity ) : array(); // Give the failed-status legend action a stable target within the incrementally refreshed dashboard. echo "
"; echo "

" . esc_html__( 'Recent Activity', 'ai-for-seo' ) . '

'; if ( ! $ai4seo_latest_activity ) { echo "

" . esc_html__( 'No recent activity. Try to generate metadata or media attributes first.', 'ai-for-seo' ) . '

'; } else { echo "
"; foreach ( $ai4seo_latest_activity as $ai4seo_this_latest_activity_entry ) { // Resolve one fallback title for both the visible entry text and its action-specific accessible labels. $ai4seo_this_plugin_page_icon = ai4seo_get_dashicon_tag_for_navigation( $ai4seo_this_latest_activity_entry['post_type'] ?? '' ); $ai4seo_this_latest_activity_entry_title = (string) ( $ai4seo_this_latest_activity_entry['title'] ?? '' ); if ( '' === $ai4seo_this_latest_activity_entry_title ) { if ( $ai4seo_this_latest_activity_entry['post_id'] ?? 0 ) { $ai4seo_this_latest_activity_entry_title = sprintf( /* translators: %s: Post ID. */ esc_html__( 'Post ID %s', 'ai-for-seo' ), $ai4seo_this_latest_activity_entry['post_id'] ); } else { $ai4seo_this_latest_activity_entry_title = esc_html__( 'N/A', 'ai-for-seo' ); } } echo "
"; echo "
"; ai4seo_echo_wp_kses( $ai4seo_this_plugin_page_icon ); echo '
'; echo "
"; echo ''; if ( $ai4seo_this_latest_activity_entry['timestamp'] ?? 0 ) { echo esc_html( ai4seo_format_unix_timestamp( $ai4seo_this_latest_activity_entry['timestamp'] ?? 0 ) ) . ' - '; } echo ''; // title. echo esc_html( $ai4seo_this_latest_activity_entry_title ); echo '
'; // status. $ai4seo_this_latest_activity_entry_is_success = ( $ai4seo_this_latest_activity_entry['status'] ?? 'error' ) === 'success'; if ( $ai4seo_this_latest_activity_entry_is_success ) { echo "
"; ai4seo_echo_wp_kses( ai4seo_get_svg_tag( 'circle-check', esc_html__( 'Success', 'ai-for-seo' ), 'ai4seo-gray-icon' ) ); echo ' '; } else { echo "
"; ai4seo_echo_wp_kses( ai4seo_get_svg_tag( 'circle-xmark', esc_html__( 'Error', 'ai-for-seo' ), 'ai4seo-red-icon' ) ); echo ' '; } // Keep the compact action bounded while rendering operational diagnostics completely on their own line. $ai4seo_this_latest_activity_message_parts = ai4seo_get_latest_activity_message_parts( $ai4seo_this_latest_activity_entry ); echo esc_html( ai4seo_mb_substr( $ai4seo_this_latest_activity_message_parts['summary'], 0, 160 ) ); if ( '' !== $ai4seo_this_latest_activity_message_parts['details'] ) { echo '
'; echo "" . esc_html( $ai4seo_this_latest_activity_message_parts['details'] ) . ''; } echo '
'; echo '
'; if ( $ai4seo_this_latest_activity_entry['cost'] ?? 0 ) { echo "
"; echo esc_html( ai4seo_format_number_i18n( $ai4seo_this_latest_activity_entry['cost'] ) ) . ' ' . esc_html__( 'Cr.', 'ai-for-seo' ); echo '
'; } echo "
"; // see post / media preview. if ( isset( $ai4seo_this_latest_activity_entry['url'] ) && $ai4seo_this_latest_activity_entry['url'] ) { $ai4seo_view_latest_activity_entry_label = sprintf( /* translators: %s: Entry title. */ esc_html__( 'View %s', 'ai-for-seo' ), $ai4seo_this_latest_activity_entry_title ); ai4seo_echo_wp_kses( ai4seo_get_a_tag_icon_button_tag( $ai4seo_this_latest_activity_entry['url'], '', '_blank', 'eye', '', '', '', $ai4seo_view_latest_activity_entry_label ) ); } // Preserve legacy numeric post types as strings while rejecting compound stored values. $ai4seo_this_latest_activity_post_type = $ai4seo_this_latest_activity_entry['post_type'] ?? ''; $ai4seo_this_latest_activity_post_type = is_string( $ai4seo_this_latest_activity_post_type ) || is_int( $ai4seo_this_latest_activity_post_type ) ? (string) $ai4seo_this_latest_activity_post_type : ''; if ( in_array( $ai4seo_this_latest_activity_post_type, $ai4seo_supported_attachment_post_types, true ) ) { // Name the icon-only editor action with the same entry identity shown in this activity row. $ai4seo_open_latest_activity_entry_editor_label = sprintf( /* translators: %s: Entry title. */ esc_html__( 'Open media attributes editor for %s', 'ai-for-seo' ), $ai4seo_this_latest_activity_entry_title ); ai4seo_echo_wp_kses( ai4seo_get_icon_button_tag( 'pen-to-square', '', '', 'ai4seo_open_attachment_attributes_editor_modal(' . esc_js( $ai4seo_this_latest_activity_entry['post_id'] ) . ');', $ai4seo_open_latest_activity_entry_editor_label ) ); } else { // Keep the metadata editor action distinct from the adjacent view-entry action for screen readers. $ai4seo_open_latest_activity_entry_editor_label = sprintf( /* translators: %s: Entry title. */ esc_html__( 'Open metadata editor for %s', 'ai-for-seo' ), $ai4seo_this_latest_activity_entry_title ); ai4seo_echo_wp_kses( ai4seo_get_icon_button_tag( 'pen-to-square', '', '', 'ai4seo_open_metadata_editor_modal(' . esc_js( $ai4seo_this_latest_activity_entry['post_id'] ) . ');', $ai4seo_open_latest_activity_entry_editor_label ) ); } echo '
'; echo '
'; } echo '
'; } // todo: add show full log button. echo '
'; $ai4seo_dashboard_toggle_onclick = 'ai4seo_toggle_collapsible_section(this, 200);'; $ai4seo_dashboard_toggle_onkeydown = 'ai4seo_handle_collapsible_section_keydown(event, this, 200);'; // === Ask for feedback ========================================================================== \\ $ai4seo_support_feedback_trigger_id = 'ai4seo-support-feedback-trigger'; $ai4seo_support_feedback_panel_id = 'ai4seo-support-feedback-panel'; echo "
"; echo "

"; echo "'; echo '

'; echo "
"; // HELP SECTION // icon. ai4seo_echo_wp_kses( ai4seo_get_svg_tag( 'circle-question', __( 'Help section', 'ai-for-seo' ), 'ai4seo-big-paragraph-icon' ) ); echo ' '; ai4seo_echo_wp_kses( sprintf( /* translators: %1$s is help section link, %2$s is getting started guide link, %3$s is FAQ link, %4$s is useful links section link */ __( 'Check our help section for a detailed getting started guide, our organized F.A.Q or other useful links.', 'ai-for-seo' ), esc_url( $ai4seo_help_page_url ), esc_url( $ai4seo_help_page_url . '#ai4seo-getting-started-section' ), esc_url( $ai4seo_help_page_url . '#ai4seo-faq-section' ), esc_url( $ai4seo_help_page_url . '#ai4seo-links-section' ) ) ); // button to help section. echo "
"; ai4seo_echo_wp_kses( ai4seo_get_a_tag_icon_button_tag( $ai4seo_help_page_url, '', '', 'arrow-up-right-from-square', esc_html__( 'Go to our help section', 'ai-for-seo' ) ) ); echo '
'; // CONTACT US // icon. ai4seo_echo_wp_kses( ai4seo_get_svg_tag( 'comments', __( 'Contact us', 'ai-for-seo' ), 'ai4seo-big-paragraph-icon' ) ); echo ' '; ai4seo_echo_wp_kses( sprintf( __( 'Missing a feature, need assistance, or looking for a quote?', 'ai-for-seo' ) . ' ' . /* translators: %s is a clickable email address */ __( "Please contact us. We offer support in any language.", 'ai-for-seo' ), esc_url( AI4SEO_OFFICIAL_CONTACT_URL ) ) ); // button to contact us. echo "
"; ai4seo_echo_wp_kses( ai4seo_get_contact_us_button() ); echo '
'; // RATE US // icon. ai4seo_echo_wp_kses( ai4seo_get_svg_tag( 'star', __( 'Rate us', 'ai-for-seo' ), 'ai4seo-big-paragraph-icon' ) ); echo ' '; // like our plugin rate us at AI4SEO_OFFICIAL_WORDPRESS_ORG_PAGE. ai4seo_echo_wp_kses( sprintf( /* translators: %s is the rate us link */ __( "Like our plugin and want to support us? Please rate us on WordPress.org. We appreciate your feedback!", 'ai-for-seo' ), esc_url( AI4SEO_OFFICIAL_RATE_US_URL ) ) ); // button to rate us. echo "
"; ai4seo_echo_wp_kses( ai4seo_get_a_tag_icon_button_tag( esc_url( AI4SEO_OFFICIAL_RATE_US_URL ), '', '_blank', 'arrow-up-right-from-square', esc_html__( 'Rate us', 'ai-for-seo' ) ) ); echo '
'; echo '
'; echo '
'; // === Recent Plugin Updates ========================================================================== \\ $ai4seo_recent_plugin_updates_trigger_id = 'ai4seo-recent-plugin-updates-trigger'; $ai4seo_recent_plugin_updates_panel_id = 'ai4seo-recent-plugin-updates-panel'; echo "
"; echo "

"; echo "'; echo '

'; echo "
"; echo esc_html__( 'We update the plugin regularly to improve its performance and add new features. Please check the changelog for more information.', 'ai-for-seo' ) . '
'; // Generate updates dynamically from const parameter. foreach ( $ai4seo_change_log as $ai4seo_this_plugin_update_index => $ai4seo_this_plugin_update_details ) { $ai4seo_this_is_first_plugin_update = ( 0 === $ai4seo_this_plugin_update_index ); $ai4seo_this_changes_count = count( $ai4seo_this_plugin_update_details['updates'] ); $ai4seo_this_is_important_update = $ai4seo_this_plugin_update_details['important'] ?? false; $ai4seo_this_plugin_update_dom_index = (int) $ai4seo_this_plugin_update_index + 1; $ai4seo_this_plugin_update_trigger = 'ai4seo-plugin-update-' . $ai4seo_this_plugin_update_dom_index . '-trigger'; $ai4seo_this_plugin_update_panel = 'ai4seo-plugin-update-' . $ai4seo_this_plugin_update_dom_index . '-panel'; // skip not important updates after the 5th entry. if ( $ai4seo_this_plugin_update_index >= 5 && ! $ai4seo_this_is_important_update ) { continue; } // Header with date, version, and collapsible functionality. echo "'; // Content - first entry expanded, others collapsed. echo "
"; echo '
    '; foreach ( $ai4seo_this_plugin_update_details['updates'] as $ai4seo_this_plugin_update_item ) { echo '
  • ' . wp_kses_post( $ai4seo_this_plugin_update_item ) . '
  • '; } echo '
'; echo '
'; } echo '
'; echo '
'; // === Money Back Guarantee ========================================================================== \\ $ai4seo_guarantee_trigger_id = 'ai4seo-guarantee-trigger'; $ai4seo_guarantee_panel_id = 'ai4seo-guarantee-panel'; echo "
"; echo "

"; echo "'; echo '

'; echo "
"; ai4seo_echo_wp_kses( ai4seo_get_svg_tag( 'handshake', __( 'Guarantee', 'ai-for-seo' ), 'ai4seo-handshake-icon' ) ); echo ' '; // The guarantee remains visible while no applicability filter is available here. ai4seo_output_money_back_guarantee_notice(); echo '
'; echo '
'; echo '
'; // Close the refresh root after the card grid so AJAX can return one complete dashboard boundary. echo '
';