diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index f4ed2378..b1e07140 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -1292,6 +1292,9 @@ if ( !function_exists( 'sp_get_eos_safe_slug' ) ) { if ( !function_exists( 'sp_solve' ) ) { function sp_solve( $equation, $vars, $precision = 0, $default = 0 ) { + // Add a hook to alter $equation + $equation = apply_filters( 'sportspress_equation_alter', $equation, $vars ); + if ( $equation == null ) return $default; diff --git a/modules/sportspress-event-specs.php b/modules/sportspress-event-specs.php index 34eab80e..56164b3d 100644 --- a/modules/sportspress-event-specs.php +++ b/modules/sportspress-event-specs.php @@ -41,6 +41,8 @@ class SportsPress_Event_Specs { add_filter( 'sportspress_config_types', array( $this, 'add_post_type' ) ); add_filter( 'sportspress_event_details', array( $this, 'event_details' ), 10, 2 ); add_filter( 'sportspress_calendar_columns', array( $this, 'calendar_columns' ) ); + add_filter( 'sportspress_equation_options', array( $this, 'add_options' ) ); + add_filter( 'sportspress_equation_alter', array( $this, 'alter_equation' ), 11, 2 ); } /** @@ -267,6 +269,33 @@ class SportsPress_Event_Specs { } } } + + /** + * Add additional options. + * + * @return array + */ + public function add_options( $options ) { + $spec_labels = (array)sp_get_var_labels( 'sp_spec', null, false ); + foreach ( $spec_labels as $key => $value ) { + $options[ 'Event Specs' ]['$spec'.$key] = $value; + } + return $options; + } + + /** + * Alter. + * + * @return array + */ + public function alter_equation( $equation, $vars ) { + //var_dump($equation); + //var_dump($vars); + // Remove space between equation parts + $equation = str_replace( ' ', '', $equation ); + + return $equation; + } } endif;