| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Quick Interest Slider |
| 4 |
Plugin URI: http://loanpaymentplugin.com/ |
| 5 |
Description: Interest calculator with slider and multiple display options. |
| 6 |
Version: 3.1.3 |
| 7 |
Author: aerin |
| 8 |
Author URI: http://quick-plugins.com/ |
| 9 |
Text Domain: quick-interest-slider |
| 10 |
Domain Path: /languages |
| 11 |
License: GPLv2 or later |
| 12 |
*/ |
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 15 |
|
| 16 |
define('QIS_VERSION', '3.1.3'); |
| 17 |
|
| 18 |
require_once( plugin_dir_path( __FILE__ ) . '/options.php' ); |
| 19 |
require_once( plugin_dir_path( __FILE__ ) . '/register.php' ); |
| 20 |
|
| 21 |
$qis_forms = 0; |
| 22 |
|
| 23 |
add_shortcode('qis', 'qis_loop'); |
| 24 |
add_shortcode('qis-subscribe', 'qis_subscribe'); |
| 25 |
add_shortcode('qisprogress', 'qis_show_progress'); |
| 26 |
|
| 27 |
add_action('wp_enqueue_scripts', 'qis_scripts'); |
| 28 |
add_action('init', 'qis_lang_init'); |
| 29 |
add_action('wp_head', 'qis_head_css'); |
| 30 |
add_action('template_redirect', 'qis_upgrade_ipn'); |
| 31 |
|
| 32 |
add_action('wp_ajax_qis_get_calculator', 'qis_get_calculator'); |
| 33 |
add_action('wp_ajax_nopriv_qis_get_calculator', 'qis_get_calculator'); |
| 34 |
|
| 35 |
add_action('wp_ajax_qis_get_stylesheet', 'qis_get_stylesheet'); |
| 36 |
add_action('wp_ajax_nopriv_qis_get_stylesheet', 'qis_get_stylesheet'); |
| 37 |
|
| 38 |
add_action('wp_ajax_qis_capture_application', 'qis_capture_application'); |
| 39 |
add_action('wp_ajax_nopriv_qis_capture_application', 'qis_capture_application'); |
| 40 |
|
| 41 |
add_action( 'wp_dashboard_setup', 'qis_add_dashboard_widgets' ); |
| 42 |
|
| 43 |
add_filter('plugin_action_links', 'qis_plugin_action_links', 10, 2 ); |
| 44 |
|
| 45 |
if (is_admin()) require_once( plugin_dir_path( __FILE__ ) . '/settings.php' ); |
| 46 |
|
| 47 |
|
| 48 |
function qis_add_dashboard_widgets() { |
| 49 |
|
| 50 |
$track = qis_get_track(); |
| 51 |
|
| 52 |
if (isset($track) && $track['enabletracking']) { |
| 53 |
wp_add_dashboard_widget( |
| 54 |
'qis_dashboard_widget', // Widget slug. |
| 55 |
esc_html__( 'Loan Application Tracking', 'quick-interest-slider' ), // Title. |
| 56 |
'qis_dashboard_widget_render' // Display function. |
| 57 |
); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
function qis_dashboard_widget_render() { |
| 62 |
|
| 63 |
$track = qis_get_track(); |
| 64 |
|
| 65 |
if ($track) { |
| 66 |
if (!isset($track['completed'])) $track['completed'] = 0; |
| 67 |
if (!isset($track['visitors'])) $track['visitors'] = 0; |
| 68 |
if (!isset($track['opened'])) $track['opened'] = 0; |
| 69 |
|
| 70 |
echo '<div style="text-align:center;width:33.3%;float:left"><div>Visitors</div> |
| 71 |
<div style="font-size:30px;text-align:center;">'.esc_html($track['visitors']).'</div></div>'; |
| 72 |
|
| 73 |
echo '<div style="text-align:center;width:33.3%;float:left"><div>Form Opened</div> |
| 74 |
<div style="font-size:30px;text-align:center;">'.esc_html($track['opened']).'</div></div>'; |
| 75 |
|
| 76 |
echo '<div style="text-align:center;width:33.3%;float:left"><div>Completed</div> |
| 77 |
<div style="font-size:30px;text-align:center;">'.esc_html($track['completed']).'</div></div>'; |
| 78 |
|
| 79 |
|
| 80 |
echo '<div style="clear:both"></div>'; |
| 81 |
|
| 82 |
if ($track['completed'] > 0) { |
| 83 |
$percent = ($track['completed'] / $track['visitors']) * 100; |
| 84 |
$percent = round($percent, 2); |
| 85 |
echo '<div style="text-align:center;">Percentage completed: '.esc_html($percent).'%</div>'; |
| 86 |
} |
| 87 |
} else { |
| 88 |
echo '<p>No tracking data available</p>'; |
| 89 |
} |
| 90 |
|
| 91 |
} |
| 92 |
|
| 93 |
function qis_get_calculator() { |
| 94 |
|
| 95 |
$return = ['success' => false]; |
| 96 |
|
| 97 |
if (isset($_POST['attributes'])) { // phpcs:ignore WordPress.Security.NonceVerification |
| 98 |
|
| 99 |
// Pass the shortcode attributes to the qis_loop handler |
| 100 |
$data = qis_loop($_POST['attributes']); // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 101 |
|
| 102 |
$return['data'] = $data; |
| 103 |
$return['success'] = true; |
| 104 |
|
| 105 |
} |
| 106 |
|
| 107 |
echo wp_json_encode($return); |
| 108 |
|
| 109 |
die(); |
| 110 |
} |
| 111 |
|
| 112 |
function qis_get_stylesheet() { |
| 113 |
$allowed_html = callback_allowed_html(); |
| 114 |
if (isset($_POST['form'])) { // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 115 |
header('content-type: text/css'); |
| 116 |
echo wp_kses(qis_generate_css(),$allowed_html); |
| 117 |
} |
| 118 |
die(); |
| 119 |
} |
| 120 |
|
| 121 |
function qis_block_init() { |
| 122 |
|
| 123 |
if ( !function_exists( 'register_block_type' ) ) { |
| 124 |
return; |
| 125 |
} |
| 126 |
|
| 127 |
$settings = qis_get_stored_settings(null); |
| 128 |
|
| 129 |
// Register our block editor script. |
| 130 |
wp_register_script( |
| 131 |
'block', |
| 132 |
plugins_url( 'block.js', __FILE__ ), |
| 133 |
array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor' ),"1.1",true |
| 134 |
); |
| 135 |
|
| 136 |
// Register our block, and explicitly define the attributes we accept. |
| 137 |
register_block_type( |
| 138 |
'quick-interest-slider/block', array( |
| 139 |
'attributes' => array( |
| 140 |
'calculator' => array( |
| 141 |
'type'=> 'string', |
| 142 |
'default' => 1 |
| 143 |
), |
| 144 |
), |
| 145 |
'editor_script' => 'block', // The script name we gave in the wp_register_script() call. |
| 146 |
'render_callback' => 'qis_loop' |
| 147 |
) |
| 148 |
); |
| 149 |
} |
| 150 |
|
| 151 |
add_action( 'init', 'qis_block_init' ); |
| 152 |
|
| 153 |
function qis_loop($atts) { |
| 154 |
$allowed_html = callback_allowed_html(); |
| 155 |
qis_get_stored_upgrade(); |
| 156 |
|
| 157 |
// Shortcode Attributes |
| 158 |
$atts = shortcode_atts(array( |
| 159 |
'calculator' => '', |
| 160 |
'currency' => '', |
| 161 |
'ba' => '', |
| 162 |
'primary' => '', |
| 163 |
'secondary' => '', |
| 164 |
'loanmin' => '', |
| 165 |
'loanmax' => '', |
| 166 |
'loaninitial' => '', |
| 167 |
'loanstep' => '', |
| 168 |
'periodslider' => '', |
| 169 |
'periodmin' => '', |
| 170 |
'periodmax' => '', |
| 171 |
'periodinitial' => '', |
| 172 |
'periodstep' => '', |
| 173 |
'period' => '', |
| 174 |
'interestslider' => '', |
| 175 |
'interestselector' => '', |
| 176 |
'interestmin' => '', |
| 177 |
'interestmax' => '', |
| 178 |
'interestinitial' => '', |
| 179 |
'intereststep' => '', |
| 180 |
'multiplier' => '', |
| 181 |
'triggertype' => '', |
| 182 |
'trigger' => '', |
| 183 |
'outputtotallabel' => '', |
| 184 |
'interesttype' => '', |
| 185 |
'totallabel' => '', |
| 186 |
'primarylabel' => '', |
| 187 |
'secondarylabel' => '', |
| 188 |
'usebubble' => '', |
| 189 |
'repaymentlabel' => '', |
| 190 |
'outputtotal' => '', |
| 191 |
'outputrepayments' => '', |
| 192 |
'outputhelp' => '', |
| 193 |
'application' => '', |
| 194 |
'repaymentlabel' => '', |
| 195 |
'buttons' => '', |
| 196 |
'markers' => '', |
| 197 |
'processing' => '', |
| 198 |
'adminfee' => '', |
| 199 |
'adminfeevalue' => '', |
| 200 |
'textinputs' => '', |
| 201 |
'interesttype' => '', |
| 202 |
'decimals' => '', |
| 203 |
'discount' => '', |
| 204 |
'applynow' => '', |
| 205 |
'fixedaddition' => '', |
| 206 |
'application' => '', |
| 207 |
'fields' => '', |
| 208 |
'loanlabel' => '', |
| 209 |
'termlabel' => '', |
| 210 |
'interestlabel' => '', |
| 211 |
'parttwo' => '', |
| 212 |
'usedownpayment' => '', |
| 213 |
'float' => '', |
| 214 |
'percentages' => '', |
| 215 |
'usegraph' => '', |
| 216 |
'interestdropdown' => '', |
| 217 |
'terminterface' => '', |
| 218 |
'use' => '' |
| 219 |
),$atts,'quick-interest-slider'); |
| 220 |
|
| 221 |
foreach ($atts as $key => $value) { |
| 222 |
$atts[$key] = sanitize_text_field($atts[$key]); |
| 223 |
} |
| 224 |
|
| 225 |
if (isset($_GET['amount']) && $_GET['amount']) $atts['loaninitial'] = $_GET['amount']; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 226 |
if (isset($_GET['term']) && $_GET['term']) $atts['periodinitial'] = $_GET['term']; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 227 |
|
| 228 |
$dropdown = qis_get_stored_dropdown(); |
| 229 |
|
| 230 |
$atts['calculatorname'] = $atts['calculator'] ? $dropdown['forms'][$atts['calculator']] : $dropdown['forms']['one']; |
| 231 |
|
| 232 |
if ($atts['use'] == 'dropdown') $dropdown['use'] = true; |
| 233 |
if ($atts['calculator'] == 'one') $atts['calculator'] = 1; |
| 234 |
if ($atts['calculator'] == 'two') $atts['calculator'] = 2; |
| 235 |
if ($atts['calculator'] == 'three') $atts['calculator'] = 3; |
| 236 |
if ($atts['calculator'] == 'four') $atts['calculator'] = 4; |
| 237 |
if ($atts['calculator'] == 'five') $atts['calculator'] = 5; |
| 238 |
if ($atts['calculator'] == 'six') $atts['calculator'] = 6; |
| 239 |
if ($atts['calculator'] == 'seven') $atts['calculator'] = 7; |
| 240 |
if ($atts['calculator'] == 'eight') $atts['calculator'] = 8; |
| 241 |
|
| 242 |
// Pro Version filters |
| 243 |
$qppkey = qis_key(); |
| 244 |
if (!isset($qppkey['authorised'])) { |
| 245 |
$atts['loanlabel'] = $atts['termlabel'] = $atts['application'] = $atts['applynow'] = $atts['interestslider'] = $atts['intereselector']= $atts['usedownpayment'] = $atts['terminterface'] = false; |
| 246 |
if ($atts['interesttype'] == 'amortization' || $atts['interesttype'] == 'amortisation') $atts['interesttype'] = 'compound'; |
| 247 |
} |
| 248 |
|
| 249 |
global $post; |
| 250 |
|
| 251 |
// Apply Now Button |
| 252 |
|
| 253 |
if (!empty($_POST['qisapply'])) { // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 254 |
$formvalues = qis_check_key($_POST); // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 255 |
if (isset($_GET['param'])) { // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 256 |
$formvalues['param'] = $_GET['param']; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 257 |
} else { |
| 258 |
$formvalues['param'] = false; |
| 259 |
} |
| 260 |
$settings = qis_get_stored_settings($formvalues['formname']); |
| 261 |
$dropdown = qis_get_stored_dropdown(); |
| 262 |
$url = $settings['applynowaction']; |
| 263 |
if ($settings['applynowquery']) { |
| 264 |
$settings['querystructure'] = str_replace('[total]', $_POST['totalamount'], $settings['querystructure']); // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 265 |
$settings['querystructure'] = str_replace('[amount]', $_POST['loan-amount'], $settings['querystructure']); // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 266 |
$settings['querystructure'] = str_replace('[term]', $_POST['loan-period'], $settings['querystructure']); // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 267 |
$settings['querystructure'] = str_replace('[rate]', $_POST['rate'], $settings['querystructure']); // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 268 |
$settings['querystructure'] = str_replace('[form]', $formvalues['formname'], $settings['querystructure']); |
| 269 |
$settings['querystructure'] = str_replace('[calculator]', $dropdown['forms'][$formvalues['formname']], $settings['querystructure']); |
| 270 |
if ($formvalues['param']) $settings['querystructure'] = str_replace('[param]', $formvalues['param'], $settings['querystructure']); |
| 271 |
$url = $url.$settings['querystructure']; |
| 272 |
} |
| 273 |
|
| 274 |
echo "<p>".__('Redirecting....','quick-interest-slider')."</p>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 275 |
echo '<meta http-equiv="refresh" content="0;url='.$url.'" />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 276 |
die(); |
| 277 |
//wp_redirect( $url ); |
| 278 |
//exit(); |
| 279 |
|
| 280 |
// Application Form |
| 281 |
|
| 282 |
} elseif (!empty($_POST['qissubmit'])) { // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 283 |
$formvalues = $_POST; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 284 |
$formerrors = array(); |
| 285 |
|
| 286 |
if (!qis_verify_form($formvalues, $formerrors)) { |
| 287 |
return qis_display($atts,$formvalues, $formerrors,null); |
| 288 |
} else { |
| 289 |
$formvalues = qis_process_form($formvalues); |
| 290 |
$apply = qis_get_stored_application_messages($formvalues['formname']); |
| 291 |
if ($apply['enable'] || $atts['parttwo']) return qis_display_application($formvalues,array(),'checked'); |
| 292 |
else return qis_display($atts,$formvalues, $formerrors,'registered'); |
| 293 |
} |
| 294 |
|
| 295 |
// Part 2 Application |
| 296 |
|
| 297 |
} elseif (!empty($_POST['part2submit'])) { // phpcs:ignore WordPress.Security.NonceVerification |
| 298 |
$formvalues = $_POST; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 299 |
$formerrors = array(); |
| 300 |
if (!qis_verify_application($formvalues, $formerrors)) { |
| 301 |
return qis_display_application($formvalues, $formerrors,null); |
| 302 |
} else { |
| 303 |
qis_process_application($formvalues); |
| 304 |
return qis_display_result($formvalues); |
| 305 |
} |
| 306 |
|
| 307 |
|
| 308 |
} elseif (!isset($_POST['attributes']) && ($dropdown['use'])) { // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 309 |
|
| 310 |
// Show Dropdown |
| 311 |
$dd = '<select id="calculators">'; |
| 312 |
$one = 1; |
| 313 |
$i = 1; |
| 314 |
$addition = 'selected="selected"'; |
| 315 |
|
| 316 |
foreach ($dropdown['forms'] as $key => $name) { |
| 317 |
if ($name) { |
| 318 |
$dd .= '<option value="'.$i.'" '.$addition.'>'.$name.'</option>'; |
| 319 |
if ($one++ == 1) $addition = ''; |
| 320 |
} |
| 321 |
$i++; |
| 322 |
} |
| 323 |
|
| 324 |
$dd .= "</select>"; |
| 325 |
|
| 326 |
$_POST['attributes'] = []; |
| 327 |
|
| 328 |
// Append The Default Calculator |
| 329 |
$dd .= '<div id="calculator-container">'; |
| 330 |
$dd .= qis_loop($atts); |
| 331 |
$dd .= "</div>"; |
| 332 |
|
| 333 |
return $dd; |
| 334 |
|
| 335 |
} else { // Default Display |
| 336 |
$formnumber = $atts['calculator']; |
| 337 |
$theform = (!$formnumber || $formnumber == 1) ? 1 : $formnumber; |
| 338 |
$settings = qis_get_stored_settings($theform); |
| 339 |
$track = qis_get_track(); |
| 340 |
if (isset($track['enabletracking']) && $track['enabletracking']) { |
| 341 |
@$track['visitors']++; |
| 342 |
update_option('qis_track',$track); |
| 343 |
} |
| 344 |
$arr = explode(",",$settings['interestdropdownvalues']); |
| 345 |
//$values = qis_get_stored_register($theform); |
| 346 |
$values['formname'] = $theform; |
| 347 |
$values['interestdropdown'] = $arr[0]; |
| 348 |
$digit1 = wp_rand(1,10); |
| 349 |
$digit2 = wp_rand(1,10); |
| 350 |
if( $digit2 >= $digit1 ) { |
| 351 |
$values['thesum'] = "$digit1 + $digit2"; |
| 352 |
$values['answer'] = $digit1 + $digit2; |
| 353 |
} else { |
| 354 |
$values['thesum'] = "$digit1 - $digit2"; |
| 355 |
$values['answer'] = $digit1 - $digit2; |
| 356 |
} |
| 357 |
return qis_display($atts,$values ,array(),null); |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
function qis_capture_application() { |
| 362 |
|
| 363 |
$track = qis_get_track(); |
| 364 |
|
| 365 |
if ($track['enabletracking']) { |
| 366 |
$track['opened']++; |
| 367 |
update_option('qis_track', $track); |
| 368 |
} |
| 369 |
echo wp_json_encode(['success' => true]); |
| 370 |
die(); |
| 371 |
} |
| 372 |
// Display the form on the page |
| 373 |
|
| 374 |
function qis_display($atts,$formvalues,$formerrors,$registered) { |
| 375 |
|
| 376 |
global $qis_forms; |
| 377 |
|
| 378 |
$formnumber = $atts['calculator']; |
| 379 |
$theform = (!$formnumber || $formnumber == 1) ? 1 : $formnumber; |
| 380 |
$settings = qis_get_stored_settings($theform); |
| 381 |
$style = qis_get_stored_style(); |
| 382 |
$register = qis_get_stored_register($theform); |
| 383 |
$table = qis_get_stored_ouputtable(); |
| 384 |
$qppkey = qis_key(); |
| 385 |
$floats = false; |
| 386 |
|
| 387 |
$qis_forms++; |
| 388 |
|
| 389 |
foreach ($atts as $item => $key) { |
| 390 |
if ($key) { |
| 391 |
$settings[$item] = esc_attr($key); |
| 392 |
} |
| 393 |
} |
| 394 |
|
| 395 |
if ($atts['terminterface']) { |
| 396 |
|
| 397 |
$settings['terminterface'] = $atts['terminterface']; |
| 398 |
|
| 399 |
if (!in_array(strtolower($atts['terminterface']),['slider','button'])) { |
| 400 |
$settings['periodslider'] = false; |
| 401 |
} else { |
| 402 |
$settings['periodslider'] = 'checked'; |
| 403 |
} |
| 404 |
} |
| 405 |
|
| 406 |
if ($atts['periodslider']) $settings['terminterface'] = 'slider'; |
| 407 |
|
| 408 |
// Field override |
| 409 |
|
| 410 |
if ($atts['fields']) $formvalues['fields'] = $atts['fields']; |
| 411 |
if ($atts['application']) $register['application'] = 'checked'; |
| 412 |
if ($atts['primary']) $settings['triggers'][0]['rate'] = $atts['primary']; |
| 413 |
if ($atts['secondary']) $settings['triggers'][1]['rate'] = $atts['secondary']; |
| 414 |
if ($atts['trigger']) $settings['triggers'][1]['trigger'] = $atts['trigger']; |
| 415 |
if ($atts['repaymentlabel']) $settings['outputrepayments'] = 'true'; |
| 416 |
|
| 417 |
if ($atts['processing']) { |
| 418 |
if (stristr($atts['processing'],'%')) { |
| 419 |
$settings['adminfee'] = true; |
| 420 |
if (preg_match('/^(\d+?\.?\d*)%$/',$atts['processing'],$matches)) { |
| 421 |
$settings['adminfeevalue'] = trim($matches[1],'.'); |
| 422 |
$settings['adminfeetype'] = 'percent'; |
| 423 |
} |
| 424 |
} else { |
| 425 |
$settings['adminfee'] = true; |
| 426 |
if (is_numeric($atts['processing'])) { |
| 427 |
$settings['adminfeevalue'] = (float) $atts['processing']; |
| 428 |
$settings['adminfeetype'] = 'fixed'; |
| 429 |
} |
| 430 |
} |
| 431 |
} |
| 432 |
|
| 433 |
if ($settings['percentages']) { |
| 434 |
$settings['percentarr'] = array(); |
| 435 |
$ratesarray = explode(',',$settings['percentages']); |
| 436 |
for ($i=0;$i<count($ratesarray);$i++) |
| 437 |
$settings['percentarr'][$i] = $ratesarray[$i]; |
| 438 |
} |
| 439 |
|
| 440 |
$settings['repaymentlabel'] = preg_replace('/{(\w+)}/','[\1]',$settings['repaymentlabel']); |
| 441 |
|
| 442 |
if ($settings['ba'] == 'before') { |
| 443 |
$settings['cb'] = $settings['currency']; |
| 444 |
$settings['ca'] = ' '; |
| 445 |
} else { |
| 446 |
$settings['ca'] = $settings['currency']; |
| 447 |
$settings['cb'] = ' '; |
| 448 |
} |
| 449 |
|
| 450 |
if ($register['application']) $settings['application'] = true; |
| 451 |
if (!isset($formvalues['loan-amount'])) $formvalues['loan-amount'] = $settings['loaninitial']; |
| 452 |
if (!isset($formvalues['loan-period'])) $formvalues['loan-period'] = $settings['periodinitial']; |
| 453 |
if (!isset($formvalues['loan-interest'])) $formvalues['loan-interest'] = $settings['interestinitial']; |
| 454 |
if (!isset($formvalues['loan-downpayment'])) $formvalues['loan-downpayment'] = $settings['downpaymentinitial']; |
| 455 |
if ($settings['multiplier'] < 1 || $settings['multiplier'] == false) {$settings['multiplier'] = $formvalues['multiplier'] = 1;} |
| 456 |
|
| 457 |
$settings['singleperiod'] = $settings['singleperiodlabel'] ? $settings['singleperiodlabel'] : $settings['period']; |
| 458 |
$settings['periodlabel'] = $settings['periodlabel'] ? $settings['periodlabel'] : $settings['period']; |
| 459 |
$settings['offset'] = $register['offset'] ? $register['offset'] : 0; |
| 460 |
|
| 461 |
if ($style['floatoutput']) $atts['float'] = true; |
| 462 |
|
| 463 |
// Normalize values |
| 464 |
|
| 465 |
$outputA = array(); |
| 466 |
|
| 467 |
foreach ($settings as $k => $v) { |
| 468 |
$outputA[$k] = $v; |
| 469 |
|
| 470 |
if (!is_array($v)) { |
| 471 |
|
| 472 |
if (@strtolower($v) == 'checked') $outputA[$k] = true; |
| 473 |
|
| 474 |
if ($v == '') $outputA[$k] = false; |
| 475 |
|
| 476 |
if (@preg_match('/[0-9.]+/',$v)) $outputA[$k] = (float) $v; |
| 477 |
} |
| 478 |
} |
| 479 |
|
| 480 |
if ($settings['nosliderlabel']) { |
| 481 |
$amountmin = qis_separator($settings['loanmin'],$outputA['separator']); |
| 482 |
$amountmax = qis_separator($settings['loanmax'],$outputA['separator']); |
| 483 |
$periodmin = $settings['periodmin']; |
| 484 |
$periodmax = $settings['periodmax']; |
| 485 |
$interestmin = $settings['interestmin']; |
| 486 |
$interestmax = $settings['interestmax']; |
| 487 |
$downpaymentmin = qis_separator($settings['downpaymentmin'],$outputA['separator']); |
| 488 |
$downpaymentmax = qis_separator($settings['downpaymentmax'],$outputA['separator']); |
| 489 |
} else { |
| 490 |
$amountmin = $settings['cb'].qis_separator($settings['loanmin'],$outputA['separator']).$settings['ca']; |
| 491 |
$amountmax = $settings['cb'].qis_separator($settings['loanmax'],$outputA['separator']).$settings['ca']; |
| 492 |
$periodmin = $settings['periodmin'].' '.$settings['singleperiod']; |
| 493 |
$periodmax = $settings['periodmax'].' '.$settings['periodlabel']; |
| 494 |
$interestmin = $settings['interestmin'].'%'; |
| 495 |
$interestmax = $settings['interestmax'].'%'; |
| 496 |
$downpaymentmin = $settings['cb'].qis_separator($settings['downpaymentmin'],$outputA['separator']).$settings['ca']; |
| 497 |
$downpaymentmax = $settings['cb'].qis_separator($settings['downpaymentmax'],$outputA['separator']).$settings['ca']; |
| 498 |
} |
| 499 |
|
| 500 |
if ($settings['onlyslidervalue']) { |
| 501 |
$amountmin = $amountmax = $periodmin = $periodmax = ' '; |
| 502 |
} |
| 503 |
|
| 504 |
// Shortcode Replacements |
| 505 |
|
| 506 |
$dpf = false; |
| 507 |
|
| 508 |
if ($settings['downpaymentfixed']) $dpf = $settings['cb'].$settings['downpaymentfixed'].$settings['ca']; |
| 509 |
if ($settings['downpaymentpercent'] && $dpf) $dpf = $dpf.' and '.$settings['downpaymentpercent'].'%'; |
| 510 |
if ($settings['downpaymentpercent'] && !$dpf) $dpf = $settings['downpaymentpercent'].'%'; |
| 511 |
|
| 512 |
if (strpos($settings['repaymentlabel'],'[table]') !== false) { |
| 513 |
|
| 514 |
$outputtable = '<table class="outputtable">'; |
| 515 |
|
| 516 |
$sort = explode(",", $table['sort']); |
| 517 |
foreach ($sort as $name) { |
| 518 |
if ($table['use'.$name]) $outputtable .= '<tr><td class="output-caption">'.$table[$name.'caption'].'</td><td class="values-colour output-values">'.$strongon.'['.$name.']'.$strongoff.'</td></tr>'; |
| 519 |
} |
| 520 |
|
| 521 |
$outputtable .= '</table>'; |
| 522 |
|
| 523 |
$settings['repaymentlabel'] = str_replace('[table]', $outputtable, $settings['repaymentlabel']); |
| 524 |
} |
| 525 |
|
| 526 |
$arr = array('repaymentlabel','outputtotallabel'); |
| 527 |
|
| 528 |
foreach ($arr as $item) { |
| 529 |
$settings[$item] = str_replace('[step]', $settings['periodstep'], $settings[$item]); |
| 530 |
$settings[$item] = str_replace('[amount]', '<span class="repayment"></span>', $settings[$item]); |
| 531 |
$settings[$item] = str_replace('[repayment]', '<span class="repayment"></span>', $settings[$item]); |
| 532 |
$settings[$item] = str_replace('[period]', $settings['singleperiod'], $settings[$item]); |
| 533 |
$settings[$item] = str_replace('[rate]', '<span class="interestrate"></span>', $settings[$item]); |
| 534 |
$settings[$item] = str_replace('[dae]', '<span class="dae"></span>', $settings[$item]); |
| 535 |
$settings[$item] = str_replace('[interest]', '<span class="current_interest"></span>', $settings[$item]); |
| 536 |
$settings[$item] = str_replace('[monthlyrate]', '<span class="monthlyrate"></span>', $settings[$item]); |
| 537 |
$settings[$item] = str_replace('[total]', '<span class="final_total"></span>', $settings[$item]); |
| 538 |
$settings[$item] = str_replace('[discount]', '<span class="discount"></span>', $settings[$item]); |
| 539 |
$settings[$item] = str_replace('[principle]', '<span class="principle"></span>', $settings[$item]); |
| 540 |
$settings[$item] = str_replace('[term]', '<span class="term"></span>', $settings[$item]); |
| 541 |
$settings[$item] = str_replace('[processing]', '<span class="processing"></span>', $settings[$item]); |
| 542 |
$settings[$item] = str_replace('[date]', '<span class="repaymentdate"></span>', $settings[$item]); |
| 543 |
$settings[$item] = str_replace('[percentages1]', '<span class="percentages1"></span>', $settings[$item]); |
| 544 |
$settings[$item] = str_replace('[percentages2]', '<span class="percentages2"></span>', $settings[$item]); |
| 545 |
$settings[$item] = str_replace('[percentages3]', '<span class="percentages3"></span>', $settings[$item]); |
| 546 |
$settings[$item] = str_replace('[percentages4]', '<span class="percentages4"></span>', $settings[$item]); |
| 547 |
|
| 548 |
$settings[$item] = str_replace('[primary]', '<span class="generic_primary"></span>', $settings[$item]); |
| 549 |
$settings[$item] = str_replace('[secondary]', '<span class="generic_secondary"></span>', $settings[$item]); |
| 550 |
|
| 551 |
$settings[$item] = str_replace('[weeks]', '<span class="weeks"></span>', $settings[$item]); |
| 552 |
$settings[$item] = str_replace('[years]', '<span class="years"></span>', $settings[$item]); |
| 553 |
$settings[$item] = str_replace('[weekly]', '<span class="weekly"></span>', $settings[$item]); |
| 554 |
$settings[$item] = str_replace('[monthly]', '<span class="monthly"></span>', $settings[$item]); |
| 555 |
$settings[$item] = str_replace('[annual]', '<span class="annual"></span>', $settings[$item]); |
| 556 |
|
| 557 |
if (isset($qppkey['authorised'])) { |
| 558 |
$settings[$item] = str_replace('[downpayment]', '<span class="downpayment"></span>', $settings[$item]); |
| 559 |
$settings[$item] = str_replace('[fixeddownpayment]', $settings['cb'].$settings['downpaymentfixed'].$settings['ca'], $settings[$item]); |
| 560 |
$settings[$item] = str_replace('[downpaymentpercent]', $settings['downpaymentpercent'].'%', $settings[$item]); |
| 561 |
$settings[$item] = str_replace('[mitigated]', '<span class="mitigated"></span>', $settings[$item]); |
| 562 |
} |
| 563 |
} |
| 564 |
|
| 565 |
$addFloat = ''; |
| 566 |
if ($atts['float']) { |
| 567 |
$addFloat = 'qis-add-float'; |
| 568 |
} |
| 569 |
|
| 570 |
// Append the currencies to the rates object |
| 571 |
|
| 572 |
$outputA['currencies'] = array(); |
| 573 |
$s_form = ((isset($_POST['submitted_form']))? $_POST['submitted_form']:'N/A'); // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 574 |
|
| 575 |
$i = 1; |
| 576 |
for ($A_i = 0; isset($settings['currency_array'][$A_i]); $A_i++) { |
| 577 |
$outputA['currencies']['c'.$A_i] = $settings['currency_array'][$A_i]; |
| 578 |
} |
| 579 |
|
| 580 |
$newTriggers = []; |
| 581 |
foreach ($outputA['triggers'] as $k => $v) { |
| 582 |
if ($v['rate'] != '') $newTriggers[] = $v; |
| 583 |
} |
| 584 |
|
| 585 |
$outputA['triggers'] = $newTriggers; |
| 586 |
$outputA['graph'] = ['use' => false]; |
| 587 |
$outputA['applynowaction'] = $settings['applynowaction']; |
| 588 |
|
| 589 |
$output = '<script type="text/javascript">'; |
| 590 |
$output .= 'qis__rates["qis_'.$qis_forms.'"] = '.wp_json_encode($outputA).';'; |
| 591 |
$output .= 'qis_form = '.wp_json_encode($s_form).';'; |
| 592 |
$output .= '</script>'; |
| 593 |
$output .= $floats; |
| 594 |
$output .= '<form action="" class="qis_form '.$style['border'].'" method="POST" id="qis_'.$qis_forms.'" enctype="multipart/form-data">'; |
| 595 |
$output .= '<input type="hidden" name="submitted_form" value="qis_'.$qis_forms.'" />'; |
| 596 |
|
| 597 |
if ($settings['formheader']) $output .= '<h2>'.$settings['formheader'].'</h2>'; |
| 598 |
|
| 599 |
$output .= '<div class="qis-sections qis-float '.$addFloat.'"><div class="qis-inputs qis-float-columns">'; |
| 600 |
|
| 601 |
$output .= '<input type="hidden" name="interesttype" value="'.$settings['interesttype'].'" />'; |
| 602 |
|
| 603 |
$sort = explode(",", $settings['sort']); |
| 604 |
|
| 605 |
if ($settings['usedownpaymentslider'] != 'checked') { |
| 606 |
$sort = qis_unset($sort,'downpayment'); |
| 607 |
} |
| 608 |
|
| 609 |
foreach($sort as $item) { |
| 610 |
|
| 611 |
if ($item == 'amount') { |
| 612 |
$output .= '<div class="range qis-slider-principal">'; |
| 613 |
|
| 614 |
$label = false; |
| 615 |
|
| 616 |
// Principal Slider |
| 617 |
|
| 618 |
if ($settings['loanlabel'] && $settings['sliderlabelposition'] == 'aboveslider') { |
| 619 |
$output .= '<div class="slider-label">'.$settings['loanlabel']; |
| 620 |
if ($settings['loanhelp']) $output .= qis_tooltip($settings['loaninfo']); |
| 621 |
$output .= '</div>'; |
| 622 |
} |
| 623 |
|
| 624 |
if ($settings['loanlabel'] && $settings['sliderlabelposition'] == 'beforeoutput') { |
| 625 |
$label = '<span class="sliderlabel">'.$settings['loanlabel'].' </span>'; |
| 626 |
} |
| 627 |
|
| 628 |
if ($settings['textinputs'] != 'slider') $oX = '<input type="text" class="output" value="'.$formvalues['loan-amount'].'" />'; |
| 629 |
elseif ($settings['outputlimits']) $oX = '<output></output>'; |
| 630 |
else $oX = null; |
| 631 |
|
| 632 |
if ($settings['textinputs'] != 'text') { |
| 633 |
|
| 634 |
if ($settings['buttons'] && $settings['sliderbuttonposition'] == 'slidertop') { |
| 635 |
$output .= qis_outputs (true,$amountmin,$amountmax,$oX,$label); |
| 636 |
} elseif ($settings['maxminlimits']) { |
| 637 |
$output .= qis_outputs (false,$amountmin,$amountmax,$oX,$label); |
| 638 |
} else { |
| 639 |
$output .= qis_outputs (false,' ',' ',$oX,$label); |
| 640 |
} |
| 641 |
|
| 642 |
if ($settings['buttons'] && $settings['sliderbuttonposition'] == 'sliderside') { |
| 643 |
$output .= '<div class="qis_buttons"> |
| 644 |
<div class="circle-control minus"><svg xmlns="http://www.w3.org/2000/svg" height="25px" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM184 232c-13.3 0-24 10.7-24 24s10.7 24 24 24H328c13.3 0 24-10.7 24-24s-10.7-24-24-24H184z"/></svg></div> |
| 645 |
<div><input type="range" name="loan-amount" min="'.$settings['loanmin'].'" max="'.$settings['loanmax'].'" value="'.$formvalues['loan-amount'].'" step="'.$settings['loanstep'].'" data-qis></div> |
| 646 |
<div class="circle-control plus"><svg xmlns="http://www.w3.org/2000/svg" height="25px" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM232 344c0 13.3 10.7 24 24 24s24-10.7 24-24V280h64c13.3 0 24-10.7 24-24s-10.7-24-24-24H280V168c0-13.3-10.7-24-24-24s-24 10.7-24 24v64H168c-13.3 0-24 10.7-24 24s10.7 24 24 24h64v64z"/></svg></div></div>'; |
| 647 |
} else { |
| 648 |
$output .= '<input type="range" name="loan-amount" min="'.$settings['loanmin'].'" max="'.$settings['loanmax'].'" value="'.$formvalues['loan-amount'].'" step="'.$settings['loanstep'].'" data-qis>'; |
| 649 |
} |
| 650 |
|
| 651 |
if ($settings['markers']) { |
| 652 |
$output .= qis_markers($settings,$style['handle-size'],$settings['loanmax'],$settings['loanmin'],$settings['loanstep']); |
| 653 |
} |
| 654 |
|
| 655 |
} else { |
| 656 |
$output .= '<div>'.$oX.'</div>'; |
| 657 |
$label = str_replace('[min]',$amountmin,$settings['amounttext']); |
| 658 |
$label = str_replace('[max]',$amountmax,$label); |
| 659 |
$output .= '<div class="textlabel".>'.$label.'</div>'; |
| 660 |
$output .= '<div class="hidethis"><input type="range" name="loan-amount" min="'.$settings['loanmin'].'" max="'.$settings['loanmax'].'" value="'.$formvalues['loan-amount'].'" step="'.$settings['loanstep'].'" data-qis></div>'; |
| 661 |
} |
| 662 |
|
| 663 |
$output .= '</div>'; |
| 664 |
} |
| 665 |
|
| 666 |
if ($item == 'term') { |
| 667 |
|
| 668 |
$label = false; |
| 669 |
|
| 670 |
// Term Slider |
| 671 |
|
| 672 |
if ($settings['textinputs'] != 'slider') $oX = '<input type="text" class="output" value="'.$formvalues['loan-period'].'" />'; |
| 673 |
elseif ($settings['outputlimits']) $oX = '<output></output>'; |
| 674 |
else $oX = null; |
| 675 |
|
| 676 |
if ($settings['periodslider']) { |
| 677 |
|
| 678 |
if ($settings['termlabel'] && $settings['sliderlabelposition'] == 'aboveslider') { |
| 679 |
$output .= '<div class="slider-label">'.$settings['termlabel']; |
| 680 |
if ($settings['periodhelp']) $output .= qis_tooltip($settings['periodinfo']); |
| 681 |
$output .= '</div>'; |
| 682 |
} |
| 683 |
|
| 684 |
if ($settings['termlabel'] && $settings['sliderlabelposition'] == 'beforeoutput') { |
| 685 |
$label = '<span class="sliderlabel">'.$settings['termlabel'].' </span>'; |
| 686 |
} |
| 687 |
|
| 688 |
$output .= '<div class="range qis-slider-term">'; |
| 689 |
|
| 690 |
if ($settings['textinputs'] != 'text') { |
| 691 |
|
| 692 |
if ($settings['buttons'] && $settings['sliderbuttonposition'] == 'slidertop') { |
| 693 |
$output .= qis_outputs (true,$periodmin,$periodmax,$oX,$label); |
| 694 |
} elseif ($settings['maxminlimits']) { |
| 695 |
$output .= qis_outputs (false,$periodmin,$periodmax,$oX,$label); |
| 696 |
} else { |
| 697 |
$output .= qis_outputs (false,' ',' ',$oX,$label); |
| 698 |
} |
| 699 |
|
| 700 |
if ($settings['buttons'] && $settings['sliderbuttonposition'] == 'sliderside') { |
| 701 |
$output .= '<div class="qis_buttons"> |
| 702 |
<div class="circle-control minus"><svg xmlns="http://www.w3.org/2000/svg" height="25px" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM184 232c-13.3 0-24 10.7-24 24s10.7 24 24 24H328c13.3 0 24-10.7 24-24s-10.7-24-24-24H184z"/></svg></div> |
| 703 |
<div><input type="range" name="loan-period" min="'.$settings['periodmin'].'" max="'.$settings['periodmax'].'" value="'.$formvalues['loan-period'].'" step="'.$settings['periodstep'].'" data-qis></div> |
| 704 |
<div class="circle-control plus"><svg xmlns="http://www.w3.org/2000/svg" height="25px" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM232 344c0 13.3 10.7 24 24 24s24-10.7 24-24V280h64c13.3 0 24-10.7 24-24s-10.7-24-24-24H280V168c0-13.3-10.7-24-24-24s-24 10.7-24 24v64H168c-13.3 0-24 10.7-24 24s10.7 24 24 24h64v64z"/></svg></div></div>'; |
| 705 |
} else { |
| 706 |
$output .= '<input type="range" name="loan-period" min="'.$settings['periodmin'].'" max="'.$settings['periodmax'].'" value="'.$formvalues['loan-period'].'" step="'.$settings['periodstep'].'" data-qis>'; |
| 707 |
} |
| 708 |
|
| 709 |
if ($settings['markers']) { |
| 710 |
$output .= qis_markers($settings,$style['handle-size'],$settings['periodmax'],$settings['periodmin'],$settings['periodstep']); |
| 711 |
} |
| 712 |
|
| 713 |
} else { |
| 714 |
$output .= '<div>'.$oX.'</div>'; |
| 715 |
$label = str_replace('[min]',$periodmin,$settings['termtext']); |
| 716 |
$label = str_replace('[max]',$periodmax,$label); |
| 717 |
$output .= '<div class="textlabel".>'.$label.'</div>'; |
| 718 |
$output .= '<div class="hidethis"><input type="range" name="loan-period" min="'.$settings['periodmin'].'" max="'.$settings['periodmax'].'" value="'.$formvalues['loan-period'].'" step="'.$settings['periodstep'].'" data-qis></div>'; |
| 719 |
} |
| 720 |
$output .= '</div>'; |
| 721 |
} else { |
| 722 |
$output .= '<input type="hidden" name="loan-period" value="'.$formvalues['loan-period'].'">'; |
| 723 |
} |
| 724 |
|
| 725 |
} |
| 726 |
|
| 727 |
if ($item == 'downpayment' && $settings['usedownpaymentslider']) { |
| 728 |
|
| 729 |
$output .= '<div class="range qis-slider-downpayment">'; |
| 730 |
|
| 731 |
$label = false; |
| 732 |
|
| 733 |
// Downpayment Slider |
| 734 |
if ($settings['downpaymentlabel'] && $settings['sliderlabelposition'] == 'aboveslider') { |
| 735 |
$output .= '<div class="slider-label">'.$settings['downpaymentlabel']; |
| 736 |
if ($settings['downpaymenthelp']) $output .= qis_tooltip($settings['downpaymentinfo']); |
| 737 |
$output .= '</div>'; |
| 738 |
} |
| 739 |
|
| 740 |
if ($settings['downpaymentlabel'] && $settings['sliderlabelposition'] == 'beforeoutput') { |
| 741 |
$label = '<span class="sliderlabel">'.$settings['downpaymentlabel'].' </span>'; |
| 742 |
} |
| 743 |
|
| 744 |
if ($settings['textinputs'] != 'slider') $oX = '<input type="text" class="output" value="'.$formvalues['loan-downpayment'].'" />'; |
| 745 |
elseif ($settings['outputlimits']) $oX = '<output></output>'; |
| 746 |
else $oX = null; |
| 747 |
|
| 748 |
if ($settings['textinputs'] != 'text') { |
| 749 |
|
| 750 |
if ($settings['buttons'] && $settings['sliderbuttonposition'] == 'slidertop') { |
| 751 |
$output .= qis_outputs (true,$downpaymentmin,$downpaymentmax,$oX,$label); |
| 752 |
} elseif ($settings['maxminlimits']) { |
| 753 |
$output .= qis_outputs (false,$downpaymentmin,$downpaymentmax,$oX,$label); |
| 754 |
} else { |
| 755 |
$output .= qis_outputs (false,' ',' ',$oX,$label); |
| 756 |
} |
| 757 |
|
| 758 |
if ($settings['buttons'] && $settings['sliderbuttonposition'] == 'sliderside') { |
| 759 |
$output .= '<div class="qis_buttons"> |
| 760 |
<div class="circle-control minus"><svg xmlns="http://www.w3.org/2000/svg" height="25px" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM184 232c-13.3 0-24 10.7-24 24s10.7 24 24 24H328c13.3 0 24-10.7 24-24s-10.7-24-24-24H184z"/></svg></div> |
| 761 |
<div><input type="range" name="loan-downpayment" min="'.$settings['downpaymentmin'].'" max="'.$settings['downpaymentmax'].'" value="'.$formvalues['loan-downpayment'].'" step="'.$settings['downpaymentstep'].'" data-qis></div> |
| 762 |
<div class="circle-control plus"><svg xmlns="http://www.w3.org/2000/svg" height="25px" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM232 344c0 13.3 10.7 24 24 24s24-10.7 24-24V280h64c13.3 0 24-10.7 24-24s-10.7-24-24-24H280V168c0-13.3-10.7-24-24-24s-24 10.7-24 24v64H168c-13.3 0-24 10.7-24 24s10.7 24 24 24h64v64z"/></svg></div></div>'; |
| 763 |
} else { |
| 764 |
$output .= '<input type="range" name="loan-downpayment" min="'.$settings['downpaymentmin'].'" max="'.$settings['downpaymentmax'].'" value="'.$formvalues['loan-downpayment'].'" step="'.$settings['downpaymentstep'].'" data-qis>'; |
| 765 |
} |
| 766 |
|
| 767 |
if ($settings['markers']) { |
| 768 |
$output .= qis_markers($settings,$style['handle-size'],$settings['downpaymentmax'],$settings['downpaymentmin'],$settings['downpaymentstep']); |
| 769 |
} |
| 770 |
|
| 771 |
} else { |
| 772 |
$output .= '<div>'.$oX.'</div>'; |
| 773 |
$label = str_replace('[min]',$downpaymentmin,$settings['downpaymenttext']); |
| 774 |
$label = str_replace('[max]',$downpaymentmax,$label); |
| 775 |
$output .= '<div class="textlabel".>'.$label.'</div>'; |
| 776 |
$output .= '<div class="hidethis"><input type="range" name="loan-downpayment" min="'.$settings['downpaymentmin'].'" max="'.$settings['downpaymentmax'].'" value="'.$formvalues['loan-downpayment'].'" step="'.$settings['downpaymentstep'].'" data-qis></div>'; |
| 777 |
} |
| 778 |
$output .= '</div>'; |
| 779 |
} |
| 780 |
|
| 781 |
if ($item == 'interest') { |
| 782 |
|
| 783 |
$label = false; |
| 784 |
|
| 785 |
// Interest Slider |
| 786 |
|
| 787 |
if ($settings['textinputs'] != 'slider') $oX = '<input type="text" class="output" value="'.$formvalues['loan-interest'].'" />'; |
| 788 |
elseif ($settings['outputlimits']) $oX = '<output></output>'; |
| 789 |
else $oX = null; |
| 790 |
|
| 791 |
if ($settings['interestslider'] && !$settings['interestselector'] && !$settings['interestdropdown']) { |
| 792 |
|
| 793 |
if ($settings['interestlabel'] && $settings['sliderlabelposition'] == 'aboveslider') { |
| 794 |
$output .= '<div class="slider-label">'.$settings['interestlabel']; |
| 795 |
if ($settings['interesthelp']) $output .= qis_tooltip($settings['interestinfo']); |
| 796 |
$output .= '</div>'; |
| 797 |
} |
| 798 |
|
| 799 |
if ($settings['interestlabel'] && $settings['sliderlabelposition'] == 'beforeoutput') { |
| 800 |
$label = '<span class="sliderlabel">'.$settings['interestlabel'].' </span>'; |
| 801 |
} |
| 802 |
|
| 803 |
$output .= '<div class="range qis-slider-interest">'; |
| 804 |
|
| 805 |
if ($settings['textinputs'] != 'text') { |
| 806 |
|
| 807 |
if ($settings['buttons'] && $settings['sliderbuttonposition'] == 'slidertop') { |
| 808 |
$output .= qis_outputs (true,$interestmin,$interestmax,$oX,$label); |
| 809 |
} elseif ($settings['maxminlimits']) { |
| 810 |
$output .= qis_outputs (false,$interestmin,$interestmax,$oX,$label); |
| 811 |
} else { |
| 812 |
$output .= qis_outputs (false,' ',' ',$oX,$label); |
| 813 |
} |
| 814 |
|
| 815 |
if ($settings['buttons'] && $settings['sliderbuttonposition'] == 'sliderside') { |
| 816 |
$output .= '<div class="qis_buttons"> |
| 817 |
<div class="circle-control minus"><svg xmlns="http://www.w3.org/2000/svg" height="25px" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM184 232c-13.3 0-24 10.7-24 24s10.7 24 24 24H328c13.3 0 24-10.7 24-24s-10.7-24-24-24H184z"/></svg></div> |
| 818 |
<div><input type="range" name="loan-interest" min="'.$settings['interestmin'].'" max="'.$settings['interestmax'].'" value="'.$formvalues['loan-interest'].'" step="'.$settings['intereststep'].'" data-qis></div> |
| 819 |
<div class="circle-control plus"><svg xmlns="http://www.w3.org/2000/svg" height="25px" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM232 344c0 13.3 10.7 24 24 24s24-10.7 24-24V280h64c13.3 0 24-10.7 24-24s-10.7-24-24-24H280V168c0-13.3-10.7-24-24-24s-24 10.7-24 24v64H168c-13.3 0-24 10.7-24 24s10.7 24 24 24h64v64z"/></svg></div></div>'; |
| 820 |
} else { |
| 821 |
$output .= '<input type="range" name="loan-interest" min="'.$settings['interestmin'].'" max="'.$settings['interestmax'].'" value="'.$formvalues['loan-interest'].'" step="'.$settings['intereststep'].'" data-qis>'; |
| 822 |
} |
| 823 |
|
| 824 |
if ($settings['markers']) { |
| 825 |
$output .= qis_markers($settings,$style['handle-size'],$settings['interestmax'],$settings['interestmin'],$settings['intereststep']); |
| 826 |
} |
| 827 |
|
| 828 |
} else { |
| 829 |
$output .= '<div>'.$oX.'</div>'; |
| 830 |
$label = str_replace('[min]',$interestmin,$settings['interesttext']); |
| 831 |
$label = str_replace('[max]',$interestmax,$label); |
| 832 |
$output .= '<div class="textlabel".>'.$label.'</div>'; |
| 833 |
$output .= '<div class="hidethis"><input type="range" name="loan-interest" min="'.$settings['interestmin'].'" max="'.$settings['interestmax'].'" value="'.$formvalues['loan-interest'].'" step="'.$settings['intereststep'].'" data-qis></div>'; |
| 834 |
} |
| 835 |
|
| 836 |
$output .= '</div>'; |
| 837 |
} |
| 838 |
|
| 839 |
// Interest Selectors |
| 840 |
if ($settings['interestselector'] && $qppkey['authorised'] && !$settings['interestslider'] && !$settings['interestdropdown']) { |
| 841 |
$output .= '<div class="checkradio"><ul>'; |
| 842 |
if ($settings['interestselectorlabel']) $output .= '<li class="label">'.$settings['interestselectorlabel'].':</li>'; |
| 843 |
for ($i = 1; $i <= 4; $i++) { |
| 844 |
if ($settings['interestname'.$i]) { |
| 845 |
$checked = $i == 1 ? 'checked' : ''; |
| 846 |
$output .= '<li><input type="radio" name="interestselector" value="'.$i.'" '.$checked.' id="interestname'.$i.'"><label for="interestname'.$i.'"><span></span>'.$settings['interestname'.$i].'</label></li>'; |
| 847 |
} |
| 848 |
} |
| 849 |
$output .= '</ul></div>'; |
| 850 |
$output .= '<div style="clear:both"></div>'; |
| 851 |
} |
| 852 |
|
| 853 |
// Interest Dropdown |
| 854 |
if ($settings['interestdropdown'] && $qppkey['authorised'] && !$settings['interestslider'] && !$settings['interestselector']) { |
| 855 |
|
| 856 |
$arr = explode(",",$settings['interestdropdownvalues']); |
| 857 |
$output .= '<div class="qis-register">'; |
| 858 |
if ($settings['interestdropdownlabelposition'] == 'paragraph') |
| 859 |
$output .= '<p>'.$settings['interestdropdownlabel'].'</p>'; |
| 860 |
$output .= '<select name="interestdropdown">'; |
| 861 |
if ($settings['interestdropdownlabelposition'] == 'include') |
| 862 |
$output .= '<option value="'.preg_replace("/[^0-9.]/", "", $arr[0]).'">' . $settings['interestdropdownlabel'] . '</option>'."\r\t"; |
| 863 |
foreach ($arr as $item) { |
| 864 |
$value = preg_replace("/[^0-9.]/", "", $item); |
| 865 |
$selected = $formvalues['interestdropdown'] == $value ? ' selected="selected"' : ''; |
| 866 |
$output .= '<option value="' . $value . '" ' . $selected .'>' . $item . '</option>'."\r\t"; |
| 867 |
} |
| 868 |
$output .= '</select></div>'; |
| 869 |
} |
| 870 |
} |
| 871 |
|
| 872 |
// Loan Breakdown Graph |
| 873 |
|
| 874 |
if ($item == 'graph' && !$atts['float']) { |
| 875 |
|
| 876 |
if ($settings['usegraph']) { |
| 877 |
|
| 878 |
if ($settings['graphlabel']) $output .= '<div class="slider-label">'.$settings['graphlabel'].'</div>'; |
| 879 |
$output .= '<div class="qisBar"> |
| 880 |
<div class="qisBarProgress1" style="background-color:'.$style['graphdownpayment'].'"></div> |
| 881 |
<div class="qisBarProgress2" style="background-color:'.$style['graphprinciple'].'"></div>'; |
| 882 |
if ($settings['adminfeewhen'] == 'beforeinterest' && $settings['adminfee']) $output .= '<div class="qisBarProgress4" style="background-color:'.$style['graphprocessing'].'"></div>'; |
| 883 |
$output .= '<div class="qisBarProgress3" style="background-color:'.$style['graphinterest'].'"></div>'; |
| 884 |
if ($settings['adminfeewhen'] == 'afterinterest' && $settings['adminfee']) $output .= '<div class="qisBarProgress4" style="background-color:'.$style['graphprocessing'].'"></div>'; |
| 885 |
$output .= '</div>'; |
| 886 |
|
| 887 |
$output .= '<div id="qis-totalbar"></div>'; |
| 888 |
$output .= '<p class="legend">'; |
| 889 |
if ($settings['usedownpayment'] || $settings['usedownpaymentslider']) $output .= '<span style="background-color:'.$style['graphdownpayment'].'"></span> '.$settings['graphdownpayment'].' '; |
| 890 |
if ($settings['discount']) $output .= '<span style="background-color:'.$style['graphdiscount'].'"></span> '.$settings['graphdiscount'].' '; |
| 891 |
$output .= '<span style="background-color:'.$style['graphprinciple'].'"></span> '.$settings['graphprinciple'].' '; |
| 892 |
if ($settings['adminfeewhen'] == 'beforeinterest' && $settings['adminfee']) $output .= '<span style="background-color:'.$style['graphprocessing'].'"></span> '.$settings['graphprocessing'].' '; |
| 893 |
$output .= '<span style="background-color:'.$style['graphinterest'].'"></span> '.$settings['graphinterest'].' '; |
| 894 |
if ($settings['adminfeewhen'] == 'afterinterest' && $settings['adminfee']) $output .= '<span style="background-color:'.$style['graphprocessing'].'"></span> '.$settings['graphprocessing'].' '; |
| 895 |
$output .= '</p>'; |
| 896 |
} |
| 897 |
} |
| 898 |
|
| 899 |
if ($item == 'repayments' && !$atts['float']) { |
| 900 |
|
| 901 |
// Display output messages |
| 902 |
if ($settings['outputrepayments']) { |
| 903 |
$output .= '<div class="qis-repayments">'.$settings['repaymentlabel']; |
| 904 |
if ($settings['outputhelp']) $output .= qis_tooltip($settings['outputinfo']); |
| 905 |
$output .= '</div>'; |
| 906 |
} |
| 907 |
} |
| 908 |
|
| 909 |
if ($item == 'total' && !$atts['float']) { |
| 910 |
|
| 911 |
if ($settings['outputtotal']) { |
| 912 |
$output .= '<div class="qis-total">'.$settings['outputtotallabel'].'</div>'; |
| 913 |
} |
| 914 |
} |
| 915 |
|
| 916 |
if ($item == 'apply' && !$atts['float']) { |
| 917 |
|
| 918 |
// Apply Now and Application Form |
| 919 |
if ($register['application'] && $qppkey['authorised']) $output .= qis_display_form($formvalues,$formerrors,$registered).'</div>'; |
| 920 |
elseif ($settings['applynow'] && $qppkey['authorised']) $output .= '<div class="qis-apply"><a id="applybutton" href="'.$settings['applynowaction'].'" >'.$settings['applynowlabel'].'</a></div>'; |
| 921 |
} |
| 922 |
|
| 923 |
$output .= $settings['outputtable']; |
| 924 |
} |
| 925 |
|
| 926 |
// $output .= '</div>'; |
| 927 |
|
| 928 |
if ($atts['float']) { |
| 929 |
|
| 930 |
$output .= '</div><div class="qis-outputs qis-float-columns">'; |
| 931 |
|
| 932 |
// Display output messages |
| 933 |
|
| 934 |
if ($settings['outputrepayments']) { |
| 935 |
$output .= '<div class="qis-repayments">'.$settings['repaymentlabel']; |
| 936 |
if ($settings['outputhelp']) $output .= qis_tooltip($settings['outputinfo']); |
| 937 |
$output .= '</div>'; |
| 938 |
} |
| 939 |
|
| 940 |
if ($settings['outputtotal']) { |
| 941 |
$output .= '<div class="qis-total">'.$settings['outputtotallabel'].'</div>'; |
| 942 |
} |
| 943 |
|
| 944 |
$output .= $settings['outputtable']; |
| 945 |
|
| 946 |
// Apply Now and Application Form |
| 947 |
|
| 948 |
if ($register['application'] && $qppkey['authorised']) $output .= qis_display_form($formvalues,$formerrors,$registered).'</div>'; |
| 949 |
elseif ($settings['applynow'] && $qppkey['authorised']) $output .= '<div class="qis-apply"><a id="applybutton" href="'.$settings['applynowaction'].'" >'.$settings['applynowlabel'].'</a></div>'; |
| 950 |
|
| 951 |
// Close .qis-float |
| 952 |
$output .= '</div>'; |
| 953 |
} |
| 954 |
|
| 955 |
$output .= '</div>'; |
| 956 |
|
| 957 |
$output .= '<input type="hidden" name="repayment" value="'.@$formvalues['repayment'].'" />'; |
| 958 |
$output .= '<input type="hidden" name="totalamount" value="'.@$formvalues['totalamount'].'" />'; |
| 959 |
$output .= '<input type="hidden" id="formname" name="formname" value="'.$formvalues['formname'].'" />'; |
| 960 |
$output .= '<input type="hidden" id="calculatorname" name="calculatorname" value="'.$atts['calculatorname'].'" />'; |
| 961 |
$output .= '<input type="hidden" name="rate" value="" />'; |
| 962 |
$output .= '<div id="filechecking"><div class="filecheckingcontent"><img src="'.plugin_dir_url( __FILE__ ).'/img/waiting.gif'.'" alt="Loading"></div></div>'; // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage |
| 963 |
|
| 964 |
$output .= '</div></form>'; |
| 965 |
return $output; |
| 966 |
} |
| 967 |
|
| 968 |
function qis_markers($settings,$handle,$min,$max,$step) { |
| 969 |
|
| 970 |
//Put together a step total and output a set of step markers |
| 971 |
$inner_value = (float) $min - $max; |
| 972 |
$pps = $inner_value / $step; |
| 973 |
$ppw = 100 / $pps; |
| 974 |
|
| 975 |
if ($settings['buttons'] && $settings['sliderbuttonposition'] == 'sliderside') { |
| 976 |
$output = '<div class="qis_buttons"> |
| 977 |
<div></div> |
| 978 |
<div class="qis_slider_markers" style="position: relative; margin-left: '.($handle/2).'px; margin-right: '.($handle/2).'px; border-left: 1px solid black; border-right: 1px solid black; height: 10px">'; |
| 979 |
for ($i = 1; $i < $pps; $i++) { |
| 980 |
$output .= '<div class="qis_slider_marker" style="position: absolute; height: 10px; left: '.$ppw * $i.'%; margin-left: -1px; width: 1px; background-color: black;"></div>'; |
| 981 |
} |
| 982 |
|
| 983 |
$output .= '</div> |
| 984 |
<div></div> |
| 985 |
</div>'; |
| 986 |
} else { |
| 987 |
$output .= '<div class="qis_slider_markers" style="position: relative; margin-left: '.($handle/2).'px; margin-right: '.($handle/2).'px; border-left: 1px solid black; border-right: 1px solid black; height: 10px">'; |
| 988 |
for ($i = 1; $i < $pps; $i++) { |
| 989 |
$output .= '<div class="qis_slider_marker" style="position: absolute; height: 10px; left: '.$ppw * $i.'%; margin-left: -1px; width: 1px; background-color: black;"></div>'; |
| 990 |
} |
| 991 |
$output .= '</div>'; |
| 992 |
} |
| 993 |
|
| 994 |
return $output; |
| 995 |
|
| 996 |
} |
| 997 |
|
| 998 |
// Display Values |
| 999 |
function qis_outputs($buttons,$min,$max,$oX,$label) { |
| 1000 |
|
| 1001 |
if ($buttons) { |
| 1002 |
$output = '<div class="qis_slideroutputs"> |
| 1003 |
<div class="column left circle-control minus"><svg xmlns="http://www.w3.org/2000/svg" height="25px" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM184 232c-13.3 0-24 10.7-24 24s10.7 24 24 24H328c13.3 0 24-10.7 24-24s-10.7-24-24-24H184z"/></svg></div> |
| 1004 |
<span class="column center qis-slidercenter">'.$label.$oX.'</span> |
| 1005 |
<div class="column right circle-control plus"><svg xmlns="http://www.w3.org/2000/svg" height="25px" viewBox="0 0 512 512"><path d="M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM232 344c0 13.3 10.7 24 24 24s24-10.7 24-24V280h64c13.3 0 24-10.7 24-24s-10.7-24-24-24H280V168c0-13.3-10.7-24-24-24s-24 10.7-24 24v64H168c-13.3 0-24 10.7-24 24s10.7 24 24 24h64v64z"/></svg></div></div>'; |
| 1006 |
} else { |
| 1007 |
$output = '<div class="qis_slideroutputs">'; |
| 1008 |
$output .= '<span class="column left qis-sliderleft">'.$min.'</span>'; |
| 1009 |
$output .= '<span class="column center qis-slidercenter">'.$label.$oX.'</span>'; |
| 1010 |
$output .= '<span class="column right qis-sliderright">'.$max.'</span>'; |
| 1011 |
$output .= '</div>'; |
| 1012 |
} |
| 1013 |
return $output; |
| 1014 |
} |
| 1015 |
|
| 1016 |
function qis_unset($array,$value) { |
| 1017 |
|
| 1018 |
$newarray = []; |
| 1019 |
foreach ($array as $k => $v) { |
| 1020 |
if ($v == $value) unset($array[$v]); |
| 1021 |
else $newarray[] = $v; |
| 1022 |
} |
| 1023 |
return $newarray; |
| 1024 |
} |
| 1025 |
|
| 1026 |
// Display Tooltip |
| 1027 |
|
| 1028 |
function qis_tooltip($text) { |
| 1029 |
return '<span class="qis_tooltip_toggle"><a href="javascript:void(0);"></a><div class="qis_tooltip_body"><div class="qis_tooltip_content">'.$text.'</div><div class="close"></div></div></span>'; |
| 1030 |
} |
| 1031 |
|
| 1032 |
// Enqueue Scripts and Styles |
| 1033 |
|
| 1034 |
function qis_scripts() { |
| 1035 |
$style = qis_get_stored_style(); |
| 1036 |
if (!$style['nostyles']) wp_enqueue_style( 'qis_style',plugins_url('slider.css', __FILE__),"QIS_VERSION",true); |
| 1037 |
wp_enqueue_script('jquery-ui-datepicker'); |
| 1038 |
wp_enqueue_script("jquery-effects-core"); |
| 1039 |
wp_enqueue_script('qis_script',plugins_url('slider.js?v=1.16', __FILE__ ), array( 'jquery' ), "QIS_VERSION", true ); |
| 1040 |
//wp_enqueue_style ('jquery-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css'); |
| 1041 |
wp_enqueue_style ('jquery-style', 'jquery-ui.css',false,"1.11.2",true); |
| 1042 |
wp_localize_script('qis_script', 'qis_application', [ |
| 1043 |
'ajax_url' => admin_url( 'admin-ajax.php' ) |
| 1044 |
]); |
| 1045 |
} |
| 1046 |
|
| 1047 |
// Dashboard Link |
| 1048 |
|
| 1049 |
function qis_plugin_action_links($links, $file ) { |
| 1050 |
if ( $file == plugin_basename( __FILE__ ) ) { |
| 1051 |
$qis_links = '<a href="'.get_admin_url().'options-general.php?page=quick-interest-slider-settings">'.__('Settings','quick-interest-slider').'</a>'; |
| 1052 |
array_unshift( $links, $qis_links ); |
| 1053 |
} |
| 1054 |
return $links; |
| 1055 |
} |
| 1056 |
|
| 1057 |
// Build Custom CSS |
| 1058 |
|
| 1059 |
function qis_generate_css() { |
| 1060 |
$style = qis_get_stored_style(); |
| 1061 |
|
| 1062 |
if ($style['nostyles'] || $style['nocustomstyles']) return; |
| 1063 |
|
| 1064 |
$border = $radius = $background = false; |
| 1065 |
|
| 1066 |
//Slider output on small screens |
| 1067 |
$smaller = preg_split('#(?<=\d)(?=[a-z%])#i', $style['output-size']); |
| 1068 |
//$smaller = (floatval($smaller[0])*0.6).$smaller[1]; |
| 1069 |
$smaller = (floatval($smaller[0])*0.6).$smaller[0]; |
| 1070 |
// Handle |
| 1071 |
$svgsize = $handlesize = preg_split('#(?<=\d)(?=[a-z%])#i', $style['handle-size']); |
| 1072 |
$handlesize[0] = $handlesize[0] - $style['handle-thickness']*2; |
| 1073 |
if (!isset($handlesize[1])) $handlesize[1] = 'px'; |
| 1074 |
|
| 1075 |
// Slider bar |
| 1076 |
$sliderthickness = preg_split('#(?<=\d)(?=[a-z%])#i', $style['slider-thickness']); |
| 1077 |
if (!isset($sliderthickness[1])) $sliderthickness[1] = 'px'; |
| 1078 |
$slideradius = ($sliderthickness[0] / 2).$sliderthickness[1]; |
| 1079 |
$slidermargin = (1 + ($handlesize[0] - $sliderthickness[0])/2).'px'; |
| 1080 |
|
| 1081 |
// Handle position |
| 1082 |
$handletop = $handlesize[0]/2 - $sliderthickness[0]/2 + $style['handle-thickness']; |
| 1083 |
|
| 1084 |
// Form Border |
| 1085 |
if ($style['border']<>'none') { |
| 1086 |
$border = ".qis_form.".$style['border']." {border:".$style['form-border-thickness']."px solid ".$style['form-border-color']."; padding: ".$style['form-padding']."px;border-radius:".$style['form-border-radius']."px;}"; |
| 1087 |
} |
| 1088 |
if ($style['background'] == 'white') { |
| 1089 |
$background = "form.qis_form {background:#FFF;}"; |
| 1090 |
} |
| 1091 |
if ($style['background'] == 'color') { |
| 1092 |
$background = "form.qis_form {background:".$style['backgroundhex'].";}"; |
| 1093 |
} |
| 1094 |
if ($style['backgroundimage']) { |
| 1095 |
$background = "form.qis_form {background: url('".$style['backgroundimage']."');}"; |
| 1096 |
} |
| 1097 |
|
| 1098 |
// form width |
| 1099 |
$formwidth = preg_split('#(?<=\d)(?=[a-z%])#i', $style['width']); |
| 1100 |
if (!isset($formwidth[1])) $formwidth[1] = 'px'; |
| 1101 |
if ($style['widthtype'] == 'pixel') $width = $formwidth[0].$formwidth[1]; |
| 1102 |
else $width = '100%'; |
| 1103 |
|
| 1104 |
$data = $border.$radius.$background.' |
| 1105 |
.qis_form {width:'.$width.';max-width:100%;} |
| 1106 |
.qis, .qis__fill {width: 100%;height: '.$sliderthickness[0].$sliderthickness[1].';background: '.$style['slider-background'].';border-radius: '.$slideradius.';} |
| 1107 |
.qis__fill {background: '.$style['slider-revealed'].';border-radius: '.$slideradius.' 0 0 '.$slideradius.';} |
| 1108 |
.qis__handle {width: '.$handlesize[0].$handlesize[1].';height: '.$handlesize[0].$handlesize[1].';top: -'.$handletop.'px;background: '.$style['handle-background'].';border: '.$style['handle-thickness'].'px solid '.$style['handle-border'].';position: absolute;border-radius:'.$style['handle-corners'].'%;} |
| 1109 |
.total {font-weight:bold;border-top:1px solid #FFF;margin-top:6px;text-align:left;} |
| 1110 |
.qis--horizontal {margin: '.$slidermargin.' 0;} |
| 1111 |
.qis-slidercenter {color:'.$style['slideroutputcolour'].';font-size:'.$style['output-size'].'px;} |
| 1112 |
.qis-sliderleft, .qis-sliderright {color:'.$style['toplinecolour'].';font-size:'.$style['toplinefont'].'px;} |
| 1113 |
.slider-label {color:'.$style['slider-label-colour'].';font-size:'.$style['slider-label-size'].'px;margin:'.$style['slider-label-margin'].';} |
| 1114 |
.qis-interest, .qis-repayments {color:'.$style['interestcolour'].';font-size:'.$style['interestfont'].'px;margin:'.$style['interestmargin'].';} |
| 1115 |
.qis-total {color:'.$style['totalcolour'].';font-size:'.$style['totalfont'].'px;margin:'.$style['totalmargin'].';} |
| 1116 |
.qis_tooltip_body {border: '.$style['tooltipborderthickness'].'px solid '.$style['tooltipbordercolour'].'; background-color: '.$style['tooltipbackground'].'; border-radius: '.$style['tooltipcorner'].'px; color: '.$style['tooltipcolour'].';} |
| 1117 |
.qis_tooltip_content {overflow: hidden; width: 100%; height: 100%;} |
| 1118 |
.checkradio input[type=radio]:not(old) + label > span{border:3px solid '.$style['handle-border'].'} |
| 1119 |
.checkradio input[type=radio]:not(old):checked + label > span{background: '.$style['slider-revealed'].';border: 3px solid '.$style['handle-border'].';} |
| 1120 |
.circle-control svg {fill: '.$style['buttoncolour'].';height:'.$svgsize[0].'px'.';vertical-align:text-bottom;} |
| 1121 |
.circle-control svg:hover {fill: '.$style['buttonhover'].';} |
| 1122 |
.qis-outputs {'.$style['floatcustom'].'} |
| 1123 |
.qis_buttons, .qis_slideroutputs {line-height:'.$style['output-size'].'px;margin-bottom:'.$style['slideroutputmargin'].'px;} |
| 1124 |
'; |
| 1125 |
|
| 1126 |
$table = qis_get_stored_ouputtable(); |
| 1127 |
$right = $table['values-padding'] * 2; |
| 1128 |
$strongon = $table['values-strong'] ? '<strong>' : ''; |
| 1129 |
$strongoff = $table['values-strong'] ? '</strong>' : ''; |
| 1130 |
$data .= $table['values-colour'] ? '.outputtable td{padding: 0 '.$right.'px '.$table['values-padding'].'px 0;}.values-colour{color:'.$table['values-colour'].'}' : ''; |
| 1131 |
$right = $style['floatpercentage'] ? 98 - $style['floatpercentage'] : 98; |
| 1132 |
|
| 1133 |
$data .= '.qis-add-float {display:grid;grid-template-columns:'.$style['floatpercentage'].'% '.$right.'%;grid-gap:2%;} |
| 1134 |
@media only screen and (max-width:'.$style['floatbreakpoint'].'px) {.qis-add-float{display:block;} |
| 1135 |
.qis-slidercenter {font-size:'.$smaller.'px;}.qis_buttons, .qis_slideroutputs {margin-bottom:'.($style['slideroutputmargin']/2).'px;} |
| 1136 |
}'; |
| 1137 |
|
| 1138 |
return $data; |
| 1139 |
} |
| 1140 |
|
| 1141 |
// Builds Application Form CSS |
| 1142 |
|
| 1143 |
function qis_register_css () { |
| 1144 |
$allowed_html = callback_allowed_html(); |
| 1145 |
$code=$header=$input=$submitwidth=$paragraph=$submitbutton=$submit=''; |
| 1146 |
$style = qis_get_register_style(); |
| 1147 |
$corners = '-webkit-border-radius:'.$style['corners'].'px;border-radius:'.$style['corners'].'px;'; |
| 1148 |
$input = '.qis-register input[type=text], .qis-register input[type=tel], .qis-register textarea, .qis-register select, .qis_checkbox label, #calculators {color:'.$style['font-colour'].';border:'.$style['input-border'].';background-color:'.$style['inputbackground'].';}.registerradio input[type=radio]:not(old) + label > span{border:'.$style['input-border'].';}'; |
| 1149 |
$required = '.qis-register input[type=text].required, .qis-register input[type=tel].required, .qis-register textarea.required, .qis-register select.required {border:'.$style['input-required'].'}'; |
| 1150 |
$focus = ".qis-register input:focus, .qis-register textarea:focus {background:".$style['inputfocus'].";}"; |
| 1151 |
$text = ".qis-register p {color:".$style['font-colour'].";margin: 6px 0 !important;padding: 0 !important;}"; |
| 1152 |
$error = ".qis-register .error {color:".$style['error-font-colour']." !important;border-color:".$style['error-font-colour']." !important;}"; |
| 1153 |
$button = ".toggle-qis a {color: ".$style['header-colour'].";height:auto;font-size:1em;margin:0;text-decoration:none;}"; |
| 1154 |
$submit = "color:".$style['submit-colour'].";background:".$style['submit-background'].";border:".$style['submit-border'].";font-size: inherit;".$corners; |
| 1155 |
$submithover = "background:".$style['submit-hover-background'].";"; |
| 1156 |
$submitbutton = ".qis-register .submit, .toggle-qis a {".$submit."}.qis-register .submit:hover {".$submithover."}"; |
| 1157 |
$applybutton = ".qis-apply a {color:".$style['submit-colour'].";background:".$style['submit-background'].";border:".$style['submit-border'].";font-size: inherit;".$corners.";}"; |
| 1158 |
$applybutton .= ".qis-apply a:hover {background:".$style['submit-hover-background'].";}"; |
| 1159 |
|
| 1160 |
$code = ".qis-register {max-width:100%;overflow:hidden;}".$submitbutton.$header.$paragraph.$input.$focus.$required.$text.$error.$applybutton; |
| 1161 |
|
| 1162 |
$data = '<style type="text/css" media="screen">'.$code.'</style>'; |
| 1163 |
echo wp_kses($data,$allowed_html); |
| 1164 |
} |
| 1165 |
|
| 1166 |
// Add to Head |
| 1167 |
function qis_head_css ($atts) { |
| 1168 |
$allowed_html = callback_allowed_html(); |
| 1169 |
$atts = shortcode_atts(array('calculator' => ''),$atts,'quick-interest-slider'); |
| 1170 |
$data = '<style type="text/css" media="screen">'.qis_generate_css($atts['calculator']).'</style><script type="text/javascript">qis__rates = [];</script>'; |
| 1171 |
echo wp_kses($data,$allowed_html); |
| 1172 |
qis_register_css(); |
| 1173 |
} |
| 1174 |
|
| 1175 |
// GDPR Subscribe/Unsubsribe |
| 1176 |
|
| 1177 |
function qis_subscribe() { |
| 1178 |
$message = get_option('qis_messages'); |
| 1179 |
|
| 1180 |
$auto = qis_get_stored_autoresponder(null); |
| 1181 |
if ( isset ($_GET['sub']) ) { // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 1182 |
$ref = $_GET['sub']; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 1183 |
foreach ($message as $key => $value ) { |
| 1184 |
if ($ref == $value['timestamp'] && $value['confirmed'] != true) { |
| 1185 |
if ($auto['notification']) qis_send_notification ($value); |
| 1186 |
$message[$key]['confirmed'] = true; |
| 1187 |
update_option('qis_messages',$message); |
| 1188 |
return '<div class="emailresponse">'.$auto['subscribemessage'].'</div>'; |
| 1189 |
} |
| 1190 |
} |
| 1191 |
return '<div class="emailresponse">'.$auto['subscribealready'].'</div>'; |
| 1192 |
} |
| 1193 |
if ( isset ($_GET['unsub']) ) { // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 1194 |
$ref = $_GET['unsub']; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 1195 |
foreach ($message as $key => $value ) { |
| 1196 |
if ($ref == $value['timestamp']) { |
| 1197 |
unset($value); |
| 1198 |
$message = array_values($message); |
| 1199 |
update_option('qis_messages',$message); |
| 1200 |
return '<div class="emailresponse">'.$auto['unsubscribemessage'].'</div>'; |
| 1201 |
} |
| 1202 |
} |
| 1203 |
return '<div class="emailresponse">You have already unsubscribed</div>'; |
| 1204 |
} |
| 1205 |
} |
| 1206 |
|
| 1207 |
// Report of all Applications |
| 1208 |
|
| 1209 |
function qis_show_progress() { |
| 1210 |
|
| 1211 |
$content = false; |
| 1212 |
|
| 1213 |
$progress = qis_get_stored_progress(); |
| 1214 |
|
| 1215 |
if (!empty($_POST['showprogress']) && check_admin_referer("save_qis")) { |
| 1216 |
$formvalues = $_POST; |
| 1217 |
$formvalues['youremail'] = filter_var($formvalues['youremail'],FILTER_SANITIZE_EMAIL); |
| 1218 |
$formvalues['reference'] = htmlentities($formvalues['reference']); |
| 1219 |
|
| 1220 |
$message = get_option('qis_messages'); |
| 1221 |
|
| 1222 |
foreach ($message as $key) { |
| 1223 |
if ($formvalues['youremail'] == $key['youremail'] && $formvalues['reference'] == $key['reference']) { |
| 1224 |
$register = qis_get_stored_register(1); |
| 1225 |
$content = '<div class="qis-register">'; |
| 1226 |
if ($progress['showdetails']) { |
| 1227 |
$content .= '<h2>'.$progress['loanlabel'].'</h2>'; |
| 1228 |
$content .= qis_build_message($key,$register); |
| 1229 |
} |
| 1230 |
$content .= '<h2>'.$progress['progresslabel'].'</h2>'; |
| 1231 |
$content .= '<p>'; |
| 1232 |
$steps = explode(",",$progress['progresssteps']); |
| 1233 |
$stop = false; |
| 1234 |
if ($progress['rejected'] && end($steps) == $key['progress']) { |
| 1235 |
$stop = $progress['currentstep'] = true; |
| 1236 |
$progress['highlight'] = $progress['rejectedcolour']; |
| 1237 |
} |
| 1238 |
foreach ($steps as $item) { |
| 1239 |
if ($progress['currentstep']) { |
| 1240 |
$background = $item == $key['progress'] ? ' style="background-color:'.$progress['highlight'].';"' : ' style="background-color:'.$progress['background'].';"'; |
| 1241 |
} else { |
| 1242 |
$background = $stop ? ' style="background-color:'.$progress['background'].';"' : ' style="background-color:'.$progress['highlight'].';"'; |
| 1243 |
if ($item == $key['progress']) $stop = true; |
| 1244 |
} |
| 1245 |
$content .= '<span class="step"'.$background.'>'.$item.'</span>'; |
| 1246 |
} |
| 1247 |
$content .= '</p>'; |
| 1248 |
$content .= '</div>'; |
| 1249 |
} |
| 1250 |
} |
| 1251 |
if ($content) return $content; |
| 1252 |
else return '<h2>'.$progress['nothingfound'].'</h2>'; |
| 1253 |
} |
| 1254 |
|
| 1255 |
$content .= '<form action="" method="POST" class="qis-register"> |
| 1256 |
<p>'.$progress['emaillabel'].'<br> |
| 1257 |
<input type="email" name="youremail" value=""></p> |
| 1258 |
<p>'.$progress['referencelabel'].'<br> |
| 1259 |
<input type="text" name="reference" value=""></p> |
| 1260 |
<p><input onClick="check();" type="submit" value="'.$progress['submitlabel'].'" class="submit" name="showprogress" /><p> |
| 1261 |
<input type="hidden" name="anything" value="'. gmdate('Y-m-d H:i:s').'"> |
| 1262 |
<div class="validator">Enter the word YES in the box: <input type="text" style="width:3em" name="validator" value=""></div>'; |
| 1263 |
$content .= wp_nonce_field("save_qis"); |
| 1264 |
$content .= '</form>'; |
| 1265 |
|
| 1266 |
return $content; |
| 1267 |
} |
| 1268 |
|
| 1269 |
// Report of all Applications |
| 1270 |
|
| 1271 |
function qis_registration_report() { |
| 1272 |
$allowed_html = callback_allowed_html(); |
| 1273 |
$message = get_option('qis_messages'); |
| 1274 |
ob_start(); |
| 1275 |
$content ='<div id="qis-widget"> |
| 1276 |
<h2>'.__('Loan Applications','quick-interest-slider').'</h2>'; |
| 1277 |
$content .= qis_build_registration_table ($message,'report',null,null); |
| 1278 |
$content .='</div>'; |
| 1279 |
echo wp_kses($content,$allowed_html); |
| 1280 |
$output_string=ob_get_contents(); |
| 1281 |
ob_end_clean(); |
| 1282 |
return $output_string; |
| 1283 |
} |
| 1284 |
|
| 1285 |
// Build the table of registrations |
| 1286 |
|
| 1287 |
function qis_build_registration_table ($message,$report,$qis_edit,$selected) { |
| 1288 |
$register = qis_get_stored_register(1); |
| 1289 |
$progress = qis_get_stored_progress(); |
| 1290 |
$span=$charles=$content=''; |
| 1291 |
$delete=array();$i=0; |
| 1292 |
|
| 1293 |
$arr = array('name','email','telephone','message','company','address','number','checks','dropdown','dropdown2','radio','consent'); |
| 1294 |
|
| 1295 |
foreach ($arr as $item) { |
| 1296 |
foreach($message as $row) { |
| 1297 |
if (isset($row['your'.$item]) && $row['your'.$item]) { |
| 1298 |
$register['use'.$item] = true; |
| 1299 |
} |
| 1300 |
} |
| 1301 |
} |
| 1302 |
|
| 1303 |
$register['yourdropdown'] = $register['dropdownlabel']; |
| 1304 |
$register['yourdropdown2'] = $register['dropdown2label']; |
| 1305 |
|
| 1306 |
$dashboard = '<table cellspacing="0"> |
| 1307 |
<tr> |
| 1308 |
<th>'.__('Reference', 'quick-interest-slider').'</th>'; |
| 1309 |
foreach ($arr as $item) { |
| 1310 |
if ($register['use'.$item]) $dashboard .= '<th>'.$register['your'.$item].'</th>'; |
| 1311 |
} |
| 1312 |
$dashboard .= '<th>'.__('Amount', 'quick-interest-slider').'</th><th>Period</th>'; |
| 1313 |
if ($register['useattachment']) $dashboard .= '<th>Attachments</th>'; |
| 1314 |
$dashboard .= '<th>'.__('Date Sent', 'quick-interest-slider').'</th>'; |
| 1315 |
if ($progress['enabled']) $dashboard .= '<th>Progress</th>'; |
| 1316 |
if (!$report) $dashboard .= '<th></th>'; |
| 1317 |
|
| 1318 |
$dashboard .= '</tr>'; |
| 1319 |
|
| 1320 |
foreach($message as $value) { |
| 1321 |
$span = ($value['reference'] && !$value['confirmed']) ? ' style="font-style:italic;color:#ccc;"' : ''; |
| 1322 |
$content .= '<tr'.$span.'> |
| 1323 |
<td>'.$value['reference'].'</td>'; |
| 1324 |
foreach ($arr as $item) { |
| 1325 |
if ($register['use'.$item]) { |
| 1326 |
if (isset($value['yourconsent']) && $value['yourconsent']) $value['yourconsent'] = 'checked'; |
| 1327 |
$content .= '<td>'; |
| 1328 |
if ( ($qis_edit == 'selected' && $selected[$i]) || $qis_edit == 'all') $content .= '<input style="width:100%" type="text" value="'.$message[$i]['your'.$item].'" name="message['.$i.'][your'.$item.']">'; |
| 1329 |
elseif (isset($value['your'.$item])) $content .= $value['your'.$item]; |
| 1330 |
else $content .= ''; |
| 1331 |
$content .= '</td>'; |
| 1332 |
} |
| 1333 |
} |
| 1334 |
if ( ($qis_edit == 'selected' && $selected[$i]) || $qis_edit == 'all') { |
| 1335 |
$content .= '<td><input style="width:100%" type="text" value="'.$message[$i]['loan-amount'].'" name="message['.$i.'][loan-amount]"></td> |
| 1336 |
<td><input style="width:100%" type="text" value="'.$message[$i]['loan-period'].'" name="message['.$i.'][loan-period]"></td>'; |
| 1337 |
} else { |
| 1338 |
$content .= '<td>'.$value['loan-amount'].'</td><td>'.$value['loan-period'].'</td>'; |
| 1339 |
} |
| 1340 |
if ($value['yourname']) $charles = 'messages'; |
| 1341 |
|
| 1342 |
/* |
| 1343 |
if ($register['useattachment']) { |
| 1344 |
$content .= $value['attachment'] ? '<td><a href="'.$value['attachment'].'" target="_blank">View</a></td>' : '<td></td>'; |
| 1345 |
} |
| 1346 |
*/ |
| 1347 |
|
| 1348 |
if ($register['useattachment']) $content .= qis_message_thumbs($value); |
| 1349 |
$content .= '<td>'.$value['sentdate'].'</td>'; |
| 1350 |
|
| 1351 |
if ($progress['enabled']) { |
| 1352 |
if ( ($qis_edit == 'selected' && $selected[$i]) || $qis_edit == 'all') { |
| 1353 |
$content .= '<td>'; |
| 1354 |
$steps = explode(",",$progress['progresssteps']); |
| 1355 |
$content .= '<select name="message['.$i.'][progress]">'; |
| 1356 |
if ($message[$i]['progress']) $content .= '<option value="'.$message[$i]['progress'].'">'.$message[$i]['progress'].'</option>'; |
| 1357 |
foreach ($steps as $item) { |
| 1358 |
$content .= '<option value="' . $item . '">' . $item . '</option>'."\r\t"; |
| 1359 |
} |
| 1360 |
$content .= '</select></div>'; |
| 1361 |
$content .= '</td>'; |
| 1362 |
} else { |
| 1363 |
$content .= '<td>'.$message[$i]['progress'].'</td>'; |
| 1364 |
} |
| 1365 |
} |
| 1366 |
|
| 1367 |
if (!$report) $content .= '<td><input type="checkbox" name="'.$i.'" value="checked" /></td>'; |
| 1368 |
$content .= '</tr>'; |
| 1369 |
$i++; |
| 1370 |
} |
| 1371 |
|
| 1372 |
$dashboard .= $content.'</table>'; |
| 1373 |
if ($charles) return $dashboard; |
| 1374 |
} |
| 1375 |
|
| 1376 |
// Languages |
| 1377 |
|
| 1378 |
function qis_lang_init() { |
| 1379 |
load_plugin_textdomain( 'quick-interest-slider', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 1380 |
} |
| 1381 |
|
| 1382 |
// Upgrade IPN function |
| 1383 |
|
| 1384 |
function qis_upgrade_ipn() { |
| 1385 |
$qppkey = qis_key(); |
| 1386 |
if (!isset($_POST['custom']) || $qppkey['authorised']) // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 1387 |
return; |
| 1388 |
$raw_post_data = file_get_contents('php://input'); |
| 1389 |
$raw_post_array = explode('&', $raw_post_data); |
| 1390 |
$myPost = array(); |
| 1391 |
foreach ($raw_post_array as $keyval) { |
| 1392 |
$keyval = explode ('=', $keyval); |
| 1393 |
if (count($keyval) == 2) |
| 1394 |
$myPost[$keyval[0]] = urldecode($keyval[1]); |
| 1395 |
} |
| 1396 |
$req = 'cmd=_notify-validate'; |
| 1397 |
if(function_exists('get_magic_quotes_gpc')) { |
| 1398 |
$get_magic_quotes_exists = true; |
| 1399 |
} |
| 1400 |
foreach ($myPost as $key => $value) { |
| 1401 |
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { |
| 1402 |
$value = urlencode(stripslashes($value)); |
| 1403 |
} else { |
| 1404 |
$value = urlencode($value); |
| 1405 |
} |
| 1406 |
$req .= "&$key=$value"; |
| 1407 |
} |
| 1408 |
/* |
| 1409 |
$ch = curl_init("https://www.paypal.com/cgi-bin/webscr"); |
| 1410 |
if ($ch == FALSE) { |
| 1411 |
return FALSE; |
| 1412 |
} |
| 1413 |
|
| 1414 |
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
| 1415 |
curl_setopt($ch, CURLOPT_POST, 1); |
| 1416 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); |
| 1417 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $req); |
| 1418 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); |
| 1419 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); |
| 1420 |
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); |
| 1421 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
| 1422 |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); |
| 1423 |
|
| 1424 |
$res = curl_exec($ch); |
| 1425 |
*/ |
| 1426 |
$response = wp_remote_post( "https://www.paypal.com/cgi-bin/webscr", array( |
| 1427 |
'body' => $req, |
| 1428 |
'headers' => array( |
| 1429 |
'Connection' => 'Close', |
| 1430 |
), |
| 1431 |
) ); |
| 1432 |
|
| 1433 |
$tokens = explode("\r\n\r\n", trim($response["body"])); |
| 1434 |
$res = trim(end($tokens)); |
| 1435 |
$tokens = explode("\r\n\r\n", trim($res)); |
| 1436 |
$res = trim(end($tokens)); |
| 1437 |
|
| 1438 |
if (strcmp ($res, "VERIFIED") == 0 && $qppkey['key'] == $_POST['custom']) { // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 1439 |
$qppkey['authorised'] = 'true'; |
| 1440 |
update_option('qpp_key',$qppkey); |
| 1441 |
$qpp_setup = qp_get_stored_setup(); |
| 1442 |
$email = bloginfo('admin_email'); |
| 1443 |
$headers = "From: Quick Plugins <mail@quick-plugins.com>\r\n" |
| 1444 |
. "Content-Type: text/html; charset=\"utf-8\"\r\n"; |
| 1445 |
$message = '<html><p>'.__('Thank you for upgrading. Your authorisation key is','quick-interest-slider').':</p><p>'.$qppkey['key'].'</p></html>'; |
| 1446 |
wp_mail($email,__('Quick Plugins Authorisation Key','quick-interest-slider'),$message,$headers); |
| 1447 |
} |
| 1448 |
exit(); |
| 1449 |
} |
| 1450 |
|
| 1451 |
// Get URL of the current page |
| 1452 |
|
| 1453 |
function qis_current_page_url() { |
| 1454 |
$pageURL = 'http'; |
| 1455 |
if (!isset($_SERVER['HTTPS'])) $_SERVER['HTTPS'] = ''; |
| 1456 |
if (!empty($_SERVER["HTTPS"])) { |
| 1457 |
$pageURL .= "s"; |
| 1458 |
} |
| 1459 |
$pageURL .= "://"; |
| 1460 |
if (($_SERVER["SERVER_PORT"] != "80") && ($_SERVER['SERVER_PORT'] != '443')) // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 1461 |
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 1462 |
else |
| 1463 |
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput |
| 1464 |
return $pageURL; |
| 1465 |
} |
| 1466 |
|
| 1467 |
// Changes thousands seperator |
| 1468 |
|
| 1469 |
function qis_separator($s,$separator) { |
| 1470 |
if ($separator == 'none') return $s; |
| 1471 |
else if ($separator == 'apostrophe') $se = "'"; |
| 1472 |
else if ($separator == 'dot') $se = "."; |
| 1473 |
else if ($separator == 'comma') $se = ","; |
| 1474 |
else $se = ' '; |
| 1475 |
return trim(preg_replace("/(\d)(?=(\d{3})+$)/",'$1'.$se,$s)); |
| 1476 |
} |
| 1477 |
|