array( 'title' => __( 'Project enquiry', 'ai-eshop-optimizer' ), 'notify' => true, 'fields' => array( array( 'key' => 'first_name', 'type' => 'text', 'label' => __( 'First name', 'ai-eshop-optimizer' ), 'required' => true, 'width' => 'half', 'autocomplete' => 'given-name', 'missing' => __( 'Enter your first name.', 'ai-eshop-optimizer' ) ), array( 'key' => 'last_name', 'type' => 'text', 'label' => __( 'Last name', 'ai-eshop-optimizer' ), 'required' => true, 'width' => 'half', 'autocomplete' => 'family-name', 'missing' => __( 'Enter your last name.', 'ai-eshop-optimizer' ) ), array( 'key' => 'email', 'type' => 'email', 'label' => __( 'E-mail', 'ai-eshop-optimizer' ), 'required' => true, 'width' => 'half', 'autocomplete' => 'email', 'missing' => __( 'Enter your e-mail.', 'ai-eshop-optimizer' ), 'invalid' => __( 'Enter an e-mail address like name@company.com.', 'ai-eshop-optimizer' ) ), array( 'key' => 'company', 'type' => 'text', 'label' => __( 'Company', 'ai-eshop-optimizer' ), 'width' => 'half', 'autocomplete' => 'organization' ), array( 'key' => 'topic', 'type' => 'select', 'label' => __( 'What is it about?', 'ai-eshop-optimizer' ), 'prompt' => __( 'Select one', 'ai-eshop-optimizer' ), 'choices' => array( 'project' => __( 'A new project', 'ai-eshop-optimizer' ), 'support' => __( 'Support for a site we run', 'ai-eshop-optimizer' ), 'partnership' => __( 'A partnership', 'ai-eshop-optimizer' ), 'other' => __( 'Something else', 'ai-eshop-optimizer' ), ), ), array( 'key' => 'message', 'type' => 'textarea', 'label' => __( 'Message', 'ai-eshop-optimizer' ), 'required' => true, 'placeholder' => __( 'Tell us what you need…', 'ai-eshop-optimizer' ), 'missing' => __( 'Tell us what you need.', 'ai-eshop-optimizer' ) ), array( 'key' => 'consent', 'type' => 'consent', 'label' => __( 'I agree that you may use these details to answer my enquiry.', 'ai-eshop-optimizer' ), 'required' => true, 'missing' => __( 'Tick the box to agree that we may use these details to answer you.', 'ai-eshop-optimizer' ) ), ), 'settings' => array( 'button' => __( 'Send enquiry', 'ai-eshop-optimizer' ), 'success' => __( 'Thank you. We have your enquiry and will be in touch shortly.', 'ai-eshop-optimizer' ), 'subject' => __( 'Project enquiry from {first_name} {last_name}', 'ai-eshop-optimizer' ), 'ack_subject' => __( 'We have your enquiry, {first_name}', 'ai-eshop-optimizer' ), 'ack_body' => self::ack_body( __( 'Thank you for your enquiry. We have received it and will be in touch shortly.', 'ai-eshop-optimizer' ) ), ), ), 'professional-application' => array( 'title' => __( 'Professional account application', 'ai-eshop-optimizer' ), 'notify' => true, 'fields' => array_merge( self::applicant(), array( array( 'key' => 'business', 'type' => 'text', 'label' => __( 'Business name', 'ai-eshop-optimizer' ), 'required' => true, 'width' => 'half', 'autocomplete' => 'organization', 'missing' => __( 'Enter your business name.', 'ai-eshop-optimizer' ) ), array( 'key' => 'profession', 'type' => 'text', 'label' => __( 'Profession', 'ai-eshop-optimizer' ), 'required' => true, 'width' => 'half', 'missing' => __( 'Enter your profession.', 'ai-eshop-optimizer' ) ), array( 'key' => 'licence', 'type' => 'text', 'label' => __( 'Licence or VAT number', 'ai-eshop-optimizer' ), 'required' => true, 'help' => __( 'We check it before we approve the account.', 'ai-eshop-optimizer' ), 'missing' => __( 'Enter your licence or VAT number.', 'ai-eshop-optimizer' ) ), self::application_consent(), ) ), 'settings' => array( 'button' => __( 'Apply for a professional account', 'ai-eshop-optimizer' ), 'success' => __( 'Thank you. We have your application and will e-mail you when it is reviewed.', 'ai-eshop-optimizer' ), 'subject' => __( 'Professional account application from {first_name} {last_name}', 'ai-eshop-optimizer' ), 'ack_subject' => __( 'We have your application, {first_name}', 'ai-eshop-optimizer' ), 'ack_body' => self::ack_body( __( 'Thank you for applying for a professional account. We will check your details and e-mail you when your application is reviewed.', 'ai-eshop-optimizer' ) ), ), ), 'student-application' => array( 'title' => __( 'Student account application', 'ai-eshop-optimizer' ), 'notify' => true, 'fields' => array_merge( self::applicant(), array( array( 'key' => 'school', 'type' => 'text', 'label' => __( 'School', 'ai-eshop-optimizer' ), 'required' => true, 'width' => 'half', 'autocomplete' => 'organization', 'missing' => __( 'Enter your school.', 'ai-eshop-optimizer' ) ), array( 'key' => 'course', 'type' => 'text', 'label' => __( 'Course of study', 'ai-eshop-optimizer' ), 'required' => true, 'width' => 'half', 'missing' => __( 'Enter your course of study.', 'ai-eshop-optimizer' ) ), array( 'key' => 'student_id', 'type' => 'text', 'label' => __( 'Student ID number', 'ai-eshop-optimizer' ), 'required' => true, 'help' => __( 'We check it before we approve the account.', 'ai-eshop-optimizer' ), 'missing' => __( 'Enter your student ID number.', 'ai-eshop-optimizer' ) ), self::application_consent(), ) ), 'settings' => array( 'button' => __( 'Apply for a student account', 'ai-eshop-optimizer' ), 'success' => __( 'Thank you. We have your application and will e-mail you when it is reviewed.', 'ai-eshop-optimizer' ), 'subject' => __( 'Student account application from {first_name} {last_name}', 'ai-eshop-optimizer' ), 'ack_subject' => __( 'We have your application, {first_name}', 'ai-eshop-optimizer' ), 'ack_body' => self::ack_body( __( 'Thank you for applying for a student account. We will check your details and e-mail you when your application is reviewed.', 'ai-eshop-optimizer' ) ), ), ), ); } private static function ack_body( $sentence ) { return __( 'Hello {first_name},', 'ai-eshop-optimizer' ) . "\n\n" . $sentence; } private static function applicant() { return array( array( 'key' => 'first_name', 'type' => 'text', 'label' => __( 'First name', 'ai-eshop-optimizer' ), 'required' => true, 'width' => 'half', 'autocomplete' => 'given-name', 'missing' => __( 'Enter your first name.', 'ai-eshop-optimizer' ) ), array( 'key' => 'last_name', 'type' => 'text', 'label' => __( 'Last name', 'ai-eshop-optimizer' ), 'required' => true, 'width' => 'half', 'autocomplete' => 'family-name', 'missing' => __( 'Enter your last name.', 'ai-eshop-optimizer' ) ), array( 'key' => 'email', 'type' => 'email', 'label' => __( 'E-mail', 'ai-eshop-optimizer' ), 'required' => true, 'autocomplete' => 'email', 'missing' => __( 'Enter your e-mail.', 'ai-eshop-optimizer' ), 'invalid' => __( 'Enter an e-mail address like name@company.com.', 'ai-eshop-optimizer' ) ), ); } private static function application_consent() { return array( 'key' => 'consent', 'type' => 'consent', 'label' => __( 'I agree that you may use these details to review my application and to contact me about it.', 'ai-eshop-optimizer' ), 'required' => true, 'missing' => __( 'Tick the box to agree that we may use these details to review your application.', 'ai-eshop-optimizer' ) ); } public static function get( $slug ) { $all = self::all(); return $all[ sanitize_key( (string) $slug ) ] ?? null; } public static function choices() { return array_map( static fn ( $def ) => (string) $def['title'], self::all() ); } } }