wpseo_calc

Do simple reliable math calculations without the risk of wrong results.

Description

wpseo_calc( (number) $number1, (string) $action, (number) $number2, (constant) $round = false, (int) $decimals = 0, (int) $precision = 10 ); 

Parameters (6)

0. $number1 (number)
Scalar (string/int/float/bool).
1. $action (string)
Calculation action to execute.
2. $number2 (number)
Scalar (string/int/float/bool).
3. $round — Optional. (constant) => false
Whether or not to round the result. Defaults to false.
4. $decimals — Optional. (int)
Decimals for rounding operation. Defaults to 0.
5. $precision — Optional. (int) => 10
Calculation precision. Defaults to 10.

Usage

  1. if ( !function_exists( 'wpseo_calc' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yoast-seo/inc/wpseo-functions-deprecated.php'; 
  3.  
  4. // Scalar (string/int/float/bool). 
  5. $number1 = null; 
  6.  
  7. // Calculation action to execute. 
  8. $action = ''; 
  9.  
  10. // Scalar (string/int/float/bool). 
  11. $number2 = null; 
  12.  
  13. // Whether or not to round the result. Defaults to false. 
  14. $round = false; 
  15.  
  16. // Decimals for rounding operation. Defaults to 0. 
  17. $decimals = -1; 
  18.  
  19. // Calculation precision. Defaults to 10. 
  20. $precision = 10; 
  21.  
  22. // NOTICE! Understand what this does before running. 
  23. $result = wpseo_calc($number1, $action, $number2, $round, $decimals, $precision); 
  24.  

Defined (1)

The function is defined in the following location(s).

/inc/wpseo-functions-deprecated.php  
  1. function wpseo_calc( $number1, $action, $number2, $round = false, $decimals = 0, $precision = 10 ) { 
  2. _deprecated_function( __FUNCTION__, 'WPSEO 1.6.1', 'WPSEO_Utils::calc()' ); 
  3.  
  4. return WPSEO_Utils::calc( $number1, $action, $number2, $round, $decimals, $precision );