Changeset 2946744
- Timestamp:
- 08/02/2023 05:04:30 PM (3 years ago)
- Location:
- pvb-contact-form-7-calculator/trunk
- Files:
-
- 27 edited
-
autoload.php (modified) (1 diff)
-
js/pvb-cf7-calculator-admin.js (modified) (2 diffs)
-
js/pvb-cf7-calculator.js (modified) (5 diffs)
-
lib/Math/Exception/class-divisionbyzeroexception.php (modified) (3 diffs)
-
lib/Math/Exception/class-integeroverflowexception.php (modified) (2 diffs)
-
lib/Math/Exception/class-mathexception.php (modified) (1 diff)
-
lib/Math/Exception/class-numberformatexception.php (modified) (1 diff)
-
lib/Math/Exception/class-roundingnecessaryexception.php (modified) (2 diffs)
-
lib/Math/Internal/Calculator/class-bcmathcalculator.php (modified) (8 diffs)
-
lib/Math/Internal/Calculator/class-gmpcalculator.php (modified) (8 diffs)
-
lib/Math/Internal/Calculator/class-nativecalculator.php (modified) (15 diffs)
-
lib/Math/Internal/class-calculator.php (modified) (2 diffs)
-
lib/Math/class-bigdecimal.php (modified) (18 diffs)
-
lib/Math/class-biginteger.php (modified) (9 diffs)
-
lib/Math/class-bignumber.php (modified) (10 diffs)
-
lib/Math/class-bigrational.php (modified) (8 diffs)
-
lib/Math/class-pvbcalculator.php (modified) (23 diffs)
-
lib/Math/class-roundingmode.php (modified) (1 diff)
-
lib/Math/class-tokenizer.php (modified) (1 diff)
-
lib/Math/class-tokenizerinterface.php (modified) (2 diffs)
-
lib/Math/class-tokens.php (modified) (2 diffs)
-
lib/class-pvbcf7calculator.php (modified) (47 diffs)
-
lib/wpSettingsFramework/assets/js/main.js (modified) (5 diffs)
-
lib/wpSettingsFramework/class-wordpresssettingsframework.php (modified) (48 diffs)
-
pvb-cf7-calculator.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
views/tag-generator-calculate-button.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pvb-contact-form-7-calculator/trunk/autoload.php
r2149454 r2946744 1 1 <?php 2 /** 3 * File: autoload.php 4 * 5 * Defines the pvb_cf7_calculator_autoload function. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 11 2 12 /** 3 13 * Dynamically loads the class attempting to be instantiated elsewhere in the -
pvb-contact-form-7-calculator/trunk/js/pvb-cf7-calculator-admin.js
r2149454 r2946744 1 /** 2 * File: pvb-cf7-calculator-admin.js 3 * 4 * Provides support functions for the admin dashboard. 5 * 6 * @since 1.0.0 7 * 8 * @package PVBCF7Calculator 9 */ 10 11 /** 12 * Posts a message to the backend to enable a "powered by" badge. 13 * 14 * @param {string|jQuery} aElm Target element for confirmation output. 15 * @param {string} msgWait Message to display while waiting 16 * for the asynchronous action. 17 * @param {string} msgOK Confirmation message to display on success. 18 */ 1 19 function pvbCf7CalculatorPoweredByEnable(aElm, msgWait, msgOK) { 2 20 jQuery( aElm ).text( msgWait ); … … 10 28 } 11 29 30 /** 31 * Hides admin notices and posts a message to the backend to not display them 32 * (either temporarily or permanently). 33 * 34 * @param {number} period The dismissal period, either 1 (temporary) 35 * or any other value (permanent). 36 * @param {string|jQuery} target Container element from which 37 * notices should be removed. 38 */ 12 39 function pvbCf7CalculatorHideAdminNotices(period, target) { 13 40 jQuery( target ).closest( '.notice' ).remove(); 14 41 15 42 if (period == 1) { 16 // Dismiss temporarily 43 // Dismiss temporarily. 17 44 jQuery.post( ajaxurl, {action: 'pvb_promo_pause'} ); 18 45 } else { 19 // Dismiss permanently 46 // Dismiss permanently. 20 47 jQuery.post( ajaxurl, {action: 'pvb_promo_disable'} ); 21 48 } -
pvb-contact-form-7-calculator/trunk/js/pvb-cf7-calculator.js
r2269783 r2946744 1 /** 2 * File: pvb-cf7-calculator.js 3 * 4 * Provides front-end support functions. 5 * 6 * @since 1.0.0 7 * 8 * @package PVBCF7Calculator 9 */ 10 11 /** 12 * Performs calculations on a form. 13 * 14 * @param {jQuery} $form The form to process. 15 */ 1 16 function cf7Calculate($form) { 2 // Retrieve form ID 17 // Retrieve form ID. 3 18 var form_id = null; 4 19 var $form_div = $form.closest( 'div.wpcf7' ); 5 if ( !$form_div.length) {20 if ( ! $form_div.length) { 6 21 return; 7 22 } … … 17 32 var $button = $form_div.find( '.cf7-calculate_button' ); 18 33 19 // Retrieve form values 34 // Retrieve form values. 20 35 $form = $button.closest( 'form' ); 21 if ( !$form.length) {36 if ( ! $form.length) { 22 37 return; 23 38 } 24 39 var postdata = $form.serializeArray(); 25 40 26 // Add form ID to posted data 41 // Add form ID to posted data. 27 42 postdata.push( {name: 'action', value: 'pvb_calculate'} ); 28 43 postdata.push( {name: 'pvb_form_id', value: form_id} ); 29 44 30 // Send data to server 45 // Send data to server. 31 46 jQuery.post( 32 47 frontend_ajax_object.ajaxurl, 33 48 postdata, 34 49 function(r) { 35 // Fill fields with results 50 // Fill fields with results. 36 51 if (r instanceof Object) { 37 52 var nameLowercaseCompare = function() { … … 42 57 } 43 58 } 44 // Enable button again 59 // Enable button again. 45 60 if ($button) { 46 61 $button.prop( 'disabled', false ); … … 50 65 ).fail( 51 66 function() { 52 // Enable button again 67 // Enable button again. 53 68 $button.prop( 'disabled', false ); 54 69 $form.trigger( 'wpcf7calculatefail' ); … … 57 72 } 58 73 59 // Attach to Calculate buttons 60 jQuery(function($) { 61 jQuery('body').on( 62 'click', 63 '.cf7-calculate_button', 64 function(event) { 65 // Disable button 66 var $button = jQuery( event.target ); 67 if (!$button.length) { 68 return; 74 // Attach to Calculate buttons. 75 jQuery( 76 function($) { 77 jQuery( 'body' ).on( 78 'click', 79 '.cf7-calculate_button', 80 function(event) { 81 // Disable button. 82 var $button = jQuery( event.target ); 83 if ( ! $button.length) { 84 return; 85 } 86 $button.prop( 'disabled', true ); 87 cf7Calculate( $button.closest( 'form' ) ); 69 88 } 70 $button.prop( 'disabled', true ); 71 cf7Calculate( $button.closest( 'form' ) ); 72 } 73 ); 74 }); 89 ); 90 } 91 ); -
pvb-contact-form-7-calculator/trunk/lib/Math/Exception/class-divisionbyzeroexception.php
r2149454 r2946744 1 1 <?php 2 2 /** 3 * File: class-divisionbyzeroexception.php 4 * 5 * Defines the DivisionByZeroException class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math\Exception; … … 10 18 11 19 /** 20 * Division by zero. 21 * 12 22 * @return DivisionByZeroException 13 23 */ … … 17 27 18 28 /** 29 * Division by zero when defining a rational number. 30 * 19 31 * @return DivisionByZeroException 20 32 */ -
pvb-contact-form-7-calculator/trunk/lib/Math/Exception/class-integeroverflowexception.php
r2149454 r2946744 1 1 <?php 2 2 /** 3 * File: class-integeroverflowexception.php 4 * 5 * Defines the IntegerOverflowException class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math\Exception; … … 12 20 13 21 /** 14 * @param BigInteger $value 22 * Overflow when converting to integer. 23 * 24 * @param BigInteger $value The value that is out of range. 15 25 * 16 26 * @return IntegerOverflowException -
pvb-contact-form-7-calculator/trunk/lib/Math/Exception/class-mathexception.php
r2149454 r2946744 1 1 <?php 2 2 /** 3 * File: class-mathexception.php 4 * 5 * Defines the MathException class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math\Exception; -
pvb-contact-form-7-calculator/trunk/lib/Math/Exception/class-numberformatexception.php
r2149454 r2946744 1 1 <?php 2 2 /** 3 * File: class-numberformatexception.php 4 * 5 * Defines the NumberFormatException class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math\Exception; -
pvb-contact-form-7-calculator/trunk/lib/Math/Exception/class-roundingnecessaryexception.php
r2149454 r2946744 1 1 <?php 2 2 /** 3 * File: class-roundingnecessaryexception.php 4 * 5 * Defines the RoundingNecessaryException class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math\Exception; … … 10 18 11 19 /** 20 * Rounding necessary (scale mismatch exception). 21 * 12 22 * @return RoundingNecessaryException 13 23 */ -
pvb-contact-form-7-calculator/trunk/lib/Math/Internal/Calculator/class-bcmathcalculator.php
r2149454 r2946744 1 1 <?php 2 /** 3 * File: class-bcmathcalculator.php 4 * 5 * Defines the BcMathCalculator class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 11 2 12 namespace PVBCF7Calculator\lib\Math\Internal\Calculator; 3 13 … … 12 22 13 23 /** 14 * {@inheritdoc} 24 * Adds two numbers. 25 * 26 * @param string $a The augend. 27 * @param string $b The addend. 28 * 29 * @return string The sum. 15 30 */ 16 31 public function add( $a, $b ) { … … 19 34 20 35 /** 21 * {@inheritdoc} 36 * Subtracts two numbers. 37 * 38 * @param string $a The minuend. 39 * @param string $b The subtrahend. 40 * 41 * @return string The difference. 22 42 */ 23 43 public function sub( $a, $b ) { … … 26 46 27 47 /** 28 * {@inheritdoc} 48 * Multiplies two numbers. 49 * 50 * @param string $a The multiplicand. 51 * @param string $b The multiplier. 52 * 53 * @return string The product. 29 54 */ 30 55 public function mul( $a, $b ) { … … 33 58 34 59 /** 35 * {@inheritdoc} 60 * Returns the quotient of the division of two numbers. 61 * 62 * @param string $a The dividend. 63 * @param string $b The divisor, must not be zero. 64 * 65 * @return string The quotient. 36 66 */ 37 67 public function div_q( $a, $b ) { … … 40 70 41 71 /** 42 * {@inheritdoc} 72 * Returns the remainder of the division of two numbers. 73 * 74 * @param string $a The dividend. 75 * @param string $b The divisor, must not be zero. 76 * 77 * @return string The remainder. 43 78 */ 44 79 public function div_r( $a, $b ) { … … 47 82 48 83 /** 49 * {@inheritdoc} 84 * Returns the quotient and remainder of the division of two numbers. 85 * 86 * @param string $a The dividend. 87 * @param string $b The divisor, must not be zero. 88 * 89 * @return string[] An array containing the quotient and remainder. 50 90 */ 51 91 public function div_q_r( $a, $b ) { … … 53 93 $r = bcmod( $a, $b ); 54 94 55 return [ $q, $r ];95 return array( $q, $r ); 56 96 } 57 97 58 98 /** 59 * {@inheritdoc} 99 * Exponentiates a number. 100 * 101 * @param string $a The base. 102 * @param int $e The exponent, validated as an integer between 0 and MAX_POWER. 103 * 104 * @return string The power. 60 105 */ 61 106 public function pow( $a, $e ) { -
pvb-contact-form-7-calculator/trunk/lib/Math/Internal/Calculator/class-gmpcalculator.php
r2149454 r2946744 1 1 <?php 2 /** 3 * File: class-gmpcalculator.php 4 * 5 * Defines the GmpCalculator class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 11 2 12 namespace PVBCF7Calculator\lib\Math\Internal\Calculator; 3 13 … … 12 22 13 23 /** 14 * {@inheritdoc} 24 * Adds two numbers. 25 * 26 * @param string $a The augend. 27 * @param string $b The addend. 28 * 29 * @return string The sum. 15 30 */ 16 31 public function add( $a, $b ) { … … 19 34 20 35 /** 21 * {@inheritdoc} 36 * Subtracts two numbers. 37 * 38 * @param string $a The minuend. 39 * @param string $b The subtrahend. 40 * 41 * @return string The difference. 22 42 */ 23 43 public function sub( $a, $b ) { … … 26 46 27 47 /** 28 * {@inheritdoc} 48 * Multiplies two numbers. 49 * 50 * @param string $a The multiplicand. 51 * @param string $b The multiplier. 52 * 53 * @return string The product. 29 54 */ 30 55 public function mul( $a, $b ) { … … 33 58 34 59 /** 35 * {@inheritdoc} 60 * Returns the quotient of the division of two numbers. 61 * 62 * @param string $a The dividend. 63 * @param string $b The divisor, must not be zero. 64 * 65 * @return string The quotient. 36 66 */ 37 67 public function div_q( $a, $b ) { … … 40 70 41 71 /** 42 * {@inheritdoc} 72 * Returns the remainder of the division of two numbers. 73 * 74 * @param string $a The dividend. 75 * @param string $b The divisor, must not be zero. 76 * 77 * @return string The remainder. 43 78 */ 44 79 public function div_r( $a, $b ) { … … 47 82 48 83 /** 49 * {@inheritdoc} 84 * Returns the quotient and remainder of the division of two numbers. 85 * 86 * @param string $a The dividend. 87 * @param string $b The divisor, must not be zero. 88 * 89 * @return string[] An array containing the quotient and remainder. 50 90 */ 51 91 public function div_q_r( $a, $b ) { 52 92 list($q, $r) = gmp_div_qr( $a, $b ); 53 93 54 return [94 return array( 55 95 gmp_strval( $q ), 56 96 gmp_strval( $r ), 57 ];97 ); 58 98 } 59 99 60 100 /** 61 * {@inheritdoc} 101 * Exponentiates a number. 102 * 103 * @param string $a The base. 104 * @param int $e The exponent, validated as an integer between 0 and MAX_POWER. 105 * 106 * @return string The power. 62 107 */ 63 108 public function pow( $a, $e ) { … … 66 111 67 112 /** 68 * {@inheritdoc} 113 * Returns the greatest common divisor of the two numbers. 114 * 115 * This method can be overridden by the concrete implementation if the underlying library 116 * has built-in support for GCD calculations. 117 * 118 * @param string $a The first number. 119 * @param string $b The second number. 120 * 121 * @return string The GCD, always positive, or zero if both arguments are zero. 69 122 */ 70 123 public function gcd( $a, $b ) { -
pvb-contact-form-7-calculator/trunk/lib/Math/Internal/Calculator/class-nativecalculator.php
r2149454 r2946744 1 1 <?php 2 /** 3 * File: class-nativecalculator.php 4 * 5 * Defines the NativeCalculator class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 11 2 12 namespace PVBCF7Calculator\lib\Math\Internal\Calculator; 3 13 … … 45 55 46 56 /** 47 * {@inheritdoc} 57 * Adds two numbers. 58 * 59 * @param string $a The augend. 60 * @param string $b The addend. 61 * 62 * @return string The sum. 48 63 */ 49 64 public function add( $a, $b ) { … … 76 91 77 92 /** 78 * {@inheritdoc} 93 * Subtracts two numbers. 94 * 95 * @param string $a The minuend. 96 * @param string $b The subtrahend. 97 * 98 * @return string The difference. 79 99 */ 80 100 public function sub( $a, $b ) { … … 83 103 84 104 /** 85 * {@inheritdoc} 105 * Multiplies two numbers. 106 * 107 * @param string $a The multiplicand. 108 * @param string $b The multiplier. 109 * 110 * @return string The product. 86 111 */ 87 112 public function mul( $a, $b ) { … … 122 147 123 148 /** 124 * {@inheritdoc} 149 * Returns the quotient of the division of two numbers. 150 * 151 * @param string $a The dividend. 152 * @param string $b The divisor, must not be zero. 153 * 154 * @return string The quotient. 125 155 */ 126 156 public function div_q( $a, $b ) { … … 129 159 130 160 /** 131 * {@inheritdoc} 161 * Returns the remainder of the division of two numbers. 162 * 163 * @param string $a The dividend. 164 * @param string $b The divisor, must not be zero. 165 * 166 * @return string The remainder. 132 167 */ 133 168 public function div_r( $a, $b ) { … … 136 171 137 172 /** 138 * {@inheritdoc} 173 * Returns the quotient and remainder of the division of two numbers. 174 * 175 * @param string $a The dividend. 176 * @param string $b The divisor, must not be zero. 177 * 178 * @return string[] An array containing the quotient and remainder. 139 179 */ 140 180 public function div_q_r( $a, $b ) { 141 181 if ( '0' === $a ) { 142 return [ '0', '0' ];182 return array( '0', '0' ); 143 183 } 144 184 145 185 if ( $a === $b ) { 146 return [ '1', '0' ];186 return array( '1', '0' ); 147 187 } 148 188 149 189 if ( '1' === $b ) { 150 return [ $a, '0' ];190 return array( $a, '0' ); 151 191 } 152 192 153 193 if ( '-1' === $b ) { 154 return [ $this->neg( $a ), '0' ];194 return array( $this->neg( $a ), '0' ); 155 195 } 156 196 … … 167 207 $r = (string) $r; 168 208 169 return [ $q, $r ];209 return array( $q, $r ); 170 210 } 171 211 … … 180 220 } 181 221 182 return [ $q, $r ]; 183 } 184 185 /** 186 * {@inheritdoc} 222 return array( $q, $r ); 223 } 224 225 /** 226 * Exponentiates a number. 227 * 228 * @param string $a The base. 229 * @param int $e The exponent, validated as an integer between 0 and MAX_POWER. 230 * 231 * @return string The power. 187 232 */ 188 233 public function pow( $a, $e ) { … … 352 397 353 398 if ( -1 === $cmp ) { 354 return [ '0', $a ];355 } 356 357 // we now know that a > b && x >= y358 359 $q = '0'; // quotient360 $r = $a; // remainder361 $z = $y; // focus length, always $y or $y+1399 return array( '0', $a ); 400 } 401 402 // We now know that (a > b && x >= y). 403 404 $q = '0'; // Quotient. 405 $r = $a; // Remainder. 406 $z = $y; // Focus length, always $y or ($y + 1). 362 407 363 408 for ( ;; ) { … … 367 412 368 413 if ( -1 === $cmp ) { 369 if ( $z === $x ) { // remainder < dividend414 if ( $z === $x ) { // Remainder < dividend. 370 415 break; 371 416 } … … 381 426 $r = $a; 382 427 383 if ( '0' === $r ) { // remainder == 0428 if ( '0' === $r ) { // Remainder == 0. 384 429 break; 385 430 } … … 387 432 $x = strlen( $a ); 388 433 389 if ( $x < $y ) { // remainder < dividend434 if ( $x < $y ) { // Remainder < dividend. 390 435 break; 391 436 } … … 394 439 } 395 440 396 return [ $q, $r ];441 return array( $q, $r ); 397 442 } 398 443 … … 442 487 * @return int The length of both strings. 443 488 */ 444 private function pad( & $a, &$b, $x, $y ) {489 private function pad( &$a, &$b, $x, $y ) { 445 490 if ( $x === $y ) { 446 491 return $x; -
pvb-contact-form-7-calculator/trunk/lib/Math/Internal/class-calculator.php
r2149454 r2946744 1 1 <?php 2 2 /** 3 * File: class-calculator.php 4 * 5 * Defines the Calculator class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math\Internal; … … 93 101 * @return void 94 102 */ 95 final protected function init( $a, $b, & $a_dig, & $b_dig, & $a_neg, & $b_neg, & $a_len, &$b_len ) {103 final protected function init( $a, $b, &$a_dig, &$b_dig, &$a_neg, &$b_neg, &$a_len, &$b_len ) { 96 104 $a_neg = ( '-' === $a[0] ); 97 105 $b_neg = ( '-' === $b[0] ); -
pvb-contact-form-7-calculator/trunk/lib/Math/class-bigdecimal.php
r2157957 r2946744 1 1 <?php 2 2 /** 3 * File: class-bigdecimal.php 4 * 5 * Defines the BigDecimal class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math; … … 47 55 * Creates a BigDecimal of the given value. 48 56 * 49 * @param BigNumber|number|string $value 57 * @param BigNumber|number|string $value Value to convert. 50 58 * 51 59 * @return BigDecimal … … 208 216 * 209 217 * @throws \InvalidArgumentException If the scale or rounding mode is invalid. 210 * @throws MathException If the number is invalid, is zero, or rounding was necessary.218 * @throws DivisionByZeroException If the divisor is not a valid decimal number, or is zero. 211 219 */ 212 220 public function dividedBy( $that, $scale = null, $rounding_mode = RoundingMode::UNNECESSARY ) { … … 244 252 * @return BigDecimal The result. 245 253 * 246 * @throws MathException If the divisor is not a valid number, is not convertible to a BigDecimal, is zero, 247 * or the result yields an infinite number of digits. 254 * @throws DivisionByZeroException If the divisor is not a valid decimal number, or is zero. 248 255 */ 249 256 public function exactlyDividedBy( $that ) { … … 261 268 $calculator = Calculator::get(); 262 269 263 foreach ( [ 5, 2 ]as $prime ) {270 foreach ( array( 5, 2 ) as $prime ) { 264 271 for ( ;; ) { 265 272 $last_digit = (int) substr( $d, -1 ); … … 319 326 * @return BigDecimal The quotient. 320 327 * 321 * @throws MathException If the divisor is not a valid decimal number, or is zero.328 * @throws DivisionByZeroException If the divisor is not a valid decimal number, or is zero. 322 329 */ 323 330 public function quotient( $that ) { … … 345 352 * @return BigDecimal The remainder. 346 353 * 347 * @throws MathException If the divisor is not a valid decimal number, or is zero.354 * @throws DivisionByZeroException If the divisor is not a valid decimal number, or is zero. 348 355 */ 349 356 public function remainder( $that ) { … … 373 380 * @return BigDecimal[] An array containing the quotient and the remainder. 374 381 * 375 * @throws MathException If the divisor is not a valid decimal number, or is zero.382 * @throws DivisionByZeroException If the divisor is not a valid decimal number, or is zero. 376 383 */ 377 384 public function quotientAndRemainder( $that ) { … … 394 401 $remainder = new BigDecimal( $remainder, $scale ); 395 402 396 return [ $quotient, $remainder ];403 return array( $quotient, $remainder ); 397 404 } 398 405 … … 400 407 * Returns a copy of this BigDecimal with the decimal point moved $n places to the left. 401 408 * 402 * @param int $n 409 * @param int $n Number of places to move the decimal point. 403 410 * 404 411 * @return BigDecimal … … 419 426 * Returns a copy of this BigDecimal with the decimal point moved $n places to the right. 420 427 * 421 * @param int $n 428 * @param int $n Number of places to move the decimal point. 422 429 * 423 430 * @return BigDecimal … … 496 503 497 504 /** 498 * {@inheritdoc} 505 * Compares this number to the given one. 506 * 507 * @param BigNumber|number|string $that Number to compare to. 508 * 509 * @return int [-1,0,1] If `$this` is lower than, equal to, or greater than `$that`. 510 * 511 * @throws MathException If the number is not valid. 499 512 */ 500 513 public function compareTo( $that ) { … … 522 535 523 536 /** 537 * Returns the unscaled value. 538 * 524 539 * @return BigInteger 525 540 */ … … 529 544 530 545 /** 546 * Returns the scale. 547 * 531 548 * @return int 532 549 */ … … 602 619 603 620 /** 604 * {@inheritdoc} 621 * Converts this number to a BigDecimal with the given scale, using rounding if necessary. 622 * 623 * @param int $scale The scale of the resulting `BigDecimal`. 624 * @param int $rounding_mode A `RoundingMode` constant. 625 * 626 * @return BigDecimal 627 * 628 * @throws RoundingNecessaryException If this number cannot be converted to the given scale without rounding. 629 * This only applies when RoundingMode::UNNECESSARY is used. 605 630 */ 606 631 public function toScale( $scale, $rounding_mode = RoundingMode::UNNECESSARY ) { … … 655 680 * @internal 656 681 * 657 * @param string $value 682 * @param string $value Value to unserialize. 658 683 * 659 684 * @return void 660 685 * 661 * @throws \LogicException 686 * @throws \LogicException If called directly. 662 687 */ 663 688 public function unserialize( $value ) { … … 682 707 * @return void 683 708 */ 684 private function scaleValues( $x, $y, & $a, &$b ) {709 private function scaleValues( $x, $y, &$a, &$b ) { 685 710 $a = $x->value; 686 711 $b = $y->value; … … 694 719 695 720 /** 696 * @param int $scale 721 * Zero-pads the value up to $scale 722 * 723 * @param int $scale Minimum scale. 697 724 * 698 725 * @return string -
pvb-contact-form-7-calculator/trunk/lib/Math/class-biginteger.php
r2157957 r2946744 1 1 <?php 2 2 /** 3 * File: class-biginteger.php 4 * 5 * Defines the BigInteger class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math; … … 39 47 * Creates a BigInteger of the given value. 40 48 * 41 * @param BigNumber|number|string $value 49 * @param BigNumber|number|string $value Value to convert. 42 50 * 43 51 * @return BigInteger … … 244 252 * @return BigInteger The result. 245 253 * 246 * @throws MathException If the divisor is not a valid number, is not convertible to a BigInteger, is zero,247 * or RoundingMode::UNNECESSARY is used and the remainder is not zero.254 * @throws DivisionByZeroException If the divisor is not a valid number, is not convertible to a BigInteger, is zero, 255 * or RoundingMode::UNNECESSARY is used and the remainder is not zero. 248 256 */ 249 257 public function dividedBy( $that, int $rounding_mode = RoundingMode::UNNECESSARY ) { … … 360 368 $remainder = $r[1]; 361 369 362 return [370 return array( 363 371 new BigInteger( $quotient ), 364 372 new BigInteger( $remainder ), 365 ];373 ); 366 374 } 367 375 … … 410 418 411 419 /** 412 * {@inheritdoc} 420 * Compares this number to the given one. 421 * 422 * @param BigNumber|number|string $that Number to compare to. 423 * 424 * @return int [-1,0,1] If `$this` is lower than, equal to, or greater than `$that`. 425 * 426 * @throws MathException If the number is not valid. 413 427 */ 414 428 public function compareTo( $that ) { … … 451 465 452 466 /** 453 * {@inheritdoc} 467 * Converts this number to a BigDecimal with the given scale, using rounding if necessary. 468 * 469 * @param int $scale The scale of the resulting `BigDecimal`. 470 * @param int $rounding_mode A `RoundingMode` constant. 471 * 472 * @return BigDecimal 473 * 474 * @throws RoundingNecessaryException If this number cannot be converted to the given scale without rounding. 475 * This only applies when RoundingMode::UNNECESSARY is used. 454 476 */ 455 477 public function toScale( $scale, $rounding_mode = RoundingMode::UNNECESSARY ) { … … 458 480 459 481 /** 460 * {@inheritdoc} 482 * Returns the exact value of this number as a native integer. 483 * 484 * If this number cannot be converted to a native integer without losing precision, an exception is thrown. 485 * Note that the acceptable range for an integer depends on the platform and differs for 32-bit and 64-bit. 486 * 487 * @return int The converted value. 488 * 489 * @throws IntegerOverflowException If this number cannot be exactly converted to a native integer. 461 490 */ 462 491 public function toInt() { … … 478 507 * Returns a string representation of this number in the given base. 479 508 * 480 * @param int $base 509 * @param int $base Base to use. 481 510 * 482 511 * @return string … … 544 573 * @internal 545 574 * 546 * @param string $value 575 * @param string $value Value to unserialize. 547 576 * 548 577 * @return void 549 578 * 550 * @throws \LogicException 579 * @throws \LogicException If called directly. 551 580 */ 552 581 public function unserialize( $value ) { -
pvb-contact-form-7-calculator/trunk/lib/Math/class-bignumber.php
r2149454 r2946744 1 1 <?php 2 2 /** 3 * File: class-bignumber.php 4 * 5 * Defines the BigNumber class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math; … … 44 52 * - strings containing only digits with an optional leading `+` or `-` sign are returned as BigInteger 45 53 * 46 * @param BigNumber|number|string $value 54 * @param BigNumber|number|string $value Value to convert. 47 55 * 48 56 * @return BigNumber … … 121 129 * @return static The minimum value. 122 130 * 123 * @throws \InvalidArgumentException If no values are given. 124 * @throws MathException If an argument is not valid. 131 * @throws \InvalidArgumentException If no values are given or an argument is not valid. 125 132 */ 126 133 public static function min( ...$values ) { … … 150 157 * @return static The maximum value. 151 158 * 152 * @throws \InvalidArgumentException If no values are given. 153 * @throws MathException If an argument is not valid. 159 * @throws \InvalidArgumentException If no values are given or an argument is not valid. 154 160 */ 155 161 public static function max( ...$values ) { … … 201 207 * Checks if this number is equal to the given one. 202 208 * 203 * @param BigNumber|number|string $that 209 * @param BigNumber|number|string $that Number to compare to. 204 210 * 205 211 * @return bool … … 212 218 * Checks if this number is strictly lower than the given one. 213 219 * 214 * @param BigNumber|number|string $that 220 * @param BigNumber|number|string $that Number to compare to. 215 221 * 216 222 * @return bool … … 223 229 * Checks if this number is lower than or equal to the given one. 224 230 * 225 * @param BigNumber|number|string $that 231 * @param BigNumber|number|string $that Number to compare to. 226 232 * 227 233 * @return bool … … 234 240 * Checks if this number is strictly greater than the given one. 235 241 * 236 * @param BigNumber|number|string $that 242 * @param BigNumber|number|string $that Number to compare to. 237 243 * 238 244 * @return bool … … 245 251 * Checks if this number is greater than or equal to the given one. 246 252 * 247 * @param BigNumber|number|string $that 253 * @param BigNumber|number|string $that Number to compare to. 248 254 * 249 255 * @return bool … … 308 314 * Compares this number to the given one. 309 315 * 310 * @param BigNumber|number|string $that 316 * @param BigNumber|number|string $that Number to compare to. 311 317 * 312 318 * @return int [-1,0,1] If `$this` is lower than, equal to, or greater than `$that`. -
pvb-contact-form-7-calculator/trunk/lib/Math/class-bigrational.php
r2149454 r2946744 1 1 <?php 2 2 /** 3 * File: class-bignumber.php 4 * 5 * Defines the BigNumber class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math; … … 58 66 * Creates a BigRational of the given value. 59 67 * 60 * @param BigNumber|number|string $value 68 * @param BigNumber|number|string $value Value to convert. 61 69 * 62 70 * @return BigRational … … 136 144 137 145 /** 146 * Returns the numerator. 147 * 138 148 * @return BigInteger 139 149 */ … … 143 153 144 154 /** 155 * Returns the denominator. 156 * 145 157 * @return BigInteger 146 158 */ … … 323 335 324 336 /** 325 * {@inheritdoc} 337 * Compares this number to the given one. 338 * 339 * @param BigNumber|number|string $that Number to compare to. 340 * 341 * @return int [-1,0,1] If `$this` is lower than, equal to, or greater than `$that`. 342 * 343 * @throws MathException If the number is not valid. 326 344 */ 327 345 public function compareTo( $that ) { … … 337 355 338 356 /** 339 * {@inheritdoc} 357 * Converts this number to a BigInteger. 358 * 359 * @return BigInteger The converted number. 360 * 361 * @throws RoundingNecessaryException If this number cannot be converted to a BigInteger without rounding. 340 362 */ 341 363 public function toBigInteger() { … … 364 386 365 387 /** 366 * {@inheritdoc} 388 * Converts this number to a BigDecimal with the given scale, using rounding if necessary. 389 * 390 * @param int $scale The scale of the resulting `BigDecimal`. 391 * @param int $rounding_mode A `RoundingMode` constant. 392 * 393 * @return BigDecimal 394 * 395 * @throws RoundingNecessaryException If this number cannot be converted to the given scale without rounding. 396 * This only applies when RoundingMode::UNNECESSARY is used. 367 397 */ 368 398 public function toScale( $scale, $rounding_mode = RoundingMode::UNNECESSARY ) { … … 414 444 * @internal 415 445 * 416 * @param string $value 446 * @param string $value Value to unserialize. 417 447 * 418 448 * @return void 419 449 * 420 * @throws \LogicException 450 * @throws \LogicException If called directly. 421 451 */ 422 452 public function unserialize( $value ) { -
pvb-contact-form-7-calculator/trunk/lib/Math/class-pvbcalculator.php
r2149454 r2946744 1 1 <?php 2 /** 3 * File: class-pvbcalculator.php 4 * 5 * Defines the PVBCalculator class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 11 2 12 namespace PVBCF7Calculator\lib\Math; 3 13 … … 6 16 use \DatePeriod; 7 17 18 /** 19 * Provides support for custom functions when calculating expressions 20 */ 8 21 class PVBCalculator { 9 22 10 23 /** 11 * @var array Defined functions. 12 */ 13 private $functions = []; 14 15 /** 16 * @var TokenizerInterface . 24 * Defined functions. 25 * 26 * @var array 27 */ 28 private $functions = array(); 29 30 /** 31 * Tokenizer. 32 * 33 * @var TokenizerInterface 17 34 */ 18 35 private $tokenizer; 19 36 37 /** 38 * Proxy method to access protected constructors from sibling classes. 39 * 40 * @internal 41 * 42 * @return static 43 */ 20 44 public static function create() { 21 45 return new self( new Tokenizer() ); … … 26 50 * Sets expression if provided. 27 51 * Sets default functions: sqrt(n), ln(n), log(a,b). 28 * @param TokenizerInterface $tokenizer 52 * 53 * @param TokenizerInterface $tokenizer Tokenizer. 29 54 */ 30 55 public function __construct( $tokenizer ) { … … 46 71 'fn_day', 47 72 function ( $timestamp ) { 48 return date( 'j', $timestamp * 86400 );73 return gmdate( 'j', $timestamp * 86400 ); 49 74 } 50 75 ); … … 52 77 'fn_month', 53 78 function ( $timestamp ) { 54 return date( 'n', $timestamp * 86400 );79 return gmdate( 'n', $timestamp * 86400 ); 55 80 } 56 81 ); … … 58 83 'fn_year', 59 84 function ( $timestamp ) { 60 return date( 'Y', $timestamp * 86400 );85 return gmdate( 'Y', $timestamp * 86400 ); 61 86 } 62 87 ); … … 64 89 'fn_day_of_year', 65 90 function ( $timestamp ) { 66 return date( 'z', $timestamp * 86400 );91 return gmdate( 'z', $timestamp * 86400 ); 67 92 } 68 93 ); … … 70 95 'fn_weekday', 71 96 function ( $timestamp ) { 72 return date( 'N', $timestamp * 86400 );97 return gmdate( 'N', $timestamp * 86400 ); 73 98 } 74 99 ); … … 77 102 function ( $timestamp1, $timestamp2 ) { 78 103 $utc = new DateTimeZone( 'UTC' ); 79 $working_days = [ 1, 2, 3, 4, 5 ]; # date format = N (1 = Monday, ...)80 $holiday_days = [ '*-12-25', '*-01-01', '2013-12-23' ]; # variable and fixed holidays104 $working_days = array( 1, 2, 3, 4, 5 ); // Date format = N (1 = Monday, etc). 105 $holiday_days = array( '*-12-25', '*-01-01', '2013-12-23' ); // Variable and fixed holidays. 81 106 82 107 if ( $timestamp1 < $timestamp2 ) { 83 $from = new DateTime( date( 'Y-m-d', $timestamp1 * 86400 ), $utc );84 $to = new DateTime( date( 'Y-m-d', $timestamp2 * 86400 ), $utc );108 $from = new DateTime( gmdate( 'Y-m-d', $timestamp1 * 86400 ), $utc ); 109 $to = new DateTime( gmdate( 'Y-m-d', $timestamp2 * 86400 ), $utc ); 85 110 } else { 86 $from = new DateTime( date( 'Y-m-d', $timestamp2 * 86400 ), $utc );87 $to = new DateTime( date( 'Y-m-d', $timestamp1 * 86400 ), $utc );111 $from = new DateTime( gmdate( 'Y-m-d', $timestamp2 * 86400 ), $utc ); 112 $to = new DateTime( gmdate( 'Y-m-d', $timestamp1 * 86400 ), $utc ); 88 113 } 89 114 $to->modify( '+1 day' ); … … 110 135 111 136 /** 112 * @return array 137 * Returns the functions. 138 * 139 * @return array 113 140 */ 114 141 public function get_functions() { … … 117 144 118 145 /** 119 * @param string $name Name of the function (as in arithmetic expressions). 146 * Adds a function. 147 * 148 * @param string $name Name of the function (as in arithmetic expressions). 120 149 * @param callable $function Interpretation of this function. 121 * @throws \Exception 150 * 151 * @throws \InvalidArgumentException If function name contains invalid characters. 152 * @throws \Exception If function already exists. 122 153 */ 123 154 public function add_function( $name, $function ) { … … 135 166 $params_count = $reflection->getNumberOfRequiredParameters(); 136 167 137 $this->functions[ $name ] = [168 $this->functions[ $name ] = array( 138 169 'func' => $function, 139 170 'paramsCount' => $params_count, 140 ]; 141 } 142 143 /** 144 * @param string $name Name of the function. 171 ); 172 } 173 174 /** 175 * Replaces a function. 176 * 177 * @param string $name Name of the function. 145 178 * @param callable $function Interpretation. 146 179 */ … … 151 184 152 185 /** 153 * @param string $name Name of function. 186 * Removes a function. 187 * 188 * @param string $name Name of function. 154 189 */ 155 190 public function remove_function( $name ) { … … 165 200 * also known as Postfix Notation. 166 201 * 167 * @param array $tokens 202 * @param array $tokens Tokens to rearrange. 168 203 * @return \SplQueue 169 * @throws \InvalidArgumentException 204 * @throws \InvalidArgumentException If parentheses are misplaced. 170 205 */ 171 206 private function get_reverse_polish_notation( $tokens ) { … … 181 216 $stack->push( $tokens[ $i ] ); 182 217 } elseif ( Tokens::ARG_SEPARATOR === $tokens[ $i ] ) { 183 // checking whether stack contains left parenthesis (dirty hack)218 // Checks whether stack contains left parenthesis. 184 219 if ( substr_count( $stack->serialize(), Tokens::PAREN_LEFT ) === 0 ) { 185 throw new \InvalidArgumentException( 'Parenthes is are misplaced' );220 throw new \InvalidArgumentException( 'Parentheses are misplaced' ); 186 221 } 187 222 … … 201 236 $stack->push( Tokens::PAREN_LEFT ); 202 237 } elseif ( Tokens::PAREN_RIGHT === $tokens[ $i ] ) { 203 // checking whether stack contains left parenthesis (dirty hack)238 // Checks whether stack contains left parenthesis. 204 239 if ( substr_count( $stack->serialize(), Tokens::PAREN_LEFT ) === 0 ) { 205 throw new \InvalidArgumentException( 'Parenthes is are misplaced' );240 throw new \InvalidArgumentException( 'Parentheses are misplaced' ); 206 241 } 207 242 … … 228 263 * Calculates tokens ordered in RPN. 229 264 * 230 * @param \SplQueue $queue 265 * @param \SplQueue $queue Queue to process. 231 266 * @return int|float Result of the calculation. 232 * @throws \InvalidArgumentException 267 * @throws \InvalidArgumentException If expression is invalid. 233 268 */ 234 269 private function calculate_from_rpn( $queue ) { … … 250 285 } 251 286 252 $params = [];287 $params = array(); 253 288 for ( $i = 0; $i < $this->functions[ $current_token ]['paramsCount']; $i++ ) { 254 289 $params[] = $stack->pop(); … … 269 304 * Calculates the current arithmetic expression. 270 305 * 271 * @param string $expression 306 * @param string $expression Expression to calculate. 272 307 * @return float|int Result of the calculation. 273 308 */ … … 281 316 282 317 /** 318 * Checks association of an operator. 319 * 283 320 * @param string $operator A valid operator. 284 321 * @return bool 285 * @throws \InvalidArgumentException 322 * @throws \InvalidArgumentException If operator is not valid. 286 323 */ 287 324 private function is_operator_left_associative( $operator ) { … … 298 335 299 336 /** 337 * Checks precedence of an operator. 338 * 300 339 * @param string $operator A valid operator. 301 340 * @return int 302 * @throws \InvalidArgumentException 341 * @throws \InvalidArgumentException If operator is not valid. 303 342 */ 304 343 private function get_operator_precedence( $operator ) { … … 318 357 319 358 /** 359 * Executes an operator. 360 * 320 361 * @param string $operator A valid operator. 321 362 * @param int|float $a First value. 322 363 * @param int|float $b Second value. 323 364 * @return int|float Result. 324 * @throws \InvalidArgumentException 365 * @throws \InvalidArgumentException If operator is not valid. 325 366 */ 326 367 private function execute_operator( $operator, $a, $b ) { … … 350 391 351 392 /** 352 * @param string $function_name 353 * @param array $params 393 * Executes a function. 394 * 395 * @param string $function_name Name of the function to execute. 396 * @param array $params Parameters to pass. 397 * 354 398 * @return int|float Result. 355 399 */ -
pvb-contact-form-7-calculator/trunk/lib/Math/class-roundingmode.php
r2149454 r2946744 1 1 <?php 2 2 /** 3 * File: class-roundingmode.php 4 * 5 * Defines the RoundingMode class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 3 11 4 12 namespace PVBCF7Calculator\lib\Math; -
pvb-contact-form-7-calculator/trunk/lib/Math/class-tokenizer.php
r2149454 r2946744 1 1 <?php 2 /** 3 * File: class-tokenizer.php 4 * 5 * Defines the Tokenizer class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 11 2 12 namespace PVBCF7Calculator\lib\Math; 3 13 14 /** 15 * Breaks down an expression into tokens. 16 */ 4 17 class Tokenizer implements TokenizerInterface { 5 18 6 19 /** 7 * @param string $expression 8 * @param array $function_names 20 * Breaks down an expression into tokens. 21 * 22 * @param string $expression Expression to tokenize. 23 * @param array $function_names Names of functions to support. 24 * 9 25 * @return array Tokens of $expression 10 * @throws \ Exception26 * @throws \InvalidArgumentException If expression is not valid. 11 27 */ 12 public function tokenize( $expression, $function_names = []) {28 public function tokenize( $expression, $function_names = array() ) { 13 29 $expr_length = strlen( $expression ); 14 30 15 $tokens = [];31 $tokens = array(); 16 32 $number_buffer = ''; 17 33 -
pvb-contact-form-7-calculator/trunk/lib/Math/class-tokenizerinterface.php
r2149454 r2946744 1 1 <?php 2 /** 3 * File: class-tokenizerinterface.php 4 * 5 * Defines the TokenizerInterface interface. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 11 2 12 namespace PVBCF7Calculator\lib\Math; 3 13 … … 5 15 6 16 /** 7 * @param string $expression 8 * @param array $function_names 17 * Breaks down an expression into tokens. 18 * 19 * @param string $expression Expression to tokenize. 20 * @param array $function_names Names of functions to support. 21 * 9 22 * @return array Tokens of $expression 10 23 */ 11 public function tokenize( $expression, $function_names = []);24 public function tokenize( $expression, $function_names = array()); 12 25 } -
pvb-contact-form-7-calculator/trunk/lib/Math/class-tokens.php
r2149454 r2946744 1 1 <?php 2 /** 3 * File: class-tokens.php 4 * 5 * Defines the Tokens interface. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 11 2 12 namespace PVBCF7Calculator\lib\Math; 3 13 … … 17 27 const PAREN_RIGHT = ')'; 18 28 19 const OPERATORS = [ Tokens::PLUS, Tokens::MINUS, Tokens::MULT, Tokens::DIV, Tokens::POW, Tokens::MOD ];20 const PARENTHESES = [ Tokens::PAREN_LEFT, Tokens::PAREN_RIGHT ];29 const OPERATORS = array( Tokens::PLUS, Tokens::MINUS, Tokens::MULT, Tokens::DIV, Tokens::POW, Tokens::MOD ); 30 const PARENTHESES = array( Tokens::PAREN_LEFT, Tokens::PAREN_RIGHT ); 21 31 } -
pvb-contact-form-7-calculator/trunk/lib/class-pvbcf7calculator.php
r2269783 r2946744 1 1 <?php 2 /** 3 * File: class-pvbcf7calculator.php 4 * 5 * Defines the PVBCF7Calculator class. 6 * 7 * @since 1.0.0 8 * 9 * @package PVBCF7Calculator 10 */ 11 2 12 namespace PVBCF7Calculator\lib; 3 13 … … 11 21 define( 'PVB_CF7_CALCULATOR_PATH', dirname( dirname( __FILE__ ) ) ); 12 22 23 /** 24 * Initializes the PVB Contact Form 7 Calculator plugin 25 * and provides core functions. 26 * 27 * @since 1.0.0 28 */ 13 29 class PVBCF7Calculator { 14 30 … … 20 36 /** 21 37 * Unique ID string for plugin settings page 38 * 22 39 * @since 1.0.6 23 40 */ … … 26 43 /** 27 44 * This plugin's current version 45 * 46 * @var string 28 47 */ 29 48 private $plugin_version; 30 49 31 50 /** 51 * Placeholder for a WordPressSettingsFramework instance 52 * 32 53 * @var WordPressSettingsFramework 33 54 * @since 1.0.6 … … 39 60 * 40 61 * @since 1.0.0 41 *42 62 */ 43 63 public function __construct() { … … 47 67 add_action( 'admin_menu', array( $this, 'settings_menu' ) ); 48 68 49 // Set plugin version 69 // Set plugin version. 50 70 $plugin_data = get_file_data( 51 71 PVB_CF7_CALCULATOR_PATH . '/pvb-cf7-calculator.php', … … 56 76 $this->plugin_version = $plugin_data['Version']; 57 77 58 // Register settings 78 // Register settings. 59 79 $this->wpsf = new WordPressSettingsFramework( 60 80 PVB_CF7_CALCULATOR_PATH . '/settings/settings-general.php', … … 67 87 * 68 88 * @since 1.0.0 69 *70 89 */ 71 90 public function init() { … … 97 116 * 98 117 * @since 1.0.0 99 *100 118 */ 101 119 public function cf7_init() { … … 161 179 * 162 180 * @since 1.0.0 163 *164 181 */ 165 182 public function admin_init() { … … 183 200 * 184 201 * @since 1.0.0 185 *186 202 */ 187 203 public function enqueue_scripts() { 188 204 189 // CSS190 205 wp_enqueue_style( 191 206 'pvb-cf7-calculator', … … 199 214 200 215 wp_enqueue_script( 201 'pvb-cf7-calculator', // handle 202 plugins_url( 'js/pvb-cf7-calculator.js', dirname( __FILE__ ) ), // url 203 array( 'jquery' ), // dependencies 204 $this->plugin_version, // version 205 true // in footer 206 ); 207 208 // Provide the script with an URL where form data should be sent for calculation 216 'pvb-cf7-calculator', 217 plugins_url( 'js/pvb-cf7-calculator.js', dirname( __FILE__ ) ), 218 array( 'jquery' ), 219 $this->plugin_version, 220 true 221 ); 222 223 // Provide the script with an URL 224 // where form data should be sent for calculation. 209 225 wp_localize_script( 210 226 'pvb-cf7-calculator', … … 220 236 * 221 237 * @since 1.0.1 222 *223 238 */ 224 239 public function enqueue_admin_scripts() { 225 240 wp_enqueue_script( 226 'pvb-cf7-calculator-admin', // handle227 plugins_url( 'js/pvb-cf7-calculator-admin.js', dirname( __FILE__ ) ), // url228 array( 'jquery' ), // dependencies229 $this->plugin_version, // version230 true // in footer231 ); 232 } 233 234 /** 235 * Display a notice in the admin area if CF7 not installed, not active, or too old236 * 237 * @since 1.0.0238 * 241 'pvb-cf7-calculator-admin', 242 plugins_url( 'js/pvb-cf7-calculator-admin.js', dirname( __FILE__ ) ), 243 array( 'jquery' ), 244 $this->plugin_version, 245 true 246 ); 247 } 248 249 /** 250 * Display a notice in the admin area if CF7 not installed, 251 * not active, or too old 252 * 253 * @since 1.0.0 239 254 */ 240 255 public function not_active_notice() { … … 247 262 * 248 263 * @since 1.0.9 249 *250 264 */ 251 265 public function pro_active_notice() { … … 257 271 * 258 272 * @since 1.0.1 259 *260 273 */ 261 274 public function powered_by_opt_in() { … … 276 289 * Add "Settings" and "Support" links on Plugins page 277 290 * 291 * @param string[] $links Links to filter. 292 * 278 293 * @since 1.0.6 279 *280 294 */ 281 295 public function plugin_action_links( $links ) { … … 295 309 * Adds a nonce for AJAX calculation requests 296 310 * 311 * @param string $form_elements Form elements to filter. 312 * 297 313 * @since 1.0.6 298 *299 314 */ 300 315 public function nonce_output( $form_elements ) { … … 307 322 * Filter that outputs "Powered by:" link (only if admin opted in) 308 323 * 324 * @param string $form_elements Form elements to filter. 325 * 309 326 * @since 1.0.1 310 *311 327 */ 312 328 public function powered_by_output( $form_elements ) { … … 320 336 * 321 337 * @since 1.0.6 322 *323 338 */ 324 339 public function promo_pause() { 325 // Make sure the AJAX request was sent by an authorized user 340 // Make sure the AJAX request was sent by an authorized user. 326 341 if ( current_user_can( 'manage_options' ) ) { 327 342 wpSettingsFramework\wpsf_set_setting( … … 335 350 'features', 336 351 'hide_promo_admin_notices_until', 337 date( 'Y-m-d', strtotime( '+2 days' ) )352 gmdate( 'Y-m-d', strtotime( '+2 days' ) ) 338 353 ); 339 354 wp_send_json( true ); … … 347 362 * 348 363 * @since 1.0.6 349 *350 364 */ 351 365 public function promo_disable() { 352 // Make sure the AJAX request was sent by an authorized user 366 // Make sure the AJAX request was sent by an authorized user. 353 367 if ( current_user_can( 'manage_options' ) ) { 354 368 wpSettingsFramework\wpsf_set_setting( … … 368 382 * 369 383 * @since 1.0.0 370 *371 384 */ 372 385 public function pro_notice() { 373 386 if ( ! current_user_can( 'manage_options' ) ) { 374 // Only show to admins 387 // Only show to admins. 375 388 return; 376 389 } … … 390 403 ) 391 404 ) > time() ) { 392 // Notifications temporarily dismissed 405 // Notifications temporarily dismissed. 393 406 return; 394 407 } 395 408 if ( 2 === (int) $hide_option ) { 396 // Notifications permanently dismissed 409 // Notifications permanently dismissed. 397 410 return; 398 411 } … … 420 433 * 421 434 * @since 1.0.6 422 *423 435 */ 424 436 public function settings_menu() { … … 436 448 * Display a dialog to generate a "calculation" field in the form 437 449 * 438 * @param WPCF7_ContactForm $contact_form 439 * @param array $options440 * @since 1.0.0441 * 450 * @param WPCF7_ContactForm $contact_form The contact form. 451 * @param array $options Tag generator options. 452 * 453 * @since 1.0.0 442 454 */ 443 455 public function calculation_tag_generator( $contact_form, $options ) { … … 452 464 * Process "calculation" form tags 453 465 * 454 * @param WPCF7_FormTag $tag 466 * @param WPCF7_FormTag $tag The form tag to process. 467 * 455 468 * @return string 456 * @since 1.0.0457 * 469 * 470 * @since 1.0.0 458 471 */ 459 472 public function calculation_tag_handler( $tag ) { … … 540 553 * Display a dialog to generate a "calculate" button in the form 541 554 * 542 * @param WPCF7_ContactForm $contact_form 543 * @param array $options 544 * @return string 545 * @since 1.0.0 546 * 555 * @param WPCF7_ContactForm $contact_form The CF7 contact form. 556 * @param array $options Tag generator options. 557 * 558 * @since 1.0.0 547 559 */ 548 560 public function calculate_button_tag_generator( $contact_form, $options ) { … … 557 569 * Process "calculate" button tags 558 570 * 559 * @param WPCF7_FormTag $tag 571 * @param WPCF7_FormTag $tag The form tag to process. 572 * 560 573 * @return string 561 * @since 1.0.0562 * 574 * 575 * @since 1.0.0 563 576 */ 564 577 public function calculate_button_tag_handler( $tag ) { … … 591 604 * 592 605 * @since 1.0.0 593 *594 606 */ 595 607 public function ajax_calculate() { 596 $r = array(); // Return values will be stored here 608 $r = array(); // Return values will be stored here. 597 609 $input = array(); 598 610 … … 603 615 ) 604 616 ) { 605 // Do not process without a valid nonce 617 // Do not process without a valid nonce. 606 618 return; 607 619 } … … 624 636 * Calculate all "calculation" values for a given form 625 637 * 626 * @param WPCF7_ContactForm $form 627 * @param array $input 638 * @param WPCF7_ContactForm $form The CF7 contact form. 639 * @param string[] $input Sanitized POST input values. 640 * 628 641 * @return array 629 * @since 1.0.0630 * 642 * 643 * @since 1.0.0 631 644 */ 632 645 public function calculate_form( $form, $input ) { 633 $r = array(); // Return values will be stored here 646 $r = array(); // Return values will be stored here. 634 647 $tags = $form->scan_form_tags(); 635 648 foreach ( $tags as $tag ) { … … 657 670 * 658 671 * @since 1.0.0 659 *660 672 */ 661 673 public function intercept_submit() { … … 666 678 ) 667 679 ) { 668 // Do not process without a valid nonce 680 // Do not process without a valid nonce. 669 681 return; 670 682 } … … 694 706 * Extracts attributes (such as "min", "max" and "precision") from a CF7 tag 695 707 * 696 * @param WPCF7_FormTag $tag 708 * @param WPCF7_FormTag $tag The form tag to process. 697 709 * @return array 698 710 * @since 1.0.0 699 *700 711 */ 701 712 private function extract_options( $tag ) { … … 715 726 * Calculate the value of a "calculation" field based on user input 716 727 * 717 * @param WPCF7_ContactForm $form 718 * @param string $values 719 * @param array $input 728 * @param WPCF7_ContactForm $form The CF7 contact form. 729 * @param string|array $values Expression(s) to calculate. 730 * @param array $input Sanitized POST input values. 731 * @param array $options Modifier options - "min", "max", and "precision". 720 732 * @return float 721 733 * @since 1.0.0 722 *723 734 */ 724 735 private function calculate_equation( $form, $values, $input, $options = array() ) { … … 734 745 $expression = $values; 735 746 736 // Order input variables from longest to shortest names 747 // Order input variables from longest to shortest names. 737 748 $keys = array_keys( $input ); 738 749 739 // Handle checkbox groups with nothing selected 750 // Handle checkbox groups with nothing selected. 740 751 $tags = $form->scan_form_tags(); 741 752 foreach ( $tags as $tag ) { … … 749 760 usort( $keys, array( $this, 'sort_by_length_helper' ) ); 750 761 751 // Replace input variables in equation 762 // Replace input variables in equation. 752 763 foreach ( $keys as $key ) { 753 764 if ( is_array( $input[ $key ] ) ) { … … 756 767 $input[ $key ] = array_shift( $input[ $key ] ); 757 768 } else { 758 // Sum values 769 // Sum values. 759 770 $sum = 0; 760 771 foreach ( $input[ $key ] as $value ) { … … 767 778 } 768 779 if ( preg_match( '/[0-9]{4}\-[0-9]{2}-[0-9]{2}/', $input[ $key ] ) ) { 769 // Date 780 // Date variable. 770 781 $days = intval( strtotime( $input[ $key ] . 'T00:00:00 UTC' ) / 86400 ); 771 782 $expression = preg_replace( … … 776 787 $expression = str_replace( '###RPLC###', $days, $expression ); 777 788 } else { 778 // Not date789 // Not a date variable. 779 790 if ( is_array( $input[ $key ] ) ) { 780 // Sum values (for checkboxes) 791 // Sum values (for checkboxes). 781 792 $num = array_sum( $input[ $key ] ); 782 793 } elseif ( is_numeric( $input[ $key ] ) ) { … … 786 797 } 787 798 788 // Handle negative numbers 799 // Handle negative numbers. 789 800 if ( $num < 0 ) { 790 801 $num = ' (' . $num . ') '; … … 799 810 } 800 811 801 // Fix nested parentheses bug 812 // Fix nested parentheses bug. 802 813 while ( preg_match( '/\(\s*\(/', $expression ) ) { 803 814 $expression = preg_replace( '/\(\s*\(/', '(1*( ', $expression ); 804 815 } 805 816 806 // Calculate 817 // Calculate. 807 818 $calculator = PVBCalculator::create(); 808 819 try { … … 812 823 } 813 824 814 // Apply minimum 825 // Apply minimum. 815 826 if ( isset( $options['min'] ) && is_numeric( $options['min'] ) ) { 816 827 $r = max( $r, $options['min'] ); 817 828 } 818 829 819 // Apply maximum 830 // Apply maximum. 820 831 if ( isset( $options['max'] ) && is_numeric( $options['max'] ) ) { 821 832 $r = min( $r, $options['max'] ); 822 833 } 823 834 824 // Apply rounding 835 // Apply rounding. 825 836 if ( isset( $options['precision'] ) && is_numeric( $options['precision'] ) ) { 826 837 $r = round( $r, $options['precision'] ); … … 835 846 * @return boolean 836 847 * @since 1.0.0 837 *838 848 */ 839 849 private function check_cf7() { … … 846 856 * @return boolean 847 857 * @since 1.0.9 848 *849 858 */ 850 859 private function check_pro() { … … 856 865 * 857 866 * @param string $view Name of the file in the views subdirectory of the plugin. 858 * @param array $data Arguments to make available to the view as PHP variables. 859 * @since 1.0.0 860 * 867 * @param array $data Arguments to make available to the view as PHP variables. 868 * @since 1.0.0 861 869 */ 862 870 private function load_view( $view, $data = array() ) { … … 871 879 872 880 /** 873 * 874 * @since 1.0.0 875 * 881 * Helper function to sort by length. 882 * Returns difference in length for two strings. 883 * 884 * @param string $a First string. 885 * @param string $b Second string. 886 * 887 * @return int 888 * 889 * @since 1.0.0 876 890 */ 877 891 private function sort_by_length_helper( $a, $b ) { -
pvb-contact-form-7-calculator/trunk/lib/wpSettingsFramework/assets/js/main.js
r2149454 r2946744 1 /** 2 * File: main.js 3 * 4 * Provides support functions for the settings framework. 5 * 6 * @since 1.0.6 7 * 8 * @package PVBCF7Calculator 9 */ 10 1 11 (function($, document) { 2 12 … … 12 22 on_ready: function() { 13 23 14 // on ready stuff here15 24 wpsf.cache(); 16 25 wpsf.trigger_dynamic_fields(); … … 39 48 function(){ 40 49 41 // Set tab link active class 50 // Set tab link active class. 42 51 wpsf.els.tab_links.removeClass( 'nav-tab-active' ); 43 52 $( this ).addClass( 'nav-tab-active' ); 44 53 45 // Show tab 54 // Show tab. 46 55 var tab_id = $( this ).attr( 'href' ); 47 56 … … 95 104 setup_groups: function() { 96 105 97 // add row106 // Add row. 98 107 99 108 $( document ).on( … … 118 127 ); 119 128 120 // remove row129 // Remove row. 121 130 122 131 $( document ).on( -
pvb-contact-form-7-calculator/trunk/lib/wpSettingsFramework/class-wordpresssettingsframework.php
r2269783 r2946744 1 1 <?php 2 /** 3 * File: class-wordpresssettingsframework.php 4 * 5 * Defines the WordPressSettingsFramework class. 6 * 7 * @since 1.0.6 8 * 9 * @package PVBCF7Calculator 10 */ 11 2 12 namespace PVBCF7Calculator\lib\wpSettingsFramework; 3 13 … … 16 26 class WordPressSettingsFramework { 17 27 /** 28 * Settings wrapper 29 * 18 30 * @access private 19 31 * @var array … … 22 34 23 35 /** 36 * Settings 37 * 24 38 * @access private 25 39 * @var array … … 28 42 29 43 /** 44 * Tabs 45 * 30 46 * @access private 31 47 * @var array … … 34 50 35 51 /** 52 * Option group 53 * 36 54 * @access private 37 55 * @var string … … 40 58 41 59 /** 60 * Settings page 61 * 42 62 * @access private 43 63 * @var array … … 46 66 47 67 /** 68 * Options path 69 * 48 70 * @access private 49 71 * @var string … … 52 74 53 75 /** 76 * Options URL 77 * 54 78 * @access private 55 79 * @var string … … 58 82 59 83 /** 84 * Setting defaults 85 * 60 86 * @access protected 61 87 * @var array … … 76 102 * WordPressSettingsFramework constructor. 77 103 * 78 * @param string $settings_file 79 * @param bool $option_group104 * @param string $settings_file The file defining the settings. 105 * @param string $option_group Option group. 80 106 */ 81 107 public function __construct( $settings_file, $option_group = false ) { … … 131 157 } 132 158 133 // If "sections" is set, this settings group probably has tabs 159 // If "sections" is set, this settings group probably has tabs. 134 160 if ( isset( $this->settings_wrapper['sections'] ) ) { 135 161 $this->tabs = ( isset( $this->settings_wrapper['tabs'] ) ) ? $this->settings_wrapper['tabs'] : array(); 136 162 $this->settings = $this->settings_wrapper['sections']; 137 // If not, it's probably just an array of settings 163 // If not, it's probably just an array of settings. 138 164 } else { 139 165 $this->settings = $this->settings_wrapper; … … 163 189 * Add Settings Page 164 190 * 165 * @param array $args 191 * @param array $args Parameters for the settings page. 166 192 */ 167 193 public function add_settings_page( $args ) { … … 204 230 * Settings Page Content 205 231 */ 206 207 232 public function settings_page_content() { 208 233 if ( ! current_user_can( $this->settings_page['capability'] ) ) { … … 214 239 <h2><?php echo esc_html( $this->settings_page['title'] ); ?></h2> 215 240 <?php 216 // Output your settings form 241 // Output your settings form. 217 242 $this->settings(); 218 243 ?> … … 233 258 */ 234 259 public function admin_enqueue_scripts() { 235 // scripts260 // Register and enqueue scripts. 236 261 wp_register_script( 237 262 'jquery-ui-timepicker', … … 258 283 wp_enqueue_script( 'wpsf' ); 259 284 260 // styles285 // Register and enqueue styles. 261 286 wp_register_style( 262 287 'jquery-ui-timepicker', … … 288 313 * Adds a filter for settings validation. 289 314 * 290 * @param $input315 * @param mixed $input Input to validate. 291 316 * 292 317 * @return array … … 299 324 * Displays the "section_description" if specified in $this->settings 300 325 * 301 * @param array callback args from add_settings_section()326 * @param array $args Callback args from add_settings_section(). 302 327 */ 303 328 public function section_intro( $args ) { … … 357 382 * Usort callback. Sorts $this->settings by "section_order" 358 383 * 359 * @param $a360 * @param $b384 * @param mixed $a First element to compare. 385 * @param mixed $b Second element to compare. 361 386 * 362 387 * @return bool … … 373 398 * Generates the HTML output of the settings fields 374 399 * 375 * @param array callback args from add_settings_field()400 * @param array $args Callback args from add_settings_field(). 376 401 */ 377 402 public function generate_setting( $args ) { … … 399 424 * Do field method, if it exists 400 425 * 401 * @param array $args 426 * @param array $args Field method parameters. 402 427 */ 403 428 public function do_field_method( $args ) { … … 412 437 * Generate: Text field 413 438 * 414 * @param array $args 439 * @param array $args Text field parameters. 415 440 */ 416 441 public function generate_text_field( $args ) { … … 427 452 * Generate: Number field 428 453 * 429 * @param array $args 454 * @param array $args Number field parameters. 430 455 */ 431 456 public function generate_number_field( $args ) { … … 442 467 * Generate: Time field 443 468 * 444 * @param array $args 469 * @param array $args Time field parameters. 445 470 */ 446 471 public function generate_time_field( $args ) { … … 460 485 * Generate: Date field 461 486 * 462 * @param array $args 487 * @param array $args Date field parameters. 463 488 */ 464 489 public function generate_date_field( $args ) { … … 479 504 * Generates a table of subfields, and a javascript template for create new repeatable rows 480 505 * 481 * @param array $args 506 * @param array $args Group field parameters. 482 507 */ 483 508 public function generate_group_field( $args ) { … … 508 533 * Generate group row template 509 534 * 510 * @param array $args Field arguments 511 * @param bool $blank Blank values 512 * @param int $row Iterator 535 * @param array $args Field arguments. 536 * @param bool $blank Blank values. 537 * @param int $row Iterator. 513 538 * 514 539 * @return string|bool … … 529 554 $subfield = wp_parse_args( $subfield, $this->setting_defaults ); 530 555 531 $subfield['value'] = ( $blank ) ? '' : isset( $args['value'][ $row ][ $subfield['id'] ] ) ? $args['value'][ $row ][ $subfield['id'] ] : ''; 556 $subfield['value'] = ( $blank ) ? 557 '' : 558 ( isset( $args['value'][ $row ][ $subfield['id'] ] ) ? $args['value'][ $row ][ $subfield['id'] ] : '' ); 532 559 $subfield['name'] = sprintf( '%s[%d][%s]', $args['name'], $row, $subfield['id'] ); 533 560 $subfield['id'] = sprintf( '%s_%d_%s', $args['id'], $row, $subfield['id'] ); … … 562 589 * Generate: Select field 563 590 * 564 * @param array $args 591 * @param array $args Select field parameters. 565 592 */ 566 593 public function generate_select_field( $args ) { … … 590 617 * Generate: Password field 591 618 * 592 * @param array $args 619 * @param array $args Password field parameters. 593 620 */ 594 621 public function generate_password_field( $args ) { … … 607 634 * Generate: Textarea field 608 635 * 609 * @param array $args 636 * @param array $args Textarea field parameters. 610 637 */ 611 638 public function generate_textarea_field( $args ) { … … 624 651 * Generate: Radio field 625 652 * 626 * @param array $args 653 * @param array $args Radio field parameters. 627 654 */ 628 655 public function generate_radio_field( $args ) { … … 650 677 * Generate: Checkbox field 651 678 * 652 * @param array $args 679 * @param array $args Checkbox field parameters. 653 680 */ 654 681 public function generate_checkbox_field( $args ) { … … 668 695 * Generate: Checkboxes field 669 696 * 670 * @param array $args 697 * @param array $args Checkbox field parameters. 671 698 */ 672 699 public function generate_checkboxes_field( $args ) { … … 698 725 * Generate: Color field 699 726 * 700 * @param array $args 727 * @param array $args Color field parameters. 701 728 */ 702 729 public function generate_color_field( $args ) { … … 742 769 * Generate: File field 743 770 * 744 * @param array $args 771 * @param array $args File field parameters. 745 772 */ 746 773 public function generate_file_field( $args ) { … … 786 813 * Generate: Editor field 787 814 * 788 * @param array $args 815 * @param array $args Editor field parameters. 789 816 */ 790 817 public function generate_editor_field( $args ) { … … 797 824 * Generate: Custom field 798 825 * 799 * @param array $args 826 * @param array $args Custom field parameters. 800 827 */ 801 828 public function generate_custom_field( $args ) { … … 806 833 * Generate: Multi Inputs field 807 834 * 808 * @param array $args 835 * @param array $args Multi Inputs field parameters. 809 836 */ 810 837 public function generate_multiinputs_field( $args ) { … … 842 869 * Generate: Field ID 843 870 * 844 * @param mixed $id 871 * @param mixed $id Setting ID. 845 872 * 846 873 * @return string … … 853 880 * Generate: Description 854 881 * 855 * @param mixed $description 882 * @param mixed $description Description text. 856 883 */ 857 884 public function generate_description( $description ) { … … 998 1025 } 999 1026 1027 /** 1028 * Returns list of allowed tags for the custom field. 1029 */ 1000 1030 private function expanded_alowed_tags() { 1001 1031 $my_allowed = wp_kses_allowed_html( 'post' ); 1002 // iframe 1032 1033 // Iframe. 1003 1034 $my_allowed['iframe'] = array( 1004 1035 'src' => array(), … … 1008 1039 'allowfullscreen' => array(), 1009 1040 ); 1010 // form fields - input 1041 1042 // Form fields - input. 1011 1043 $my_allowed['input'] = array( 1012 1044 'class' => array(), … … 1016 1048 'type' => array(), 1017 1049 ); 1018 // select 1050 1051 // Select. 1019 1052 $my_allowed['select'] = array( 1020 1053 'class' => array(), … … 1024 1057 'type' => array(), 1025 1058 ); 1026 // select options 1059 1060 // Select options. 1027 1061 $my_allowed['option'] = array( 1028 1062 'selected' => array(), 1029 1063 ); 1030 // style 1064 1065 // Style. 1031 1066 $my_allowed['style'] = array( 1032 1067 'types' => array(), 1033 1068 ); 1034 // script 1069 1070 // Script. 1035 1071 $my_allowed['script'] = array( 1036 1072 'type' => array(), … … 1045 1081 * Get a setting from an option group 1046 1082 * 1047 * @param string $option_group 1048 * @param string $section_id May also be prefixed with tab ID1049 * @param string $field_id 1083 * @param string $option_group The option group. 1084 * @param string $section_id May also be prefixed with tab ID. 1085 * @param string $field_id The field ID. 1050 1086 * 1051 1087 * @return mixed … … 1063 1099 * Delete all the saved settings from a settings file/option group 1064 1100 * 1065 * @param string $option_group 1101 * @param string $option_group The option group. 1066 1102 */ 1067 1103 function wpsf_delete_settings( $option_group ) { … … 1073 1109 * the WordPressSettingsFramework class 1074 1110 * 1075 * @param string $option_group 1076 * @param string $section_id May also be prefixed with tab ID 1077 * @param string $field_id 1078 * @param mixed $value 1079 * 1111 * @param string $option_group The option group. 1112 * @param string $section_id May also be prefixed with tab ID. 1113 * @param string $field_id The field ID. 1114 * @param mixed $value Setting value. 1080 1115 */ 1081 1116 function wpsf_set_setting( -
pvb-contact-form-7-calculator/trunk/pvb-cf7-calculator.php
r2269783 r2946744 1 1 <?php 2 /* 3 Plugin Name: PVB Contact Form 7 Calculator 4 Plugin URI: https://bossakov.eu/product/pvb-contact-form-7-calculator-pro/ 5 Description: Lets you easily turn any Contact Form 7 form into a quote or price estimate calculator. 6 Version: 1.0.10 7 Author: Petko Bossakov 8 Author URI: http://bossakov.eu/ 9 License: GPLv3 or later 10 Text Domain: pvb-cf7-calculator 11 Domain Path: /languages 12 */ 2 /** 3 * PVB Contact Form 7 Calculator 4 * 5 * @package PVBCF7Calculator 6 * @author Petko Bossakov 7 * @copyright 2018 Petko Bossakov 8 * @license GPL-3.0-or-later 9 * 10 * @wordpress-plugin 11 * Plugin Name: PVB Contact Form 7 Calculator 12 * Plugin URI: https://bossakov.eu/product/pvb-contact-form-7-calculator-pro/ 13 * Description: Lets you easily turn any Contact Form 7 form into a quote or price estimate calculator. 14 * Version: 1.0.11 15 * Author: Petko Bossakov 16 * Author URI: http://bossakov.eu/ 17 * License: GPLv3 or later 18 * Text Domain: pvb-cf7-calculator 19 * Domain Path: /languages 20 */ 13 21 14 22 namespace PVBCF7Calculator; … … 20 28 } 21 29 22 // Do not proceed if the premium version of the plugin is active 30 // Do not proceed if the premium version of the plugin is active. 23 31 if ( ! defined( 'PVB_CF7_CALCULATOR_PRO_ACTIVE' ) ) { 24 32 require_once 'autoload.php'; -
pvb-contact-form-7-calculator/trunk/readme.txt
r2570143 r2946744 4 4 Tags: calculator, cost calculator, price calculator, loan calculator, mortgage calculator, Contact Form 7, PayPal, Stripe 5 5 Requires at least: 4.9.2 6 Tested up to: 5.86 Tested up to: 6.3 7 7 Requires PHP: 5.6 8 8 Stable tag: trunk … … 125 125 == Changelog == 126 126 127 = 1.0.11 = 128 * Fix: PHP 8 fatal error 129 * Fix: Calculate button shortcode issues 130 * Code formatting and documentation updates 131 * Tested for compatibility with WordPress 6.3 132 127 133 = 1.0.10 = 128 134 * Fix: error when adding negative numbers -
pvb-contact-form-7-calculator/trunk/views/tag-generator-calculate-button.php
r2149454 r2946744 19 19 <table class="form-table"> 20 20 <tbody> 21 <tr> 22 <th scope="row"> 23 <label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php esc_html_e( 'Name', 'pvb-cf7-calculator' ); ?></label> 24 </th> 25 <td> 26 <input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /> 27 </td> 28 </tr> 21 29 <tr> 22 30 <th scope="row">
Note: See TracChangeset
for help on using the changeset viewer.