0 && class_exists('GFForms') ? 'gravity' : 'native';
}
public static function in_use_note($competition_id) {
$gf = class_exists('AIEO_Competition_CPT') ? (int) get_post_meta((int) $competition_id, AIEO_Competition_CPT::META_GF, true) : 0;
if ('gravity' === self::form_in_use($competition_id)) {
$form = class_exists('GFAPI') ? GFAPI::get_form($gf) : null;
$title = is_array($form) && '' !== (string) ($form['title'] ?? '') ? (string) $form['title'] : '#' . $gf;
return sprintf(__('Entries come through the linked Gravity Forms form “%s”.', 'ai-eshop-optimizer'), $title);
}
if ($gf > 0) {
return sprintf(__('Gravity Forms is inactive, so the competition’s built-in entry form takes the entries (first and last name, e-mail, the newsletter box and the terms). Form #%d takes them again once Gravity Forms is active.', 'ai-eshop-optimizer'), $gf);
}
return __('No Gravity Forms form is linked, so the competition’s built-in entry form takes the entries: first and last name, e-mail, the newsletter box and the terms. Entrants the shop does not know confirm their entry by e-mail.', 'ai-eshop-optimizer');
}
public static function native_entry_id($email) {
return self::NATIVE_BASE + (int) hexdec(substr(md5('aieo-comp-native|' . strtolower(trim((string) $email))), 0, 15));
}
private static function words() {
return array(
'button' => __('Enter the competition', 'ai-eshop-optimizer'),
'sending' => __('Sending…', 'ai-eshop-optimizer'),
'check' => __('Please correct the highlighted fields.', 'ai-eshop-optimizer'),
'network' => __('The request could not be sent. Please check your connection and try again.', 'ai-eshop-optimizer'),
'pending' => __('Thank you for entering. We have sent you an e-mail: confirm your address with its link to take part in the draw.', 'ai-eshop-optimizer'),
'confirmed' => __('Thank you: your entry is confirmed and takes part in the draw.', 'ai-eshop-optimizer'),
'already' => __('You have already entered this competition with this e-mail address, and your entry takes part in the draw.', 'ai-eshop-optimizer'),
'closed' => __('This competition is not taking entries now.', 'ai-eshop-optimizer'),
);
}
public static function render($competition_id) {
$cid = (int) $competition_id;
if (class_exists('AIEO_Form_Render')) {
AIEO_Form_Render::register_assets();
wp_enqueue_style(AIEO_Form_Render::STYLE);
if (function_exists('wp_enqueue_script_module')) {
wp_enqueue_script_module(AIEO_Form_Render::MODULE);
}
}
$w = self::words();
$base = 'aieo-comp-entry-' . $cid;
$req = ' *';
$text = static function ($key, $type, $label, $autocomplete, $required, $missing, $invalid, $width) use ($base, $req) {
$id = $base . '-' . $key;
$extra = 'email' === $type ? ' inputmode="email" spellcheck="false"' : '';
return '