MP_StyleSettings

Class MP_StyleSettings


Description Description

See also See also


Top ↑

Source Source

File: mortgage-platform/Inc/Base/Settings/MP_StyleSettings.php

class MP_StyleSettings extends MP_Settings {


	/**
	 * Fields of Tab "Style".
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return array {
	 *  Style settings fields
	 *      @type array type_style Type Style
	 *      @type array primary_color Primary Color
	 *      @type array fonts Fonts
	 *      @type array type_inputs Type inputs
	 *      @type array rounded_elements Rounded Buttons
	 *      @type array slider_for_input Enable Slider for Input
	 *      @type array type_slyder Type Slider for input
	 *      @type array first_input Enable Focus First Input
	 *      @type array bitly Enable Bit.ly API
	 *      @type array bitly_API Bit.ly API key
	 *      @type array bitly_user Bit.ly user name
	 *      @type array social_share Enable Social Share Icons
	 *      @type array social_bitly Use Bit.ly to short URL with calculator
	 *      @type array social_title Social Share Title
	 *      @type array social_description Social Share Description
	 *      @type array social_image Social Share Image
	 *      @type array social_icon_facebook Enable Social Facebook Icon
	 *      @type array social_icon_twitter Enable Social Twitter Icon
	 *      @type array social_icon_pinterest Enable Social Pinterest Icon
	 *      @type array social_icon_linkedin Enable Social Linkedin Icon
	 *      @type array social_icon_reddit Enable Social Reddit Icon
	 *      @type array social_icon_email Enable Share Email
	 *      @type array social_icon_email_text Enable Share Email Text
	 *      @type array custom_css Custom CSS Code
	 *      @type array custom_js Custom JS Code
	 * }
	 */
	public function set_fields_style() {
		$fields_style = array(
			array(
				'id'       => 'type_style',
				'title'    => __( 'Type Style', 'mortgage_platform' ),
				'callback' => array( $this, 'select' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'type_style',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Choose type style of calculator', 'mortgage_platform' ),
					'options'     => array(
						'lighttheme' => __( 'Light Theme', 'mortgage_platform' ),
						'darktheme'  => __( 'Dark Theme', 'mortgage_platform' ),
						'fullpage'   => __( 'Full Page Theme', 'mortgage_platform' ),
					),
				),
			),
			array(
				'id'       => 'primary_color',
				'title'    => __( 'Primary Color', 'mortgage_platform' ),
				'callback' => array( $this, 'color' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'primary_color',
					'placeholder' => __( 'Primary Color', 'mortgage_platform' ),
					'default'     => '',
					'description' => __( 'This sets the primary color for the Calculator', 'mortgage_platform' ),
				),
			),
			array(
				'id'       => 'fonts',
				'title'    => __( 'Fonts', 'mortgage_platform' ),
				'callback' => array( $this, 'fonts' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'fonts',
					'placeholder' => '',
					'default'     => __( 'default', 'mortgage_platform' ),
					'description' => __( 'Choose the font to use.  Helvetica is going to be the smallest but does not support many RTL languages.', 'mortgage_platform' ),
				),
			),
			array(
				'id'       => 'type_inputs',
				'title'    => __( 'Type inputs', 'mortgage_platform' ),
				'callback' => array( $this, 'select' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'type_inputs',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Type inputs', 'mortgage_platform' ),
					'options'     => array(
						'bottom_line'   => __( 'Bottom line', 'mortgage_platform' ),
						'squared_input' => __( 'Squared', 'mortgage_platform' ),
						'rounded_input' => __( 'Rounded', 'mortgage_platform' ),
					),
				),
			),
			array(
				'id'       => 'rounded_elements',
				'title'    => __( 'Rounded Buttons', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'rounded_elements',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'slider_for_input',
				'title'    => __( 'Enable Slider for Input', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'slider_for_input',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'type_slyder',
				'title'    => __( 'Type Slider for input', 'mortgage_platform' ),
				'callback' => array( $this, 'select' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'type_slyder',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Choose type slider for input', 'mortgage_platform' ),
					'options'     => array(
						'round'    => __( 'Round', 'mortgage_platform' ),
						'oval'     => __( 'Oval', 'mortgage_platform' ),
						'triangle' => __( 'Triangle', 'mortgage_platform' ),
					),
				),
			),
			array(
				'id'       => 'first_input',
				'title'    => __( 'Enable Focus First Input', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'first_input',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'bitly',
				'title'    => __( 'Enable Bit.ly API', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'bitly',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Enable Bit.ly API to use short URL', 'mortgage_platform' ),
				),
			),
			array(
				'id'       => 'bitly_API',
				'title'    => __( 'Bit.ly API key', 'mortgage_platform' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'bitly_API',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Bit.ly API key', 'mortgage_platform' ),
				),
			),
			array(
				'id'       => 'bitly_user',
				'title'    => __( 'Bit.ly user name', 'mortgage_platform' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'bitly_user',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Bit.ly user name', 'mortgage_platform' ),
				),
			),
			array(
				'id'       => 'social_share',
				'title'    => __( 'Enable Social Share Icons', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_share',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'social_bitly',
				'title'    => __( 'Use Bit.ly to short URL with calculator', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_bitly',
					'placeholder' => '',
					'default'     => '',
					'description' => __( ' To create short links you can use the service <a href="bit.ly">bit.ly</a>.', 'mortgage_platform' ),
				),
			),
			array(
				'id'       => 'social_title',
				'title'    => __( 'Social Share Title', 'mortgage_platform' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_title',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Social Share Title', 'mortgage_platform' ),
				),
			),
			array(
				'id'       => 'social_description',
				'title'    => __( 'Social Share Description', 'mortgage_platform' ),
				'callback' => array( $this, 'input' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_description',
					'placeholder' => '',
					'default'     => '',
					'description' => __( 'Social Share Description', 'mortgage_platform' ),
				),
			),
			array(
				'id'       => 'social_image',
				'title'    => __( ' Social Share Image', 'mortgage_platform' ),
				'callback' => array( $this, 'upload' ),
				'args'     => array(
					'option_name'   => MortgagePlatform::$prefix . 'style',
					'label_for'     => 'social_image',
					'attachment_id' => 'social_image_id',
					'placeholder'   => '',
					'default'       => '',
					'description'   => '',
				),
			),
			array(
				'id'       => 'social_icon_facebook',
				'title'    => __( 'Enable Social Facebook Icon', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_icon_facebook',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'social_icon_twitter',
				'title'    => __( 'Enable Social Twitter Icon', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_icon_twitter',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'social_icon_pinterest',
				'title'    => __( 'Enable Social Pinterest Icon', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_icon_pinterest',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'social_icon_linkedin',
				'title'    => __( 'Enable Social Linkedin Icon', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_icon_linkedin',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'social_icon_reddit',
				'title'    => __( 'Enable Social Reddit Icon', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_icon_reddit',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'social_icon_email',
				'title'    => __( 'Enable Share Email', 'mortgage_platform' ),
				'callback' => array( $this, 'checkbox' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_icon_email',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'social_icon_email_text',
				'title'    => __( 'Enable Share Email Text', 'mortgage_platform' ),
				'callback' => array( $this, 'textarea' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'social_icon_email_text',
					'placeholder' => '',
					'default'     => '',
					'description' => '',
				),
			),
			array(
				'id'       => 'custom_css',
				'title'    => __( 'Custom CSS Code', 'mortgage_platform' ),
				'callback' => array( $this, 'textarea' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'custom_css',
					'placeholder' => __( 'Custom CSS', 'mortgage_platform' ),
					'default'     => '',
					'description' => __( 'Add your own custom css to further control styling of the calculator', 'mortgage_platform' ),
				),
			),
			array(
				'id'       => 'custom_js',
				'title'    => __( 'Custom JS Code', 'mortgage_platform' ),
				'callback' => array( $this, 'textarea' ),
				'args'     => array(
					'option_name' => MortgagePlatform::$prefix . 'style',
					'label_for'   => 'custom_js',
					'placeholder' => __( 'Custom JS', 'mortgage_platform' ),
					'default'     => '',
					'description' => __( 'Add your own custom JS here', 'mortgage_platform' ),
				),
			),
		);

		return $fields_style;

	}



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

		/**
		 * Style settings filter.
		 *
		 * @since 1.0.0
		 *
		 * @param array $this->set_fields_style() {
		 *      @see    'MP_StyleSettings::set_fields_style()'
		 * }
		 */
		$fields_style = apply_filters( 'mortgage_platform_style', $this->set_fields_style() );

		$this->register_setting_fields( $fields_style, 'style', __( 'Style Settings', 'mortgage_platform' ), array( $this, 'page_title' ) );

		add_filter( MortgagePlatform::$prefix . 'menu', array( $this, 'filter_menu' ), 25 );
		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 style settings menu
	 *
	 * @return string list of style settings menu
	 */
	public function filter_menu( $list ) {

		if ( isset( $_GET['tab'] ) && 'style' === $_GET['tab'] ) {
			$list .= '<li class="active"><a href="?page=' . esc_attr( MortgagePlatform::$domain ) . '&tab=style" >' . esc_html__( 'Style Settings', 'mortgage_platform' ) . '</a></li>';
		} else {
			$list .= '<li ><a href="?page=' . esc_attr( MortgagePlatform::$domain ) . '&tab=style" >' . esc_html__( 'Style 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 ( 'style' === $_GET['tab'] ) {
					?>
					<div class="mp-settings__content tab-pane style">
						<form action="options.php" method="POST">
							<?php
							settings_fields( MortgagePlatform::$prefix . 'settings_style' );
							do_settings_sections( MortgagePlatform::$prefix . 'style' );
							submit_button()
							?>
						</form>
					</div>
					<?php
				}
			}
		}

	}


}

Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.