MP_Addon_Letter_Settings

Class MP_Addon_Letter_Settings.


Description Description

See also See also


Top ↑

Source Source

File: calculator-letter-add-on/inc/MP_Addon_Letter_Settings.php

class MP_Addon_Letter_Settings extends MP_Settings {


	/**
	 * Email template settings.
	 *
	 * @var array
	 *
	 * @since 1.0.0
	 * @access private
	 */
	private $email_templates;



	/**
	 * Fields of Tab "Email Templates".
	 * @since 1.0.0
	 * @access public
	 * @return array {
	 *               Email template settings.
	 *
	 *  @type array 'send_letters' Use Send Letters to the Lead
	 *  @type array 'lob_key' API key Lob.com
	 *  @type array 'company_name' Company name
	 *  @type array 'address_line1' Address Line 1
	 *  @type array 'address_line2' Address Line 2
	 *  @type array 'address_city' City
	 *  @type array 'address_state' State
	 *  @type array 'address_country' Country
	 *  @type array 'address_zip' Zip
	 *  @type array 'email_template1' HTML Letter Template #1
	 *  @type array 'email_template2' HTML Letter Template #2
	 * }
	 */
	public function set_fields() {
		$this->email_templates = array(
			array(
				'id'       => 'send_letters',
				'title'    => __( 'Use Send Letters to the Lead', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'send_letters',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Use Lob.com', 'CalculatorsLetterAddon' ),
				),
			),
			array(
				'id'       => 'lob_key',
				'title'    => __( 'API key Lob.com', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'lob_key',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'API key Lob.com', 'CalculatorsLetterAddon' ),
				),
			),
			array(
				'id'       => 'company_name',
				'title'    => __( 'Company name', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'company_name',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Company name', 'CalculatorsLetterAddon' ),
				),
			),
			array(
				'id'       => 'address_line1',
				'title'    => __( 'Address Line 1', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'address_line1',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Address', 'CalculatorsLetterAddon' ),
				),
			),
			array(
				'id'       => 'address_line2',
				'title'    => __( 'Address Line 2', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'address_line2',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Address', 'CalculatorsLetterAddon' ),
				),
			),
			array(
				'id'       => 'address_city',
				'title'    => __( 'City', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'address_city',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Address City', 'CalculatorsLetterAddon' ),
				),
			),
			array(
				'id'       => 'address_state',
				'title'    => __( 'State', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'address_state',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Address State', 'CalculatorsLetterAddon' ),
				),
			),
			array(
				'id'       => 'address_country',
				'title'    => __( 'Country', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'address_country',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Address Country', 'CalculatorsLetterAddon' ),
				),
			),
			array(
				'id'       => 'address_zip',
				'title'    => __( 'Zip', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'address_zip',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Address Zip', 'CalculatorsLetterAddon' ),
				),
			),
			array(
				'id'       => 'email_template1',
				'title'    => __( 'HTML Letter Template #1', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'textarea' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'email_template1',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'HTML Letter Template', 'CalculatorsLetterAddon' ),
				),
			),
			array(
				'id'       => 'email_template2',
				'title'    => __( 'HTML Letter Template #2', 'CalculatorsLetterAddon' ),
				'callback' => array( $this, 'textarea' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'email_templates',
					'label_for'   => 'email_template2',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'HTML Letter Template', 'CalculatorsLetterAddon' ),
				),
			),
		);

		return $this->email_templates;

	}


	/**
	 * Register Style Settings.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function register() {

		$fields = $this->set_fields();

		$this->register_setting_fields(
			$fields,
			'email_templates',
			__( 'Letter templates settings', 'CalculatorsLetterAddon' ),
			array( $this, 'page_title' )
		);

		add_filter( MortgagePlatform::$prefix . 'menu', array( $this, 'filter_menu' ), 50 );
		add_action( MortgagePlatform::$prefix . 'menu_settings', array( $this, 'filter_settings' ) );

	}


	/**
	 * Filter Settings Menu.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @param string  $list menu list
	 *
	 * @return string menu list
	 */
	public function filter_menu( $list ) {

		if ( isset( $_GET['tab'] ) && 'email_templates' === $_GET['tab'] ) {
			$list .= '<li class="active"><a href="?page=' . esc_attr( MortgagePlatform::$domain ) . '&tab=email_templates" >' . esc_html__( 'Letter templates', 'CalculatorsLetterAddon' ) . '</a></li>';
		} else {
			$list .= '<li ><a href="?page=' . esc_attr( MortgagePlatform::$domain ) . '&tab=email_templates" >' . esc_html__( 'Letter templates', 'CalculatorsLetterAddon' ) . '</a></li>';
		}

		return $list;

	}


	/**
	 * Add Setting Fields.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @global $pagenow
	 */
	public function filter_settings() {
		global $pagenow;
		if ( isset( $_GET['tab'] ) ) {
			if ( 'admin.php' === $pagenow && MortgagePlatform::$domain === $_GET['page'] ) {

				if ( 'email_templates' === $_GET['tab'] ) {
					?>
					<div class="mp-settings__content tab-pane email_templates">
						<form action="options.php" method="POST">
							<?php
							settings_fields( MortgagePlatform::$prefix . 'settings_email_templates' );
							do_settings_sections( MortgagePlatform::$prefix . 'email_templates' );
							submit_button()
							?>
						</form>
					</div>
					<?php
				}
			}
		}

	}


}

Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.