'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 '' . esc_html( $ai4seo_scheduling_messages[ $ai4seo_execute_sooner_result['status'] ] ) . '';
} else {
echo '
';
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 ( '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 "
';
}
// 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 "
';
}
// 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 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 "
";
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 '
';
// 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 "