prefix . 'bylt_form_entries'; } public static function install() { global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $t = self::table(); dbDelta( "CREATE TABLE {$t} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, form_id bigint(20) unsigned NOT NULL DEFAULT 0, status varchar(10) NOT NULL DEFAULT 'new', email varchar(190) NOT NULL DEFAULT '', data longtext NULL, user_id bigint(20) unsigned NOT NULL DEFAULT 0, product_id bigint(20) unsigned NOT NULL DEFAULT 0, page_url varchar(500) NOT NULL DEFAULT '', ip varchar(64) NOT NULL DEFAULT '', created_gmt datetime NULL DEFAULT NULL, PRIMARY KEY (id), KEY form_status (form_id,status), KEY email (email), KEY created (created_gmt) ) {$wpdb->get_charset_collate()};" ); update_option( 'bylt_forms_db_version', self::DB_VERSION, false ); } public static function maybe_install() { if ( get_option( 'bylt_forms_db_version' ) !== self::DB_VERSION ) { self::install(); } } public static function register_cpt() { register_post_type( self::CPT, array( 'label' => __( 'Forms', 'byltcommerce-toolkit' ), 'public' => false, 'show_ui' => false, 'show_in_rest' => false, 'rewrite' => false, 'query_var' => false, 'supports' => array( 'title' ), 'capability_type' => 'page', ) ); } /* --------------------------------------------------------------------- * Forms * ------------------------------------------------------------------- */ public static function default_settings() { return array( 'kind' => 'contact', // contact | quote 'submit_label' => 'Send', 'success' => 'Thanks! We\'ll be in touch soon.', 'redirect' => '', 'notify' => 'yes', 'notify_to' => '', // Blank = site admin email. 'notify_subject' => 'New {form} entry', 'confirm' => 'no', 'confirm_subject' => 'We received your message', 'confirm_message' => "Hi {name},\n\nThanks for getting in touch. Here's a copy of what you sent:\n\n{all_fields}", 'store' => 'yes', 'protect' => 'yes', // Turnstile/reCAPTCHA via Form Protection, when set up. 'product_button' => 'no', // Quote forms: no | all | cats 'button_cats' => array(), 'button_label' => 'Request a quote', 'page_id' => 0, // Page the form lives on (for the product button). 'css_class' => '', // Extra classes on the