1st commit for "Integration Event-Specs to Equations"
This commit is contained in:
@@ -1292,6 +1292,9 @@ if ( !function_exists( 'sp_get_eos_safe_slug' ) ) {
|
|||||||
if ( !function_exists( 'sp_solve' ) ) {
|
if ( !function_exists( 'sp_solve' ) ) {
|
||||||
function sp_solve( $equation, $vars, $precision = 0, $default = 0 ) {
|
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 )
|
if ( $equation == null )
|
||||||
return $default;
|
return $default;
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class SportsPress_Event_Specs {
|
|||||||
add_filter( 'sportspress_config_types', array( $this, 'add_post_type' ) );
|
add_filter( 'sportspress_config_types', array( $this, 'add_post_type' ) );
|
||||||
add_filter( 'sportspress_event_details', array( $this, 'event_details' ), 10, 2 );
|
add_filter( 'sportspress_event_details', array( $this, 'event_details' ), 10, 2 );
|
||||||
add_filter( 'sportspress_calendar_columns', array( $this, 'calendar_columns' ) );
|
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;
|
endif;
|
||||||
|
|||||||
Reference in New Issue
Block a user