GravityMath_Shortcode
Source: includes/class-gravitymath-shortcode.php:6
Details
- Kind:
class - Namespace:
(global)
Properties
| Property | Type | Description |
|---|---|---|
$reporter | GravityMath_Report | |
$instance | GravityMath_Shortcode |
Methods
| Method | Description |
|---|---|
get_instance() | Get the instance of this class. |
add_hooks() | Register the shortcode. |
sanitize_formula() | Strip tags, remove thousands separators, and convert dashes to minus. |
do_shortcode() | Process the shortcode. |
format_number() | Intelligently format a number. |
is_valid_default_value() | Validates shortcode supplied default value. |
Method Reference
get_instance()
public static function get_instance( $calculator, $reporter )
Get the instance of this class.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$calculator | GravityMath_Engine | The calculator engine. | |
$reporter | GravityMath_Report | The reporter. |
Returns
Since: 1.0
Source: includes/class-gravitymath-shortcode.php:82
add_hooks()
public function add_hooks()
Register the shortcode.
Since: 1.0
Source: includes/class-gravitymath-shortcode.php:118
sanitize_formula()
public static function sanitize_formula( $original_formula )
Strip tags, remove thousands separators, and convert dashes to minus.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$original_formula | string | The original formula. |
Returns
string
Since: 1.0
Source: includes/class-gravitymath-shortcode.php:133
do_shortcode()
public function do_shortcode( $atts=[], $passed_content='', $shortcode='gravitymath' )
Process the shortcode.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$atts | array | [] | Attributes for the shortcode. |
$passed_content | '' | ||
$shortcode | string | 'gravitymath' | Shortcode used (default: gv_math). |
$content | string | Content passed to the shortcode. |
Returns
mixed|string|void
See Also
GravityMath_Shortcode::$default_atts
Since: 1.0
Source: includes/class-gravitymath-shortcode.php:267
format_number()
public static function format_number( $number, $decimals=null )
Intelligently format a number.
If you don't define the number of decimal places, then it will use the existing number of decimal places. This is done in a way that respects the localization of the site.
If you do define decimals, it uses number_format_i18n().
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$number | int | float | string | A number to format. | |
$decimals | int | null | null | Optional. Precision of the number of decimal places. Default '' (use existing number of decimals). |
Returns
string— Converted number in string format.
See Also
Since: 1.0
Source: includes/class-gravitymath-shortcode.php:405
is_valid_default_value()
public static function is_valid_default_value( $value )
Validates shortcode supplied default value.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | mixed | Default value setting. |
Returns
bool— True: valid default value; False: invalid.
See Also
GravityMath_Shortcode::do_shortcode
Since: 1.0
Source: includes/class-gravitymath-shortcode.php:440