sanitize_key((string) $l['key']), 'label' => sanitize_text_field((string) $l['label']), 'unlocked' => !empty($l['unlocked']), 'min_plan_name' => sanitize_text_field(isset($l['minPlanName']) ? (string) $l['minPlanName'] : ''), 'path' => isset($l['path']) && preg_match('#^/dashboard(/[a-z0-9\-/]*)?$#', (string) $l['path']) ? (string) $l['path'] : '/dashboard', ); if (count($locks) >= 20) break; } $channel = isset($e['upgradeChannel']) ? (string) $e['upgradeChannel'] : 'stripe'; return array( 'plan_name' => sanitize_text_field(isset($e['planName']) ? (string) $e['planName'] : ''), 'locks' => $locks, 'upgrade_channel' => in_array($channel, array('stripe', 'wix', 'shopify'), true) ? $channel : 'stripe', ); } /** The plan block saved by the last health ping, or null. */ function citami_plan_info() { $health = get_option(CITAMI_HEALTH_OPT, array()); return is_array($health) && isset($health['plan']) && is_array($health['plan']) ? $health['plan'] : null; } /** The Overview card (empty when not connected or the platform did not say). */ function citami_plan_card_html() { $p = citami_plan_info(); if ($p === null || empty($p['locks'])) return ''; $base = function_exists('citami_brand_site') ? citami_brand_site() : citami_default_endpoint(); $rows = ''; $locked = 0; foreach ($p['locks'] as $l) { if ($l['unlocked']) { $rows .= '
  • ' . esc_html($l['label']) . '
  • '; } else { $locked++; $rows .= '
  • ' . esc_html($l['label']) . ' ยท ' . esc_html(sprintf(citami_t('dal piano %s', 'from the %s plan'), $l['min_plan_name'])) . '
  • '; } } $action = ''; if ($locked > 0) { if ($p['upgrade_channel'] === 'wix') { $action = '

    ' . esc_html(citami_t('Il tuo piano si cambia dall\'app CiteProof in Wix.', 'Your plan is changed from the CiteProof app in Wix.')) . '

    '; } elseif ($p['upgrade_channel'] === 'shopify') { $action = '

    ' . esc_html(citami_t('Il tuo piano si cambia dall\'app CiteProof in Shopify.', 'Your plan is changed from the CiteProof app in Shopify.')) . '

    '; } else { $action = '

    ' . esc_html(citami_t('Sblocca con un piano', 'Unlock with a plan')) . '

    '; } } $title = $p['plan_name'] !== '' ? sprintf(citami_t('Piano %s: cosa include', '%s plan: what it includes'), $p['plan_name']) : citami_t('Cosa include il tuo piano', 'What your plan includes'); return '
    ' . esc_html($title) . '
    ' . '

    ' . esc_html(citami_t('Lo stesso piano vale nella dashboard, su Wix, su Shopify e qui.', 'The same plan applies in the dashboard, on Wix, on Shopify and here.')) . '

    ' . '' . $action . '
    '; } /* ---------------------------------------------------------------- */ /* 2.76.0 โ€” one message for a free account (ENT-D) */ /* ---------------------------------------------------------------- */ /** The message of a health reply, cleaned (null when there is none). */ function citami_nudge_from_body($body) { if (!is_array($body) || !isset($body['nudge']) || !is_array($body['nudge'])) return null; $n = $body['nudge']; $text = sanitize_text_field(isset($n['text']) ? (string) $n['text'] : ''); $cta = sanitize_text_field(isset($n['cta']) ? (string) $n['cta'] : ''); if ($text === '' || $cta === '') return null; $path = isset($n['path']) && preg_match('#^/dashboard(/[a-z0-9\-/]*)?$#', (string) $n['path']) ? (string) $n['path'] : '/dashboard'; return array('text' => $text, 'cta' => $cta, 'path' => $path); } /** The Overview banner: the account's own numbers and what unlocks them; "Not now" hides it for three days. */ function citami_nudge_html() { $health = get_option(CITAMI_HEALTH_OPT, array()); $n = is_array($health) && isset($health['nudge']) && is_array($health['nudge']) ? $health['nudge'] : null; if ($n === null) return ''; // 2.77.0 โ€” while the first run is open its banner is the one thing to do: no plan message on top of it. if (function_exists('citami_setup_is_done') && !citami_setup_is_done()) return ''; $until = (int) get_user_meta(get_current_user_id(), 'citami_nudge_until', true); if ($until > time()) return ''; $base = function_exists('citami_brand_site') ? citami_brand_site() : citami_default_endpoint(); $later = admin_url('admin-post.php?action=citami_nudge_later&_wpnonce=' . wp_create_nonce('citami_nudge_later')); return '

    ' . esc_html($n['text']) . '

    ' . '

    ' . esc_html($n['cta']) . ' ' . '' . esc_html(citami_t('Non ora', 'Not now')) . '

    '; } function citami_nudge_later() { if (!current_user_can('manage_options')) wp_die(esc_html(citami_t('Permesso negato.', 'Permission denied.'))); check_admin_referer('citami_nudge_later'); update_user_meta(get_current_user_id(), 'citami_nudge_until', time() + 3 * DAY_IN_SECONDS); wp_safe_redirect(admin_url('admin.php?page=citami-connector')); exit; } add_action('admin_post_citami_nudge_later', 'citami_nudge_later');