Plugin Directory

Changeset 2946744


Ignore:
Timestamp:
08/02/2023 05:04:30 PM (3 years ago)
Author:
pbosakov
Message:

1.0.11

  • Fix: PHP 8 fatal error
  • Fix: Calculate button shortcode issues
  • Code formatting and documentation updates
  • Tested for compatibility with WordPress 6.3
Location:
pvb-contact-form-7-calculator/trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • pvb-contact-form-7-calculator/trunk/autoload.php

    r2149454 r2946744  
    11<?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
    212/**
    313 * 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 */
    119function pvbCf7CalculatorPoweredByEnable(aElm, msgWait, msgOK) {
    220    jQuery( aElm ).text( msgWait );
     
    1028}
    1129
     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 */
    1239function pvbCf7CalculatorHideAdminNotices(period, target) {
    1340    jQuery( target ).closest( '.notice' ).remove();
    1441
    1542    if (period == 1) {
    16         // Dismiss temporarily
     43        // Dismiss temporarily.
    1744        jQuery.post( ajaxurl, {action: 'pvb_promo_pause'} );
    1845    } else {
    19         // Dismiss permanently
     46        // Dismiss permanently.
    2047        jQuery.post( ajaxurl, {action: 'pvb_promo_disable'} );
    2148    }
  • 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 */
    116function cf7Calculate($form) {
    2     // Retrieve form ID
     17    // Retrieve form ID.
    318    var form_id   = null;
    419    var $form_div = $form.closest( 'div.wpcf7' );
    5     if (!$form_div.length) {
     20    if ( ! $form_div.length) {
    621        return;
    722    }
     
    1732    var $button = $form_div.find( '.cf7-calculate_button' );
    1833
    19     // Retrieve form values
     34    // Retrieve form values.
    2035    $form = $button.closest( 'form' );
    21     if (!$form.length) {
     36    if ( ! $form.length) {
    2237        return;
    2338    }
    2439    var postdata = $form.serializeArray();
    2540
    26     // Add form ID to posted data
     41    // Add form ID to posted data.
    2742    postdata.push( {name: 'action', value: 'pvb_calculate'} );
    2843    postdata.push( {name: 'pvb_form_id', value: form_id} );
    2944
    30     // Send data to server
     45    // Send data to server.
    3146    jQuery.post(
    3247        frontend_ajax_object.ajaxurl,
    3348        postdata,
    3449        function(r) {
    35             // Fill fields with results
     50            // Fill fields with results.
    3651            if (r instanceof Object) {
    3752                var nameLowercaseCompare = function() {
     
    4257                }
    4358            }
    44             // Enable button again
     59            // Enable button again.
    4560            if ($button) {
    4661                $button.prop( 'disabled', false );
     
    5065    ).fail(
    5166        function() {
    52                 // Enable button again
     67                // Enable button again.
    5368                $button.prop( 'disabled', false );
    5469                $form.trigger( 'wpcf7calculatefail' );
     
    5772}
    5873
    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.
     75jQuery(
     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' ) );
    6988            }
    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  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math\Exception;
     
    1018
    1119    /**
     20     * Division by zero.
     21     *
    1222     * @return DivisionByZeroException
    1323     */
     
    1727
    1828    /**
     29     * Division by zero when defining a rational number.
     30     *
    1931     * @return DivisionByZeroException
    2032     */
  • pvb-contact-form-7-calculator/trunk/lib/Math/Exception/class-integeroverflowexception.php

    r2149454 r2946744  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math\Exception;
     
    1220
    1321    /**
    14      * @param BigInteger $value
     22     * Overflow when converting to integer.
     23     *
     24     * @param BigInteger $value The value that is out of range.
    1525     *
    1626     * @return IntegerOverflowException
  • pvb-contact-form-7-calculator/trunk/lib/Math/Exception/class-mathexception.php

    r2149454 r2946744  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math\Exception;
  • pvb-contact-form-7-calculator/trunk/lib/Math/Exception/class-numberformatexception.php

    r2149454 r2946744  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math\Exception;
  • pvb-contact-form-7-calculator/trunk/lib/Math/Exception/class-roundingnecessaryexception.php

    r2149454 r2946744  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math\Exception;
     
    1018
    1119    /**
     20     * Rounding necessary (scale mismatch exception).
     21     *
    1222     * @return RoundingNecessaryException
    1323     */
  • pvb-contact-form-7-calculator/trunk/lib/Math/Internal/Calculator/class-bcmathcalculator.php

    r2149454 r2946744  
    11<?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
    212namespace PVBCF7Calculator\lib\Math\Internal\Calculator;
    313
     
    1222
    1323    /**
    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.
    1530     */
    1631    public function add( $a, $b ) {
     
    1934
    2035    /**
    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.
    2242     */
    2343    public function sub( $a, $b ) {
     
    2646
    2747    /**
    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.
    2954     */
    3055    public function mul( $a, $b ) {
     
    3358
    3459    /**
    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.
    3666     */
    3767    public function div_q( $a, $b ) {
     
    4070
    4171    /**
    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.
    4378     */
    4479    public function div_r( $a, $b ) {
     
    4782
    4883    /**
    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.
    5090     */
    5191    public function div_q_r( $a, $b ) {
     
    5393        $r = bcmod( $a, $b );
    5494
    55         return [ $q, $r ];
     95        return array( $q, $r );
    5696    }
    5797
    5898    /**
    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.
    60105     */
    61106    public function pow( $a, $e ) {
  • pvb-contact-form-7-calculator/trunk/lib/Math/Internal/Calculator/class-gmpcalculator.php

    r2149454 r2946744  
    11<?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
    212namespace PVBCF7Calculator\lib\Math\Internal\Calculator;
    313
     
    1222
    1323    /**
    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.
    1530     */
    1631    public function add( $a, $b ) {
     
    1934
    2035    /**
    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.
    2242     */
    2343    public function sub( $a, $b ) {
     
    2646
    2747    /**
    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.
    2954     */
    3055    public function mul( $a, $b ) {
     
    3358
    3459    /**
    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.
    3666     */
    3767    public function div_q( $a, $b ) {
     
    4070
    4171    /**
    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.
    4378     */
    4479    public function div_r( $a, $b ) {
     
    4782
    4883    /**
    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.
    5090     */
    5191    public function div_q_r( $a, $b ) {
    5292        list($q, $r) = gmp_div_qr( $a, $b );
    5393
    54         return [
     94        return array(
    5595            gmp_strval( $q ),
    5696            gmp_strval( $r ),
    57         ];
     97        );
    5898    }
    5999
    60100    /**
    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.
    62107     */
    63108    public function pow( $a, $e ) {
     
    66111
    67112    /**
    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.
    69122     */
    70123    public function gcd( $a, $b ) {
  • pvb-contact-form-7-calculator/trunk/lib/Math/Internal/Calculator/class-nativecalculator.php

    r2149454 r2946744  
    11<?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
    212namespace PVBCF7Calculator\lib\Math\Internal\Calculator;
    313
     
    4555
    4656    /**
    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.
    4863     */
    4964    public function add( $a, $b ) {
     
    7691
    7792    /**
    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.
    7999     */
    80100    public function sub( $a, $b ) {
     
    83103
    84104    /**
    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.
    86111     */
    87112    public function mul( $a, $b ) {
     
    122147
    123148    /**
    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.
    125155     */
    126156    public function div_q( $a, $b ) {
     
    129159
    130160    /**
    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.
    132167     */
    133168    public function div_r( $a, $b ) {
     
    136171
    137172    /**
    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.
    139179     */
    140180    public function div_q_r( $a, $b ) {
    141181        if ( '0' === $a ) {
    142             return [ '0', '0' ];
     182            return array( '0', '0' );
    143183        }
    144184
    145185        if ( $a === $b ) {
    146             return [ '1', '0' ];
     186            return array( '1', '0' );
    147187        }
    148188
    149189        if ( '1' === $b ) {
    150             return [ $a, '0' ];
     190            return array( $a, '0' );
    151191        }
    152192
    153193        if ( '-1' === $b ) {
    154             return [ $this->neg( $a ), '0' ];
     194            return array( $this->neg( $a ), '0' );
    155195        }
    156196
     
    167207            $r = (string) $r;
    168208
    169             return [ $q, $r ];
     209            return array( $q, $r );
    170210        }
    171211
     
    180220        }
    181221
    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.
    187232     */
    188233    public function pow( $a, $e ) {
     
    352397
    353398        if ( -1 === $cmp ) {
    354             return [ '0', $a ];
    355         }
    356 
    357         // we now know that a > b && x >= y
    358 
    359         $q = '0'; // quotient
    360         $r = $a; // remainder
    361         $z = $y; // focus length, always $y or $y+1
     399            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).
    362407
    363408        for ( ;; ) {
     
    367412
    368413            if ( -1 === $cmp ) {
    369                 if ( $z === $x ) { // remainder < dividend
     414                if ( $z === $x ) { // Remainder < dividend.
    370415                    break;
    371416                }
     
    381426            $r = $a;
    382427
    383             if ( '0' === $r ) { // remainder == 0
     428            if ( '0' === $r ) { // Remainder == 0.
    384429                break;
    385430            }
     
    387432            $x = strlen( $a );
    388433
    389             if ( $x < $y ) { // remainder < dividend
     434            if ( $x < $y ) { // Remainder < dividend.
    390435                break;
    391436            }
     
    394439        }
    395440
    396         return [ $q, $r ];
     441        return array( $q, $r );
    397442    }
    398443
     
    442487     * @return int The length of both strings.
    443488     */
    444     private function pad( & $a, & $b, $x, $y ) {
     489    private function pad( &$a, &$b, $x, $y ) {
    445490        if ( $x === $y ) {
    446491            return $x;
  • pvb-contact-form-7-calculator/trunk/lib/Math/Internal/class-calculator.php

    r2149454 r2946744  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math\Internal;
     
    93101     * @return void
    94102     */
    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 ) {
    96104        $a_neg = ( '-' === $a[0] );
    97105        $b_neg = ( '-' === $b[0] );
  • pvb-contact-form-7-calculator/trunk/lib/Math/class-bigdecimal.php

    r2157957 r2946744  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math;
     
    4755     * Creates a BigDecimal of the given value.
    4856     *
    49      * @param BigNumber|number|string $value
     57     * @param BigNumber|number|string $value Value to convert.
    5058     *
    5159     * @return BigDecimal
     
    208216     *
    209217     * @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.
    211219     */
    212220    public function dividedBy( $that, $scale = null, $rounding_mode = RoundingMode::UNNECESSARY ) {
     
    244252     * @return BigDecimal The result.
    245253     *
    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.
    248255     */
    249256    public function exactlyDividedBy( $that ) {
     
    261268        $calculator = Calculator::get();
    262269
    263         foreach ( [ 5, 2 ] as $prime ) {
     270        foreach ( array( 5, 2 ) as $prime ) {
    264271            for ( ;; ) {
    265272                $last_digit = (int) substr( $d, -1 );
     
    319326     * @return BigDecimal The quotient.
    320327     *
    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.
    322329     */
    323330    public function quotient( $that ) {
     
    345352     * @return BigDecimal The remainder.
    346353     *
    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.
    348355     */
    349356    public function remainder( $that ) {
     
    373380     * @return BigDecimal[] An array containing the quotient and the remainder.
    374381     *
    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.
    376383     */
    377384    public function quotientAndRemainder( $that ) {
     
    394401        $remainder = new BigDecimal( $remainder, $scale );
    395402
    396         return [ $quotient, $remainder ];
     403        return array( $quotient, $remainder );
    397404    }
    398405
     
    400407     * Returns a copy of this BigDecimal with the decimal point moved $n places to the left.
    401408     *
    402      * @param int $n
     409     * @param int $n Number of places to move the decimal point.
    403410     *
    404411     * @return BigDecimal
     
    419426     * Returns a copy of this BigDecimal with the decimal point moved $n places to the right.
    420427     *
    421      * @param int $n
     428     * @param int $n Number of places to move the decimal point.
    422429     *
    423430     * @return BigDecimal
     
    496503
    497504    /**
    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.
    499512     */
    500513    public function compareTo( $that ) {
     
    522535
    523536    /**
     537     * Returns the unscaled value.
     538     *
    524539     * @return BigInteger
    525540     */
     
    529544
    530545    /**
     546     * Returns the scale.
     547     *
    531548     * @return int
    532549     */
     
    602619
    603620    /**
    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.
    605630     */
    606631    public function toScale( $scale, $rounding_mode = RoundingMode::UNNECESSARY ) {
     
    655680     * @internal
    656681     *
    657      * @param string $value
     682     * @param string $value Value to unserialize.
    658683     *
    659684     * @return void
    660685     *
    661      * @throws \LogicException
     686     * @throws \LogicException If called directly.
    662687     */
    663688    public function unserialize( $value ) {
     
    682707     * @return void
    683708     */
    684     private function scaleValues( $x, $y, & $a, & $b ) {
     709    private function scaleValues( $x, $y, &$a, &$b ) {
    685710        $a = $x->value;
    686711        $b = $y->value;
     
    694719
    695720    /**
    696      * @param int $scale
     721     * Zero-pads the value up to $scale
     722     *
     723     * @param int $scale Minimum scale.
    697724     *
    698725     * @return string
  • pvb-contact-form-7-calculator/trunk/lib/Math/class-biginteger.php

    r2157957 r2946744  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math;
     
    3947     * Creates a BigInteger of the given value.
    4048     *
    41      * @param BigNumber|number|string $value
     49     * @param BigNumber|number|string $value Value to convert.
    4250     *
    4351     * @return BigInteger
     
    244252     * @return BigInteger The result.
    245253     *
    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.
    248256     */
    249257    public function dividedBy( $that, int $rounding_mode = RoundingMode::UNNECESSARY ) {
     
    360368        $remainder = $r[1];
    361369
    362         return [
     370        return array(
    363371            new BigInteger( $quotient ),
    364372            new BigInteger( $remainder ),
    365         ];
     373        );
    366374    }
    367375
     
    410418
    411419    /**
    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.
    413427     */
    414428    public function compareTo( $that ) {
     
    451465
    452466    /**
    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.
    454476     */
    455477    public function toScale( $scale, $rounding_mode = RoundingMode::UNNECESSARY ) {
     
    458480
    459481    /**
    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.
    461490     */
    462491    public function toInt() {
     
    478507     * Returns a string representation of this number in the given base.
    479508     *
    480      * @param int $base
     509     * @param int $base Base to use.
    481510     *
    482511     * @return string
     
    544573     * @internal
    545574     *
    546      * @param string $value
     575     * @param string $value Value to unserialize.
    547576     *
    548577     * @return void
    549578     *
    550      * @throws \LogicException
     579     * @throws \LogicException If called directly.
    551580     */
    552581    public function unserialize( $value ) {
  • pvb-contact-form-7-calculator/trunk/lib/Math/class-bignumber.php

    r2149454 r2946744  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math;
     
    4452     * - strings containing only digits with an optional leading `+` or `-` sign are returned as BigInteger
    4553     *
    46      * @param BigNumber|number|string $value
     54     * @param BigNumber|number|string $value Value to convert.
    4755     *
    4856     * @return BigNumber
     
    121129     * @return static The minimum value.
    122130     *
    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.
    125132     */
    126133    public static function min( ...$values ) {
     
    150157     * @return static The maximum value.
    151158     *
    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.
    154160     */
    155161    public static function max( ...$values ) {
     
    201207     * Checks if this number is equal to the given one.
    202208     *
    203      * @param BigNumber|number|string $that
     209     * @param BigNumber|number|string $that Number to compare to.
    204210     *
    205211     * @return bool
     
    212218     * Checks if this number is strictly lower than the given one.
    213219     *
    214      * @param BigNumber|number|string $that
     220     * @param BigNumber|number|string $that Number to compare to.
    215221     *
    216222     * @return bool
     
    223229     * Checks if this number is lower than or equal to the given one.
    224230     *
    225      * @param BigNumber|number|string $that
     231     * @param BigNumber|number|string $that Number to compare to.
    226232     *
    227233     * @return bool
     
    234240     * Checks if this number is strictly greater than the given one.
    235241     *
    236      * @param BigNumber|number|string $that
     242     * @param BigNumber|number|string $that Number to compare to.
    237243     *
    238244     * @return bool
     
    245251     * Checks if this number is greater than or equal to the given one.
    246252     *
    247      * @param BigNumber|number|string $that
     253     * @param BigNumber|number|string $that Number to compare to.
    248254     *
    249255     * @return bool
     
    308314     * Compares this number to the given one.
    309315     *
    310      * @param BigNumber|number|string $that
     316     * @param BigNumber|number|string $that Number to compare to.
    311317     *
    312318     * @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  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math;
     
    5866     * Creates a BigRational of the given value.
    5967     *
    60      * @param BigNumber|number|string $value
     68     * @param BigNumber|number|string $value Value to convert.
    6169     *
    6270     * @return BigRational
     
    136144
    137145    /**
     146     * Returns the numerator.
     147     *
    138148     * @return BigInteger
    139149     */
     
    143153
    144154    /**
     155     * Returns the denominator.
     156     *
    145157     * @return BigInteger
    146158     */
     
    323335
    324336    /**
    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.
    326344     */
    327345    public function compareTo( $that ) {
     
    337355
    338356    /**
    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.
    340362     */
    341363    public function toBigInteger() {
     
    364386
    365387    /**
    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.
    367397     */
    368398    public function toScale( $scale, $rounding_mode = RoundingMode::UNNECESSARY ) {
     
    414444     * @internal
    415445     *
    416      * @param string $value
     446     * @param string $value Value to unserialize.
    417447     *
    418448     * @return void
    419449     *
    420      * @throws \LogicException
     450     * @throws \LogicException If called directly.
    421451     */
    422452    public function unserialize( $value ) {
  • pvb-contact-form-7-calculator/trunk/lib/Math/class-pvbcalculator.php

    r2149454 r2946744  
    11<?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
    212namespace PVBCF7Calculator\lib\Math;
    313
     
    616use \DatePeriod;
    717
     18/**
     19 * Provides support for custom functions when calculating expressions
     20 */
    821class PVBCalculator {
    922
    1023    /**
    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
    1734     */
    1835    private $tokenizer;
    1936
     37    /**
     38     * Proxy method to access protected constructors from sibling classes.
     39     *
     40     * @internal
     41     *
     42     * @return static
     43     */
    2044    public static function create() {
    2145        return new self( new Tokenizer() );
     
    2650     * Sets expression if provided.
    2751     * Sets default functions: sqrt(n), ln(n), log(a,b).
    28      * @param TokenizerInterface $tokenizer
     52     *
     53     * @param TokenizerInterface $tokenizer Tokenizer.
    2954     */
    3055    public function __construct( $tokenizer ) {
     
    4671            'fn_day',
    4772            function ( $timestamp ) {
    48                 return date( 'j', $timestamp * 86400 );
     73                return gmdate( 'j', $timestamp * 86400 );
    4974            }
    5075        );
     
    5277            'fn_month',
    5378            function ( $timestamp ) {
    54                 return date( 'n', $timestamp * 86400 );
     79                return gmdate( 'n', $timestamp * 86400 );
    5580            }
    5681        );
     
    5883            'fn_year',
    5984            function ( $timestamp ) {
    60                 return date( 'Y', $timestamp * 86400 );
     85                return gmdate( 'Y', $timestamp * 86400 );
    6186            }
    6287        );
     
    6489            'fn_day_of_year',
    6590            function ( $timestamp ) {
    66                 return date( 'z', $timestamp * 86400 );
     91                return gmdate( 'z', $timestamp * 86400 );
    6792            }
    6893        );
     
    7095            'fn_weekday',
    7196            function ( $timestamp ) {
    72                 return date( 'N', $timestamp * 86400 );
     97                return gmdate( 'N', $timestamp * 86400 );
    7398            }
    7499        );
     
    77102            function ( $timestamp1, $timestamp2 ) {
    78103                $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 holidays
     104                $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.
    81106
    82107                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 );
    85110                } 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 );
    88113                }
    89114                $to->modify( '+1 day' );
     
    110135
    111136    /**
    112      * @return  array
     137     * Returns the functions.
     138     *
     139     * @return array
    113140     */
    114141    public function get_functions() {
     
    117144
    118145    /**
    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).
    120149     * @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.
    122153     */
    123154    public function add_function( $name, $function ) {
     
    135166        $params_count = $reflection->getNumberOfRequiredParameters();
    136167
    137         $this->functions[ $name ] = [
     168        $this->functions[ $name ] = array(
    138169            'func'        => $function,
    139170            '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.
    145178     * @param callable $function Interpretation.
    146179     */
     
    151184
    152185    /**
    153      * @param  string $name Name of function.
     186     * Removes a function.
     187     *
     188     * @param string $name Name of function.
    154189     */
    155190    public function remove_function( $name ) {
     
    165200     * also known as Postfix Notation.
    166201     *
    167      * @param  array $tokens
     202     * @param  array $tokens Tokens to rearrange.
    168203     * @return \SplQueue
    169      * @throws \InvalidArgumentException
     204     * @throws \InvalidArgumentException If parentheses are misplaced.
    170205     */
    171206    private function get_reverse_polish_notation( $tokens ) {
     
    181216                $stack->push( $tokens[ $i ] );
    182217            } elseif ( Tokens::ARG_SEPARATOR === $tokens[ $i ] ) {
    183                 // checking whether stack contains left parenthesis (dirty hack)
     218                // Checks whether stack contains left parenthesis.
    184219                if ( substr_count( $stack->serialize(), Tokens::PAREN_LEFT ) === 0 ) {
    185                     throw new \InvalidArgumentException( 'Parenthesis are misplaced' );
     220                    throw new \InvalidArgumentException( 'Parentheses are misplaced' );
    186221                }
    187222
     
    201236                $stack->push( Tokens::PAREN_LEFT );
    202237            } elseif ( Tokens::PAREN_RIGHT === $tokens[ $i ] ) {
    203                 // checking whether stack contains left parenthesis (dirty hack)
     238                // Checks whether stack contains left parenthesis.
    204239                if ( substr_count( $stack->serialize(), Tokens::PAREN_LEFT ) === 0 ) {
    205                     throw new \InvalidArgumentException( 'Parenthesis are misplaced' );
     240                    throw new \InvalidArgumentException( 'Parentheses are misplaced' );
    206241                }
    207242
     
    228263     * Calculates tokens ordered in RPN.
    229264     *
    230      * @param  \SplQueue $queue
     265     * @param  \SplQueue $queue Queue to process.
    231266     * @return int|float Result of the calculation.
    232      * @throws \InvalidArgumentException
     267     * @throws \InvalidArgumentException If expression is invalid.
    233268     */
    234269    private function calculate_from_rpn( $queue ) {
     
    250285                    }
    251286
    252                     $params = [];
     287                    $params = array();
    253288                    for ( $i = 0; $i < $this->functions[ $current_token ]['paramsCount']; $i++ ) {
    254289                        $params[] = $stack->pop();
     
    269304     * Calculates the current arithmetic expression.
    270305     *
    271      * @param string $expression
     306     * @param string $expression Expression to calculate.
    272307     * @return float|int Result of the calculation.
    273308     */
     
    281316
    282317    /**
     318     * Checks association of an operator.
     319     *
    283320     * @param  string $operator A valid operator.
    284321     * @return bool
    285      * @throws \InvalidArgumentException
     322     * @throws \InvalidArgumentException If operator is not valid.
    286323     */
    287324    private function is_operator_left_associative( $operator ) {
     
    298335
    299336    /**
     337     * Checks precedence of an operator.
     338     *
    300339     * @param  string $operator A valid operator.
    301340     * @return int
    302      * @throws \InvalidArgumentException
     341     * @throws \InvalidArgumentException If operator is not valid.
    303342     */
    304343    private function get_operator_precedence( $operator ) {
     
    318357
    319358    /**
     359     * Executes an operator.
     360     *
    320361     * @param  string    $operator A valid operator.
    321362     * @param  int|float $a First value.
    322363     * @param  int|float $b Second value.
    323364     * @return int|float Result.
    324      * @throws \InvalidArgumentException
     365     * @throws \InvalidArgumentException If operator is not valid.
    325366     */
    326367    private function execute_operator( $operator, $a, $b ) {
     
    350391
    351392    /**
    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     *
    354398     * @return int|float Result.
    355399     */
  • pvb-contact-form-7-calculator/trunk/lib/Math/class-roundingmode.php

    r2149454 r2946744  
    11<?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 */
    311
    412namespace PVBCF7Calculator\lib\Math;
  • pvb-contact-form-7-calculator/trunk/lib/Math/class-tokenizer.php

    r2149454 r2946744  
    11<?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
    212namespace PVBCF7Calculator\lib\Math;
    313
     14/**
     15 * Breaks down an expression into tokens.
     16 */
    417class Tokenizer implements TokenizerInterface {
    518
    619    /**
    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     *
    925     * @return array Tokens of $expression
    10      * @throws \Exception
     26     * @throws \InvalidArgumentException If expression is not valid.
    1127     */
    12     public function tokenize( $expression, $function_names = [] ) {
     28    public function tokenize( $expression, $function_names = array() ) {
    1329        $expr_length = strlen( $expression );
    1430
    15         $tokens        = [];
     31        $tokens        = array();
    1632        $number_buffer = '';
    1733
  • pvb-contact-form-7-calculator/trunk/lib/Math/class-tokenizerinterface.php

    r2149454 r2946744  
    11<?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
    212namespace PVBCF7Calculator\lib\Math;
    313
     
    515
    616    /**
    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     *
    922     * @return array Tokens of $expression
    1023     */
    11     public function tokenize( $expression, $function_names = []);
     24    public function tokenize( $expression, $function_names = array());
    1225}
  • pvb-contact-form-7-calculator/trunk/lib/Math/class-tokens.php

    r2149454 r2946744  
    11<?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
    212namespace PVBCF7Calculator\lib\Math;
    313
     
    1727    const PAREN_RIGHT = ')';
    1828
    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 );
    2131}
  • pvb-contact-form-7-calculator/trunk/lib/class-pvbcf7calculator.php

    r2269783 r2946744  
    11<?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
    212namespace PVBCF7Calculator\lib;
    313
     
    1121define( 'PVB_CF7_CALCULATOR_PATH', dirname( dirname( __FILE__ ) ) );
    1222
     23/**
     24 * Initializes the PVB Contact Form 7 Calculator plugin
     25 * and provides core functions.
     26 *
     27 * @since 1.0.0
     28 */
    1329class PVBCF7Calculator {
    1430
     
    2036    /**
    2137     * Unique ID string for plugin settings page
     38     *
    2239     * @since 1.0.6
    2340     */
     
    2643    /**
    2744     * This plugin's current version
     45     *
     46     * @var string
    2847     */
    2948    private $plugin_version;
    3049
    3150    /**
     51     * Placeholder for a WordPressSettingsFramework instance
     52     *
    3253     * @var WordPressSettingsFramework
    3354     * @since 1.0.6
     
    3960     *
    4061     * @since 1.0.0
    41      *
    4262     */
    4363    public function __construct() {
     
    4767        add_action( 'admin_menu', array( $this, 'settings_menu' ) );
    4868
    49         // Set plugin version
     69        // Set plugin version.
    5070        $plugin_data = get_file_data(
    5171            PVB_CF7_CALCULATOR_PATH . '/pvb-cf7-calculator.php',
     
    5676        $this->plugin_version = $plugin_data['Version'];
    5777
    58         // Register settings
     78        // Register settings.
    5979        $this->wpsf = new WordPressSettingsFramework(
    6080            PVB_CF7_CALCULATOR_PATH . '/settings/settings-general.php',
     
    6787     *
    6888     * @since 1.0.0
    69      *
    7089     */
    7190    public function init() {
     
    97116     *
    98117     * @since 1.0.0
    99      *
    100118     */
    101119    public function cf7_init() {
     
    161179     *
    162180     * @since 1.0.0
    163      *
    164181     */
    165182    public function admin_init() {
     
    183200     *
    184201     * @since 1.0.0
    185      *
    186202     */
    187203    public function enqueue_scripts() {
    188204
    189         // CSS
    190205        wp_enqueue_style(
    191206            'pvb-cf7-calculator',
     
    199214
    200215        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.
    209225        wp_localize_script(
    210226            'pvb-cf7-calculator',
     
    220236     *
    221237     * @since 1.0.1
    222      *
    223238     */
    224239    public function enqueue_admin_scripts() {
    225240        wp_enqueue_script(
    226             'pvb-cf7-calculator-admin',                                           // handle
    227             plugins_url( 'js/pvb-cf7-calculator-admin.js', dirname( __FILE__ ) ), // url
    228             array( 'jquery' ),                                                    // dependencies
    229             $this->plugin_version,                                                // version
    230             true                                                                  // in footer
    231         );
    232     }
    233 
    234     /**
    235      * Display a notice in the admin area if CF7 not installed, not active, or too old
    236      *
    237      * @since 1.0.0
    238      *
     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
    239254     */
    240255    public function not_active_notice() {
     
    247262     *
    248263     * @since 1.0.9
    249      *
    250264     */
    251265    public function pro_active_notice() {
     
    257271     *
    258272     * @since 1.0.1
    259      *
    260273     */
    261274    public function powered_by_opt_in() {
     
    276289     * Add "Settings" and "Support" links on Plugins page
    277290     *
     291     * @param string[] $links Links to filter.
     292     *
    278293     * @since 1.0.6
    279      *
    280294     */
    281295    public function plugin_action_links( $links ) {
     
    295309     * Adds a nonce for AJAX calculation requests
    296310     *
     311     * @param string $form_elements Form elements to filter.
     312     *
    297313     * @since 1.0.6
    298      *
    299314     */
    300315    public function nonce_output( $form_elements ) {
     
    307322     * Filter that outputs "Powered by:" link (only if admin opted in)
    308323     *
     324     * @param string $form_elements Form elements to filter.
     325     *
    309326     * @since 1.0.1
    310      *
    311327     */
    312328    public function powered_by_output( $form_elements ) {
     
    320336     *
    321337     * @since 1.0.6
    322      *
    323338     */
    324339    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.
    326341        if ( current_user_can( 'manage_options' ) ) {
    327342            wpSettingsFramework\wpsf_set_setting(
     
    335350                'features',
    336351                'hide_promo_admin_notices_until',
    337                 date( 'Y-m-d', strtotime( '+2 days' ) )
     352                gmdate( 'Y-m-d', strtotime( '+2 days' ) )
    338353            );
    339354            wp_send_json( true );
     
    347362     *
    348363     * @since 1.0.6
    349      *
    350364     */
    351365    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.
    353367        if ( current_user_can( 'manage_options' ) ) {
    354368            wpSettingsFramework\wpsf_set_setting(
     
    368382     *
    369383     * @since 1.0.0
    370      *
    371384     */
    372385    public function pro_notice() {
    373386        if ( ! current_user_can( 'manage_options' ) ) {
    374             // Only show to admins
     387            // Only show to admins.
    375388            return;
    376389        }
     
    390403                )
    391404            ) > time() ) {
    392             // Notifications temporarily dismissed
     405            // Notifications temporarily dismissed.
    393406            return;
    394407        }
    395408        if ( 2 === (int) $hide_option ) {
    396             // Notifications permanently dismissed
     409            // Notifications permanently dismissed.
    397410            return;
    398411        }
     
    420433     *
    421434     * @since 1.0.6
    422      *
    423435     */
    424436    public function settings_menu() {
     
    436448     * Display a dialog to generate a "calculation" field in the form
    437449     *
    438      * @param WPCF7_ContactForm $contact_form
    439      * @param array $options
    440      * @since 1.0.0
    441      *
     450     * @param WPCF7_ContactForm $contact_form The contact form.
     451     * @param array             $options Tag generator options.
     452     *
     453     * @since 1.0.0
    442454     */
    443455    public function calculation_tag_generator( $contact_form, $options ) {
     
    452464     * Process "calculation" form tags
    453465     *
    454      * @param WPCF7_FormTag $tag
     466     * @param WPCF7_FormTag $tag The form tag to process.
     467     *
    455468     * @return string
    456      * @since 1.0.0
    457      *
     469     *
     470     * @since 1.0.0
    458471     */
    459472    public function calculation_tag_handler( $tag ) {
     
    540553     * Display a dialog to generate a "calculate" button in the form
    541554     *
    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
    547559     */
    548560    public function calculate_button_tag_generator( $contact_form, $options ) {
     
    557569     * Process "calculate" button tags
    558570     *
    559      * @param WPCF7_FormTag $tag
     571     * @param WPCF7_FormTag $tag The form tag to process.
     572     *
    560573     * @return string
    561      * @since 1.0.0
    562      *
     574     *
     575     * @since 1.0.0
    563576     */
    564577    public function calculate_button_tag_handler( $tag ) {
     
    591604     *
    592605     * @since 1.0.0
    593      *
    594606     */
    595607    public function ajax_calculate() {
    596         $r     = array(); // Return values will be stored here
     608        $r     = array(); // Return values will be stored here.
    597609        $input = array();
    598610
     
    603615            )
    604616        ) {
    605             // Do not process without a valid nonce
     617            // Do not process without a valid nonce.
    606618            return;
    607619        }
     
    624636     * Calculate all "calculation" values for a given form
    625637     *
    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     *
    628641     * @return array
    629      * @since 1.0.0
    630      *
     642     *
     643     * @since 1.0.0
    631644     */
    632645    public function calculate_form( $form, $input ) {
    633         $r    = array(); // Return values will be stored here
     646        $r    = array(); // Return values will be stored here.
    634647        $tags = $form->scan_form_tags();
    635648        foreach ( $tags as $tag ) {
     
    657670     *
    658671     * @since 1.0.0
    659      *
    660672     */
    661673    public function intercept_submit() {
     
    666678            )
    667679        ) {
    668             // Do not process without a valid nonce
     680            // Do not process without a valid nonce.
    669681            return;
    670682        }
     
    694706     * Extracts attributes (such as "min", "max" and "precision") from a CF7 tag
    695707     *
    696      * @param WPCF7_FormTag $tag
     708     * @param WPCF7_FormTag $tag The form tag to process.
    697709     * @return array
    698710     * @since 1.0.0
    699      *
    700711     */
    701712    private function extract_options( $tag ) {
     
    715726     * Calculate the value of a "calculation" field based on user input
    716727     *
    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".
    720732     * @return float
    721733     * @since 1.0.0
    722      *
    723734     */
    724735    private function calculate_equation( $form, $values, $input, $options = array() ) {
     
    734745        $expression = $values;
    735746
    736         // Order input variables from longest to shortest names
     747        // Order input variables from longest to shortest names.
    737748        $keys = array_keys( $input );
    738749
    739         // Handle checkbox groups with nothing selected
     750        // Handle checkbox groups with nothing selected.
    740751        $tags = $form->scan_form_tags();
    741752        foreach ( $tags as $tag ) {
     
    749760        usort( $keys, array( $this, 'sort_by_length_helper' ) );
    750761
    751         // Replace input variables in equation
     762        // Replace input variables in equation.
    752763        foreach ( $keys as $key ) {
    753764            if ( is_array( $input[ $key ] ) ) {
     
    756767                    $input[ $key ] = array_shift( $input[ $key ] );
    757768                } else {
    758                     // Sum values
     769                    // Sum values.
    759770                    $sum = 0;
    760771                    foreach ( $input[ $key ] as $value ) {
     
    767778            }
    768779            if ( preg_match( '/[0-9]{4}\-[0-9]{2}-[0-9]{2}/', $input[ $key ] ) ) {
    769                 // Date
     780                // Date variable.
    770781                $days       = intval( strtotime( $input[ $key ] . 'T00:00:00 UTC' ) / 86400 );
    771782                $expression = preg_replace(
     
    776787                $expression = str_replace( '###RPLC###', $days, $expression );
    777788            } else {
    778                 // Not date
     789                // Not a date variable.
    779790                if ( is_array( $input[ $key ] ) ) {
    780                     // Sum values (for checkboxes)
     791                    // Sum values (for checkboxes).
    781792                    $num = array_sum( $input[ $key ] );
    782793                } elseif ( is_numeric( $input[ $key ] ) ) {
     
    786797                }
    787798
    788                 // Handle negative numbers
     799                // Handle negative numbers.
    789800                if ( $num < 0 ) {
    790801                    $num = ' (' . $num . ') ';
     
    799810        }
    800811
    801         // Fix nested parentheses bug
     812        // Fix nested parentheses bug.
    802813        while ( preg_match( '/\(\s*\(/', $expression ) ) {
    803814            $expression = preg_replace( '/\(\s*\(/', '(1*( ', $expression );
    804815        }
    805816
    806         // Calculate
     817        // Calculate.
    807818        $calculator = PVBCalculator::create();
    808819        try {
     
    812823        }
    813824
    814         // Apply minimum
     825        // Apply minimum.
    815826        if ( isset( $options['min'] ) && is_numeric( $options['min'] ) ) {
    816827            $r = max( $r, $options['min'] );
    817828        }
    818829
    819         // Apply maximum
     830        // Apply maximum.
    820831        if ( isset( $options['max'] ) && is_numeric( $options['max'] ) ) {
    821832            $r = min( $r, $options['max'] );
    822833        }
    823834
    824         // Apply rounding
     835        // Apply rounding.
    825836        if ( isset( $options['precision'] ) && is_numeric( $options['precision'] ) ) {
    826837            $r = round( $r, $options['precision'] );
     
    835846     * @return boolean
    836847     * @since 1.0.0
    837      *
    838848     */
    839849    private function check_cf7() {
     
    846856     * @return boolean
    847857     * @since 1.0.9
    848      *
    849858     */
    850859    private function check_pro() {
     
    856865     *
    857866     * @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
    861869     */
    862870    private function load_view( $view, $data = array() ) {
     
    871879
    872880    /**
    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
    876890     */
    877891    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
    111(function($, document) {
    212
     
    1222        on_ready: function() {
    1323
    14             // on ready stuff here
    1524            wpsf.cache();
    1625            wpsf.trigger_dynamic_fields();
     
    3948                function(){
    4049
    41                     // Set tab link active class
     50                    // Set tab link active class.
    4251                    wpsf.els.tab_links.removeClass( 'nav-tab-active' );
    4352                    $( this ).addClass( 'nav-tab-active' );
    4453
    45                     // Show tab
     54                    // Show tab.
    4655                    var tab_id = $( this ).attr( 'href' );
    4756
     
    95104        setup_groups: function() {
    96105
    97             // add row
     106            // Add row.
    98107
    99108            $( document ).on(
     
    118127            );
    119128
    120             // remove row
     129            // Remove row.
    121130
    122131            $( document ).on(
  • pvb-contact-form-7-calculator/trunk/lib/wpSettingsFramework/class-wordpresssettingsframework.php

    r2269783 r2946744  
    11<?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
    212namespace PVBCF7Calculator\lib\wpSettingsFramework;
    313
     
    1626class WordPressSettingsFramework {
    1727    /**
     28     * Settings wrapper
     29     *
    1830     * @access private
    1931     * @var array
     
    2234
    2335    /**
     36     * Settings
     37     *
    2438     * @access private
    2539     * @var array
     
    2842
    2943    /**
     44     * Tabs
     45     *
    3046     * @access private
    3147     * @var array
     
    3450
    3551    /**
     52     * Option group
     53     *
    3654     * @access private
    3755     * @var string
     
    4058
    4159    /**
     60     * Settings page
     61     *
    4262     * @access private
    4363     * @var array
     
    4666
    4767    /**
     68     * Options path
     69     *
    4870     * @access private
    4971     * @var string
     
    5274
    5375    /**
     76     * Options URL
     77     *
    5478     * @access private
    5579     * @var string
     
    5882
    5983    /**
     84     * Setting defaults
     85     *
    6086     * @access protected
    6187     * @var array
     
    76102     * WordPressSettingsFramework constructor.
    77103     *
    78      * @param string $settings_file
    79      * @param bool   $option_group
     104     * @param string $settings_file The file defining the settings.
     105     * @param string $option_group  Option group.
    80106     */
    81107    public function __construct( $settings_file, $option_group = false ) {
     
    131157        }
    132158
    133         // If "sections" is set, this settings group probably has tabs
     159        // If "sections" is set, this settings group probably has tabs.
    134160        if ( isset( $this->settings_wrapper['sections'] ) ) {
    135161            $this->tabs     = ( isset( $this->settings_wrapper['tabs'] ) ) ? $this->settings_wrapper['tabs'] : array();
    136162            $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.
    138164        } else {
    139165            $this->settings = $this->settings_wrapper;
     
    163189     * Add Settings Page
    164190     *
    165      * @param array $args
     191     * @param array $args Parameters for the settings page.
    166192     */
    167193    public function add_settings_page( $args ) {
     
    204230     * Settings Page Content
    205231     */
    206 
    207232    public function settings_page_content() {
    208233        if ( ! current_user_can( $this->settings_page['capability'] ) ) {
     
    214239            <h2><?php echo esc_html( $this->settings_page['title'] ); ?></h2>
    215240            <?php
    216             // Output your settings form
     241            // Output your settings form.
    217242            $this->settings();
    218243            ?>
     
    233258     */
    234259    public function admin_enqueue_scripts() {
    235         // scripts
     260        // Register and enqueue scripts.
    236261        wp_register_script(
    237262            'jquery-ui-timepicker',
     
    258283        wp_enqueue_script( 'wpsf' );
    259284
    260         // styles
     285        // Register and enqueue styles.
    261286        wp_register_style(
    262287            'jquery-ui-timepicker',
     
    288313     * Adds a filter for settings validation.
    289314     *
    290      * @param $input
     315     * @param mixed $input Input to validate.
    291316     *
    292317     * @return array
     
    299324     * Displays the "section_description" if specified in $this->settings
    300325     *
    301      * @param array callback args from add_settings_section()
     326     * @param array $args Callback args from add_settings_section().
    302327     */
    303328    public function section_intro( $args ) {
     
    357382     * Usort callback. Sorts $this->settings by "section_order"
    358383     *
    359      * @param $a
    360      * @param $b
     384     * @param mixed $a First element to compare.
     385     * @param mixed $b Second element to compare.
    361386     *
    362387     * @return bool
     
    373398     * Generates the HTML output of the settings fields
    374399     *
    375      * @param array callback args from add_settings_field()
     400     * @param array $args Callback args from add_settings_field().
    376401     */
    377402    public function generate_setting( $args ) {
     
    399424     * Do field method, if it exists
    400425     *
    401      * @param array $args
     426     * @param array $args Field method parameters.
    402427     */
    403428    public function do_field_method( $args ) {
     
    412437     * Generate: Text field
    413438     *
    414      * @param array $args
     439     * @param array $args Text field parameters.
    415440     */
    416441    public function generate_text_field( $args ) {
     
    427452     * Generate: Number field
    428453     *
    429      * @param array $args
     454     * @param array $args Number field parameters.
    430455     */
    431456    public function generate_number_field( $args ) {
     
    442467     * Generate: Time field
    443468     *
    444      * @param array $args
     469     * @param array $args Time field parameters.
    445470     */
    446471    public function generate_time_field( $args ) {
     
    460485     * Generate: Date field
    461486     *
    462      * @param array $args
     487     * @param array $args Date field parameters.
    463488     */
    464489    public function generate_date_field( $args ) {
     
    479504     * Generates a table of subfields, and a javascript template for create new repeatable rows
    480505     *
    481      * @param array $args
     506     * @param array $args Group field parameters.
    482507     */
    483508    public function generate_group_field( $args ) {
     
    508533     * Generate group row template
    509534     *
    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.
    513538     *
    514539     * @return string|bool
     
    529554                $subfield = wp_parse_args( $subfield, $this->setting_defaults );
    530555
    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'] ] : '' );
    532559                $subfield['name']  = sprintf( '%s[%d][%s]', $args['name'], $row, $subfield['id'] );
    533560                $subfield['id']    = sprintf( '%s_%d_%s', $args['id'], $row, $subfield['id'] );
     
    562589     * Generate: Select field
    563590     *
    564      * @param array $args
     591     * @param array $args Select field parameters.
    565592     */
    566593    public function generate_select_field( $args ) {
     
    590617     * Generate: Password field
    591618     *
    592      * @param array $args
     619     * @param array $args Password field parameters.
    593620     */
    594621    public function generate_password_field( $args ) {
     
    607634     * Generate: Textarea field
    608635     *
    609      * @param array $args
     636     * @param array $args Textarea field parameters.
    610637     */
    611638    public function generate_textarea_field( $args ) {
     
    624651     * Generate: Radio field
    625652     *
    626      * @param array $args
     653     * @param array $args Radio field parameters.
    627654     */
    628655    public function generate_radio_field( $args ) {
     
    650677     * Generate: Checkbox field
    651678     *
    652      * @param array $args
     679     * @param array $args Checkbox field parameters.
    653680     */
    654681    public function generate_checkbox_field( $args ) {
     
    668695     * Generate: Checkboxes field
    669696     *
    670      * @param array $args
     697     * @param array $args Checkbox field parameters.
    671698     */
    672699    public function generate_checkboxes_field( $args ) {
     
    698725     * Generate: Color field
    699726     *
    700      * @param array $args
     727     * @param array $args Color field parameters.
    701728     */
    702729    public function generate_color_field( $args ) {
     
    742769     * Generate: File field
    743770     *
    744      * @param array $args
     771     * @param array $args File field parameters.
    745772     */
    746773    public function generate_file_field( $args ) {
     
    786813     * Generate: Editor field
    787814     *
    788      * @param array $args
     815     * @param array $args Editor field parameters.
    789816     */
    790817    public function generate_editor_field( $args ) {
     
    797824     * Generate: Custom field
    798825     *
    799      * @param array $args
     826     * @param array $args Custom field parameters.
    800827     */
    801828    public function generate_custom_field( $args ) {
     
    806833     * Generate: Multi Inputs field
    807834     *
    808      * @param array $args
     835     * @param array $args Multi Inputs field parameters.
    809836     */
    810837    public function generate_multiinputs_field( $args ) {
     
    842869     * Generate: Field ID
    843870     *
    844      * @param mixed $id
     871     * @param mixed $id Setting ID.
    845872     *
    846873     * @return string
     
    853880     * Generate: Description
    854881     *
    855      * @param mixed $description
     882     * @param mixed $description Description text.
    856883     */
    857884    public function generate_description( $description ) {
     
    9981025    }
    9991026
     1027    /**
     1028     * Returns list of allowed tags for the custom field.
     1029     */
    10001030    private function expanded_alowed_tags() {
    10011031        $my_allowed = wp_kses_allowed_html( 'post' );
    1002         // iframe
     1032
     1033        // Iframe.
    10031034        $my_allowed['iframe'] = array(
    10041035            'src'             => array(),
     
    10081039            'allowfullscreen' => array(),
    10091040        );
    1010         // form fields - input
     1041
     1042        // Form fields - input.
    10111043        $my_allowed['input'] = array(
    10121044            'class' => array(),
     
    10161048            'type'  => array(),
    10171049        );
    1018         // select
     1050
     1051        // Select.
    10191052        $my_allowed['select'] = array(
    10201053            'class' => array(),
     
    10241057            'type'  => array(),
    10251058        );
    1026         // select options
     1059
     1060        // Select options.
    10271061        $my_allowed['option'] = array(
    10281062            'selected' => array(),
    10291063        );
    1030         // style
     1064
     1065        // Style.
    10311066        $my_allowed['style'] = array(
    10321067            'types' => array(),
    10331068        );
    1034         // script
     1069
     1070        // Script.
    10351071        $my_allowed['script'] = array(
    10361072            'type' => array(),
     
    10451081 * Get a setting from an option group
    10461082 *
    1047  * @param string $option_group
    1048  * @param string $section_id May also be prefixed with tab ID
    1049  * @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.
    10501086 *
    10511087 * @return mixed
     
    10631099 * Delete all the saved settings from a settings file/option group
    10641100 *
    1065  * @param string $option_group
     1101 * @param string $option_group The option group.
    10661102 */
    10671103function wpsf_delete_settings( $option_group ) {
     
    10731109 * the WordPressSettingsFramework class
    10741110 *
    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.
    10801115 */
    10811116function wpsf_set_setting(
  • pvb-contact-form-7-calculator/trunk/pvb-cf7-calculator.php

    r2269783 r2946744  
    11<?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 */
    1321
    1422namespace PVBCF7Calculator;
     
    2028}
    2129
    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.
    2331if ( ! defined( 'PVB_CF7_CALCULATOR_PRO_ACTIVE' ) ) {
    2432    require_once 'autoload.php';
  • pvb-contact-form-7-calculator/trunk/readme.txt

    r2570143 r2946744  
    44Tags: calculator, cost calculator, price calculator, loan calculator, mortgage calculator, Contact Form 7, PayPal, Stripe
    55Requires at least: 4.9.2
    6 Tested up to: 5.8
     6Tested up to: 6.3
    77Requires PHP: 5.6
    88Stable tag: trunk
     
    125125== Changelog ==
    126126
     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
    127133= 1.0.10 =
    128134* Fix: error when adding negative numbers
  • pvb-contact-form-7-calculator/trunk/views/tag-generator-calculate-button.php

    r2149454 r2946744  
    1919        <table class="form-table">
    2020            <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>
    2129                <tr>
    2230                    <th scope="row">
Note: See TracChangeset for help on using the changeset viewer.