Changeset 2977585
- Timestamp:
- 10/11/2023 12:28:07 PM (2 years ago)
- Location:
- eh-gms-feed
- Files:
-
- 6 edited
-
tags/3.7/eh-gms-feed.php (modified) (1 diff)
-
tags/3.7/includes/main-class.php (modified) (5 diffs)
-
tags/3.7/readme.txt (modified) (2 diffs)
-
trunk/eh-gms-feed.php (modified) (1 diff)
-
trunk/includes/main-class.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
eh-gms-feed/tags/3.7/eh-gms-feed.php
r2968572 r2977585 4 4 * Plugin URI: https://wordpress.org/plugins/eh-gms-feed/ 5 5 * Description: Show fixtures, results and tables from England Hockey GMS 6 * Version: 3. 66 * Version: 3.7 7 7 * Author: Matthew Treherne 8 8 * Author URI: https://profiles.wordpress.org/mtreherne -
eh-gms-feed/tags/3.7/includes/main-class.php
r2968572 r2977585 14 14 private $args = ['method','show','team','comp_id','club_id','whatson','link','sort_by','options']; 15 15 private $api = [ 16 'table' => ['transient' => 'COMPETITION LEAGUE', 'keys' => ['competitions'], 'error_bag' => null ],17 'fixturesandresults' => ['transient' => 'TEAM', 'keys' => ['teams'], 'error_bag' => null ],18 'matchdays' => ['transient' => 'CLUB MATCHDAYS', 'keys' => ['clubs'], 'error_bag' => null ],19 'matchday' => ['suffix' => '', 'transient' => 'CLUB MATCHDAY', 'keys' => ['clubs', 'matchdays'], 'error_bag' => null ],20 'teamsinclub' => ['suffix' => 'teams', 'transient' => 'CLUB TEAMS', 'keys' => ['clubs'], 'error_bag' => 'teamselected' ],21 'teamslist' => ['suffix' => 'teams', 'transient' => 'CLUB TEAMS', 'keys' => ['clubs'], 'error_bag' => null ],22 'compsinfixtures' => ['suffix' => 'fixturesandresults', 'transient' => 'TEAM', 'keys' => ['teams'], 'error_bag' => 'competition' ],23 'competition' => ['suffix' => '', 'transient' => 'COMPETITION SUMMARY', 'keys' => ['competitions'], 'error_bag' => null ],16 'table' => ['transient' => 'COMPETITION LEAGUE', 'keys' => ['competitions'], 'error_bag' => null, 'expiry' => 'default'], 17 'fixturesandresults' => ['transient' => 'TEAM', 'keys' => ['teams'], 'error_bag' => null, 'expiry' => 'default'], 18 'matchdays' => ['transient' => 'CLUB MATCHDAYS', 'keys' => ['clubs'], 'error_bag' => null, 'expiry' => 'default'], 19 'matchday' => ['suffix' => '', 'transient' => 'CLUB MATCHDAY', 'keys' => ['clubs', 'matchdays'], 'error_bag' => null, 'expiry' => 'static'], 20 'teamsinclub' => ['suffix' => 'teams', 'transient' => 'CLUB TEAMS', 'keys' => ['clubs'], 'error_bag' => 'teamselected', 'expiry' => 'static'], 21 'teamslist' => ['suffix' => 'teams', 'transient' => 'CLUB TEAMS', 'keys' => ['clubs'], 'error_bag' => null, 'expiry' => 'static'], 22 'compsinfixtures' => ['suffix' => 'fixturesandresults', 'transient' => 'TEAM', 'keys' => ['teams'], 'error_bag' => 'competition', 'expiry' => 'default'], 23 'competition' => ['suffix' => '', 'transient' => 'COMPETITION SUMMARY', 'keys' => ['competitions'], 'error_bag' => null, 'expiry' => 'default'], 24 24 ]; 25 25 … … 27 27 $this->basename = $GLOBALS['EH_GMS_Feed_basename']; 28 28 $this->settings = new Settings($this->basename); 29 $this->settings->static_transient_expiry = '86400'; 29 30 add_shortcode( 'gms', array( $this, 'gms_shortcode' ) ); 30 31 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); … … 78 79 if ($http_code == 200) { 79 80 $body = wp_remote_retrieve_body($response); 80 if (strlen($transient_name) <= 172) set_transient($transient_name, $body, $this->settings->default_transient_expiry); 81 if (strlen($transient_name) <= 172) { 82 switch ($this->api[$key]['expiry']) { 83 case 'static' : $expiry = $this->settings->static_transient_expiry; break; 84 case 'weekly' : $expiry = '604800'; break; 85 case 'matchday' : $expiry = '3540'; break; 86 default : $expiry = $this->settings->default_transient_expiry; 87 } 88 set_transient($transient_name, $body, $expiry); 89 } 81 90 } 82 91 else { … … 167 176 foreach ($fixtures as $fixture) { 168 177 $valid_date = new \DateTime($fixture->fixtureDate); 178 if ($fixture->isBye) continue; 169 179 if ($this->table_name == 'fixtures') { 170 180 if ($fixture->isResult || $this->is_beforetoday($valid_date)) continue; 171 181 } 172 182 elseif ($this->table_name == 'results') { 173 if ($fixture->isBye || (!$fixture->isResult && !$this->is_beforetoday($valid_date))) continue; 174 } 175 elseif ($this->table_name == 'combined') { 176 if ($fixture->isBye && $this->is_beforetoday($valid_date)) continue; 183 if (!$fixture->isResult && !$this->is_beforetoday($valid_date)) continue; 177 184 } 178 185 if ($this->filter_whatson($valid_date)) continue; … … 186 193 if ($fixture->isResult && !$fixture->isBye) { 187 194 $value = $fixture->{$field_name[0]} . ' : ' . $fixture->{$field_name[1]}; 188 if ($fixture->homeTeamScore == $fixture->awayTeamScore) $class = ' class="gms-draw"'; 195 if ($fixture->status == 'Postponed' || ($fixture->homeTeamScore == 'P' && $fixture->awayTeamScore == 'P')); 196 elseif ($fixture->homeTeamScore == $fixture->awayTeamScore) $class = ' class="gms-draw"'; 189 197 elseif (($fixture->homeTeam->id == $this->atts_show['team'] || ($this->is_clubwide() && $fixture->homeTeam->clubId == $this->atts_show['club_id'])) && $fixture->homeTeamScore > $fixture->awayTeamScore) $class = ' class="gms-win"'; 190 198 elseif (($fixture->awayTeam->id == $this->atts_show['team'] || ($this->is_clubwide() && $fixture->awayTeam->clubId == $this->atts_show['club_id'])) && $fixture->homeTeamScore < $fixture->awayTeamScore) $class = ' class="gms-win"'; -
eh-gms-feed/tags/3.7/readme.txt
r2968572 r2977585 5 5 Tested up to: 6.2 6 6 Requires PHP: 5.3 7 Stable tag: 3. 67 Stable tag: 3.7 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 63 63 == Changelog == 64 64 65 = 3.7 = 66 * Fix to not add gms-draw class to postponement 67 * Tweak to consistently not show bye fixtures 68 * Tweak to cache expiry for static data 69 65 70 = 3.6 = 66 71 * Fix to default settings -
eh-gms-feed/trunk/eh-gms-feed.php
r2968572 r2977585 4 4 * Plugin URI: https://wordpress.org/plugins/eh-gms-feed/ 5 5 * Description: Show fixtures, results and tables from England Hockey GMS 6 * Version: 3. 66 * Version: 3.7 7 7 * Author: Matthew Treherne 8 8 * Author URI: https://profiles.wordpress.org/mtreherne -
eh-gms-feed/trunk/includes/main-class.php
r2968572 r2977585 14 14 private $args = ['method','show','team','comp_id','club_id','whatson','link','sort_by','options']; 15 15 private $api = [ 16 'table' => ['transient' => 'COMPETITION LEAGUE', 'keys' => ['competitions'], 'error_bag' => null ],17 'fixturesandresults' => ['transient' => 'TEAM', 'keys' => ['teams'], 'error_bag' => null ],18 'matchdays' => ['transient' => 'CLUB MATCHDAYS', 'keys' => ['clubs'], 'error_bag' => null ],19 'matchday' => ['suffix' => '', 'transient' => 'CLUB MATCHDAY', 'keys' => ['clubs', 'matchdays'], 'error_bag' => null ],20 'teamsinclub' => ['suffix' => 'teams', 'transient' => 'CLUB TEAMS', 'keys' => ['clubs'], 'error_bag' => 'teamselected' ],21 'teamslist' => ['suffix' => 'teams', 'transient' => 'CLUB TEAMS', 'keys' => ['clubs'], 'error_bag' => null ],22 'compsinfixtures' => ['suffix' => 'fixturesandresults', 'transient' => 'TEAM', 'keys' => ['teams'], 'error_bag' => 'competition' ],23 'competition' => ['suffix' => '', 'transient' => 'COMPETITION SUMMARY', 'keys' => ['competitions'], 'error_bag' => null ],16 'table' => ['transient' => 'COMPETITION LEAGUE', 'keys' => ['competitions'], 'error_bag' => null, 'expiry' => 'default'], 17 'fixturesandresults' => ['transient' => 'TEAM', 'keys' => ['teams'], 'error_bag' => null, 'expiry' => 'default'], 18 'matchdays' => ['transient' => 'CLUB MATCHDAYS', 'keys' => ['clubs'], 'error_bag' => null, 'expiry' => 'default'], 19 'matchday' => ['suffix' => '', 'transient' => 'CLUB MATCHDAY', 'keys' => ['clubs', 'matchdays'], 'error_bag' => null, 'expiry' => 'static'], 20 'teamsinclub' => ['suffix' => 'teams', 'transient' => 'CLUB TEAMS', 'keys' => ['clubs'], 'error_bag' => 'teamselected', 'expiry' => 'static'], 21 'teamslist' => ['suffix' => 'teams', 'transient' => 'CLUB TEAMS', 'keys' => ['clubs'], 'error_bag' => null, 'expiry' => 'static'], 22 'compsinfixtures' => ['suffix' => 'fixturesandresults', 'transient' => 'TEAM', 'keys' => ['teams'], 'error_bag' => 'competition', 'expiry' => 'default'], 23 'competition' => ['suffix' => '', 'transient' => 'COMPETITION SUMMARY', 'keys' => ['competitions'], 'error_bag' => null, 'expiry' => 'default'], 24 24 ]; 25 25 … … 27 27 $this->basename = $GLOBALS['EH_GMS_Feed_basename']; 28 28 $this->settings = new Settings($this->basename); 29 $this->settings->static_transient_expiry = '86400'; 29 30 add_shortcode( 'gms', array( $this, 'gms_shortcode' ) ); 30 31 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); … … 78 79 if ($http_code == 200) { 79 80 $body = wp_remote_retrieve_body($response); 80 if (strlen($transient_name) <= 172) set_transient($transient_name, $body, $this->settings->default_transient_expiry); 81 if (strlen($transient_name) <= 172) { 82 switch ($this->api[$key]['expiry']) { 83 case 'static' : $expiry = $this->settings->static_transient_expiry; break; 84 case 'weekly' : $expiry = '604800'; break; 85 case 'matchday' : $expiry = '3540'; break; 86 default : $expiry = $this->settings->default_transient_expiry; 87 } 88 set_transient($transient_name, $body, $expiry); 89 } 81 90 } 82 91 else { … … 167 176 foreach ($fixtures as $fixture) { 168 177 $valid_date = new \DateTime($fixture->fixtureDate); 178 if ($fixture->isBye) continue; 169 179 if ($this->table_name == 'fixtures') { 170 180 if ($fixture->isResult || $this->is_beforetoday($valid_date)) continue; 171 181 } 172 182 elseif ($this->table_name == 'results') { 173 if ($fixture->isBye || (!$fixture->isResult && !$this->is_beforetoday($valid_date))) continue; 174 } 175 elseif ($this->table_name == 'combined') { 176 if ($fixture->isBye && $this->is_beforetoday($valid_date)) continue; 183 if (!$fixture->isResult && !$this->is_beforetoday($valid_date)) continue; 177 184 } 178 185 if ($this->filter_whatson($valid_date)) continue; … … 186 193 if ($fixture->isResult && !$fixture->isBye) { 187 194 $value = $fixture->{$field_name[0]} . ' : ' . $fixture->{$field_name[1]}; 188 if ($fixture->homeTeamScore == $fixture->awayTeamScore) $class = ' class="gms-draw"'; 195 if ($fixture->status == 'Postponed' || ($fixture->homeTeamScore == 'P' && $fixture->awayTeamScore == 'P')); 196 elseif ($fixture->homeTeamScore == $fixture->awayTeamScore) $class = ' class="gms-draw"'; 189 197 elseif (($fixture->homeTeam->id == $this->atts_show['team'] || ($this->is_clubwide() && $fixture->homeTeam->clubId == $this->atts_show['club_id'])) && $fixture->homeTeamScore > $fixture->awayTeamScore) $class = ' class="gms-win"'; 190 198 elseif (($fixture->awayTeam->id == $this->atts_show['team'] || ($this->is_clubwide() && $fixture->awayTeam->clubId == $this->atts_show['club_id'])) && $fixture->homeTeamScore < $fixture->awayTeamScore) $class = ' class="gms-win"'; -
eh-gms-feed/trunk/readme.txt
r2968572 r2977585 5 5 Tested up to: 6.2 6 6 Requires PHP: 5.3 7 Stable tag: 3. 67 Stable tag: 3.7 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 63 63 == Changelog == 64 64 65 = 3.7 = 66 * Fix to not add gms-draw class to postponement 67 * Tweak to consistently not show bye fixtures 68 * Tweak to cache expiry for static data 69 65 70 = 3.6 = 66 71 * Fix to default settings
Note: See TracChangeset
for help on using the changeset viewer.