Skip to main content

GravityMath_Report

Class GravityMath_Report

Source: includes/class-gravitymath-report.php:9

Details

  • Kind: class
  • Namespace: (global)

Methods

MethodDescription
get_instance()Get the instance of the class.
add_gf_logging()Adds Math by GravityView to the plugins shown in the Logging screen.
register_scripts()Enqueue the script to enhance GV Math debugging output.
add_report_links()Add links to the reports.
add_shortcode_debugging()Add reporting for a shortcode.
report_errors()Include errors and warnings after the_content.
log_from_action()Add Errors to GFLogging and if debug is on, store for output.
add_index()Foreach gv_math shortcode on a post add it to the index.
get_current_index()Get current position for the debug index this fires early so later use will require -1.
add_alert()Add Errors to the Alert array only if debugging is on.
get_error_message()Get Error messages for supplied or current index.
get_alert_messages()Get all Errors, Notices and Warnings.
get_warning_message()Get Warning messages for supplied or current index.
get_notice_messages()Get Notice messages for supplied or current index.
has_errors()Are there errors?
has_warnings()Are there warnings?
get_skip_flag()Get the skip status for the current formula being processed.
set_skip_flag()Set a flag when a formula should not be processed.
get_debug_link()Get the link or signify a notice.
is_debug_active()Check if the supplied index has debugging on.
filter_notices()Only output final notice message if requested.
suppress_alerts()Should errors be suppressed?

Method Reference

get_instance()

public static function get_instance()

Get the instance of the class.

Returns

Since: 1.0

Source: includes/class-gravitymath-report.php:70

add_gf_logging()

public function add_gf_logging( $plugins=[] )

Adds Math by GravityView to the plugins shown in the Logging screen.

Parameters

NameTypeDefaultDescription
$pluginsarray[]Associative array, with key set to the logging key and value set to the displayed name.

Returns

  • array

Since: 2.0

Source: includes/class-gravitymath-report.php:133

register_scripts()

public function register_scripts()

Enqueue the script to enhance GV Math debugging output.

Since: 1.0

Source: includes/class-gravitymath-report.php:144

function add_report_links( $result, $atts, $content, $shortcode, $object, $nesting_level )

Add links to the reports.

Parameters

NameTypeDefaultDescription
$resultstringShortcode output.
$attsarrayShortcode parameters.
$contentstringContent passed to the shortcode.
$shortcodestringgv_mathShortcode used (default: gv_math).
$object
$nesting_levelintLevel of shortcode nesting.
$thisGravityMath_ShortcodeCurrent object.

Returns

  • string — Original result with debugging links appended, if notices are enabled

Since: 1.0

Source: includes/class-gravitymath-report.php:162

add_shortcode_debugging()

public function add_shortcode_debugging( $formula, $atts, $content, $shortcode, $object )

Add reporting for a shortcode.

Parameters

NameTypeDefaultDescription
$formulastringThe math formula to modify.
$attsarrayShortcode parameters.
$contentstringContent passed to the shortcode.
$shortcodestringgv_mathShortcode used (default: gv_math).
$objectGravityMath_ShortcodeCurrent object.

Returns

  • string — Original formula, not modified.

Since: 1.0

Source: includes/class-gravitymath-report.php:201

report_errors()

public function report_errors( $content )

Include errors and warnings after the_content.

Parameters

NameTypeDefaultDescription
$contentstringExisting post content.

Returns

  • string — Post content with errors/warnings appended, if any.

Since: 1.0

Source: includes/class-gravitymath-report.php:309

log_from_action()

public function log_from_action( $message='', $data=[] )

Add Errors to GFLogging and if debug is on, store for output.

Parameters

NameTypeDefaultDescription
$messagestring''
$dataarray[]

Returns

  • void

Since: 1.0

Source: includes/class-gravitymath-report.php:376

add_index()

public function add_index( $debug_value=false )

Foreach gv_math shortcode on a post add it to the index.

Parameters

NameTypeDefaultDescription
$debug_valueboolfalse

Returns

  • void

Since: 1.0

Source: includes/class-gravitymath-report.php:579

get_current_index()

public function get_current_index( $already_advanced=false )

Get current position for the debug index this fires early so later use will require -1.

Parameters

NameTypeDefaultDescription
$already_advancedfalse

Returns

  • int

Since: 1.0

Source: includes/class-gravitymath-report.php:601

add_alert()

public function add_alert( $type, $alert, $line_number=0 )

Add Errors to the Alert array only if debugging is on.

Parameters

NameTypeDefaultDescription
$typestringType of alert to add: 'warnings', 'notices' or 'errors'. Default: 'warnings'.
$alertWP_Error | arrayThe alert to add.
$line_numberint0The line number of the shortcode.

Returns

  • void

Since:

  • 1.0
  • 2.0 (Added 'notices' alert type, changed $alert parameter type to WP_Error|array, and removed requirement for debug to be enabled)

Source: includes/class-gravitymath-report.php:624

get_error_message()

public function get_error_message( $index )

Get Error messages for supplied or current index.

Parameters

NameTypeDefaultDescription
$indexintrequested shortcode.

Returns

  • array — Errors, with stored errors added.

See Also

Since: 1.0

Source: includes/class-gravitymath-report.php:645

get_alert_messages()

public function get_alert_messages( $type='all' )

Get all Errors, Notices and Warnings.

Parameters

NameTypeDefaultDescription
$typestring'all'Type of alerts to get. Options: 'all', 'errors', 'notices', 'warnings'. Default: 'all'.

Returns

  • array

Since:

  • 1.0
  • 2.0 (Added 'notices' alert type)

Source: includes/class-gravitymath-report.php:719

get_warning_message()

public function get_warning_message( $index )

Get Warning messages for supplied or current index.

Parameters

NameTypeDefaultDescription
$indexintcurrent shortcode being requested

Returns

  • array

See Also

Since: 1.0

Source: includes/class-gravitymath-report.php:760

get_notice_messages()

public function get_notice_messages( $index )

Get Notice messages for supplied or current index.

Parameters

NameTypeDefaultDescription
$indexintcurrent shortcode being requested.

Returns

  • array

See Also

Since: 2.0

Source: includes/class-gravitymath-report.php:793

has_errors()

public function has_errors()

Are there errors?

Returns

  • bool — true: Yes, there are. False: nope!

Since: 1.0

Source: includes/class-gravitymath-report.php:820

has_warnings()

public function has_warnings()

Are there warnings?

Returns

  • bool — true: Yes, there are. False: nope!

Since: 1.0

Source: includes/class-gravitymath-report.php:851

get_skip_flag()

public function get_skip_flag()

Get the skip status for the current formula being processed.

Returns

  • bool

Since: 1.0

Source: includes/class-gravitymath-report.php:864

set_skip_flag()

public function set_skip_flag( $flag=false )

Set a flag when a formula should not be processed.

Parameters

NameTypeDefaultDescription
$flagboolfalseTrue: don't process. False: process.

Returns

  • bool

Since: 1.0

Source: includes/class-gravitymath-report.php:877

public function get_debug_link( $index, $debug_caps=false )

Get the link or signify a notice.

Parameters

NameTypeDefaultDescription
$indexintThe index of the shortcode.
$debug_capsboolfalseWhether the user has debug capabilities.

Returns

  • string

Since: 1.0

Source: includes/class-gravitymath-report.php:891

is_debug_active()

public function is_debug_active( $index=0 )

Check if the supplied index has debugging on.

Parameters

NameTypeDefaultDescription
$indexint0The index of the shortcode.

Returns

  • bool

Since: 1.0

Source: includes/class-gravitymath-report.php:924

filter_notices()

public function filter_notices( $message=[] )

Only output final notice message if requested.

Parameters

NameTypeDefaultDescription
$messagearray[]

Returns

  • array

Since: 2.0

Source: includes/class-gravitymath-report.php:949

suppress_alerts()

public function suppress_alerts()

Should errors be suppressed?

Returns

  • bool — True: don't show the errors. False: show the errors. Default: false

Since: 1.0

Source: includes/class-gravitymath-report.php:992