Allow limit of 0 for unlimited teams per event

This commit is contained in:
Brian Miyaji
2015-09-21 00:21:53 +10:00
parent 5da135ede2
commit 6c1d580118
2 changed files with 72 additions and 53 deletions

View File

@@ -21,6 +21,7 @@ class SP_Meta_Box_Event_Teams {
public static function output( $post ) { public static function output( $post ) {
$limit = get_option( 'sportspress_event_teams', 2 ); $limit = get_option( 'sportspress_event_teams', 2 );
$teams = (array) get_post_meta( $post->ID, 'sp_team', false ); $teams = (array) get_post_meta( $post->ID, 'sp_team', false );
if ( $limit ) {
for ( $i = 0; $i < $limit; $i ++ ): for ( $i = 0; $i < $limit; $i ++ ):
$team = array_shift( $teams ); $team = array_shift( $teams );
?> ?>
@@ -77,6 +78,24 @@ class SP_Meta_Box_Event_Teams {
</div> </div>
<?php <?php
endfor; endfor;
} else {
?>
<p><strong><?php printf( __( 'Select %s:', 'sportspress' ), __( 'Teams', 'sportspress' ) ); ?></strong></p>
<?php
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_team[]',
'selected' => $teams,
'values' => 'ID',
'class' => 'widefat',
'property' => 'multiple',
'chosen' => true,
'placeholder' => __( 'None', 'sportspress' ),
);
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
}
} }
/** /**

View File

@@ -116,7 +116,7 @@ class SP_Settings_Events extends SP_Settings_Page {
'desc' => __( 'teams', 'sportspress' ), 'desc' => __( 'teams', 'sportspress' ),
'type' => 'number', 'type' => 'number',
'custom_attributes' => array( 'custom_attributes' => array(
'min' => 1, 'min' => 0,
'step' => 1 'step' => 1
), ),
), ),