MP_LeadSettings
Class MP_LeadSettings
Contents
Description Description
See also See also
Source Source
File: mortgage-platform/Inc/Base/Settings/MP_LeadSettings.php
class MP_LeadSettings extends MP_Settings {
/**
* Fields of Tab "Leads".
*
* @since 1.0.0
* @access public
*
* @return array {
* Leads settings fields.
* @type array allow_leads Allow collect leads
* @type array leads_title Title Lead Form
* @type array leads_firstname First name label
* @type array leads_firstname_error First name error
* @type array leads_secondname Second name label
* @type array leads_secondname_error Second name error
* @type array leads_phone Lead phone
* @type array leads_phone_error Lead phone error
* @type array leads_email Lead email
* @type array leads_email_error Lead email error
* @type array leads_zipcode Zipcode label
* @type array leads_zipcode_error Zipcode error
* @type array leads_year_of_birth Year of Birth Label
* @type array begin_leads_year_of_birth Begin Value Year of Birth
* @type array end_leads_year_of_birth End value Year of Birth
* @type array leads_year_of_birth_error Year of Birth error
* @type array leads_investment_amount_label Leads investment amount label
* @type array leads_investment_amount Leads investment amount value
* @type array leads_investment_amount_error Leads investment amount error
* @type array leads_button Button to send lead data
* @type array leads_thankyou Thank you message
* @type array check_new_lead_by_name check a new lead by first name and second name
* @type array check_new_lead_by_name_additional check a new lead by zip code and year of birth
* @type array check_new_lead_by_phone check a new lead by phone
* @type array check_new_lead_by_email check a new lead by email
* @type array abandoned_leads Enable Abandoned Leads
* @type array abandoned_leads_first_name Enable tracking of First name for Abandoned Leads
* @type array abandoned_leads_second_name Enable tracking of Second name for Abandoned Leads
* @type array abandoned_leads_phone Enable tracking of Phone for Abandoned Leads
* @type array abandoned_leads_email Enable tracking of Email for Abandoned Leads
* @type array abandoned_leads_zipcode Enable tracking of Zip Code for Abandoned Leads
* @type array abandoned_leads_yearofbirth Enable tracking of Year of Birth Label for Abandoned Leads
* @type array abandoned_leads_investment_amount Enable tracking of Investment Amount Label for Abandoned Leads
* @type array lead_geo API Key by IP2Location
* }
*/
public function set_fields_leads() {
$fields_leads = array(
array(
'id' => 'allow_leads',
'title' => __( 'Allow collect leads', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'allow_leads',
'placeholder' => '',
'default' => '',
'description' => __( 'Choose whether to allow collect leads or not', 'mortgage_platform' ),
),
),
array(
'id' => 'leads_title',
'title' => __( 'Title Lead Form', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_title',
'placeholder' => '',
'default' => __( 'Please enter your info to show the rest and also get a copy in email.', 'mortgage_platform' ),
'description' => __( 'Title Lead Form', 'mortgage_platform' ),
),
),
array(
'id' => 'leads_firstname',
'title' => __( 'First Name Label', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_firstname',
'placeholder' => __( 'First Name', 'mortgage_platform' ),
'default' => __( 'First Name', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_firstname_error',
'title' => __( 'First Name Error', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_firstname_error',
'placeholder' => __( 'First Name Error', 'mortgage_platform' ),
'default' => __( 'Please enter your first name', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_secondname',
'title' => __( 'Second Name Label', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_secondname',
'placeholder' => __( 'Second Name', 'mortgage_platform' ),
'default' => __( 'Second Name', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_secondname_error',
'title' => __( 'Second Name Error', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_secondname_error',
'placeholder' => __( 'Second Name Error', 'mortgage_platform' ),
'default' => __( 'Please enter your second name', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_phone',
'title' => __( 'Phone Label', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_phone',
'placeholder' => __( 'Phone', 'mortgage_platform' ),
'default' => __( 'Phone', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_phone_error',
'title' => __( 'Phone Error', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_phone_error',
'placeholder' => __( 'Phone Error', 'mortgage_platform' ),
'default' => __( 'Please enter your phone', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_email',
'title' => __( 'Email Label', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_email',
'placeholder' => __( 'Email', 'mortgage_platform' ),
'default' => __( 'Email', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_email_error',
'title' => __( 'Email Error', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_email_error',
'placeholder' => __( 'Email Error', 'mortgage_platform' ),
'default' => __( 'Please enter your correct email', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_zipcode',
'title' => __( 'Zip code Label', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_zipcode',
'placeholder' => __( 'Zip code', 'mortgage_platform' ),
'default' => __( 'Zip code', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_zipcode_error',
'title' => __( 'Zip code Error', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_zipcode_error',
'placeholder' => __( 'Zip code Error', 'mortgage_platform' ),
'default' => __( 'Please enter zipcode', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_year_of_birth',
'title' => __( 'Year of Birth Label', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_year_of_birth',
'placeholder' => __( 'Year of Birth', 'mortgage_platform' ),
'default' => __( 'Year of Birth', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'begin_leads_year_of_birth',
'title' => __( 'Begin Value Year of Birth', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'begin_leads_year_of_birth',
'placeholder' => __( 'Begin Value Year of Birth', 'mortgage_platform' ),
'default' => __( '1900', 'mortgage_platform' ),
'description' => __( 'Default 1900 year', 'mortgage_platform' ),
),
),
array(
'id' => 'end_leads_year_of_birth',
'title' => __( 'End Value Year of Birth', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'end_leads_year_of_birth',
'placeholder' => __( 'End Value Year of Birth', 'mortgage_platform' ),
'default' => __( '2019', 'mortgage_platform' ),
'description' => __( 'Default current year', 'mortgage_platform' ),
),
),
array(
'id' => 'leads_year_of_birth_error',
'title' => __( 'Year of Birth Error', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_year_of_birth_error',
'placeholder' => __( 'Year of Birth Error', 'mortgage_platform' ),
'default' => __( 'Please select your year of birth', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_investment_amount_label',
'title' => __( 'Investment Amount Label', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_investment_amount_label',
'placeholder' => __( 'Investment Amount Label', 'mortgage_platform' ),
'default' => __( 'Investment Amount', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_investment_amount',
'title' => __( 'Investment Amount', 'mortgage_platform' ),
'callback' => array( $this, 'textarea' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_investment_amount',
'placeholder' => __( 'Investment Amount', 'mortgage_platform' ),
'default' => __(
'$0 - $10,000
$10,000 - $25,000
$25,000 - $50,000
$50,000 - $100,000
$100,000 - $250,000
$250,000 - $500,000
$500,000 - $1 Million
$1 Million - $3 Million
More than $3 Million',
'mortgage_platform'
),
'description' => '',
),
),
array(
'id' => 'leads_investment_amount_error',
'title' => __( 'Investment Amount Error', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_investment_amount_error',
'placeholder' => __( 'Investment Amount Error', 'mortgage_platform' ),
'default' => __( 'Please select Investment Amount', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_button',
'title' => __( 'Button Send Leads Value', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_button',
'placeholder' => __( 'Send', 'mortgage_platform' ),
'default' => __( 'Send', 'mortgage_platform' ),
'description' => '',
),
),
array(
'id' => 'leads_thankyou',
'title' => __( 'Thank you message', 'mortgage_platform' ),
'callback' => array( $this, 'textarea' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'leads_thankyou',
'placeholder' => __( 'Thank you', 'mortgage_platform' ),
'default' => '',
'description' => __( 'Thank you message. Support HTML markup', 'mortgage_platform' ),
),
),
array(
'id' => 'check_new_lead_by_name',
'title' => __( 'Check for duplicates by name when adding a new lead', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'check_new_lead_by_name',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable check for duplicates by name when adding a new lead. Include following fields: first name, second name.', 'mortgage_platform' ),
),
),
array(
'id' => 'check_new_lead_by_name_additional',
'title' => __( 'Check for duplicates by name and additional fields when adding a new lead', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'check_new_lead_by_name_additional',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable check for duplicates by name and year of birth and zip cod when adding a new leade.', 'mortgage_platform' ),
),
),
array(
'id' => 'check_new_lead_by_phone',
'title' => __( 'Check for duplicates by phone when adding a new lead', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'check_new_lead_by_phone',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable check for duplicates by phone when adding a new lead', 'mortgage_platform' ),
),
),
array(
'id' => 'check_new_lead_by_email',
'title' => __( 'Check for duplicates by email when adding a new lead', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'check_new_lead_by_email',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable check for duplicates by email when adding a new lead', 'mortgage_platform' ),
),
),
array(
'id' => 'abandoned_leads',
'title' => __( 'Enable Abandoned Leads', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'abandoned_leads',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable tracking of Abandoned Leads. By default, information is sent if at least one field is filled', 'mortgage_platform' ),
),
),
array(
'id' => 'abandoned_leads_first_name',
'title' => __( 'Enable tracking of First Name for Abandoned Leads', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'abandoned_leads_first_name',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable tracking of First Name field is filled for Abandoned Leads', 'mortgage_platform' ),
),
),
array(
'id' => 'abandoned_leads_second_name',
'title' => __( 'Enable tracking of Second Name for Abandoned Leads', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'abandoned_leads_second_name',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable tracking of Second Name field is filled for Abandoned Leads', 'mortgage_platform' ),
),
),
array(
'id' => 'abandoned_leads_phone',
'title' => __( 'Enable tracking of Phone for Abandoned Leads', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'abandoned_leads_phone',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable tracking of Phone field is filled for Abandoned Leads', 'mortgage_platform' ),
),
),
array(
'id' => 'abandoned_leads_email',
'title' => __( 'Enable tracking of Email for Abandoned Leads', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'abandoned_leads_email',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable tracking of Email field is filled for Abandoned Leads', 'mortgage_platform' ),
),
),
array(
'id' => 'abandoned_leads_zipcode',
'title' => __( 'Enable tracking of Zip Code for Abandoned Leads', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'abandoned_leads_zipcode',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable tracking of Zip Code field is filled for Abandoned Leads', 'mortgage_platform' ),
),
),
array(
'id' => 'abandoned_leads_yearofbirth',
'title' => __( 'Enable tracking of Year of Birth Label for Abandoned Leads', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'abandoned_leads_yearofbirth',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable tracking of Year of Birth Label field is filled for Abandoned Leads', 'mortgage_platform' ),
),
),
array(
'id' => 'abandoned_leads_investment_amount',
'title' => __( 'Enable tracking of Investment Amount Label for Abandoned Leads', 'mortgage_platform' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'abandoned_leads_investment_amount',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable tracking of Investment Amount Label field is filled for Abandoned Leads', 'mortgage_platform' ),
),
),
array(
'id' => 'lead_geo',
'title' => __( 'API Key by IP2Location', 'mortgage_platform' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'leads',
'label_for' => 'lead_geo',
'placeholder' => '',
'default' => '',
'description' => __('API Key by IP2Location <a href="https://ipinfodb.com/account">https://ipinfodb.com/account</a>','mortgage_platform') //sprintf( wp_kses( __( 'API Key by IP2Location <a href="%s">https://ipinfodb.com/account</a>', 'mortgage_platform' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( 'https://ipinfodb.com/account' ) ),
),
),
);
return $fields_leads;
}
/**
* Register Lead Settings.
*
* @since 1.0.0
* @access public
*/
public function register() {
/**
* Leads settings filter.
*
* @since 1.0.0
*
* @param array $this->set_fields_leads() {
* @see 'MP_LeadSettings::set_fields_leads()'
* }
*/
$fields_leads = apply_filters( 'mortgage_platform_leads_settings', $this->set_fields_leads() );
$this->register_setting_fields( $fields_leads, 'leads', __( 'Leads Settings', 'mortgage_platform' ), array( $this, 'page_title' ) );
add_filter( MortgagePlatform::$prefix . 'menu', array( $this, 'filter_menu' ), 15 );
add_action( MortgagePlatform::$prefix . 'menu_settings', array( $this, 'filter_settings' ) );
}
/**
* Filter Settings Menu.
*
* @since 1.0.0
* @access public
*
* @see 'MP_Settings::filter_menu()'
*
* @param string $list list of lead settings menu
*
* @return string list of lead settings menu
*/
public function filter_menu( $list ) {
if ( isset( $_GET['tab'] ) && 'leads' === $_GET['tab'] ) {
$list .= '<li class="active"><a href="?page=' . esc_attr( MortgagePlatform::$domain ) . '&tab=leads" >' . esc_html__( 'Leads Settings', 'mortgage_platform' ) . '</a></li>';
} else {
$list .= '<li ><a href="?page=' . esc_attr( MortgagePlatform::$domain ) . '&tab=leads" >' . esc_html__( 'Leads Settings', 'mortgage_platform' ) . '</a></li>';
}
return $list;
}
/**
* Add Setting Fields.
*
* @since 1.0.0
* @access public
*
* @see 'MP_Settings::filter_settings()'
*
* @global $pagenow
*/
public function filter_settings() {
global $pagenow;
if ( isset( $_GET['tab'] ) ) {
if ( 'admin.php' === $pagenow && MortgagePlatform::$domain === $_GET['page'] ) {
if ( 'leads' === $_GET['tab'] ) {
?>
<div class="mp-settings__content tab-pane leads">
<form action="options.php" method="POST">
<?php
settings_fields( MortgagePlatform::$prefix . 'settings_leads' );
do_settings_sections( MortgagePlatform::$prefix . 'leads' );
submit_button()
?>
</form>
</div>
<?php
}
}
}
}
}
Methods Methods
- filter_menu — Filter Settings Menu.
- filter_settings — Add Setting Fields.
- register — Register Lead Settings.
- set_fields_leads — Fields of Tab "Leads".
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |