' . esc_html( $error ) . '';
return;
}
$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'] ) ) : '';
$headers = array(
'From: ' . esc_attr( $from ) . ' <' . esc_attr( $email ) . '>',
'content-type: text/html',
);
$debug = isset( $support['debug'] ) ? '-------
' . nl2br( wp_kses_post( $support['info'] ) ) . '
' : '';
$message_mail = '
' . nl2br( wp_kses_post( $message ) ) . '
';
$to_mail = WOW_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.', 'floating-button' );
echo '' . esc_html( $text ) . '
';
} else {
$text = __( 'Sorry, but message did not send. Please, contact us ', 'floating-button' ) . $to_mail;
echo '' . esc_html( $text ) . '
';
}
}
private static function error(): ?string {
if ( ! self::verify() ) {
return '';
}
$fields = [ 'name', 'email', 'link', 'type', 'plugin', 'license', 'message' ];
foreach ( $fields as $field ) {
if ( empty( $_POST['support'][ $field ] ) ) {
return __( 'Please fill in all the form fields below.', 'floating-button' );
}
}
return '';
}
private static function verify(): bool {
$nonce_name = WOW_Plugin::PREFIX . '_nonce_name';
$nonce_action = WOW_Plugin::PREFIX . '_nonce_action';
if ( empty( $_POST[ $nonce_name ] ) ) {
return false;
}
return ! empty( $_POST['support'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ $nonce_name ] ) ),
$nonce_action );
}
}