Plugin Directory

Changeset 2977585


Ignore:
Timestamp:
10/11/2023 12:28:07 PM (2 years ago)
Author:
mtreherne
Message:

Release of Version 3.7

Location:
eh-gms-feed
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • eh-gms-feed/tags/3.7/eh-gms-feed.php

    r2968572 r2977585  
    44 * Plugin URI: https://wordpress.org/plugins/eh-gms-feed/
    55 * Description: Show fixtures, results and tables from England Hockey GMS
    6  * Version: 3.6
     6 * Version: 3.7
    77 * Author: Matthew Treherne
    88 * Author URI: https://profiles.wordpress.org/mtreherne
  • eh-gms-feed/tags/3.7/includes/main-class.php

    r2968572 r2977585  
    1414    private $args = ['method','show','team','comp_id','club_id','whatson','link','sort_by','options'];
    1515    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'],
    2424    ];
    2525
     
    2727        $this->basename = $GLOBALS['EH_GMS_Feed_basename'];
    2828        $this->settings = new Settings($this->basename);
     29        $this->settings->static_transient_expiry = '86400';
    2930        add_shortcode( 'gms', array( $this, 'gms_shortcode' ) );
    3031        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
     
    7879            if ($http_code == 200) {
    7980                $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                }
    8190            }
    8291            else {
     
    167176        foreach ($fixtures as $fixture) {
    168177            $valid_date = new \DateTime($fixture->fixtureDate);
     178            if ($fixture->isBye) continue;
    169179            if ($this->table_name == 'fixtures') {
    170180                if ($fixture->isResult || $this->is_beforetoday($valid_date)) continue;
    171181            }
    172182            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;
    177184            }
    178185            if ($this->filter_whatson($valid_date)) continue;
     
    186193                            if ($fixture->isResult && !$fixture->isBye) {
    187194                                $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"';
    189197                                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"';
    190198                                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  
    55Tested up to: 6.2
    66Requires PHP: 5.3
    7 Stable tag: 3.6
     7Stable tag: 3.7
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6363== Changelog ==
    6464
     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
    6570= 3.6 =
    6671* Fix to default settings
  • eh-gms-feed/trunk/eh-gms-feed.php

    r2968572 r2977585  
    44 * Plugin URI: https://wordpress.org/plugins/eh-gms-feed/
    55 * Description: Show fixtures, results and tables from England Hockey GMS
    6  * Version: 3.6
     6 * Version: 3.7
    77 * Author: Matthew Treherne
    88 * Author URI: https://profiles.wordpress.org/mtreherne
  • eh-gms-feed/trunk/includes/main-class.php

    r2968572 r2977585  
    1414    private $args = ['method','show','team','comp_id','club_id','whatson','link','sort_by','options'];
    1515    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'],
    2424    ];
    2525
     
    2727        $this->basename = $GLOBALS['EH_GMS_Feed_basename'];
    2828        $this->settings = new Settings($this->basename);
     29        $this->settings->static_transient_expiry = '86400';
    2930        add_shortcode( 'gms', array( $this, 'gms_shortcode' ) );
    3031        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
     
    7879            if ($http_code == 200) {
    7980                $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                }
    8190            }
    8291            else {
     
    167176        foreach ($fixtures as $fixture) {
    168177            $valid_date = new \DateTime($fixture->fixtureDate);
     178            if ($fixture->isBye) continue;
    169179            if ($this->table_name == 'fixtures') {
    170180                if ($fixture->isResult || $this->is_beforetoday($valid_date)) continue;
    171181            }
    172182            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;
    177184            }
    178185            if ($this->filter_whatson($valid_date)) continue;
     
    186193                            if ($fixture->isResult && !$fixture->isBye) {
    187194                                $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"';
    189197                                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"';
    190198                                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  
    55Tested up to: 6.2
    66Requires PHP: 5.3
    7 Stable tag: 3.6
     7Stable tag: 3.7
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6363== Changelog ==
    6464
     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
    6570= 3.6 =
    6671* Fix to default settings
Note: See TracChangeset for help on using the changeset viewer.