MP_Addon_Payoff_Register

Class MP_Addon_Payoff_Register


Source Source

File: calculator-mortgage-payoff-add-on/inc/MP_Addon_Payoff_Register.php

class MP_Addon_Payoff_Register {


	/**
	 * Create Page for Iframe Widget.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function createPage() {
		$new_page_title   = MP_Addon_CalculatorsMortgagePayoffAddon::$page_title;
		$new_page_content = '';

		$page_check     = get_page_by_title( $new_page_title );
		$new_page = array(
			'post_type'    => 'page',
			'post_title'   => $new_page_title,
			'post_name'    => MP_Addon_CalculatorsMortgagePayoffAddon::$page_name,
			'post_content' => $new_page_content,
			'post_status'  => 'publish',
			'post_author'  => 1,
		);
		if ( ! isset( $page_check->ID ) ) {
			$new_page_id = wp_insert_post( $new_page );
		}

	}

	/**
	 * Template Iframe Page.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @param string $template template
	 *
	 * @global $post
	 *
	 * @return string
	 */
	public function iframePage( $template ) {
		global $post;
		if ( isset($post) && $post->post_name == MP_Addon_CalculatorsMortgagePayoffAddon::$page_name ) {
			return plugin_dir_path( __FILE__ ) . 'templates/сalculatorPage.php';
		}

		return $template;
	}




	/**
	 * Register mortgage calculator widget.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function register_calculator_widget() {
		/**
		 * MortgagePayoffCalculatorWidget.php
		 */
		include_once plugin_dir_path( __FILE__ ) . 'extensions/MortgagePayoffCalculatorWidget.php';
		register_widget( 'MP_MortgagePayoffCalculatorWidget' );
	}


	/**
	 * Set default Settings for Mortgage Platform.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return array
	 */
	public function defaultSettings() {
		$set      = new MP_Addon_Payoff_Settings();
		$setarr   = $set->set_fields();
		$settings = [];
		foreach ( $setarr as $option ) {
			$settings[ $option['id'] ] = $option['args']['default'];
		}

		return $settings;
	}



	/**
	 * Add Mortgage Payoff Calculator add-on to Mortgage Platform.
	 *
	 * @access public
	 * @since 1.0.0
	 */
	public function add_mortgage_platform_addon() {

		add_filter('mortgage_platform_addon_page', array($this, 'addon_template'));

	}


	/**
	 * Mortgage Payoff Calculator add-on template.
	 *
	 * @access public
	 * @since 1.0.0
	 */
	public function addon_template() {
		?>
		<div class="mortgage-calculator-addon">
			<h3><?php echo esc_html__(' Mortgage Payoff Calculator add-on','CalculatorsMortgagePayoffAddon'); ?></h3>
			<p><?php echo esc_html__('Description','CalculatorsMortgagePayoffAddon'); ?></p>
			<a href="#" class="addon"><?php echo esc_html__('install add-on','CalculatorsMortgagePayoffAddon'); ?></a>
		</div>
		<?php
	}

}

Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.