Plugin Directory

Changeset 3042119


Ignore:
Timestamp:
02/27/2024 05:37:07 PM (2 years ago)
Author:
mtreherne
Message:

Release of Version 3.9

Location:
eh-gms-feed
Files:
8 edited

Legend:

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

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

    r2981152 r3042119  
    1010class EH_GMS_Feed {
    1111
    12     private $basename, $settings, $atts_show, $not_valid, $filter_match, $table_name, $fixture_data, $display_name, $show_gender, $show_list;
     12    private $basename, $settings, $atts_show, $not_valid, $filter_match, $table_name, $fixture_data, $display_name, $show_gender, $show_list, $show_cal, $cal_summary;
    1313    private $club_link, $team_link, $comp_link, $team_comps, $comp_name;
    1414    private $args = ['method','show','team','comp_id','club_id','whatson','link','sort_by','options'];
     
    6464
    6565    private function get_json($key, $keys=[]) {
    66     $keys = (array) $keys; $valid_json = true; $link = null;
     66    $keys = (array) $keys; $valid_json = true;
    6767        $headers = ['headers' => ['Content-Type' => 'application/json;charset=UTF-8', 'x-functions-key' => $this->settings->gms_api_key]];
    6868        $transient_name = 'eh_gms_feed '.$this->api[$key]['transient'];
     
    8383                        case 'static' : $expiry = $this->settings->static_transient_expiry; break;
    8484                        case 'weekly' : $expiry = '604800'; break;
    85                         case 'matchday' : $expiry = '3540'; break;
    8685                        default : $expiry = $this->settings->default_transient_expiry;
    8786                    }
     
    9695                    $message = sprintf(esc_html__( 'Failed to get data with error: %s', 'eh-gms-feed' ), $error_message);
    9796                }
    98                 $link = $gms_api_url;
    9997            }
    10098        }
     
    118116                $valid_json = false;
    119117                $message = esc_html__( 'Failed to decode JSON.', 'eh-gms-feed' );
    120                 $link = $gms_api_url;
    121118            }
    122119        }
     
    125122            return [];
    126123        }
    127         else return $this->show_api_error($message, $link);
     124        else return $this->show_api_error($message);
    128125    }
    129126
     
    152149    }
    153150
    154     private function show_api_error ($message, $link) {
     151    private function show_api_error ($message) {
    155152        return '<p>'.sprintf(esc_html__( '%1$s', 'eh-gms-feed' ), $message).'</p>';
    156153    }
     
    367364    private function process_teamslist($data) {
    368365        $this->filter_match = false;
    369         $html = '<table class="gms-table gms-table-'.$this->display_name.'"><thead><tr><th>England Hockey Link</th><th>Gender</th></tr></thead><tbody>';
     366        $colspan = $this->show_cal ? 3 : 2;
     367        $cal_options = $this->cal_summary ? '&options=summary:'.$this->cal_summary : '';
     368        $html =  $this->show_cal ? '<p>If your calendar app supports subscribing to internet calendars (the WebCal protocol), then click on Copy WebCal for link to paste into your calendar app. For more help and advanced options please goto <a href="https://gmsfeed.co.uk/webcal?club_id='.$this->atts_show['club_id'].'" target="_blank">GMS Feed WebCal</a>.</p><p><span style="word-break: break-all" id="gms-webcal-link"><i>Click on Copy WebCal to select and copy link</i></span></p>' : '';
     369        $html .= '<table class="gms-table gms-table-'.$this->display_name.'"><thead><tr><th>England Hockey Link</th><th>Gender</th>'.($this->show_cal ? '<th>Fixtures Calendar</th>' : '').'</tr></thead><tbody>';
    370370        foreach ($data as $team) {
    371371            $this->filter_match = true;
    372             $html .= '<tr><td><a href="'.esc_attr($this->get_link('team', $team->entityUrlSlug)).'" target="_blank">'.esc_html($team->teamName).'</a></td><td>'.esc_html($team->gender).'</td></tr>';
     372            $calid = 'gms_webcal_'.$team->id;
     373            $webcal = $this->show_cal ? '<td><button type="button" class="gms-button gms-copy" data-copy_id="gms-webcal-link" data-copy_text="'.esc_html('webcal://gmsfeed.co.uk/api/calendar?team='.$team->id.$cal_options).'" title="'.esc_html($team->teamName).'">Copy WebCal</button></td>' : '';
     374            $html .= '<tr><td><a href="'.esc_attr($this->get_link('team', $team->entityUrlSlug)).'" target="_blank">'.esc_html($team->teamName).'</a></td><td>'.esc_html($team->gender).'</td>'.$webcal.'</tr>';
    373375            if (!$this->club_link) $this->club_link = $this->get_link('club', $team->clubUrlSlug);
    374376        }
    375         if (!$this->filter_match) $html .= '<tr><td colspan=2>No teams found</td></tr>';
     377        if (!$this->filter_match) $html .= '<tr><td colspan='.$colspan.'>No teams found</td></tr>';
    376378        $html .= '</tbody></table><div class="gms-footnote">'.($this->club_link ? sprintf(esc_html__( '[Club %1$s%3$s also found at%4$s %2$s]', 'eh-gms-feed' ), 'teams', '<a href="'.$this->club_link.'" target="_blank">England Hockey Link</a>', '<span class="gms-nomobile">', '</span>') : '').'</div>';
    377379        return $html;
     
    520522                if ($option_split[0] == 'showgender' && ($option_split[1] ?? '') == 'yes') $this->show_gender = true;
    521523                if ($option_split[0] == 'showlist' && ($option_split[1] ?? '') == 'yes') $this->show_list = true;
     524                if ($option_split[0] == 'showcal' && ($option_split[1] ?? '') == 'yes') $this->show_cal = true;
     525                if ($option_split[0] == 'calsummary') $this->cal_summary = $option_split[1] ?? '';
    522526            }
    523527        }
     
    536540
    537541    public function enqueue_scripts () {
    538         wp_register_script('EH_GMS_Feed', plugin_dir_url(__DIR__).'js/eh-gms-feed.js', ['jquery'], '3.8', true);
     542        wp_register_script('EH_GMS_Feed', plugin_dir_url(__DIR__).'js/eh-gms-feed.js', ['jquery'], '3.9', true);
    539543        wp_localize_script('EH_GMS_Feed', 'eh_gms_feed_ajax_obj', ['ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce('get_gms_table')]);
    540544        wp_register_style('EH_GMS_Feed', plugin_dir_url(__DIR__).'css/gms-default.css',[],'3.8');
  • eh-gms-feed/tags/3.9/js/eh-gms-feed.js

    r2981152 r3042119  
    125125                }
    126126                else ele.html(data);
     127                if (options && options.includes('showCal:yes')) ele.on('click', '.gms-copy', function(event) {
     128                    var text = event.target.dataset.copy_text;
     129                    var ele = document.getElementById(event.target.dataset.copy_id);
     130                    if (text) ele.textContent = text;
     131                    var range = document.createRange();
     132                    var selection = window.getSelection();
     133                    range.selectNodeContents(ele);
     134                    selection.removeAllRanges();
     135                    selection.addRange(range);
     136                    document.execCommand('copy');
     137                });
    127138            })
    128139            .fail(function(response) {
  • eh-gms-feed/tags/3.9/readme.txt

    r2981152 r3042119  
    55Tested up to: 6.2
    66Requires PHP: 5.3
    7 Stable tag: 3.8
     7Stable tag: 3.9
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6363== Changelog ==
    6464
     65= 3.9 =
     66* Added option to provide link to WebCal with club teams list
     67
    6568= 3.8 =
    6669* Added show as list option for fixtures and results
  • eh-gms-feed/trunk/eh-gms-feed.php

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

    r2981152 r3042119  
    1010class EH_GMS_Feed {
    1111
    12     private $basename, $settings, $atts_show, $not_valid, $filter_match, $table_name, $fixture_data, $display_name, $show_gender, $show_list;
     12    private $basename, $settings, $atts_show, $not_valid, $filter_match, $table_name, $fixture_data, $display_name, $show_gender, $show_list, $show_cal, $cal_summary;
    1313    private $club_link, $team_link, $comp_link, $team_comps, $comp_name;
    1414    private $args = ['method','show','team','comp_id','club_id','whatson','link','sort_by','options'];
     
    6464
    6565    private function get_json($key, $keys=[]) {
    66     $keys = (array) $keys; $valid_json = true; $link = null;
     66    $keys = (array) $keys; $valid_json = true;
    6767        $headers = ['headers' => ['Content-Type' => 'application/json;charset=UTF-8', 'x-functions-key' => $this->settings->gms_api_key]];
    6868        $transient_name = 'eh_gms_feed '.$this->api[$key]['transient'];
     
    8383                        case 'static' : $expiry = $this->settings->static_transient_expiry; break;
    8484                        case 'weekly' : $expiry = '604800'; break;
    85                         case 'matchday' : $expiry = '3540'; break;
    8685                        default : $expiry = $this->settings->default_transient_expiry;
    8786                    }
     
    9695                    $message = sprintf(esc_html__( 'Failed to get data with error: %s', 'eh-gms-feed' ), $error_message);
    9796                }
    98                 $link = $gms_api_url;
    9997            }
    10098        }
     
    118116                $valid_json = false;
    119117                $message = esc_html__( 'Failed to decode JSON.', 'eh-gms-feed' );
    120                 $link = $gms_api_url;
    121118            }
    122119        }
     
    125122            return [];
    126123        }
    127         else return $this->show_api_error($message, $link);
     124        else return $this->show_api_error($message);
    128125    }
    129126
     
    152149    }
    153150
    154     private function show_api_error ($message, $link) {
     151    private function show_api_error ($message) {
    155152        return '<p>'.sprintf(esc_html__( '%1$s', 'eh-gms-feed' ), $message).'</p>';
    156153    }
     
    367364    private function process_teamslist($data) {
    368365        $this->filter_match = false;
    369         $html = '<table class="gms-table gms-table-'.$this->display_name.'"><thead><tr><th>England Hockey Link</th><th>Gender</th></tr></thead><tbody>';
     366        $colspan = $this->show_cal ? 3 : 2;
     367        $cal_options = $this->cal_summary ? '&options=summary:'.$this->cal_summary : '';
     368        $html =  $this->show_cal ? '<p>If your calendar app supports subscribing to internet calendars (the WebCal protocol), then click on Copy WebCal for link to paste into your calendar app. For more help and advanced options please goto <a href="https://gmsfeed.co.uk/webcal?club_id='.$this->atts_show['club_id'].'" target="_blank">GMS Feed WebCal</a>.</p><p><span style="word-break: break-all" id="gms-webcal-link"><i>Click on Copy WebCal to select and copy link</i></span></p>' : '';
     369        $html .= '<table class="gms-table gms-table-'.$this->display_name.'"><thead><tr><th>England Hockey Link</th><th>Gender</th>'.($this->show_cal ? '<th>Fixtures Calendar</th>' : '').'</tr></thead><tbody>';
    370370        foreach ($data as $team) {
    371371            $this->filter_match = true;
    372             $html .= '<tr><td><a href="'.esc_attr($this->get_link('team', $team->entityUrlSlug)).'" target="_blank">'.esc_html($team->teamName).'</a></td><td>'.esc_html($team->gender).'</td></tr>';
     372            $calid = 'gms_webcal_'.$team->id;
     373            $webcal = $this->show_cal ? '<td><button type="button" class="gms-button gms-copy" data-copy_id="gms-webcal-link" data-copy_text="'.esc_html('webcal://gmsfeed.co.uk/api/calendar?team='.$team->id.$cal_options).'" title="'.esc_html($team->teamName).'">Copy WebCal</button></td>' : '';
     374            $html .= '<tr><td><a href="'.esc_attr($this->get_link('team', $team->entityUrlSlug)).'" target="_blank">'.esc_html($team->teamName).'</a></td><td>'.esc_html($team->gender).'</td>'.$webcal.'</tr>';
    373375            if (!$this->club_link) $this->club_link = $this->get_link('club', $team->clubUrlSlug);
    374376        }
    375         if (!$this->filter_match) $html .= '<tr><td colspan=2>No teams found</td></tr>';
     377        if (!$this->filter_match) $html .= '<tr><td colspan='.$colspan.'>No teams found</td></tr>';
    376378        $html .= '</tbody></table><div class="gms-footnote">'.($this->club_link ? sprintf(esc_html__( '[Club %1$s%3$s also found at%4$s %2$s]', 'eh-gms-feed' ), 'teams', '<a href="'.$this->club_link.'" target="_blank">England Hockey Link</a>', '<span class="gms-nomobile">', '</span>') : '').'</div>';
    377379        return $html;
     
    520522                if ($option_split[0] == 'showgender' && ($option_split[1] ?? '') == 'yes') $this->show_gender = true;
    521523                if ($option_split[0] == 'showlist' && ($option_split[1] ?? '') == 'yes') $this->show_list = true;
     524                if ($option_split[0] == 'showcal' && ($option_split[1] ?? '') == 'yes') $this->show_cal = true;
     525                if ($option_split[0] == 'calsummary') $this->cal_summary = $option_split[1] ?? '';
    522526            }
    523527        }
     
    536540
    537541    public function enqueue_scripts () {
    538         wp_register_script('EH_GMS_Feed', plugin_dir_url(__DIR__).'js/eh-gms-feed.js', ['jquery'], '3.8', true);
     542        wp_register_script('EH_GMS_Feed', plugin_dir_url(__DIR__).'js/eh-gms-feed.js', ['jquery'], '3.9', true);
    539543        wp_localize_script('EH_GMS_Feed', 'eh_gms_feed_ajax_obj', ['ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce('get_gms_table')]);
    540544        wp_register_style('EH_GMS_Feed', plugin_dir_url(__DIR__).'css/gms-default.css',[],'3.8');
  • eh-gms-feed/trunk/js/eh-gms-feed.js

    r2981152 r3042119  
    125125                }
    126126                else ele.html(data);
     127                if (options && options.includes('showCal:yes')) ele.on('click', '.gms-copy', function(event) {
     128                    var text = event.target.dataset.copy_text;
     129                    var ele = document.getElementById(event.target.dataset.copy_id);
     130                    if (text) ele.textContent = text;
     131                    var range = document.createRange();
     132                    var selection = window.getSelection();
     133                    range.selectNodeContents(ele);
     134                    selection.removeAllRanges();
     135                    selection.addRange(range);
     136                    document.execCommand('copy');
     137                });
    127138            })
    128139            .fail(function(response) {
  • eh-gms-feed/trunk/readme.txt

    r2981152 r3042119  
    55Tested up to: 6.2
    66Requires PHP: 5.3
    7 Stable tag: 3.8
     7Stable tag: 3.9
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6363== Changelog ==
    6464
     65= 3.9 =
     66* Added option to provide link to WebCal with club teams list
     67
    6568= 3.8 =
    6669* Added show as list option for fixtures and results
Note: See TracChangeset for help on using the changeset viewer.