'text', 'email' => 'email', 'url' => 'url', 'tel' => 'phone', 'number' => 'number', 'range' => 'range_slider', 'date' => 'date', 'textarea' => 'textarea', 'select' => 'dropdown', 'checkbox' => 'multiple_choice', 'radio' => 'radio', 'acceptance' => 'consent', 'file' => 'file_upload', 'hidden' => 'hidden', 'submit' => self::SUBMIT, 'quiz' => '!quiz', 'captchac' => '!captcha', 'captchar' => '!captcha', 'recaptcha' => '!captcha', ); /** * Gravity Forms field types. */ public const GRAVITY = array( 'text' => 'text', 'textarea' => 'textarea', 'select' => 'dropdown', 'multiselect' => 'multiple_choice', 'checkbox' => 'multiple_choice', 'radio' => 'radio', 'name' => 'name_group', 'email' => 'email', 'phone' => 'phone', 'address' => 'address_group', 'website' => 'url', 'number' => 'number', 'date' => 'date', 'time' => 'time', 'fileupload' => 'file_upload', 'hidden' => 'hidden', 'html' => 'html', 'section' => 'section_break', 'page' => self::STEP, 'consent' => 'consent', 'password' => 'password', 'list' => '!list', 'product' => '!payment', 'quantity' => '!payment', 'option' => '!payment', 'shipping' => '!payment', 'total' => '!payment', 'donation' => '!payment', 'calculation' => '!payment', 'singleproduct' => '!payment', 'creditcard' => '!payment', 'stripe_creditcard' => '!payment', 'paypal' => '!payment', 'paypal_checkout' => '!payment', 'square' => '!payment', 'coupon' => '!payment', 'captcha' => '!captcha', 'quiz' => '!quiz', 'poll' => '!quiz', 'survey' => '!quiz', 'likert' => '!quiz', 'rank' => '!quiz', 'rating' => '!quiz', 'post_title' => '!post', 'post_content' => '!post', 'post_excerpt' => '!post', 'post_tags' => '!post', 'post_category' => '!post', 'post_image' => '!post', 'post_custom_field' => '!post', 'signature' => '!signature', 'repeater' => '!repeater', ); /** * Fluent Forms elements. */ public const FLUENT = array( 'input_text' => 'text', 'input_email' => 'email', 'textarea' => 'textarea', 'select' => 'dropdown', 'multi_select' => 'multiple_choice', 'input_radio' => 'radio', 'input_checkbox' => 'multiple_choice', 'input_name' => 'name_group', 'phone' => 'phone', 'address' => 'address_group', 'input_number' => 'number', 'input_date' => 'date', 'input_url' => 'url', 'input_file' => 'file_upload', 'input_image' => 'image_upload', 'input_password' => 'password', 'select_country' => 'country', 'rangeslider' => 'range_slider', 'section_break' => 'section_break', 'form_step' => self::STEP, 'terms_and_condition' => 'consent', 'gdpr_agreement' => 'consent', 'custom_html' => 'html', 'input_hidden' => 'hidden', 'custom_submit_button' => self::SUBMIT, 'repeater_field' => '!repeater', 'input_repeat' => '!repeater', 'payment_method' => '!payment', 'multi_payment_component' => '!payment', 'subscription_payment_component' => '!payment', 'custom_payment_component' => '!payment', 'item_quantity_component' => '!payment', 'payment_summary_component' => '!payment', 'payment_coupon' => '!payment', 'recaptcha' => '!captcha', 'hcaptcha' => '!captcha', 'turnstile' => '!captcha', 'quiz_score' => '!quiz', 'ratings' => '!quiz', 'net_promoter_score' => '!quiz', 'tabular_grid' => '!quiz', 'post_title' => '!post', 'post_content' => '!post', 'post_excerpt' => '!post', 'featured_image' => '!post', 'taxonomy' => '!post', 'signature' => '!signature', ); /** * WPForms field types. */ public const WPFORMS = array( 'name' => 'name_group', 'email' => 'email', 'text' => 'text', 'textarea' => 'textarea', 'number' => 'number', 'number-slider' => 'range_slider', 'phone' => 'phone', 'address' => 'address_group', 'url' => 'url', 'select' => 'dropdown', 'radio' => 'radio', 'checkbox' => 'multiple_choice', 'gdpr-checkbox' => 'consent', 'date-time' => 'date', 'hidden' => 'hidden', 'html' => 'html', 'content' => 'html', 'divider' => 'section_break', 'pagebreak' => self::STEP, 'file-upload' => 'file_upload', 'rating' => 'rating', 'net_promoter_score' => 'net_promoter_score', 'password' => 'password', 'richtext' => 'rich_text', 'layout' => self::LAYOUT, 'likert_scale' => '!quiz', 'captcha' => '!captcha', 'payment-single' => '!payment', 'payment-multiple' => '!payment', 'payment-checkbox' => '!payment', 'payment-select' => '!payment', 'payment-total' => '!payment', 'payment-coupon' => '!payment', 'credit-card' => '!payment', 'stripe-credit-card' => '!payment', 'square' => '!payment', 'authorize_net' => '!payment', 'paypal-commerce' => '!payment', 'signature' => '!signature', 'repeater' => '!repeater', 'entry-preview' => '!preview', ); /** * Ninja Forms field types. */ public const NINJA = array( 'firstname' => 'text', 'lastname' => 'text', 'email' => 'email', 'textbox' => 'text', 'textarea' => 'textarea', 'phone' => 'phone', 'number' => 'number', 'listselect' => 'dropdown', 'listradio' => 'radio', 'listcheckbox' => 'multiple_choice', 'listmultiselect' => 'multiple_choice', 'checkbox' => 'checkbox', 'date' => 'date', 'address' => 'text', 'city' => 'text', 'zip' => 'text', 'liststate' => 'dropdown', 'listcountry' => 'country', 'hidden' => 'hidden', 'html' => 'html', 'hr' => 'section_break', 'starrating' => 'rating', 'file_upload' => 'file_upload', 'password' => 'password', 'submit' => self::SUBMIT, 'recaptcha' => '!captcha', 'recaptcha_v3' => '!captcha', 'hcaptcha' => '!captcha', 'spam' => '!captcha', 'timed_submit' => '!captcha', 'confirm' => '!confirm', 'passwordconfirm' => '!confirm', 'repeater' => '!repeater', 'product' => '!payment', 'quantity' => '!payment', 'shipping' => '!payment', 'total' => '!payment', 'tax' => '!payment', 'creditcard' => '!payment', 'creditcardcvc' => '!payment', 'creditcardexpiration' => '!payment', 'creditcardfullname' => '!payment', 'creditcardnumber' => '!payment', 'creditcardzip' => '!payment', 'signature' => '!signature', ); /** * Plain names of the sources, for report lines. * * @return array */ public static function sourceLabels(): array { return array( 'cf7' => __( 'Contact Form 7', 'subtleforms' ), 'gravity' => __( 'Gravity Forms', 'subtleforms' ), 'fluent' => __( 'Fluent Forms', 'subtleforms' ), 'wpforms' => __( 'WPForms', 'subtleforms' ), 'ninja' => __( 'Ninja Forms', 'subtleforms' ), ); } /** * The table for a source. * * @param string $source cf7, gravity, fluent, wpforms or ninja. * @return array */ public static function table( string $source ): array { switch ( $source ) { case 'cf7': return self::CF7; case 'gravity': return self::GRAVITY; case 'fluent': return self::FLUENT; case 'wpforms': return self::WPFORMS; case 'ninja': return self::NINJA; } return array(); } /** * The SubtleForms type for a source type, or an empty string when it is * skipped or unknown. * * @param string $source Source id. * @param string $type Source field type. * @return string */ public static function target( string $source, string $type ): string { $target = self::table( $source )[ strtolower( $type ) ] ?? ''; return '' !== $target && '!' !== $target[0] ? $target : ''; } /** * Why a source type is skipped, in plain words. * * @param string $source Source id. * @param string $type Source field type. * @return string */ public static function reason( string $source, string $type ): string { $target = self::table( $source )[ strtolower( $type ) ] ?? ''; $key = '' !== $target && '!' === $target[0] ? substr( $target, 1 ) : 'unknown'; $why = array( 'payment' => __( 'payments are not imported', 'subtleforms' ), 'captcha' => __( 'SubtleForms has its own spam protection and CAPTCHA settings', 'subtleforms' ), 'quiz' => __( 'quizzes, polls, surveys and ratings are not imported', 'subtleforms' ), 'post' => __( 'post creation fields are not imported', 'subtleforms' ), 'list' => __( 'list fields have no SubtleForms equivalent', 'subtleforms' ), 'repeater' => __( 'repeating fields are not imported', 'subtleforms' ), 'signature' => __( 'signature fields are not imported', 'subtleforms' ), 'preview' => __( 'entry preview fields are not imported', 'subtleforms' ), 'confirm' => __( 'confirm fields are not imported', 'subtleforms' ), 'unknown' => __( 'this field type has no SubtleForms equivalent', 'subtleforms' ), ); return $why[ $key ] ?? $why['unknown']; } /** * The report line for a skipped field. * * @param string $source Source id. * @param string $label Field label (or name). * @param string $type Source field type. * @param string $reason Reason; empty uses the table. * @return string */ public static function skippedLine( string $source, string $label, string $type, string $reason = '' ): string { return sprintf( /* translators: 1: plugin name, 2: field label, 3: field type, 4: reason */ __( '%1$s field \'%2$s\' (type %3$s) was skipped: %4$s.', 'subtleforms' ), self::sourceLabels()[ $source ] ?? $source, '' !== $label ? $label : $type, '' !== $type ? $type : '?', '' !== $reason ? $reason : self::reason( $source, $type ) ); } }