' . esc_html__('Where this form brings people from: the pages it was sent from, and the pages where its button and the call and chat buttons beside it were pressed.', 'ai-eshop-optimizer') . '
'; \Rooster\Admin\Markup::out(AIEO_Page_Actions::form_pages('aieo_form_' . (int) $post->ID)); } private static function notice($html, $tone) { return AIEO_DMM_UI::notice($html, $tone); } public static function render($post) { $form_id = (int) $post->ID; $fields = AIEO_Form_CPT::fields($form_id); $total = AIEO_Form_Entries::entry_count($form_id); if (empty($fields)) { echo '' . esc_html__('Add some fields first.', 'ai-eshop-optimizer') . '
'; return; } if (!$total) { echo '' . esc_html__('No answers yet.', 'ai-eshop-optimizer') . '
'; return; } printf( '%s %s
', esc_html(number_format_i18n($total)), esc_html(_n('entry recorded.', 'entries recorded.', $total, 'ai-eshop-optimizer')) ); $latest = AIEO_Form_Entries::latest($form_id, 20); $rows = array(); $decide = class_exists('AIEO_Pro_Signup') && '' !== AIEO_Pro_Signup::kind_of_form($form_id); $statuses = $decide ? AIEO_Pro_Signup::statuses(array_map(static function ($e) { return (int) $e['id']; }, $latest)) : array(); if ($decide) { \Rooster\Admin\Markup::out(AIEO_Pro_Signup::result_notice()); } if (!class_exists('AIEO_Submission_Panel', false) && defined('AIEO_DIR') && is_readable(AIEO_DIR . 'includes/dmm/class-aieo-submission-panel.php')) { require_once AIEO_DIR . 'includes/dmm/class-aieo-submission-panel.php'; } $leads = class_exists('AIEO_Submission_Panel') ? AIEO_Submission_Panel::keys_for('aieo_form', array_map(static function ($e) { return (int) $e['id']; }, $latest)) : array(); foreach ($latest as $entry) { $lines = array(); foreach ($fields as $f) { if (!isset($entry['answers'][$f['key']])) { continue; } $label = '' !== trim((string) $f['label']) ? (string) $f['label'] : (string) $f['key']; $value = (string) $entry['answers'][$f['key']]; $value = 'consent' === $f['type'] ? __('Yes', 'ai-eshop-optimizer') : $value; $lines[] = '' . esc_html(class_exists('AIEO_Engine_Blocks') ? AIEO_Engine_Blocks::plain($label) : $label) . ': ' . esc_html(class_exists('AIEO_Engine_Blocks') && AIEO_Form_CPT::is_choice_type($f['type']) ? AIEO_Engine_Blocks::plain($value) : $value); } if ('' !== (string) ($entry['page_url'] ?? '')) { $path = (string) wp_parse_url((string) $entry['page_url'], PHP_URL_PATH); $lines[] = '' . esc_html__('Sent from', 'ai-eshop-optimizer') . ': ' . esc_html('' !== $path ? $path : (string) $entry['page_url']) . ''; } $campaign = ''; if (isset($leads[(int) $entry['id']]) && class_exists('AIEO_Form_Submit')) { $c = AIEO_Form_Submit::campaign((int) $entry['id']); $from = implode(' / ', array_filter(array($c['source'], $c['medium'], $c['campaign']))); $campaign = esc_html('' !== $from ? $from : __('Direct visit', 'ai-eshop-optimizer')) . ('' !== $c['referrer'] ? '' . esc_html($f['key']) . '';
printf(
' · %s',
esc_html(sprintf(
__('%d asked', 'ai-eshop-optimizer'),
$asked
))
);
echo '' . esc_html__('Nobody has answered this one.', 'ai-eshop-optimizer') . '
'; continue; } $fe_rows = array(); foreach ($f['choices'] as $ck => $cl) { $n = isset($dist[$ck]) ? (int) $dist[$ck] : 0; $pct = $asked ? (int) round($n / $asked * 100) : 0; $fe_rows[] = array( 'choice' => (string) $cl, 'count' => $n . ' / ' . (int) $asked, 'share' => array('value' => $pct, 'label' => $pct . '%'), ); } foreach ($dist as $ck => $n) { if (isset($f['choices'][$ck])) { continue; } $pct = $asked ? (int) round($n / $asked * 100) : 0; $fe_rows[] = array( 'choice' => array('html' => '' . esc_html($ck) . ' ' . esc_html__('no longer offered', 'ai-eshop-optimizer') . ''),
'count' => (int) $n . ' / ' . (int) $asked,
'share' => array('value' => $pct, 'label' => $pct . '%'),
);
}
\Rooster\Admin\Markup::out(\Rooster\Admin\Ui::table(
array(
array('key' => 'choice', 'label' => __('Answer', 'ai-eshop-optimizer'), 'type' => 'text'),
array('key' => 'count', 'label' => __('Answers', 'ai-eshop-optimizer'), 'type' => 'num', 'priority' => 'low'),
array('key' => 'share', 'label' => __('Share', 'ai-eshop-optimizer'), 'type' => 'progress'),
),
$fe_rows,
array('caption' => esc_html($f['label']))
));
} else {
$texts = AIEO_Form_Entries::free_text($form_id, $f['key'], 50);
if (empty($texts)) {
echo '' . esc_html__('Nobody has answered this one.', 'ai-eshop-optimizer') . '
'; continue; } $list = '