MP_Addon_Calls_Settings
Class MP_Addon_Calls_Settings.
Contents
Description Description
See also See also
Source Source
File: calculator-calls-add-on/inc/MP_Addon_Calls_Settings.php
class MP_Addon_Calls_Settings extends MP_Settings {
/**
* Calls settings.
* @var array calls settings
* @since 1.0.0
* @access private
*/
private $settings;
/**
* Widget settings.
* @var array widget settings
* @since 1.0.0
* @access private
*/
private $widget_settings;
/**
* Set Call Settings.
* @since 1.0.0
* @access private
* @return array {
*
* Calls settings.
*
* @type array 'send_sms' Allow SMS/Calls
* @type array 'account_sid' Twilio ACCOUNT SID
* @type array 'auth_token' Twilio AUTH TOKEN
* @type array 'twilio_phone' Twilio Number Phone
* @type array 'call_to_admin' Call to Admin
* @type array 'number_sms_to_admin' Number Admin Phone for SMS
* }
*/
private function set_settings() {
$this->settings = array(
array(
'id' => 'send_sms',
'title' => __( 'Allow SMS/Calls', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'sms',
'label_for' => 'send_sms',
'placeholder' => '',
'default' => '',
'description' => __( 'Use Twilio.com', 'CalculatorsCallsAddon' ),
),
),
array(
'id' => 'account_sid',
'title' => __( 'Twilio ACCOUNT SID', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'sms',
'label_for' => 'account_sid',
'placeholder' => __( 'ACXXXXXXXXXXXXXXXXXXXXXX', 'CalculatorsCallsAddon' ),
'default' => '',
'description' => '',
),
),
array(
'id' => 'auth_token',
'title' => __( 'Twilio AUTH TOKEN', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'sms',
'label_for' => 'auth_token',
'placeholder' => '',
'default' => '',
'description' => '',
),
),
array(
'id' => 'twilio_phone',
'title' => __( 'Twilio Number Phone', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'sms',
'label_for' => 'twilio_phone',
'placeholder' => __( '+1XXXYYYZZZZ', 'CalculatorsCallsAddon' ),
'default' => '',
'description' => '',
),
),
array(
'id' => 'call_to_admin',
'title' => __( 'Call to Admin', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'sms',
'label_for' => 'call_to_admin',
'placeholder' => '',
'default' => '',
'description' => '',
),
),
array(
'id' => 'number_sms_to_admin',
'title' => __( 'Number Admin Phone for SMS', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'sms',
'label_for' => 'number_sms_to_admin',
'placeholder' => '',
'default' => '',
'description' => '',
),
),
);
return $this->settings;
}
/**
* Call widget settings.
* @since 1.0.0
* @access public
* @return array {
*
* Widget settings.
*
* @type array 'call_phone' Enable call on phone widget
* @type array 'call_phone_number' Phone number
* @type array 'call_browser' Enable call in browser widget
* @type array 'incoming_call' Receive an incoming call to the admin number
* @type array 'call_widget_tooltip' Call tooltip
* }
*/
public function call_widget_settings() {
$this->widget_settings = array(
array(
'id' => 'call_phone',
'title' => __( 'Enable call on phone widget', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'contact',
'label_for' => 'call_phone',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable call on phone widget', 'CalculatorsCallsAddon' ),
),
),
array(
'id' => 'call_phone_number',
'title' => __( 'Phone number ', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'contact',
'label_for' => 'call_phone_number',
'placeholder' => '',
'default' => '',
'description' => __( 'Phone number of the call on phone widget', 'CalculatorsCallsAddon' ),
),
),
array(
'id' => 'call_browser',
'title' => __( 'Enable call in browser widget', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'contact',
'label_for' => 'call_browser',
'placeholder' => '',
'default' => '',
'description' => __( 'Enable call in browser widget via Twilio', 'CalculatorsCallsAddon' ),
),
),
array(
'id' => 'incoming_call',
'title' => __( 'Receive an incoming call to the admin number', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'checkbox' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'contact',
'label_for' => 'incoming_call',
'placeholder' => '',
'default' => '',
'description' => __( 'Disabled: Receive an incoming call to the browser. Enabled: Receive an incoming call to the administrator number.', 'CalculatorsCallsAddon' ),
),
),
array(
'id' => 'call_widget_tooltip',
'title' => __( 'Call tooltip', 'CalculatorsCallsAddon' ),
'callback' => array( $this, 'input' ),
'args' => array(
'option_name' => MortgagePlatform::$prefix . 'contact',
'label_for' => 'call_widget_tooltip',
'placeholder' => '',
'default' => '',
'description' => __( 'Call tooltip', 'CalculatorsCallsAddon' ),
),
),
);
return $this->widget_settings;
}
/**
* Register Style Settings.
*
* @since 1.0.0
* @access public
*/
public function register() {
if ( ! in_array( 'calculator-sms-add-on/calculator-sms-add-on.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
$fields = $this->set_settings();
$this->register_setting_fields(
$fields,
'sms',
__( 'Call Settings', 'CalculatorsCallsAddon' ),
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'] ) && 'sms' === $_GET['tab'] ) {
$list .= '<li class="active"><a href="?page=' . esc_attr( MortgagePlatform::$domain ) . '&tab=sms" >' . esc_html__( 'Call Settings', 'CalculatorsCallsAddon' ) . '</a></li>';
} else {
$list .= '<li ><a href="?page=' . esc_attr( MortgagePlatform::$domain ) . '&tab=sms" >' . esc_html__( 'Call Settings', 'CalculatorsCallsAddon' ) . '</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 ( 'sms' === $_GET['tab'] ) {
?>
<div class="mp-settings__content tab-pane sms">
<form action="options.php" method="POST">
<?php
settings_fields( MortgagePlatform::$prefix . 'settings_sms' );
do_settings_sections( MortgagePlatform::$prefix . 'sms' );
submit_button()
?>
</form>
</div>
<?php
}
}
}
}
/**
* Widget settings.
*
* @since 1.0.0
* @access public
*
* @param array $array widget settings
*
* @return mixed widget settings
*/
public function filter_calls_widget_settings( $array ) {
$allow_widget = array_shift( $array );
$settings = $this->call_widget_settings();
array_unshift( $settings, $allow_widget );
return array_merge( $settings, $array );
}
}
Methods Methods
- call_widget_settings — Call widget settings.
- filter_calls_widget_settings — Widget settings.
- filter_menu — Filter Settings Menu.
- filter_settings — Add Setting Fields.
- register — Register Style Settings.
- set_settings — Set Call Settings.
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |