*/ public static function items(array $ctx) { $urls = isset($ctx['urls']) && is_array($ctx['urls']) ? $ctx['urls'] : array(); $st = isset($ctx['statement']) && is_array($ctx['statement']) ? $ctx['statement'] : array(); $rows = array(); $rows[] = array( 'key' => 'connect', 'label' => __('Connect your site to AllAccessible', 'allaccessible'), 'done' => !empty($ctx['has_account']), 'url' => isset($urls['connect']) ? $urls['connect'] : admin_url('admin.php?page=allaccessible-wizard'), 'cta' => __('Connect', 'allaccessible'), ); $rows[] = array( 'key' => 'scan', 'label' => __('Run your first scan', 'allaccessible'), 'done' => !empty($ctx['scanned']), 'url' => isset($urls['scan']) ? $urls['scan'] : admin_url('admin.php?page=aacb-agentic-fixes'), 'cta' => __('Scan now', 'allaccessible'), ); if (!empty($ctx['has_agentic'])) { $rows[] = array( 'key' => 'fix', 'label' => __('Approve your first suggested fix ✦', 'allaccessible'), 'done' => (int) (isset($ctx['active_fixes']) ? $ctx['active_fixes'] : 0) > 0, 'url' => isset($urls['fixes']) ? $urls['fixes'] : admin_url('admin.php?page=aacb-agentic-fixes'), 'cta' => __('Review fixes', 'allaccessible'), ); } $has_page = !empty($st['page']); $published = !empty($st['published']); $registered = !empty($st['registered']); if (!$has_page) { $cta = __('Create it', 'allaccessible'); } elseif (!$published) { $cta = __('Publish it', 'allaccessible'); } else { $cta = __('Link it', 'allaccessible'); } $rows[] = array( 'key' => 'statement', 'label' => __('Publish an accessibility statement page', 'allaccessible'), 'done' => $published && $registered, 'url' => isset($urls['statement']) ? $urls['statement'] : admin_url('admin.php?page=allaccessible#aacb-statement-card'), 'cta' => $cta, ); return $rows; } public static function should_show(array $ctx) { $state = get_option(self::OPTION, array()); $state = is_array($state) ? $state : array(); if ((int) (isset($state['dismissed_version']) ? $state['dismissed_version'] : 0) >= self::VERSION) { return false; } foreach (self::items($ctx) as $row) { if (!$row['done']) return true; } return false; } public static function render(array $ctx) { $items = self::items($ctx); $total = count($items); $done = count(array_filter($items, function ($i) { return $i['done']; })); $left = $total - $done; $nonce = wp_create_nonce(self::AJAX_ACTION); $pct = $total > 0 ? (int) round(($done / $total) * 100) : 0; // The first undone row is "next": it carries its action inline. $next_key = ''; foreach ($items as $row) { if (!$row['done']) { $next_key = $row['key']; break; } } $statement_inline = ($next_key === 'statement') && class_exists('AllAccessible_StatementPage'); ?>
__('Unauthorized', 'allaccessible')), 403); } check_ajax_referer(self::AJAX_ACTION, '_wpnonce'); update_option(self::OPTION, array('dismissed_version' => self::VERSION, 'dismissed_at' => time()), false); wp_send_json_success(); } }