' . esc_html( $error ) . '';
return;
}
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verification is handled elsewhere.
$from = isset( $_POST['support']['name'] ) ? sanitize_text_field( wp_unslash( $_POST['support']['name'] ) ) : '';
$email = isset( $_POST['support']['email'] ) ? sanitize_email( wp_unslash( $_POST['support']['email'] ) ) : '';
$license = isset( $_POST['support']['license'] ) ? sanitize_text_field( wp_unslash( $_POST['support']['license'] ) ) : '';
$plugin = isset( $_POST['support']['plugin'] ) ? sanitize_text_field( wp_unslash( $_POST['support']['plugin'] ) ) : '';
$link = isset( $_POST['support']['link'] ) ? sanitize_url( wp_unslash( $_POST['support']['link'] ) ) : '';
$message = isset( $_POST['support']['message'] ) ? wp_kses_post( wp_unslash( $_POST['support']['message'] ) ) : '';
$type = isset( $_POST['support']['type'] ) ? sanitize_text_field( wp_unslash( $_POST['support']['type'] ) ) : '';
// phpcs:enable
$headers = array(
'From: ' . esc_attr( $from ) . ' <' . esc_attr( $email ) . '>',
'content-type: text/html',
);
$message_mail = '
' . nl2br( wp_kses_post( $message ) ) . '
';
$to_mail = WOWP_Plugin::info( 'email' );
$send = wp_mail( $to_mail, 'Support Request: ' . $type, $message_mail, $headers );
if ( $send ) {
$text = __( 'Your message has been sent to the support team.', 'float-menu' );
echo '' . esc_html( $text ) . '
';
} else {
$text = __( 'Sorry, but message did not send. Please, contact us via support page.', 'float-menu' );
echo '' . esc_html( $text ) . '
';
}
}
private static function error(): ?string {
$fields = [ 'name', 'email', 'link', 'type', 'plugin', 'license', 'message' ];
foreach ( $fields as $field ) {
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verification is handled elsewhere.
if ( empty( $_POST['support'][ $field ] ) ) {
return __( 'Please fill in all the form fields below.', 'float-menu' );
}
}
return '';
}
}