prefix . 'tt24_forms'; // FIX: Silencing false-positive DB warnings // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery // phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching $form_title = $wpdb->get_var( $wpdb->prepare( "SELECT title FROM {$table_forms} WHERE id = %d", $form_id ) ); // phpcs:enable if ( ! $form_title ) { $form_title = esc_html__( 'Unrestricted Form', '24tt-unrestricted-forms' ); } // 2. Determine the Recipient (To) Address // For v1.0, we route to the default WordPress Administrator email. // We apply a filter here so advanced users can override it via their theme's functions.php. $admin_email = get_option( 'admin_email' ); $to_email = apply_filters( 'tt24_forms_notification_email', $admin_email, $form_id ); // 3. Build the Email Subject $site_name = get_bloginfo( 'name' ); /* translators: 1: Site name, 2: Form title */ $subject = sprintf( esc_html__( '[%1$s] New Submission: %2$s', '24tt-unrestricted-forms' ), $site_name, $form_title ); // 4. Construct the Email Body (HTML) // We build a clean, responsive HTML table to display the data professionally. $message = '
'; $message .= '' . esc_html__( 'You have received a new form submission. Here are the details:', '24tt-unrestricted-forms' ) . '
'; $message .= '| ' . esc_html( $display_key ) . ' | '; $message .= '' . nl2br( esc_html( $display_value ) ) . ' | '; $message .= '
'; /* translators: %s: Site name */ $message .= sprintf( esc_html__( 'This email was generated automatically by 24TT Unrestricted Forms on %s. You can view all your securely stored data in your WordPress Dashboard.', '24tt-unrestricted-forms' ), $site_name ); $message .= '
'; $message .= '