$deadline) { return false; } return true; } public static function shortcode($atts) { $atts = shortcode_atts(array('event_id' => 0), $atts, 'aieo_event_register'); $event_id = (int) $atts['event_id']; if ($event_id <= 0) { $p = get_post(); if ($p && class_exists('AIEO_Event_CPT') && $p->post_type === AIEO_Event_CPT::POST_TYPE) { $event_id = (int) $p->ID; } } if ($event_id <= 0 || !class_exists('AIEO_Event_CPT') || get_post_type($event_id) !== AIEO_Event_CPT::POST_TYPE) { return ''; } return self::render_form($event_id); } public static function render_form($event_id) { if (!self::is_open($event_id)) { return self::style() . '
' . esc_html__('Registration for this event is closed.', 'ai-eshop-optimizer') . '
'; } $err = ''; if (isset($_GET['aieo_reg_error'])) { $err = self::error_text(sanitize_key(wp_unslash($_GET['aieo_reg_error']))); } ob_start(); echo self::style(); ?>

1 ? '-' . self::$drawn[(int) $event_id] : ''); $field = static function ($key, $type, $label, $required, $autocomplete) use ($base) { $id = $base . '-' . $key; return '
' . '
'; }; ?>
= 10) { $fail('rate'); } $email = isset($_POST['email']) ? sanitize_email(wp_unslash($_POST['email'])) : ''; $first = isset($_POST['first_name']) ? sanitize_text_field(wp_unslash($_POST['first_name'])) : ''; $last = isset($_POST['last_name']) ? sanitize_text_field(wp_unslash($_POST['last_name'])) : ''; if (!is_email($email)) { $fail('email'); } if ($first === '' && $last === '') { $fail('name'); } $org = isset($_POST['organization']) ? sanitize_text_field(wp_unslash($_POST['organization'])) : ''; $phone = isset($_POST['phone']) ? sanitize_text_field(wp_unslash($_POST['phone'])) : ''; if (!class_exists('AIEO_Event_Participants')) { $fail('unavailable'); } $pid = AIEO_Event_Participants::upsert($event_id, array( 'first_name' => $first, 'last_name' => $last, 'email' => $email, 'organization' => $org, 'phone' => $phone, 'rsvp_status' => 'confirmed', ), 'self-registered', 0, ''); set_transient($rk, $cnt + 1, HOUR_IN_SECONDS); if ($pid <= 0) { $fail('save'); } do_action('aieo_submission', array( 'provider' => 'event', 'goal_key' => 'event_registration', 'entry_id' => (int) $pid, 'surface' => 'event_' . (int) $event_id, 'email' => $email, )); if (class_exists('AIEO_Event_RSVP')) { global $wpdb; $token = $wpdb->get_var($wpdb->prepare( 'SELECT rsvp_token FROM ' . AIEO_Event_Participants::table() . ' WHERE participant_id = %d', (int) $pid )); if ($token) { wp_safe_redirect(add_query_arg('registered', '1', AIEO_Event_RSVP::url($token))); exit; } } wp_safe_redirect(add_query_arg('aieo_reg', 'ok', $redirect)); exit; } private static function client_ip() { foreach (array('HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR') as $k) { if (!empty($_SERVER[$k])) { $parts = explode(',', (string) wp_unslash($_SERVER[$k])); $ip = trim($parts[0]); if (filter_var($ip, FILTER_VALIDATE_IP)) { return $ip; } } } return '0.0.0.0'; } private static function error_text($code) { $map = array( 'spam' => __('Your submission could not be processed.', 'ai-eshop-optimizer'), 'closed' => __('Registration for this event is closed.', 'ai-eshop-optimizer'), 'rate' => __('Too many attempts. Please try again later.', 'ai-eshop-optimizer'), 'email' => __('Please enter a valid email address.', 'ai-eshop-optimizer'), 'name' => __('Please enter your name.', 'ai-eshop-optimizer'), 'save' => __('Sorry, we could not complete your registration. Please try again.', 'ai-eshop-optimizer'), 'unavailable' => __('Registration is temporarily unavailable.', 'ai-eshop-optimizer'), ); return isset($map[$code]) ? $map[$code] : __('Please check your details and try again.', 'ai-eshop-optimizer'); } private static function style() { if (self::$style_done) { return ''; } self::$style_done = true; $fields = class_exists('AIEO_Form_Fields') ? AIEO_Form_Fields::style_here() : ''; return $fields . ''; } }