admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'qo_admin_nonce' ), 'i18n' => array( 'processing' => __( 'Processing...', '365i-queue-optimizer' ), 'runQueue' => __( 'Run Queue', '365i-queue-optimizer' ), ), ) ); } /** * Get queue health status. * * @return array Health status data. */ private function get_health_status() { $status = array( 'health' => 'healthy', 'label' => __( 'Healthy', '365i-queue-optimizer' ), 'pending' => 0, 'running' => 0, 'failed' => 0, 'available' => false, ); if ( ! class_exists( 'ActionScheduler' ) || ! function_exists( 'as_get_scheduled_actions' ) ) { return $status; } $status['available'] = true; // Get pending count. $pending = as_get_scheduled_actions( array( 'status' => ActionScheduler_Store::STATUS_PENDING, 'per_page' => 0, ), 'ids' ); $status['pending'] = count( $pending ); // Get running count. $running = as_get_scheduled_actions( array( 'status' => ActionScheduler_Store::STATUS_RUNNING, 'per_page' => 0, ), 'ids' ); $status['running'] = count( $running ); // Get failed count (last 24h). $failed = as_get_scheduled_actions( array( 'status' => ActionScheduler_Store::STATUS_FAILED, 'per_page' => 0, 'date' => gmdate( 'Y-m-d H:i:s', time() - DAY_IN_SECONDS ), 'date_compare' => '>', ), 'ids' ); $status['failed'] = count( $failed ); // Determine health. if ( $status['failed'] > 0 ) { $status['health'] = 'critical'; $status['label'] = __( 'Needs Attention', '365i-queue-optimizer' ); } elseif ( $status['pending'] > 50 ) { $status['health'] = 'warning'; $status['label'] = __( 'Backlog', '365i-queue-optimizer' ); } return $status; } /** * Render the dashboard widget. */ public function render_widget() { $status = $this->get_health_status(); ?>

0 ) : ?>