AnsPress_Email_Hooks::template_form( string $active )

Description #

Generate email template form.

Parameters #

  • $active
    string (Required) Currently active template.

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: addons/free/email.php

	public static function template_form( $active ) {
		$form = anspress()->get_form( 'email_template' );
		$template = get_post( ap_opt( 'email_template_' . $active ) );

		if ( $template ) {
			$form->set_values( array(
				'subject' => $template->post_title,
				'body'    => $template->post_content,
			) );
		} else {
			$default_template = self::get_default_template( $active );
			$form->set_values( array(
				'subject' => $default_template['subject'],
				'body'    => $default_template['body'],
			) );
		}

		$form->generate(array(
			'ajax_submit' => true,
			'hidden_fields' => array(
				[ 'name' => 'action', 'value' => 'ap_ajax' ],
				[ 'name' => 'ap_ajax_action', 'value' => 'form_email_template' ],
				[ 'name' => 'template', 'value' => $active ],
			),
		));
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment