array( __( 'Name', 'nodebook' ), 'text', 'name' ), 'email' => array( __( 'Email', 'nodebook' ), 'email', 'email' ), 'phone' => array( __( 'Phone', 'nodebook' ), 'tel', 'tel' ), 'company' => array( __( 'Company', 'nodebook' ), 'text', 'organization' ), 'message' => array( __( 'Message', 'nodebook' ), 'textarea', 'off' ), ); } public static function render( $atts ) { $atts = shortcode_atts( array( 'fields' => 'name,email,message', 'button' => __( 'Send', 'nodebook' ), 'success' => __( 'Thank you! We received your message.', 'nodebook' ), 'source' => '', 'subscribe' => '', 'subscribe_label' => __( 'Yes, send me news and offers by email. I can unsubscribe at any time.', 'nodebook' ), ), $atts, 'nodebook_form' ); $avail = self::available(); $fields = array_intersect( array_map( 'trim', explode( ',', strtolower( $atts['fields'] ) ) ), array_keys( $avail ) ); if ( ! in_array( 'email', $fields, true ) ) { array_unshift( $fields, 'email' ); } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display-only flag after redirect. $sent = isset( $_GET['nodebook_sent'] ) && '1' === $_GET['nodebook_sent']; $uid = 'nbf-' . wp_rand( 1000, 999999 ); ob_start(); ?>


>

$def ) { if ( isset( $in[ $key ] ) ) { $fields[] = array( 'label' => $def[0], 'key' => $key, 'type' => 'message' === $key ? 'textarea' : ( 'name' === $key ? 'name' : $def[1] ), 'value' => $in[ $key ], ); } } $source = isset( $_POST['nb_source'] ) && '' !== $_POST['nb_source'] ? sanitize_text_field( wp_unslash( $_POST['nb_source'] ) ) : __( 'Nodebook form', 'nodebook' ); // Consent from the form's own checkbox. The wording is signed, so the proof shows what the page really said. $context = array(); $opt = isset( $_POST['nb_subscribe'] ) ? sanitize_key( wp_unslash( $_POST['nb_subscribe'] ) ) : ''; $text = isset( $_POST['nb_consent_text'] ) ? sanitize_text_field( wp_unslash( $_POST['nb_consent_text'] ) ) : ''; $sig = isset( $_POST['nb_consent_sig'] ) ? sanitize_text_field( wp_unslash( $_POST['nb_consent_sig'] ) ) : ''; if ( in_array( $opt, array( '1', 'signup' ), true ) && '' !== $text && hash_equals( wp_hash( 'nodebook_consent|' . $text ), $sig ) ) { $context = array( 'email_consent' => true, 'consent_text' => $text, 'url' => $back, ); } if ( Nodebook_Forms::enabled( 'nodebook' ) ) { Nodebook_Capture::from_fields( $fields, $source, get_the_title( url_to_postid( $back ) ), url_to_postid( $back ), $context ); } wp_safe_redirect( add_query_arg( 'nodebook_sent', '1', $back ) ); exit; } }