MP_Callback::constructor_code_send()

Send Calculator constructor code to email.

Contents


Source Source

File: mortgage-platform/Inc/Callback/MP_Callback.php

	public function constructor_code_send() {

		$email = isset( $_POST['email'] ) ? $_POST['email'] : null;
		$code  = isset( $_POST['code'] ) ? $_POST['code'] : null;

		if ( ! $email ) {
			wp_send_json( __( 'Error. Email not sent.', 'mortgage_platform' ) );
		}

		$to      = $email;
		$subject = __( 'E-Mail webmaster. Embed Code in your site', 'mortgage_platform' );
		$from    = ( ! empty( get_option( MortgagePlatform::$prefix . 'email' )['email'] ) ) ? get_option( MortgagePlatform::$prefix . 'email' )['email'] : get_option( 'admin_email' );

		$headers  = 'MIME-Version: 1.0' . PHP_EOL;
		$headers .= 'Content-type:text/html;charset=UTF-8' . PHP_EOL;
		$headers .= 'From: ' . $from . PHP_EOL;

		$message = '<textarea readonly rows="20" style="width: 100%">' . $code . '</textarea>';

		$send_email = new MP_Email();
		$send_email->send_email( $to, $subject, $message, $headers );

		wp_send_json( __( 'Email sent successfully.', 'mortgage_platform' ) );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.