Add equation selector
This commit is contained in:
@@ -35,66 +35,18 @@ function sp_stat_meta_init() {
|
||||
}
|
||||
|
||||
function sp_stat_equation_meta( $post ) {
|
||||
$args = array(
|
||||
'post_type' => 'sp_stat',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'exclude' => $post->ID
|
||||
);
|
||||
$sports = get_the_terms( $post->ID, 'sp_sport' );
|
||||
if ( ! empty( $sports ) ):
|
||||
$terms = array();
|
||||
foreach ( $sports as $sport ):
|
||||
$terms[] = $sport->slug;
|
||||
endforeach;
|
||||
$args['tax_query'] = array(
|
||||
array(
|
||||
'taxonomy' => 'sp_sport',
|
||||
'field' => 'slug',
|
||||
'terms' => $terms
|
||||
)
|
||||
);
|
||||
endif;
|
||||
$stats = get_posts( $args );
|
||||
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
||||
?>
|
||||
<div>
|
||||
<p class="sp-equation-selector">
|
||||
<select data-remove-text="<?php _e( 'Remove', 'sportspress' ); ?>">
|
||||
<option value=""><?php _e( 'Select', 'sportspress' ); ?></option>
|
||||
<optgroup label="<?php _e( 'Events', 'sportspress' ); ?>">
|
||||
<option value="wins"><?php _e( 'Wins', 'sportspress' ); ?></option>
|
||||
<option value="draws"><?php _e( 'Draws', 'sportspress' ); ?></option>
|
||||
<option value="ties"><?php _e( 'Ties', 'sportspress' ); ?></option>
|
||||
<option value="losses"><?php _e( 'Losses', 'sportspress' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php _e( 'Statistics', 'sportspress' ); ?>">
|
||||
<?php foreach ( $stats as $stat ): ?>
|
||||
<option value="<?php echo $stat->post_name; ?>"><?php echo $stat->post_title; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<optgroup label="<?php _e( 'Operators', 'sportspress' ); ?>">
|
||||
<option value="+">+</option>
|
||||
<option value="-">−</option>
|
||||
<option value="X">×</option>
|
||||
<option value="/">÷</option>
|
||||
<option value="(">(</option>
|
||||
<option value=")">)</option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php _e( 'Constants', 'sportspress' ); ?>">
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7">7</option>
|
||||
<option value="8">8</option>
|
||||
<option value="9">9</option>
|
||||
<option value="10">10</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
<?php
|
||||
foreach ( $equation as $piece ):
|
||||
sp_get_equation_selector( 'stat', $piece );
|
||||
endforeach;
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
sp_nonce();
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user