af3
Forum Replies Created
-
Forum: Plugins
In reply to: [Football Pool] Log every user prediction@antoineh is it possible to add time of entry in pool_wprw_predictions db table so this can be shown on the prediction page i.e. the time when user made the predictions. I had similar issues when user that didnt make any prediction (nothing saved in db) contesting that he did made a prediction and blaming the system instead for not saving.
Forum: Plugins
In reply to: [Football Pool] Issue with prediction score “0”Thanks!
Forum: Plugins
In reply to: [Football Pool] Next Match widget time is offAntoine
I added this js in header.php of my theme:<script type="text/javascript"> <!-- Get the user timezone --> var timezone_offset_minutes = new Date().getTimezoneOffset(); timezone_offset_minutes = timezone_offset_minutes == 0 ? 0 : -timezone_offset_minutes; <!-- Timezone difference in minutes such as 330 or -360 or 0 --> console.log(timezone_offset_minutes); </script>
And made this function inside class-football-pool-utils.php like this:
public static function date_from_gmt( $date_string, $date_format = 'Y-m-d H:i' ) { $timezone_offset_minutes = $_GET['timezone_offset_minutes']; // Convert minutes to seconds $timezone_name = timezone_name_from_abbr("", $timezone_offset_minutes*60, false); date_default_timezone_set($timezone_name); if ( strlen( $date_string ) === strlen( '0000-00-00 00:00' ) ) $date_string .= ':00'; return $date_string !== '' ? get_date_from_gmt( $date_string, $date_format ) : ''; }
Not sure if this is the best but seems like the countdown changes based on my pc’s timezone.
Forum: Plugins
In reply to: [Football Pool] Issue with prediction score “0”Nice!
How abt only making 0 when saving instead of adding during recalc? So only those input being saved are checked if NULL and changed to 0. Just a thought.Forum: Plugins
In reply to: [Football Pool] Next Match widget time is offThanks Antoine. Maybe can use javascript to populate a session that has the user timezone and call in php that session data to calculate the countdown? Anyway i dont know hpw to do this ;(
Forum: Plugins
In reply to: [Football Pool] Issue with prediction score “0”Maybe there is a way to put empty to default to zero?
Forum: Plugins
In reply to: [Football Pool] show user predictions for open matchesThe “show user predictions” is already showing all users predictions in addition to the current user. No ?
The url https://your.domain.com/statistics/?view=matchpredictions&match=xxx shows a table with all users predictions?
Forum: Plugins
In reply to: [Football Pool] Allow admin to view user predictionYes. I wanted Site Admin to be able to view predictions of users, ranking etc — but I guess, in this case it wont work. I’ll have to login as the pool user. Thanks
Forum: Plugins
In reply to: [Football Pool] Allow admin to use shoutboxHey — this works! It now shows Site Admin instead of unknown user. Thanks.
Forum: Plugins
In reply to: [Football Pool] Add Group name in [fp-group id=x]Got it. Thx
DOne. thx
I think event manager is not using any local language.. it uses wordpress translation.
I had the same problem and use this hack to force EM to use local translation using loco.I added this in functions.php and it now loads the loco translation file. But seems like not all strings are translatable… for example, if you are using buddypress, the “xx added the event xxx” is not translated.
1. Added to your theme’s functions.php
function my_custom_em_plugin_translations() { $text = 'events-manager'; $locale = apply_filters( 'plugin_locale', function_exists( 'determine_locale' ) ? determine_locale() : get_locale(), $text ); $mofile = WP_CONTENT_DIR . '/languages/plugins/'. $text . '-' . $locale . '.mo'; $loaded = load_textdomain( $text, $mofile ); if( !$loaded ) { $loaded = load_plugin_textdomain( $text, false, '/languages/' ); } if( !$loaded ) { $loaded = load_muplugin_textdomain( $text, '/languages/' ); } } add_action('init', 'my_custom_em_plugin_translations');
2. You must save your loco translated mo file (under setup) to the same dir as you set above
Maybe related to this too… my experice with the latest update so far..
the calendar flatpickr doesnt change the month everytime we click on the left/right arrow. The month stays unchanged.
ughhh..
Forum: Themes and Templates
In reply to: [Kadence] Translate “LISTEN TO THE MESSAGE”Duh.. its in Customize archive layout!! lol..
Forum: Plugins
In reply to: [Football Pool] Add “Currently Playing”@magicjohnson Hi, I am not a PHP programmer, this is just based on what I gather but so far it works for me. Its not the best code, maybe someone can help make it better. I added +8 to return the local time in my case; so you have to change this based on what is your GMT.
Btw, this is a plugin so you have to save it as a php file and put in the root of the \plugin folder and activate win wp-admin.
I also added the “locked” text in addition to the additional “Save” button. You can remove this if not needed.
Also added is a link to “Insights” for match_type > 2 — I used it in Euro 2020 for knockout rounds (match_type 2 and above) just to add a manually created page of the match to add some articles or for people to comment on. You can change the match_type, or remove the whole thing if not needed.<?php /** * Plugin Name: Football Pool - Playing Now & Extra Save Buttons * Description: Add "Playing now" for every match and Extra Save buttons, added by af3 */ // 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_card_template' ), null, 2 ); add_filter( 'footballpool_predictionform_match_template_params', array( __CLASS__, 'change_parameters' ), null, 4 ); } public static function change_parameters( $match_template_params, $match_id, $user_id, $is_user_page ) { // 1. First we add Playing Now Params $mynote = ''; $current_date = gmdate('M d, Y', strtotime('+ 8 hours')); $current_timestamp = gmdate('M d, Y H:i:s', strtotime('+ 8 hours')); $game_date = $match_template_params['match_datetime_formatted'].' '.$match_template_params['match_time']; $duration = strtotime($game_date) - strtotime($current_timestamp); $min = $duration / 60; $hours = floor(abs($min) / 60); $minutes = (abs($min) % 60); if ( $current_date == $match_template_params['match_datetime_formatted'] ) { if ($min > 1 && $min < 116 ) { $mynote = '<span class="playing-now">Starting in ' .round($min,0). ' mins</span>'; } elseif ($min > 116 ) { $mynote = '<span class="playing-now">Playing in ' .$hours.' hrs, '. $minutes. ' mins</span>'; } elseif ($min < -116 ) { $mynote = '<span class="playing-now">Played '.round(abs($min),0).' mins ago</span>'; } elseif ($min > -166 && $min < 1 ) { $mynote = '<span class="playing-now">Started '.round(abs($min),0).' mins ago</span>'; } } elseif ( strtotime($current_date) < strtotime($match_template_params['match_datetime_formatted']) ) { if ($min < 240 ) { $mynote = '<span class="playing-now">Playing in '. round(abs($min),0). ' mins</span>'; } else { $mynote = '<span class="playing-now">Coming up</span>'; } } elseif ( strtotime($current_date) > strtotime($match_template_params['match_datetime_formatted']) ) { $mynote = '<span class="playing-now">Completed</span>'; } if ($match_template_params['match_type_id'] > 2) { $match_template_params['home_team']= str_replace(' ', '-', $match_template_params['home_team']); $match_template_params['away_team']= str_replace(' ', '-', $match_template_params['away_team']); $mynote .= '<span class="match_info"><a href="'.home_url( '/' ).strtolower($match_template_params['home_team']).'-vs-'.strtolower($match_template_params['away_team']).'">Insights</a></span>'; } $match_template_params['play_started'] = $mynote; // 3. Now we add extra save buttons if ( $match_template_params['match_is_editable'] == true ) { $match_template_params['save_button'] = '<input type="submit" value="save" /><span class="closing-time">Locked 15mins before match</span>'; } else { $match_template_params['save_button'] = ''; } // 4. FInally, send all the new params for the template return $match_template_params; } public static function match_card_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% %save_button%</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 class="match-card-save">%save_button%</div> </div>'; } } return $match_template; } } add_filter( 'plugins_loaded', array( 'FootballPoolExtensionPlayNow', 'init_extension' ) );