// ======== SHORTCODE: SPEAKER GRID (detail-state diagnostics) ======== // Usage: [pretalx_speakers columns="4" cache="600" debug="1"] add_shortcode('pretalx_speakers', function($atts){ $atts = shortcode_atts([ 'limit' => 0, 'cache' => 600, 'columns' => 4, 'debug' => 0, ], $atts, 'pretalx_speakers'); $is_admin = current_user_can('manage_options'); $debug = (int)$atts['debug'] === 1 && $is_admin; $no_cache = $debug || (int)$atts['cache'] === 0; $cache_key = 'pretalx_speakers_v7_detail_dbg_' . md5(PRETALX_BASE.PRETALX_EVENT.PRETALX_LOCALE.json_encode($atts)); $speakers = $no_cache ? null : get_transient($cache_key); // Diagnostics holder $diag = [ 'base' => PRETALX_BASE, 'event' => PRETALX_EVENT, 'token' => pretalx_get_token()!=='' ? 'yes' : 'no', 'list_total' => 0, 'detail_accepted' => 0, 'detail_confirmed' => 0, 'allowed_speaker_codes' => 0, 'speakers_total' => 0, ]; $dbg_rows = []; // will collect per-submission state lines // Small fetch helper: returns ['url','code','body'] $fetch = function($path, $args = []) { $args = array_filter($args, fn($v)=>$v!==null && $v!==''); $url = trailingslashit(PRETALX_BASE) . ltrim($path,'/'); if ($args) $url .= (strpos($url,'?')===false?'?':'&') . http_build_query($args); $headers = ['Accept'=>'application/json','User-Agent'=>'WP Pretalx Integrator/v7']; $tok = pretalx_get_token(); if ($tok!=='') $headers['Authorization']='Token '.$tok; $r = wp_remote_get($url, ['headers'=>$headers,'timeout'=>15]); $code = is_wp_error($r) ? -1 : (int)wp_remote_retrieve_response_code($r); $body = is_wp_error($r) ? null : json_decode(wp_remote_retrieve_body($r), true); return compact('url','code','body'); }; if (!$speakers) { // 1) List submissions (list endpoint may omit 'state') $list = $fetch("/api/events/".rawurlencode(PRETALX_EVENT)."/submissions/", [ 'limit'=>200, 'locale'=>PRETALX_LOCALE, ]); $subs = is_array($list['body']) ? $list['body'] : []; $diag['list_total'] = count($subs); // 2) For each submission, load detail to read 'state' and collect speaker codes $allowed_codes = []; // speaker codes of accepted/confirmed foreach ($subs as $s) { $code = (string)($s['code'] ?? ''); if ($code === '') continue; $detail = $fetch("/api/events/".rawurlencode(PRETALX_EVENT)."/submissions/".rawurlencode($code)."/", [ 'locale'=>PRETALX_LOCALE, ]); // collect debug info: which state string do we really get? if (is_array($detail['body'])) { $st = (string)($detail['body']['state'] ?? ''); $sp_names = []; foreach ((array)($detail['body']['speakers'] ?? []) as $spRow) { $sp_names[] = (string)($spRow['name'] ?? $spRow['code'] ?? ''); } $dbg_rows[] = [ 'code' => $code, 'state' => $st, 'speakers' => implode(', ', array_filter($sp_names)), ]; // Count and filter on canonical states (we’ll adjust once we see real strings) if ($st === 'accepted' || $st === 'confirmed') { if ($st === 'accepted') $diag['detail_accepted']++; if ($st === 'confirmed') $diag['detail_confirmed']++; foreach ((array)($detail['body']['speakers'] ?? []) as $sp) { if (!empty($sp['code'])) $allowed_codes[$sp['code']] = true; } } } } $diag['allowed_speaker_codes'] = count($allowed_codes); // 3) Fetch speakers (answers + avatar) $sp_all = $fetch("/api/events/".rawurlencode(PRETALX_EVENT)."/speakers/", [ 'limit'=>200, 'locale'=>PRETALX_LOCALE, 'questions'=>'all', ]); $all_speakers = is_array($sp_all['body']) ? $sp_all['body'] : []; $diag['speakers_total'] = count($all_speakers); // 4) Apply filter (if any accepted/confirmed found), else show none (debug mode) $filtered = []; if (!empty($allowed_codes)) { foreach ($all_speakers as $sp) { $sc = (string)($sp['code'] ?? ''); if ($sc !== '' && isset($allowed_codes[$sc])) $filtered[] = $sp; } } $speakers = $filtered; if (!$no_cache) set_transient($cache_key, $speakers, (int)$atts['cache']); } // DEBUG PANEL (admins only) if ($debug) { echo '
'; echo 'pretalx_speakers diagnostics (detail states)
'; echo 'Base: '.esc_html($diag['base']).' | Event: '.esc_html($diag['event']).' | Token: '.$diag['token']."
"; echo 'Submissions list: '.$diag['list_total']."
"; echo 'Detail states → accepted: '.$diag['detail_accepted'].' | confirmed: '.$diag['detail_confirmed']."
"; echo 'Allowed speaker codes: '.$diag['allowed_speaker_codes']."
"; echo 'Speakers total: '.$diag['speakers_total'].' | Rendered: '.(is_array($speakers)?count($speakers):0).""; if (!empty($dbg_rows)) { echo '
Submission detail states:
'; foreach ($dbg_rows as $r) { echo '• '.esc_html($r['code']).' → state '.esc_html($r['state]() https://sid.earth/post-sitemap.xml 2025-11-12T07:46:48+00:00 https://sid.earth/page-sitemap.xml 2025-11-06T17:02:15+00:00 https://sid.earth/session-sitemap.xml 2025-07-01T15:43:18+00:00 https://sid.earth/veranstaltungen-sitemap.xml 2022-10-12T12:16:34+00:00 https://sid.earth/avada_portfolio-sitemap.xml 2022-06-28T14:06:51+00:00 https://sid.earth/category-sitemap.xml 2025-11-12T07:46:48+00:00 https://sid.earth/post_tag-sitemap.xml 2024-04-08T13:42:00+00:00 https://sid.earth/fusion_tb_category-sitemap.xml 2024-11-06T07:14:37+00:00 https://sid.earth/events_category-sitemap.xml 2022-10-12T12:16:34+00:00 https://sid.earth/portfolio_category-sitemap.xml 2022-06-28T14:06:51+00:00 https://sid.earth/portfolio_skills-sitemap.xml 2022-06-28T14:06:51+00:00 https://sid.earth/portfolio_tags-sitemap.xml 2022-06-28T14:06:51+00:00 https://sid.earth/element_category-sitemap.xml 2025-07-17T09:56:54+00:00