Forum Replies Created

Viewing 15 replies - 61 through 75 (of 246 total)
  • Thread Starter af3

    (@af3)

    Hi @antoineh
    I cant get the gmt time to substract correctly.. seems like the parameters are all in utc? so i tried to convert the server utc to gmt.. with my limited php, this is what i have so far but the minutes are -ve and not calculating properly.

    <?php
    /**
     * Plugin Name: Football Pool - Playing Now
     */
    
    // Save this plugin in the "/wp-content/plugins" folder and activate it //
    
    class FootballPoolExtensionPlayNow {
    	public static function init_extension() {
    		add_filter( 'footballpool_predictionform_match_template', array( __CLASS__, 'match_row_template' ), null, 2 );
    		add_filter( 'footballpool_predictionform_match_template_params', array( __CLASS__, 'change_params' ), null, 4 );
    	}
    	
    	public static function change_params( $match_template_params, $match_id, $user_id, $is_user_page ) {
            
    		$current_date = gmdate('M d, Y', strtotime('+ 8 hours'));
    		$current_time = gmdate('H:i s', strtotime('+ 8 hours'));
    		$mynote = '';
    		
            if ( $current_date == $match_template_params['match_datetime_formatted'] ) { 
            
                $match_time = $match_template_params['match_time'];
    			$diff = strtotime($current_time) - strtotime($match_time);
                $min_diff = $diff / 60;
    			$hour = floor($min_diff) / 60;
        		$min = ($min_diff % 60);
    			
                if ($min < 116) { $mynote = '<span class="playing-now">Started ' .round($min,0). ' min ago</span>'; }
    			
    			if ($min < 1 )  { 
    				$mynote = '<span class="playing-now">Starting in '.$hour.' hr and '.$min.' min</span>';
    			}
    			if ($minutes > 116 ) { $mynote = '<span class="playing-now">Completed just now</span>'; } // assume by min 116 since start, match is completed.
    		} 
    	
            if ( $current_date > $match_template_params['match_datetime_formatted'] ) { 
            	$mynote = '<span class="playing-now">Completed</span>'; 
    		} 		
            
            $match_template_params['play_started'] = $mynote;
    		return $match_template_params;
    	}
    	
    	public static function match_row_template( $match_template, $is_user_page ) {
    		if ( ! $is_user_page ) {
    			if ( strpos( $match_template, '<tr>' ) !== false ) {
    				$match_template = '<tr id="match-%match_id%-%form_id%" class="%css_class%"
    								title="' . __('match', 'football-pool') . ' %match_id%">
    									<td class="time">%match_time% %play_started%</td>
    									<td class="home">%home_team%</td>
    									<td class="flag">%home_team_flag%</td>
    									<td class="score">%home_input%</td>
    									<td>-</td>
    									<td class="score">%away_input%</td>
    									<td class="flag">%away_team_flag%</td>
    									<td class="away">%away_team%</td>
    									<td>%joker%</td>
    									<td title="' . __('score', 'football-pool') . '" class="numeric">%user_score%</td>
    									<td>%stats_link%</td>
    								</tr>';
    			} else {
    				$match_template = '<div id="match-%match_id%-%form_id%" 
    											class="%css_class% match-card match-type-%match_type_id%"
    											title="' . __( 'match', 'football-pool' ) . ' %match_id%">
    										<div class="match-card-header">
    											<span class="matchdate">%match_datetime_formatted%</span>
    											<span class="time">%match_time% %play_started%</span>
    										</div>
    										<div class="flag">%home_team_flag%</div>
    										<div class="flag">%away_team_flag%</div>
    										<div class="home">%home_team%</div>
    										<div class="away">%away_team%</div>
    										<div class="score">
    											%home_input%
    											<div class="actual-score">%home_actual_score%</div>
    										</div>
    										<div class="score">
    											%away_input%
    											<div class="actual-score">%away_actual_score%</div>
    										</div>
    										<div class="match-card-footer">
    											<div class="user-score">%user_score_txt%</div>
    											<div class="fp-icon">%stats_link%</div>
    											<div class="fp-icon">%joker%</div>
    										</div>
    									</div>';
    			}
    		}
    		
    		return $match_template;
    	}
    }
    
    add_filter( 'plugins_loaded', array( 'FootballPoolExtensionPlayNow', 'init_extension' ) );
    Thread Starter af3

    (@af3)

    Got it done. It turns out quite simple. Thanks for the save codes & templates.

    Thread Starter af3

    (@af3)

    Just to share, I added this to the ranking page’s header in the theme. This hides the empty text for option value 1, and use option 5 (for my case to be shown as default).

    <script>
    jQuery(document).ready(function() {
    jQuery("#ranking option[value="+1+"]").hide();
    jQuery("#ranking option[value="+5+"]").attr('selected','selected');
    });
    </script>
    Thread Starter af3

    (@af3)

    Thanks @antoineh

    Yes, I want to have multiple championships where users by league group can participate. Thank you for your suggestions — i think it will work and will try it for a smaller group of people.

    Anyway, cuurious if anyone tried this plugin on multisite — this can perhaps one solution to have multiple championships.

    Cheers

    Thread Starter af3

    (@af3)

    Thanks again! the option=1 can be hidden using jquery. thanks

    Thread Starter af3

    (@af3)

    Additionally, the message “No results yet. Below is a list of all users.” only appears in the Ranking page, not on the default statistic page where the selection will return empty page. Using WordPress 2021 theme.

    Thread Starter af3

    (@af3)

    Thanks @antoineh – i reset my theme and it’s there!
    Just curious how to name the default ranking — it appears as Option=1 in the Selection but it has no name.

    Best if created ranking can be set as default.

    Thanks

    • This reply was modified 4 years, 11 months ago by af3.

    I think it’s up to your own rules because you add the final actual score manually.

    Thread Starter af3

    (@af3)

    OMG! I didnt see this. I can create & define ranking based on matches, round of 16 etc! Wow this is awesome.

    I created the rankings are user can select which ranking to show on the Statistics page (despite the other rankings are for future matches — it will return empty page).

    However, on the ranking page — seems like only the default ranking is shown as there is no selection/dropdown to select ranking to show (despite I activated User-defined in plugin option in admin). Is this as intended (because Round of 16 ranking etc is still empty) ?

    Thanks again for the help.

    • This reply was modified 4 years, 11 months ago by af3.
    Thread Starter af3

    (@af3)

    I added this to make the text appears on top.

    ol.team-list li a, ol.stadium-list li a {
        display: flex;
        align-items: top;
    }
    Thread Starter af3

    (@af3)

    That works. You are awesome!

    Thread Starter af3

    (@af3)

    Thank for the suggestion. I just dont know how to do it 🙂

    its already doing that.. no ?

    ok.

    Thread Starter af3

    (@af3)

    thanks

Viewing 15 replies - 61 through 75 (of 246 total)