Changeset 3042119
- Timestamp:
- 02/27/2024 05:37:07 PM (2 years ago)
- Location:
- eh-gms-feed
- Files:
-
- 8 edited
-
tags/3.9/eh-gms-feed.php (modified) (1 diff)
-
tags/3.9/includes/main-class.php (modified) (10 diffs)
-
tags/3.9/js/eh-gms-feed.js (modified) (1 diff)
-
tags/3.9/readme.txt (modified) (2 diffs)
-
trunk/eh-gms-feed.php (modified) (1 diff)
-
trunk/includes/main-class.php (modified) (10 diffs)
-
trunk/js/eh-gms-feed.js (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
eh-gms-feed/tags/3.9/eh-gms-feed.php
r2981152 r3042119 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. 86 * Version: 3.9 7 7 * Author: Matthew Treherne 8 8 * Author URI: https://profiles.wordpress.org/mtreherne -
eh-gms-feed/tags/3.9/includes/main-class.php
r2981152 r3042119 10 10 class EH_GMS_Feed { 11 11 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; 13 13 private $club_link, $team_link, $comp_link, $team_comps, $comp_name; 14 14 private $args = ['method','show','team','comp_id','club_id','whatson','link','sort_by','options']; … … 64 64 65 65 private function get_json($key, $keys=[]) { 66 $keys = (array) $keys; $valid_json = true; $link = null;66 $keys = (array) $keys; $valid_json = true; 67 67 $headers = ['headers' => ['Content-Type' => 'application/json;charset=UTF-8', 'x-functions-key' => $this->settings->gms_api_key]]; 68 68 $transient_name = 'eh_gms_feed '.$this->api[$key]['transient']; … … 83 83 case 'static' : $expiry = $this->settings->static_transient_expiry; break; 84 84 case 'weekly' : $expiry = '604800'; break; 85 case 'matchday' : $expiry = '3540'; break;86 85 default : $expiry = $this->settings->default_transient_expiry; 87 86 } … … 96 95 $message = sprintf(esc_html__( 'Failed to get data with error: %s', 'eh-gms-feed' ), $error_message); 97 96 } 98 $link = $gms_api_url;99 97 } 100 98 } … … 118 116 $valid_json = false; 119 117 $message = esc_html__( 'Failed to decode JSON.', 'eh-gms-feed' ); 120 $link = $gms_api_url;121 118 } 122 119 } … … 125 122 return []; 126 123 } 127 else return $this->show_api_error($message , $link);124 else return $this->show_api_error($message); 128 125 } 129 126 … … 152 149 } 153 150 154 private function show_api_error ($message , $link) {151 private function show_api_error ($message) { 155 152 return '<p>'.sprintf(esc_html__( '%1$s', 'eh-gms-feed' ), $message).'</p>'; 156 153 } … … 367 364 private function process_teamslist($data) { 368 365 $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>'; 370 370 foreach ($data as $team) { 371 371 $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>'; 373 375 if (!$this->club_link) $this->club_link = $this->get_link('club', $team->clubUrlSlug); 374 376 } 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>'; 376 378 $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>'; 377 379 return $html; … … 520 522 if ($option_split[0] == 'showgender' && ($option_split[1] ?? '') == 'yes') $this->show_gender = true; 521 523 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] ?? ''; 522 526 } 523 527 } … … 536 540 537 541 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); 539 543 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')]); 540 544 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 125 125 } 126 126 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 }); 127 138 }) 128 139 .fail(function(response) { -
eh-gms-feed/tags/3.9/readme.txt
r2981152 r3042119 5 5 Tested up to: 6.2 6 6 Requires PHP: 5.3 7 Stable tag: 3. 87 Stable tag: 3.9 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 63 63 == Changelog == 64 64 65 = 3.9 = 66 * Added option to provide link to WebCal with club teams list 67 65 68 = 3.8 = 66 69 * Added show as list option for fixtures and results -
eh-gms-feed/trunk/eh-gms-feed.php
r2981152 r3042119 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. 86 * Version: 3.9 7 7 * Author: Matthew Treherne 8 8 * Author URI: https://profiles.wordpress.org/mtreherne -
eh-gms-feed/trunk/includes/main-class.php
r2981152 r3042119 10 10 class EH_GMS_Feed { 11 11 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; 13 13 private $club_link, $team_link, $comp_link, $team_comps, $comp_name; 14 14 private $args = ['method','show','team','comp_id','club_id','whatson','link','sort_by','options']; … … 64 64 65 65 private function get_json($key, $keys=[]) { 66 $keys = (array) $keys; $valid_json = true; $link = null;66 $keys = (array) $keys; $valid_json = true; 67 67 $headers = ['headers' => ['Content-Type' => 'application/json;charset=UTF-8', 'x-functions-key' => $this->settings->gms_api_key]]; 68 68 $transient_name = 'eh_gms_feed '.$this->api[$key]['transient']; … … 83 83 case 'static' : $expiry = $this->settings->static_transient_expiry; break; 84 84 case 'weekly' : $expiry = '604800'; break; 85 case 'matchday' : $expiry = '3540'; break;86 85 default : $expiry = $this->settings->default_transient_expiry; 87 86 } … … 96 95 $message = sprintf(esc_html__( 'Failed to get data with error: %s', 'eh-gms-feed' ), $error_message); 97 96 } 98 $link = $gms_api_url;99 97 } 100 98 } … … 118 116 $valid_json = false; 119 117 $message = esc_html__( 'Failed to decode JSON.', 'eh-gms-feed' ); 120 $link = $gms_api_url;121 118 } 122 119 } … … 125 122 return []; 126 123 } 127 else return $this->show_api_error($message , $link);124 else return $this->show_api_error($message); 128 125 } 129 126 … … 152 149 } 153 150 154 private function show_api_error ($message , $link) {151 private function show_api_error ($message) { 155 152 return '<p>'.sprintf(esc_html__( '%1$s', 'eh-gms-feed' ), $message).'</p>'; 156 153 } … … 367 364 private function process_teamslist($data) { 368 365 $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>'; 370 370 foreach ($data as $team) { 371 371 $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>'; 373 375 if (!$this->club_link) $this->club_link = $this->get_link('club', $team->clubUrlSlug); 374 376 } 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>'; 376 378 $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>'; 377 379 return $html; … … 520 522 if ($option_split[0] == 'showgender' && ($option_split[1] ?? '') == 'yes') $this->show_gender = true; 521 523 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] ?? ''; 522 526 } 523 527 } … … 536 540 537 541 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); 539 543 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')]); 540 544 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 125 125 } 126 126 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 }); 127 138 }) 128 139 .fail(function(response) { -
eh-gms-feed/trunk/readme.txt
r2981152 r3042119 5 5 Tested up to: 6.2 6 6 Requires PHP: 5.3 7 Stable tag: 3. 87 Stable tag: 3.9 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 63 63 == Changelog == 64 64 65 = 3.9 = 66 * Added option to provide link to WebCal with club teams list 67 65 68 = 3.8 = 66 69 * Added show as list option for fixtures and results
Note: See TracChangeset
for help on using the changeset viewer.