MP_AbandonedLeads

Class MP_AbandonedLeads


Description Description

See also See also


Top ↑

Source Source

File: mortgage-platform/Inc/MP_AbandonedLeads.php

class MP_AbandonedLeads extends MP_BaseLeadSettings {


	/**
	 * Lead.
	 *
	 * @var string lead
	 *
	 * @since 1.0.0
	 * @access private
	 */
	private $lead;



	/**
	 * AbandonedLeads constructor.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function __construct() {

		$this->lead = MortgagePlatform::$abandoned_lead;

	}



	/**
	 * Initialization Post Type Leads.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function init() {

		add_action( 'init', array( $this, 'register' ) );

		add_action( 'add_meta_boxes', array( $this, 'lead_fields' ), 1 );
		add_action( 'add_meta_boxes', array( $this, 'address_metabox' ), 2 );
		add_action( 'add_meta_boxes', array( $this, 'calculate_fields' ), 3 );
		add_action( 'add_meta_boxes', array( $this, 'utm_fields' ), 4 );
		add_action( 'add_meta_boxes', array( $this, 'client_fields' ), 5 );
		add_action( 'add_meta_boxes', array( $this, 'lead_logs_field' ), 6 );
		add_action( 'add_meta_boxes', array( $this, 'message_field' ), 7 );
		add_action( 'add_meta_boxes', array( $this, 'lead_comment_field' ), 8 );
		add_action( 'add_meta_boxes', array( $this, 'gallery_metabox' ), 9 );

		add_action( 'save_post', array( $this, 'gallery_meta_save' ) );
		add_action( 'save_post', array( $this, 'save_lead' ) );

		add_filter( 'manage_' . $this->lead . '_posts_columns', array( $this, 'add_leads_table_column' ), 10 );
		add_action( 'manage_' . $this->lead . '_posts_custom_column', array( $this, 'get_leads_table_column' ), 10, 2 );
		add_action( 'admin_print_footer_scripts-edit.php', array( $this, 'style_lead_table' ) );
		add_filter( 'manage_edit-' . $this->lead . '_sortable_columns', array( $this, 'add_sortable_column' ) );

		add_filter( 'pre_get_posts', array( $this, 'sort_by_phone' ) );
		add_filter( 'pre_get_posts', array( $this, 'sort_by_email' ) );
		add_filter( 'pre_get_posts', array( $this, 'sort_by_zipcode' ) );
		add_filter( 'pre_get_posts', array( $this, 'sort_by_yearofbirth' ) );
		add_filter( 'pre_get_posts', array( $this, 'sort_by_investmentamount' ) );

		add_filter( MortgagePlatform::$prefix . 'send', array( $this, 'send_message_field' ) );

	}


	/**
	 * Register Lead Post Type.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::register_leads()'
	 */
	public function register() {

		return $this->register_leads( $this->lead, array(), 'Abandoned Lead', 'Abandoned Leads' ,20);
	}


	/**
	 * Add Lead Fields Metabox.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::add_lead_fields()'
	 */
	public function lead_fields() {

		$this->add_lead_fields( $this->lead );
	}


	/**
	 * Add Address Metabox.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::add_address_metabox()'
	 */
	public function address_metabox() {

		$this->add_address_metabox( $this->lead );
	}


	/**
	 * Add calculate fields Metabox.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::add_calculate_fields()'
	 */
	public function calculate_fields() {

		$this->add_calculate_fields( $this->lead );
	}


	/**
	 * Add UTM fields Metabox.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::add_utm_fields()'
	 */
	public function utm_fields() {

		$this->add_utm_fields( $this->lead );
	}


	/**
	 * Add Client Fields Metabox.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::add_client_fields()'
	 */
	public function client_fields() {

		$this->add_client_fields( $this->lead );
	}


	/**
	 * Add Logs Metabox.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::add_lead_logs_field()'
	 */
	public function lead_logs_field() {

		$this->add_lead_logs_field( $this->lead );
	}


	/**
	 * Add Send Message Metabox.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::add_send_message_field()'
	 */
	public function message_field() {

		$this->add_send_message_field( $this->lead );
	}


	/**
	 * Add Note Metabox.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::add_lead_comment_field()'
	 */
	public function lead_comment_field() {

		$this->add_lead_comment_field( $this->lead );
	}


	/**
	 * Add Gallery Metabox.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::add_gallery_metabox()'
	 */
	public function gallery_metabox() {

		$this->add_gallery_metabox( $this->lead );
	}


	/**
	 * Filter send message Metabox.
	 *
	 * @param object $post post
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @see     'MP_BaseLeadSettings::filter_send_message_field()'
	 */
	public function send_message_field( $post ) {

		if ( MortgagePlatform::$abandoned_lead === $post->post_type ) {
			$this->filter_send_message_field( $post );
		}

	}

	/**
	 * Save comment lead field.
	 * @since  1.0.0
	 * @access public
	 *
	 * @param int $post_id post id
	 *
	 * @see     'MP_BaseLeadSettings::save_leads_fields()'
	 */
	public function save_lead( $post_id ) {
		wp_cache_delete($this->lead, MortgagePlatform::$domain);
		return $this->save_leads_fields( $post_id );
	}
}

Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.