SportsPress – Sports Club & League Manager - Version 2.7.9

Version Description

  • Tweak - Add support for event format in REST API.
  • Tweak - Add "Order" and "Order by" selection fields for countdown widget.
  • Tweak - Add option to display event status in countdown widget.
  • Tweak - Add ability to filter events by format in calendar template.
  • Tweak - Update TGM plugin activation library.
  • Fix - Remove plugin headers from modules for improved compatibility.
  • Fix - Reverse order not applying to teams in event lists.
  • Fix - Add validation to user inputs for improved security.
  • Fix - Sanitize all user inputs for improved security.
  • Fix - Escape all outputs in admin for improved security.
  • Fix - Filtering based on format for event blocks.
  • Fix - Last week and next week filter not applying to player lists.
  • Fix - Deselecting a selected team in settings.
  • Fix - PHP 8.0 deprecated warnings.
  • Localization - Add nationalities and flags for French Guiana, French Polynesia, Guadeloupe, Greenland, Martinique, Reunion, and Sint Maarten.
Download this release

Release Info

Developer ThemeBoy
Plugin Icon 128x128 SportsPress – Sports Club & League Manager
Version 2.7.9
Comparing to
See all releases

Code changes from version 2.7.8 to 2.7.9

Files changed (87) hide show
  1. assets/css/activation.css +5 -5
  2. assets/css/admin.css +52 -52
  3. assets/css/chosen.css +3 -3
  4. assets/css/customize.css +1 -1
  5. assets/css/equation.css +1 -1
  6. assets/css/leaflet.css +10 -10
  7. assets/css/menu.css +1 -1
  8. assets/css/setup.css +214 -214
  9. assets/css/slickmap.css +1 -1
  10. assets/css/sportspress-style-ltr.css +9 -9
  11. assets/css/sportspress-style-rtl.css +9 -9
  12. assets/css/sportspress-style.css +319 -319
  13. assets/css/sportspress.css +16 -16
  14. assets/css/themes/twentyfourteen.css +1 -1
  15. assets/images/flags/glp.png +0 -0
  16. assets/images/flags/grl.png +0 -0
  17. assets/images/flags/guf.png +0 -0
  18. assets/images/flags/mtq.png +0 -0
  19. assets/images/flags/pyf.png +0 -0
  20. assets/images/flags/reu.png +0 -0
  21. assets/images/flags/sxm.png +0 -0
  22. assets/js/admin/colorpicker.js +34 -22
  23. assets/js/admin/dashboard.js +16 -9
  24. assets/js/admin/editor-lang.php +46 -34
  25. assets/js/admin/editor.js +51 -35
  26. assets/js/admin/equationbuilder.js +52 -34
  27. assets/js/admin/iconpicker.js +47 -32
  28. assets/js/admin/quickeditor.js +58 -42
  29. assets/js/admin/settings.js +83 -55
  30. assets/js/admin/sp-geocoder.js +71 -49
  31. assets/js/admin/sp-setup-geocoder.js +71 -49
  32. assets/js/admin/sportspress-admin.js +1156 -861
  33. assets/js/admin/sportspress-setup.js +30 -22
  34. assets/js/admin/widgets.js +55 -36
  35. assets/js/blocks/event-calendar.js +84 -77
  36. assets/js/jquery.fitvids.js +64 -60
  37. assets/js/leaflet.js +1 -1
  38. assets/js/sportspress.js +115 -96
  39. changelog.txt +17 -0
  40. feeds/ical.php +61 -49
  41. includes/abstracts/abstract-sp-custom-post.php +11 -11
  42. includes/abstracts/abstract-sp-secondary-post.php +47 -47
  43. includes/admin/class-sp-admin-ajax.php +8 -8
  44. includes/admin/class-sp-admin-assets.php +112 -107
  45. includes/admin/class-sp-admin-dashboard.php +115 -86
  46. includes/admin/class-sp-admin-editor.php +6 -6
  47. includes/admin/class-sp-admin-importers.php +142 -136
  48. includes/admin/class-sp-admin-menus.php +251 -241
  49. includes/admin/class-sp-admin-notices.php +109 -105
  50. includes/admin/class-sp-admin-permalink-settings.php +90 -81
  51. includes/admin/class-sp-admin-post-types.php +94 -90
  52. includes/admin/class-sp-admin-sample-data.php +275 -156
  53. includes/admin/class-sp-admin-settings.php +708 -618
  54. includes/admin/class-sp-admin-setup-wizard.php +869 -771
  55. includes/admin/class-sp-admin-sports.php +97 -65
  56. includes/admin/class-sp-admin-status.php +53 -50
  57. includes/admin/class-sp-admin-taxonomies.php +117 -78
  58. includes/admin/class-sp-admin-welcome.php +435 -392
  59. includes/admin/class-sp-admin.php +27 -27
  60. includes/admin/importers/class-sp-event-importer.php +172 -125
  61. includes/admin/importers/class-sp-event-performance-importer.php +82 -55
  62. includes/admin/importers/class-sp-fixture-importer.php +116 -92
  63. includes/admin/importers/class-sp-importer.php +71 -51
  64. includes/admin/importers/class-sp-official-importer.php +28 -20
  65. includes/admin/importers/class-sp-player-importer.php +88 -62
  66. includes/admin/importers/class-sp-staff-importer.php +67 -41
  67. includes/admin/importers/class-sp-team-importer.php +43 -30
  68. includes/admin/post-types/class-sp-admin-cpt-calendar.php +148 -138
  69. includes/admin/post-types/class-sp-admin-cpt-column.php +66 -62
  70. includes/admin/post-types/class-sp-admin-cpt-event.php +309 -286
  71. includes/admin/post-types/class-sp-admin-cpt-list.php +144 -132
  72. includes/admin/post-types/class-sp-admin-cpt-metric.php +54 -50
  73. includes/admin/post-types/class-sp-admin-cpt-official.php +40 -35
  74. includes/admin/post-types/class-sp-admin-cpt-outcome.php +59 -55
  75. includes/admin/post-types/class-sp-admin-cpt-performance.php +68 -64
  76. includes/admin/post-types/class-sp-admin-cpt-player.php +338 -289
  77. includes/admin/post-types/class-sp-admin-cpt-result.php +54 -50
  78. includes/admin/post-types/class-sp-admin-cpt-spec.php +54 -50
  79. includes/admin/post-types/class-sp-admin-cpt-staff.php +158 -145
  80. includes/admin/post-types/class-sp-admin-cpt-statistic.php +66 -62
  81. includes/admin/post-types/class-sp-admin-cpt-table.php +122 -114
  82. includes/admin/post-types/class-sp-admin-cpt-team.php +126 -115
  83. includes/admin/post-types/class-sp-admin-cpt.php +50 -46
  84. includes/admin/post-types/class-sp-admin-meta-boxes.php +162 -146
  85. includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-columns.php +27 -25
  86. includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php +104 -84
  87. includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php +80 -79
assets/css/activation.css CHANGED
@@ -60,18 +60,18 @@ p.sportspress-actions a.button-primary:focus {
60
 
61
  .sportspress-steps:before,
62
  .sportspress-steps:after {
63
- content: " ";
64
- display: table;
65
  }
66
 
67
  .sportspress-steps:after {
68
- clear: both;
69
  }
70
 
71
  .sportspress-steps {
72
- *zoom: 1;
73
  }
74
 
75
  .sportspress-steps .welcome-icon i:before {
76
  color: #888;
77
- }
60
 
61
  .sportspress-steps:before,
62
  .sportspress-steps:after {
63
+ content: " ";
64
+ display: table;
65
  }
66
 
67
  .sportspress-steps:after {
68
+ clear: both;
69
  }
70
 
71
  .sportspress-steps {
72
+ *zoom: 1;
73
  }
74
 
75
  .sportspress-steps .welcome-icon i:before {
76
  color: #888;
77
+ }
assets/css/admin.css CHANGED
@@ -318,8 +318,8 @@ table.widefat.sp-data-table input[type="text"],
318
  table.widefat.sp-data-table input[type="number"] {
319
  min-width: 1.25em;
320
  width: 100%;
321
- margin: 1px;
322
- padding: 3px 5px;
323
  }
324
 
325
  table.widefat.sp-data-table input[type="text"]::placeholder,
@@ -681,28 +681,28 @@ table.widefat.sp-sortable-table tbody tr .icon {
681
 
682
  .sp-toggle-switch + label:before,
683
  .sp-toggle-switch + label:after {
684
- display: block;
685
- position: absolute;
686
- top: 0;
687
- left: 0;
688
- bottom: 0;
689
- content: "";
690
  }
691
 
692
  .sp-toggle-switch + label:before {
693
- right: 1px;
694
- background-color: #e4e4e4;
695
- border-radius: 16px;
696
- transition: background 0.4s;
697
  }
698
 
699
  .sp-toggle-switch + label:after {
700
- width: 16px;
701
- background-color: #fff;
702
- border-radius: 100%;
703
- -webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
704
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
705
- transition: margin 0.4s;
706
  }
707
 
708
  .sp-toggle-switch:checked + label:before {
@@ -735,7 +735,7 @@ table.widefat.sp-sortable-table tbody tr .icon {
735
  clear: both;
736
  max-width: 382px;
737
  width: 100%;
738
- box-sizing: border-box;
739
  }
740
 
741
  .sp-sortable-list .sp-item-float + .sp-item-float {
@@ -743,49 +743,49 @@ table.widefat.sp-sortable-table tbody tr .icon {
743
  }
744
 
745
  .sp-item-bar {
746
- clear: both;
747
- line-height: 1.5em;
748
- position: relative;
749
- margin: 9px 0 0;
750
  }
751
 
752
  .sp-item-bar .sp-item-handle {
753
  background: #fafafa;
754
  color: #23282d;
755
- border: 1px solid #dfdfdf;
756
- position: relative;
757
- padding: 10px 15px;
758
- height: auto;
759
- min-height: 20px;
760
- line-height: 30px;
761
- overflow: hidden;
762
- word-wrap: break-word;
763
  }
764
 
765
  .sp-item-bar .sp-item-handle:hover {
766
- border-color: #999;
767
- -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.1);
768
- box-shadow: 0 1px 2px rgba(0,0,0,.1);
769
  }
770
 
771
  .sp-item-bar .sp-item-title {
772
  font-size: 13px;
773
- font-weight: 600;
774
- line-height: 20px;
775
- display: block;
776
- margin-right: 13em;
777
  }
778
 
779
  .sp-item-settings {
780
- display: block;
781
- padding: 10px 0 10px 15px;
782
- position: relative;
783
- z-index: 10;
784
- background: #fff;
785
- border: 1px solid #e5e5e5;
786
- border-top: none;
787
- -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.04);
788
- box-shadow: 0 1px 1px rgba(0,0,0,.04);
789
  }
790
 
791
  .js .sp-item-handle {
@@ -793,9 +793,9 @@ table.widefat.sp-sortable-table tbody tr .icon {
793
  }
794
 
795
  .sp-sortable-list .sp-item-placeholder {
796
- border: 1px dashed #b4b9be;
797
- margin: 9px auto 6px;
798
- height: 42px;
799
  }
800
 
801
  /* Logo */
@@ -1225,7 +1225,7 @@ table.sp-status-table td mark.yes {
1225
  float: none;
1226
  margin-left: 0;
1227
  }
1228
-
1229
  .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-sp_format,
1230
  .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-sp_icon,
1231
  .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-sp_number {
@@ -1241,7 +1241,7 @@ table.sp-status-table td mark.yes {
1241
  margin-right: 0;
1242
  padding-right: 0;
1243
  }
1244
-
1245
  .about-sportspress-wrap .sp-badge {
1246
  float: none;
1247
  margin: 20px auto 10px;
318
  table.widefat.sp-data-table input[type="number"] {
319
  min-width: 1.25em;
320
  width: 100%;
321
+ margin: 1px;
322
+ padding: 3px 5px;
323
  }
324
 
325
  table.widefat.sp-data-table input[type="text"]::placeholder,
681
 
682
  .sp-toggle-switch + label:before,
683
  .sp-toggle-switch + label:after {
684
+ display: block;
685
+ position: absolute;
686
+ top: 0;
687
+ left: 0;
688
+ bottom: 0;
689
+ content: "";
690
  }
691
 
692
  .sp-toggle-switch + label:before {
693
+ right: 1px;
694
+ background-color: #e4e4e4;
695
+ border-radius: 16px;
696
+ transition: background 0.4s;
697
  }
698
 
699
  .sp-toggle-switch + label:after {
700
+ width: 16px;
701
+ background-color: #fff;
702
+ border-radius: 100%;
703
+ -webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
704
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
705
+ transition: margin 0.4s;
706
  }
707
 
708
  .sp-toggle-switch:checked + label:before {
735
  clear: both;
736
  max-width: 382px;
737
  width: 100%;
738
+ box-sizing: border-box;
739
  }
740
 
741
  .sp-sortable-list .sp-item-float + .sp-item-float {
743
  }
744
 
745
  .sp-item-bar {
746
+ clear: both;
747
+ line-height: 1.5em;
748
+ position: relative;
749
+ margin: 9px 0 0;
750
  }
751
 
752
  .sp-item-bar .sp-item-handle {
753
  background: #fafafa;
754
  color: #23282d;
755
+ border: 1px solid #dfdfdf;
756
+ position: relative;
757
+ padding: 10px 15px;
758
+ height: auto;
759
+ min-height: 20px;
760
+ line-height: 30px;
761
+ overflow: hidden;
762
+ word-wrap: break-word;
763
  }
764
 
765
  .sp-item-bar .sp-item-handle:hover {
766
+ border-color: #999;
767
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.1);
768
+ box-shadow: 0 1px 2px rgba(0,0,0,.1);
769
  }
770
 
771
  .sp-item-bar .sp-item-title {
772
  font-size: 13px;
773
+ font-weight: 600;
774
+ line-height: 20px;
775
+ display: block;
776
+ margin-right: 13em;
777
  }
778
 
779
  .sp-item-settings {
780
+ display: block;
781
+ padding: 10px 0 10px 15px;
782
+ position: relative;
783
+ z-index: 10;
784
+ background: #fff;
785
+ border: 1px solid #e5e5e5;
786
+ border-top: none;
787
+ -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.04);
788
+ box-shadow: 0 1px 1px rgba(0,0,0,.04);
789
  }
790
 
791
  .js .sp-item-handle {
793
  }
794
 
795
  .sp-sortable-list .sp-item-placeholder {
796
+ border: 1px dashed #b4b9be;
797
+ margin: 9px auto 6px;
798
+ height: 42px;
799
  }
800
 
801
  /* Logo */
1225
  float: none;
1226
  margin-left: 0;
1227
  }
1228
+
1229
  .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-sp_format,
1230
  .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-sp_icon,
1231
  .wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-sp_number {
1241
  margin-right: 0;
1242
  padding-right: 0;
1243
  }
1244
+
1245
  .about-sportspress-wrap .sp-badge {
1246
  float: none;
1247
  margin: 20px auto 10px;
assets/css/chosen.css CHANGED
@@ -427,9 +427,9 @@ This file is generated by `grunt build`, do not edit it by hand.
427
  .chosen-container-multi .chosen-choices .search-choice .search-choice-close,
428
  .chosen-container .chosen-results-scroll-down span,
429
  .chosen-container .chosen-results-scroll-up span {
430
- background-image: url('../images/chosen/chosen-sprite@2x.png') !important;
431
- background-size: 52px 37px !important;
432
- background-repeat: no-repeat !important;
433
  }
434
  }
435
  /* @end */
427
  .chosen-container-multi .chosen-choices .search-choice .search-choice-close,
428
  .chosen-container .chosen-results-scroll-down span,
429
  .chosen-container .chosen-results-scroll-up span {
430
+ background-image: url('../images/chosen/chosen-sprite@2x.png') !important;
431
+ background-size: 52px 37px !important;
432
+ background-repeat: no-repeat !important;
433
  }
434
  }
435
  /* @end */
assets/css/customize.css CHANGED
@@ -17,4 +17,4 @@
17
  }
18
  #available-widgets [class*=sp_countdown] .widget-title:before {
19
  content: "\f469";
20
- }
17
  }
18
  #available-widgets [class*=sp_countdown] .widget-title:before {
19
  content: "\f469";
20
+ }
assets/css/equation.css CHANGED
@@ -73,4 +73,4 @@
73
 
74
  .sp-equation-formula .button .remove:hover {
75
  color: #d00;
76
- }
73
 
74
  .sp-equation-formula .button .remove:hover {
75
  color: #d00;
76
+ }
assets/css/leaflet.css CHANGED
@@ -22,7 +22,7 @@
22
  .leaflet-marker-shadow {
23
  -webkit-user-select: none;
24
  -moz-user-select: none;
25
- user-select: none;
26
  -webkit-user-drag: none;
27
  }
28
  /* Prevents IE11 from highlighting tiles in blue */
@@ -86,7 +86,7 @@
86
  width: 0;
87
  height: 0;
88
  -moz-box-sizing: border-box;
89
- box-sizing: border-box;
90
  z-index: 800;
91
  }
92
  /* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
@@ -173,15 +173,15 @@
173
  opacity: 0;
174
  -webkit-transition: opacity 0.2s linear;
175
  -moz-transition: opacity 0.2s linear;
176
- transition: opacity 0.2s linear;
177
  }
178
  .leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
179
  opacity: 1;
180
  }
181
  .leaflet-zoom-animated {
182
  -webkit-transform-origin: 0 0;
183
- -ms-transform-origin: 0 0;
184
- transform-origin: 0 0;
185
  }
186
  .leaflet-zoom-anim .leaflet-zoom-animated {
187
  will-change: transform;
@@ -189,13 +189,13 @@
189
  .leaflet-zoom-anim .leaflet-zoom-animated {
190
  -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
191
  -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
192
- transition: transform 0.25s cubic-bezier(0,0,0.25,1);
193
  }
194
  .leaflet-zoom-anim .leaflet-tile,
195
  .leaflet-pan-anim .leaflet-tile {
196
  -webkit-transition: none;
197
  -moz-transition: none;
198
- transition: none;
199
  }
200
 
201
  .leaflet-zoom-anim .leaflet-zoom-hide {
@@ -435,7 +435,7 @@ svg.leaflet-image-layer.leaflet-interactive path {
435
  white-space: nowrap;
436
  overflow: hidden;
437
  -moz-box-sizing: border-box;
438
- box-sizing: border-box;
439
 
440
  background: #fff;
441
  background: rgba(255, 255, 255, 0.5);
@@ -498,8 +498,8 @@ svg.leaflet-image-layer.leaflet-interactive path {
498
 
499
  -webkit-transform: rotate(45deg);
500
  -moz-transform: rotate(45deg);
501
- -ms-transform: rotate(45deg);
502
- transform: rotate(45deg);
503
  }
504
  .leaflet-popup-content-wrapper,
505
  .leaflet-popup-tip {
22
  .leaflet-marker-shadow {
23
  -webkit-user-select: none;
24
  -moz-user-select: none;
25
+ user-select: none;
26
  -webkit-user-drag: none;
27
  }
28
  /* Prevents IE11 from highlighting tiles in blue */
86
  width: 0;
87
  height: 0;
88
  -moz-box-sizing: border-box;
89
+ box-sizing: border-box;
90
  z-index: 800;
91
  }
92
  /* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
173
  opacity: 0;
174
  -webkit-transition: opacity 0.2s linear;
175
  -moz-transition: opacity 0.2s linear;
176
+ transition: opacity 0.2s linear;
177
  }
178
  .leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
179
  opacity: 1;
180
  }
181
  .leaflet-zoom-animated {
182
  -webkit-transform-origin: 0 0;
183
+ -ms-transform-origin: 0 0;
184
+ transform-origin: 0 0;
185
  }
186
  .leaflet-zoom-anim .leaflet-zoom-animated {
187
  will-change: transform;
189
  .leaflet-zoom-anim .leaflet-zoom-animated {
190
  -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
191
  -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
192
+ transition: transform 0.25s cubic-bezier(0,0,0.25,1);
193
  }
194
  .leaflet-zoom-anim .leaflet-tile,
195
  .leaflet-pan-anim .leaflet-tile {
196
  -webkit-transition: none;
197
  -moz-transition: none;
198
+ transition: none;
199
  }
200
 
201
  .leaflet-zoom-anim .leaflet-zoom-hide {
435
  white-space: nowrap;
436
  overflow: hidden;
437
  -moz-box-sizing: border-box;
438
+ box-sizing: border-box;
439
 
440
  background: #fff;
441
  background: rgba(255, 255, 255, 0.5);
498
 
499
  -webkit-transform: rotate(45deg);
500
  -moz-transform: rotate(45deg);
501
+ -ms-transform: rotate(45deg);
502
+ transform: rotate(45deg);
503
  }
504
  .leaflet-popup-content-wrapper,
505
  .leaflet-popup-tip {
assets/css/menu.css CHANGED
@@ -371,4 +371,4 @@ i.mce-i-sp_shortcodes_button:before, span.mce_sp_shortcodes_button:before {
371
  text-align: center;
372
  content: "\f111";
373
  font-size: 20px;
374
- }
371
  text-align: center;
372
  content: "\f111";
373
  font-size: 20px;
374
+ }
assets/css/setup.css CHANGED
@@ -1,421 +1,421 @@
1
  .sp-setup-content p,
2
  .sp-setup-content table {
3
- font-size: 1em;
4
- line-height: 1.75em;
5
- color: #666;
6
  }
7
 
8
  body {
9
- margin: 100px auto 24px;
10
- box-shadow: none;
11
- background: #f1f1f1;
12
- padding: 0;
13
  }
14
 
15
  #sp-logo {
16
- border: 0;
17
- margin: 0 0 24px;
18
- padding: 0;
19
- text-align: center;
20
  }
21
 
22
  #sp-logo img {
23
- width: auto;
24
- height: auto;
25
- max-width: 100%;
26
- max-height: 50px;
27
  }
28
 
29
  .sp-setup-content {
30
- box-shadow: 0 1px 3px rgba(0, 0, 0, .13);
31
- padding: 24px 24px 0;
32
- background: #fff;
33
- zoom: 1;
34
  }
35
 
36
  .sp-setup-content:after {
37
- content: "";
38
- display: table;
39
- clear: both;
40
  }
41
 
42
  .sp-setup-content h1,
43
  .sp-setup-content h2,
44
  .sp-setup-content h3,
45
  .sp-setup-content table {
46
- margin: 0 0 24px;
47
- border: 0;
48
- padding: 0;
49
- color: #666;
50
- clear: none;
51
  }
52
 
53
  .sp-setup-content p {
54
- margin: 0 0 24px;
55
  }
56
 
57
  .sp-setup-content a {
58
- color: #00a69c;
59
  }
60
 
61
  .sp-setup-content a:focus,
62
  .sp-setup-content a:hover {
63
- color: #111;
64
  }
65
 
66
  .sp-setup-content .form-table {
67
- width: 100%;
68
- border-top: 1px solid #eee;
69
  }
70
 
71
  .sp-setup-content .form-table th {
72
- width: 30%;
73
- vertical-align: top;
74
- font-weight: 700;
75
  }
76
 
77
  .sp-setup-content .form-table td {
78
- vertical-align: top;
79
  }
80
 
81
  .sp-setup-content .form-table td input,
82
  .sp-setup-content .form-table td select {
83
- width: 100%;
84
- box-sizing: border-box;
85
  }
86
 
87
  .sp-setup-content .form-table td input[size] {
88
- width: auto;
89
  }
90
 
91
  .sp-setup-content .form-table td ol,
92
  .sp-setup-content .form-table td ul {
93
- margin: 0;
94
- padding: 0;
95
  }
96
 
97
  .sp-setup-content .form-table td ul {
98
- list-style: none;
99
  }
100
 
101
  .sp-setup-content .form-table td li {
102
- margin-bottom: 10px;
103
  }
104
 
105
  .sp-setup-content .form-table td li:last-child {
106
- margin-bottom: 0;
107
  }
108
 
109
  .sp-setup-content .form-table td .description {
110
- line-height: 1.5em;
111
- display: block;
112
- margin: .25em 0 0;
113
- color: #999;
114
- font-style: italic;
115
  }
116
 
117
  .sp-setup-content .form-table td .input-checkbox,
118
  .sp-setup-content .form-table td .input-radio {
119
- width: auto;
120
- box-sizing: inherit;
121
- padding: inherit;
122
- margin: 0 .5em 0 0;
123
- box-shadow: none;
124
  }
125
 
126
  .sp-setup-content .form-table .section_title td {
127
- padding: 0;
128
  }
129
 
130
  .sp-setup-content .form-table .section_title td h2,
131
  .sp-setup-content .form-table .section_title td p {
132
- margin: 12px 0 0;
133
  }
134
 
135
  .sp-setup-content .form-table td,
136
  .sp-setup-content .form-table th {
137
- padding: 14px 0;
138
- margin: 0;
139
- border: 0;
140
- border-bottom: 1px solid #eee;
141
  }
142
 
143
  .sp-setup-content .form-table td:first-child,
144
  .sp-setup-content .form-table th:first-child {
145
- padding-right: 9px;
146
  }
147
 
148
  .sp-setup-content .form-table th .sp-desc-tip {
149
- line-height: 1.4;
150
  }
151
 
152
  .sp-setup-content .form-table .sp-chosen-container {
153
- display: block;
154
  }
155
 
156
  .sp-setup-content .form-table .sp-location-picker {
157
- width: 100%;
158
- height: 320px;
159
- margin: 0.5em 0 0;
160
  }
161
 
162
  .sp-setup-content .twitter-share-button {
163
- float: right;
164
  }
165
 
166
  .sp-setup-content .sp-banner {
167
- margin: 0 -24px 24px;
168
  }
169
 
170
  .sp-setup-content .sp-banner img {
171
- display: block;
172
- width: auto;
173
- height: auto;
174
- max-width: 100%;
175
  }
176
 
177
  .sp-setup-content .sp-setup-next-steps {
178
- overflow: hidden;
179
- margin: 0 0 24px;
180
  }
181
 
182
  .sp-setup-content .sp-setup-next-steps h2 {
183
- margin-bottom: 12px;
184
  }
185
 
186
  .sp-setup-content .sp-setup-next-steps .sp-setup-next-steps-first {
187
- float: left;
188
- width: 50%;
189
- box-sizing: border-box;
190
  }
191
 
192
  .sp-setup-content .sp-setup-next-steps .sp-setup-next-steps-last {
193
- float: right;
194
- width: 50%;
195
- box-sizing: border-box;
196
  }
197
 
198
  .sp-setup-content .sp-setup-next-steps ul {
199
- padding: 0 2em 0 0;
200
- list-style: none;
201
- margin: 0;
202
  }
203
 
204
  .sp-setup-content .sp-setup-next-steps ul li .button {
205
- display: block;
206
- padding: 0 0 .75em;
207
  }
208
 
209
  .sp-setup-content .sp-setup-next-steps ul li .button-first-event {
210
- background-color: #3bbab3;
211
- border-color: #15a29a;
212
- -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
213
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
214
- text-shadow: 0 -1px 1px #15a29a, 1px 0 1px #15a29a, 0 1px 1px #15a29a, -1px 0 1px #15a29a;
215
- font-size: 1em;
216
- height: auto;
217
- line-height: 1.75em;
218
- margin: 0 0 .75em;
219
- opacity: 1;
220
- padding: 1em;
221
- text-align: center;
222
  }
223
 
224
  .sp-setup-content .sp-setup-next-steps ul li .button-first-event:active,
225
  .sp-setup-content .sp-setup-next-steps ul li .button-first-event:focus,
226
  .sp-setup-content .sp-setup-next-steps ul li .button-first-event:hover {
227
- background: #15a29a;
228
- border-color: #15a29a;
229
- -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
230
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
231
  }
232
 
233
  .sp-setup-content .sp-setup-next-steps ul li a:before {
234
- color: #82878c;
235
- font: 400 20px/1 dashicons;
236
- speak: none;
237
- display: inline-block;
238
- padding: 0 10px 0 0;
239
- top: 1px;
240
- position: relative;
241
- -webkit-font-smoothing: antialiased;
242
- -moz-osx-font-smoothing: grayscale;
243
- text-decoration: none!important;
244
- vertical-align: top;
245
  }
246
 
247
  .sp-setup-content .sp-setup-next-steps ul .learn-more a:before {
248
- content: "\f105";
249
  }
250
 
251
  .sp-setup-content .sp-setup-next-steps ul .video-walkthrough a:before {
252
- content: "\f126";
253
  }
254
 
255
  .sp-setup-content .sp-setup-next-steps ul .newsletter a:before {
256
- content: "\f465";
257
  }
258
 
259
  .sp-setup-content .updated {
260
- padding: 24px 24px 0;
261
- margin: 0 0 24px;
262
- overflow: hidden;
263
- background: #f5f5f5;
264
  }
265
 
266
  .sp-setup-content .updated p {
267
- padding: 0;
268
- margin: 0 0 12px;
269
  }
270
 
271
  .sp-setup-content .updated p:last-child {
272
- margin: 0 0 24px;
273
  }
274
 
275
  .sp-setup-steps {
276
- padding: 0 0 24px;
277
- margin: 0;
278
- list-style: none;
279
- overflow: hidden;
280
- color: #ccc;
281
- width: 100%;
282
- display: -webkit-inline-flex;
283
- display: -ms-inline-flexbox;
284
- display: inline-flex;
285
  }
286
 
287
  .sp-setup-steps li {
288
- width: 20%;
289
- float: left;
290
- padding: 0 0 .8em;
291
- margin: 0;
292
- text-align: center;
293
- position: relative;
294
- border-bottom: 4px solid #ccc;
295
- line-height: 1.4em;
296
  }
297
 
298
  .sp-setup-steps li:before {
299
- content: "";
300
- border: 4px solid #ccc;
301
- border-radius: 100%;
302
- width: 4px;
303
- height: 4px;
304
- position: absolute;
305
- bottom: 0;
306
- left: 50%;
307
- margin-left: -6px;
308
- margin-bottom: -8px;
309
- background: #fff;
310
  }
311
 
312
  .sp-setup-steps li.active {
313
- border-color: #00a69c;
314
- color: #00a69c;
315
  }
316
 
317
  .sp-setup-steps li.active:before {
318
- border-color: #00a69c;
319
  }
320
 
321
  .sp-setup-steps li.done {
322
- border-color: #00a69c;
323
- color: #00a69c;
324
  }
325
 
326
  .sp-setup-steps li.done:before {
327
- border-color: #00a69c;
328
- background: #00a69c;
329
  }
330
 
331
  .sp-setup .sp-setup-actions:after {
332
- content: "";
333
- display: table;
334
- clear: both;
335
  }
336
 
337
  .sp-setup .sp-setup-actions .button {
338
- float: right;
339
- font-size: 1.25em;
340
- padding: .5em 1em;
341
- line-height: 1em;
342
- margin-right: .5em;
343
- margin-bottom: 2px;
344
- height: auto;
345
- border-radius: 4px;
346
  }
347
 
348
  .sp-setup .sp-setup-actions .button-primary {
349
- background-color: #3bbab3;
350
- border-color: #15a29a;
351
- -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
352
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
353
- text-shadow: 0 -1px 1px #15a29a, 1px 0 1px #15a29a, 0 1px 1px #15a29a, -1px 0 1px #15a29a;
354
- float: right;
355
- margin: 0 0 0 1em;
356
- opacity: 1;
357
  }
358
 
359
  .sp-setup .sp-setup-actions .button-primary:active,
360
  .sp-setup .sp-setup-actions .button-primary:focus,
361
  .sp-setup .sp-setup-actions .button-primary:hover {
362
- background: #15a29a;
363
- border-color: #15a29a;
364
- -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
365
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
366
  }
367
 
368
  .sp-setup .sp-setup-actions .button-muted {
369
- border: none;
370
- background: transparent;
371
- -webkit-box-shadow: none;
372
- box-shadow: none;
373
- padding: 0;
374
- margin: .55em 0.05em 0.65em;
375
- color: #ccc;
376
  }
377
 
378
  .sp-setup .sp-setup-actions .button-muted:hover {
379
- color: #999;
380
  }
381
 
382
  .sp-return-to-dashboard {
383
- font-size: .85em;
384
- margin: 1.18em 0;
385
- display: block;
386
- text-align: center;
387
  }
388
 
389
  .sp-return-to-dashboard a {
390
- color: #b5b5b5;
391
  }
392
 
393
  .sp-return-to-dashboard a:hover {
394
- color: #888;
395
  }
396
 
397
  /* Media Queries */
398
 
399
  @media screen and (max-width: 782px) {
400
- .sp-setup-content .form-table tbody th {
401
- width: auto
402
- };
403
  }
404
 
405
  @media screen and (min-width: 783px) {
406
- .sp-setup-content .form-table td li input {
407
- width: 40%;
408
- }
409
-
410
- .sp-setup-content .form-table td .player input {
411
- width: 40%;
412
- }
413
-
414
- .sp-setup-content .form-table td .player .player-number {
415
- width: 11%;
416
- }
417
-
418
- .sp-setup-content .form-table td .staff .staff-name {
419
- width: 52%;
420
- }
421
- }
1
  .sp-setup-content p,
2
  .sp-setup-content table {
3
+ font-size: 1em;
4
+ line-height: 1.75em;
5
+ color: #666;
6
  }
7
 
8
  body {
9
+ margin: 100px auto 24px;
10
+ box-shadow: none;
11
+ background: #f1f1f1;
12
+ padding: 0;
13
  }
14
 
15
  #sp-logo {
16
+ border: 0;
17
+ margin: 24px 0;
18
+ padding: 0;
19
+ text-align: center;
20
  }
21
 
22
  #sp-logo img {
23
+ width: auto;
24
+ height: auto;
25
+ max-width: 100%;
26
+ max-height: 50px;
27
  }
28
 
29
  .sp-setup-content {
30
+ box-shadow: 0 1px 3px rgba(0, 0, 0, .13);
31
+ padding: 24px 24px 0;
32
+ background: #fff;
33
+ zoom: 1;
34
  }
35
 
36
  .sp-setup-content:after {
37
+ content: "";
38
+ display: table;
39
+ clear: both;
40
  }
41
 
42
  .sp-setup-content h1,
43
  .sp-setup-content h2,
44
  .sp-setup-content h3,
45
  .sp-setup-content table {
46
+ margin: 0 0 24px;
47
+ border: 0;
48
+ padding: 0;
49
+ color: #666;
50
+ clear: none;
51
  }
52
 
53
  .sp-setup-content p {
54
+ margin: 0 0 24px;
55
  }
56
 
57
  .sp-setup-content a {
58
+ color: #00a69c;
59
  }
60
 
61
  .sp-setup-content a:focus,
62
  .sp-setup-content a:hover {
63
+ color: #111;
64
  }
65
 
66
  .sp-setup-content .form-table {
67
+ width: 100%;
68
+ border-top: 1px solid #eee;
69
  }
70
 
71
  .sp-setup-content .form-table th {
72
+ width: 30%;
73
+ vertical-align: top;
74
+ font-weight: 700;
75
  }
76
 
77
  .sp-setup-content .form-table td {
78
+ vertical-align: top;
79
  }
80
 
81
  .sp-setup-content .form-table td input,
82
  .sp-setup-content .form-table td select {
83
+ width: 100%;
84
+ box-sizing: border-box;
85
  }
86
 
87
  .sp-setup-content .form-table td input[size] {
88
+ width: auto;
89
  }
90
 
91
  .sp-setup-content .form-table td ol,
92
  .sp-setup-content .form-table td ul {
93
+ margin: 0;
94
+ padding: 0;
95
  }
96
 
97
  .sp-setup-content .form-table td ul {
98
+ list-style: none;
99
  }
100
 
101
  .sp-setup-content .form-table td li {
102
+ margin-bottom: 10px;
103
  }
104
 
105
  .sp-setup-content .form-table td li:last-child {
106
+ margin-bottom: 0;
107
  }
108
 
109
  .sp-setup-content .form-table td .description {
110
+ line-height: 1.5em;
111
+ display: block;
112
+ margin: .25em 0 0;
113
+ color: #999;
114
+ font-style: italic;
115
  }
116
 
117
  .sp-setup-content .form-table td .input-checkbox,
118
  .sp-setup-content .form-table td .input-radio {
119
+ width: auto;
120
+ box-sizing: inherit;
121
+ padding: inherit;
122
+ margin: 0 .5em 0 0;
123
+ box-shadow: none;
124
  }
125
 
126
  .sp-setup-content .form-table .section_title td {
127
+ padding: 0;
128
  }
129
 
130
  .sp-setup-content .form-table .section_title td h2,
131
  .sp-setup-content .form-table .section_title td p {
132
+ margin: 12px 0 0;
133
  }
134
 
135
  .sp-setup-content .form-table td,
136
  .sp-setup-content .form-table th {
137
+ padding: 14px 0;
138
+ margin: 0;
139
+ border: 0;
140
+ border-bottom: 1px solid #eee;
141
  }
142
 
143
  .sp-setup-content .form-table td:first-child,
144
  .sp-setup-content .form-table th:first-child {
145
+ padding-right: 9px;
146
  }
147
 
148
  .sp-setup-content .form-table th .sp-desc-tip {
149
+ line-height: 1.4;
150
  }
151
 
152
  .sp-setup-content .form-table .sp-chosen-container {
153
+ display: block;
154
  }
155
 
156
  .sp-setup-content .form-table .sp-location-picker {
157
+ width: 100%;
158
+ height: 320px;
159
+ margin: 0.5em 0 0;
160
  }
161
 
162
  .sp-setup-content .twitter-share-button {
163
+ float: right;
164
  }
165
 
166
  .sp-setup-content .sp-banner {
167
+ margin: 0 -24px 24px;
168
  }
169
 
170
  .sp-setup-content .sp-banner img {
171
+ display: block;
172
+ width: auto;
173
+ height: auto;
174
+ max-width: 100%;
175
  }
176
 
177
  .sp-setup-content .sp-setup-next-steps {
178
+ overflow: hidden;
179
+ margin: 0 0 24px;
180
  }
181
 
182
  .sp-setup-content .sp-setup-next-steps h2 {
183
+ margin-bottom: 12px;
184
  }
185
 
186
  .sp-setup-content .sp-setup-next-steps .sp-setup-next-steps-first {
187
+ float: left;
188
+ width: 50%;
189
+ box-sizing: border-box;
190
  }
191
 
192
  .sp-setup-content .sp-setup-next-steps .sp-setup-next-steps-last {
193
+ float: right;
194
+ width: 50%;
195
+ box-sizing: border-box;
196
  }
197
 
198
  .sp-setup-content .sp-setup-next-steps ul {
199
+ padding: 0 2em 0 0;
200
+ list-style: none;
201
+ margin: 0;
202
  }
203
 
204
  .sp-setup-content .sp-setup-next-steps ul li .button {
205
+ display: block;
206
+ padding: 0 0 .75em;
207
  }
208
 
209
  .sp-setup-content .sp-setup-next-steps ul li .button-first-event {
210
+ background-color: #3bbab3;
211
+ border-color: #15a29a;
212
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
213
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
214
+ text-shadow: 0 -1px 1px #15a29a, 1px 0 1px #15a29a, 0 1px 1px #15a29a, -1px 0 1px #15a29a;
215
+ font-size: 1em;
216
+ height: auto;
217
+ line-height: 1.75em;
218
+ margin: 0 0 .75em;
219
+ opacity: 1;
220
+ padding: 1em;
221
+ text-align: center;
222
  }
223
 
224
  .sp-setup-content .sp-setup-next-steps ul li .button-first-event:active,
225
  .sp-setup-content .sp-setup-next-steps ul li .button-first-event:focus,
226
  .sp-setup-content .sp-setup-next-steps ul li .button-first-event:hover {
227
+ background: #15a29a;
228
+ border-color: #15a29a;
229
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
230
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
231
  }
232
 
233
  .sp-setup-content .sp-setup-next-steps ul li a:before {
234
+ color: #82878c;
235
+ font: 400 20px/1 dashicons;
236
+ speak: none;
237
+ display: inline-block;
238
+ padding: 0 10px 0 0;
239
+ top: 1px;
240
+ position: relative;
241
+ -webkit-font-smoothing: antialiased;
242
+ -moz-osx-font-smoothing: grayscale;
243
+ text-decoration: none!important;
244
+ vertical-align: top;
245
  }
246
 
247
  .sp-setup-content .sp-setup-next-steps ul .learn-more a:before {
248
+ content: "\f105";
249
  }
250
 
251
  .sp-setup-content .sp-setup-next-steps ul .video-walkthrough a:before {
252
+ content: "\f126";
253
  }
254
 
255
  .sp-setup-content .sp-setup-next-steps ul .newsletter a:before {
256
+ content: "\f465";
257
  }
258
 
259
  .sp-setup-content .updated {
260
+ padding: 24px 24px 0;
261
+ margin: 0 0 24px;
262
+ overflow: hidden;
263
+ background: #f5f5f5;
264
  }
265
 
266
  .sp-setup-content .updated p {
267
+ padding: 0;
268
+ margin: 0 0 12px;
269
  }
270
 
271
  .sp-setup-content .updated p:last-child {
272
+ margin: 0 0 24px;
273
  }
274
 
275
  .sp-setup-steps {
276
+ padding: 0 0 24px;
277
+ margin: 0;
278
+ list-style: none;
279
+ overflow: hidden;
280
+ color: #ccc;
281
+ width: 100%;
282
+ display: -webkit-inline-flex;
283
+ display: -ms-inline-flexbox;
284
+ display: inline-flex;
285
  }
286
 
287
  .sp-setup-steps li {
288
+ width: 20%;
289
+ float: left;
290
+ padding: 0 0 .8em;
291
+ margin: 0;
292
+ text-align: center;
293
+ position: relative;
294
+ border-bottom: 4px solid #ccc;
295
+ line-height: 1.4em;
296
  }
297
 
298
  .sp-setup-steps li:before {
299
+ content: "";
300
+ border: 4px solid #ccc;
301
+ border-radius: 100%;
302
+ width: 4px;
303
+ height: 4px;
304
+ position: absolute;
305
+ bottom: 0;
306
+ left: 50%;
307
+ margin-left: -6px;
308
+ margin-bottom: -8px;
309
+ background: #fff;
310
  }
311
 
312
  .sp-setup-steps li.active {
313
+ border-color: #00a69c;
314
+ color: #00a69c;
315
  }
316
 
317
  .sp-setup-steps li.active:before {
318
+ border-color: #00a69c;
319
  }
320
 
321
  .sp-setup-steps li.done {
322
+ border-color: #00a69c;
323
+ color: #00a69c;
324
  }
325
 
326
  .sp-setup-steps li.done:before {
327
+ border-color: #00a69c;
328
+ background: #00a69c;
329
  }
330
 
331
  .sp-setup .sp-setup-actions:after {
332
+ content: "";
333
+ display: table;
334
+ clear: both;
335
  }
336
 
337
  .sp-setup .sp-setup-actions .button {
338
+ float: right;
339
+ font-size: 1.25em;
340
+ padding: .5em 1em;
341
+ line-height: 1em;
342
+ margin-right: .5em;
343
+ margin-bottom: 2px;
344
+ height: auto;
345
+ border-radius: 4px;
346
  }
347
 
348
  .sp-setup .sp-setup-actions .button-primary {
349
+ background-color: #3bbab3;
350
+ border-color: #15a29a;
351
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
352
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
353
+ text-shadow: 0 -1px 1px #15a29a, 1px 0 1px #15a29a, 0 1px 1px #15a29a, -1px 0 1px #15a29a;
354
+ float: right;
355
+ margin: 0 0 0 1em;
356
+ opacity: 1;
357
  }
358
 
359
  .sp-setup .sp-setup-actions .button-primary:active,
360
  .sp-setup .sp-setup-actions .button-primary:focus,
361
  .sp-setup .sp-setup-actions .button-primary:hover {
362
+ background: #15a29a;
363
+ border-color: #15a29a;
364
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
365
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
366
  }
367
 
368
  .sp-setup .sp-setup-actions .button-muted {
369
+ border: none;
370
+ background: transparent;
371
+ -webkit-box-shadow: none;
372
+ box-shadow: none;
373
+ padding: 0;
374
+ margin: .55em 0.05em 0.65em;
375
+ color: #ccc;
376
  }
377
 
378
  .sp-setup .sp-setup-actions .button-muted:hover {
379
+ color: #999;
380
  }
381
 
382
  .sp-return-to-dashboard {
383
+ font-size: .85em;
384
+ margin: 1.18em 0;
385
+ display: block;
386
+ text-align: center;
387
  }
388
 
389
  .sp-return-to-dashboard a {
390
+ color: #b5b5b5;
391
  }
392
 
393
  .sp-return-to-dashboard a:hover {
394
+ color: #888;
395
  }
396
 
397
  /* Media Queries */
398
 
399
  @media screen and (max-width: 782px) {
400
+ .sp-setup-content .form-table tbody th {
401
+ width: auto
402
+ };
403
  }
404
 
405
  @media screen and (min-width: 783px) {
406
+ .sp-setup-content .form-table td li input {
407
+ width: 40%;
408
+ }
409
+
410
+ .sp-setup-content .form-table td .player input {
411
+ width: 40%;
412
+ }
413
+
414
+ .sp-setup-content .form-table td .player .player-number {
415
+ width: 11%;
416
+ }
417
+
418
+ .sp-setup-content .form-table td .staff .staff-name {
419
+ width: 52%;
420
+ }
421
+ }
assets/css/slickmap.css CHANGED
@@ -240,4 +240,4 @@ table, .sp-sitemap caption, .sp-sitemap tbody, .sp-sitemap tfoot, .sp-sitemap th
240
  .sp-sitemap .sp-utility {
241
  max-width: none;
242
  }
243
- }
240
  .sp-sitemap .sp-utility {
241
  max-width: none;
242
  }
243
+ }
assets/css/sportspress-style-ltr.css CHANGED
@@ -6,28 +6,28 @@
6
  */
7
 
8
  .sp-tournament-bracket .sp-team .sp-team-name:before {
9
- border-left-color: #e5e5e5 !important;
10
- border-right-color: #e5e5e5 !important;
11
- left: -10px !important;
12
  }
13
 
14
  .sp-tournament-bracket .sp-team-flip .sp-team-name:before {
15
- left: auto !important;
16
- right: -10px !important;
17
  }
18
 
19
  .sp-tournament-bracket .sp-team.sp-first-round .sp-team-name {
20
- margin-left: -1px !important;
21
  }
22
 
23
  .sp-tournament-bracket .sp-team.sp-last-round .sp-team-name {
24
- margin-right: -1px !important;
25
  }
26
 
27
  .sp-template-event-performance-icons .sp-performance-icons {
28
- text-align: right !important;
29
  }
30
 
31
  .sp-data-table .data-name {
32
- text-align: left !important;
33
  }
6
  */
7
 
8
  .sp-tournament-bracket .sp-team .sp-team-name:before {
9
+ border-left-color: #e5e5e5 !important;
10
+ border-right-color: #e5e5e5 !important;
11
+ left: -10px !important;
12
  }
13
 
14
  .sp-tournament-bracket .sp-team-flip .sp-team-name:before {
15
+ left: auto !important;
16
+ right: -10px !important;
17
  }
18
 
19
  .sp-tournament-bracket .sp-team.sp-first-round .sp-team-name {
20
+ margin-left: -1px !important;
21
  }
22
 
23
  .sp-tournament-bracket .sp-team.sp-last-round .sp-team-name {
24
+ margin-right: -1px !important;
25
  }
26
 
27
  .sp-template-event-performance-icons .sp-performance-icons {
28
+ text-align: right !important;
29
  }
30
 
31
  .sp-data-table .data-name {
32
+ text-align: left !important;
33
  }
assets/css/sportspress-style-rtl.css CHANGED
@@ -6,28 +6,28 @@
6
  */
7
 
8
  .sp-tournament-bracket .sp-team .sp-team-name:before {
9
- border-right-color: #e5e5e5 !important;
10
- border-left-color: #e5e5e5 !important;
11
- right: -10px !important;
12
  }
13
 
14
  .sp-tournament-bracket .sp-team-flip .sp-team-name:before {
15
- right: auto !important;
16
- left: -10px !important;
17
  }
18
 
19
  .sp-tournament-bracket .sp-team.sp-first-round .sp-team-name {
20
- margin-right: -1px !important;
21
  }
22
 
23
  .sp-tournament-bracket .sp-team.sp-last-round .sp-team-name {
24
- margin-left: -1px !important;
25
  }
26
 
27
  .sp-template-event-performance-icons .sp-performance-icons {
28
- text-align: left !important;
29
  }
30
 
31
  .sp-data-table .data-name {
32
- text-align: right !important;
33
  }
6
  */
7
 
8
  .sp-tournament-bracket .sp-team .sp-team-name:before {
9
+ border-right-color: #e5e5e5 !important;
10
+ border-left-color: #e5e5e5 !important;
11
+ right: -10px !important;
12
  }
13
 
14
  .sp-tournament-bracket .sp-team-flip .sp-team-name:before {
15
+ right: auto !important;
16
+ left: -10px !important;
17
  }
18
 
19
  .sp-tournament-bracket .sp-team.sp-first-round .sp-team-name {
20
+ margin-right: -1px !important;
21
  }
22
 
23
  .sp-tournament-bracket .sp-team.sp-last-round .sp-team-name {
24
+ margin-left: -1px !important;
25
  }
26
 
27
  .sp-template-event-performance-icons .sp-performance-icons {
28
+ text-align: left !important;
29
  }
30
 
31
  .sp-data-table .data-name {
32
+ text-align: right !important;
33
  }
assets/css/sportspress-style.css CHANGED
@@ -3,12 +3,12 @@
3
  .sp-template,
4
  .sp-data-table,
5
  .sp-table-caption {
6
- font-family: "Roboto", "Helvetica", sans-serif;
7
  }
8
 
9
  .sp-template {
10
- clear: both;
11
- overflow: hidden;
12
  }
13
 
14
  /*
@@ -34,34 +34,34 @@
34
  .sp-table-caption h4,
35
  .sp-table-caption h5,
36
  .sp-table-caption h6 {
37
- font-family: "Roboto", "Helvetica", sans-serif !important;
38
  }
39
 
40
  .sp-template {
41
- margin-bottom: 20px !important;
42
  }
43
 
44
  .sp-template *,
45
  .sp-data-table *,
46
  .sp-table-caption {
47
- box-sizing: border-box !important;
48
- font-weight: 400 !important;
49
- text-transform: none !important;
50
- letter-spacing: normal !important;
51
- color: #333 !important;
52
  }
53
 
54
  .sp-table-caption {
55
- margin: 0 !important;
56
- padding: 15px !important;
57
- background: #fff !important;
58
- border: 1px solid #e5e5e5 !important;
59
- border-bottom: none !important;
60
- font-size: 20px !important;
61
- font-weight: 400 !important;
62
- line-height: 1.5 !important;
63
- display: table !important;
64
- width: 100% !important;
65
  }
66
 
67
  /* Color Resets */
@@ -70,177 +70,177 @@
70
  .sp-data-table input,
71
  .sp-template .sp-event-logos,
72
  .sp-template .sp-event-staff {
73
- color: initial !important;
74
  }
75
 
76
  /* Links */
77
 
78
  .sp-template a,
79
  .sp-data-table a {
80
- box-shadow: none !important;
81
- border: none !important;
82
- text-decoration: none !important;
83
- font-weight: inherit !important;
84
- color: #00a69c !important;
85
  }
86
 
87
  .sp-template a:hover,
88
  .sp-data-table a:hover {
89
- text-decoration: underline !important;
90
  }
91
 
92
  .sp-template a:hover .dashicons,
93
  .sp-template a:hover [class^="sp-icon-"], [class*=" sp-icon-"],
94
  .sp-data-table a:hover .dashicons,
95
  .sp-data-table a:hover [class^="sp-icon-"], [class*=" sp-icon-"] {
96
- text-decoration: none !important;
97
  }
98
 
99
  .sp-view-all-link {
100
- padding: 10px 15px !important;
101
- margin: 0 !important;
102
- background: #fff !important;
103
- border: 1px solid #e5e5e5 !important;
104
- border-top: none !important;
105
- overflow: hidden !important;
106
- display: table !important;
107
- width: 100% !important;
108
- text-align: right !important;
109
  }
110
 
111
  .sp-view-all-link a {
112
- font-size: 12px !important;
113
- font-weight: 400 !important;
114
- line-height: 1.5 !important;
115
- text-decoration: none !important;
116
- color: rgba(51,51,51,0.5) !important;
117
  }
118
 
119
  .sp-view-all-link a:hover {
120
- color: #333 !important;
121
- text-decoration: none !important;
122
  }
123
 
124
  .sp-form-events a:hover {
125
- color: #fff !important;
126
- text-decoration: none !important;
127
  }
128
 
129
  /* Images */
130
 
131
  .sp-template img {
132
- display: inline-block !important;
133
- box-shadow: none !important;
134
  }
135
 
136
  /* Tables */
137
 
138
  .sp-data-table {
139
- margin: 0 !important;
140
- background: #fff !important;
141
- border-collapse: collapse !important;
142
- border: 1px solid #e5e5e5 !important;
143
- width: 100% !important;
144
  }
145
 
146
  .sp-data-table tr {
147
- border: none !important;
148
  }
149
 
150
  .sp-data-table th,
151
  .sp-data-table td {
152
- font-size: 13px !important;
153
- font-weight: 400 !important;
154
- line-height: 1.5 !important;
155
- border: 1px solid #e5e5e5 !important;
156
- padding: 5px 10px !important;
157
- text-align: center !important;
158
  }
159
 
160
  .sp-data-table th {
161
- font-size: 12px !important;
162
- font-weight: 500 !important;
163
- background: #fff !important;
164
- color: #999 !important;
165
- border: none !important;
166
  }
167
 
168
  .sp-data-table th a {
169
- color: inherit !important;
170
  }
171
 
172
  .sp-data-table .sp-highlight,
173
  .sp-data-table .highlighted td {
174
- font-weight: 500 !important;
175
- background: #f9f9f9 !important;
176
  }
177
 
178
  /* Galleries */
179
 
180
  .sp-template-gallery .sp-gallery-wrapper {
181
- border: 1px solid #e5e5e5 !important;
182
- background: #fff !important;
183
- display: table !important;
184
- width: 100% !important;
185
  }
186
 
187
  .sp-template-gallery .gallery-item {
188
- padding: 0 !important;
189
- margin: 0 !important;
190
- position: relative !important;
191
  }
192
 
193
  .sp-template-gallery .gallery-item a {
194
- display: block !important;
195
- color: #999 !important;
196
  }
197
 
198
  .sp-template-gallery .gallery-item img {
199
- display: block !important;
200
- border: none !important;
201
- padding: 0 !important;
202
- margin: 0 !important;
203
- border-radius: 0 !important;
204
  }
205
 
206
  .sp-template-gallery .gallery-caption {
207
- padding: 0 !important;
208
- margin: 0 !important;
209
- font-size: 12px !important;
210
- font-style: normal !important;
211
- font-weight: 500 !important;
212
- text-align: center !important;
213
- color: #999 !important;
214
- line-height: 1.5 !important;
215
- padding: 5px 10px !important;
216
  }
217
 
218
  .sp-template-gallery .gallery-caption strong {
219
- color: #fff !important;
220
- background: #00a69c !important;
221
- display: block !important;
222
- font-weight: 400 !important;
223
- font-size: 13px !important;
224
- line-height: 1.5 !important;
225
- position: absolute !important;
226
- left: 0 !important;
227
- top: 0 !important;
228
- padding: 5px 10px !important;
229
  }
230
 
231
  .sp-template-staff-gallery .gallery-caption strong {
232
- display: none !important;
233
  }
234
 
235
  .sp-template-gallery .sp-gallery-group-name {
236
- margin: 0 !important;
237
- padding: 15px !important;
238
- background: #fff !important;
239
- border-bottom: 1px solid #e5e5e5 !important;
240
- font-size: 20px !important;
241
- font-weight: 400 !important;
242
- line-height: 1.5 !important;
243
- display: block !important;
244
  }
245
 
246
  /* Countdowns */
@@ -249,472 +249,472 @@
249
  .sp-template-countdown .sp-event-venue,
250
  .sp-template-countdown .sp-event-league,
251
  .sp-template-countdown .sp-event-date {
252
- margin: 0 !important;
253
- padding: 5px 10px !important;
254
- text-align: center !important;
255
- line-height: 1.5 !important;
256
- display: table !important;
257
- width: 100% !important;
258
- background: #fff !important;
259
- border: 1px solid #e5e5e5 !important;
260
- border-bottom: none !important;
261
  }
262
 
263
  .sp-template-countdown .sp-event-name {
264
- font-size: 13px !important;
265
- font-weight: 400 !important;
266
- color: #333 !important;
267
  }
268
 
269
  .sp-template-countdown .sp-event-venue,
270
  .sp-template-countdown .sp-event-league,
271
  .sp-template-countdown .sp-event-date {
272
- font-size: 12px !important;
273
- font-weight: 500 !important;
274
- background: #fff !important;
275
- color: #999 !important;
276
  }
277
 
278
  .sp-template-countdown .sp-event-venue a,
279
  .sp-template-countdown .sp-event-league a {
280
- color: inherit !important;
281
  }
282
 
283
  .sp-countdown time {
284
- display: table !important;
285
- background: #fff !important;
286
- border: 1px solid #e5e5e5 !important;
287
- border-collapse: collapse !important;
288
- width: 100% !important;
289
  }
290
 
291
  .sp-countdown span {
292
- font-size: 20px !important;
293
- font-weight: 400 !important;
294
- line-height: 1.5 !important;
295
- display: table-cell !important;
296
- border: 1px solid #e5e5e5 !important;
297
- padding: 10px 5px !important;
298
- text-align: center !important;
299
  }
300
 
301
  .sp-countdown span small {
302
- font-size: 12px !important;
303
- font-weight: 400 !important;
304
- line-height: 1.5 !important;
305
- font-weight: 500 !important;
306
- color: rgba(51,51,51,0.5) !important;
307
- display: block !important;
308
  }
309
 
310
  /* Event Calendars */
311
 
312
  .sp-template-event-calendar .sp-table-caption {
313
- display: table-caption !important;
314
  }
315
 
316
  .sp-template-event-calendar td {
317
- padding: 10px 5px !important;
318
  }
319
 
320
  .sp-template-event-calendar tfoot td {
321
- padding: 10px 15px !important;
322
- border: none !important;
323
  }
324
 
325
  .sp-template-event-calendar .sp-previous-month {
326
- text-align: left !important;
327
  }
328
 
329
  .sp-template-event-calendar .sp-next-month {
330
- text-align: right !important;
331
  }
332
 
333
  .sp-template-event-calendar tfoot a {
334
- font-size: 12px !important;
335
- font-weight: 400 !important;
336
- line-height: 1.5 !important;
337
- text-decoration: none !important;
338
- color: rgba(51,51,51,0.5) !important;
339
  }
340
 
341
  .sp-template-event-calendar tfoot a:hover {
342
- color: #333 !important;
343
- text-decoration: none !important;
344
  }
345
 
346
  .sp-template-event-calendar tbody td {
347
- position: relative !important;
348
  }
349
 
350
  .sp-template-event-calendar tbody td a:before {
351
- content: '•' !important;
352
- position: absolute !important;
353
- font-size: 20px !important;
354
- line-height: 1 !important;
355
- width: 1em !important;
356
- top: 0 !important;
357
- right: 0 !important;
358
  }
359
 
360
  /* Event Lists */
361
 
362
  .sp-template-event-list .data-home {
363
- text-align: right !important;
364
  }
365
 
366
  .sp-template-event-list .data-away {
367
- text-align: left !important;
368
  }
369
 
370
  /* Event Blocks */
371
 
372
  .sp-template-event-blocks td {
373
- padding: 0 !important;
374
  }
375
 
376
  .sp-template-event-blocks .sp-event-date {
377
- color: rgba(51,51,51,0.5) !important;
378
- font-weight: 500 !important;
379
- font-size: 12px !important;
380
- margin: 10px !important;
381
  }
382
 
383
  .sp-template-event-blocks .sp-event-date a,
384
  .sp-template-event-blocks .sp-event-date a:hover {
385
- color: inherit !important;
386
  }
387
 
388
  .sp-template-event-blocks .sp-event-results {
389
- font-size: 20px !important;
390
- font-weight: 400 !important;
391
- padding: 0 !important;
392
- margin: 0 !important;
393
- color: #333 !important;
394
  }
395
 
396
  .sp-template-event-blocks .sp-event-results a {
397
- color: inherit !important;
398
  }
399
 
400
  .sp-template-event-blocks .sp-event-results a:hover {
401
- color: inherit !important;
402
- text-decoration: none !important;
403
  }
404
 
405
  .sp-template-event-blocks .sp-event-title,
406
  .sp-template-event-blocks .sp-event-status {
407
- display: block !important;
408
- padding: 0 !important;
409
- margin: 10px !important;
410
- font-size: 13px !important;
411
- font-weight: 400 !important;
412
  }
413
 
414
  /* Event Logos */
415
 
416
  .sp-template-event-logos .sp-team-name,
417
  .sp-template-event-logos .sp-team-result {
418
- font-size: 20px !important;
419
- font-weight: 400 !important;
420
- padding: 0 !important;
421
- margin: 0 !important;
422
- color: #333 !important;
423
  }
424
 
425
  .sp-template-event-logos a,
426
  .sp-template-event-logos a:hover {
427
- border: none !important;
428
- text-decoration: none !important;
429
  }
430
 
431
  /* Event Performance */
432
 
433
  .sp-template-event-performance-icons td {
434
- border: none !important;
435
  }
436
 
437
  .sp-template-event-performance-icons tr:first-child td {
438
- border-top: 1px solid #e5e5e5 !important;
439
  }
440
 
441
  /* Videos */
442
  .sp-template-event-video iframe {
443
- width: 100% !important;
444
  }
445
 
446
  /* Match Stats */
447
 
448
  .sp-template-event-statistics .sp-statistic-label {
449
- font-size: 12px !important;
450
- font-weight: 500 !important;
451
- color: inherit !important;
452
- opacity: 0.5 !important;
453
  }
454
 
455
  .sp-event-statistics {
456
- background: transparent !important;
457
- margin: 0 0 10px !important;
458
  }
459
 
460
  .sp-event-statistics,
461
  .sp-event-statistics tr,
462
  .sp-event-statistics td {
463
- border: none !important;
464
  }
465
 
466
  .sp-event-statistics .sp-statistic-ratio {
467
- padding: 0 !important;
468
  }
469
 
470
  .sp-event-statistics .sp-statistic-bar {
471
- border: 1px solid #e5e5e5 !important;
472
- background: #f9f9f9 !important;
473
  }
474
 
475
  /* Venues */
476
 
477
  .sp-event-venue-map-row td {
478
- padding: 0 !important;
479
  }
480
 
481
  .sp-event-venue-map-row .sp-google-map {
482
- display: block !important;
483
- margin: 0 !important;
484
  }
485
 
486
  /* Teams */
487
 
488
  .sp-template-logo {
489
- float: right !important;
490
- margin: 0 0 20px 20px !important;
491
- clear: none !important;
492
  }
493
 
494
  /* Profiles */
495
 
496
  .sp-template-details dl {
497
- margin: 0 0 20px !important;
498
- padding: 15px !important;
499
- border: 1px solid #e5e5e5 !important;
500
- background: #fff !important;
501
  }
502
 
503
  .sp-template-details dt,
504
  .sp-template-details dd {
505
- margin: 0 !important;
506
- padding: 0 !important;
507
  }
508
 
509
  .sp-template-details dt {
510
- font-size: 12px !important;
511
- font-weight: 500 !important;
512
- color: rgba(51,51,51,0.5) !important;
513
  }
514
 
515
  .sp-template-details dd {
516
- font-size: 16px !important;
517
- font-weight: 400 !important;
518
- color: #333 !important;
519
- margin-bottom: 10px !important;
520
  }
521
 
522
  .sp-template-details dd:last-child {
523
- margin-bottom: 0 !important;
524
  }
525
 
526
  /* Twitter */
527
 
528
  .sp-tweets {
529
- border: 1px solid #e5e5e5 !important;
530
- border-top: none !important;
531
  }
532
 
533
  /* Scoreboards */
534
 
535
  .sp-header-scoreboard .sp-template-scoreboard {
536
- margin-bottom: 0 !important;
537
  }
538
 
539
  .sp-template-scoreboard td {
540
- padding: 0 !important;
541
  }
542
 
543
  .sp-template-scoreboard td:hover {
544
- background: #f9f9f9 !important;
545
  }
546
 
547
  .sp-template-scoreboard a,
548
  .sp-template-scoreboard a:hover {
549
- text-decoration: none !important;
550
- color: #333 !important;
551
  }
552
 
553
  .sp-template-scoreboard .sp-scoreboard-date {
554
- font-size: 12px !important;
555
- font-weight: 500 !important;
556
- color: rgba(51,51,51,0.5) !important;
557
  }
558
 
559
  .sp-template-scoreboard .sp-scoreboard-nav {
560
- color: #fff !important;
561
- background: #00a69c !important;
562
  }
563
 
564
  /* Timelines */
565
 
566
  .sp-template-timeline .sp-timeline * {
567
- color: initial !important;
568
  }
569
 
570
  /* Tournaments */
571
 
572
  .sp-tournament-bracket {
573
- color: #333 !important;
574
- background: transparent !important;
575
- width: 100% !important;
576
- border-collapse: separate !important;
577
  }
578
 
579
  .sp-tournament-bracket a,
580
  .sp-tournament-bracket a:hover {
581
- text-decoration: none !important;
582
- color: inherit !important;
583
- border: none! important;
584
  }
585
 
586
  .sp-tournament-bracket tr,
587
  .sp-tournament-bracket th,
588
  .sp-tournament-bracket td {
589
- border: none !important;
590
  }
591
 
592
  .sp-tournament-bracket thead th {
593
- font-size: 12px !important;
594
- font-weight: 500 !important;
595
- color: rgba(51,51,51,0.5) !important;
596
- text-align: center !important;
597
- border-bottom: 1px solid #e5e5e5 !important;
598
  }
599
 
600
  .sp-tournament-bracket .sp-team-name {
601
- font-size: 13px !important;
602
- font-weight: 400 !important;
603
- text-align: center !important;
604
- background: #fff !important;
605
- border: 1px solid #e5e5e5 !important;
606
  }
607
 
608
  .sp-tournament-bracket .sp-team-name:hover {
609
- border: 1px solid #e5e5e5 !important;
610
  }
611
 
612
  .sp-tournament-bracket .sp-heading,
613
  .sp-tournament-bracket .sp-heading:hover {
614
- color: #fff !important;
615
- background: #00a69c !important;
616
- border-color: #00a69c !important;
617
  }
618
 
619
  .sp-tournament-bracket .sp-event {
620
- border-color: #e5e5e5 !important;
621
- border-width: 1px !important;
622
  }
623
 
624
  .sp-tournament-bracket .sp-event .sp-event-title {
625
- font-size: 12px !important;
626
- font-weight: 400 !important;
627
- color: rgba(51,51,51,0.5) !important;
628
- text-align: center !important;
629
  }
630
 
631
  .sp-tournament-bracket .sp-event .sp-event-title:hover {
632
- color: #333 !important;
633
  }
634
 
635
  /* Tabs */
636
 
637
  .sp-tab-menu {
638
- display: block !important;
639
- clear: both !important;
640
- margin: 0 0 20px !important;
641
- padding: 0 !important;
642
- list-style: none !important;
643
  }
644
 
645
  .sp-tab-menu-item {
646
- display: inline-block !important;
647
- margin: 0 !important;
648
- padding: 0 !important;
649
  }
650
 
651
  .sp-tab-menu-item a {
652
- margin: 0 !important;
653
- padding: 5px 10px;
654
- border-bottom: 2px solid transparent !important;
655
- box-shadow: none !important;
656
  }
657
 
658
  .sp-tab-menu-item a:hover {
659
- text-decoration: none !important;
660
  }
661
 
662
  .sp-tab-menu-item-active a,
663
  .sp-tab-menu-item-active a:hover {
664
- color: #00a69c !important;
665
- border-bottom-color: #00a69c !important;
666
  }
667
 
668
  /* Messages */
669
  .sp-template .sp-message {
670
- color: #00a69c !important;
671
- border-color: #00a69c !important;
672
  }
673
 
674
  /* Post Content */
675
 
676
  .single-sp_team .has-post-thumbnail .sp-post-content {
677
- clear: none;
678
  }
679
 
680
  /* Media Queries */
681
 
682
  @media screen and (min-width: 601px) {
683
- .sp-template-event-calendar tbody td {
684
- padding: 15px 5px !important;
685
- }
686
 
687
- .sp-template-event-calendar tbody td a:before {
688
- font-size: 25px !important;
689
- }
690
 
691
- .widget .sp-template-event-calendar tbody td {
692
- padding: 10px 5px !important;
693
- }
694
 
695
- .widget .sp-template-event-calendar tbody td a:before {
696
- font-size: 20px !important;
697
- }
698
  }
699
 
700
  @media screen and (min-width: 801px) {
701
- .sp-template-event-calendar tbody td {
702
- padding: 20px 5px !important;
703
- }
704
-
705
- .sp-template-event-calendar tbody td a:before {
706
- font-size: 30px !important;
707
- }
708
-
709
- .widget .sp-template-event-calendar tbody td {
710
- padding: 10px 5px !important;
711
- }
712
-
713
- .widget .sp-template-event-calendar tbody td a:before {
714
- font-size: 20px !important;
715
- }
716
-
717
- .sp-template-event-performance-icons.sp-template-event-performance-section:nth-child(2n) {
718
- padding-top: 61px !important;
719
- }
720
- }
3
  .sp-template,
4
  .sp-data-table,
5
  .sp-table-caption {
6
+ font-family: "Roboto", "Helvetica", sans-serif;
7
  }
8
 
9
  .sp-template {
10
+ clear: both;
11
+ overflow: hidden;
12
  }
13
 
14
  /*
34
  .sp-table-caption h4,
35
  .sp-table-caption h5,
36
  .sp-table-caption h6 {
37
+ font-family: "Roboto", "Helvetica", sans-serif !important;
38
  }
39
 
40
  .sp-template {
41
+ margin-bottom: 20px !important;
42
  }
43
 
44
  .sp-template *,
45
  .sp-data-table *,
46
  .sp-table-caption {
47
+ box-sizing: border-box !important;
48
+ font-weight: 400 !important;
49
+ text-transform: none !important;
50
+ letter-spacing: normal !important;
51
+ color: #333 !important;
52
  }
53
 
54
  .sp-table-caption {
55
+ margin: 0 !important;
56
+ padding: 15px !important;
57
+ background: #fff !important;
58
+ border: 1px solid #e5e5e5 !important;
59
+ border-bottom: none !important;
60
+ font-size: 20px !important;
61
+ font-weight: 400 !important;
62
+ line-height: 1.5 !important;
63
+ display: table !important;
64
+ width: 100% !important;
65
  }
66
 
67
  /* Color Resets */
70
  .sp-data-table input,
71
  .sp-template .sp-event-logos,
72
  .sp-template .sp-event-staff {
73
+ color: initial !important;
74
  }
75
 
76
  /* Links */
77
 
78
  .sp-template a,
79
  .sp-data-table a {
80
+ box-shadow: none !important;
81
+ border: none !important;
82
+ text-decoration: none !important;
83
+ font-weight: inherit !important;
84
+ color: #00a69c !important;
85
  }
86
 
87
  .sp-template a:hover,
88
  .sp-data-table a:hover {
89
+ text-decoration: underline !important;
90
  }
91
 
92
  .sp-template a:hover .dashicons,
93
  .sp-template a:hover [class^="sp-icon-"], [class*=" sp-icon-"],
94
  .sp-data-table a:hover .dashicons,
95
  .sp-data-table a:hover [class^="sp-icon-"], [class*=" sp-icon-"] {
96
+ text-decoration: none !important;
97
  }
98
 
99
  .sp-view-all-link {
100
+ padding: 10px 15px !important;
101
+ margin: 0 !important;
102
+ background: #fff !important;
103
+ border: 1px solid #e5e5e5 !important;
104
+ border-top: none !important;
105
+ overflow: hidden !important;
106
+ display: table !important;
107
+ width: 100% !important;
108
+ text-align: right !important;
109
  }
110
 
111
  .sp-view-all-link a {
112
+ font-size: 12px !important;
113
+ font-weight: 400 !important;
114
+ line-height: 1.5 !important;
115
+ text-decoration: none !important;
116
+ color: rgba(51,51,51,0.5) !important;
117
  }
118
 
119
  .sp-view-all-link a:hover {
120
+ color: #333 !important;
121
+ text-decoration: none !important;
122
  }
123
 
124
  .sp-form-events a:hover {
125
+ color: #fff !important;
126
+ text-decoration: none !important;
127
  }
128
 
129
  /* Images */
130
 
131
  .sp-template img {
132
+ display: inline-block !important;
133
+ box-shadow: none !important;
134
  }
135
 
136
  /* Tables */
137
 
138
  .sp-data-table {
139
+ margin: 0 !important;
140
+ background: #fff !important;
141
+ border-collapse: collapse !important;
142
+ border: 1px solid #e5e5e5 !important;
143
+ width: 100% !important;
144
  }
145
 
146
  .sp-data-table tr {
147
+ border: none !important;
148
  }
149
 
150
  .sp-data-table th,
151
  .sp-data-table td {
152
+ font-size: 13px !important;
153
+ font-weight: 400 !important;
154
+ line-height: 1.5 !important;
155
+ border: 1px solid #e5e5e5 !important;
156
+ padding: 5px 10px !important;
157
+ text-align: center !important;
158
  }
159
 
160
  .sp-data-table th {
161
+ font-size: 12px !important;
162
+ font-weight: 500 !important;
163
+ background: #fff !important;
164
+ color: #999 !important;
165
+ border: none !important;
166
  }
167
 
168
  .sp-data-table th a {
169
+ color: inherit !important;
170
  }
171
 
172
  .sp-data-table .sp-highlight,
173
  .sp-data-table .highlighted td {
174
+ font-weight: 500 !important;
175
+ background: #f9f9f9 !important;
176
  }
177
 
178
  /* Galleries */
179
 
180
  .sp-template-gallery .sp-gallery-wrapper {
181
+ border: 1px solid #e5e5e5 !important;
182
+ background: #fff !important;
183
+ display: table !important;
184
+ width: 100% !important;
185
  }
186
 
187
  .sp-template-gallery .gallery-item {
188
+ padding: 0 !important;
189
+ margin: 0 !important;
190
+ position: relative !important;
191
  }
192
 
193
  .sp-template-gallery .gallery-item a {
194
+ display: block !important;
195
+ color: #999 !important;
196
  }
197
 
198
  .sp-template-gallery .gallery-item img {
199
+ display: block !important;
200
+ border: none !important;
201
+ padding: 0 !important;
202
+ margin: 0 !important;
203
+ border-radius: 0 !important;
204
  }
205
 
206
  .sp-template-gallery .gallery-caption {
207
+ padding: 0 !important;
208
+ margin: 0 !important;
209
+ font-size: 12px !important;
210
+ font-style: normal !important;
211
+ font-weight: 500 !important;
212
+ text-align: center !important;
213
+ color: #999 !important;
214
+ line-height: 1.5 !important;
215
+ padding: 5px 10px !important;
216
  }
217
 
218
  .sp-template-gallery .gallery-caption strong {
219
+ color: #fff !important;
220
+ background: #00a69c !important;
221
+ display: block !important;
222
+ font-weight: 400 !important;
223
+ font-size: 13px !important;
224
+ line-height: 1.5 !important;
225
+ position: absolute !important;
226
+ left: 0 !important;
227
+ top: 0 !important;
228
+ padding: 5px 10px !important;
229
  }
230
 
231
  .sp-template-staff-gallery .gallery-caption strong {
232
+ display: none !important;
233
  }
234
 
235
  .sp-template-gallery .sp-gallery-group-name {
236
+ margin: 0 !important;
237
+ padding: 15px !important;
238
+ background: #fff !important;
239
+ border-bottom: 1px solid #e5e5e5 !important;
240
+ font-size: 20px !important;
241
+ font-weight: 400 !important;
242
+ line-height: 1.5 !important;
243
+ display: block !important;
244
  }
245
 
246
  /* Countdowns */
249
  .sp-template-countdown .sp-event-venue,
250
  .sp-template-countdown .sp-event-league,
251
  .sp-template-countdown .sp-event-date {
252
+ margin: 0 !important;
253
+ padding: 5px 10px !important;
254
+ text-align: center !important;
255
+ line-height: 1.5 !important;
256
+ display: table !important;
257
+ width: 100% !important;
258
+ background: #fff !important;
259
+ border: 1px solid #e5e5e5 !important;
260
+ border-bottom: none !important;
261
  }
262
 
263
  .sp-template-countdown .sp-event-name {
264
+ font-size: 13px !important;
265
+ font-weight: 400 !important;
266
+ color: #333 !important;
267
  }
268
 
269
  .sp-template-countdown .sp-event-venue,
270
  .sp-template-countdown .sp-event-league,
271
  .sp-template-countdown .sp-event-date {
272
+ font-size: 12px !important;
273
+ font-weight: 500 !important;
274
+ background: #fff !important;
275
+ color: #999 !important;
276
  }
277
 
278
  .sp-template-countdown .sp-event-venue a,
279
  .sp-template-countdown .sp-event-league a {
280
+ color: inherit !important;
281
  }
282
 
283
  .sp-countdown time {
284
+ display: table !important;
285
+ background: #fff !important;
286
+ border: 1px solid #e5e5e5 !important;
287
+ border-collapse: collapse !important;
288
+ width: 100% !important;
289
  }
290
 
291
  .sp-countdown span {
292
+ font-size: 20px !important;
293
+ font-weight: 400 !important;
294
+ line-height: 1.5 !important;
295
+ display: table-cell !important;
296
+ border: 1px solid #e5e5e5 !important;
297
+ padding: 10px 5px !important;
298
+ text-align: center !important;
299
  }
300
 
301
  .sp-countdown span small {
302
+ font-size: 12px !important;
303
+ font-weight: 400 !important;
304
+ line-height: 1.5 !important;
305
+ font-weight: 500 !important;
306
+ color: rgba(51,51,51,0.5) !important;
307
+ display: block !important;
308
  }
309
 
310
  /* Event Calendars */
311
 
312
  .sp-template-event-calendar .sp-table-caption {
313
+ display: table-caption !important;
314
  }
315
 
316
  .sp-template-event-calendar td {
317
+ padding: 10px 5px !important;
318
  }
319
 
320
  .sp-template-event-calendar tfoot td {
321
+ padding: 10px 15px !important;
322
+ border: none !important;
323
  }
324
 
325
  .sp-template-event-calendar .sp-previous-month {
326
+ text-align: left !important;
327
  }
328
 
329
  .sp-template-event-calendar .sp-next-month {
330
+ text-align: right !important;
331
  }
332
 
333
  .sp-template-event-calendar tfoot a {
334
+ font-size: 12px !important;
335
+ font-weight: 400 !important;
336
+ line-height: 1.5 !important;
337
+ text-decoration: none !important;
338
+ color: rgba(51,51,51,0.5) !important;
339
  }
340
 
341
  .sp-template-event-calendar tfoot a:hover {
342
+ color: #333 !important;
343
+ text-decoration: none !important;
344
  }
345
 
346
  .sp-template-event-calendar tbody td {
347
+ position: relative !important;
348
  }
349
 
350
  .sp-template-event-calendar tbody td a:before {
351
+ content: '•' !important;
352
+ position: absolute !important;
353
+ font-size: 20px !important;
354
+ line-height: 1 !important;
355
+ width: 1em !important;
356
+ top: 0 !important;
357
+ right: 0 !important;
358
  }
359
 
360
  /* Event Lists */
361
 
362
  .sp-template-event-list .data-home {
363
+ text-align: right !important;
364
  }
365
 
366
  .sp-template-event-list .data-away {
367
+ text-align: left !important;
368
  }
369
 
370
  /* Event Blocks */
371
 
372
  .sp-template-event-blocks td {
373
+ padding: 0 !important;
374
  }
375
 
376
  .sp-template-event-blocks .sp-event-date {
377
+ color: rgba(51,51,51,0.5) !important;
378
+ font-weight: 500 !important;
379
+ font-size: 12px !important;
380
+ margin: 10px !important;
381
  }
382
 
383
  .sp-template-event-blocks .sp-event-date a,
384
  .sp-template-event-blocks .sp-event-date a:hover {
385
+ color: inherit !important;
386
  }
387
 
388
  .sp-template-event-blocks .sp-event-results {
389
+ font-size: 20px !important;
390
+ font-weight: 400 !important;
391
+ padding: 0 !important;
392
+ margin: 0 !important;
393
+ color: #333 !important;
394
  }
395
 
396
  .sp-template-event-blocks .sp-event-results a {
397
+ color: inherit !important;
398
  }
399
 
400
  .sp-template-event-blocks .sp-event-results a:hover {
401
+ color: inherit !important;
402
+ text-decoration: none !important;
403
  }
404
 
405
  .sp-template-event-blocks .sp-event-title,
406
  .sp-template-event-blocks .sp-event-status {
407
+ display: block !important;
408
+ padding: 0 !important;
409
+ margin: 10px !important;
410
+ font-size: 13px !important;
411
+ font-weight: 400 !important;
412
  }
413
 
414
  /* Event Logos */
415
 
416
  .sp-template-event-logos .sp-team-name,
417
  .sp-template-event-logos .sp-team-result {
418
+ font-size: 20px !important;
419
+ font-weight: 400 !important;
420
+ padding: 0 !important;
421
+ margin: 0 !important;
422
+ color: #333 !important;
423
  }
424
 
425
  .sp-template-event-logos a,
426
  .sp-template-event-logos a:hover {
427
+ border: none !important;
428
+ text-decoration: none !important;
429
  }
430
 
431
  /* Event Performance */
432
 
433
  .sp-template-event-performance-icons td {
434
+ border: none !important;
435
  }
436
 
437
  .sp-template-event-performance-icons tr:first-child td {
438
+ border-top: 1px solid #e5e5e5 !important;
439
  }
440
 
441
  /* Videos */
442
  .sp-template-event-video iframe {
443
+ width: 100% !important;
444
  }
445
 
446
  /* Match Stats */
447
 
448
  .sp-template-event-statistics .sp-statistic-label {
449
+ font-size: 12px !important;
450
+ font-weight: 500 !important;
451
+ color: inherit !important;
452
+ opacity: 0.5 !important;
453
  }
454
 
455
  .sp-event-statistics {
456
+ background: transparent !important;
457
+ margin: 0 0 10px !important;
458
  }
459
 
460
  .sp-event-statistics,
461
  .sp-event-statistics tr,
462
  .sp-event-statistics td {
463
+ border: none !important;
464
  }
465
 
466
  .sp-event-statistics .sp-statistic-ratio {
467
+ padding: 0 !important;
468
  }
469
 
470
  .sp-event-statistics .sp-statistic-bar {
471
+ border: 1px solid #e5e5e5 !important;
472
+ background: #f9f9f9 !important;
473
  }
474
 
475
  /* Venues */
476
 
477
  .sp-event-venue-map-row td {
478
+ padding: 0 !important;
479
  }
480
 
481
  .sp-event-venue-map-row .sp-google-map {
482
+ display: block !important;
483
+ margin: 0 !important;
484
  }
485
 
486
  /* Teams */
487
 
488
  .sp-template-logo {
489
+ float: right !important;
490
+ margin: 0 0 20px 20px !important;
491
+ clear: none !important;
492
  }
493
 
494
  /* Profiles */
495
 
496
  .sp-template-details dl {
497
+ margin: 0 0 20px !important;
498
+ padding: 15px !important;
499
+ border: 1px solid #e5e5e5 !important;
500
+ background: #fff !important;
501
  }
502
 
503
  .sp-template-details dt,
504
  .sp-template-details dd {
505
+ margin: 0 !important;
506
+ padding: 0 !important;
507
  }
508
 
509
  .sp-template-details dt {
510
+ font-size: 12px !important;
511
+ font-weight: 500 !important;
512
+ color: rgba(51,51,51,0.5) !important;
513
  }
514
 
515
  .sp-template-details dd {
516
+ font-size: 16px !important;
517
+ font-weight: 400 !important;
518
+ color: #333 !important;
519
+ margin-bottom: 10px !important;
520
  }
521
 
522
  .sp-template-details dd:last-child {
523
+ margin-bottom: 0 !important;
524
  }
525
 
526
  /* Twitter */
527
 
528
  .sp-tweets {
529
+ border: 1px solid #e5e5e5 !important;
530
+ border-top: none !important;
531
  }
532
 
533
  /* Scoreboards */
534
 
535
  .sp-header-scoreboard .sp-template-scoreboard {
536
+ margin-bottom: 0 !important;
537
  }
538
 
539
  .sp-template-scoreboard td {
540
+ padding: 0 !important;
541
  }
542
 
543
  .sp-template-scoreboard td:hover {
544
+ background: #f9f9f9 !important;
545
  }
546
 
547
  .sp-template-scoreboard a,
548
  .sp-template-scoreboard a:hover {
549
+ text-decoration: none !important;
550
+ color: #333 !important;
551
  }
552
 
553
  .sp-template-scoreboard .sp-scoreboard-date {
554
+ font-size: 12px !important;
555
+ font-weight: 500 !important;
556
+ color: rgba(51,51,51,0.5) !important;
557
  }
558
 
559
  .sp-template-scoreboard .sp-scoreboard-nav {
560
+ color: #fff !important;
561
+ background: #00a69c !important;
562
  }
563
 
564
  /* Timelines */
565
 
566
  .sp-template-timeline .sp-timeline * {
567
+ color: initial !important;
568
  }
569
 
570
  /* Tournaments */
571
 
572
  .sp-tournament-bracket {
573
+ color: #333 !important;
574
+ background: transparent !important;
575
+ width: 100% !important;
576
+ border-collapse: separate !important;
577
  }
578
 
579
  .sp-tournament-bracket a,
580
  .sp-tournament-bracket a:hover {
581
+ text-decoration: none !important;
582
+ color: inherit !important;
583
+ border: none! important;
584
  }
585
 
586
  .sp-tournament-bracket tr,
587
  .sp-tournament-bracket th,
588
  .sp-tournament-bracket td {
589
+ border: none !important;
590
  }
591
 
592
  .sp-tournament-bracket thead th {
593
+ font-size: 12px !important;
594
+ font-weight: 500 !important;
595
+ color: rgba(51,51,51,0.5) !important;
596
+ text-align: center !important;
597
+ border-bottom: 1px solid #e5e5e5 !important;
598
  }
599
 
600
  .sp-tournament-bracket .sp-team-name {
601
+ font-size: 13px !important;
602
+ font-weight: 400 !important;
603
+ text-align: center !important;
604
+ background: #fff !important;
605
+ border: 1px solid #e5e5e5 !important;
606
  }
607
 
608
  .sp-tournament-bracket .sp-team-name:hover {
609
+ border: 1px solid #e5e5e5 !important;
610
  }
611
 
612
  .sp-tournament-bracket .sp-heading,
613
  .sp-tournament-bracket .sp-heading:hover {
614
+ color: #fff !important;
615
+ background: #00a69c !important;
616
+ border-color: #00a69c !important;
617
  }
618
 
619
  .sp-tournament-bracket .sp-event {
620
+ border-color: #e5e5e5 !important;
621
+ border-width: 1px !important;
622
  }
623
 
624
  .sp-tournament-bracket .sp-event .sp-event-title {
625
+ font-size: 12px !important;
626
+ font-weight: 400 !important;
627
+ color: rgba(51,51,51,0.5) !important;
628
+ text-align: center !important;
629
  }
630
 
631
  .sp-tournament-bracket .sp-event .sp-event-title:hover {
632
+ color: #333 !important;
633
  }
634
 
635
  /* Tabs */
636
 
637
  .sp-tab-menu {
638
+ display: block !important;
639
+ clear: both !important;
640
+ margin: 0 0 20px !important;
641
+ padding: 0 !important;
642
+ list-style: none !important;
643
  }
644
 
645
  .sp-tab-menu-item {
646
+ display: inline-block !important;
647
+ margin: 0 !important;
648
+ padding: 0 !important;
649
  }
650
 
651
  .sp-tab-menu-item a {
652
+ margin: 0 !important;
653
+ padding: 5px 10px;
654
+ border-bottom: 2px solid transparent !important;
655
+ box-shadow: none !important;
656
  }
657
 
658
  .sp-tab-menu-item a:hover {
659
+ text-decoration: none !important;
660
  }
661
 
662
  .sp-tab-menu-item-active a,
663
  .sp-tab-menu-item-active a:hover {
664
+ color: #00a69c !important;
665
+ border-bottom-color: #00a69c !important;
666
  }
667
 
668
  /* Messages */
669
  .sp-template .sp-message {
670
+ color: #00a69c !important;
671
+ border-color: #00a69c !important;
672
  }
673
 
674
  /* Post Content */
675
 
676
  .single-sp_team .has-post-thumbnail .sp-post-content {
677
+ clear: none;
678
  }
679
 
680
  /* Media Queries */
681
 
682
  @media screen and (min-width: 601px) {
683
+ .sp-template-event-calendar tbody td {
684
+ padding: 15px 5px !important;
685
+ }
686
 
687
+ .sp-template-event-calendar tbody td a:before {
688
+ font-size: 25px !important;
689
+ }
690
 
691
+ .widget .sp-template-event-calendar tbody td {
692
+ padding: 10px 5px !important;
693
+ }
694
 
695
+ .widget .sp-template-event-calendar tbody td a:before {
696
+ font-size: 20px !important;
697
+ }
698
  }
699
 
700
  @media screen and (min-width: 801px) {
701
+ .sp-template-event-calendar tbody td {
702
+ padding: 20px 5px !important;
703
+ }
704
+
705
+ .sp-template-event-calendar tbody td a:before {
706
+ font-size: 30px !important;
707
+ }
708
+
709
+ .widget .sp-template-event-calendar tbody td {
710
+ padding: 10px 5px !important;
711
+ }
712
+
713
+ .widget .sp-template-event-calendar tbody td a:before {
714
+ font-size: 20px !important;
715
+ }
716
+
717
+ .sp-template-event-performance-icons.sp-template-event-performance-section:nth-child(2n) {
718
+ padding-top: 61px !important;
719
+ }
720
+ }
assets/css/sportspress.css CHANGED
@@ -61,10 +61,10 @@
61
  margin: 0 10px;
62
  color: inherit;
63
  opacity: 0.5;
64
- transition: all .3s;
65
  }
66
  .sp-tab-menu-item a:focus {
67
- outline: none;
68
  }
69
  .sp-tab-menu-item-active a,
70
  .sp-tab-menu-item a:hover {
@@ -90,7 +90,7 @@
90
  .sp-data-table {
91
  width: 100%;
92
  table-layout: auto;
93
- border-spacing: 0;
94
  }
95
  .sp-paginated-table {
96
  margin-bottom: 0;
@@ -310,12 +310,12 @@
310
  color: #f4d014;
311
  }
312
  .sp-event-performance .sp-event-star-number {
313
- margin-left: -20px;
314
- width: 20px;
315
- text-align: center;
316
- display: inline-block;
317
- font-size: smaller;
318
- line-height: 20px;
319
  }
320
 
321
  /* Event Performance (Icons) */
@@ -335,12 +335,12 @@
335
  }
336
 
337
  .sp-template-event-performance-icons .sp-player-position {
338
- display: block;
339
  }
340
 
341
  /* Event Calendar */
342
  .sp-event-calendar {
343
- border-spacing: 0;
344
  }
345
  .sp-event-calendar a {
346
  text-decoration: none;
@@ -635,11 +635,11 @@ span.sp_event_spec_label {
635
  display: inline-block;
636
  margin: 0 0.25em;
637
  }
638
-
639
  .sp-template-logo + .sp-post-content {
640
  clear: left;
641
  }
642
-
643
  .sp-template-photo + .sp-post-content {
644
  clear: none;
645
  }
@@ -664,15 +664,15 @@ span.sp_event_spec_label {
664
  text-align: right;
665
  float: right;
666
  }
667
-
668
  .sp-template-event-logos-block .logo-odd img {
669
  margin-right: 10px;
670
  }
671
-
672
  .sp-template-event-logos-block .logo-even img {
673
  margin-left: 10px;
674
  }
675
-
676
  .sp-template-event-logos-block .sp-team-name {
677
  display: inline;
678
  clear: none;
61
  margin: 0 10px;
62
  color: inherit;
63
  opacity: 0.5;
64
+ transition: all .3s;
65
  }
66
  .sp-tab-menu-item a:focus {
67
+ outline: none;
68
  }
69
  .sp-tab-menu-item-active a,
70
  .sp-tab-menu-item a:hover {
90
  .sp-data-table {
91
  width: 100%;
92
  table-layout: auto;
93
+ border-spacing: 0;
94
  }
95
  .sp-paginated-table {
96
  margin-bottom: 0;
310
  color: #f4d014;
311
  }
312
  .sp-event-performance .sp-event-star-number {
313
+ margin-left: -20px;
314
+ width: 20px;
315
+ text-align: center;
316
+ display: inline-block;
317
+ font-size: smaller;
318
+ line-height: 20px;
319
  }
320
 
321
  /* Event Performance (Icons) */
335
  }
336
 
337
  .sp-template-event-performance-icons .sp-player-position {
338
+ display: block;
339
  }
340
 
341
  /* Event Calendar */
342
  .sp-event-calendar {
343
+ border-spacing: 0;
344
  }
345
  .sp-event-calendar a {
346
  text-decoration: none;
635
  display: inline-block;
636
  margin: 0 0.25em;
637
  }
638
+
639
  .sp-template-logo + .sp-post-content {
640
  clear: left;
641
  }
642
+
643
  .sp-template-photo + .sp-post-content {
644
  clear: none;
645
  }
664
  text-align: right;
665
  float: right;
666
  }
667
+
668
  .sp-template-event-logos-block .logo-odd img {
669
  margin-right: 10px;
670
  }
671
+
672
  .sp-template-event-logos-block .logo-even img {
673
  margin-left: 10px;
674
  }
675
+
676
  .sp-template-event-logos-block .sp-team-name {
677
  display: inline;
678
  clear: none;
assets/css/themes/twentyfourteen.css CHANGED
@@ -6,4 +6,4 @@
6
 
7
  .sportspress-page .entry-content h4:first-child {
8
  margin-top: 36px;
9
- }
6
 
7
  .sportspress-page .entry-content h4:first-child {
8
  margin-top: 36px;
9
+ }
assets/images/flags/glp.png ADDED
Binary file
assets/images/flags/grl.png ADDED
Binary file
assets/images/flags/guf.png ADDED
Binary file
assets/images/flags/mtq.png ADDED
Binary file
assets/images/flags/pyf.png ADDED
Binary file
assets/images/flags/reu.png ADDED
Binary file
assets/images/flags/sxm.png ADDED
Binary file
assets/js/admin/colorpicker.js CHANGED
@@ -1,26 +1,38 @@
1
- jQuery(document).ready(function($){
 
2
 
3
- // Color picker
4
- $('.colorpick').iris( {
5
- change: function(event, ui){
6
- $(this).css( { backgroundColor: ui.color.toString() } );
7
- },
8
- hide: true,
9
- border: true
10
- } ).each( function() {
11
- $(this).css( { backgroundColor: $(this).val() } );
12
- })
13
- .click(function(){
14
- $('.iris-picker').hide();
15
- $(this).closest('.sp-color-box, td').find('.iris-picker').show();
16
- });
 
 
 
 
 
 
17
 
18
- $('body').click(function() {
19
- $('.iris-picker').hide();
20
- });
 
 
21
 
22
- $('.sp-color-box, .colorpick').click(function(event){
23
- event.stopPropagation();
24
- });
 
 
25
 
26
- });
 
1
+ jQuery( document ).ready(
2
+ function($){
3
 
4
+ // Color picker
5
+ $( '.colorpick' ).iris(
6
+ {
7
+ change: function(event, ui){
8
+ $( this ).css( { backgroundColor: ui.color.toString() } );
9
+ },
10
+ hide: true,
11
+ border: true
12
+ }
13
+ ).each(
14
+ function() {
15
+ $( this ).css( { backgroundColor: $( this ).val() } );
16
+ }
17
+ )
18
+ .click(
19
+ function(){
20
+ $( '.iris-picker' ).hide();
21
+ $( this ).closest( '.sp-color-box, td' ).find( '.iris-picker' ).show();
22
+ }
23
+ );
24
 
25
+ $( 'body' ).click(
26
+ function() {
27
+ $( '.iris-picker' ).hide();
28
+ }
29
+ );
30
 
31
+ $( '.sp-color-box, .colorpick' ).click(
32
+ function(event){
33
+ event.stopPropagation();
34
+ }
35
+ );
36
 
37
+ }
38
+ );
assets/js/admin/dashboard.js CHANGED
@@ -1,11 +1,18 @@
1
- jQuery(document).ready(function($){
 
2
 
3
- // Dashboard countdown
4
- $("#sportspress_dashboard_status .sp_status_list li.countdown").each(function() {
5
- var $this = $(this), finalDate = $(this).data('countdown');
6
- $this.countdown(finalDate, function(event) {
7
- $this.find('strong').html(event.strftime("%D "+localized_strings.days+" %H:%M:%S"));
8
- });
9
- });
 
 
 
 
 
10
 
11
- });
 
1
+ jQuery( document ).ready(
2
+ function($){
3
 
4
+ // Dashboard countdown
5
+ $( "#sportspress_dashboard_status .sp_status_list li.countdown" ).each(
6
+ function() {
7
+ var $this = $( this ), finalDate = $( this ).data( 'countdown' );
8
+ $this.countdown(
9
+ finalDate,
10
+ function(event) {
11
+ $this.find( 'strong' ).html( event.strftime( "%D " + localized_strings.days + " %H:%M:%S" ) );
12
+ }
13
+ );
14
+ }
15
+ );
16
 
17
+ }
18
+ );
assets/js/admin/editor-lang.php CHANGED
@@ -3,51 +3,63 @@
3
  $shortcodes = '';
4
 
5
  $options = array(
6
- 'event' => array(
7
- 'details', 'results', 'performance', 'venue', 'officials', 'teams', 'full',
8
- ),
9
- 'team' => array(),
10
- 'player' => array(
11
- 'details', 'statistics'
12
- ),
 
 
 
 
 
 
 
13
  );
14
 
15
  $options = apply_filters( 'sportspress_shortcodes', $options );
16
 
17
  foreach ( $options as $name => $group ) {
18
- if ( empty( $group ) ) continue;
19
- $shortcodes .= $name . '[' . implode( '|', $group ) . ']';
 
 
20
  }
21
 
22
- $raw = apply_filters( 'sportspress_tinymce_strings', array(
23
- 'shortcodes' => $shortcodes,
24
- 'insert' => __( 'SportsPress Shortcodes', 'sportspress' ),
25
- 'auto' => __( 'Auto', 'sportspress' ),
26
- 'manual' => __( 'Manual', 'sportspress' ),
27
- 'select' => __( 'Select...', 'sportspress' ),
28
- 'event' => __( 'Event', 'sportspress' ),
29
- 'details' => __( 'Details', 'sportspress' ),
30
- 'results' => __( 'Results', 'sportspress' ),
31
- 'countdown' => __( 'Countdown', 'sportspress' ),
32
- 'performance' => __( 'Box Score', 'sportspress' ),
33
- 'venue' => __( 'Venue', 'sportspress' ),
34
- 'officials' => __( 'Officials', 'sportspress' ),
35
- 'teams' => __( 'Teams', 'sportspress' ),
36
- 'full' => __( 'Full Info', 'sportspress' ),
37
- 'calendar' => __( 'Calendar', 'sportspress' ),
38
- 'statistics' => __( 'Statistics', 'sportspress' ),
39
- 'team' => __( 'Team', 'sportspress' ),
40
- 'standings' => __( 'League Table', 'sportspress' ),
41
- 'player' => __( 'Player', 'sportspress' ),
42
- 'list' => __( 'List', 'sportspress' ),
43
- 'blocks' => __( 'Blocks', 'sportspress' ),
44
- 'gallery' => __( 'Gallery', 'sportspress' ),
45
- ));
 
 
 
46
 
47
  $formatted = array();
48
 
49
  foreach ( $raw as $key => $value ) {
50
- $formatted[] = $key . ': "' . esc_js( $value ) . '"';
51
  }
52
 
53
  $strings = 'tinyMCE.addI18n({' . _WP_Editors::$mce_locale . ':{
3
  $shortcodes = '';
4
 
5
  $options = array(
6
+ 'event' => array(
7
+ 'details',
8
+ 'results',
9
+ 'performance',
10
+ 'venue',
11
+ 'officials',
12
+ 'teams',
13
+ 'full',
14
+ ),
15
+ 'team' => array(),
16
+ 'player' => array(
17
+ 'details',
18
+ 'statistics',
19
+ ),
20
  );
21
 
22
  $options = apply_filters( 'sportspress_shortcodes', $options );
23
 
24
  foreach ( $options as $name => $group ) {
25
+ if ( empty( $group ) ) {
26
+ continue;
27
+ }
28
+ $shortcodes .= $name . '[' . implode( '|', $group ) . ']';
29
  }
30
 
31
+ $raw = apply_filters(
32
+ 'sportspress_tinymce_strings',
33
+ array(
34
+ 'shortcodes' => $shortcodes,
35
+ 'insert' => esc_attr__( 'SportsPress Shortcodes', 'sportspress' ),
36
+ 'auto' => esc_attr__( 'Auto', 'sportspress' ),
37
+ 'manual' => esc_attr__( 'Manual', 'sportspress' ),
38
+ 'select' => esc_attr__( 'Select...', 'sportspress' ),
39
+ 'event' => esc_attr__( 'Event', 'sportspress' ),
40
+ 'details' => esc_attr__( 'Details', 'sportspress' ),
41
+ 'results' => esc_attr__( 'Results', 'sportspress' ),
42
+ 'countdown' => esc_attr__( 'Countdown', 'sportspress' ),
43
+ 'performance' => esc_attr__( 'Box Score', 'sportspress' ),
44
+ 'venue' => esc_attr__( 'Venue', 'sportspress' ),
45
+ 'officials' => esc_attr__( 'Officials', 'sportspress' ),
46
+ 'teams' => esc_attr__( 'Teams', 'sportspress' ),
47
+ 'full' => esc_attr__( 'Full Info', 'sportspress' ),
48
+ 'calendar' => esc_attr__( 'Calendar', 'sportspress' ),
49
+ 'statistics' => esc_attr__( 'Statistics', 'sportspress' ),
50
+ 'team' => esc_attr__( 'Team', 'sportspress' ),
51
+ 'standings' => esc_attr__( 'League Table', 'sportspress' ),
52
+ 'player' => esc_attr__( 'Player', 'sportspress' ),
53
+ 'list' => esc_attr__( 'List', 'sportspress' ),
54
+ 'blocks' => esc_attr__( 'Blocks', 'sportspress' ),
55
+ 'gallery' => esc_attr__( 'Gallery', 'sportspress' ),
56
+ )
57
+ );
58
 
59
  $formatted = array();
60
 
61
  foreach ( $raw as $key => $value ) {
62
+ $formatted[] = $key . ': "' . esc_js( $value ) . '"';
63
  }
64
 
65
  $strings = 'tinyMCE.addI18n({' . _WP_Editors::$mce_locale . ':{
assets/js/admin/editor.js CHANGED
@@ -1,42 +1,58 @@
1
  /* global tinymce */
2
  ( function () {
3
- tinymce.PluginManager.add( 'sp_shortcodes_button', function( editor, url ) {
4
- var ed = tinymce.activeEditor;
 
 
5
 
6
- var groups = ed.getLang( 'sportspress.shortcodes' ).split("]");
7
- var menu = new Array();
8
 
9
- groups.forEach(function(g) {
10
- if ( "" == g ) return;
11
- var p = g.split("[");
12
- var label = p.shift();
13
- var variations = p.shift();
14
- var shortcodes = typeof variations!== 'undefined' ? variations.split("|") : [];
15
- var submenu = new Array();
16
- shortcodes.forEach(function(s) {
17
- submenu.push({
18
- text: ed.getLang( 'sportspress.' + s ),
19
- onclick: function() {
20
- // triggers the thickbox
21
- var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
22
- W = W - 80;
23
- H = H - 84;
24
- tb_show( ed.getLang( 'sportspress.' + label ) + ' - ' + ed.getLang( 'sportspress.' + s ), 'admin-ajax.php?action=sportspress_' + label + '_' + s + '_shortcode&width=' + W + '&height=' + H );
25
  }
26
- });
27
- });
28
- menu.push({
29
- text: ed.getLang( 'sportspress.' + label ),
30
- menu: submenu
31
- });
32
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
- editor.addButton( 'sp_shortcodes_button', {
35
- title: ed.getLang('sportspress.insert'),
36
- text: false,
37
- icon: false,
38
- type: 'menubutton',
39
- menu: menu
40
- });
41
- });
 
 
 
 
42
  })();
1
  /* global tinymce */
2
  ( function () {
3
+ tinymce.PluginManager.add(
4
+ 'sp_shortcodes_button',
5
+ function( editor, url ) {
6
+ var ed = tinymce.activeEditor;
7
 
8
+ var groups = ed.getLang( 'sportspress.shortcodes' ).split( "]" );
9
+ var menu = new Array();
10
 
11
+ groups.forEach(
12
+ function(g) {
13
+ if ( "" == g ) {
14
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
+ var p = g.split( "[" );
17
+ var label = p.shift();
18
+ var variations = p.shift();
19
+ var shortcodes = typeof variations !== 'undefined' ? variations.split( "|" ) : [];
20
+ var submenu = new Array();
21
+ shortcodes.forEach(
22
+ function(s) {
23
+ submenu.push(
24
+ {
25
+ text: ed.getLang( 'sportspress.' + s ),
26
+ onclick: function() {
27
+ // triggers the thickbox
28
+ var width = jQuery( window ).width(), H = jQuery( window ).height(), W = ( 720 < width ) ? 720 : width;
29
+ W = W - 80;
30
+ H = H - 84;
31
+ tb_show( ed.getLang( 'sportspress.' + label ) + ' - ' + ed.getLang( 'sportspress.' + s ), 'admin-ajax.php?action=sportspress_' + label + '_' + s + '_shortcode&width=' + W + '&height=' + H );
32
+ }
33
+ }
34
+ );
35
+ }
36
+ );
37
+ menu.push(
38
+ {
39
+ text: ed.getLang( 'sportspress.' + label ),
40
+ menu: submenu
41
+ }
42
+ );
43
+ }
44
+ );
45
 
46
+ editor.addButton(
47
+ 'sp_shortcodes_button',
48
+ {
49
+ title: ed.getLang( 'sportspress.insert' ),
50
+ text: false,
51
+ icon: false,
52
+ type: 'menubutton',
53
+ menu: menu
54
+ }
55
+ );
56
+ }
57
+ );
58
  })();
assets/js/admin/equationbuilder.js CHANGED
@@ -1,37 +1,55 @@
1
- jQuery(document).ready(function($){
2
- $("#title").keyup(function() {
3
- val = $(this).val();
4
- if ( val == '' ) val = 'f(x)';
5
- $(".sp-equation-variable").text( val + ' =' );
6
- });
 
 
 
 
 
7
 
8
- $(".sp-equation-parts .button").draggable({
9
- appendTo: "body",
10
- helper: "clone",
11
- cursor: "move",
12
- distance: 10,
13
- containment: "#sp_equationdiv",
14
- }).click(function() {
15
- $("<label class='button'></label>").text( $(this).text() ).append("<span class='remove'>&times;</span><input name='sp_equation[]' type='hidden' value='" + $(this).data("variable") + "'>").appendTo( $(".sp-equation-formula") );
16
- });
 
 
 
 
17
 
18
- $(".sp-equation").droppable({
19
- activeClass: "ui-state-active",
20
- hoverClass: "ui-state-hover",
21
- accept: ".button:not(.ui-sortable-helper)",
22
- drop: function( event, ui ) {
23
- $("<label class='button'></label>").text( ui.draggable.text() ).append("<span class='remove'>&times;</span><input name='sp_equation[]' type='hidden' value='" + ui.draggable.data("variable") + "'>").appendTo( $(".sp-equation-formula") );
24
- }
25
- }).sortable({
26
- items: ".button",
27
- tolerance: "pointer",
28
- containment: "#sp_equationdiv",
29
- sort: function() {
30
- $( this ).removeClass( "ui-state-active" );
31
- }
32
- });
 
 
 
 
33
 
34
- $(".sp-equation-formula").on("click", ".button .remove", function() {
35
- $(this).closest(".button").remove();
36
- });
37
- });
 
 
 
 
 
1
+ jQuery( document ).ready(
2
+ function($){
3
+ $( "#title" ).keyup(
4
+ function() {
5
+ val = $( this ).val();
6
+ if ( val == '' ) {
7
+ val = 'f(x)';
8
+ }
9
+ $( ".sp-equation-variable" ).text( val + ' =' );
10
+ }
11
+ );
12
 
13
+ $( ".sp-equation-parts .button" ).draggable(
14
+ {
15
+ appendTo: "body",
16
+ helper: "clone",
17
+ cursor: "move",
18
+ distance: 10,
19
+ containment: "#sp_equationdiv",
20
+ }
21
+ ).click(
22
+ function() {
23
+ $( "<label class='button'></label>" ).text( $( this ).text() ).append( "<span class='remove'>&times;</span><input name='sp_equation[]' type='hidden' value='" + $( this ).data( "variable" ) + "'>" ).appendTo( $( ".sp-equation-formula" ) );
24
+ }
25
+ );
26
 
27
+ $( ".sp-equation" ).droppable(
28
+ {
29
+ activeClass: "ui-state-active",
30
+ hoverClass: "ui-state-hover",
31
+ accept: ".button:not(.ui-sortable-helper)",
32
+ drop: function( event, ui ) {
33
+ $( "<label class='button'></label>" ).text( ui.draggable.text() ).append( "<span class='remove'>&times;</span><input name='sp_equation[]' type='hidden' value='" + ui.draggable.data( "variable" ) + "'>" ).appendTo( $( ".sp-equation-formula" ) );
34
+ }
35
+ }
36
+ ).sortable(
37
+ {
38
+ items: ".button",
39
+ tolerance: "pointer",
40
+ containment: "#sp_equationdiv",
41
+ sort: function() {
42
+ $( this ).removeClass( "ui-state-active" );
43
+ }
44
+ }
45
+ );
46
 
47
+ $( ".sp-equation-formula" ).on(
48
+ "click",
49
+ ".button .remove",
50
+ function() {
51
+ $( this ).closest( ".button" ).remove();
52
+ }
53
+ );
54
+ }
55
+ );
assets/js/admin/iconpicker.js CHANGED
@@ -1,37 +1,52 @@
1
- jQuery(document).ready(function($){
 
2
 
3
- // Icon picker
4
- $('.sp-icons input').on('change', function() {
5
- if ('' == $(this).val()) {
6
- $('.sp-custom-colors').hide();
7
- $('.sp-custom-thumbnail').show();
8
- } else {
9
- $('.sp-custom-thumbnail').hide();
10
- $('.sp-custom-colors').show();
11
- }
12
- });
 
 
 
13
 
14
- // Color picker
15
- $('.colorpick').iris( {
16
- change: function(event, ui){
17
- $(this).css( { backgroundColor: ui.color.toString() } );
18
- },
19
- hide: true,
20
- border: true
21
- } ).each( function() {
22
- $(this).css( { backgroundColor: $(this).val() } );
23
- })
24
- .click(function(){
25
- $('.iris-picker').hide();
26
- $(this).closest('.sp-color-box-for-icon, td').find('.iris-picker').show();
27
- });
 
 
 
 
 
 
28
 
29
- $('body').click(function() {
30
- $('.iris-picker').hide();
31
- });
 
 
32
 
33
- $('.sp-color-box-for-icon, .colorpick').click(function(event){
34
- event.stopPropagation();
35
- });
 
 
36
 
37
- });
 
1
+ jQuery( document ).ready(
2
+ function($){
3
 
4
+ // Icon picker
5
+ $( '.sp-icons input' ).on(
6
+ 'change',
7
+ function() {
8
+ if ('' == $( this ).val()) {
9
+ $( '.sp-custom-colors' ).hide();
10
+ $( '.sp-custom-thumbnail' ).show();
11
+ } else {
12
+ $( '.sp-custom-thumbnail' ).hide();
13
+ $( '.sp-custom-colors' ).show();
14
+ }
15
+ }
16
+ );
17
 
18
+ // Color picker
19
+ $( '.colorpick' ).iris(
20
+ {
21
+ change: function(event, ui){
22
+ $( this ).css( { backgroundColor: ui.color.toString() } );
23
+ },
24
+ hide: true,
25
+ border: true
26
+ }
27
+ ).each(
28
+ function() {
29
+ $( this ).css( { backgroundColor: $( this ).val() } );
30
+ }
31
+ )
32
+ .click(
33
+ function(){
34
+ $( '.iris-picker' ).hide();
35
+ $( this ).closest( '.sp-color-box-for-icon, td' ).find( '.iris-picker' ).show();
36
+ }
37
+ );
38
 
39
+ $( 'body' ).click(
40
+ function() {
41
+ $( '.iris-picker' ).hide();
42
+ }
43
+ );
44
 
45
+ $( '.sp-color-box-for-icon, .colorpick' ).click(
46
+ function(event){
47
+ event.stopPropagation();
48
+ }
49
+ );
50
 
51
+ }
52
+ );
assets/js/admin/quickeditor.js CHANGED
@@ -24,56 +24,72 @@
24
  var $post_row = $( '#post-' + $post_id );
25
 
26
  // get the data
27
- var $number = $( '.column-sp_number', $post_row ).text();
28
- var $current_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'current-teams' ) ).split(',');
29
- var $past_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'past-teams' ) ).split(',');
30
 
31
  // populate the data
32
  $( ':input[name="sp_number"]', $edit_row ).val( $number );
33
- $( ':input[name="sp_current_team[]"]', $edit_row ).each(function() {
34
- $(this).prop("checked", ($.inArray($(this).val(), $current_teams ) != -1));
35
- });
36
- $( ':input[name="sp_past_team[]"]', $edit_row ).each(function() {
37
- $(this).prop("checked", ($.inArray($(this).val(), $past_teams ) != -1));
38
- });
 
 
 
 
39
  }
40
  };
41
 
42
- $( document ).on( 'click', '#bulk_edit', function() {
43
- // define the bulk edit row
44
- var $bulk_row = $( '#bulk-edit' );
 
 
 
45
 
46
- // get the selected post ids that are being edited
47
- var $post_ids = new Array();
48
- $bulk_row.find( '#bulk-titles' ).children().each( function() {
49
- $post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
50
- });
 
 
51
 
52
- // get the data
53
- var $current_teams = [];
54
- $bulk_row.find( 'input[name="sp_current_team[]"]:checked' ).each(function() {
55
- $current_teams.push( $(this).val() );
56
- });
 
 
57
 
58
- var $past_teams = [];
59
- $bulk_row.find( 'input[name="sp_past_team[]"]:checked' ).each(function() {
60
- $past_teams.push( $(this).val() );
61
- });
 
 
62
 
63
- // save the data
64
- $.ajax({
65
- url: ajaxurl, // this is a variable that WordPress has already defined for us
66
- type: 'POST',
67
- async: false,
68
- cache: false,
69
- data: {
70
- action: 'save_bulk_edit_sp_player',
71
- post_ids: $post_ids,
72
- current_teams: $current_teams,
73
- past_teams: $past_teams,
74
- nonce: $("#sp_player_edit_nonce").val()
75
- }
76
- });
77
- });
 
 
 
78
 
79
- })(jQuery);
24
  var $post_row = $( '#post-' + $post_id );
25
 
26
  // get the data
27
+ var $number = $( '.column-sp_number', $post_row ).text();
28
+ var $current_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'current-teams' ) ).split( ',' );
29
+ var $past_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'past-teams' ) ).split( ',' );
30
 
31
  // populate the data
32
  $( ':input[name="sp_number"]', $edit_row ).val( $number );
33
+ $( ':input[name="sp_current_team[]"]', $edit_row ).each(
34
+ function() {
35
+ $( this ).prop( "checked", ($.inArray( $( this ).val(), $current_teams ) != -1) );
36
+ }
37
+ );
38
+ $( ':input[name="sp_past_team[]"]', $edit_row ).each(
39
+ function() {
40
+ $( this ).prop( "checked", ($.inArray( $( this ).val(), $past_teams ) != -1) );
41
+ }
42
+ );
43
  }
44
  };
45
 
46
+ $( document ).on(
47
+ 'click',
48
+ '#bulk_edit',
49
+ function() {
50
+ // define the bulk edit row
51
+ var $bulk_row = $( '#bulk-edit' );
52
 
53
+ // get the selected post ids that are being edited
54
+ var $post_ids = new Array();
55
+ $bulk_row.find( '#bulk-titles' ).children().each(
56
+ function() {
57
+ $post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
58
+ }
59
+ );
60
 
61
+ // get the data
62
+ var $current_teams = [];
63
+ $bulk_row.find( 'input[name="sp_current_team[]"]:checked' ).each(
64
+ function() {
65
+ $current_teams.push( $( this ).val() );
66
+ }
67
+ );
68
 
69
+ var $past_teams = [];
70
+ $bulk_row.find( 'input[name="sp_past_team[]"]:checked' ).each(
71
+ function() {
72
+ $past_teams.push( $( this ).val() );
73
+ }
74
+ );
75
 
76
+ // save the data
77
+ $.ajax(
78
+ {
79
+ url: ajaxurl, // this is a variable that WordPress has already defined for us
80
+ type: 'POST',
81
+ async: false,
82
+ cache: false,
83
+ data: {
84
+ action: 'save_bulk_edit_sp_player',
85
+ post_ids: $post_ids,
86
+ current_teams: $current_teams,
87
+ past_teams: $past_teams,
88
+ nonce: $( "#sp_player_edit_nonce" ).val()
89
+ }
90
+ }
91
+ );
92
+ }
93
+ );
94
 
95
+ })( jQuery );
assets/js/admin/settings.js CHANGED
@@ -1,64 +1,92 @@
1
- jQuery(document).ready(function($){
 
2
 
3
- // Display custom sport name field as needed
4
- $("body.toplevel_page_sportspress #sportspress_sport").change(function() {
5
- $target = $("#sportspress_custom_sport_name");
6
- if ( $(this).val() == "custom" )
7
- $target.show();
8
- else
9
- $target.hide();
10
- });
 
 
 
11
 
12
- // Color picker
13
- $('.colorpick').iris( {
14
- change: function(event, ui){
15
- $(this).css( { backgroundColor: ui.color.toString() } );
16
- },
17
- hide: true,
18
- border: true
19
- } ).each( function() {
20
- $(this).css( { backgroundColor: $(this).val() } );
21
- })
22
- .click(function(){
23
- $('.iris-picker').hide();
24
- $(this).closest('.sp-color-box, td').find('.iris-picker').show();
25
- });
 
 
 
 
 
 
26
 
27
- $('body').click(function() {
28
- $('.iris-picker').hide();
29
- });
 
 
30
 
31
- $('.sp-color-box, .colorpick').click(function(event){
32
- event.stopPropagation();
33
- });
 
 
34
 
35
- // Chosen select
36
- $(".chosen-select").chosen({
37
- allow_single_deselect: true,
38
- single_backstroke_delete: false,
39
- placeholder_text_multiple: localized_strings.none
40
- });
 
 
41
 
42
- // Preset field modifier
43
- $(".sp-custom-input-wrapper .preset").click(function() {
44
- val = $(this).val();
45
- if(val == "\\c\\u\\s\\t\\o\\m") return true;
46
- example = $(this).attr("data-example");
47
- $(this).closest(".sp-custom-input-wrapper").find(".value").val(val).siblings(".example").html(example);
48
- });
 
 
 
 
49
 
50
- // Select custom preset when field is brought to focus
51
- $(".sp-custom-input-wrapper .value").focus(function() {
52
- $(this).siblings("label").find(".preset").prop("checked", true);
53
- });
 
 
54
 
55
- // Adjust example field when custom preset is entered
56
- $(".sp-custom-input-wrapper .value").on("keyup", function() {
57
- val = $(this).val();
58
- if ( val === undefined ) return true;
59
- format = $(this).attr("data-example-format");
60
- example = format.replace(/__val__/g, val);
61
- $(this).siblings(".example").html(example);
62
- });
 
 
 
 
 
63
 
64
- });
 
1
+ jQuery( document ).ready(
2
+ function($){
3
 
4
+ // Display custom sport name field as needed
5
+ $( "body.toplevel_page_sportspress #sportspress_sport" ).change(
6
+ function() {
7
+ $target = $( "#sportspress_custom_sport_name" );
8
+ if ( $( this ).val() == "custom" ) {
9
+ $target.show();
10
+ } else {
11
+ $target.hide();
12
+ }
13
+ }
14
+ );
15
 
16
+ // Color picker
17
+ $( '.colorpick' ).iris(
18
+ {
19
+ change: function(event, ui){
20
+ $( this ).css( { backgroundColor: ui.color.toString() } );
21
+ },
22
+ hide: true,
23
+ border: true
24
+ }
25
+ ).each(
26
+ function() {
27
+ $( this ).css( { backgroundColor: $( this ).val() } );
28
+ }
29
+ )
30
+ .click(
31
+ function(){
32
+ $( '.iris-picker' ).hide();
33
+ $( this ).closest( '.sp-color-box, td' ).find( '.iris-picker' ).show();
34
+ }
35
+ );
36
 
37
+ $( 'body' ).click(
38
+ function() {
39
+ $( '.iris-picker' ).hide();
40
+ }
41
+ );
42
 
43
+ $( '.sp-color-box, .colorpick' ).click(
44
+ function(event){
45
+ event.stopPropagation();
46
+ }
47
+ );
48
 
49
+ // Chosen select
50
+ $( ".chosen-select" ).chosen(
51
+ {
52
+ allow_single_deselect: true,
53
+ single_backstroke_delete: false,
54
+ placeholder_text_multiple: localized_strings.none
55
+ }
56
+ );
57
 
58
+ // Preset field modifier
59
+ $( ".sp-custom-input-wrapper .preset" ).click(
60
+ function() {
61
+ val = $( this ).val();
62
+ if (val == "\\c\\u\\s\\t\\o\\m") {
63
+ return true;
64
+ }
65
+ example = $( this ).attr( "data-example" );
66
+ $( this ).closest( ".sp-custom-input-wrapper" ).find( ".value" ).val( val ).siblings( ".example" ).html( example );
67
+ }
68
+ );
69
 
70
+ // Select custom preset when field is brought to focus
71
+ $( ".sp-custom-input-wrapper .value" ).focus(
72
+ function() {
73
+ $( this ).siblings( "label" ).find( ".preset" ).prop( "checked", true );
74
+ }
75
+ );
76
 
77
+ // Adjust example field when custom preset is entered
78
+ $( ".sp-custom-input-wrapper .value" ).on(
79
+ "keyup",
80
+ function() {
81
+ val = $( this ).val();
82
+ if ( val === undefined ) {
83
+ return true;
84
+ }
85
+ format = $( this ).attr( "data-example-format" );
86
+ example = format.replace( /__val__/g, val );
87
+ $( this ).siblings( ".example" ).html( example );
88
+ }
89
+ );
90
 
91
+ }
92
+ );
assets/js/admin/sp-geocoder.js CHANGED
@@ -1,54 +1,76 @@
1
- //Get variables form input values
2
- latitude = document.getElementById('term_meta[sp_latitude]').value;
3
- longitude = document.getElementById('term_meta[sp_longitude]').value;
4
-
5
- //Initialize the map and add the Search control box
6
- var map = L.map('sp-location-picker').setView([latitude, longitude], 15),
7
  geocoder = L.Control.Geocoder.nominatim(),
8
- control = L.Control.geocoder({
9
- geocoder: geocoder,
10
- collapsed: false,
11
- defaultMarkGeocode: false
12
- }).addTo(map),
13
- //Add a marker to use from the begining
14
- marker = L.marker([latitude, longitude],{draggable: true, autoPan: true}).addTo(map);
 
 
15
 
16
- L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
17
- attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
18
- }).addTo(map);
 
 
 
19
 
20
- //Pass the values to the fields after dragging
21
- marker.on('dragend', function (e) {
22
- document.getElementById('term_meta[sp_latitude]').value = marker.getLatLng().lat;
23
- document.getElementById('term_meta[sp_longitude]').value = marker.getLatLng().lng;
24
- geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
25
- var r = results[0];
26
- if (r) {
27
- document.getElementById('term_meta[sp_address]').value = r.name;
28
- }
29
- })
30
- });
 
 
 
 
 
 
 
31
 
32
- //After searching
33
- control.on('markgeocode', function(e) {
34
- var center = e.geocode.center;
35
- var address = e.geocode.name;
36
- map.setView([center.lat, center.lng], 15); //Center map to the new place
37
- map.removeLayer(marker); //Remove previous marker
38
- marker = L.marker([center.lat, center.lng],{draggable: true, autoPan: true}).addTo(map); //Add new marker to use
39
- //Pass the values to the fields after searching
40
- document.getElementById('term_meta[sp_latitude]').value = center.lat;
41
- document.getElementById('term_meta[sp_longitude]').value = center.lng;
42
- document.getElementById('term_meta[sp_address]').value = address;
43
- //Pass the values to the fields after dragging
44
- marker.on('dragend', function (e) {
45
- document.getElementById('term_meta[sp_latitude]').value = marker.getLatLng().lat;
46
- document.getElementById('term_meta[sp_longitude]').value = marker.getLatLng().lng;
47
- geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
48
- var r = results[0];
49
- if (r) {
50
- document.getElementById('term_meta[sp_address]').value = r.name;
 
 
 
 
 
 
 
 
 
 
51
  }
52
- })
53
- });
54
- }).addTo(map);
1
+ // Get variables form input values
2
+ latitude = document.getElementById( 'term_meta[sp_latitude]' ).value;
3
+ longitude = document.getElementById( 'term_meta[sp_longitude]' ).value;
4
+
5
+ // Initialize the map and add the Search control box
6
+ var map = L.map( 'sp-location-picker' ).setView( [latitude, longitude], 15 ),
7
  geocoder = L.Control.Geocoder.nominatim(),
8
+ control = L.Control.geocoder(
9
+ {
10
+ geocoder: geocoder,
11
+ collapsed: false,
12
+ defaultMarkGeocode: false
13
+ }
14
+ ).addTo( map ),
15
+ // Add a marker to use from the begining
16
+ marker = L.marker( [latitude, longitude],{draggable: true, autoPan: true} ).addTo( map );
17
 
18
+ L.tileLayer(
19
+ 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
20
+ {
21
+ attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
22
+ }
23
+ ).addTo( map );
24
 
25
+ // Pass the values to the fields after dragging
26
+ marker.on(
27
+ 'dragend',
28
+ function (e) {
29
+ document.getElementById( 'term_meta[sp_latitude]' ).value = marker.getLatLng().lat;
30
+ document.getElementById( 'term_meta[sp_longitude]' ).value = marker.getLatLng().lng;
31
+ geocoder.reverse(
32
+ marker.getLatLng(),
33
+ map.options.crs.scale( map.getZoom() ),
34
+ function(results) {
35
+ var r = results[0];
36
+ if (r) {
37
+ document.getElementById( 'term_meta[sp_address]' ).value = r.name;
38
+ }
39
+ }
40
+ )
41
+ }
42
+ );
43
 
44
+ // After searching
45
+ control.on(
46
+ 'markgeocode',
47
+ function(e) {
48
+ var center = e.geocode.center;
49
+ var address = e.geocode.name;
50
+ map.setView( [center.lat, center.lng], 15 ); // Center map to the new place
51
+ map.removeLayer( marker ); // Remove previous marker
52
+ marker = L.marker( [center.lat, center.lng],{draggable: true, autoPan: true} ).addTo( map ); // Add new marker to use
53
+ // Pass the values to the fields after searching
54
+ document.getElementById( 'term_meta[sp_latitude]' ).value = center.lat;
55
+ document.getElementById( 'term_meta[sp_longitude]' ).value = center.lng;
56
+ document.getElementById( 'term_meta[sp_address]' ).value = address;
57
+ // Pass the values to the fields after dragging
58
+ marker.on(
59
+ 'dragend',
60
+ function (e) {
61
+ document.getElementById( 'term_meta[sp_latitude]' ).value = marker.getLatLng().lat;
62
+ document.getElementById( 'term_meta[sp_longitude]' ).value = marker.getLatLng().lng;
63
+ geocoder.reverse(
64
+ marker.getLatLng(),
65
+ map.options.crs.scale( map.getZoom() ),
66
+ function(results) {
67
+ var r = results[0];
68
+ if (r) {
69
+ document.getElementById( 'term_meta[sp_address]' ).value = r.name;
70
+ }
71
+ }
72
+ )
73
  }
74
+ );
75
+ }
76
+ ).addTo( map );
assets/js/admin/sp-setup-geocoder.js CHANGED
@@ -1,54 +1,76 @@
1
- //Get variables form input values
2
- latitude = document.getElementById('sp_latitude').value;
3
- longitude = document.getElementById('sp_longitude').value;
4
-
5
- //Initialize the map and add the Search control box
6
- var map = L.map('sp-location-picker').setView([latitude, longitude], 15),
7
  geocoder = L.Control.Geocoder.nominatim(),
8
- control = L.Control.geocoder({
9
- geocoder: geocoder,
10
- collapsed: false,
11
- defaultMarkGeocode: false
12
- }).addTo(map),
13
- //Add a marker to use from the begining
14
- marker = L.marker([latitude, longitude],{draggable: true, autoPan: true}).addTo(map);
 
 
15
 
16
- L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
17
- attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
18
- }).addTo(map);
 
 
 
19
 
20
- //Pass the values to the fields after dragging
21
- marker.on('dragend', function (e) {
22
- document.getElementById('sp_latitude').value = marker.getLatLng().lat;
23
- document.getElementById('sp_longitude').value = marker.getLatLng().lng;
24
- geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
25
- var r = results[0];
26
- if (r) {
27
- document.getElementById('sp_address').value = r.name;
28
- }
29
- })
30
- });
 
 
 
 
 
 
 
31
 
32
- //After searching
33
- control.on('markgeocode', function(e) {
34
- var center = e.geocode.center;
35
- var address = e.geocode.name;
36
- map.setView([center.lat, center.lng], 15); //Center map to the new place
37
- map.removeLayer(marker); //Remove previous marker
38
- marker = L.marker([center.lat, center.lng],{draggable: true, autoPan: true}).addTo(map); //Add new marker to use
39
- //Pass the values to the fields after searching
40
- document.getElementById('sp_latitude').value = center.lat;
41
- document.getElementById('sp_longitude').value = center.lng;
42
- document.getElementById('sp_address').value = address;
43
- //Pass the values to the fields after dragging
44
- marker.on('dragend', function (e) {
45
- document.getElementById('sp_latitude').value = marker.getLatLng().lat;
46
- document.getElementById('sp_longitude').value = marker.getLatLng().lng;
47
- geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
48
- var r = results[0];
49
- if (r) {
50
- document.getElementById('sp_address').value = r.name;
 
 
 
 
 
 
 
 
 
 
51
  }
52
- })
53
- });
54
- }).addTo(map);
1
+ // Get variables form input values
2
+ latitude = document.getElementById( 'sp_latitude' ).value;
3
+ longitude = document.getElementById( 'sp_longitude' ).value;
4
+
5
+ // Initialize the map and add the Search control box
6
+ var map = L.map( 'sp-location-picker' ).setView( [latitude, longitude], 15 ),
7
  geocoder = L.Control.Geocoder.nominatim(),
8
+ control = L.Control.geocoder(
9
+ {
10
+ geocoder: geocoder,
11
+ collapsed: false,
12
+ defaultMarkGeocode: false
13
+ }
14
+ ).addTo( map ),
15
+ // Add a marker to use from the begining
16
+ marker = L.marker( [latitude, longitude],{draggable: true, autoPan: true} ).addTo( map );
17
 
18
+ L.tileLayer(
19
+ 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
20
+ {
21
+ attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
22
+ }
23
+ ).addTo( map );
24
 
25
+ // Pass the values to the fields after dragging
26
+ marker.on(
27
+ 'dragend',
28
+ function (e) {
29
+ document.getElementById( 'sp_latitude' ).value = marker.getLatLng().lat;
30
+ document.getElementById( 'sp_longitude' ).value = marker.getLatLng().lng;
31
+ geocoder.reverse(
32
+ marker.getLatLng(),
33
+ map.options.crs.scale( map.getZoom() ),
34
+ function(results) {
35
+ var r = results[0];
36
+ if (r) {
37
+ document.getElementById( 'sp_address' ).value = r.name;
38
+ }
39
+ }
40
+ )
41
+ }
42
+ );
43
 
44
+ // After searching
45
+ control.on(
46
+ 'markgeocode',
47
+ function(e) {
48
+ var center = e.geocode.center;
49
+ var address = e.geocode.name;
50
+ map.setView( [center.lat, center.lng], 15 ); // Center map to the new place
51
+ map.removeLayer( marker ); // Remove previous marker
52
+ marker = L.marker( [center.lat, center.lng],{draggable: true, autoPan: true} ).addTo( map ); // Add new marker to use
53
+ // Pass the values to the fields after searching
54
+ document.getElementById( 'sp_latitude' ).value = center.lat;
55
+ document.getElementById( 'sp_longitude' ).value = center.lng;
56
+ document.getElementById( 'sp_address' ).value = address;
57
+ // Pass the values to the fields after dragging
58
+ marker.on(
59
+ 'dragend',
60
+ function (e) {
61
+ document.getElementById( 'sp_latitude' ).value = marker.getLatLng().lat;
62
+ document.getElementById( 'sp_longitude' ).value = marker.getLatLng().lng;
63
+ geocoder.reverse(
64
+ marker.getLatLng(),
65
+ map.options.crs.scale( map.getZoom() ),
66
+ function(results) {
67
+ var r = results[0];
68
+ if (r) {
69
+ document.getElementById( 'sp_address' ).value = r.name;
70
+ }
71
+ }
72
+ )
73
  }
74
+ );
75
+ }
76
+ ).addTo( map );
assets/js/admin/sportspress-admin.js CHANGED
@@ -1,892 +1,1187 @@
1
- jQuery(document).ready(function($){
2
-
3
- // Tiptip
4
- $(".sp-tip").tipTip({
5
- delay: 200,
6
- fadeIn: 100,
7
- fadeOut: 100
8
- });
9
- $(".sp-desc-tip").tipTip({
10
- delay: 200,
11
- fadeIn: 100,
12
- fadeOut: 100,
13
- defaultPosition: 'right'
14
- });
15
-
16
- // Chosen select
17
- $(document).on("postbox-toggled", function() {
18
- $(".chosen-select").filter(":visible").chosen({
19
- allow_single_deselect: true,
20
- search_contains: true,
21
- single_backstroke_delete: false,
22
- disable_search_threshold: 10,
23
- placeholder_text_multiple: localized_strings.none
24
- });
25
- }).trigger("postbox-toggled");
26
-
27
-
28
- // Auto key placeholder
29
- $("#poststuff #title").on("keyup", function() {
30
- val = $(this).val()
31
- lc = val.replace(/[^a-z]/gi,"").toLowerCase();
32
- $("#sp_key").attr("placeholder", lc);
33
- $("#sp_default_key").val(lc);
34
- $("#sp_singular").attr("placeholder", val);
35
- });
36
-
37
- // Activate auto key placeholder
38
- $("#poststuff #title").keyup();
39
-
40
- // Radio input toggle
41
- $(".sp-radio-toggle").click(function() {
42
- if($(this).data("sp-checked")) {
43
- $(this).attr("checked", false );
44
- $(this).data("sp-checked", false );
45
- } else {
46
- $(this).data("sp-checked", true );
47
- }
48
- });
49
-
50
- // Table switcher
51
- $(".sp-table-panel").siblings(".sp-table-bar").find("a").click(function() {
52
- $(this).closest("li").find("a").addClass("current").closest("li").siblings().find("a").removeClass("current").closest(".sp-table-bar").siblings($(this).attr("href")).show().siblings(".sp-table-panel").hide();
53
- return false;
54
- });
55
-
56
- // Tab switcher
57
- $(".sp-tab-panel").siblings(".sp-tab-bar").find("a").click(function() {
58
- $(this).closest("li").addClass("tabs").siblings().removeClass("tabs").closest(".sp-tab-bar").siblings($(this).attr("href")).show().trigger('checkCheck').siblings(".sp-tab-panel").hide();
59
- return false;
60
- });
61
-
62
- // Tab filter
63
- $(".sp-tab-filter-panel").siblings(".sp-tab-select").find("select").change(function() {
64
- var val = $(this).val();
65
- var filter = ".sp-filter-"+val;
66
- var $filters = $(this).closest(".sp-tab-select").siblings(".sp-tab-select");
67
- if($filters.length) {
68
- $filters.each(function() {
69
- filterval = $(this).find("select").val();
70
- if(filterval !== undefined)
71
- filter += ".sp-filter-"+filterval;
72
- });
73
- }
74
- $panel = $(this).closest(".sp-tab-select").siblings(".sp-tab-panel");
75
- $panel.each(function() {
76
- $(this).find(".sp-post").hide(0, function() {
77
- $(this).find("input").prop("disabled", true);
78
- $(this).filter(filter).show(0, function() {
79
- $(this).find("input").prop("disabled", false);
80
- });
81
- });
82
- if($(this).find(".sp-post:visible").length > 0) {
83
- $(this).find(".sp-select-all-container").show();
84
- $(this).find(".sp-show-all-container").show();
85
- $(this).find(".sp-not-found-container").hide();
86
- } else {
87
- $(this).find(".sp-select-all-container").hide();
88
- $(this).find(".sp-show-all-container").hide();
89
- $(this).find(".sp-not-found-container").show();
90
- }
91
- });
92
- });
93
-
94
- // Trigger tab filter
95
- $(".sp-tab-filter-panel").siblings(".sp-tab-select").find("select").change();
96
-
97
- // Dropdown filter
98
- $(".sp-dropdown-target").siblings(".sp-dropdown-filter").find("select").change(function() {
99
- var val = $(this).val();
100
- var filter = ".sp-filter-"+val;
101
- var $filters = $(this).closest(".sp-dropdown-filter").siblings(".sp-dropdown-filter");
102
- if($filters.length) {
103
- $filters.each(function() {
104
- filterval = $(this).find("select").val();
105
- if(filterval !== undefined)
106
- filter += ".sp-filter-"+filterval;
107
- });
108
- }
109
- $target = $(this).closest(".sp-dropdown-filter").siblings(".sp-dropdown-target").find("select");
110
- $target.find(".sp-post").prop("disabled", true).each(function() {
111
- $(this).filter(filter).prop("disabled", false);
112
- });
113
- });
114
-
115
- // Trigger dropdown filter
116
- $(".sp-dropdown-target").siblings(".sp-dropdown-filter").find("select").change();
117
-
118
- // Filter show all action links
119
- $(".sp-tab-panel").find(".sp-post input:checked").each(function() {
120
- $(this).prop("disabled", false).closest("li").show().siblings(".sp-not-found-container").hide().siblings(".sp-show-all-container").show();
121
- });
122
-
123
- // Show all filter
124
- $(".sp-tab-panel").on("click", ".sp-show-all", function() {
125
- $(this).closest("li").hide().siblings(".sp-post, .sp-select-all-container").show().find("input").prop("disabled", false);
126
- });
127
-
128
- // Self-cloning
129
- $(".sp-clone:last").find("select").change(function() {
130
- $(this).closest(".sp-clone").siblings().find("select").change(function() {
131
- if($(this).val() == "0") $(this).closest(".sp-clone").remove();
132
- }).find("option:first").text(localized_strings.remove_text);
133
- if($(this).val() != "0") {
134
- $original = $(this).closest(".sp-clone");
135
- $original.before($original.clone().find("select").attr("name", $original.attr("data-clone-name") + "[]").val($(this).val()).closest(".sp-clone")).attr("data-clone-num", parseInt($original.attr("data-clone-num")) + 1).find("select").val("0").change();
136
- }
137
- });
138
-
139
- // Activate self-cloning
140
- $(".sp-clone:last").find("select").change();
141
-
142
- // Custom value editor
143
- $(".sp-data-table .sp-default-value").click(function() {
144
- $(this).hide().siblings(".sp-custom-value").show().find(".sp-custom-value-input").focus();
145
- });
146
-
147
- // Define custom value editor saving
148
- $(".sp-data-table .sp-custom-value .sp-custom-value-input").on("saveInput", function() {
149
- $val = $(this).val();
150
- if($val == "") $val = $(this).attr("placeholder");
151
- $(this).closest(".sp-custom-value").hide().siblings(".sp-default-value").show().find(".sp-default-value-input").html($val);
152
- });
153
-
154
- // Define custom value editor cancellation
155
- $(".sp-data-table .sp-custom-value .sp-custom-value-input").on("cancelInput", function() {
156
- $val = $(this).closest(".sp-custom-value").siblings(".sp-default-value").find(".sp-default-value-input").html();
157
- if($val == $(this).attr("placeholder")) $(this).val("");
158
- else $(this).val($val);
159
- $(this).closest(".sp-custom-value").hide().siblings(".sp-default-value").show();
160
- });
161
-
162
- // Custom value editor save
163
- $(".sp-data-table .sp-custom-value .sp-save").click(function() {
164
- $(this).siblings(".sp-custom-value-input").trigger("saveInput");
165
- });
166
-
167
- // Custom value editor cancel
168
- $(".sp-data-table .sp-custom-value .sp-cancel").click(function() {
169
- $(this).siblings(".sp-custom-value-input").trigger("cancelInput");
170
- });
171
-
172
- // Prevent custom value editor input from submitting form
173
- $(".sp-data-table .sp-custom-value .sp-custom-value-input").keypress(function(event) {
174
- if(event.keyCode == 13){
175
- event.preventDefault();
176
- $(this).trigger("saveInput");
177
- return false;
178
- }
179
- });
180
-
181
- // Cancel custom value editor form on escape
182
- $(".sp-data-table .sp-custom-value .sp-custom-value-input").keyup(function(event) {
183
- if(event.keyCode == 27){
184
- event.preventDefault();
185
- $(this).trigger("cancelInput");
186
- return false;
187
- }
188
- });
189
-
190
- // Data table adjustments
191
- $(".sp-table-adjustments input").change(function() {
192
- matrix = $(this).attr("data-matrix");
193
- $el = $(this).closest(".sp-table-adjustments").siblings(".sp-table-values").find("input[data-matrix="+matrix+"]");
194
- placeholder = $el.attr("data-placeholder");
195
- current_adjustment = parseFloat($el.attr("data-adjustment"));
196
- adjustment = parseFloat($(this).val());
197
- if(! isNaN(adjustment) && adjustment != 0) {
198
- placeholder = parseFloat(placeholder);
199
- if(isNaN(placeholder)) placeholder = 0;
200
- if(isNaN(current_adjustment)) current_adjustment = 0;
201
- placeholder += adjustment - current_adjustment;
202
- }
203
- $el.attr("placeholder", placeholder);
204
- }).change();
205
-
206
- // Data table keyboard navigation
207
- $(".sp-data-table tbody tr td input:text").keydown(function(event) {
208
- if(! $(this).parent().hasClass("chosen-search") && [37,38,39,40].indexOf(event.keyCode) > -1){
209
- $el = $(this).closest("td");
210
- var col = $el.parent().children().index($el)+1;
211
- var row = $el.parent().parent().children().index($el.parent())+1;
212
- if(event.keyCode == 37){
213
- if ( $(this).caret().start != 0 )
214
- return true;
215
- col -= 1;
216
  }
217
- if(event.keyCode == 38){
218
- row -= 1;
 
 
 
 
 
219
  }
220
- if(event.keyCode == 39){
221
- if ( $(this).caret().start != $(this).val().length )
222
- return true;
223
- col += 1;
 
 
 
 
 
 
 
 
 
 
 
224
  }
225
- if(event.keyCode == 40){
226
- row += 1;
 
 
 
 
 
 
 
 
 
227
  }
228
- $el.closest("tbody").find("tr:nth-child("+row+") td:nth-child("+col+") input:text").first().focus();
229
- }
230
- });
231
-
232
- // Prevent data table from submitting form
233
- $(".sp-data-table tbody tr td input:text").keypress(function(event) {
234
- if(! $(this).parent().hasClass("chosen-search") && event.keyCode == 13){
235
- event.preventDefault();
236
- $el = $(this).closest("td");
237
- var col = $el.parent().children().index($el)+1;
238
- var row = $el.parent().parent().children().index($el.parent())+2;
239
- $el.closest("tbody").find("tr:nth-child("+row+") td:nth-child("+col+") input:text").focus();
240
- return false;
241
- }
242
- });
243
-
244
- // Total stats calculator
245
- $(".sp-data-table .sp-total input[data-sp-format=number][data-sp-total-type!=average]").on("updateTotal", function() {
246
- index = $(this).parent().index();
247
- var sum = 0;
248
- $(this).closest(".sp-data-table").find(".sp-post").each(function() {
249
- val = $(this).find("td").eq(index).find("input").val();
250
- if(val == "") {
251
- val = $(this).find("td").eq(index).find("input").attr("placeholder");
252
- }
253
- if($.isNumeric(val)) {
254
- sum += parseFloat(val, 10);
255
- }
256
- });
257
- $(this).attr("placeholder", sum);
258
- });
259
-
260
- // Activate total stats calculator
261
- if($(".sp-data-table .sp-total").length) {
262
- $(".sp-data-table .sp-post td input").on("keyup", function() {
263
- $(this).closest(".sp-data-table").find(".sp-total td").eq($(this).parent().index()).find("input[data-sp-format=number][data-sp-total-type!=average]").trigger("updateTotal");
264
- });
265
- }
266
 
267
- // Trigger total stats calculator
268
- $(".sp-data-table .sp-total input[data-sp-format=number][data-sp-total-type!=average]").trigger("updateTotal");
269
 
270
- // Sync inputs
271
- $(".sp-sync-input").on("keyup", function() {
272
- name = $(this).attr("name");
273
- $el = $("input[name='"+name+"']");
274
- if ( $el.length > 1 ) {
275
- val = $(this).val();
276
- $el.val(val);
277
- }
278
- });
279
-
280
- // Sync selects
281
- $(".sp-sync-select").on("change", function() {
282
- name = $(this).attr("name");
283
- $el = $("select[name='"+name+"']")
284
- if ( $el.length > 1 ) {
285
- val = $(this).val();
286
- $el.val(val);
287
- }
288
- });
289
-
290
- // Select all checkboxes
291
- $(".sp-select-all-range").on("change", ".sp-select-all", function() {
292
- $range = $(this).closest(".sp-select-all-range");
293
- $range.find("input[type=checkbox]").prop("checked", $(this).prop("checked"));
294
- });
295
-
296
- // Check if all checkboxes are checked already
297
- $(".sp-select-all-range").on("checkCheck", function() {
298
- $(this).each(function() {
299
- $(this).find(".sp-select-all").prop("checked", $(this).find("input[type=checkbox]:checked:not(.sp-select-all)").length != 0 && $(this).find("input[type=checkbox]:checked:not(.sp-select-all)").length == $(this).find("input[type=checkbox]:visible:not(.sp-select-all)").length);
300
- });
301
- });
302
-
303
- // Activate check check when a checkbox is checked
304
- $(".sp-select-all-range input[type=checkbox]:not(.sp-select-all)").change(function() {
305
- $(this).closest(".sp-select-all-range").trigger("checkCheck");
306
- });
307
-
308
- // Activate check check on page load
309
- $(".sp-select-all-range").trigger("checkCheck");
310
-
311
- // Trigger check check
312
- $(".sp-data-table").trigger("checkCheck");
313
-
314
- // Sortable tables
315
- $(".sp-sortable-table tbody").sortable({
316
- handle: ".icon",
317
- axis: "y"
318
- });
319
-
320
- // Sortable lists
321
- $( ".sp-sortable-list" ).sortable({
322
- handle: ".sp-item-handle",
323
- placeholder: "sp-item-placeholder",
324
- connectWith: ".sp-connected-list"
325
- });
326
-
327
- // Autosave
328
- $(".sp-autosave").change(function() {
329
- $(this).attr("readonly", true).closest("form").submit();
330
- });
331
-
332
- // Video embed
333
- $(".sp-add-video").click(function() {
334
- $(this).closest("fieldset").hide().siblings(".sp-video-field").show();
335
- return false;
336
- });
337
-
338
- // Removing video embed
339
- $(".sp-remove-video").click(function() {
340
- $(this).closest("fieldset").hide().siblings(".sp-video-adder").show().siblings(".sp-video-field").find("input").val(null);
341
- return false;
342
- });
343
-
344
- // Equation selector
345
- $(".sp-equation-selector select:last").change(function() {
346
- $(this).siblings().change(function() {
347
- if($(this).val() == "") $(this).remove();
348
- }).find("option:first").text(localized_strings.remove_text);
349
- if($(this).val() != "") {
350
- $(this).before($(this).clone().val($(this).val())).val("").change();
351
- }
352
- });
353
 
354
- // Trigger equation selector
355
- $(".sp-equation-selector select:last").change().siblings().change();
 
 
 
 
 
356
 
357
- // Order selector
358
- $(".sp-order-selector select:first").change(function() {
359
- if($(this).val() == "0") {
360
- $(this).siblings().prop( "disabled", true );
361
- } else {
362
- $(this).siblings().prop( "disabled", false )
363
- }
364
- });
365
-
366
- // Trigger order selector
367
- $(".sp-order-selector select:first").change();
368
-
369
- // Format selector
370
- $(".sp-format-selector select:first").change(function() {
371
-
372
- $precisiondiv = $("#sp_precisiondiv");
373
- $precisioninput = $("#sp_precision");
374
- $timeddiv = $("#sp_timeddiv");
375
- $equationdiv = $("#sp_equationdiv");
376
-
377
- // Equation settings
378
- if ($(this).val() == "equation") {
379
- $equationdiv.show();
380
- $precisiondiv.show();
381
- $timeddiv.hide();
382
- $precisioninput.prop( "disabled", false );
383
- } else if ($(this).val() == "number") {
384
- $equationdiv.hide();
385
- $precisiondiv.hide();
386
- $timeddiv.show();
387
- $precisioninput.prop( "disabled", true );
388
- } else {
389
- $equationdiv.hide();
390
- $precisiondiv.hide();
391
- $timeddiv.hide();
392
- $precisioninput.prop( "disabled", true );
393
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
 
395
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
 
397
- // Trigger format selector
398
- $(".sp-format-selector select:first").change();
399
 
400
- // Team era selector
401
- $(".sp-team-era-selector select:first-child").change(function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
402
 
403
- $subselector = $(this).siblings();
 
 
 
 
 
404
 
405
- // Sub settings
406
- if($(this).val() == 0) {
407
- $subselector.hide();
408
- } else {
409
- $subselector.show();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  }
411
 
412
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
 
414
- // Trigger team era selector
415
- $(".sp-team-era-selector select:first-child").change();
416
 
417
- // Status selector
418
- $(".sp-status-selector select:first-child").change(function() {
419
 
420
- $subselector = $(this).siblings();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
 
422
- // Sub settings
423
- if($(this).val() == "sub") {
424
- $subselector.show();
425
- } else {
426
- $subselector.hide();
427
- }
428
 
429
- });
430
-
431
- // Trigger status selector
432
- $(".sp-status-selector select:first-child").change();
433
-
434
- // Preset field modifier
435
- $(".sp-custom-input-wrapper .preset").click(function() {
436
- val = $(this).val();
437
- if(val == "\\c\\u\\s\\t\\o\\m") return true;
438
- example = $(this).attr("data-example");
439
- $(this).closest(".sp-custom-input-wrapper").find(".value").val(val).siblings(".example").html(example);
440
- });
441
-
442
- // Select custom preset when field is brought to focus
443
- $(".sp-custom-input-wrapper .value").focus(function() {
444
- $(this).siblings("label").find(".preset").prop("checked", true);
445
- });
446
-
447
- // Adjust example field when custom preset is entered
448
- $(".sp-custom-input-wrapper .value").on("keyup", function() {
449
- val = $(this).val();
450
- if ( val === undefined ) return true;
451
- format = $(this).attr("data-example-format");
452
- example = format.replace("__val__", val);
453
- $(this).siblings(".example").html(example);
454
- });
455
-
456
- // Prevent address input from submitting form
457
- $(".sp-address").keypress(function(event) {
458
- return event.keyCode != 13;
459
- });
460
-
461
- // Dashboard countdown
462
- $("#sportspress_dashboard_status .sp_status_list li.countdown").each(function() {
463
- var $this = $(this);
464
- // Get countdown time
465
- var countDownDate = new Date($(this).data('countdown')).getTime();
466
- // Iterate every second
467
- var x = setInterval(function() {
468
-
469
- // Get todays date and time
470
- var now = new Date();
471
-
472
- // Convert curent date and time to UTC
473
- var tzDifference = now.getTimezoneOffset();
474
- var nowutc = new Date(now.getTime() + tzDifference * 60 * 1000);
475
-
476
- // Find the distance between now and the count down date
477
- var distance = countDownDate - nowutc;
478
- if ( distance < 0 ) {
479
- distance = 0;
480
- }
481
-
482
- // Time calculations for days, hours, minutes and seconds
483
- var days = Math.floor(distance / (1000 * 60 * 60 * 24));
484
- var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
485
- var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
486
- var seconds = Math.floor((distance % (1000 * 60)) / 1000);
487
-
488
- // Output the result
489
- $this.find('strong').html(days+" "+localized_strings.days+" "+('0' + hours).slice(-2)+":"+('0' + minutes).slice(-2)+":"+('0' + seconds).slice(-2));
490
- }, 1000);
491
- });
492
-
493
- // Event format affects data
494
- $(".post-type-sp_event #post-formats-select").change(function() {
495
- layout = $(".post-type-sp_event #post-formats-select input:checked").val();
496
- if ( layout == "friendly" ) {
497
- $(".sp_event-sp_league-field").hide().find("select").prop("disabled", true);
498
- $(".sp_event-sp_season-field").hide().find("select").prop("disabled", true);
499
- } else {
500
- $(".sp_event-sp_league-field").show().find("select").prop("disabled", false);
501
- $(".sp_event-sp_season-field").show().find("select").prop("disabled", false);
502
- }
503
- });
504
-
505
- // Trigger event format change
506
- $(".post-type-sp_event #post-formats-select").trigger("change");
507
-
508
- // Calendar layout affects data
509
- $(".post-type-sp_calendar #post-formats-select").change(function() {
510
- layout = $(".post-type-sp_calendar #post-formats-select input:checked").val();
511
- $(".sp-calendar-table tr").each(function() {
512
- if ( layout == "list" ) {
513
- $(this).find("th input[type=checkbox]").show();
514
- $(this).find("th select").prop("disabled", false);
515
- } else {
516
- $(this).find("th input[type=checkbox]").hide();
517
- $(this).find("th select").prop('selectedIndex', 0).prop("disabled", true);
518
- }
519
- });
520
- });
521
-
522
- // Trigger calendar layout change
523
- $(".post-type-sp_calendar #post-formats-select").trigger("change");
524
-
525
- // Player list layout affects data
526
- $(".post-type-sp_list #post-formats-select").change(function() {
527
- layout = $(".post-type-sp_list #post-formats-select input:checked").val();
528
- $(".sp-player-list-table tr").each(function() {
529
- if ( layout == "list" ) {
530
- $(this).find("th input[type=checkbox]").show();
531
- } else {
532
- $(this).find("th input[type=checkbox]").hide();
533
- }
534
- });
535
- });
536
-
537
- // Trigger player list layout change
538
- $(".post-type-sp_list #post-formats-select").trigger("change");
539
-
540
- // Configure primary result option (Ajax)
541
- $(".sp-admin-config-table").on("click", ".sp-primary-result-option", function() {
542
- $.post( ajaxurl, {
543
- action: "sp-save-primary-result",
544
- primary_result: $(this).val(),
545
- nonce: $("#sp-primary-result-nonce").val()
546
- });
547
- });
548
-
549
- // Configure primary performance option (Ajax)
550
- $(".sp-admin-config-table").on("click", ".sp-primary-performance-option", function() {
551
- $.post( ajaxurl, {
552
- action: "sp-save-primary-performance",
553
- primary_performance: $(this).val(),
554
- nonce: $("#sp-primary-performance-nonce").val()
555
- });
556
- });
557
-
558
- // Update importer post count
559
- $(".sp-import-table").on("updatePostCount", function() {
560
- $(".sp-post-count").text(localized_strings.displaying_posts.replace("%s", 1).replace(/%s/g, count = $(this).find("tbody tr").length));
561
- });
562
-
563
- // Delete importer row
564
- $(".sp-import-table").on("click", ".sp-delete-row", function() {
565
- $self = $(this);
566
- $self.closest("tr").css("background-color", "#f99").fadeOut(400, function() {
567
- $table = $self.closest(".sp-import-table");
568
- $(this).remove();
569
- $table.trigger("updatePostCount");
570
- });
571
- return false;
572
- });
573
-
574
- // Add importer row
575
- $(".sp-import-table").on("click", ".sp-add-row", function() {
576
- $self = $(this);
577
- $table = $self.closest(".sp-import-table");
578
- if ( $self.hasClass("sp-add-first") ) {
579
- $tr = $table.find("tbody tr:first-child");
580
- $row = $tr.clone();
581
- $row.insertBefore($tr).find("input").val("");
582
- } else {
583
- $tr = $self.closest("tr");
584
- $row = $tr.clone();
585
- $tr.find("input").val("");
586
- $row.insertBefore($tr);
587
- }
588
- $table.trigger("updatePostCount");
589
- return false;
590
- });
591
-
592
- // Enable or disable importer inputs based on column label
593
- $(".sp-import-table").on("change", "select", function() {
594
- $self = $(this);
595
- $table = $self.closest(".sp-import-table");
596
- index = parseInt($self.data("index"));
597
- if ( $self.val() == 0 ) {
598
- $table.find("tbody tr td:nth-child("+parseInt(index+1)+") input").prop("disabled", true);
599
- } else {
600
- $table.find("tbody tr td:nth-child("+parseInt(index+1)+") input").prop("disabled", false);
601
- $self.closest("th").siblings().find("select").each(function() {
602
- if ( $(this).val() == $self.val() ) $(this).val("0").trigger("change");
603
- });
604
- }
605
- });
606
-
607
- // Datepicker
608
- $(".sp-datepicker").datepicker({
609
- dateFormat : "yy-mm-dd"
610
- });
611
- $(".sp-datepicker-from").datepicker({
612
- dateFormat : "yy-mm-dd",
613
- onClose: function( selectedDate ) {
614
- $(this).closest(".sp-date-selector").find(".sp-datepicker-to").datepicker("option", "minDate", selectedDate);
615
- }
616
- });
617
- $(".sp-datepicker-to").datepicker({
618
- dateFormat : "yy-mm-dd",
619
- onClose: function( selectedDate ) {
620
- $(this).closest(".sp-date-selector").find(".sp-datepicker-from").datepicker("option", "maxDate", selectedDate);
621
- }
622
- });
623
-
624
- // Show or hide datepicker
625
- $(".sp-date-selector select").change(function() {
626
- if ( $(this).val() == "range" ) {
627
- $(this).closest(".sp-date-selector").find(".sp-date-range").show();
628
- } else {
629
- $(this).closest(".sp-date-selector").find(".sp-date-range").hide();
630
- }
631
- });
632
- $(".sp-date-selector select").trigger("change");
633
-
634
- // Toggle date range selectors
635
- $(".sp-date-relative input").change(function() {
636
- $relative = $(this).closest(".sp-date-relative").siblings(".sp-date-range-relative").toggle(0, $(this).attr("checked"));
637
- $absolute = $(this).closest(".sp-date-relative").siblings(".sp-date-range-absolute").toggle(0, $(this).attr("checked"));
638
-
639
- if ($(this).attr("checked")) {
640
- $relative.show();
641
- $absolute.hide();
642
- } else {
643
- $absolute.show();
644
- $relative.hide();
645
- }
646
- });
647
- $(".sp-date-selector input").trigger("change");
648
-
649
- // Apply color scheme
650
- $(".sp-color-option").on("click", function() {
651
- colors = $(this).find("label").data("sp-colors").split(",");
652
- $(".sp-custom-colors").find(".sp-color-box").each(function(index) {
653
- $(this).find("input").val("#"+colors[index]).css("background-color", "#"+colors[index]);
654
- });;
655
- });
656
-
657
- // Edit inline results
658
- $("#the-list").on("click, focus", ".sp-result, .sp-edit-results", function(){
659
- team = $(this).data("team");
660
- $column = $(this).closest(".column-sp_team");
661
- $column.find(".sp-result, .sp-row-actions").hide();
662
- $column.find(".sp-edit-result, .sp-inline-edit-save").show();
663
- if ( team != undefined ) {
664
- $column.find(".sp-edit-result[data-team='"+team+"']").select();
665
- }
666
- return false;
667
- });
668
-
669
- // Cancel inline results
670
- $("#the-list").on("click", ".sp-inline-edit-save .cancel", function(){
671
- $column = $(this).closest(".column-sp_team");
672
- $column.find(".sp-edit-result, .sp-inline-edit-save").hide();
673
- $column.find(".sp-result, .sp-row-actions").show();
674
- return false;
675
- });
676
-
677
- // Save inline results
678
- $("#the-list").on("click", ".sp-inline-edit-save .save", function(){
679
- $column = $(this).closest(".column-sp_team");
680
- results = {};
681
- $column.find(".sp-edit-result").each(function() {
682
- id = $(this).data("team");
683
- result = $(this).val();
684
- results[id] = result;
685
- });
686
- $.post( ajaxurl, {
687
- action: "sp-save-inline-results",
688
- post_id: $column.find("input[name='sp_post_id']").val(),
689
- results: results,
690
- nonce: $("#sp-inline-nonce").val()
691
- }, function(response) {
692
- $column.find(".sp-edit-result").each(function() {
693
- val = $(this).val();
694
- $column.find(".sp-result[data-team='"+$(this).data("team")+"']").html(val==''?'-':val);
695
- });
696
- $column.find(".sp-edit-result, .sp-inline-edit-save").hide();
697
- $column.find(".sp-result, .sp-row-actions").show();
698
- return false;
699
- });
700
- });
701
-
702
- // Override inline form submission
703
- $("#the-list").on("keypress", ".sp-edit-result", function(e) {
704
- if ( e.which == 13 ) {
705
- $(this).closest(".column-sp_team").find(".sp-inline-edit-save .save").trigger("click");
706
- return false;
707
- }
708
- });
709
-
710
- // Fitvids
711
- $(".sp-fitvids").fitVids();
712
-
713
- // Display configure sport button
714
- $(".sp-select-sport").change(function() {
715
- $(".sp-configure-sport").hide();
716
- });
717
-
718
- // Ajax checklist
719
- $(".sp-ajax-checklist").siblings(".sp-tab-select").find("select").change(function() {
720
- $(this).closest(".sp-tab-select").siblings(".sp-ajax-checklist").find("ul").html("<li>" + localized_strings.loading + "</li>");
721
- $.post( ajaxurl, {
722
- action: "sp-get-players",
723
- team: $(this).val(),
724
- league: ('yes' == localized_strings.option_filter_by_league) ? $("select[name=\"tax_input[sp_league][]\"]").val() : null,
725
- season: ('yes' == localized_strings.option_filter_by_season) ? $("select[name=\"tax_input[sp_season][]\"]").val() : null,
726
- index: $(this).closest(".sp-instance").index(),
727
- nonce: $("#sp-get-players-nonce").val()
728
- }).done(function( response ) {
729
- index = response.data.index;
730
- $target = $(".sp-instance").eq(index).find(".sp-ajax-checklist ul");
731
- if ( response.success ) {
732
- $target.html("");
733
- i = 0;
734
- if(-1 == response.data.sections) {
735
- if(response.data.players.length) {
736
- $target.eq(0).append("<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>");
737
- $(response.data.players).each(function( key, value ) {
738
- $target.eq(0).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_player[" + index + "][]\">" + value.post_title + "</li>");
739
- });
740
- $target.eq(0).append("<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_players\">" + localized_strings.show_all + "</a></li>");
741
- } else {
742
- $target.eq(0).html("<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_players\">" + localized_strings.show_all + "</a></li>");
743
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
744
  } else {
745
- if ( 1 == response.data.sections ) {
746
- defense = i;
747
- offense = i+1;
748
- } else {
749
- offense = i;
750
- defense = i+1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
751
  }
752
- if(response.data.players.length) {
753
- $target.eq(offense).append("<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>");
754
- $target.eq(defense).append("<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>");
755
- $(response.data.players).each(function( key, value ) {
756
- $target.eq(offense).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_offense[" + index + "][]\">" + value.post_title + "</li>");
757
- $target.eq(defense).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_defense[" + index + "][]\">" + value.post_title + "</li>");
758
- });
759
- $target.eq(offense).append("<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_offense\">" + localized_strings.show_all + "</a></li>");
760
- $target.eq(defense).append("<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_defense\">" + localized_strings.show_all + "</a></li>");
761
- } else {
762
- $target.eq(offense).html("<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_offense\">" + localized_strings.show_all + "</a></li>");
763
- $target.eq(defense).html("<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_defense\">" + localized_strings.show_all + "</a></li>");
 
 
 
 
 
 
764
  }
765
- i++;
766
- }
767
- i++;
768
- if(response.data.staff.length) {
769
- $target.eq(i).append("<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>");
770
- $(response.data.staff).each(function( key, value ) {
771
- $target.eq(i).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_staff[" + index + "][]\">" + value.post_title + "</li>");
772
- });
773
- $target.eq(i).append("<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_staffs\">" + localized_strings.show_all + "</a></li>");
774
- } else {
775
- $target.eq(i).html("<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_staffs\">" + localized_strings.show_all + "</a></li>");
776
- }
777
- } else {
778
- $target.html("<li>" + localized_strings.no_results_found + "</li>");
779
- }
780
- });
781
- });
782
-
783
- // Activate Ajax trigger
784
- $(".sp-ajax-trigger").change(function() {
785
- $(".sp-ajax-checklist").siblings(".sp-tab-select").find("select").change();
786
- });
787
-
788
- // Ajax show all filter
789
- $(".sp-tab-panel").on("click", ".sp-ajax-show-all", function() {
790
- index = $(this).closest(".sp-instance").index();
791
- $(this).parent().html(localized_strings.loading);
792
- $.post( ajaxurl, {
793
- action: "sp-get-players",
794
- index: index,
795
- nonce: $("#sp-get-players-nonce").val()
796
- }).done(function( response ) {
797
- index = response.data.index;
798
- console.log(index);
799
- $target = $(".sp-instance").eq(index).find(".sp-ajax-checklist ul");
800
- $target.find(".sp-ajax-show-all-container").hide();
801
- if ( response.success ) {
802
- i = 0;
803
- console.log(response.data.sections);
804
- if ( -1 == response.data.sections ) {
805
- if(response.data.players.length) {
806
- $(response.data.players).each(function( key, value ) {
807
- if($target.eq(i).find("input[value=" + value.ID + "]").length) return true;
808
- $target.eq(i).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_player[" + index + "][]\"> " + value.post_title + "</li>");
809
- });
810
- } else {
811
- $target.eq(i).html("<li>" + localized_strings.no_results_found + "</li>");
812
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
  } else {
814
- if(response.data.players.length) {
815
- if ( 1 == response.data.sections ) {
816
- defense = i;
817
- offense = i+1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
818
  } else {
819
- offense = i;
820
- defense = i+1;
821
  }
822
- $(response.data.players).each(function( key, value ) {
823
- $target.eq(offense).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_offense[" + index + "][]\"> " + value.post_title + "</li>");
824
- $target.eq(defense).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_defense[" + index + "][]\"> " + value.post_title + "</li>");
825
- });
826
- } else {
827
- $target.eq(offense).html("<li>" + localized_strings.no_results_found + "</li>");
828
- $target.eq(defense).html("<li>" + localized_strings.no_results_found + "</li>");
829
  }
830
- i++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
831
  }
832
- i++;
833
- if(response.data.staff.length) {
834
- $(response.data.staff).each(function( key, value ) {
835
- $target.eq(i).append("<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_staff[" + index + "][]\"> " + value.post_title + "</li>");
836
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
837
  } else {
838
- $target.eq(i).html("<li>" + localized_strings.no_results_found + "</li>");
839
- }
840
- } else {
841
- $target.html("<li>" + localized_strings.no_results_found + "</li>");
842
- }
843
- });
844
- });
845
-
846
- // Event status selector
847
- $('.sp-edit-event-status').click(function(e) {
848
- e.preventDefault();
849
- $select = $(this).siblings('.sp-event-status-select');
850
- if ( $select.is(':hidden') ) {
851
- $select.slideDown( 'fast', function() {
852
- $select.find( 'input[type="radio"]' ).first().focus();
853
- } );
854
- $(this).hide();
855
- }
856
- });
857
-
858
- $('.sp-save-event-status').click(function(e) {
859
- e.preventDefault();
860
- $select = $(this).closest('.sp-event-status-select');
861
- $input = $select.find('input[name=sp_status]:checked');
862
- val = $input.val();
863
- label = $input.data('sp-event-status');
864
- $select.slideUp('fast').siblings('.sp-edit-event-status').show().siblings('.sp-event-status').find('.sp-event-status-display').data('sp-event-status', val).html(label);
865
- });
866
-
867
- $('.sp-cancel-event-status').click(function(e) {
868
- e.preventDefault();
869
- $select = $(this).closest('.sp-event-status-select');
870
- val = $select.siblings('.sp-event-status').find('.sp-event-status-display').data('sp-event-status');
871
- $select.find('input[value='+val+']').attr('checked', true);
872
- $select.slideUp('fast').siblings('.sp-edit-event-status').show();
873
- });
874
-
875
- // Box score time converter
876
- $('.sp-convert-time-input').change(function() {
877
- var s = 0;
878
- var val = $(this).val();
879
- if (val === '') {
880
- $(this).siblings('.sp-convert-time-output').val('');
881
- return;
882
- }
883
- var a = val.split(':').reverse();
884
- $.each(a, function( index, value ) {
885
- s += parseInt(value) * Math.pow(60, index);
886
- });
887
- $(this).siblings('.sp-convert-time-output').val(s);
888
- });
889
-
890
- // Trigger box score time converter
891
- $('.sp-convert-time-input').change();
892
- });
1
+ jQuery( document ).ready(
2
+ function($){
3
+
4
+ // Tiptip
5
+ $( ".sp-tip" ).tipTip(
6
+ {
7
+ delay: 200,
8
+ fadeIn: 100,
9
+ fadeOut: 100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
11
+ );
12
+ $( ".sp-desc-tip" ).tipTip(
13
+ {
14
+ delay: 200,
15
+ fadeIn: 100,
16
+ fadeOut: 100,
17
+ defaultPosition: 'right'
18
  }
19
+ );
20
+
21
+ // Chosen select
22
+ $( document ).on(
23
+ "postbox-toggled",
24
+ function() {
25
+ $( ".chosen-select" ).filter( ":visible" ).chosen(
26
+ {
27
+ allow_single_deselect: true,
28
+ search_contains: true,
29
+ single_backstroke_delete: false,
30
+ disable_search_threshold: 10,
31
+ placeholder_text_multiple: localized_strings.none
32
+ }
33
+ );
34
  }
35
+ ).trigger( "postbox-toggled" );
36
+
37
+ // Auto key placeholder
38
+ $( "#poststuff #title" ).on(
39
+ "keyup",
40
+ function() {
41
+ val = $( this ).val()
42
+ lc = val.replace( /[^a-z]/gi,"" ).toLowerCase();
43
+ $( "#sp_key" ).attr( "placeholder", lc );
44
+ $( "#sp_default_key" ).val( lc );
45
+ $( "#sp_singular" ).attr( "placeholder", val );
46
  }
47
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
+ // Activate auto key placeholder
50
+ $( "#poststuff #title" ).keyup();
51
 
52
+ // Radio input toggle
53
+ $( ".sp-radio-toggle" ).click(
54
+ function() {
55
+ if ($( this ).data( "sp-checked" )) {
56
+ $( this ).prop( "checked", false );
57
+ $( this ).data( "sp-checked", false );
58
+ } else {
59
+ $( this ).data( "sp-checked", true );
60
+ }
61
+ }
62
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
+ // Table switcher
65
+ $( ".sp-table-panel" ).siblings( ".sp-table-bar" ).find( "a" ).click(
66
+ function() {
67
+ $( this ).closest( "li" ).find( "a" ).addClass( "current" ).closest( "li" ).siblings().find( "a" ).removeClass( "current" ).closest( ".sp-table-bar" ).siblings( $( this ).attr( "href" ) ).show().siblings( ".sp-table-panel" ).hide();
68
+ return false;
69
+ }
70
+ );
71
 
72
+ // Tab switcher
73
+ $( ".sp-tab-panel" ).siblings( ".sp-tab-bar" ).find( "a" ).click(
74
+ function() {
75
+ $( this ).closest( "li" ).addClass( "tabs" ).siblings().removeClass( "tabs" ).closest( ".sp-tab-bar" ).siblings( $( this ).attr( "href" ) ).show().trigger( 'checkCheck' ).siblings( ".sp-tab-panel" ).hide();
76
+ return false;
77
+ }
78
+ );
79
+
80
+ // Tab filter
81
+ $( ".sp-tab-filter-panel" ).siblings( ".sp-tab-select" ).find( "select" ).change(
82
+ function() {
83
+ var val = $( this ).val();
84
+ var filter = ".sp-filter-" + val;
85
+ var $filters = $( this ).closest( ".sp-tab-select" ).siblings( ".sp-tab-select" );
86
+ if ($filters.length) {
87
+ $filters.each(
88
+ function() {
89
+ filterval = $( this ).find( "select" ).val();
90
+ if (filterval !== undefined) {
91
+ filter += ".sp-filter-" + filterval;
92
+ }
93
+ }
94
+ );
95
+ }
96
+ $panel = $( this ).closest( ".sp-tab-select" ).siblings( ".sp-tab-panel" );
97
+ $panel.each(
98
+ function() {
99
+ $( this ).find( ".sp-post" ).hide(
100
+ 0,
101
+ function() {
102
+ $( this ).find( "input" ).prop( "disabled", true );
103
+ $( this ).filter( filter ).show(
104
+ 0,
105
+ function() {
106
+ $( this ).find( "input" ).prop( "disabled", false );
107
+ }
108
+ );
109
+ }
110
+ );
111
+ if ($( this ).find( ".sp-post:visible" ).length > 0) {
112
+ $( this ).find( ".sp-select-all-container" ).show();
113
+ $( this ).find( ".sp-show-all-container" ).show();
114
+ $( this ).find( ".sp-not-found-container" ).hide();
115
+ } else {
116
+ $( this ).find( ".sp-select-all-container" ).hide();
117
+ $( this ).find( ".sp-show-all-container" ).hide();
118
+ $( this ).find( ".sp-not-found-container" ).show();
119
+ }
120
+ }
121
+ );
122
+ }
123
+ );
124
+
125
+ // Trigger tab filter
126
+ $( ".sp-tab-filter-panel" ).siblings( ".sp-tab-select" ).find( "select" ).change();
127
+
128
+ // Dropdown filter
129
+ $( ".sp-dropdown-target" ).siblings( ".sp-dropdown-filter" ).find( "select" ).change(
130
+ function() {
131
+ var val = $( this ).val();
132
+ var filter = ".sp-filter-" + val;
133
+ var $filters = $( this ).closest( ".sp-dropdown-filter" ).siblings( ".sp-dropdown-filter" );
134
+ if ($filters.length) {
135
+ $filters.each(
136
+ function() {
137
+ filterval = $( this ).find( "select" ).val();
138
+ if (filterval !== undefined) {
139
+ filter += ".sp-filter-" + filterval;
140
+ }
141
+ }
142
+ );
143
+ }
144
+ $target = $( this ).closest( ".sp-dropdown-filter" ).siblings( ".sp-dropdown-target" ).find( "select" );
145
+ $target.find( ".sp-post" ).prop( "disabled", true ).each(
146
+ function() {
147
+ $( this ).filter( filter ).prop( "disabled", false );
148
+ }
149
+ );
150
+ }
151
+ );
152
+
153
+ // Trigger dropdown filter
154
+ $( ".sp-dropdown-target" ).siblings( ".sp-dropdown-filter" ).find( "select" ).change();
155
 
156
+ // Filter show all action links
157
+ $( ".sp-tab-panel" ).find( ".sp-post input:checked" ).each(
158
+ function() {
159
+ $( this ).prop( "disabled", false ).closest( "li" ).show().siblings( ".sp-not-found-container" ).hide().siblings( ".sp-show-all-container" ).show();
160
+ }
161
+ );
162
+
163
+ // Show all filter
164
+ $( ".sp-tab-panel" ).on(
165
+ "click",
166
+ ".sp-show-all",
167
+ function() {
168
+ $( this ).closest( "li" ).hide().siblings( ".sp-post, .sp-select-all-container" ).show().find( "input" ).prop( "disabled", false );
169
+ }
170
+ );
171
+
172
+ // Self-cloning
173
+ $( ".sp-clone:last" ).find( "select" ).change(
174
+ function() {
175
+ $( this ).closest( ".sp-clone" ).siblings().find( "select" ).change(
176
+ function() {
177
+ if ($( this ).val() == "0") {
178
+ $( this ).closest( ".sp-clone" ).remove();
179
+ }
180
+ }
181
+ ).find( "option:first" ).text( localized_strings.remove_text );
182
+ if ($( this ).val() != "0") {
183
+ $original = $( this ).closest( ".sp-clone" );
184
+ $original.before( $original.clone().find( "select" ).attr( "name", $original.attr( "data-clone-name" ) + "[]" ).val( $( this ).val() ).closest( ".sp-clone" ) ).attr( "data-clone-num", parseInt( $original.attr( "data-clone-num" ) ) + 1 ).find( "select" ).val( "0" ).change();
185
+ }
186
+ }
187
+ );
188
 
189
+ // Activate self-cloning
190
+ $( ".sp-clone:last" ).find( "select" ).change();
191
 
192
+ // Custom value editor
193
+ $( ".sp-data-table .sp-default-value" ).click(
194
+ function() {
195
+ $( this ).hide().siblings( ".sp-custom-value" ).show().find( ".sp-custom-value-input" ).focus();
196
+ }
197
+ );
198
+
199
+ // Define custom value editor saving
200
+ $( ".sp-data-table .sp-custom-value .sp-custom-value-input" ).on(
201
+ "saveInput",
202
+ function() {
203
+ $val = $( this ).val();
204
+ if ($val == "") {
205
+ $val = $( this ).attr( "placeholder" );
206
+ }
207
+ $( this ).closest( ".sp-custom-value" ).hide().siblings( ".sp-default-value" ).show().find( ".sp-default-value-input" ).html( $val );
208
+ }
209
+ );
210
+
211
+ // Define custom value editor cancellation
212
+ $( ".sp-data-table .sp-custom-value .sp-custom-value-input" ).on(
213
+ "cancelInput",
214
+ function() {
215
+ $val = $( this ).closest( ".sp-custom-value" ).siblings( ".sp-default-value" ).find( ".sp-default-value-input" ).html();
216
+ if ($val == $( this ).attr( "placeholder" )) {
217
+ $( this ).val( "" );
218
+ } else {
219
+ $( this ).val( $val );
220
+ }
221
+ $( this ).closest( ".sp-custom-value" ).hide().siblings( ".sp-default-value" ).show();
222
+ }
223
+ );
224
 
225
+ // Custom value editor save
226
+ $( ".sp-data-table .sp-custom-value .sp-save" ).click(
227
+ function() {
228
+ $( this ).siblings( ".sp-custom-value-input" ).trigger( "saveInput" );
229
+ }
230
+ );
231
 
232
+ // Custom value editor cancel
233
+ $( ".sp-data-table .sp-custom-value .sp-cancel" ).click(
234
+ function() {
235
+ $( this ).siblings( ".sp-custom-value-input" ).trigger( "cancelInput" );
236
+ }
237
+ );
238
+
239
+ // Prevent custom value editor input from submitting form
240
+ $( ".sp-data-table .sp-custom-value .sp-custom-value-input" ).keypress(
241
+ function(event) {
242
+ if (event.keyCode == 13) {
243
+ event.preventDefault();
244
+ $( this ).trigger( "saveInput" );
245
+ return false;
246
+ }
247
+ }
248
+ );
249
+
250
+ // Cancel custom value editor form on escape
251
+ $( ".sp-data-table .sp-custom-value .sp-custom-value-input" ).keyup(
252
+ function(event) {
253
+ if (event.keyCode == 27) {
254
+ event.preventDefault();
255
+ $( this ).trigger( "cancelInput" );
256
+ return false;
257
+ }
258
+ }
259
+ );
260
+
261
+ // Data table adjustments
262
+ $( ".sp-table-adjustments input" ).change(
263
+ function() {
264
+ matrix = $( this ).attr( "data-matrix" );
265
+ $el = $( this ).closest( ".sp-table-adjustments" ).siblings( ".sp-table-values" ).find( "input[data-matrix=" + matrix + "]" );
266
+ placeholder = $el.attr( "data-placeholder" );
267
+ current_adjustment = parseFloat( $el.attr( "data-adjustment" ) );
268
+ adjustment = parseFloat( $( this ).val() );
269
+ if ( ! isNaN( adjustment ) && adjustment != 0) {
270
+ placeholder = parseFloat( placeholder );
271
+ if (isNaN( placeholder )) {
272
+ placeholder = 0;
273
+ }
274
+ if (isNaN( current_adjustment )) {
275
+ current_adjustment = 0;
276
+ }
277
+ placeholder += adjustment - current_adjustment;
278
+ }
279
+ $el.attr( "placeholder", placeholder );
280
+ }
281
+ ).change();
282
+
283
+ // Data table keyboard navigation
284
+ $( ".sp-data-table tbody tr td input:text" ).keydown(
285
+ function(event) {
286
+ if ( ! $( this ).parent().hasClass( "chosen-search" ) && [37,38,39,40].indexOf( event.keyCode ) > -1) {
287
+ $el = $( this ).closest( "td" );
288
+ var col = $el.parent().children().index( $el ) + 1;
289
+ var row = $el.parent().parent().children().index( $el.parent() ) + 1;
290
+ if (event.keyCode == 37) {
291
+ if ( $( this ).caret().start != 0 ) {
292
+ return true;
293
+ }
294
+ col -= 1;
295
+ }
296
+ if (event.keyCode == 38) {
297
+ row -= 1;
298
+ }
299
+ if (event.keyCode == 39) {
300
+ if ( $( this ).caret().start != $( this ).val().length ) {
301
+ return true;
302
+ }
303
+ col += 1;
304
+ }
305
+ if (event.keyCode == 40) {
306
+ row += 1;
307
+ }
308
+ $el.closest( "tbody" ).find( "tr:nth-child(" + row + ") td:nth-child(" + col + ") input:text" ).first().focus();
309
+ }
310
+ }
311
+ );
312
+
313
+ // Prevent data table from submitting form
314
+ $( ".sp-data-table tbody tr td input:text" ).keypress(
315
+ function(event) {
316
+ if ( ! $( this ).parent().hasClass( "chosen-search" ) && event.keyCode == 13) {
317
+ event.preventDefault();
318
+ $el = $( this ).closest( "td" );
319
+ var col = $el.parent().children().index( $el ) + 1;
320
+ var row = $el.parent().parent().children().index( $el.parent() ) + 2;
321
+ $el.closest( "tbody" ).find( "tr:nth-child(" + row + ") td:nth-child(" + col + ") input:text" ).focus();
322
+ return false;
323
+ }
324
+ }
325
+ );
326
+
327
+ // Total stats calculator
328
+ $( ".sp-data-table .sp-total input[data-sp-format=number][data-sp-total-type!=average]" ).on(
329
+ "updateTotal",
330
+ function() {
331
+ index = $( this ).parent().index();
332
+ var sum = 0;
333
+ $( this ).closest( ".sp-data-table" ).find( ".sp-post" ).each(
334
+ function() {
335
+ val = $( this ).find( "td" ).eq( index ).find( "input" ).val();
336
+ if (val == "") {
337
+ val = $( this ).find( "td" ).eq( index ).find( "input" ).attr( "placeholder" );
338
+ }
339
+ if ($.isNumeric( val )) {
340
+ sum += parseFloat( val, 10 );
341
+ }
342
+ }
343
+ );
344
+ $( this ).attr( "placeholder", sum );
345
+ }
346
+ );
347
+
348
+ // Activate total stats calculator
349
+ if ($( ".sp-data-table .sp-total" ).length) {
350
+ $( ".sp-data-table .sp-post td input" ).on(
351
+ "keyup",
352
+ function() {
353
+ $( this ).closest( ".sp-data-table" ).find( ".sp-total td" ).eq( $( this ).parent().index() ).find( "input[data-sp-format=number][data-sp-total-type!=average]" ).trigger( "updateTotal" );
354
+ }
355
+ );
356
  }
357
 
358
+ // Trigger total stats calculator
359
+ $( ".sp-data-table .sp-total input[data-sp-format=number][data-sp-total-type!=average]" ).trigger( "updateTotal" );
360
+
361
+ // Sync inputs
362
+ $( ".sp-sync-input" ).on(
363
+ "keyup",
364
+ function() {
365
+ name = $( this ).attr( "name" );
366
+ $el = $( "input[name='" + name + "']" );
367
+ if ( $el.length > 1 ) {
368
+ val = $( this ).val();
369
+ $el.val( val );
370
+ }
371
+ }
372
+ );
373
+
374
+ // Sync selects
375
+ $( ".sp-sync-select" ).on(
376
+ "change",
377
+ function() {
378
+ name = $( this ).attr( "name" );
379
+ $el = $( "select[name='" + name + "']" )
380
+ if ( $el.length > 1 ) {
381
+ val = $( this ).val();
382
+ $el.val( val );
383
+ }
384
+ }
385
+ );
386
+
387
+ // Select all checkboxes
388
+ $( ".sp-select-all-range" ).on(
389
+ "change",
390
+ ".sp-select-all",
391
+ function() {
392
+ $range = $( this ).closest( ".sp-select-all-range" );
393
+ $range.find( "input[type=checkbox]" ).prop( "checked", $( this ).prop( "checked" ) );
394
+ }
395
+ );
396
+
397
+ // Check if all checkboxes are checked already
398
+ $( ".sp-select-all-range" ).on(
399
+ "checkCheck",
400
+ function() {
401
+ $( this ).each(
402
+ function() {
403
+ $( this ).find( ".sp-select-all" ).prop( "checked", $( this ).find( "input[type=checkbox]:checked:not(.sp-select-all)" ).length != 0 && $( this ).find( "input[type=checkbox]:checked:not(.sp-select-all)" ).length == $( this ).find( "input[type=checkbox]:visible:not(.sp-select-all)" ).length );
404
+ }
405
+ );
406
+ }
407
+ );
408
+
409
+ // Activate check check when a checkbox is checked
410
+ $( ".sp-select-all-range input[type=checkbox]:not(.sp-select-all)" ).change(
411
+ function() {
412
+ $( this ).closest( ".sp-select-all-range" ).trigger( "checkCheck" );
413
+ }
414
+ );
415
 
416
+ // Activate check check on page load
417
+ $( ".sp-select-all-range" ).trigger( "checkCheck" );
418
 
419
+ // Trigger check check
420
+ $( ".sp-data-table" ).trigger( "checkCheck" );
421
 
422
+ // Sortable tables
423
+ $( ".sp-sortable-table tbody" ).sortable(
424
+ {
425
+ handle: ".icon",
426
+ axis: "y"
427
+ }
428
+ );
429
+
430
+ // Sortable lists
431
+ $( ".sp-sortable-list" ).sortable(
432
+ {
433
+ handle: ".sp-item-handle",
434
+ placeholder: "sp-item-placeholder",
435
+ connectWith: ".sp-connected-list"
436
+ }
437
+ );
438
 
439
+ // Autosave
440
+ $( ".sp-autosave" ).change(
441
+ function() {
442
+ $( this ).attr( "readonly", true ).closest( "form" ).submit();
443
+ }
444
+ );
445
 
446
+ // Video embed
447
+ $( ".sp-add-video" ).click(
448
+ function() {
449
+ $( this ).closest( "fieldset" ).hide().siblings( ".sp-video-field" ).show();
450
+ return false;
451
+ }
452
+ );
453
+
454
+ // Removing video embed
455
+ $( ".sp-remove-video" ).click(
456
+ function() {
457
+ $( this ).closest( "fieldset" ).hide().siblings( ".sp-video-adder" ).show().siblings( ".sp-video-field" ).find( "input" ).val( null );
458
+ return false;
459
+ }
460
+ );
461
+
462
+ // Equation selector
463
+ $( ".sp-equation-selector select:last" ).change(
464
+ function() {
465
+ $( this ).siblings().change(
466
+ function() {
467
+ if ($( this ).val() == "") {
468
+ $( this ).remove();
469
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
  }
471
+ ).find( "option:first" ).text( localized_strings.remove_text );
472
+ if ($( this ).val() != "") {
473
+ $( this ).before( $( this ).clone().val( $( this ).val() ) ).val( "" ).change();
474
+ }
475
+ }
476
+ );
477
+
478
+ // Trigger equation selector
479
+ $( ".sp-equation-selector select:last" ).change().siblings().change();
480
+
481
+ // Order selector
482
+ $( ".sp-order-selector select:first" ).change(
483
+ function() {
484
+ if ($( this ).val() == "0") {
485
+ $( this ).siblings().prop( "disabled", true );
486
+ } else {
487
+ $( this ).siblings().prop( "disabled", false )
488
+ }
489
+ }
490
+ );
491
+
492
+ // Trigger order selector
493
+ $( ".sp-order-selector select:first" ).change();
494
+
495
+ // Format selector
496
+ $( ".sp-format-selector select:first" ).change(
497
+ function() {
498
+
499
+ $precisiondiv = $( "#sp_precisiondiv" );
500
+ $precisioninput = $( "#sp_precision" );
501
+ $timeddiv = $( "#sp_timeddiv" );
502
+ $equationdiv = $( "#sp_equationdiv" );
503
+
504
+ // Equation settings
505
+ if ($( this ).val() == "equation") {
506
+ $equationdiv.show();
507
+ $precisiondiv.show();
508
+ $timeddiv.hide();
509
+ $precisioninput.prop( "disabled", false );
510
+ } else if ($( this ).val() == "number") {
511
+ $equationdiv.hide();
512
+ $precisiondiv.hide();
513
+ $timeddiv.show();
514
+ $precisioninput.prop( "disabled", true );
515
+ } else {
516
+ $equationdiv.hide();
517
+ $precisiondiv.hide();
518
+ $timeddiv.hide();
519
+ $precisioninput.prop( "disabled", true );
520
+ }
521
+
522
+ }
523
+ );
524
+
525
+ // Trigger format selector
526
+ $( ".sp-format-selector select:first" ).change();
527
+
528
+ // Team era selector
529
+ $( ".sp-team-era-selector select:first-child" ).change(
530
+ function() {
531
+
532
+ $subselector = $( this ).siblings();
533
+
534
+ // Sub settings
535
+ if ($( this ).val() == 0) {
536
+ $subselector.hide();
537
  } else {
538
+ $subselector.show();
539
+ }
540
+
541
+ }
542
+ );
543
+
544
+ // Trigger team era selector
545
+ $( ".sp-team-era-selector select:first-child" ).change();
546
+
547
+ // Status selector
548
+ $( ".sp-status-selector select:first-child" ).change(
549
+ function() {
550
+
551
+ $subselector = $( this ).siblings();
552
+
553
+ // Sub settings
554
+ if ($( this ).val() == "sub") {
555
+ $subselector.show();
556
+ } else {
557
+ $subselector.hide();
558
+ }
559
+
560
+ }
561
+ );
562
+
563
+ // Trigger status selector
564
+ $( ".sp-status-selector select:first-child" ).change();
565
+
566
+ // Preset field modifier
567
+ $( ".sp-custom-input-wrapper .preset" ).click(
568
+ function() {
569
+ val = $( this ).val();
570
+ if (val == "\\c\\u\\s\\t\\o\\m") {
571
+ return true;
572
+ }
573
+ example = $( this ).attr( "data-example" );
574
+ $( this ).closest( ".sp-custom-input-wrapper" ).find( ".value" ).val( val ).siblings( ".example" ).html( example );
575
+ }
576
+ );
577
+
578
+ // Select custom preset when field is brought to focus
579
+ $( ".sp-custom-input-wrapper .value" ).focus(
580
+ function() {
581
+ $( this ).siblings( "label" ).find( ".preset" ).prop( "checked", true );
582
+ }
583
+ );
584
+
585
+ // Adjust example field when custom preset is entered
586
+ $( ".sp-custom-input-wrapper .value" ).on(
587
+ "keyup",
588
+ function() {
589
+ val = $( this ).val();
590
+ if ( val === undefined ) {
591
+ return true;
592
+ }
593
+ format = $( this ).attr( "data-example-format" );
594
+ example = format.replace( "__val__", val );
595
+ $( this ).siblings( ".example" ).html( example );
596
+ }
597
+ );
598
+
599
+ // Prevent address input from submitting form
600
+ $( ".sp-address" ).keypress(
601
+ function(event) {
602
+ return event.keyCode != 13;
603
+ }
604
+ );
605
+
606
+ // Dashboard countdown
607
+ $( "#sportspress_dashboard_status .sp_status_list li.countdown" ).each(
608
+ function() {
609
+ var $this = $( this );
610
+ // Get countdown time
611
+ var countDownDate = new Date( $( this ).data( 'countdown' ) ).getTime();
612
+ // Iterate every second
613
+ var x = setInterval(
614
+ function() {
615
+
616
+ // Get todays date and time
617
+ var now = new Date();
618
+
619
+ // Convert curent date and time to UTC
620
+ var tzDifference = now.getTimezoneOffset();
621
+ var nowutc = new Date( now.getTime() + tzDifference * 60 * 1000 );
622
+
623
+ // Find the distance between now and the count down date
624
+ var distance = countDownDate - nowutc;
625
+ if ( distance < 0 ) {
626
+ distance = 0;
627
+ }
628
+
629
+ // Time calculations for days, hours, minutes and seconds
630
+ var days = Math.floor( distance / (1000 * 60 * 60 * 24) );
631
+ var hours = Math.floor( (distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) );
632
+ var minutes = Math.floor( (distance % (1000 * 60 * 60)) / (1000 * 60) );
633
+ var seconds = Math.floor( (distance % (1000 * 60)) / 1000 );
634
+
635
+ // Output the result
636
+ $this.find( 'strong' ).html( days + " " + localized_strings.days + " " + ('0' + hours).slice( -2 ) + ":" + ('0' + minutes).slice( -2 ) + ":" + ('0' + seconds).slice( -2 ) );
637
+ },
638
+ 1000
639
+ );
640
+ }
641
+ );
642
+
643
+ // Event format affects data
644
+ $( ".post-type-sp_event #post-formats-select" ).change(
645
+ function() {
646
+ layout = $( ".post-type-sp_event #post-formats-select input:checked" ).val();
647
+ if ( layout == "friendly" ) {
648
+ $( ".sp_event-sp_league-field" ).hide().find( "select" ).prop( "disabled", true );
649
+ $( ".sp_event-sp_season-field" ).hide().find( "select" ).prop( "disabled", true );
650
+ } else {
651
+ $( ".sp_event-sp_league-field" ).show().find( "select" ).prop( "disabled", false );
652
+ $( ".sp_event-sp_season-field" ).show().find( "select" ).prop( "disabled", false );
653
+ }
654
+ }
655
+ );
656
+
657
+ // Trigger event format change
658
+ $( ".post-type-sp_event #post-formats-select" ).trigger( "change" );
659
+
660
+ // Calendar layout affects data
661
+ $( ".post-type-sp_calendar #post-formats-select" ).change(
662
+ function() {
663
+ layout = $( ".post-type-sp_calendar #post-formats-select input:checked" ).val();
664
+ $( ".sp-calendar-table tr" ).each(
665
+ function() {
666
+ if ( layout == "list" ) {
667
+ $( this ).find( "th input[type=checkbox]" ).show();
668
+ $( this ).find( "th select" ).prop( "disabled", false );
669
+ } else {
670
+ $( this ).find( "th input[type=checkbox]" ).hide();
671
+ $( this ).find( "th select" ).prop( 'selectedIndex', 0 ).prop( "disabled", true );
672
+ }
673
+ }
674
+ );
675
+ }
676
+ );
677
+
678
+ // Trigger calendar layout change
679
+ $( ".post-type-sp_calendar #post-formats-select" ).trigger( "change" );
680
+
681
+ // Player list layout affects data
682
+ $( ".post-type-sp_list #post-formats-select" ).change(
683
+ function() {
684
+ layout = $( ".post-type-sp_list #post-formats-select input:checked" ).val();
685
+ $( ".sp-player-list-table tr" ).each(
686
+ function() {
687
+ if ( layout == "list" ) {
688
+ $( this ).find( "th input[type=checkbox]" ).show();
689
+ } else {
690
+ $( this ).find( "th input[type=checkbox]" ).hide();
691
+ }
692
  }
693
+ );
694
+ }
695
+ );
696
+
697
+ // Trigger player list layout change
698
+ $( ".post-type-sp_list #post-formats-select" ).trigger( "change" );
699
+
700
+ // Configure primary result option (Ajax)
701
+ $( ".sp-admin-config-table" ).on(
702
+ "click",
703
+ ".sp-primary-result-option",
704
+ function() {
705
+ $.post(
706
+ ajaxurl,
707
+ {
708
+ action: "sp-save-primary-result",
709
+ primary_result: $( this ).val(),
710
+ nonce: $( "#sp-primary-result-nonce" ).val()
711
  }
712
+ );
713
+ }
714
+ );
715
+
716
+ // Configure primary performance option (Ajax)
717
+ $( ".sp-admin-config-table" ).on(
718
+ "click",
719
+ ".sp-primary-performance-option",
720
+ function() {
721
+ $.post(
722
+ ajaxurl,
723
+ {
724
+ action: "sp-save-primary-performance",
725
+ primary_performance: $( this ).val(),
726
+ nonce: $( "#sp-primary-performance-nonce" ).val()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
727
  }
728
+ );
729
+ }
730
+ );
731
+
732
+ // Update importer post count
733
+ $( ".sp-import-table" ).on(
734
+ "updatePostCount",
735
+ function() {
736
+ $( ".sp-post-count" ).text( localized_strings.displaying_posts.replace( "%s", 1 ).replace( /%s/g, count = $( this ).find( "tbody tr" ).length ) );
737
+ }
738
+ );
739
+
740
+ // Delete importer row
741
+ $( ".sp-import-table" ).on(
742
+ "click",
743
+ ".sp-delete-row",
744
+ function() {
745
+ $self = $( this );
746
+ $self.closest( "tr" ).css( "background-color", "#f99" ).fadeOut(
747
+ 400,
748
+ function() {
749
+ $table = $self.closest( ".sp-import-table" );
750
+ $( this ).remove();
751
+ $table.trigger( "updatePostCount" );
752
+ }
753
+ );
754
+ return false;
755
+ }
756
+ );
757
+
758
+ // Add importer row
759
+ $( ".sp-import-table" ).on(
760
+ "click",
761
+ ".sp-add-row",
762
+ function() {
763
+ $self = $( this );
764
+ $table = $self.closest( ".sp-import-table" );
765
+ if ( $self.hasClass( "sp-add-first" ) ) {
766
+ $tr = $table.find( "tbody tr:first-child" );
767
+ $row = $tr.clone();
768
+ $row.insertBefore( $tr ).find( "input" ).val( "" );
769
+ } else {
770
+ $tr = $self.closest( "tr" );
771
+ $row = $tr.clone();
772
+ $tr.find( "input" ).val( "" );
773
+ $row.insertBefore( $tr );
774
+ }
775
+ $table.trigger( "updatePostCount" );
776
+ return false;
777
+ }
778
+ );
779
+
780
+ // Enable or disable importer inputs based on column label
781
+ $( ".sp-import-table" ).on(
782
+ "change",
783
+ "select",
784
+ function() {
785
+ $self = $( this );
786
+ $table = $self.closest( ".sp-import-table" );
787
+ index = parseInt( $self.data( "index" ) );
788
+ if ( $self.val() == 0 ) {
789
+ $table.find( "tbody tr td:nth-child(" + parseInt( index + 1 ) + ") input" ).prop( "disabled", true );
790
  } else {
791
+ $table.find( "tbody tr td:nth-child(" + parseInt( index + 1 ) + ") input" ).prop( "disabled", false );
792
+ $self.closest( "th" ).siblings().find( "select" ).each(
793
+ function() {
794
+ if ( $( this ).val() == $self.val() ) {
795
+ $( this ).val( "0" ).trigger( "change" );
796
+ }
797
+ }
798
+ );
799
+ }
800
+ }
801
+ );
802
+
803
+ // Datepicker
804
+ $( ".sp-datepicker" ).datepicker(
805
+ {
806
+ dateFormat : "yy-mm-dd"
807
+ }
808
+ );
809
+ $( ".sp-datepicker-from" ).datepicker(
810
+ {
811
+ dateFormat : "yy-mm-dd",
812
+ onClose: function( selectedDate ) {
813
+ $( this ).closest( ".sp-date-selector" ).find( ".sp-datepicker-to" ).datepicker( "option", "minDate", selectedDate );
814
+ }
815
+ }
816
+ );
817
+ $( ".sp-datepicker-to" ).datepicker(
818
+ {
819
+ dateFormat : "yy-mm-dd",
820
+ onClose: function( selectedDate ) {
821
+ $( this ).closest( ".sp-date-selector" ).find( ".sp-datepicker-from" ).datepicker( "option", "maxDate", selectedDate );
822
+ }
823
+ }
824
+ );
825
+
826
+ // Show or hide datepicker
827
+ $( ".sp-date-selector select" ).change(
828
+ function() {
829
+ if ( $( this ).val() == "range" ) {
830
+ $( this ).closest( ".sp-date-selector" ).find( ".sp-date-range" ).show();
831
+ } else {
832
+ $( this ).closest( ".sp-date-selector" ).find( ".sp-date-range" ).hide();
833
+ }
834
+ }
835
+ );
836
+ $( ".sp-date-selector select" ).trigger( "change" );
837
+
838
+ // Toggle date range selectors
839
+ $( ".sp-date-relative input" ).change(
840
+ function() {
841
+ $relative = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-relative" ).toggle( 0, $( this ).attr( "checked" ) );
842
+ $absolute = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-absolute" ).toggle( 0, $( this ).attr( "checked" ) );
843
+
844
+ if ($( this ).attr( "checked" )) {
845
+ $relative.show();
846
+ $absolute.hide();
847
+ } else {
848
+ $absolute.show();
849
+ $relative.hide();
850
+ }
851
+ }
852
+ );
853
+ $( ".sp-date-selector input" ).trigger( "change" );
854
+
855
+ // Apply color scheme
856
+ $( ".sp-color-option" ).on(
857
+ "click",
858
+ function() {
859
+ colors = $( this ).find( "label" ).data( "sp-colors" ).split( "," );
860
+ $( ".sp-custom-colors" ).find( ".sp-color-box" ).each(
861
+ function(index) {
862
+ $( this ).find( "input" ).val( "#" + colors[index] ).css( "background-color", "#" + colors[index] );
863
+ }
864
+ );;
865
+ }
866
+ );
867
+
868
+ // Edit inline results
869
+ $( "#the-list" ).on(
870
+ "click, focus",
871
+ ".sp-result, .sp-edit-results",
872
+ function(){
873
+ team = $( this ).data( "team" );
874
+ $column = $( this ).closest( ".column-sp_team" );
875
+ $column.find( ".sp-result, .sp-row-actions" ).hide();
876
+ $column.find( ".sp-edit-result, .sp-inline-edit-save" ).show();
877
+ if ( team != undefined ) {
878
+ $column.find( ".sp-edit-result[data-team='" + team + "']" ).select();
879
+ }
880
+ return false;
881
+ }
882
+ );
883
+
884
+ // Cancel inline results
885
+ $( "#the-list" ).on(
886
+ "click",
887
+ ".sp-inline-edit-save .cancel",
888
+ function(){
889
+ $column = $( this ).closest( ".column-sp_team" );
890
+ $column.find( ".sp-edit-result, .sp-inline-edit-save" ).hide();
891
+ $column.find( ".sp-result, .sp-row-actions" ).show();
892
+ return false;
893
+ }
894
+ );
895
+
896
+ // Save inline results
897
+ $( "#the-list" ).on(
898
+ "click",
899
+ ".sp-inline-edit-save .save",
900
+ function(){
901
+ $column = $( this ).closest( ".column-sp_team" );
902
+ results = {};
903
+ $column.find( ".sp-edit-result" ).each(
904
+ function() {
905
+ id = $( this ).data( "team" );
906
+ result = $( this ).val();
907
+ results[id] = result;
908
+ }
909
+ );
910
+ $.post(
911
+ ajaxurl,
912
+ {
913
+ action: "sp-save-inline-results",
914
+ post_id: $column.find( "input[name='sp_post_id']" ).val(),
915
+ results: results,
916
+ nonce: $( "#sp-inline-nonce" ).val()
917
+ },
918
+ function(response) {
919
+ $column.find( ".sp-edit-result" ).each(
920
+ function() {
921
+ val = $( this ).val();
922
+ $column.find( ".sp-result[data-team='" + $( this ).data( "team" ) + "']" ).html( val == '' ? '-' : val );
923
+ }
924
+ );
925
+ $column.find( ".sp-edit-result, .sp-inline-edit-save" ).hide();
926
+ $column.find( ".sp-result, .sp-row-actions" ).show();
927
+ return false;
928
+ }
929
+ );
930
+ }
931
+ );
932
+
933
+ // Override inline form submission
934
+ $( "#the-list" ).on(
935
+ "keypress",
936
+ ".sp-edit-result",
937
+ function(e) {
938
+ if ( e.which == 13 ) {
939
+ $( this ).closest( ".column-sp_team" ).find( ".sp-inline-edit-save .save" ).trigger( "click" );
940
+ return false;
941
+ }
942
+ }
943
+ );
944
+
945
+ // Fitvids
946
+ $( ".sp-fitvids" ).fitVids();
947
+
948
+ // Display configure sport button
949
+ $( ".sp-select-sport" ).change(
950
+ function() {
951
+ $( ".sp-configure-sport" ).hide();
952
+ }
953
+ );
954
+
955
+ // Ajax checklist
956
+ $( ".sp-ajax-checklist" ).siblings( ".sp-tab-select" ).find( "select" ).change(
957
+ function() {
958
+ $( this ).closest( ".sp-tab-select" ).siblings( ".sp-ajax-checklist" ).find( "ul" ).html( "<li>" + localized_strings.loading + "</li>" );
959
+ $.post(
960
+ ajaxurl,
961
+ {
962
+ action: "sp-get-players",
963
+ team: $( this ).val(),
964
+ league: ('yes' == localized_strings.option_filter_by_league) ? $( "select[name=\"tax_input[sp_league][]\"]" ).val() : null,
965
+ season: ('yes' == localized_strings.option_filter_by_season) ? $( "select[name=\"tax_input[sp_season][]\"]" ).val() : null,
966
+ index: $( this ).closest( ".sp-instance" ).index(),
967
+ nonce: $( "#sp-get-players-nonce" ).val()
968
+ }
969
+ ).done(
970
+ function( response ) {
971
+ index = response.data.index;
972
+ $target = $( ".sp-instance" ).eq( index ).find( ".sp-ajax-checklist ul" );
973
+ if ( response.success ) {
974
+ $target.html( "" );
975
+ i = 0;
976
+ if (-1 == response.data.sections) {
977
+ if (response.data.players.length) {
978
+ $target.eq( 0 ).append( "<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>" );
979
+ $( response.data.players ).each(
980
+ function( key, value ) {
981
+ $target.eq( 0 ).append( "<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_player[" + index + "][]\">" + value.post_title + "</li>" );
982
+ }
983
+ );
984
+ $target.eq( 0 ).append( "<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_players\">" + localized_strings.show_all + "</a></li>" );
985
+ } else {
986
+ $target.eq( 0 ).html( "<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_players\">" + localized_strings.show_all + "</a></li>" );
987
+ }
988
+ } else {
989
+ if ( 1 == response.data.sections ) {
990
+ defense = i;
991
+ offense = i + 1;
992
+ } else {
993
+ offense = i;
994
+ defense = i + 1;
995
+ }
996
+ if (response.data.players.length) {
997
+ $target.eq( offense ).append( "<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>" );
998
+ $target.eq( defense ).append( "<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>" );
999
+ $( response.data.players ).each(
1000
+ function( key, value ) {
1001
+ $target.eq( offense ).append( "<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_offense[" + index + "][]\">" + value.post_title + "</li>" );
1002
+ $target.eq( defense ).append( "<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_defense[" + index + "][]\">" + value.post_title + "</li>" );
1003
+ }
1004
+ );
1005
+ $target.eq( offense ).append( "<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_offense\">" + localized_strings.show_all + "</a></li>" );
1006
+ $target.eq( defense ).append( "<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_defense\">" + localized_strings.show_all + "</a></li>" );
1007
+ } else {
1008
+ $target.eq( offense ).html( "<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_offense\">" + localized_strings.show_all + "</a></li>" );
1009
+ $target.eq( defense ).html( "<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_defense\">" + localized_strings.show_all + "</a></li>" );
1010
+ }
1011
+ i++;
1012
+ }
1013
+ i++;
1014
+ if (response.data.staff.length) {
1015
+ $target.eq( i ).append( "<li class=\"sp-select-all-container\"><label class=\"selectit\"><input type=\"checkbox\" class=\"sp-select-all\"><strong>" + localized_strings.select_all + "</strong></li>" );
1016
+ $( response.data.staff ).each(
1017
+ function( key, value ) {
1018
+ $target.eq( i ).append( "<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_staff[" + index + "][]\">" + value.post_title + "</li>" );
1019
+ }
1020
+ );
1021
+ $target.eq( i ).append( "<li class=\"sp-ajax-show-all-container\"><a class=\"sp-ajax-show-all\" href=\"#show-all-sp_staffs\">" + localized_strings.show_all + "</a></li>" );
1022
+ } else {
1023
+ $target.eq( i ).html( "<li>" + localized_strings.no_results_found + " <a class=\"sp-ajax-show-all\" href=\"#show-all-sp_staffs\">" + localized_strings.show_all + "</a></li>" );
1024
+ }
1025
  } else {
1026
+ $target.html( "<li>" + localized_strings.no_results_found + "</li>" );
 
1027
  }
 
 
 
 
 
 
 
1028
  }
1029
+ );
1030
+ }
1031
+ );
1032
+
1033
+ // Activate Ajax trigger
1034
+ $( ".sp-ajax-trigger" ).change(
1035
+ function() {
1036
+ $( ".sp-ajax-checklist" ).siblings( ".sp-tab-select" ).find( "select" ).change();
1037
+ }
1038
+ );
1039
+
1040
+ // Ajax show all filter
1041
+ $( ".sp-tab-panel" ).on(
1042
+ "click",
1043
+ ".sp-ajax-show-all",
1044
+ function() {
1045
+ index = $( this ).closest( ".sp-instance" ).index();
1046
+ $( this ).parent().html( localized_strings.loading );
1047
+ $.post(
1048
+ ajaxurl,
1049
+ {
1050
+ action: "sp-get-players",
1051
+ index: index,
1052
+ nonce: $( "#sp-get-players-nonce" ).val()
1053
+ }
1054
+ ).done(
1055
+ function( response ) {
1056
+ index = response.data.index;
1057
+ console.log( index );
1058
+ $target = $( ".sp-instance" ).eq( index ).find( ".sp-ajax-checklist ul" );
1059
+ $target.find( ".sp-ajax-show-all-container" ).hide();
1060
+ if ( response.success ) {
1061
+ i = 0;
1062
+ console.log( response.data.sections );
1063
+ if ( -1 == response.data.sections ) {
1064
+ if (response.data.players.length) {
1065
+ $( response.data.players ).each(
1066
+ function( key, value ) {
1067
+ if ($target.eq( i ).find( "input[value=" + value.ID + "]" ).length) {
1068
+ return true;
1069
+ }
1070
+ $target.eq( i ).append( "<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_player[" + index + "][]\"> " + value.post_title + "</li>" );
1071
+ }
1072
+ );
1073
+ } else {
1074
+ $target.eq( i ).html( "<li>" + localized_strings.no_results_found + "</li>" );
1075
+ }
1076
+ } else {
1077
+ if (response.data.players.length) {
1078
+ if ( 1 == response.data.sections ) {
1079
+ defense = i;
1080
+ offense = i + 1;
1081
+ } else {
1082
+ offense = i;
1083
+ defense = i + 1;
1084
+ }
1085
+ $( response.data.players ).each(
1086
+ function( key, value ) {
1087
+ $target.eq( offense ).append( "<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_offense[" + index + "][]\"> " + value.post_title + "</li>" );
1088
+ $target.eq( defense ).append( "<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_defense[" + index + "][]\"> " + value.post_title + "</li>" );
1089
+ }
1090
+ );
1091
+ } else {
1092
+ $target.eq( offense ).html( "<li>" + localized_strings.no_results_found + "</li>" );
1093
+ $target.eq( defense ).html( "<li>" + localized_strings.no_results_found + "</li>" );
1094
+ }
1095
+ i++;
1096
+ }
1097
+ i++;
1098
+ if (response.data.staff.length) {
1099
+ $( response.data.staff ).each(
1100
+ function( key, value ) {
1101
+ $target.eq( i ).append( "<li><label class=\"selectit\"><input type=\"checkbox\" value=\"" + value.ID + "\" name=\"sp_staff[" + index + "][]\"> " + value.post_title + "</li>" );
1102
+ }
1103
+ );
1104
+ } else {
1105
+ $target.eq( i ).html( "<li>" + localized_strings.no_results_found + "</li>" );
1106
+ }
1107
+ } else {
1108
+ $target.html( "<li>" + localized_strings.no_results_found + "</li>" );
1109
+ }
1110
+ }
1111
+ );
1112
+ }
1113
+ );
1114
+
1115
+ // Event status selector
1116
+ $( '.sp-edit-event-status' ).click(
1117
+ function(e) {
1118
+ e.preventDefault();
1119
+ $select = $( this ).siblings( '.sp-event-status-select' );
1120
+ if ( $select.is( ':hidden' ) ) {
1121
+ $select.slideDown(
1122
+ 'fast',
1123
+ function() {
1124
+ $select.find( 'input[type="radio"]' ).first().focus();
1125
+ }
1126
+ );
1127
+ $( this ).hide();
1128
  }
1129
+ }
1130
+ );
1131
+
1132
+ $( '.sp-save-event-status' ).click(
1133
+ function(e) {
1134
+ e.preventDefault();
1135
+ $select = $( this ).closest( '.sp-event-status-select' );
1136
+ $input = $select.find( 'input[name=sp_status]:checked' );
1137
+ val = $input.val();
1138
+ label = $input.data( 'sp-event-status' );
1139
+ $select.slideUp( 'fast' ).siblings( '.sp-edit-event-status' ).show().siblings( '.sp-event-status' ).find( '.sp-event-status-display' ).data( 'sp-event-status', val ).html( label );
1140
+ }
1141
+ );
1142
+
1143
+ $( '.sp-cancel-event-status' ).click(
1144
+ function(e) {
1145
+ e.preventDefault();
1146
+ $select = $( this ).closest( '.sp-event-status-select' );
1147
+ val = $select.siblings( '.sp-event-status' ).find( '.sp-event-status-display' ).data( 'sp-event-status' );
1148
+ $select.find( 'input[value=' + val + ']' ).attr( 'checked', true );
1149
+ $select.slideUp( 'fast' ).siblings( '.sp-edit-event-status' ).show();
1150
+ }
1151
+ );
1152
+
1153
+ // Box score time converter
1154
+ $( '.sp-convert-time-input' ).change(
1155
+ function() {
1156
+ var s = 0;
1157
+ var val = $( this ).val();
1158
+ if (val === '') {
1159
+ $( this ).siblings( '.sp-convert-time-output' ).val( '' );
1160
+ return;
1161
+ }
1162
+ var a = val.split( ':' ).reverse();
1163
+ $.each(
1164
+ a,
1165
+ function( index, value ) {
1166
+ s += parseInt( value ) * Math.pow( 60, index );
1167
+ }
1168
+ );
1169
+ $( this ).siblings( '.sp-convert-time-output' ).val( s );
1170
+ }
1171
+ );
1172
+
1173
+ // Trigger box score time converter
1174
+ $( '.sp-convert-time-input' ).change();
1175
+
1176
+ // Trigger show/hide of team table ordering
1177
+ $( '#sp_orderby' ).change(
1178
+ function(){
1179
+ if ($( '#sp_orderby' ).val() == 'default') {
1180
+ $( "#sp_order" ).hide();
1181
  } else {
1182
+ $( '#sp_order' ).show();
1183
+ }
1184
+ }
1185
+ );
1186
+ }
1187
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/admin/sportspress-setup.js CHANGED
@@ -1,24 +1,32 @@
1
- jQuery(document).ready(function($){
 
2
 
3
- // Tiptip
4
- $(".sp-tip").tipTip({
5
- delay: 200,
6
- fadeIn: 100,
7
- fadeOut: 100
8
- });
9
- $(".sp-desc-tip").tipTip({
10
- delay: 200,
11
- fadeIn: 100,
12
- fadeOut: 100,
13
- defaultPosition: 'right'
14
- });
 
 
 
 
15
 
16
- // Chosen select
17
- $(".chosen-select, #poststuff #post_author_override").chosen({
18
- allow_single_deselect: true,
19
- search_contains: true,
20
- single_backstroke_delete: false,
21
- disable_search_threshold: 10,
22
- placeholder_text_multiple: localized_strings.none
23
- });
24
- });
 
 
 
1
+ jQuery( document ).ready(
2
+ function($){
3
 
4
+ // Tiptip
5
+ $( ".sp-tip" ).tipTip(
6
+ {
7
+ delay: 200,
8
+ fadeIn: 100,
9
+ fadeOut: 100
10
+ }
11
+ );
12
+ $( ".sp-desc-tip" ).tipTip(
13
+ {
14
+ delay: 200,
15
+ fadeIn: 100,
16
+ fadeOut: 100,
17
+ defaultPosition: 'right'
18
+ }
19
+ );
20
 
21
+ // Chosen select
22
+ $( ".chosen-select, #poststuff #post_author_override" ).chosen(
23
+ {
24
+ allow_single_deselect: true,
25
+ search_contains: true,
26
+ single_backstroke_delete: false,
27
+ disable_search_threshold: 10,
28
+ placeholder_text_multiple: localized_strings.none
29
+ }
30
+ );
31
+ }
32
+ );
assets/js/admin/widgets.js CHANGED
@@ -1,41 +1,60 @@
1
- jQuery(document).ready(function($){
 
2
 
3
- // Orderby affects order select in widget options
4
- $("body").on("change", ".sp-select-orderby", function() {
5
- $(this).closest(".widget-content").find(".sp-select-order").prop("disabled", $(this).val() == "default");
6
- });
 
 
 
 
7
 
8
- // Calendar affects view all link checkbox in widget options
9
- $("body").on("change", ".sp-event-calendar-select", function() {
10
- $el = $(this).closest(".widget-content").find(".sp-event-calendar-show-all-toggle");
11
- if($(this).val() == 0)
12
- $el.hide();
13
- else
14
- $el.show();
15
- });
 
 
 
 
 
16
 
17
- // Show or hide datepicker
18
- $("body").on("change", ".sp-date-selector select", function() {
19
- if ( $(this).val() == "range" ) {
20
- $(this).closest(".sp-date-selector").find(".sp-date-range").show();
21
- } else {
22
- $(this).closest(".sp-date-selector").find(".sp-date-range").hide();
23
- }
24
- });
25
- $(".sp-date-selector select").trigger("change");
 
 
 
 
26
 
27
- // Toggle date range selectors
28
- $("body").on("change", ".sp-date-relative input", function() {
29
- $relative = $(this).closest(".sp-date-relative").siblings(".sp-date-range-relative").toggle(0, $(this).attr("checked"));
30
- $absolute = $(this).closest(".sp-date-relative").siblings(".sp-date-range-absolute").toggle(0, $(this).attr("checked"));
 
 
 
31
 
32
- if ($(this).attr("checked")) {
33
- $relative.show();
34
- $absolute.hide();
35
- } else {
36
- $absolute.show();
37
- $relative.hide();
38
- }
39
- });
40
- $(".sp-date-selector input").trigger("change");
41
- });
 
 
1
+ jQuery( document ).ready(
2
+ function($){
3
 
4
+ // Orderby affects order select in widget options
5
+ $( "body" ).on(
6
+ "change",
7
+ ".sp-select-orderby",
8
+ function() {
9
+ $( this ).closest( ".widget-content" ).find( ".sp-select-order" ).prop( "disabled", $( this ).val() == "default" );
10
+ }
11
+ );
12
 
13
+ // Calendar affects view all link checkbox in widget options
14
+ $( "body" ).on(
15
+ "change",
16
+ ".sp-event-calendar-select",
17
+ function() {
18
+ $el = $( this ).closest( ".widget-content" ).find( ".sp-event-calendar-show-all-toggle" );
19
+ if ($( this ).val() == 0) {
20
+ $el.hide();
21
+ } else {
22
+ $el.show();
23
+ }
24
+ }
25
+ );
26
 
27
+ // Show or hide datepicker
28
+ $( "body" ).on(
29
+ "change",
30
+ ".sp-date-selector select",
31
+ function() {
32
+ if ( $( this ).val() == "range" ) {
33
+ $( this ).closest( ".sp-date-selector" ).find( ".sp-date-range" ).show();
34
+ } else {
35
+ $( this ).closest( ".sp-date-selector" ).find( ".sp-date-range" ).hide();
36
+ }
37
+ }
38
+ );
39
+ $( ".sp-date-selector select" ).trigger( "change" );
40
 
41
+ // Toggle date range selectors
42
+ $( "body" ).on(
43
+ "change",
44
+ ".sp-date-relative input",
45
+ function() {
46
+ $relative = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-relative" ).toggle( 0, $( this ).attr( "checked" ) );
47
+ $absolute = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-absolute" ).toggle( 0, $( this ).attr( "checked" ) );
48
 
49
+ if ($( this ).attr( "checked" )) {
50
+ $relative.show();
51
+ $absolute.hide();
52
+ } else {
53
+ $absolute.show();
54
+ $relative.hide();
55
+ }
56
+ }
57
+ );
58
+ $( ".sp-date-selector input" ).trigger( "change" );
59
+ }
60
+ );
assets/js/blocks/event-calendar.js CHANGED
@@ -1,81 +1,88 @@
1
  import apiFetch from '@wordpress/api-fetch';
2
- console.log(wp.api.collections.Posts());
3
 
4
- wp.blocks.registerBlockType('sportspress/event-calendar', {
5
- title: strings.event_calendar,
6
- icon: 'calendar',
7
- category: 'sportspress',
8
- attributes: {
9
- title: {
10
- type: 'string'
11
- },
12
- id: {
13
- type: 'number'
14
- },
15
- status: {
16
- type: 'string'
17
- },
18
- date: {
19
- type: 'string'
20
- },
21
- date_from: {
22
- type: 'string'
23
- },
24
- date_to: {
25
- type: 'string'
26
- },
27
- date_past: {
28
- type: 'number'
29
- },
30
- date_future: {
31
- type: 'number'
32
- },
33
- date_relative: {
34
- type: 'number'
35
- },
36
- day: {
37
- type: 'string'
38
- },
39
- show_all_events_link: {
40
- type: 'number'
41
- },
 
 
42
 
43
- content: {type: 'string'},
44
- color: {type: 'string'}
45
- },
46
-
47
- edit: function(props) {
48
- function updateContent(event) {
49
- props.setAttributes({content: event.target.value})
50
- }
51
- function updateColor(value) {
52
- props.setAttributes({color: value.hex})
53
- }
54
- return React.createElement(
55
- wp.components.Panel,
56
- {header: strings.event_calendar},
57
- React.createElement(
58
- wp.components.PanelBody,
59
- {title: strings.properties},
60
- React.createElement(
61
- wp.components.TextControl,
62
- {label: strings.title, type: "text", value: props.attributes.title}
63
- ),
64
- React.createElement(
65
- wp.components.SelectControl,
66
- {label: strings.select_calendar, options: [{label: strings.all, value: 0}].concat(posts.events.map(post => {
67
- return {label: post.post_title, value: post.ID}
68
- }))}
69
- )
70
- )
71
- );
72
- },
73
 
74
- save: function(props) {
75
- return wp.element.createElement(
76
- "h3",
77
- { style: { border: "3px solid " + props.attributes.color } },
78
- props.attributes.content
79
- );
80
- }
81
- })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import apiFetch from '@wordpress/api-fetch';
2
+ console.log( wp.api.collections.Posts() );
3
 
4
+ wp.blocks.registerBlockType(
5
+ 'sportspress/event-calendar',
6
+ {
7
+ title: strings.event_calendar,
8
+ icon: 'calendar',
9
+ category: 'sportspress',
10
+ attributes: {
11
+ title: {
12
+ type: 'string'
13
+ },
14
+ id: {
15
+ type: 'number'
16
+ },
17
+ status: {
18
+ type: 'string'
19
+ },
20
+ date: {
21
+ type: 'string'
22
+ },
23
+ date_from: {
24
+ type: 'string'
25
+ },
26
+ date_to: {
27
+ type: 'string'
28
+ },
29
+ date_past: {
30
+ type: 'number'
31
+ },
32
+ date_future: {
33
+ type: 'number'
34
+ },
35
+ date_relative: {
36
+ type: 'number'
37
+ },
38
+ day: {
39
+ type: 'string'
40
+ },
41
+ show_all_events_link: {
42
+ type: 'number'
43
+ },
44
 
45
+ content: {type: 'string'},
46
+ color: {type: 'string'}
47
+ },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
+ edit: function(props) {
50
+ function updateContent(event) {
51
+ props.setAttributes( {content: event.target.value} )
52
+ }
53
+ function updateColor(value) {
54
+ props.setAttributes( {color: value.hex} )
55
+ }
56
+ return React.createElement(
57
+ wp.components.Panel,
58
+ {header: strings.event_calendar},
59
+ React.createElement(
60
+ wp.components.PanelBody,
61
+ {title: strings.properties},
62
+ React.createElement(
63
+ wp.components.TextControl,
64
+ {label: strings.title, type: "text", value: props.attributes.title}
65
+ ),
66
+ React.createElement(
67
+ wp.components.SelectControl,
68
+ {label: strings.select_calendar, options: [{label: strings.all, value: 0}].concat(
69
+ posts.events.map(
70
+ post => {
71
+ return {label: post.post_title, value: post.ID}
72
+ }
73
+ )
74
+ )}
75
+ )
76
+ )
77
+ );
78
+ },
79
+
80
+ save: function(props) {
81
+ return wp.element.createElement(
82
+ "h3",
83
+ { style: { border: "3px solid " + props.attributes.color } },
84
+ props.attributes.content
85
+ );
86
+ }
87
+ }
88
+ )
assets/js/jquery.fitvids.js CHANGED
@@ -11,73 +11,77 @@
11
 
12
  (function( $ ){
13
 
14
- 'use strict';
15
 
16
- $.fn.fitVids = function( options ) {
17
- var settings = {
18
- customSelector: null,
19
- ignore: null
20
- };
21
 
22
- if(!document.getElementById('fit-vids-style')) {
23
- // appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
24
- var head = document.head || document.getElementsByTagName('head')[0];
25
- var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
26
- var div = document.createElement("div");
27
- div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
28
- head.appendChild(div.childNodes[1]);
29
- }
30
 
31
- if ( options ) {
32
- $.extend( settings, options );
33
- }
34
 
35
- return this.each(function(){
36
- var selectors = [
37
- 'iframe[src*="player.vimeo.com"]',
38
- 'iframe[src*="youtube.com"]',
39
- 'iframe[src*="youtube-nocookie.com"]',
40
- 'iframe[src*="kickstarter.com"][src*="video.html"]',
41
- 'object',
42
- 'embed'
43
- ];
 
44
 
45
- if (settings.customSelector) {
46
- selectors.push(settings.customSelector);
47
- }
48
 
49
- var ignoreList = '.fitvidsignore';
50
 
51
- if(settings.ignore) {
52
- ignoreList = ignoreList + ', ' + settings.ignore;
53
- }
54
 
55
- var $allVideos = $(this).find(selectors.join(','));
56
- $allVideos = $allVideos.not('object object'); // SwfObj conflict patch
57
- $allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video.
58
 
59
- $allVideos.each(function(){
60
- var $this = $(this);
61
- if($this.parents(ignoreList).length > 0) {
62
- return; // Disable FitVids on this video.
63
- }
64
- if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
65
- if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
66
- {
67
- $this.attr('height', 9);
68
- $this.attr('width', 16);
69
- }
70
- var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
71
- width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
72
- aspectRatio = height / width;
73
- if(!$this.attr('id')){
74
- var videoID = 'fitvid' + Math.floor(Math.random()*999999);
75
- $this.attr('id', videoID);
76
- }
77
- $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
78
- $this.removeAttr('height').removeAttr('width');
79
- });
80
- });
81
- };
82
- // Works with either jQuery or Zepto
 
 
 
83
  })( window.jQuery || window.Zepto );
11
 
12
  (function( $ ){
13
 
14
+ 'use strict';
15
 
16
+ $.fn.fitVids = function( options ) {
17
+ var settings = {
18
+ customSelector: null,
19
+ ignore: null
20
+ };
21
 
22
+ if ( ! document.getElementById( 'fit-vids-style' )) {
23
+ // appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
24
+ var head = document.head || document.getElementsByTagName( 'head' )[0];
25
+ var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
26
+ var div = document.createElement( "div" );
27
+ div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
28
+ head.appendChild( div.childNodes[1] );
29
+ }
30
 
31
+ if ( options ) {
32
+ $.extend( settings, options );
33
+ }
34
 
35
+ return this.each(
36
+ function(){
37
+ var selectors = [
38
+ 'iframe[src*="player.vimeo.com"]',
39
+ 'iframe[src*="youtube.com"]',
40
+ 'iframe[src*="youtube-nocookie.com"]',
41
+ 'iframe[src*="kickstarter.com"][src*="video.html"]',
42
+ 'object',
43
+ 'embed'
44
+ ];
45
 
46
+ if (settings.customSelector) {
47
+ selectors.push( settings.customSelector );
48
+ }
49
 
50
+ var ignoreList = '.fitvidsignore';
51
 
52
+ if (settings.ignore) {
53
+ ignoreList = ignoreList + ', ' + settings.ignore;
54
+ }
55
 
56
+ var $allVideos = $( this ).find( selectors.join( ',' ) );
57
+ $allVideos = $allVideos.not( 'object object' ); // SwfObj conflict patch
58
+ $allVideos = $allVideos.not( ignoreList ); // Disable FitVids on this video.
59
 
60
+ $allVideos.each(
61
+ function(){
62
+ var $this = $( this );
63
+ if ($this.parents( ignoreList ).length > 0) {
64
+ return; // Disable FitVids on this video.
65
+ }
66
+ if (this.tagName.toLowerCase() === 'embed' && $this.parent( 'object' ).length || $this.parent( '.fluid-width-video-wrapper' ).length) {
67
+ return; }
68
+ if (( ! $this.css( 'height' ) && ! $this.css( 'width' )) && (isNaN( $this.attr( 'height' ) ) || isNaN( $this.attr( 'width' ) ))) {
69
+ $this.attr( 'height', 9 );
70
+ $this.attr( 'width', 16 );
71
+ }
72
+ var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr( 'height' ) && ! isNaN( parseInt( $this.attr( 'height' ), 10 ) )) ) ? parseInt( $this.attr( 'height' ), 10 ) : $this.height(),
73
+ width = ! isNaN( parseInt( $this.attr( 'width' ), 10 ) ) ? parseInt( $this.attr( 'width' ), 10 ) : $this.width(),
74
+ aspectRatio = height / width;
75
+ if ( ! $this.attr( 'id' )) {
76
+ var videoID = 'fitvid' + Math.floor( Math.random() * 999999 );
77
+ $this.attr( 'id', videoID );
78
+ }
79
+ $this.wrap( '<div class="fluid-width-video-wrapper"></div>' ).parent( '.fluid-width-video-wrapper' ).css( 'padding-top', (aspectRatio * 100) + '%' );
80
+ $this.removeAttr( 'height' ).removeAttr( 'width' );
81
+ }
82
+ );
83
+ }
84
+ );
85
+ };
86
+ // Works with either jQuery or Zepto
87
  })( window.jQuery || window.Zepto );
assets/js/leaflet.js CHANGED
@@ -2,5 +2,5 @@
2
  * Leaflet 1.7.1, a JS library for interactive maps. http://leafletjs.com
3
  * (c) 2010-2019 Vladimir Agafonkin, (c) 2010-2011 CloudMade
4
  */
5
- !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.L={})}(this,function(t){"use strict";function h(t){for(var i,e,n=1,o=arguments.length;n<o;n++)for(i in e=arguments[n])t[i]=e[i];return t}var s=Object.create||function(t){return i.prototype=t,new i};function i(){}function p(t,i){var e=Array.prototype.slice;if(t.bind)return t.bind.apply(t,e.call(arguments,1));var n=e.call(arguments,2);return function(){return t.apply(i,n.length?n.concat(e.call(arguments)):arguments)}}var e=0;function m(t){return t._leaflet_id=t._leaflet_id||++e,t._leaflet_id}function n(t,i,e){var n,o,s=function(){n=!1,o&&(r.apply(e,o),o=!1)},r=function(){n?o=arguments:(t.apply(e,arguments),setTimeout(s,i),n=!0)};return r}function o(t,i,e){var n=i[1],o=i[0],s=n-o;return t===n&&e?t:((t-o)%s+s)%s+o}function a(){return!1}function r(t,i){var e=Math.pow(10,void 0===i?6:i);return Math.round(t*e)/e}function u(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function l(t){return u(t).split(/\s+/)}function c(t,i){for(var e in Object.prototype.hasOwnProperty.call(t,"options")||(t.options=t.options?s(t.options):{}),i)t.options[e]=i[e];return t.options}function _(t,i,e){var n=[];for(var o in t)n.push(encodeURIComponent(e?o.toUpperCase():o)+"="+encodeURIComponent(t[o]));return(i&&-1!==i.indexOf("?")?"&":"?")+n.join("&")}var d=/\{ *([\w_-]+) *\}/g;function f(t,n){return t.replace(d,function(t,i){var e=n[i];if(void 0===e)throw new Error("No value provided for variable "+t);return"function"==typeof e&&(e=e(n)),e})}var g=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function v(t,i){for(var e=0;e<t.length;e++)if(t[e]===i)return e;return-1}var y="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function x(t){return window["webkit"+t]||window["moz"+t]||window["ms"+t]}var w=0;function P(t){var i=+new Date,e=Math.max(0,16-(i-w));return w=i+e,window.setTimeout(t,e)}var b=window.requestAnimationFrame||x("RequestAnimationFrame")||P,T=window.cancelAnimationFrame||x("CancelAnimationFrame")||x("CancelRequestAnimationFrame")||function(t){window.clearTimeout(t)};function M(t,i,e){if(!e||b!==P)return b.call(window,p(t,i));t.call(i)}function z(t){t&&T.call(window,t)}var C={extend:h,create:s,bind:p,lastId:e,stamp:m,throttle:n,wrapNum:o,falseFn:a,formatNum:r,trim:u,splitWords:l,setOptions:c,getParamString:_,template:f,isArray:g,indexOf:v,emptyImageUrl:y,requestFn:b,cancelFn:T,requestAnimFrame:M,cancelAnimFrame:z};function S(){}S.extend=function(t){function i(){this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()}var e=i.__super__=this.prototype,n=s(e);for(var o in(n.constructor=i).prototype=n,this)Object.prototype.hasOwnProperty.call(this,o)&&"prototype"!==o&&"__super__"!==o&&(i[o]=this[o]);return t.statics&&(h(i,t.statics),delete t.statics),t.includes&&(function(t){if("undefined"==typeof L||!L||!L.Mixin)return;t=g(t)?t:[t];for(var i=0;i<t.length;i++)t[i]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",(new Error).stack)}(t.includes),h.apply(null,[n].concat(t.includes)),delete t.includes),n.options&&(t.options=h(s(n.options),t.options)),h(n,t),n._initHooks=[],n.callInitHooks=function(){if(!this._initHooksCalled){e.callInitHooks&&e.callInitHooks.call(this),this._initHooksCalled=!0;for(var t=0,i=n._initHooks.length;t<i;t++)n._initHooks[t].call(this)}},i},S.include=function(t){return h(this.prototype,t),this},S.mergeOptions=function(t){return h(this.prototype.options,t),this},S.addInitHook=function(t){var i=Array.prototype.slice.call(arguments,1),e="function"==typeof t?t:function(){this[t].apply(this,i)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(e),this};var Z={on:function(t,i,e){if("object"==typeof t)for(var n in t)this._on(n,t[n],i);else for(var o=0,s=(t=l(t)).length;o<s;o++)this._on(t[o],i,e);return this},off:function(t,i,e){if(t)if("object"==typeof t)for(var n in t)this._off(n,t[n],i);else for(var o=0,s=(t=l(t)).length;o<s;o++)this._off(t[o],i,e);else delete this._events;return this},_on:function(t,i,e){this._events=this._events||{};var n=this._events[t];n||(n=[],this._events[t]=n),e===this&&(e=void 0);for(var o={fn:i,ctx:e},s=n,r=0,a=s.length;r<a;r++)if(s[r].fn===i&&s[r].ctx===e)return;s.push(o)},_off:function(t,i,e){var n,o,s;if(this._events&&(n=this._events[t]))if(i){if(e===this&&(e=void 0),n)for(o=0,s=n.length;o<s;o++){var r=n[o];if(r.ctx===e&&r.fn===i)return r.fn=a,this._firingCount&&(this._events[t]=n=n.slice()),void n.splice(o,1)}}else{for(o=0,s=n.length;o<s;o++)n[o].fn=a;delete this._events[t]}},fire:function(t,i,e){if(!this.listens(t,e))return this;var n=h({},i,{type:t,target:this,sourceTarget:i&&i.sourceTarget||this});if(this._events){var o=this._events[t];if(o){this._firingCount=this._firingCount+1||1;for(var s=0,r=o.length;s<r;s++){var a=o[s];a.fn.call(a.ctx||this,n)}this._firingCount--}}return e&&this._propagateEvent(n),this},listens:function(t,i){var e=this._events&&this._events[t];if(e&&e.length)return!0;if(i)for(var n in this._eventParents)if(this._eventParents[n].listens(t,i))return!0;return!1},once:function(t,i,e){if("object"==typeof t){for(var n in t)this.once(n,t[n],i);return this}var o=p(function(){this.off(t,i,e).off(t,o,e)},this);return this.on(t,i,e).on(t,o,e)},addEventParent:function(t){return this._eventParents=this._eventParents||{},this._eventParents[m(t)]=t,this},removeEventParent:function(t){return this._eventParents&&delete this._eventParents[m(t)],this},_propagateEvent:function(t){for(var i in this._eventParents)this._eventParents[i].fire(t.type,h({layer:t.target,propagatedFrom:t.target},t),!0)}};Z.addEventListener=Z.on,Z.removeEventListener=Z.clearAllEventListeners=Z.off,Z.addOneTimeEventListener=Z.once,Z.fireEvent=Z.fire,Z.hasEventListeners=Z.listens;var E=S.extend(Z);function k(t,i,e){this.x=e?Math.round(t):t,this.y=e?Math.round(i):i}var B=Math.trunc||function(t){return 0<t?Math.floor(t):Math.ceil(t)};function A(t,i,e){return t instanceof k?t:g(t)?new k(t[0],t[1]):null==t?t:"object"==typeof t&&"x"in t&&"y"in t?new k(t.x,t.y):new k(t,i,e)}function I(t,i){if(t)for(var e=i?[t,i]:t,n=0,o=e.length;n<o;n++)this.extend(e[n])}function O(t,i){return!t||t instanceof I?t:new I(t,i)}function R(t,i){if(t)for(var e=i?[t,i]:t,n=0,o=e.length;n<o;n++)this.extend(e[n])}function N(t,i){return t instanceof R?t:new R(t,i)}function D(t,i,e){if(isNaN(t)||isNaN(i))throw new Error("Invalid LatLng object: ("+t+", "+i+")");this.lat=+t,this.lng=+i,void 0!==e&&(this.alt=+e)}function j(t,i,e){return t instanceof D?t:g(t)&&"object"!=typeof t[0]?3===t.length?new D(t[0],t[1],t[2]):2===t.length?new D(t[0],t[1]):null:null==t?t:"object"==typeof t&&"lat"in t?new D(t.lat,"lng"in t?t.lng:t.lon,t.alt):void 0===i?null:new D(t,i,e)}k.prototype={clone:function(){return new k(this.x,this.y)},add:function(t){return this.clone()._add(A(t))},_add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.clone()._subtract(A(t))},_subtract:function(t){return this.x-=t.x,this.y-=t.y,this},divideBy:function(t){return this.clone()._divideBy(t)},_divideBy:function(t){return this.x/=t,this.y/=t,this},multiplyBy:function(t){return this.clone()._multiplyBy(t)},_multiplyBy:function(t){return this.x*=t,this.y*=t,this},scaleBy:function(t){return new k(this.x*t.x,this.y*t.y)},unscaleBy:function(t){return new k(this.x/t.x,this.y/t.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=B(this.x),this.y=B(this.y),this},distanceTo:function(t){var i=(t=A(t)).x-this.x,e=t.y-this.y;return Math.sqrt(i*i+e*e)},equals:function(t){return(t=A(t)).x===this.x&&t.y===this.y},contains:function(t){return t=A(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)},toString:function(){return"Point("+r(this.x)+", "+r(this.y)+")"}},I.prototype={extend:function(t){return t=A(t),this.min||this.max?(this.min.x=Math.min(t.x,this.min.x),this.max.x=Math.max(t.x,this.max.x),this.min.y=Math.min(t.y,this.min.y),this.max.y=Math.max(t.y,this.max.y)):(this.min=t.clone(),this.max=t.clone()),this},getCenter:function(t){return new k((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,t)},getBottomLeft:function(){return new k(this.min.x,this.max.y)},getTopRight:function(){return new k(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(t){var i,e;return(t=("number"==typeof t[0]||t instanceof k?A:O)(t))instanceof I?(i=t.min,e=t.max):i=e=t,i.x>=this.min.x&&e.x<=this.max.x&&i.y>=this.min.y&&e.y<=this.max.y},intersects:function(t){t=O(t);var i=this.min,e=this.max,n=t.min,o=t.max,s=o.x>=i.x&&n.x<=e.x,r=o.y>=i.y&&n.y<=e.y;return s&&r},overlaps:function(t){t=O(t);var i=this.min,e=this.max,n=t.min,o=t.max,s=o.x>i.x&&n.x<e.x,r=o.y>i.y&&n.y<e.y;return s&&r},isValid:function(){return!(!this.min||!this.max)}},R.prototype={extend:function(t){var i,e,n=this._southWest,o=this._northEast;if(t instanceof D)e=i=t;else{if(!(t instanceof R))return t?this.extend(j(t)||N(t)):this;if(i=t._southWest,e=t._northEast,!i||!e)return this}return n||o?(n.lat=Math.min(i.lat,n.lat),n.lng=Math.min(i.lng,n.lng),o.lat=Math.max(e.lat,o.lat),o.lng=Math.max(e.lng,o.lng)):(this._southWest=new D(i.lat,i.lng),this._northEast=new D(e.lat,e.lng)),this},pad:function(t){var i=this._southWest,e=this._northEast,n=Math.abs(i.lat-e.lat)*t,o=Math.abs(i.lng-e.lng)*t;return new R(new D(i.lat-n,i.lng-o),new D(e.lat+n,e.lng+o))},getCenter:function(){return new D((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new D(this.getNorth(),this.getWest())},getSouthEast:function(){return new D(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(t){t=("number"==typeof t[0]||t instanceof D||"lat"in t?j:N)(t);var i,e,n=this._southWest,o=this._northEast;return t instanceof R?(i=t.getSouthWest(),e=t.getNorthEast()):i=e=t,i.lat>=n.lat&&e.lat<=o.lat&&i.lng>=n.lng&&e.lng<=o.lng},intersects:function(t){t=N(t);var i=this._southWest,e=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>=i.lat&&n.lat<=e.lat,r=o.lng>=i.lng&&n.lng<=e.lng;return s&&r},overlaps:function(t){t=N(t);var i=this._southWest,e=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>i.lat&&n.lat<e.lat,r=o.lng>i.lng&&n.lng<e.lng;return s&&r},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(t,i){return!!t&&(t=N(t),this._southWest.equals(t.getSouthWest(),i)&&this._northEast.equals(t.getNorthEast(),i))},isValid:function(){return!(!this._southWest||!this._northEast)}};var W,H={latLngToPoint:function(t,i){var e=this.projection.project(t),n=this.scale(i);return this.transformation._transform(e,n)},pointToLatLng:function(t,i){var e=this.scale(i),n=this.transformation.untransform(t,e);return this.projection.unproject(n)},project:function(t){return this.projection.project(t)},unproject:function(t){return this.projection.unproject(t)},scale:function(t){return 256*Math.pow(2,t)},zoom:function(t){return Math.log(t/256)/Math.LN2},getProjectedBounds:function(t){if(this.infinite)return null;var i=this.projection.bounds,e=this.scale(t);return new I(this.transformation.transform(i.min,e),this.transformation.transform(i.max,e))},infinite:!(D.prototype={equals:function(t,i){return!!t&&(t=j(t),Math.max(Math.abs(this.lat-t.lat),Math.abs(this.lng-t.lng))<=(void 0===i?1e-9:i))},toString:function(t){return"LatLng("+r(this.lat,t)+", "+r(this.lng,t)+")"},distanceTo:function(t){return F.distance(this,j(t))},wrap:function(){return F.wrapLatLng(this)},toBounds:function(t){var i=180*t/40075017,e=i/Math.cos(Math.PI/180*this.lat);return N([this.lat-i,this.lng-e],[this.lat+i,this.lng+e])},clone:function(){return new D(this.lat,this.lng,this.alt)}}),wrapLatLng:function(t){var i=this.wrapLng?o(t.lng,this.wrapLng,!0):t.lng;return new D(this.wrapLat?o(t.lat,this.wrapLat,!0):t.lat,i,t.alt)},wrapLatLngBounds:function(t){var i=t.getCenter(),e=this.wrapLatLng(i),n=i.lat-e.lat,o=i.lng-e.lng;if(0==n&&0==o)return t;var s=t.getSouthWest(),r=t.getNorthEast();return new R(new D(s.lat-n,s.lng-o),new D(r.lat-n,r.lng-o))}},F=h({},H,{wrapLng:[-180,180],R:6371e3,distance:function(t,i){var e=Math.PI/180,n=t.lat*e,o=i.lat*e,s=Math.sin((i.lat-t.lat)*e/2),r=Math.sin((i.lng-t.lng)*e/2),a=s*s+Math.cos(n)*Math.cos(o)*r*r,h=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));return this.R*h}}),U=6378137,V={R:U,MAX_LATITUDE:85.0511287798,project:function(t){var i=Math.PI/180,e=this.MAX_LATITUDE,n=Math.max(Math.min(e,t.lat),-e),o=Math.sin(n*i);return new k(this.R*t.lng*i,this.R*Math.log((1+o)/(1-o))/2)},unproject:function(t){var i=180/Math.PI;return new D((2*Math.atan(Math.exp(t.y/this.R))-Math.PI/2)*i,t.x*i/this.R)},bounds:new I([-(W=U*Math.PI),-W],[W,W])};function q(t,i,e,n){if(g(t))return this._a=t[0],this._b=t[1],this._c=t[2],void(this._d=t[3]);this._a=t,this._b=i,this._c=e,this._d=n}function G(t,i,e,n){return new q(t,i,e,n)}q.prototype={transform:function(t,i){return this._transform(t.clone(),i)},_transform:function(t,i){return i=i||1,t.x=i*(this._a*t.x+this._b),t.y=i*(this._c*t.y+this._d),t},untransform:function(t,i){return i=i||1,new k((t.x/i-this._b)/this._a,(t.y/i-this._d)/this._c)}};var K,Y=h({},F,{code:"EPSG:3857",projection:V,transformation:G(K=.5/(Math.PI*V.R),.5,-K,.5)}),X=h({},Y,{code:"EPSG:900913"});function J(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function $(t,i){for(var e,n,o,s,r="",a=0,h=t.length;a<h;a++){for(e=0,n=(o=t[a]).length;e<n;e++)r+=(e?"L":"M")+(s=o[e]).x+" "+s.y;r+=i?Zt?"z":"x":""}return r||"M0 0"}var Q=document.documentElement.style,tt="ActiveXObject"in window,it=tt&&!document.addEventListener,et="msLaunchUri"in navigator&&!("documentMode"in document),nt=kt("webkit"),ot=kt("android"),st=kt("android 2")||kt("android 3"),rt=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),at=ot&&kt("Google")&&rt<537&&!("AudioNode"in window),ht=!!window.opera,ut=!et&&kt("chrome"),lt=kt("gecko")&&!nt&&!ht&&!tt,ct=!ut&&kt("safari"),_t=kt("phantom"),dt="OTransition"in Q,pt=0===navigator.platform.indexOf("Win"),mt=tt&&"transition"in Q,ft="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!st,gt="MozPerspective"in Q,vt=!window.L_DISABLE_3D&&(mt||ft||gt)&&!dt&&!_t,yt="undefined"!=typeof orientation||kt("mobile"),xt=yt&&nt,wt=yt&&ft,Pt=!window.PointerEvent&&window.MSPointerEvent,Lt=!(!window.PointerEvent&&!Pt),bt=!window.L_NO_TOUCH&&(Lt||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch),Tt=yt&&ht,Mt=yt&&lt,zt=1<(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI),Ct=function(){var t=!1;try{var i=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassiveEventSupport",a,i),window.removeEventListener("testPassiveEventSupport",a,i)}catch(t){}return t}(),St=!!document.createElement("canvas").getContext,Zt=!(!document.createElementNS||!J("svg").createSVGRect),Et=!Zt&&function(){try{var t=document.createElement("div");t.innerHTML='<v:shape adj="1"/>';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(t){return!1}}();function kt(t){return 0<=navigator.userAgent.toLowerCase().indexOf(t)}var Bt={ie:tt,ielt9:it,edge:et,webkit:nt,android:ot,android23:st,androidStock:at,opera:ht,chrome:ut,gecko:lt,safari:ct,phantom:_t,opera12:dt,win:pt,ie3d:mt,webkit3d:ft,gecko3d:gt,any3d:vt,mobile:yt,mobileWebkit:xt,mobileWebkit3d:wt,msPointer:Pt,pointer:Lt,touch:bt,mobileOpera:Tt,mobileGecko:Mt,retina:zt,passiveEvents:Ct,canvas:St,svg:Zt,vml:Et},At=Pt?"MSPointerDown":"pointerdown",It=Pt?"MSPointerMove":"pointermove",Ot=Pt?"MSPointerUp":"pointerup",Rt=Pt?"MSPointerCancel":"pointercancel",Nt={},Dt=!1;function jt(t,i,e,n){function o(t){Ut(t,r)}var s,r,a,h,u,l,c,_;function d(t){t.pointerType===(t.MSPOINTER_TYPE_MOUSE||"mouse")&&0===t.buttons||Ut(t,h)}return"touchstart"===i?(u=t,l=e,c=n,_=p(function(t){t.MSPOINTER_TYPE_TOUCH&&t.pointerType===t.MSPOINTER_TYPE_TOUCH&&Ri(t),Ut(t,l)}),u["_leaflet_touchstart"+c]=_,u.addEventListener(At,_,!1),Dt||(document.addEventListener(At,Wt,!0),document.addEventListener(It,Ht,!0),document.addEventListener(Ot,Ft,!0),document.addEventListener(Rt,Ft,!0),Dt=!0)):"touchmove"===i?(h=e,(a=t)["_leaflet_touchmove"+n]=d,a.addEventListener(It,d,!1)):"touchend"===i&&(r=e,(s=t)["_leaflet_touchend"+n]=o,s.addEventListener(Ot,o,!1),s.addEventListener(Rt,o,!1)),this}function Wt(t){Nt[t.pointerId]=t}function Ht(t){Nt[t.pointerId]&&(Nt[t.pointerId]=t)}function Ft(t){delete Nt[t.pointerId]}function Ut(t,i){for(var e in t.touches=[],Nt)t.touches.push(Nt[e]);t.changedTouches=[t],i(t)}var Vt=Pt?"MSPointerDown":Lt?"pointerdown":"touchstart",qt=Pt?"MSPointerUp":Lt?"pointerup":"touchend",Gt="_leaflet_";var Kt,Yt,Xt,Jt,$t,Qt,ti=fi(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),ii=fi(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),ei="webkitTransition"===ii||"OTransition"===ii?ii+"End":"transitionend";function ni(t){return"string"==typeof t?document.getElementById(t):t}function oi(t,i){var e,n=t.style[i]||t.currentStyle&&t.currentStyle[i];return n&&"auto"!==n||!document.defaultView||(n=(e=document.defaultView.getComputedStyle(t,null))?e[i]:null),"auto"===n?null:n}function si(t,i,e){var n=document.createElement(t);return n.className=i||"",e&&e.appendChild(n),n}function ri(t){var i=t.parentNode;i&&i.removeChild(t)}function ai(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function hi(t){var i=t.parentNode;i&&i.lastChild!==t&&i.appendChild(t)}function ui(t){var i=t.parentNode;i&&i.firstChild!==t&&i.insertBefore(t,i.firstChild)}function li(t,i){if(void 0!==t.classList)return t.classList.contains(i);var e=pi(t);return 0<e.length&&new RegExp("(^|\\s)"+i+"(\\s|$)").test(e)}function ci(t,i){var e;if(void 0!==t.classList)for(var n=l(i),o=0,s=n.length;o<s;o++)t.classList.add(n[o]);else li(t,i)||di(t,((e=pi(t))?e+" ":"")+i)}function _i(t,i){void 0!==t.classList?t.classList.remove(i):di(t,u((" "+pi(t)+" ").replace(" "+i+" "," ")))}function di(t,i){void 0===t.className.baseVal?t.className=i:t.className.baseVal=i}function pi(t){return t.correspondingElement&&(t=t.correspondingElement),void 0===t.className.baseVal?t.className:t.className.baseVal}function mi(t,i){"opacity"in t.style?t.style.opacity=i:"filter"in t.style&&function(t,i){var e=!1,n="DXImageTransform.Microsoft.Alpha";try{e=t.filters.item(n)}catch(t){if(1===i)return}i=Math.round(100*i),e?(e.Enabled=100!==i,e.Opacity=i):t.style.filter+=" progid:"+n+"(opacity="+i+")"}(t,i)}function fi(t){for(var i=document.documentElement.style,e=0;e<t.length;e++)if(t[e]in i)return t[e];return!1}function gi(t,i,e){var n=i||new k(0,0);t.style[ti]=(mt?"translate("+n.x+"px,"+n.y+"px)":"translate3d("+n.x+"px,"+n.y+"px,0)")+(e?" scale("+e+")":"")}function vi(t,i){t._leaflet_pos=i,vt?gi(t,i):(t.style.left=i.x+"px",t.style.top=i.y+"px")}function yi(t){return t._leaflet_pos||new k(0,0)}function xi(){zi(window,"dragstart",Ri)}function wi(){Si(window,"dragstart",Ri)}function Pi(t){for(;-1===t.tabIndex;)t=t.parentNode;t.style&&(Li(),Qt=($t=t).style.outline,t.style.outline="none",zi(window,"keydown",Li))}function Li(){$t&&($t.style.outline=Qt,Qt=$t=void 0,Si(window,"keydown",Li))}function bi(t){for(;!((t=t.parentNode).offsetWidth&&t.offsetHeight||t===document.body););return t}function Ti(t){var i=t.getBoundingClientRect();return{x:i.width/t.offsetWidth||1,y:i.height/t.offsetHeight||1,boundingClientRect:i}}Jt="onselectstart"in document?(Xt=function(){zi(window,"selectstart",Ri)},function(){Si(window,"selectstart",Ri)}):(Yt=fi(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]),Xt=function(){var t;Yt&&(t=document.documentElement.style,Kt=t[Yt],t[Yt]="none")},function(){Yt&&(document.documentElement.style[Yt]=Kt,Kt=void 0)});var Mi={TRANSFORM:ti,TRANSITION:ii,TRANSITION_END:ei,get:ni,getStyle:oi,create:si,remove:ri,empty:ai,toFront:hi,toBack:ui,hasClass:li,addClass:ci,removeClass:_i,setClass:di,getClass:pi,setOpacity:mi,testProp:fi,setTransform:gi,setPosition:vi,getPosition:yi,disableTextSelection:Xt,enableTextSelection:Jt,disableImageDrag:xi,enableImageDrag:wi,preventOutline:Pi,restoreOutline:Li,getSizedParentNode:bi,getScale:Ti};function zi(t,i,e,n){if("object"==typeof i)for(var o in i)ki(t,o,i[o],e);else for(var s=0,r=(i=l(i)).length;s<r;s++)ki(t,i[s],e,n);return this}var Ci="_leaflet_events";function Si(t,i,e,n){if("object"==typeof i)for(var o in i)Bi(t,o,i[o],e);else if(i)for(var s=0,r=(i=l(i)).length;s<r;s++)Bi(t,i[s],e,n);else{for(var a in t[Ci])Bi(t,a,t[Ci][a]);delete t[Ci]}return this}function Zi(){return Lt&&(!et&&!ct)}var Ei={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function ki(i,t,e,n){var o=t+m(e)+(n?"_"+m(n):"");if(i[Ci]&&i[Ci][o])return this;var s,r,a,h,u,l,c=function(t){return e.call(n||i,t||window.event)},_=c;function d(t){if(Lt){if(!t.isPrimary)return;if("mouse"===t.pointerType)return}else if(1<t.touches.length)return;var i=Date.now(),e=i-(h||i);u=t.touches?t.touches[0]:t,l=0<e&&e<=250,h=i}function p(t){if(l&&!u.cancelBubble){if(Lt){if("mouse"===t.pointerType)return;var i,e,n={};for(e in u)i=u[e],n[e]=i&&i.bind?i.bind(u):i;u=n}u.type="dblclick",u.button=0,r(u),h=null}}Lt&&0===t.indexOf("touch")?jt(i,t,c,o):bt&&"dblclick"===t&&!Zi()?(r=c,l=!1,(s=i)[Gt+Vt+(a=o)]=d,s[Gt+qt+a]=p,s[Gt+"dblclick"+a]=r,s.addEventListener(Vt,d,!!Ct&&{passive:!1}),s.addEventListener(qt,p,!!Ct&&{passive:!1}),s.addEventListener("dblclick",r,!1)):"addEventListener"in i?"touchstart"===t||"touchmove"===t||"wheel"===t||"mousewheel"===t?i.addEventListener(Ei[t]||t,c,!!Ct&&{passive:!1}):"mouseenter"===t||"mouseleave"===t?(c=function(t){t=t||window.event,Vi(i,t)&&_(t)},i.addEventListener(Ei[t],c,!1)):i.addEventListener(t,_,!1):"attachEvent"in i&&i.attachEvent("on"+t,c),i[Ci]=i[Ci]||{},i[Ci][o]=c}function Bi(t,i,e,n){var o,s,r,a,h,u,l,c,_=i+m(e)+(n?"_"+m(n):""),d=t[Ci]&&t[Ci][_];if(!d)return this;Lt&&0===i.indexOf("touch")?(c=(u=t)["_leaflet_"+(l=i)+_],"touchstart"===l?u.removeEventListener(At,c,!1):"touchmove"===l?u.removeEventListener(It,c,!1):"touchend"===l&&(u.removeEventListener(Ot,c,!1),u.removeEventListener(Rt,c,!1))):bt&&"dblclick"===i&&!Zi()?(r=(o=t)[Gt+Vt+(s=_)],a=o[Gt+qt+s],h=o[Gt+"dblclick"+s],o.removeEventListener(Vt,r,!!Ct&&{passive:!1}),o.removeEventListener(qt,a,!!Ct&&{passive:!1}),o.removeEventListener("dblclick",h,!1)):"removeEventListener"in t?t.removeEventListener(Ei[i]||i,d,!1):"detachEvent"in t&&t.detachEvent("on"+i,d),t[Ci][_]=null}function Ai(t){return t.stopPropagation?t.stopPropagation():t.originalEvent?t.originalEvent._stopped=!0:t.cancelBubble=!0,Ui(t),this}function Ii(t){return ki(t,"wheel",Ai),this}function Oi(t){return zi(t,"mousedown touchstart dblclick",Ai),ki(t,"click",Fi),this}function Ri(t){return t.preventDefault?t.preventDefault():t.returnValue=!1,this}function Ni(t){return Ri(t),Ai(t),this}function Di(t,i){if(!i)return new k(t.clientX,t.clientY);var e=Ti(i),n=e.boundingClientRect;return new k((t.clientX-n.left)/e.x-i.clientLeft,(t.clientY-n.top)/e.y-i.clientTop)}var ji=pt&&ut?2*window.devicePixelRatio:lt?window.devicePixelRatio:1;function Wi(t){return et?t.wheelDeltaY/2:t.deltaY&&0===t.deltaMode?-t.deltaY/ji:t.deltaY&&1===t.deltaMode?20*-t.deltaY:t.deltaY&&2===t.deltaMode?60*-t.deltaY:t.deltaX||t.deltaZ?0:t.wheelDelta?(t.wheelDeltaY||t.wheelDelta)/2:t.detail&&Math.abs(t.detail)<32765?20*-t.detail:t.detail?t.detail/-32765*60:0}var Hi={};function Fi(t){Hi[t.type]=!0}function Ui(t){var i=Hi[t.type];return Hi[t.type]=!1,i}function Vi(t,i){var e=i.relatedTarget;if(!e)return!0;try{for(;e&&e!==t;)e=e.parentNode}catch(t){return!1}return e!==t}var qi={on:zi,off:Si,stopPropagation:Ai,disableScrollPropagation:Ii,disableClickPropagation:Oi,preventDefault:Ri,stop:Ni,getMousePosition:Di,getWheelDelta:Wi,fakeStop:Fi,skipped:Ui,isExternalTarget:Vi,addListener:zi,removeListener:Si},Gi=E.extend({run:function(t,i,e,n){this.stop(),this._el=t,this._inProgress=!0,this._duration=e||.25,this._easeOutPower=1/Math.max(n||.5,.2),this._startPos=yi(t),this._offset=i.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=M(this._animate,this),this._step()},_step:function(t){var i=new Date-this._startTime,e=1e3*this._duration;i<e?this._runFrame(this._easeOut(i/e),t):(this._runFrame(1),this._complete())},_runFrame:function(t,i){var e=this._startPos.add(this._offset.multiplyBy(t));i&&e._round(),vi(this._el,e),this.fire("step")},_complete:function(){z(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(t){return 1-Math.pow(1-t,this._easeOutPower)}}),Ki=E.extend({options:{crs:Y,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(t,i){i=c(this,i),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(t),this._initLayout(),this._onResize=p(this._onResize,this),this._initEvents(),i.maxBounds&&this.setMaxBounds(i.maxBounds),void 0!==i.zoom&&(this._zoom=this._limitZoom(i.zoom)),i.center&&void 0!==i.zoom&&this.setView(j(i.center),i.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=ii&&vt&&!Tt&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),zi(this._proxy,ei,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(t,i,e){if((i=void 0===i?this._zoom:this._limitZoom(i),t=this._limitCenter(j(t),i,this.options.maxBounds),e=e||{},this._stop(),this._loaded&&!e.reset&&!0!==e)&&(void 0!==e.animate&&(e.zoom=h({animate:e.animate},e.zoom),e.pan=h({animate:e.animate,duration:e.duration},e.pan)),this._zoom!==i?this._tryAnimatedZoom&&this._tryAnimatedZoom(t,i,e.zoom):this._tryAnimatedPan(t,e.pan)))return clearTimeout(this._sizeTimer),this;return this._resetView(t,i),this},setZoom:function(t,i){return this._loaded?this.setView(this.getCenter(),t,{zoom:i}):(this._zoom=t,this)},zoomIn:function(t,i){return t=t||(vt?this.options.zoomDelta:1),this.setZoom(this._zoom+t,i)},zoomOut:function(t,i){return t=t||(vt?this.options.zoomDelta:1),this.setZoom(this._zoom-t,i)},setZoomAround:function(t,i,e){var n=this.getZoomScale(i),o=this.getSize().divideBy(2),s=(t instanceof k?t:this.latLngToContainerPoint(t)).subtract(o).multiplyBy(1-1/n),r=this.containerPointToLatLng(o.add(s));return this.setView(r,i,{zoom:e})},_getBoundsCenterZoom:function(t,i){i=i||{},t=t.getBounds?t.getBounds():N(t);var e=A(i.paddingTopLeft||i.padding||[0,0]),n=A(i.paddingBottomRight||i.padding||[0,0]),o=this.getBoundsZoom(t,!1,e.add(n));if((o="number"==typeof i.maxZoom?Math.min(i.maxZoom,o):o)===1/0)return{center:t.getCenter(),zoom:o};var s=n.subtract(e).divideBy(2),r=this.project(t.getSouthWest(),o),a=this.project(t.getNorthEast(),o);return{center:this.unproject(r.add(a).divideBy(2).add(s),o),zoom:o}},fitBounds:function(t,i){if(!(t=N(t)).isValid())throw new Error("Bounds are not valid.");var e=this._getBoundsCenterZoom(t,i);return this.setView(e.center,e.zoom,i)},fitWorld:function(t){return this.fitBounds([[-90,-180],[90,180]],t)},panTo:function(t,i){return this.setView(t,this._zoom,{pan:i})},panBy:function(t,i){return i=i||{},(t=A(t).round()).x||t.y?(!0===i.animate||this.getSize().contains(t)?(this._panAnim||(this._panAnim=new Gi,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),i.noMoveStart||this.fire("movestart"),!1!==i.animate?(ci(this._mapPane,"leaflet-pan-anim"),e=this._getMapPanePos().subtract(t).round(),this._panAnim.run(this._mapPane,e,i.duration||.25,i.easeLinearity)):(this._rawPanBy(t),this.fire("move").fire("moveend"))):this._resetView(this.unproject(this.project(this.getCenter()).add(t)),this.getZoom()),this):this.fire("moveend");var e},flyTo:function(s,r,t){if(!1===(t=t||{}).animate||!vt)return this.setView(s,r,t);this._stop();var a=this.project(this.getCenter()),h=this.project(s),i=this.getSize(),u=this._zoom;s=j(s),r=void 0===r?u:r;var l=Math.max(i.x,i.y),n=l*this.getZoomScale(u,r),c=h.distanceTo(a)||1,_=1.42,o=_*_;function e(t){var i=(n*n-l*l+(t?-1:1)*o*o*c*c)/(2*(t?n:l)*o*c),e=Math.sqrt(i*i+1)-i;return e<1e-9?-18:Math.log(e)}function d(t){return(Math.exp(t)-Math.exp(-t))/2}function p(t){return(Math.exp(t)+Math.exp(-t))/2}var m=e(0);function f(t){return l*(p(m)*(d(i=m+_*t)/p(i))-d(m))/o;var i}var g=Date.now(),v=(e(1)-m)/_,y=t.duration?1e3*t.duration:1e3*v*.8;return this._moveStart(!0,t.noMoveStart),function t(){var i,e,n=(Date.now()-g)/y,o=(i=n,(1-Math.pow(1-i,1.5))*v);n<=1?(this._flyToFrame=M(t,this),this._move(this.unproject(a.add(h.subtract(a).multiplyBy(f(o)/c)),u),this.getScaleZoom(l/(e=o,l*(p(m)/p(m+_*e))),u),{flyTo:!0})):this._move(s,r)._moveEnd(!0)}.call(this),this},flyToBounds:function(t,i){var e=this._getBoundsCenterZoom(t,i);return this.flyTo(e.center,e.zoom,i)},setMaxBounds:function(t){return(t=N(t)).isValid()?(this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this.options.maxBounds=t,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this.off("moveend",this._panInsideMaxBounds))},setMinZoom:function(t){var i=this.options.minZoom;return this.options.minZoom=t,this._loaded&&i!==t&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(t):this},setMaxZoom:function(t){var i=this.options.maxZoom;return this.options.maxZoom=t,this._loaded&&i!==t&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,i){this._enforcingBounds=!0;var e=this.getCenter(),n=this._limitCenter(e,this._zoom,N(t));return e.equals(n)||this.panTo(n,i),this._enforcingBounds=!1,this},panInside:function(t,i){var e,n,o=A((i=i||{}).paddingTopLeft||i.padding||[0,0]),s=A(i.paddingBottomRight||i.padding||[0,0]),r=this.getCenter(),a=this.project(r),h=this.project(t),u=this.getPixelBounds(),l=u.getSize().divideBy(2),c=O([u.min.add(o),u.max.subtract(s)]);return c.contains(h)||(this._enforcingBounds=!0,e=a.subtract(h),n=A(h.x+e.x,h.y+e.y),(h.x<c.min.x||h.x>c.max.x)&&(n.x=a.x-e.x,0<e.x?n.x+=l.x-o.x:n.x-=l.x-s.x),(h.y<c.min.y||h.y>c.max.y)&&(n.y=a.y-e.y,0<e.y?n.y+=l.y-o.y:n.y-=l.y-s.y),this.panTo(this.unproject(n),i),this._enforcingBounds=!1),this},invalidateSize:function(t){if(!this._loaded)return this;t=h({animate:!1,pan:!0},!0===t?{animate:!0}:t);var i=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var e=this.getSize(),n=i.divideBy(2).round(),o=e.divideBy(2).round(),s=n.subtract(o);return s.x||s.y?(t.animate&&t.pan?this.panBy(s):(t.pan&&this._rawPanBy(s),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(p(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:i,newSize:e})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){if(t=this._locateOptions=h({timeout:1e4,watch:!1},t),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var i=p(this._handleGeolocationResponse,this),e=p(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(i,e,t):navigator.geolocation.getCurrentPosition(i,e,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var i=t.code,e=t.message||(1===i?"permission denied":2===i?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:i,message:"Geolocation error: "+e+"."})},_handleGeolocationResponse:function(t){var i,e=new D(t.coords.latitude,t.coords.longitude),n=e.toBounds(2*t.coords.accuracy),o=this._locateOptions;o.setView&&(i=this.getBoundsZoom(n),this.setView(e,o.maxZoom?Math.min(i,o.maxZoom):i));var s={latlng:e,bounds:n,timestamp:t.timestamp};for(var r in t.coords)"number"==typeof t.coords[r]&&(s[r]=t.coords[r]);this.fire("locationfound",s)},addHandler:function(t,i){if(!i)return this;var e=this[t]=new i(this);return this._handlers.push(e),this.options[t]&&e.enable(),this},remove:function(){if(this._initEvents(!0),this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=void 0,this._containerId=void 0}var t;for(t in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),ri(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(z(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[t].remove();for(t in this._panes)ri(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(t,i){var e=si("div","leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),i||this._mapPane);return t&&(this._panes[t]=e),e},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds();return new R(this.unproject(t.getBottomLeft()),this.unproject(t.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,i,e){t=N(t),e=A(e||[0,0]);var n=this.getZoom()||0,o=this.getMinZoom(),s=this.getMaxZoom(),r=t.getNorthWest(),a=t.getSouthEast(),h=this.getSize().subtract(e),u=O(this.project(a,n),this.project(r,n)).getSize(),l=vt?this.options.zoomSnap:1,c=h.x/u.x,_=h.y/u.y,d=i?Math.max(c,_):Math.min(c,_),n=this.getScaleZoom(d,n);return l&&(n=Math.round(n/(l/100))*(l/100),n=i?Math.ceil(n/l)*l:Math.floor(n/l)*l),Math.max(o,Math.min(s,n))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new k(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,i){var e=this._getTopLeftPoint(t,i);return new I(e,e.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(void 0===t?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,i){var e=this.options.crs;return i=void 0===i?this._zoom:i,e.scale(t)/e.scale(i)},getScaleZoom:function(t,i){var e=this.options.crs;i=void 0===i?this._zoom:i;var n=e.zoom(t*e.scale(i));return isNaN(n)?1/0:n},project:function(t,i){return i=void 0===i?this._zoom:i,this.options.crs.latLngToPoint(j(t),i)},unproject:function(t,i){return i=void 0===i?this._zoom:i,this.options.crs.pointToLatLng(A(t),i)},layerPointToLatLng:function(t){var i=A(t).add(this.getPixelOrigin());return this.unproject(i)},latLngToLayerPoint:function(t){return this.project(j(t))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(j(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(N(t))},distance:function(t,i){return this.options.crs.distance(j(t),j(i))},containerPointToLayerPoint:function(t){return A(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return A(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var i=this.containerPointToLayerPoint(A(t));return this.layerPointToLatLng(i)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(j(t)))},mouseEventToContainerPoint:function(t){return Di(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var i=this._container=ni(t);if(!i)throw new Error("Map container not found.");if(i._leaflet_id)throw new Error("Map container is already initialized.");zi(i,"scroll",this._onScroll,this),this._containerId=m(i)},_initLayout:function(){var t=this._container;this._fadeAnimated=this.options.fadeAnimation&&vt,ci(t,"leaflet-container"+(bt?" leaflet-touch":"")+(zt?" leaflet-retina":"")+(it?" leaflet-oldie":"")+(ct?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var i=oi(t,"position");"absolute"!==i&&"relative"!==i&&"fixed"!==i&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),vi(this._mapPane,new k(0,0)),this.createPane("tilePane"),this.createPane("shadowPane"),this.createPane("overlayPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(ci(t.markerPane,"leaflet-zoom-hide"),ci(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,i){vi(this._mapPane,new k(0,0));var e=!this._loaded;this._loaded=!0,i=this._limitZoom(i),this.fire("viewprereset");var n=this._zoom!==i;this._moveStart(n,!1)._move(t,i)._moveEnd(n),this.fire("viewreset"),e&&this.fire("load")},_moveStart:function(t,i){return t&&this.fire("zoomstart"),i||this.fire("movestart"),this},_move:function(t,i,e){void 0===i&&(i=this._zoom);var n=this._zoom!==i;return this._zoom=i,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),(n||e&&e.pinch)&&this.fire("zoom",e),this.fire("move",e)},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return z(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){vi(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(t){this._targets={};var i=t?Si:zi;i((this._targets[m(this._container)]=this)._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&i(window,"resize",this._onResize,this),vt&&this.options.transform3DLimit&&(t?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){z(this._resizeRequest),this._resizeRequest=M(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,i){for(var e,n=[],o="mouseout"===i||"mouseover"===i,s=t.target||t.srcElement,r=!1;s;){if((e=this._targets[m(s)])&&("click"===i||"preclick"===i)&&!t._simulated&&this._draggableMoved(e)){r=!0;break}if(e&&e.listens(i,!0)){if(o&&!Vi(s,t))break;if(n.push(e),o)break}if(s===this._container)break;s=s.parentNode}return n.length||r||o||!Vi(s,t)||(n=[this]),n},_handleDOMEvent:function(t){var i;this._loaded&&!Ui(t)&&("mousedown"!==(i=t.type)&&"keypress"!==i&&"keyup"!==i&&"keydown"!==i||Pi(t.target||t.srcElement),this._fireDOMEvent(t,i))},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,i,e){var n;if("click"===t.type&&((n=h({},t)).type="preclick",this._fireDOMEvent(n,n.type,e)),!t._stopped&&(e=(e||[]).concat(this._findEventTargets(t,i))).length){var o=e[0];"contextmenu"===i&&o.listens(i,!0)&&Ri(t);var s,r={originalEvent:t};"keypress"!==t.type&&"keydown"!==t.type&&"keyup"!==t.type&&(s=o.getLatLng&&(!o._radius||o._radius<=10),r.containerPoint=s?this.latLngToContainerPoint(o.getLatLng()):this.mouseEventToContainerPoint(t),r.layerPoint=this.containerPointToLayerPoint(r.containerPoint),r.latlng=s?o.getLatLng():this.layerPointToLatLng(r.layerPoint));for(var a=0;a<e.length;a++)if(e[a].fire(i,r,!0),r.originalEvent._stopped||!1===e[a].options.bubblingMouseEvents&&-1!==v(this._mouseEvents,i))return}},_draggableMoved:function(t){return(t=t.dragging&&t.dragging.enabled()?t:this).dragging&&t.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var t=0,i=this._handlers.length;t<i;t++)this._handlers[t].disable()},whenReady:function(t,i){return this._loaded?t.call(i||this,{target:this}):this.on("load",t,i),this},_getMapPanePos:function(){return yi(this._mapPane)||new k(0,0)},_moved:function(){var t=this._getMapPanePos();return t&&!t.equals([0,0])},_getTopLeftPoint:function(t,i){return(t&&void 0!==i?this._getNewPixelOrigin(t,i):this.getPixelOrigin()).subtract(this._getMapPanePos())},_getNewPixelOrigin:function(t,i){var e=this.getSize()._divideBy(2);return this.project(t,i)._subtract(e)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(t,i,e){var n=this._getNewPixelOrigin(e,i);return this.project(t,i)._subtract(n)},_latLngBoundsToNewLayerBounds:function(t,i,e){var n=this._getNewPixelOrigin(e,i);return O([this.project(t.getSouthWest(),i)._subtract(n),this.project(t.getNorthWest(),i)._subtract(n),this.project(t.getSouthEast(),i)._subtract(n),this.project(t.getNorthEast(),i)._subtract(n)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(t){return this.latLngToLayerPoint(t).subtract(this._getCenterLayerPoint())},_limitCenter:function(t,i,e){if(!e)return t;var n=this.project(t,i),o=this.getSize().divideBy(2),s=new I(n.subtract(o),n.add(o)),r=this._getBoundsOffset(s,e,i);return r.round().equals([0,0])?t:this.unproject(n.add(r),i)},_limitOffset:function(t,i){if(!i)return t;var e=this.getPixelBounds(),n=new I(e.min.add(t),e.max.add(t));return t.add(this._getBoundsOffset(n,i))},_getBoundsOffset:function(t,i,e){var n=O(this.project(i.getNorthEast(),e),this.project(i.getSouthWest(),e)),o=n.min.subtract(t.min),s=n.max.subtract(t.max);return new k(this._rebound(o.x,-s.x),this._rebound(o.y,-s.y))},_rebound:function(t,i){return 0<t+i?Math.round(t-i)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(i))},_limitZoom:function(t){var i=this.getMinZoom(),e=this.getMaxZoom(),n=vt?this.options.zoomSnap:1;return n&&(t=Math.round(t/n)*n),Math.max(i,Math.min(e,t))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){_i(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,i){var e=this._getCenterOffset(t)._trunc();return!(!0!==(i&&i.animate)&&!this.getSize().contains(e))&&(this.panBy(e,i),!0)},_createAnimProxy:function(){var t=this._proxy=si("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(t),this.on("zoomanim",function(t){var i=ti,e=this._proxy.style[i];gi(this._proxy,this.project(t.center,t.zoom),this.getZoomScale(t.zoom,1)),e===this._proxy.style[i]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ri(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var t=this.getCenter(),i=this.getZoom();gi(this._proxy,this.project(t,i),this.getZoomScale(i,1))},_catchTransitionEnd:function(t){this._animatingZoom&&0<=t.propertyName.indexOf("transform")&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,i,e){if(this._animatingZoom)return!0;if(e=e||{},!this._zoomAnimated||!1===e.animate||this._nothingToAnimate()||Math.abs(i-this._zoom)>this.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(i),o=this._getCenterOffset(t)._divideBy(1-1/n);return!(!0!==e.animate&&!this.getSize().contains(o))&&(M(function(){this._moveStart(!0,!1)._animateZoom(t,i,!0)},this),!0)},_animateZoom:function(t,i,e,n){this._mapPane&&(e&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=i,ci(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:i,noUpdate:n}),setTimeout(p(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&_i(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom),M(function(){this._moveEnd(!0)},this))}});function Yi(t){return new Xi(t)}var Xi=S.extend({options:{position:"topright"},initialize:function(t){c(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var i=this._map;return i&&i.removeControl(this),this.options.position=t,i&&i.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var i=this._container=this.onAdd(t),e=this.getPosition(),n=t._controlCorners[e];return ci(i,"leaflet-control"),-1!==e.indexOf("bottom")?n.insertBefore(i,n.firstChild):n.appendChild(i),this._map.on("unload",this.remove,this),this},remove:function(){return this._map&&(ri(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null),this},_refocusOnMap:function(t){this._map&&t&&0<t.screenX&&0<t.screenY&&this._map.getContainer().focus()}});Ki.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.remove(),this},_initControlPos:function(){var n=this._controlCorners={},o="leaflet-",s=this._controlContainer=si("div",o+"control-container",this._container);function t(t,i){var e=o+t+" "+o+i;n[t+i]=si("div",e,s)}t("top","left"),t("top","right"),t("bottom","left"),t("bottom","right")},_clearControlPos:function(){for(var t in this._controlCorners)ri(this._controlCorners[t]);ri(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Ji=Xi.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(t,i,e,n){return e<n?-1:n<e?1:0}},initialize:function(t,i,e){for(var n in c(this,e),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,t)this._addLayer(t[n],n);for(n in i)this._addLayer(i[n],n,!0)},onAdd:function(t){this._initLayout(),this._update(),(this._map=t).on("zoomend",this._checkDisabledLayers,this);for(var i=0;i<this._layers.length;i++)this._layers[i].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(t){return Xi.prototype.addTo.call(this,t),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var t=0;t<this._layers.length;t++)this._layers[t].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(t,i){return this._addLayer(t,i),this._map?this._update():this},addOverlay:function(t,i){return this._addLayer(t,i,!0),this._map?this._update():this},removeLayer:function(t){t.off("add remove",this._onLayerChange,this);var i=this._getLayer(m(t));return i&&this._layers.splice(this._layers.indexOf(i),1),this._map?this._update():this},expand:function(){ci(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var t=this._map.getSize().y-(this._container.offsetTop+50);return t<this._section.clientHeight?(ci(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=t+"px"):_i(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return _i(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var t="leaflet-control-layers",i=this._container=si("div",t),e=this.options.collapsed;i.setAttribute("aria-haspopup",!0),Oi(i),Ii(i);var n=this._section=si("section",t+"-list");e&&(this._map.on("click",this.collapse,this),ot||zi(i,{mouseenter:this.expand,mouseleave:this.collapse},this));var o=this._layersLink=si("a",t+"-toggle",i);o.href="#",o.title="Layers",bt?(zi(o,"click",Ni),zi(o,"click",this.expand,this)):zi(o,"focus",this.expand,this),e||this.expand(),this._baseLayersList=si("div",t+"-base",n),this._separator=si("div",t+"-separator",n),this._overlaysList=si("div",t+"-overlays",n),i.appendChild(n)},_getLayer:function(t){for(var i=0;i<this._layers.length;i++)if(this._layers[i]&&m(this._layers[i].layer)===t)return this._layers[i]},_addLayer:function(t,i,e){this._map&&t.on("add remove",this._onLayerChange,this),this._layers.push({layer:t,name:i,overlay:e}),this.options.sortLayers&&this._layers.sort(p(function(t,i){return this.options.sortFunction(t.layer,i.layer,t.name,i.name)},this)),this.options.autoZIndex&&t.setZIndex&&(this._lastZIndex++,t.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;ai(this._baseLayersList),ai(this._overlaysList),this._layerControlInputs=[];for(var t,i,e,n=0,o=0;o<this._layers.length;o++)e=this._layers[o],this._addItem(e),i=i||e.overlay,t=t||!e.overlay,n+=e.overlay?0:1;return this.options.hideSingleBase&&(t=t&&1<n,this._baseLayersList.style.display=t?"":"none"),this._separator.style.display=i&&t?"":"none",this},_onLayerChange:function(t){this._handlingClick||this._update();var i=this._getLayer(m(t.target)),e=i.overlay?"add"===t.type?"overlayadd":"overlayremove":"add"===t.type?"baselayerchange":null;e&&this._map.fire(e,i)},_createRadioElement:function(t,i){var e='<input type="radio" class="leaflet-control-layers-selector" name="'+t+'"'+(i?' checked="checked"':"")+"/>",n=document.createElement("div");return n.innerHTML=e,n.firstChild},_addItem:function(t){var i,e=document.createElement("label"),n=this._map.hasLayer(t.layer);t.overlay?((i=document.createElement("input")).type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=n):i=this._createRadioElement("leaflet-base-layers_"+m(this),n),this._layerControlInputs.push(i),i.layerId=m(t.layer),zi(i,"click",this._onInputClick,this);var o=document.createElement("span");o.innerHTML=" "+t.name;var s=document.createElement("div");return e.appendChild(s),s.appendChild(i),s.appendChild(o),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(e),this._checkDisabledLayers(),e},_onInputClick:function(){var t,i,e=this._layerControlInputs,n=[],o=[];this._handlingClick=!0;for(var s=e.length-1;0<=s;s--)t=e[s],i=this._getLayer(t.layerId).layer,t.checked?n.push(i):t.checked||o.push(i);for(s=0;s<o.length;s++)this._map.hasLayer(o[s])&&this._map.removeLayer(o[s]);for(s=0;s<n.length;s++)this._map.hasLayer(n[s])||this._map.addLayer(n[s]);this._handlingClick=!1,this._refocusOnMap()},_checkDisabledLayers:function(){for(var t,i,e=this._layerControlInputs,n=this._map.getZoom(),o=e.length-1;0<=o;o--)t=e[o],i=this._getLayer(t.layerId).layer,t.disabled=void 0!==i.options.minZoom&&n<i.options.minZoom||void 0!==i.options.maxZoom&&n>i.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expand:function(){return this.expand()},_collapse:function(){return this.collapse()}}),$i=Xi.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"&#x2212;",zoomOutTitle:"Zoom out"},onAdd:function(t){var i="leaflet-control-zoom",e=si("div",i+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,i+"-in",e,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,i+"-out",e,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),e},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(t.shiftKey?3:1))},_zoomOut:function(t){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,i,e,n,o){var s=si("a",e,n);return s.innerHTML=t,s.href="#",s.title=i,s.setAttribute("role","button"),s.setAttribute("aria-label",i),Oi(s),zi(s,"click",Ni),zi(s,"click",o,this),zi(s,"click",this._refocusOnMap,this),s},_updateDisabled:function(){var t=this._map,i="leaflet-disabled";_i(this._zoomInButton,i),_i(this._zoomOutButton,i),!this._disabled&&t._zoom!==t.getMinZoom()||ci(this._zoomOutButton,i),!this._disabled&&t._zoom!==t.getMaxZoom()||ci(this._zoomInButton,i)}});Ki.mergeOptions({zoomControl:!0}),Ki.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new $i,this.addControl(this.zoomControl))});var Qi=Xi.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var i="leaflet-control-scale",e=si("div",i),n=this.options;return this._addScales(n,i+"-line",e),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),e},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,i,e){t.metric&&(this._mScale=si("div",i,e)),t.imperial&&(this._iScale=si("div",i,e))},_update:function(){var t=this._map,i=t.getSize().y/2,e=t.distance(t.containerPointToLatLng([0,i]),t.containerPointToLatLng([this.options.maxWidth,i]));this._updateScales(e)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var i=this._getRoundNum(t),e=i<1e3?i+" m":i/1e3+" km";this._updateScale(this._mScale,e,i/t)},_updateImperial:function(t){var i,e,n,o=3.2808399*t;5280<o?(i=o/5280,e=this._getRoundNum(i),this._updateScale(this._iScale,e+" mi",e/i)):(n=this._getRoundNum(o),this._updateScale(this._iScale,n+" ft",n/o))},_updateScale:function(t,i,e){t.style.width=Math.round(this.options.maxWidth*e)+"px",t.innerHTML=i},_getRoundNum:function(t){var i=Math.pow(10,(Math.floor(t)+"").length-1),e=t/i;return i*(e=10<=e?10:5<=e?5:3<=e?3:2<=e?2:1)}}),te=Xi.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>'},initialize:function(t){c(this,t),this._attributions={}},onAdd:function(t){for(var i in(t.attributionControl=this)._container=si("div","leaflet-control-attribution"),Oi(this._container),t._layers)t._layers[i].getAttribution&&this.addAttribution(t._layers[i].getAttribution());return this._update(),this._container},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t&&(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update()),this},removeAttribution:function(t){return t&&this._attributions[t]&&(this._attributions[t]--,this._update()),this},_update:function(){if(this._map){var t=[];for(var i in this._attributions)this._attributions[i]&&t.push(i);var e=[];this.options.prefix&&e.push(this.options.prefix),t.length&&e.push(t.join(", ")),this._container.innerHTML=e.join(" | ")}}});Ki.mergeOptions({attributionControl:!0}),Ki.addInitHook(function(){this.options.attributionControl&&(new te).addTo(this)});Xi.Layers=Ji,Xi.Zoom=$i,Xi.Scale=Qi,Xi.Attribution=te,Yi.layers=function(t,i,e){return new Ji(t,i,e)},Yi.zoom=function(t){return new $i(t)},Yi.scale=function(t){return new Qi(t)},Yi.attribution=function(t){return new te(t)};var ie=S.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});ie.addTo=function(t,i){return t.addHandler(i,this),this};var ee,ne={Events:Z},oe=bt?"touchstart mousedown":"mousedown",se={mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},re={mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"},ae=E.extend({options:{clickTolerance:3},initialize:function(t,i,e,n){c(this,n),this._element=t,this._dragStartTarget=i||t,this._preventOutline=e},enable:function(){this._enabled||(zi(this._dragStartTarget,oe,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(ae._dragging===this&&this.finishDrag(),Si(this._dragStartTarget,oe,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){var i,e;!t._simulated&&this._enabled&&(this._moved=!1,li(this._element,"leaflet-zoom-anim")||ae._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||((ae._dragging=this)._preventOutline&&Pi(this._element),xi(),Xt(),this._moving||(this.fire("down"),i=t.touches?t.touches[0]:t,e=bi(this._element),this._startPoint=new k(i.clientX,i.clientY),this._parentScale=Ti(e),zi(document,re[t.type],this._onMove,this),zi(document,se[t.type],this._onUp,this))))},_onMove:function(t){var i,e;!t._simulated&&this._enabled&&(t.touches&&1<t.touches.length?this._moved=!0:((e=new k((i=t.touches&&1===t.touches.length?t.touches[0]:t).clientX,i.clientY)._subtract(this._startPoint)).x||e.y)&&(Math.abs(e.x)+Math.abs(e.y)<this.options.clickTolerance||(e.x/=this._parentScale.x,e.y/=this._parentScale.y,Ri(t),this._moved||(this.fire("dragstart"),this._moved=!0,this._startPos=yi(this._element).subtract(e),ci(document.body,"leaflet-dragging"),this._lastTarget=t.target||t.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),ci(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(e),this._moving=!0,z(this._animRequest),this._lastEvent=t,this._animRequest=M(this._updatePosition,this,!0))))},_updatePosition:function(){var t={originalEvent:this._lastEvent};this.fire("predrag",t),vi(this._element,this._newPos),this.fire("drag",t)},_onUp:function(t){!t._simulated&&this._enabled&&this.finishDrag()},finishDrag:function(){for(var t in _i(document.body,"leaflet-dragging"),this._lastTarget&&(_i(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),re)Si(document,re[t],this._onMove,this),Si(document,se[t],this._onUp,this);wi(),Jt(),this._moved&&this._moving&&(z(this._animRequest),this.fire("dragend",{distance:this._newPos.distanceTo(this._startPos)})),this._moving=!1,ae._dragging=!1}});function he(t,i){if(!i||!t.length)return t.slice();var e=i*i;return t=function(t,i){var e=t.length,n=new(typeof Uint8Array!=void 0+""?Uint8Array:Array)(e);n[0]=n[e-1]=1,function t(i,e,n,o,s){var r,a,h,u=0;for(a=o+1;a<=s-1;a++)h=de(i[a],i[o],i[s],!0),u<h&&(r=a,u=h);n<u&&(e[r]=1,t(i,e,n,o,r),t(i,e,n,r,s))}(t,n,i,0,e-1);var o,s=[];for(o=0;o<e;o++)n[o]&&s.push(t[o]);return s}(t=function(t,i){for(var e=[t[0]],n=1,o=0,s=t.length;n<s;n++)(function(t,i){var e=i.x-t.x,n=i.y-t.y;return e*e+n*n})(t[n],t[o])>i&&(e.push(t[n]),o=n);o<s-1&&e.push(t[s-1]);return e}(t,e),e)}function ue(t,i,e){return Math.sqrt(de(t,i,e,!0))}function le(t,i,e,n,o){var s,r,a,h=n?ee:_e(t,e),u=_e(i,e);for(ee=u;;){if(!(h|u))return[t,i];if(h&u)return!1;a=_e(r=ce(t,i,s=h||u,e,o),e),s===h?(t=r,h=a):(i=r,u=a)}}function ce(t,i,e,n,o){var s,r,a=i.x-t.x,h=i.y-t.y,u=n.min,l=n.max;return 8&e?(s=t.x+a*(l.y-t.y)/h,r=l.y):4&e?(s=t.x+a*(u.y-t.y)/h,r=u.y):2&e?(s=l.x,r=t.y+h*(l.x-t.x)/a):1&e&&(s=u.x,r=t.y+h*(u.x-t.x)/a),new k(s,r,o)}function _e(t,i){var e=0;return t.x<i.min.x?e|=1:t.x>i.max.x&&(e|=2),t.y<i.min.y?e|=4:t.y>i.max.y&&(e|=8),e}function de(t,i,e,n){var o,s=i.x,r=i.y,a=e.x-s,h=e.y-r,u=a*a+h*h;return 0<u&&(1<(o=((t.x-s)*a+(t.y-r)*h)/u)?(s=e.x,r=e.y):0<o&&(s+=a*o,r+=h*o)),a=t.x-s,h=t.y-r,n?a*a+h*h:new k(s,r)}function pe(t){return!g(t[0])||"object"!=typeof t[0][0]&&void 0!==t[0][0]}function me(t){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),pe(t)}var fe={simplify:he,pointToSegmentDistance:ue,closestPointOnSegment:function(t,i,e){return de(t,i,e)},clipSegment:le,_getEdgeIntersection:ce,_getBitCode:_e,_sqClosestPointOnSegment:de,isFlat:pe,_flat:me};function ge(t,i,e){for(var n,o,s,r,a,h,u,l=[1,4,2,8],c=0,_=t.length;c<_;c++)t[c]._code=_e(t[c],i);for(s=0;s<4;s++){for(h=l[s],n=[],c=0,o=(_=t.length)-1;c<_;o=c++)r=t[c],a=t[o],r._code&h?a._code&h||((u=ce(a,r,h,i,e))._code=_e(u,i),n.push(u)):(a._code&h&&((u=ce(a,r,h,i,e))._code=_e(u,i),n.push(u)),n.push(r));t=n}return t}var ve,ye={clipPolygon:ge},xe={project:function(t){return new k(t.lng,t.lat)},unproject:function(t){return new D(t.y,t.x)},bounds:new I([-180,-90],[180,90])},we={R:6378137,R_MINOR:6356752.314245179,bounds:new I([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(t){var i=Math.PI/180,e=this.R,n=t.lat*i,o=this.R_MINOR/e,s=Math.sqrt(1-o*o),r=s*Math.sin(n),a=Math.tan(Math.PI/4-n/2)/Math.pow((1-r)/(1+r),s/2),n=-e*Math.log(Math.max(a,1e-10));return new k(t.lng*i*e,n)},unproject:function(t){for(var i,e=180/Math.PI,n=this.R,o=this.R_MINOR/n,s=Math.sqrt(1-o*o),r=Math.exp(-t.y/n),a=Math.PI/2-2*Math.atan(r),h=0,u=.1;h<15&&1e-7<Math.abs(u);h++)i=s*Math.sin(a),i=Math.pow((1-i)/(1+i),s/2),a+=u=Math.PI/2-2*Math.atan(r*i)-a;return new D(a*e,t.x*e/n)}},Pe={LonLat:xe,Mercator:we,SphericalMercator:V},Le=h({},F,{code:"EPSG:3395",projection:we,transformation:G(ve=.5/(Math.PI*we.R),.5,-ve,.5)}),be=h({},F,{code:"EPSG:4326",projection:xe,transformation:G(1/180,1,-1/180,.5)}),Te=h({},H,{projection:xe,transformation:G(1,0,-1,0),scale:function(t){return Math.pow(2,t)},zoom:function(t){return Math.log(t)/Math.LN2},distance:function(t,i){var e=i.lng-t.lng,n=i.lat-t.lat;return Math.sqrt(e*e+n*n)},infinite:!0});H.Earth=F,H.EPSG3395=Le,H.EPSG3857=Y,H.EPSG900913=X,H.EPSG4326=be,H.Simple=Te;var Me=E.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(t){return t.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(t){return t&&t.removeLayer(this),this},getPane:function(t){return this._map.getPane(t?this.options[t]||t:this.options.pane)},addInteractiveTarget:function(t){return this._map._targets[m(t)]=this},removeInteractiveTarget:function(t){return delete this._map._targets[m(t)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(t){var i,e=t.target;e.hasLayer(this)&&(this._map=e,this._zoomAnimated=e._zoomAnimated,this.getEvents&&(i=this.getEvents(),e.on(i,this),this.once("remove",function(){e.off(i,this)},this)),this.onAdd(e),this.getAttribution&&e.attributionControl&&e.attributionControl.addAttribution(this.getAttribution()),this.fire("add"),e.fire("layeradd",{layer:this}))}});Ki.include({addLayer:function(t){if(!t._layerAdd)throw new Error("The provided object is not a Layer.");var i=m(t);return this._layers[i]||((this._layers[i]=t)._mapToAdd=this,t.beforeAdd&&t.beforeAdd(this),this.whenReady(t._layerAdd,t)),this},removeLayer:function(t){var i=m(t);return this._layers[i]&&(this._loaded&&t.onRemove(this),t.getAttribution&&this.attributionControl&&this.attributionControl.removeAttribution(t.getAttribution()),delete this._layers[i],this._loaded&&(this.fire("layerremove",{layer:t}),t.fire("remove")),t._map=t._mapToAdd=null),this},hasLayer:function(t){return!!t&&m(t)in this._layers},eachLayer:function(t,i){for(var e in this._layers)t.call(i,this._layers[e]);return this},_addLayers:function(t){for(var i=0,e=(t=t?g(t)?t:[t]:[]).length;i<e;i++)this.addLayer(t[i])},_addZoomLimit:function(t){!isNaN(t.options.maxZoom)&&isNaN(t.options.minZoom)||(this._zoomBoundLayers[m(t)]=t,this._updateZoomLevels())},_removeZoomLimit:function(t){var i=m(t);this._zoomBoundLayers[i]&&(delete this._zoomBoundLayers[i],this._updateZoomLevels())},_updateZoomLevels:function(){var t=1/0,i=-1/0,e=this._getZoomSpan();for(var n in this._zoomBoundLayers)var o=this._zoomBoundLayers[n].options,t=void 0===o.minZoom?t:Math.min(t,o.minZoom),i=void 0===o.maxZoom?i:Math.max(i,o.maxZoom);this._layersMaxZoom=i===-1/0?void 0:i,this._layersMinZoom=t===1/0?void 0:t,e!==this._getZoomSpan()&&this.fire("zoomlevelschange"),void 0===this.options.maxZoom&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var ze=Me.extend({initialize:function(t,i){var e,n;if(c(this,i),this._layers={},t)for(e=0,n=t.length;e<n;e++)this.addLayer(t[e])},addLayer:function(t){var i=this.getLayerId(t);return this._layers[i]=t,this._map&&this._map.addLayer(t),this},removeLayer:function(t){var i=t in this._layers?t:this.getLayerId(t);return this._map&&this._layers[i]&&this._map.removeLayer(this._layers[i]),delete this._layers[i],this},hasLayer:function(t){return!!t&&("number"==typeof t?t:this.getLayerId(t))in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(t){var i,e,n=Array.prototype.slice.call(arguments,1);for(i in this._layers)(e=this._layers[i])[t]&&e[t].apply(e,n);return this},onAdd:function(t){this.eachLayer(t.addLayer,t)},onRemove:function(t){this.eachLayer(t.removeLayer,t)},eachLayer:function(t,i){for(var e in this._layers)t.call(i,this._layers[e]);return this},getLayer:function(t){return this._layers[t]},getLayers:function(){var t=[];return this.eachLayer(t.push,t),t},setZIndex:function(t){return this.invoke("setZIndex",t)},getLayerId:m}),Ce=ze.extend({addLayer:function(t){return this.hasLayer(t)?this:(t.addEventParent(this),ze.prototype.addLayer.call(this,t),this.fire("layeradd",{layer:t}))},removeLayer:function(t){return this.hasLayer(t)?(t in this._layers&&(t=this._layers[t]),t.removeEventParent(this),ze.prototype.removeLayer.call(this,t),this.fire("layerremove",{layer:t})):this},setStyle:function(t){return this.invoke("setStyle",t)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var t=new R;for(var i in this._layers){var e=this._layers[i];t.extend(e.getBounds?e.getBounds():e.getLatLng())}return t}}),Se=S.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0]},initialize:function(t){c(this,t)},createIcon:function(t){return this._createIcon("icon",t)},createShadow:function(t){return this._createIcon("shadow",t)},_createIcon:function(t,i){var e=this._getIconUrl(t);if(!e){if("icon"===t)throw new Error("iconUrl not set in Icon options (see the docs).");return null}var n=this._createImg(e,i&&"IMG"===i.tagName?i:null);return this._setIconStyles(n,t),n},_setIconStyles:function(t,i){var e=this.options,n=e[i+"Size"];"number"==typeof n&&(n=[n,n]);var o=A(n),s=A("shadow"===i&&e.shadowAnchor||e.iconAnchor||o&&o.divideBy(2,!0));t.className="leaflet-marker-"+i+" "+(e.className||""),s&&(t.style.marginLeft=-s.x+"px",t.style.marginTop=-s.y+"px"),o&&(t.style.width=o.x+"px",t.style.height=o.y+"px")},_createImg:function(t,i){return(i=i||document.createElement("img")).src=t,i},_getIconUrl:function(t){return zt&&this.options[t+"RetinaUrl"]||this.options[t+"Url"]}});var Ze=Se.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(t){return Ze.imagePath||(Ze.imagePath=this._detectIconPath()),(this.options.imagePath||Ze.imagePath)+Se.prototype._getIconUrl.call(this,t)},_detectIconPath:function(){var t=si("div","leaflet-default-icon-path",document.body),i=oi(t,"background-image")||oi(t,"backgroundImage");return document.body.removeChild(t),i=null===i||0!==i.indexOf("url")?"":i.replace(/^url\(["']?/,"").replace(/marker-icon\.png["']?\)$/,"")}}),Ee=ie.extend({initialize:function(t){this._marker=t},addHooks:function(){var t=this._marker._icon;this._draggable||(this._draggable=new ae(t,t,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),ci(t,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&_i(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(t){var i,e=this._marker,n=e._map,o=this._marker.options.autoPanSpeed,s=this._marker.options.autoPanPadding,r=yi(e._icon),a=n.getPixelBounds(),h=n.getPixelOrigin(),u=O(a.min._subtract(h).add(s),a.max._subtract(h).subtract(s));u.contains(r)||(i=A((Math.max(u.max.x,r.x)-u.max.x)/(a.max.x-u.max.x)-(Math.min(u.min.x,r.x)-u.min.x)/(a.min.x-u.min.x),(Math.max(u.max.y,r.y)-u.max.y)/(a.max.y-u.max.y)-(Math.min(u.min.y,r.y)-u.min.y)/(a.min.y-u.min.y)).multiplyBy(o),n.panBy(i,{animate:!1}),this._draggable._newPos._add(i),this._draggable._startPos._add(i),vi(e._icon,this._draggable._newPos),this._onDrag(t),this._panRequest=M(this._adjustPan.bind(this,t)))},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(t){this._marker.options.autoPan&&(z(this._panRequest),this._panRequest=M(this._adjustPan.bind(this,t)))},_onDrag:function(t){var i=this._marker,e=i._shadow,n=yi(i._icon),o=i._map.layerPointToLatLng(n);e&&vi(e,n),i._latlng=o,t.latlng=o,t.oldLatLng=this._oldLatLng,i.fire("move",t).fire("drag",t)},_onDragEnd:function(t){z(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",t)}}),ke=Me.extend({options:{icon:new Ze,interactive:!0,keyboard:!0,title:"",alt:"",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingMouseEvents:!1,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(t,i){c(this,i),this._latlng=j(t)},onAdd:function(t){this._zoomAnimated=this._zoomAnimated&&t.options.markerZoomAnimation,this._zoomAnimated&&t.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(t){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&t.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(t){var i=this._latlng;return this._latlng=j(t),this.update(),this.fire("move",{oldLatLng:i,latlng:this._latlng})},setZIndexOffset:function(t){return this.options.zIndexOffset=t,this.update()},getIcon:function(){return this.options.icon},setIcon:function(t){return this.options.icon=t,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){var t;return this._icon&&this._map&&(t=this._map.latLngToLayerPoint(this._latlng).round(),this._setPos(t)),this},_initIcon:function(){var t=this.options,i="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),e=t.icon.createIcon(this._icon),n=!1;e!==this._icon&&(this._icon&&this._removeIcon(),n=!0,t.title&&(e.title=t.title),"IMG"===e.tagName&&(e.alt=t.alt||"")),ci(e,i),t.keyboard&&(e.tabIndex="0"),this._icon=e,t.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex});var o=t.icon.createShadow(this._shadow),s=!1;o!==this._shadow&&(this._removeShadow(),s=!0),o&&(ci(o,i),o.alt=""),this._shadow=o,t.opacity<1&&this._updateOpacity(),n&&this.getPane().appendChild(this._icon),this._initInteraction(),o&&s&&this.getPane(t.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),ri(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&ri(this._shadow),this._shadow=null},_setPos:function(t){this._icon&&vi(this._icon,t),this._shadow&&vi(this._shadow,t),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(t){this._icon&&(this._icon.style.zIndex=this._zIndex+t)},_animateZoom:function(t){var i=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center).round();this._setPos(i)},_initInteraction:function(){var t;this.options.interactive&&(ci(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),Ee&&(t=this.options.draggable,this.dragging&&(t=this.dragging.enabled(),this.dragging.disable()),this.dragging=new Ee(this),t&&this.dragging.enable()))},setOpacity:function(t){return this.options.opacity=t,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var t=this.options.opacity;this._icon&&mi(this._icon,t),this._shadow&&mi(this._shadow,t)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});var Be=Me.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(t){this._renderer=t.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(t){return c(this,t),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&t&&Object.prototype.hasOwnProperty.call(t,"weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+this._renderer.options.tolerance}}),Ae=Be.extend({options:{fill:!0,radius:10},initialize:function(t,i){c(this,i),this._latlng=j(t),this._radius=this.options.radius},setLatLng:function(t){var i=this._latlng;return this._latlng=j(t),this.redraw(),this.fire("move",{oldLatLng:i,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(t){return this.options.radius=this._radius=t,this.redraw()},getRadius:function(){return this._radius},setStyle:function(t){var i=t&&t.radius||this._radius;return Be.prototype.setStyle.call(this,t),this.setRadius(i),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var t=this._radius,i=this._radiusY||t,e=this._clickTolerance(),n=[t+e,i+e];this._pxBounds=new I(this._point.subtract(n),this._point.add(n))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(t){return t.distanceTo(this._point)<=this._radius+this._clickTolerance()}});var Ie=Ae.extend({initialize:function(t,i,e){if("number"==typeof i&&(i=h({},e,{radius:i})),c(this,i),this._latlng=j(t),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(t){return this._mRadius=t,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var t=[this._radius,this._radiusY||this._radius];return new R(this._map.layerPointToLatLng(this._point.subtract(t)),this._map.layerPointToLatLng(this._point.add(t)))},setStyle:Be.prototype.setStyle,_project:function(){var t,i,e,n,o,s,r,a,h=this._latlng.lng,u=this._latlng.lat,l=this._map,c=l.options.crs;c.distance===F.distance?(t=Math.PI/180,i=this._mRadius/F.R/t,e=l.project([u+i,h]),n=l.project([u-i,h]),o=e.add(n).divideBy(2),s=l.unproject(o).lat,r=Math.acos((Math.cos(i*t)-Math.sin(u*t)*Math.sin(s*t))/(Math.cos(u*t)*Math.cos(s*t)))/t,!isNaN(r)&&0!==r||(r=i/Math.cos(Math.PI/180*u)),this._point=o.subtract(l.getPixelOrigin()),this._radius=isNaN(r)?0:o.x-l.project([s,h-r]).x,this._radiusY=o.y-e.y):(a=c.unproject(c.project(this._latlng).subtract([this._mRadius,0])),this._point=l.latLngToLayerPoint(this._latlng),this._radius=this._point.x-l.latLngToLayerPoint(a).x),this._updateBounds()}});var Oe=Be.extend({options:{smoothFactor:1,noClip:!1},initialize:function(t,i){c(this,i),this._setLatLngs(t)},getLatLngs:function(){return this._latlngs},setLatLngs:function(t){return this._setLatLngs(t),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(t){for(var i,e,n=1/0,o=null,s=de,r=0,a=this._parts.length;r<a;r++)for(var h=this._parts[r],u=1,l=h.length;u<l;u++){var c=s(t,i=h[u-1],e=h[u],!0);c<n&&(n=c,o=s(t,i,e))}return o&&(o.distance=Math.sqrt(n)),o},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");var t,i,e,n,o,s,r,a=this._rings[0],h=a.length;if(!h)return null;for(i=t=0;t<h-1;t++)i+=a[t].distanceTo(a[t+1])/2;if(0===i)return this._map.layerPointToLatLng(a[0]);for(n=t=0;t<h-1;t++)if(o=a[t],s=a[t+1],i<(n+=e=o.distanceTo(s)))return r=(n-i)/e,this._map.layerPointToLatLng([s.x-r*(s.x-o.x),s.y-r*(s.y-o.y)])},getBounds:function(){return this._bounds},addLatLng:function(t,i){return i=i||this._defaultShape(),t=j(t),i.push(t),this._bounds.extend(t),this.redraw()},_setLatLngs:function(t){this._bounds=new R,this._latlngs=this._convertLatLngs(t)},_defaultShape:function(){return pe(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(t){for(var i=[],e=pe(t),n=0,o=t.length;n<o;n++)e?(i[n]=j(t[n]),this._bounds.extend(i[n])):i[n]=this._convertLatLngs(t[n]);return i},_project:function(){var t=new I;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,t),this._bounds.isValid()&&t.isValid()&&(this._rawPxBounds=t,this._updateBounds())},_updateBounds:function(){var t=this._clickTolerance(),i=new k(t,t);this._pxBounds=new I([this._rawPxBounds.min.subtract(i),this._rawPxBounds.max.add(i)])},_projectLatlngs:function(t,i,e){var n,o,s=t[0]instanceof D,r=t.length;if(s){for(o=[],n=0;n<r;n++)o[n]=this._map.latLngToLayerPoint(t[n]),e.extend(o[n]);i.push(o)}else for(n=0;n<r;n++)this._projectLatlngs(t[n],i,e)},_clipPoints:function(){var t=this._renderer._bounds;if(this._parts=[],this._pxBounds&&this._pxBounds.intersects(t))if(this.options.noClip)this._parts=this._rings;else for(var i,e,n,o,s=this._parts,r=0,a=0,h=this._rings.length;r<h;r++)for(i=0,e=(o=this._rings[r]).length;i<e-1;i++)(n=le(o[i],o[i+1],t,i,!0))&&(s[a]=s[a]||[],s[a].push(n[0]),n[1]===o[i+1]&&i!==e-2||(s[a].push(n[1]),a++))},_simplifyPoints:function(){for(var t=this._parts,i=this.options.smoothFactor,e=0,n=t.length;e<n;e++)t[e]=he(t[e],i)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(t,i){var e,n,o,s,r,a,h=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(t))return!1;for(e=0,s=this._parts.length;e<s;e++)for(n=0,o=(r=(a=this._parts[e]).length)-1;n<r;o=n++)if((i||0!==n)&&ue(t,a[o],a[n])<=h)return!0;return!1}});Oe._flat=me;var Re=Oe.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");var t,i,e,n,o,s,r,a,h,u=this._rings[0],l=u.length;if(!l)return null;for(t=s=r=a=0,i=l-1;t<l;i=t++)e=u[t],n=u[i],o=e.y*n.x-n.y*e.x,r+=(e.x+n.x)*o,a+=(e.y+n.y)*o,s+=3*o;return h=0===s?u[0]:[r/s,a/s],this._map.layerPointToLatLng(h)},_convertLatLngs:function(t){var i=Oe.prototype._convertLatLngs.call(this,t),e=i.length;return 2<=e&&i[0]instanceof D&&i[0].equals(i[e-1])&&i.pop(),i},_setLatLngs:function(t){Oe.prototype._setLatLngs.call(this,t),pe(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return pe(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,i=this.options.weight,e=new k(i,i),t=new I(t.min.subtract(e),t.max.add(e));if(this._parts=[],this._pxBounds&&this._pxBounds.intersects(t))if(this.options.noClip)this._parts=this._rings;else for(var n,o=0,s=this._rings.length;o<s;o++)(n=ge(this._rings[o],t,!0)).length&&this._parts.push(n)},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(t){var i,e,n,o,s,r,a,h,u=!1;if(!this._pxBounds||!this._pxBounds.contains(t))return!1;for(o=0,a=this._parts.length;o<a;o++)for(s=0,r=(h=(i=this._parts[o]).length)-1;s<h;r=s++)e=i[s],n=i[r],e.y>t.y!=n.y>t.y&&t.x<(n.x-e.x)*(t.y-e.y)/(n.y-e.y)+e.x&&(u=!u);return u||Oe.prototype._containsPoint.call(this,t,!0)}});var Ne=Ce.extend({initialize:function(t,i){c(this,i),this._layers={},t&&this.addData(t)},addData:function(t){var i,e,n,o=g(t)?t:t.features;if(o){for(i=0,e=o.length;i<e;i++)((n=o[i]).geometries||n.geometry||n.features||n.coordinates)&&this.addData(n);return this}var s=this.options;if(s.filter&&!s.filter(t))return this;var r=De(t,s);return r?(r.feature=qe(t),r.defaultOptions=r.options,this.resetStyle(r),s.onEachFeature&&s.onEachFeature(t,r),this.addLayer(r)):this},resetStyle:function(t){return void 0===t?this.eachLayer(this.resetStyle,this):(t.options=h({},t.defaultOptions),this._setLayerStyle(t,this.options.style),this)},setStyle:function(i){return this.eachLayer(function(t){this._setLayerStyle(t,i)},this)},_setLayerStyle:function(t,i){t.setStyle&&("function"==typeof i&&(i=i(t.feature)),t.setStyle(i))}});function De(t,i){var e,n,o,s,r="Feature"===t.type?t.geometry:t,a=r?r.coordinates:null,h=[],u=i&&i.pointToLayer,l=i&&i.coordsToLatLng||We;if(!a&&!r)return null;switch(r.type){case"Point":return je(u,t,e=l(a),i);case"MultiPoint":for(o=0,s=a.length;o<s;o++)e=l(a[o]),h.push(je(u,t,e,i));return new Ce(h);case"LineString":case"MultiLineString":return n=He(a,"LineString"===r.type?0:1,l),new Oe(n,i);case"Polygon":case"MultiPolygon":return n=He(a,"Polygon"===r.type?1:2,l),new Re(n,i);case"GeometryCollection":for(o=0,s=r.geometries.length;o<s;o++){var c=De({geometry:r.geometries[o],type:"Feature",properties:t.properties},i);c&&h.push(c)}return new Ce(h);default:throw new Error("Invalid GeoJSON object.")}}function je(t,i,e,n){return t?t(i,e):new ke(e,n&&n.markersInheritOptions&&n)}function We(t){return new D(t[1],t[0],t[2])}function He(t,i,e){for(var n,o=[],s=0,r=t.length;s<r;s++)n=i?He(t[s],i-1,e):(e||We)(t[s]),o.push(n);return o}function Fe(t,i){return i="number"==typeof i?i:6,void 0!==t.alt?[r(t.lng,i),r(t.lat,i),r(t.alt,i)]:[r(t.lng,i),r(t.lat,i)]}function Ue(t,i,e,n){for(var o=[],s=0,r=t.length;s<r;s++)o.push(i?Ue(t[s],i-1,e,n):Fe(t[s],n));return!i&&e&&o.push(o[0]),o}function Ve(t,i){return t.feature?h({},t.feature,{geometry:i}):qe(i)}function qe(t){return"Feature"===t.type||"FeatureCollection"===t.type?t:{type:"Feature",properties:{},geometry:t}}var Ge={toGeoJSON:function(t){return Ve(this,{type:"Point",coordinates:Fe(this.getLatLng(),t)})}};function Ke(t,i){return new Ne(t,i)}ke.include(Ge),Ie.include(Ge),Ae.include(Ge),Oe.include({toGeoJSON:function(t){var i=!pe(this._latlngs);return Ve(this,{type:(i?"Multi":"")+"LineString",coordinates:Ue(this._latlngs,i?1:0,!1,t)})}}),Re.include({toGeoJSON:function(t){var i=!pe(this._latlngs),e=i&&!pe(this._latlngs[0]),n=Ue(this._latlngs,e?2:i?1:0,!0,t);return i||(n=[n]),Ve(this,{type:(e?"Multi":"")+"Polygon",coordinates:n})}}),ze.include({toMultiPoint:function(i){var e=[];return this.eachLayer(function(t){e.push(t.toGeoJSON(i).geometry.coordinates)}),Ve(this,{type:"MultiPoint",coordinates:e})},toGeoJSON:function(n){var t=this.feature&&this.feature.geometry&&this.feature.geometry.type;if("MultiPoint"===t)return this.toMultiPoint(n);var o="GeometryCollection"===t,s=[];return this.eachLayer(function(t){var i,e;t.toGeoJSON&&(i=t.toGeoJSON(n),o?s.push(i.geometry):"FeatureCollection"===(e=qe(i)).type?s.push.apply(s,e.features):s.push(e))}),o?Ve(this,{geometries:s,type:"GeometryCollection"}):{type:"FeatureCollection",features:s}}});var Ye=Ke,Xe=Me.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(t,i,e){this._url=t,this._bounds=N(i),c(this,e)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(ci(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){ri(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(t){return this.options.opacity=t,this._image&&this._updateOpacity(),this},setStyle:function(t){return t.opacity&&this.setOpacity(t.opacity),this},bringToFront:function(){return this._map&&hi(this._image),this},bringToBack:function(){return this._map&&ui(this._image),this},setUrl:function(t){return this._url=t,this._image&&(this._image.src=t),this},setBounds:function(t){return this._bounds=N(t),this._map&&this._reset(),this},getEvents:function(){var t={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var t="IMG"===this._url.tagName,i=this._image=t?this._url:si("img");ci(i,"leaflet-image-layer"),this._zoomAnimated&&ci(i,"leaflet-zoom-animated"),this.options.className&&ci(i,this.options.className),i.onselectstart=a,i.onmousemove=a,i.onload=p(this.fire,this,"load"),i.onerror=p(this._overlayOnError,this,"error"),!this.options.crossOrigin&&""!==this.options.crossOrigin||(i.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),t?this._url=i.src:(i.src=this._url,i.alt=this.options.alt)},_animateZoom:function(t){var i=this._map.getZoomScale(t.zoom),e=this._map._latLngBoundsToNewLayerBounds(this._bounds,t.zoom,t.center).min;gi(this._image,e,i)},_reset:function(){var t=this._image,i=new I(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),e=i.getSize();vi(t,i.min),t.style.width=e.x+"px",t.style.height=e.y+"px"},_updateOpacity:function(){mi(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var t=this.options.errorOverlayUrl;t&&this._url!==t&&(this._url=t,this._image.src=t)}}),Je=Xe.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1},_initImage:function(){var t="VIDEO"===this._url.tagName,i=this._image=t?this._url:si("video");if(ci(i,"leaflet-image-layer"),this._zoomAnimated&&ci(i,"leaflet-zoom-animated"),this.options.className&&ci(i,this.options.className),i.onselectstart=a,i.onmousemove=a,i.onloadeddata=p(this.fire,this,"load"),t){for(var e=i.getElementsByTagName("source"),n=[],o=0;o<e.length;o++)n.push(e[o].src);this._url=0<e.length?n:[i.src]}else{g(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(i.style,"objectFit")&&(i.style.objectFit="fill"),i.autoplay=!!this.options.autoplay,i.loop=!!this.options.loop,i.muted=!!this.options.muted;for(var s=0;s<this._url.length;s++){var r=si("source");r.src=this._url[s],i.appendChild(r)}}}});var $e=Xe.extend({_initImage:function(){var t=this._image=this._url;ci(t,"leaflet-image-layer"),this._zoomAnimated&&ci(t,"leaflet-zoom-animated"),this.options.className&&ci(t,this.options.className),t.onselectstart=a,t.onmousemove=a}});var Qe=Me.extend({options:{offset:[0,7],className:"",pane:"popupPane"},initialize:function(t,i){c(this,t),this._source=i},onAdd:function(t){this._zoomAnimated=t._zoomAnimated,this._container||this._initLayout(),t._fadeAnimated&&mi(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),t._fadeAnimated&&mi(this._container,1),this.bringToFront()},onRemove:function(t){t._fadeAnimated?(mi(this._container,0),this._removeTimeout=setTimeout(p(ri,void 0,this._container),200)):ri(this._container)},getLatLng:function(){return this._latlng},setLatLng:function(t){return this._latlng=j(t),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(t){return this._content=t,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var t={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&hi(this._container),this},bringToBack:function(){return this._map&&ui(this._container),this},_prepareOpen:function(t,i,e){if(i instanceof Me||(e=i,i=t),i instanceof Ce)for(var n in t._layers){i=t._layers[n];break}if(!e)if(i.getCenter)e=i.getCenter();else{if(!i.getLatLng)throw new Error("Unable to get source layer LatLng.");e=i.getLatLng()}return this._source=i,this.update(),e},_updateContent:function(){if(this._content){var t=this._contentNode,i="function"==typeof this._content?this._content(this._source||this):this._content;if("string"==typeof i)t.innerHTML=i;else{for(;t.hasChildNodes();)t.removeChild(t.firstChild);t.appendChild(i)}this.fire("contentupdate")}},_updatePosition:function(){var t,i,e,n,o;this._map&&(t=this._map.latLngToLayerPoint(this._latlng),i=A(this.options.offset),e=this._getAnchor(),this._zoomAnimated?vi(this._container,t.add(e)):i=i.add(t).add(e),n=this._containerBottom=-i.y,o=this._containerLeft=-Math.round(this._containerWidth/2)+i.x,this._container.style.bottom=n+"px",this._container.style.left=o+"px")},_getAnchor:function(){return[0,0]}}),tn=Qe.extend({options:{maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:""},openOn:function(t){return t.openPopup(this),this},onAdd:function(t){Qe.prototype.onAdd.call(this,t),t.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof Be||this._source.on("preclick",Ai))},onRemove:function(t){Qe.prototype.onRemove.call(this,t),t.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof Be||this._source.off("preclick",Ai))},getEvents:function(){var t=Qe.prototype.getEvents.call(this);return(void 0!==this.options.closeOnClick?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(t.preclick=this._close),this.options.keepInView&&(t.moveend=this._adjustPan),t},_close:function(){this._map&&this._map.closePopup(this)},_initLayout:function(){var t,i="leaflet-popup",e=this._container=si("div",i+" "+(this.options.className||"")+" leaflet-zoom-animated"),n=this._wrapper=si("div",i+"-content-wrapper",e);this._contentNode=si("div",i+"-content",n),Oi(e),Ii(this._contentNode),zi(e,"contextmenu",Ai),this._tipContainer=si("div",i+"-tip-container",e),this._tip=si("div",i+"-tip",this._tipContainer),this.options.closeButton&&((t=this._closeButton=si("a",i+"-close-button",e)).href="#close",t.innerHTML="&#215;",zi(t,"click",this._onCloseButtonClick,this))},_updateLayout:function(){var t=this._contentNode,i=t.style;i.width="",i.whiteSpace="nowrap";var e=t.offsetWidth,e=Math.min(e,this.options.maxWidth);e=Math.max(e,this.options.minWidth),i.width=e+1+"px",i.whiteSpace="",i.height="";var n=t.offsetHeight,o=this.options.maxHeight,s="leaflet-popup-scrolled";o&&o<n?(i.height=o+"px",ci(t,s)):_i(t,s),this._containerWidth=this._container.offsetWidth},_animateZoom:function(t){var i=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),e=this._getAnchor();vi(this._container,i.add(e))},_adjustPan:function(){var t,i,e,n,o,s,r,a,h,u,l,c;this.options.autoPan&&(this._map._panAnim&&this._map._panAnim.stop(),t=this._map,i=parseInt(oi(this._container,"marginBottom"),10)||0,e=this._container.offsetHeight+i,n=this._containerWidth,(o=new k(this._containerLeft,-e-this._containerBottom))._add(yi(this._container)),s=t.layerPointToContainerPoint(o),r=A(this.options.autoPanPadding),a=A(this.options.autoPanPaddingTopLeft||r),h=A(this.options.autoPanPaddingBottomRight||r),u=t.getSize(),c=l=0,s.x+n+h.x>u.x&&(l=s.x+n-u.x+h.x),s.x-l-a.x<0&&(l=s.x-a.x),s.y+e+h.y>u.y&&(c=s.y+e-u.y+h.y),s.y-c-a.y<0&&(c=s.y-a.y),(l||c)&&t.fire("autopanstart").panBy([l,c]))},_onCloseButtonClick:function(t){this._close(),Ni(t)},_getAnchor:function(){return A(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}});Ki.mergeOptions({closePopupOnClick:!0}),Ki.include({openPopup:function(t,i,e){return t instanceof tn||(t=new tn(e).setContent(t)),i&&t.setLatLng(i),this.hasLayer(t)?this:(this._popup&&this._popup.options.autoClose&&this.closePopup(),this._popup=t,this.addLayer(t))},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&this.removeLayer(t),this}}),Me.include({bindPopup:function(t,i){return t instanceof tn?(c(t,i),(this._popup=t)._source=this):(this._popup&&!i||(this._popup=new tn(i,this)),this._popup.setContent(t)),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t,i){return this._popup&&this._map&&(i=this._popup._prepareOpen(this,t,i),this._map.openPopup(this._popup,i)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(t){return this._popup&&(this._popup._map?this.closePopup():this.openPopup(t)),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var i=t.layer||t.target;this._popup&&this._map&&(Ni(t),i instanceof Be?this.openPopup(t.layer||t.target,t.latlng):this._map.hasLayer(this._popup)&&this._popup._source===i?this.closePopup():this.openPopup(i,t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var en=Qe.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,interactive:!1,opacity:.9},onAdd:function(t){Qe.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&this._source.fire("tooltipopen",{tooltip:this},!0)},onRemove:function(t){Qe.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&this._source.fire("tooltipclose",{tooltip:this},!0)},getEvents:function(){var t=Qe.prototype.getEvents.call(this);return bt&&!this.options.permanent&&(t.preclick=this._close),t},_close:function(){this._map&&this._map.closeTooltip(this)},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=si("div",t)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var i,e=this._map,n=this._container,o=e.latLngToContainerPoint(e.getCenter()),s=e.layerPointToContainerPoint(t),r=this.options.direction,a=n.offsetWidth,h=n.offsetHeight,u=A(this.options.offset),l=this._getAnchor(),c="top"===r?(i=a/2,h):"bottom"===r?(i=a/2,0):(i="center"===r?a/2:"right"===r?0:"left"===r?a:s.x<o.x?(r="right",0):(r="left",a+2*(u.x+l.x)),h/2);t=t.subtract(A(i,c,!0)).add(u).add(l),_i(n,"leaflet-tooltip-right"),_i(n,"leaflet-tooltip-left"),_i(n,"leaflet-tooltip-top"),_i(n,"leaflet-tooltip-bottom"),ci(n,"leaflet-tooltip-"+r),vi(n,t)},_updatePosition:function(){var t=this._map.latLngToLayerPoint(this._latlng);this._setPosition(t)},setOpacity:function(t){this.options.opacity=t,this._container&&mi(this._container,t)},_animateZoom:function(t){var i=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center);this._setPosition(i)},_getAnchor:function(){return A(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}});Ki.include({openTooltip:function(t,i,e){return t instanceof en||(t=new en(e).setContent(t)),i&&t.setLatLng(i),this.hasLayer(t)?this:this.addLayer(t)},closeTooltip:function(t){return t&&this.removeLayer(t),this}}),Me.include({bindTooltip:function(t,i){return t instanceof en?(c(t,i),(this._tooltip=t)._source=this):(this._tooltip&&!i||(this._tooltip=new en(i,this)),this._tooltip.setContent(t)),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(t){var i,e;!t&&this._tooltipHandlersAdded||(i=t?"off":"on",e={remove:this.closeTooltip,move:this._moveTooltip},this._tooltip.options.permanent?e.add=this._openTooltip:(e.mouseover=this._openTooltip,e.mouseout=this.closeTooltip,this._tooltip.options.sticky&&(e.mousemove=this._moveTooltip),bt&&(e.click=this._openTooltip)),this[i](e),this._tooltipHandlersAdded=!t)},openTooltip:function(t,i){return this._tooltip&&this._map&&(i=this._tooltip._prepareOpen(this,t,i),this._map.openTooltip(this._tooltip,i),this._tooltip.options.interactive&&this._tooltip._container&&(ci(this._tooltip._container,"leaflet-clickable"),this.addInteractiveTarget(this._tooltip._container))),this},closeTooltip:function(){return this._tooltip&&(this._tooltip._close(),this._tooltip.options.interactive&&this._tooltip._container&&(_i(this._tooltip._container,"leaflet-clickable"),this.removeInteractiveTarget(this._tooltip._container))),this},toggleTooltip:function(t){return this._tooltip&&(this._tooltip._map?this.closeTooltip():this.openTooltip(t)),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(t){return this._tooltip&&this._tooltip.setContent(t),this},getTooltip:function(){return this._tooltip},_openTooltip:function(t){var i=t.layer||t.target;this._tooltip&&this._map&&this.openTooltip(i,this._tooltip.options.sticky?t.latlng:void 0)},_moveTooltip:function(t){var i,e,n=t.latlng;this._tooltip.options.sticky&&t.originalEvent&&(i=this._map.mouseEventToContainerPoint(t.originalEvent),e=this._map.containerPointToLayerPoint(i),n=this._map.layerPointToLatLng(e)),this._tooltip.setLatLng(n)}});var nn=Se.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(t){var i,e=t&&"DIV"===t.tagName?t:document.createElement("div"),n=this.options;return n.html instanceof Element?(ai(e),e.appendChild(n.html)):e.innerHTML=!1!==n.html?n.html:"",n.bgPos&&(i=A(n.bgPos),e.style.backgroundPosition=-i.x+"px "+-i.y+"px"),this._setIconStyles(e,"icon"),e},createShadow:function(){return null}});Se.Default=Ze;var on=Me.extend({options:{tileSize:256,opacity:1,updateWhenIdle:yt,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(t){c(this,t)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView(),this._update()},beforeAdd:function(t){t._addZoomLimit(this)},onRemove:function(t){this._removeAllTiles(),ri(this._container),t._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(hi(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(ui(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(t){return this.options.opacity=t,this._updateOpacity(),this},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){return this._map&&(this._removeAllTiles(),this._update()),this},getEvents:function(){var t={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=n(this._onMoveEnd,this.options.updateInterval,this)),t.move=this._onMove),this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},createTile:function(){return document.createElement("div")},getTileSize:function(){var t=this.options.tileSize;return t instanceof k?t:new k(t,t)},_updateZIndex:function(){this._container&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(t){for(var i,e=this.getPane().children,n=-t(-1/0,1/0),o=0,s=e.length;o<s;o++)i=e[o].style.zIndex,e[o]!==this._container&&i&&(n=t(n,+i));isFinite(n)&&(this.options.zIndex=n+t(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!it){mi(this._container,this.options.opacity);var t=+new Date,i=!1,e=!1;for(var n in this._tiles){var o,s=this._tiles[n];s.current&&s.loaded&&(o=Math.min(1,(t-s.loaded)/200),mi(s.el,o),o<1?i=!0:(s.active?e=!0:this._onOpaqueTile(s),s.active=!0))}e&&!this._noPrune&&this._pruneTiles(),i&&(z(this._fadeFrame),this._fadeFrame=M(this._updateOpacity,this))}},_onOpaqueTile:a,_initContainer:function(){this._container||(this._container=si("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var t=this._tileZoom,i=this.options.maxZoom;if(void 0!==t){for(var e in this._levels)e=Number(e),this._levels[e].el.children.length||e===t?(this._levels[e].el.style.zIndex=i-Math.abs(t-e),this._onUpdateLevel(e)):(ri(this._levels[e].el),this._removeTilesAtZoom(e),this._onRemoveLevel(e),delete this._levels[e]);var n=this._levels[t],o=this._map;return n||((n=this._levels[t]={}).el=si("div","leaflet-tile-container leaflet-zoom-animated",this._container),n.el.style.zIndex=i,n.origin=o.project(o.unproject(o.getPixelOrigin()),t).round(),n.zoom=t,this._setZoomTransform(n,o.getCenter(),o.getZoom()),a(n.el.offsetWidth),this._onCreateLevel(n)),this._level=n}},_onUpdateLevel:a,_onRemoveLevel:a,_onCreateLevel:a,_pruneTiles:function(){if(this._map){var t,i,e,n=this._map.getZoom();if(n>this.options.maxZoom||n<this.options.minZoom)this._removeAllTiles();else{for(t in this._tiles)(e=this._tiles[t]).retain=e.current;for(t in this._tiles){(e=this._tiles[t]).current&&!e.active&&(i=e.coords,this._retainParent(i.x,i.y,i.z,i.z-5)||this._retainChildren(i.x,i.y,i.z,i.z+2))}for(t in this._tiles)this._tiles[t].retain||this._removeTile(t)}}},_removeTilesAtZoom:function(t){for(var i in this._tiles)this._tiles[i].coords.z===t&&this._removeTile(i)},_removeAllTiles:function(){for(var t in this._tiles)this._removeTile(t)},_invalidateAll:function(){for(var t in this._levels)ri(this._levels[t].el),this._onRemoveLevel(Number(t)),delete this._levels[t];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(t,i,e,n){var o=Math.floor(t/2),s=Math.floor(i/2),r=e-1,a=new k(+o,+s);a.z=+r;var h=this._tileCoordsToKey(a),u=this._tiles[h];return u&&u.active?u.retain=!0:(u&&u.loaded&&(u.retain=!0),n<r&&this._retainParent(o,s,r,n))},_retainChildren:function(t,i,e,n){for(var o=2*t;o<2*t+2;o++)for(var s=2*i;s<2*i+2;s++){var r=new k(o,s);r.z=e+1;var a=this._tileCoordsToKey(r),h=this._tiles[a];h&&h.active?h.retain=!0:(h&&h.loaded&&(h.retain=!0),e+1<n&&this._retainChildren(o,s,e+1,n))}},_resetView:function(t){var i=t&&(t.pinch||t.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),i,i)},_animateZoom:function(t){this._setView(t.center,t.zoom,!0,t.noUpdate)},_clampZoom:function(t){var i=this.options;return void 0!==i.minNativeZoom&&t<i.minNativeZoom?i.minNativeZoom:void 0!==i.maxNativeZoom&&i.maxNativeZoom<t?i.maxNativeZoom:t},_setView:function(t,i,e,n){var o=Math.round(i),o=void 0!==this.options.maxZoom&&o>this.options.maxZoom||void 0!==this.options.minZoom&&o<this.options.minZoom?void 0:this._clampZoom(o),s=this.options.updateWhenZooming&&o!==this._tileZoom;n&&!s||(this._tileZoom=o,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),void 0!==o&&this._update(t),e||this._pruneTiles(),this._noPrune=!!e),this._setZoomTransforms(t,i)},_setZoomTransforms:function(t,i){for(var e in this._levels)this._setZoomTransform(this._levels[e],t,i)},_setZoomTransform:function(t,i,e){var n=this._map.getZoomScale(e,t.zoom),o=t.origin.multiplyBy(n).subtract(this._map._getNewPixelOrigin(i,e)).round();vt?gi(t.el,o,n):vi(t.el,o)},_resetGrid:function(){var t=this._map,i=t.options.crs,e=this._tileSize=this.getTileSize(),n=this._tileZoom,o=this._map.getPixelWorldBounds(this._tileZoom);o&&(this._globalTileRange=this._pxBoundsToTileRange(o)),this._wrapX=i.wrapLng&&!this.options.noWrap&&[Math.floor(t.project([0,i.wrapLng[0]],n).x/e.x),Math.ceil(t.project([0,i.wrapLng[1]],n).x/e.y)],this._wrapY=i.wrapLat&&!this.options.noWrap&&[Math.floor(t.project([i.wrapLat[0],0],n).y/e.x),Math.ceil(t.project([i.wrapLat[1],0],n).y/e.y)]},_onMoveEnd:function(){this._map&&!this._map._animatingZoom&&this._update()},_getTiledPixelBounds:function(t){var i=this._map,e=i._animatingZoom?Math.max(i._animateToZoom,i.getZoom()):i.getZoom(),n=i.getZoomScale(e,this._tileZoom),o=i.project(t,this._tileZoom).floor(),s=i.getSize().divideBy(2*n);return new I(o.subtract(s),o.add(s))},_update:function(t){var i=this._map;if(i){var e=this._clampZoom(i.getZoom());if(void 0===t&&(t=i.getCenter()),void 0!==this._tileZoom){var n=this._getTiledPixelBounds(t),o=this._pxBoundsToTileRange(n),s=o.getCenter(),r=[],a=this.options.keepBuffer,h=new I(o.getBottomLeft().subtract([a,-a]),o.getTopRight().add([a,-a]));if(!(isFinite(o.min.x)&&isFinite(o.min.y)&&isFinite(o.max.x)&&isFinite(o.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var u in this._tiles){var l=this._tiles[u].coords;l.z===this._tileZoom&&h.contains(new k(l.x,l.y))||(this._tiles[u].current=!1)}if(1<Math.abs(e-this._tileZoom))this._setView(t,e);else{for(var c=o.min.y;c<=o.max.y;c++)for(var _=o.min.x;_<=o.max.x;_++){var d,p=new k(_,c);p.z=this._tileZoom,this._isValidTile(p)&&((d=this._tiles[this._tileCoordsToKey(p)])?d.current=!0:r.push(p))}if(r.sort(function(t,i){return t.distanceTo(s)-i.distanceTo(s)}),0!==r.length){this._loading||(this._loading=!0,this.fire("loading"));for(var m=document.createDocumentFragment(),_=0;_<r.length;_++)this._addTile(r[_],m);this._level.el.appendChild(m)}}}}},_isValidTile:function(t){var i=this._map.options.crs;if(!i.infinite){var e=this._globalTileRange;if(!i.wrapLng&&(t.x<e.min.x||t.x>e.max.x)||!i.wrapLat&&(t.y<e.min.y||t.y>e.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return N(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var i=this._map,e=this.getTileSize(),n=t.scaleBy(e),o=n.add(e);return[i.unproject(n,t.z),i.unproject(o,t.z)]},_tileCoordsToBounds:function(t){var i=this._tileCoordsToNwSe(t),e=new R(i[0],i[1]);return this.options.noWrap||(e=this._map.wrapLatLngBounds(e)),e},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var i=t.split(":"),e=new k(+i[0],+i[1]);return e.z=+i[2],e},_removeTile:function(t){var i=this._tiles[t];i&&(ri(i.el),delete this._tiles[t],this.fire("tileunload",{tile:i.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){ci(t,"leaflet-tile");var i=this.getTileSize();t.style.width=i.x+"px",t.style.height=i.y+"px",t.onselectstart=a,t.onmousemove=a,it&&this.options.opacity<1&&mi(t,this.options.opacity),ot&&!st&&(t.style.WebkitBackfaceVisibility="hidden")},_addTile:function(t,i){var e=this._getTilePos(t),n=this._tileCoordsToKey(t),o=this.createTile(this._wrapCoords(t),p(this._tileReady,this,t));this._initTile(o),this.createTile.length<2&&M(p(this._tileReady,this,t,null,o)),vi(o,e),this._tiles[n]={el:o,coords:t,current:!0},i.appendChild(o),this.fire("tileloadstart",{tile:o,coords:t})},_tileReady:function(t,i,e){i&&this.fire("tileerror",{error:i,tile:e,coords:t});var n=this._tileCoordsToKey(t);(e=this._tiles[n])&&(e.loaded=+new Date,this._map._fadeAnimated?(mi(e.el,0),z(this._fadeFrame),this._fadeFrame=M(this._updateOpacity,this)):(e.active=!0,this._pruneTiles()),i||(ci(e.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:e.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),it||!this._map._fadeAnimated?M(this._pruneTiles,this):setTimeout(p(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var i=new k(this._wrapX?o(t.x,this._wrapX):t.x,this._wrapY?o(t.y,this._wrapY):t.y);return i.z=t.z,i},_pxBoundsToTileRange:function(t){var i=this.getTileSize();return new I(t.min.unscaleBy(i).floor(),t.max.unscaleBy(i).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}});var sn=on.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1},initialize:function(t,i){this._url=t,(i=c(this,i)).detectRetina&&zt&&0<i.maxZoom&&(i.tileSize=Math.floor(i.tileSize/2),i.zoomReverse?(i.zoomOffset--,i.minZoom++):(i.zoomOffset++,i.maxZoom--),i.minZoom=Math.max(0,i.minZoom)),"string"==typeof i.subdomains&&(i.subdomains=i.subdomains.split("")),ot||this.on("tileunload",this._onTileRemove)},setUrl:function(t,i){return this._url===t&&void 0===i&&(i=!0),this._url=t,i||this.redraw(),this},createTile:function(t,i){var e=document.createElement("img");return zi(e,"load",p(this._tileOnLoad,this,i,e)),zi(e,"error",p(this._tileOnError,this,i,e)),!this.options.crossOrigin&&""!==this.options.crossOrigin||(e.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),e.alt="",e.setAttribute("role","presentation"),e.src=this.getTileUrl(t),e},getTileUrl:function(t){var i,e={r:zt?"@2x":"",s:this._getSubdomain(t),x:t.x,y:t.y,z:this._getZoomForUrl()};return this._map&&!this._map.options.crs.infinite&&(i=this._globalTileRange.max.y-t.y,this.options.tms&&(e.y=i),e["-y"]=i),f(this._url,h(e,this.options))},_tileOnLoad:function(t,i){it?setTimeout(p(t,this,null,i),0):t(null,i)},_tileOnError:function(t,i,e){var n=this.options.errorTileUrl;n&&i.getAttribute("src")!==n&&(i.src=n),t(e,i)},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,i=this.options.maxZoom;return this.options.zoomReverse&&(t=i-t),t+this.options.zoomOffset},_getSubdomain:function(t){var i=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[i]},_abortLoading:function(){var t,i;for(t in this._tiles)this._tiles[t].coords.z!==this._tileZoom&&((i=this._tiles[t].el).onload=a,i.onerror=a,i.complete||(i.src=y,ri(i),delete this._tiles[t]))},_removeTile:function(t){var i=this._tiles[t];if(i)return at||i.el.setAttribute("src",y),on.prototype._removeTile.call(this,t)},_tileReady:function(t,i,e){if(this._map&&(!e||e.getAttribute("src")!==y))return on.prototype._tileReady.call(this,t,i,e)}});function rn(t,i){return new sn(t,i)}var an=sn.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(t,i){this._url=t;var e=h({},this.defaultWmsParams);for(var n in i)n in this.options||(e[n]=i[n]);var o=(i=c(this,i)).detectRetina&&zt?2:1,s=this.getTileSize();e.width=s.x*o,e.height=s.y*o,this.wmsParams=e},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var i=1.3<=this._wmsVersion?"crs":"srs";this.wmsParams[i]=this._crs.code,sn.prototype.onAdd.call(this,t)},getTileUrl:function(t){var i=this._tileCoordsToNwSe(t),e=this._crs,n=O(e.project(i[0]),e.project(i[1])),o=n.min,s=n.max,r=(1.3<=this._wmsVersion&&this._crs===be?[o.y,o.x,s.y,s.x]:[o.x,o.y,s.x,s.y]).join(","),a=sn.prototype.getTileUrl.call(this,t);return a+_(this.wmsParams,a,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+r},setParams:function(t,i){return h(this.wmsParams,t),i||this.redraw(),this}});sn.WMS=an,rn.wms=function(t,i){return new an(t,i)};var hn=Me.extend({options:{padding:.1,tolerance:0},initialize:function(t){c(this,t),m(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),this._zoomAnimated&&ci(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var t={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(t.zoomanim=this._onAnimZoom),t},_onAnimZoom:function(t){this._updateTransform(t.center,t.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(t,i){var e=this._map.getZoomScale(i,this._zoom),n=yi(this._container),o=this._map.getSize().multiplyBy(.5+this.options.padding),s=this._map.project(this._center,i),r=this._map.project(t,i).subtract(s),a=o.multiplyBy(-e).add(n).add(o).subtract(r);vt?gi(this._container,a,e):vi(this._container,a)},_reset:function(){for(var t in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[t]._reset()},_onZoomEnd:function(){for(var t in this._layers)this._layers[t]._project()},_updatePaths:function(){for(var t in this._layers)this._layers[t]._update()},_update:function(){var t=this.options.padding,i=this._map.getSize(),e=this._map.containerPointToLayerPoint(i.multiplyBy(-t)).round();this._bounds=new I(e,e.add(i.multiplyBy(1+2*t)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),un=hn.extend({getEvents:function(){var t=hn.prototype.getEvents.call(this);return t.viewprereset=this._onViewPreReset,t},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){hn.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=document.createElement("canvas");zi(t,"mousemove",this._onMouseMove,this),zi(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this),zi(t,"mouseout",this._handleMouseOut,this),this._ctx=t.getContext("2d")},_destroyContainer:function(){z(this._redrawRequest),delete this._ctx,ri(this._container),Si(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){for(var t in this._redrawBounds=null,this._layers)this._layers[t]._update();this._redraw()}},_update:function(){var t,i,e,n;this._map._animatingZoom&&this._bounds||(hn.prototype._update.call(this),t=this._bounds,i=this._container,e=t.getSize(),n=zt?2:1,vi(i,t.min),i.width=n*e.x,i.height=n*e.y,i.style.width=e.x+"px",i.style.height=e.y+"px",zt&&this._ctx.scale(2,2),this._ctx.translate(-t.min.x,-t.min.y),this.fire("update"))},_reset:function(){hn.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(t){this._updateDashArray(t);var i=(this._layers[m(t)]=t)._order={layer:t,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=i),this._drawLast=i,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(t){var i=t._order,e=i.next,n=i.prev;e?e.prev=n:this._drawLast=n,n?n.next=e:this._drawFirst=e,delete t._order,delete this._layers[m(t)],this._requestRedraw(t)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(t){if("string"==typeof t.options.dashArray){for(var i,e=t.options.dashArray.split(/[, ]+/),n=[],o=0;o<e.length;o++){if(i=Number(e[o]),isNaN(i))return;n.push(i)}t.options._dashArray=n}else t.options._dashArray=t.options.dashArray},_requestRedraw:function(t){this._map&&(this._extendRedrawBounds(t),this._redrawRequest=this._redrawRequest||M(this._redraw,this))},_extendRedrawBounds:function(t){var i;t._pxBounds&&(i=(t.options.weight||0)+1,this._redrawBounds=this._redrawBounds||new I,this._redrawBounds.extend(t._pxBounds.min.subtract([i,i])),this._redrawBounds.extend(t._pxBounds.max.add([i,i])))},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var t,i=this._redrawBounds;i?(t=i.getSize(),this._ctx.clearRect(i.min.x,i.min.y,t.x,t.y)):(this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore())},_draw:function(){var t,i,e=this._redrawBounds;this._ctx.save(),e&&(i=e.getSize(),this._ctx.beginPath(),this._ctx.rect(e.min.x,e.min.y,i.x,i.y),this._ctx.clip()),this._drawing=!0;for(var n=this._drawFirst;n;n=n.next)t=n.layer,(!e||t._pxBounds&&t._pxBounds.intersects(e))&&t._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(t,i){if(this._drawing){var e,n,o,s,r=t._parts,a=r.length,h=this._ctx;if(a){for(h.beginPath(),e=0;e<a;e++){for(n=0,o=r[e].length;n<o;n++)s=r[e][n],h[n?"lineTo":"moveTo"](s.x,s.y);i&&h.closePath()}this._fillStroke(h,t)}}},_updateCircle:function(t){var i,e,n,o;this._drawing&&!t._empty()&&(i=t._point,e=this._ctx,n=Math.max(Math.round(t._radius),1),1!=(o=(Math.max(Math.round(t._radiusY),1)||n)/n)&&(e.save(),e.scale(1,o)),e.beginPath(),e.arc(i.x,i.y/o,n,0,2*Math.PI,!1),1!=o&&e.restore(),this._fillStroke(e,t))},_fillStroke:function(t,i){var e=i.options;e.fill&&(t.globalAlpha=e.fillOpacity,t.fillStyle=e.fillColor||e.color,t.fill(e.fillRule||"evenodd")),e.stroke&&0!==e.weight&&(t.setLineDash&&t.setLineDash(i.options&&i.options._dashArray||[]),t.globalAlpha=e.opacity,t.lineWidth=e.weight,t.strokeStyle=e.color,t.lineCap=e.lineCap,t.lineJoin=e.lineJoin,t.stroke())},_onClick:function(t){for(var i,e,n=this._map.mouseEventToLayerPoint(t),o=this._drawFirst;o;o=o.next)(i=o.layer).options.interactive&&i._containsPoint(n)&&(("click"===t.type||"preclick"!==t.type)&&this._map._draggableMoved(i)||(e=i));e&&(Fi(t),this._fireEvent([e],t))},_onMouseMove:function(t){var i;!this._map||this._map.dragging.moving()||this._map._animatingZoom||(i=this._map.mouseEventToLayerPoint(t),this._handleMouseHover(t,i))},_handleMouseOut:function(t){var i=this._hoveredLayer;i&&(_i(this._container,"leaflet-interactive"),this._fireEvent([i],t,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(t,i){if(!this._mouseHoverThrottled){for(var e,n,o=this._drawFirst;o;o=o.next)(e=o.layer).options.interactive&&e._containsPoint(i)&&(n=e);n!==this._hoveredLayer&&(this._handleMouseOut(t),n&&(ci(this._container,"leaflet-interactive"),this._fireEvent([n],t,"mouseover"),this._hoveredLayer=n)),this._hoveredLayer&&this._fireEvent([this._hoveredLayer],t),this._mouseHoverThrottled=!0,setTimeout(p(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(t,i,e){this._map._fireDOMEvent(i,e||i.type,t)},_bringToFront:function(t){var i,e,n=t._order;n&&(i=n.next,e=n.prev,i&&((i.prev=e)?e.next=i:i&&(this._drawFirst=i),n.prev=this._drawLast,(this._drawLast.next=n).next=null,this._drawLast=n,this._requestRedraw(t)))},_bringToBack:function(t){var i,e,n=t._order;n&&(i=n.next,(e=n.prev)&&((e.next=i)?i.prev=e:e&&(this._drawLast=e),n.prev=null,n.next=this._drawFirst,this._drawFirst.prev=n,this._drawFirst=n,this._requestRedraw(t)))}});function ln(t){return St?new un(t):null}var cn=function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(t){return document.createElement("<lvml:"+t+' class="lvml">')}}catch(t){return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_n={_initContainer:function(){this._container=si("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(hn.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var i=t._container=cn("shape");ci(i,"leaflet-vml-shape "+(this.options.className||"")),i.coordsize="1 1",t._path=cn("path"),i.appendChild(t._path),this._updateStyle(t),this._layers[m(t)]=t},_addPath:function(t){var i=t._container;this._container.appendChild(i),t.options.interactive&&t.addInteractiveTarget(i)},_removePath:function(t){var i=t._container;ri(i),t.removeInteractiveTarget(i),delete this._layers[m(t)]},_updateStyle:function(t){var i=t._stroke,e=t._fill,n=t.options,o=t._container;o.stroked=!!n.stroke,o.filled=!!n.fill,n.stroke?(i=i||(t._stroke=cn("stroke")),o.appendChild(i),i.weight=n.weight+"px",i.color=n.color,i.opacity=n.opacity,n.dashArray?i.dashStyle=g(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):i.dashStyle="",i.endcap=n.lineCap.replace("butt","flat"),i.joinstyle=n.lineJoin):i&&(o.removeChild(i),t._stroke=null),n.fill?(e=e||(t._fill=cn("fill")),o.appendChild(e),e.color=n.fillColor||n.color,e.opacity=n.fillOpacity):e&&(o.removeChild(e),t._fill=null)},_updateCircle:function(t){var i=t._point.round(),e=Math.round(t._radius),n=Math.round(t._radiusY||e);this._setPath(t,t._empty()?"M0 0":"AL "+i.x+","+i.y+" "+e+","+n+" 0,23592600")},_setPath:function(t,i){t._path.v=i},_bringToFront:function(t){hi(t._container)},_bringToBack:function(t){ui(t._container)}},dn=Et?cn:J,pn=hn.extend({getEvents:function(){var t=hn.prototype.getEvents.call(this);return t.zoomstart=this._onZoomStart,t},_initContainer:function(){this._container=dn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=dn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ri(this._container),Si(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_onZoomStart:function(){this._update()},_update:function(){var t,i,e;this._map._animatingZoom&&this._bounds||(hn.prototype._update.call(this),i=(t=this._bounds).getSize(),e=this._container,this._svgSize&&this._svgSize.equals(i)||(this._svgSize=i,e.setAttribute("width",i.x),e.setAttribute("height",i.y)),vi(e,t.min),e.setAttribute("viewBox",[t.min.x,t.min.y,i.x,i.y].join(" ")),this.fire("update"))},_initPath:function(t){var i=t._path=dn("path");t.options.className&&ci(i,t.options.className),t.options.interactive&&ci(i,"leaflet-interactive"),this._updateStyle(t),this._layers[m(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){ri(t._path),t.removeInteractiveTarget(t._path),delete this._layers[m(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var i=t._path,e=t.options;i&&(e.stroke?(i.setAttribute("stroke",e.color),i.setAttribute("stroke-opacity",e.opacity),i.setAttribute("stroke-width",e.weight),i.setAttribute("stroke-linecap",e.lineCap),i.setAttribute("stroke-linejoin",e.lineJoin),e.dashArray?i.setAttribute("stroke-dasharray",e.dashArray):i.removeAttribute("stroke-dasharray"),e.dashOffset?i.setAttribute("stroke-dashoffset",e.dashOffset):i.removeAttribute("stroke-dashoffset")):i.setAttribute("stroke","none"),e.fill?(i.setAttribute("fill",e.fillColor||e.color),i.setAttribute("fill-opacity",e.fillOpacity),i.setAttribute("fill-rule",e.fillRule||"evenodd")):i.setAttribute("fill","none"))},_updatePoly:function(t,i){this._setPath(t,$(t._parts,i))},_updateCircle:function(t){var i=t._point,e=Math.max(Math.round(t._radius),1),n="a"+e+","+(Math.max(Math.round(t._radiusY),1)||e)+" 0 1,0 ",o=t._empty()?"M0 0":"M"+(i.x-e)+","+i.y+n+2*e+",0 "+n+2*-e+",0 ";this._setPath(t,o)},_setPath:function(t,i){t._path.setAttribute("d",i)},_bringToFront:function(t){hi(t._path)},_bringToBack:function(t){ui(t._path)}});function mn(t){return Zt||Et?new pn(t):null}Et&&pn.include(_n),Ki.include({getRenderer:function(t){var i=(i=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer)||(this._renderer=this._createRenderer());return this.hasLayer(i)||this.addLayer(i),i},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var i=this._paneRenderers[t];return void 0===i&&(i=this._createRenderer({pane:t}),this._paneRenderers[t]=i),i},_createRenderer:function(t){return this.options.preferCanvas&&ln(t)||mn(t)}});var fn=Re.extend({initialize:function(t,i){Re.prototype.initialize.call(this,this._boundsToLatLngs(t),i)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=N(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});pn.create=dn,pn.pointsToPath=$,Ne.geometryToLayer=De,Ne.coordsToLatLng=We,Ne.coordsToLatLngs=He,Ne.latLngToCoords=Fe,Ne.latLngsToCoords=Ue,Ne.getFeature=Ve,Ne.asFeature=qe,Ki.mergeOptions({boxZoom:!0});var gn=ie.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){zi(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Si(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ri(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),Xt(),xi(),this._startPoint=this._map.mouseEventToContainerPoint(t),zi(document,{contextmenu:Ni,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=si("div","leaflet-zoom-box",this._container),ci(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var i=new I(this._point,this._startPoint),e=i.getSize();vi(this._box,i.min),this._box.style.width=e.x+"px",this._box.style.height=e.y+"px"},_finish:function(){this._moved&&(ri(this._box),_i(this._container,"leaflet-crosshair")),Jt(),wi(),Si(document,{contextmenu:Ni,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){var i;1!==t.which&&1!==t.button||(this._finish(),this._moved&&(this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(p(this._resetState,this),0),i=new R(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point)),this._map.fitBounds(i).fire("boxzoomend",{boxZoomBounds:i})))},_onKeyDown:function(t){27===t.keyCode&&this._finish()}});Ki.addInitHook("addHandler","boxZoom",gn),Ki.mergeOptions({doubleClickZoom:!0});var vn=ie.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var i=this._map,e=i.getZoom(),n=i.options.zoomDelta,o=t.originalEvent.shiftKey?e-n:e+n;"center"===i.options.doubleClickZoom?i.setZoom(o):i.setZoomAround(t.containerPoint,o)}});Ki.addInitHook("addHandler","doubleClickZoom",vn),Ki.mergeOptions({dragging:!0,inertia:!st,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var yn=ie.extend({addHooks:function(){var t;this._draggable||(t=this._map,this._draggable=new ae(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))),ci(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){_i(this._map._container,"leaflet-grab"),_i(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t,i=this._map;i._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity?(t=N(this._map.options.maxBounds),this._offsetLimit=O(this._map.latLngToContainerPoint(t.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(t.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))):this._offsetLimit=null,i.fire("movestart").fire("dragstart"),i.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){var i,e;this._map.options.inertia&&(i=this._lastTime=+new Date,e=this._lastPos=this._draggable._absPos||this._draggable._newPos,this._positions.push(e),this._times.push(i),this._prunePositions(i)),this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;1<this._positions.length&&50<t-this._times[0];)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var t=this._map.getSize().divideBy(2),i=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=i.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(t,i){return t-(t-i)*this._viscosity},_onPreDragLimit:function(){var t,i;this._viscosity&&this._offsetLimit&&(t=this._draggable._newPos.subtract(this._draggable._startPos),i=this._offsetLimit,t.x<i.min.x&&(t.x=this._viscousLimit(t.x,i.min.x)),t.y<i.min.y&&(t.y=this._viscousLimit(t.y,i.min.y)),t.x>i.max.x&&(t.x=this._viscousLimit(t.x,i.max.x)),t.y>i.max.y&&(t.y=this._viscousLimit(t.y,i.max.y)),this._draggable._newPos=this._draggable._startPos.add(t))},_onPreDragWrap:function(){var t=this._worldWidth,i=Math.round(t/2),e=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-i+e)%t+i-e,s=(n+i+e)%t-i-e,r=Math.abs(o+e)<Math.abs(s+e)?o:s;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=r},_onDragEnd:function(t){var i,e,n,o,s,r,a,h,u,l=this._map,c=l.options,_=!c.inertia||this._times.length<2;l.fire("dragend",t),_?l.fire("moveend"):(this._prunePositions(+new Date),i=this._lastPos.subtract(this._positions[0]),e=(this._lastTime-this._times[0])/1e3,n=c.easeLinearity,s=(o=i.multiplyBy(n/e)).distanceTo([0,0]),r=Math.min(c.inertiaMaxSpeed,s),a=o.multiplyBy(r/s),h=r/(c.inertiaDeceleration*n),(u=a.multiplyBy(-h/2).round()).x||u.y?(u=l._limitOffset(u,l.options.maxBounds),M(function(){l.panBy(u,{duration:h,easeLinearity:n,noMoveStart:!0,animate:!0})})):l.fire("moveend"))}});Ki.addInitHook("addHandler","dragging",yn),Ki.mergeOptions({keyboard:!0,keyboardPanDelta:80});var xn=ie.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(t){this._map=t,this._setPanDelta(t.options.keyboardPanDelta),this._setZoomDelta(t.options.zoomDelta)},addHooks:function(){var t=this._map._container;t.tabIndex<=0&&(t.tabIndex="0"),zi(t,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),Si(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){var t,i,e,n;this._focused||(t=document.body,i=document.documentElement,e=t.scrollTop||i.scrollTop,n=t.scrollLeft||i.scrollLeft,this._map._container.focus(),window.scrollTo(n,e))},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(t){for(var i=this._panKeys={},e=this.keyCodes,n=0,o=e.left.length;n<o;n++)i[e.left[n]]=[-1*t,0];for(n=0,o=e.right.length;n<o;n++)i[e.right[n]]=[t,0];for(n=0,o=e.down.length;n<o;n++)i[e.down[n]]=[0,t];for(n=0,o=e.up.length;n<o;n++)i[e.up[n]]=[0,-1*t]},_setZoomDelta:function(t){for(var i=this._zoomKeys={},e=this.keyCodes,n=0,o=e.zoomIn.length;n<o;n++)i[e.zoomIn[n]]=t;for(n=0,o=e.zoomOut.length;n<o;n++)i[e.zoomOut[n]]=-t},_addHooks:function(){zi(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){Si(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(t){if(!(t.altKey||t.ctrlKey||t.metaKey)){var i,e=t.keyCode,n=this._map;if(e in this._panKeys)n._panAnim&&n._panAnim._inProgress||(i=this._panKeys[e],t.shiftKey&&(i=A(i).multiplyBy(3)),n.panBy(i),n.options.maxBounds&&n.panInsideBounds(n.options.maxBounds));else if(e in this._zoomKeys)n.setZoom(n.getZoom()+(t.shiftKey?3:1)*this._zoomKeys[e]);else{if(27!==e||!n._popup||!n._popup.options.closeOnEscapeKey)return;n.closePopup()}Ni(t)}}});Ki.addInitHook("addHandler","keyboard",xn),Ki.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var wn=ie.extend({addHooks:function(){zi(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){Si(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(t){var i=Wi(t),e=this._map.options.wheelDebounceTime;this._delta+=i,this._lastMousePos=this._map.mouseEventToContainerPoint(t),this._startTime||(this._startTime=+new Date);var n=Math.max(e-(new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(p(this._performZoom,this),n),Ni(t)},_performZoom:function(){var t=this._map,i=t.getZoom(),e=this._map.options.zoomSnap||0;t._stop();var n=this._delta/(4*this._map.options.wheelPxPerZoomLevel),o=4*Math.log(2/(1+Math.exp(-Math.abs(n))))/Math.LN2,s=e?Math.ceil(o/e)*e:o,r=t._limitZoom(i+(0<this._delta?s:-s))-i;this._delta=0,this._startTime=null,r&&("center"===t.options.scrollWheelZoom?t.setZoom(i+r):t.setZoomAround(this._lastMousePos,i+r))}});Ki.addInitHook("addHandler","scrollWheelZoom",wn),Ki.mergeOptions({tap:!0,tapTolerance:15});var Pn=ie.extend({addHooks:function(){zi(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Si(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(t.touches){if(Ri(t),this._fireClick=!0,1<t.touches.length)return this._fireClick=!1,void clearTimeout(this._holdTimeout);var i=t.touches[0],e=i.target;this._startPos=this._newPos=new k(i.clientX,i.clientY),e.tagName&&"a"===e.tagName.toLowerCase()&&ci(e,"leaflet-active"),this._holdTimeout=setTimeout(p(function(){this._isTapValid()&&(this._fireClick=!1,this._onUp(),this._simulateEvent("contextmenu",i))},this),1e3),this._simulateEvent("mousedown",i),zi(document,{touchmove:this._onMove,touchend:this._onUp},this)}},_onUp:function(t){var i,e;clearTimeout(this._holdTimeout),Si(document,{touchmove:this._onMove,touchend:this._onUp},this),this._fireClick&&t&&t.changedTouches&&((e=(i=t.changedTouches[0]).target)&&e.tagName&&"a"===e.tagName.toLowerCase()&&_i(e,"leaflet-active"),this._simulateEvent("mouseup",i),this._isTapValid()&&this._simulateEvent("click",i))},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_onMove:function(t){var i=t.touches[0];this._newPos=new k(i.clientX,i.clientY),this._simulateEvent("mousemove",i)},_simulateEvent:function(t,i){var e=document.createEvent("MouseEvents");e._simulated=!0,i.target._simulatedClick=!0,e.initMouseEvent(t,!0,!0,window,1,i.screenX,i.screenY,i.clientX,i.clientY,!1,!1,!1,!1,0,null),i.target.dispatchEvent(e)}});!bt||Lt&&!ct||Ki.addInitHook("addHandler","tap",Pn),Ki.mergeOptions({touchZoom:bt&&!st,bounceAtZoomLimits:!0});var Ln=ie.extend({addHooks:function(){ci(this._map._container,"leaflet-touch-zoom"),zi(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){_i(this._map._container,"leaflet-touch-zoom"),Si(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var i,e,n=this._map;!t.touches||2!==t.touches.length||n._animatingZoom||this._zooming||(i=n.mouseEventToContainerPoint(t.touches[0]),e=n.mouseEventToContainerPoint(t.touches[1]),this._centerPoint=n.getSize()._divideBy(2),this._startLatLng=n.containerPointToLatLng(this._centerPoint),"center"!==n.options.touchZoom&&(this._pinchStartLatLng=n.containerPointToLatLng(i.add(e)._divideBy(2))),this._startDist=i.distanceTo(e),this._startZoom=n.getZoom(),this._moved=!1,this._zooming=!0,n._stop(),zi(document,"touchmove",this._onTouchMove,this),zi(document,"touchend",this._onTouchEnd,this),Ri(t))},_onTouchMove:function(t){if(t.touches&&2===t.touches.length&&this._zooming){var i=this._map,e=i.mouseEventToContainerPoint(t.touches[0]),n=i.mouseEventToContainerPoint(t.touches[1]),o=e.distanceTo(n)/this._startDist;if(this._zoom=i.getScaleZoom(o,this._startZoom),!i.options.bounceAtZoomLimits&&(this._zoom<i.getMinZoom()&&o<1||this._zoom>i.getMaxZoom()&&1<o)&&(this._zoom=i._limitZoom(this._zoom)),"center"===i.options.touchZoom){if(this._center=this._startLatLng,1==o)return}else{var s=e._add(n)._divideBy(2)._subtract(this._centerPoint);if(1==o&&0===s.x&&0===s.y)return;this._center=i.unproject(i.project(this._pinchStartLatLng,this._zoom).subtract(s),this._zoom)}this._moved||(i._moveStart(!0,!1),this._moved=!0),z(this._animRequest);var r=p(i._move,i,this._center,this._zoom,{pinch:!0,round:!1});this._animRequest=M(r,this,!0),Ri(t)}},_onTouchEnd:function(){this._moved&&this._zooming?(this._zooming=!1,z(this._animRequest),Si(document,"touchmove",this._onTouchMove,this),Si(document,"touchend",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))):this._zooming=!1}});Ki.addInitHook("addHandler","touchZoom",Ln),Ki.BoxZoom=gn,Ki.DoubleClickZoom=vn,Ki.Drag=yn,Ki.Keyboard=xn,Ki.ScrollWheelZoom=wn,Ki.Tap=Pn,Ki.TouchZoom=Ln,t.version="1.7.1",t.Control=Xi,t.control=Yi,t.Browser=Bt,t.Evented=E,t.Mixin=ne,t.Util=C,t.Class=S,t.Handler=ie,t.extend=h,t.bind=p,t.stamp=m,t.setOptions=c,t.DomEvent=qi,t.DomUtil=Mi,t.PosAnimation=Gi,t.Draggable=ae,t.LineUtil=fe,t.PolyUtil=ye,t.Point=k,t.point=A,t.Bounds=I,t.bounds=O,t.Transformation=q,t.transformation=G,t.Projection=Pe,t.LatLng=D,t.latLng=j,t.LatLngBounds=R,t.latLngBounds=N,t.CRS=H,t.GeoJSON=Ne,t.geoJSON=Ke,t.geoJson=Ye,t.Layer=Me,t.LayerGroup=ze,t.layerGroup=function(t,i){return new ze(t,i)},t.FeatureGroup=Ce,t.featureGroup=function(t,i){return new Ce(t,i)},t.ImageOverlay=Xe,t.imageOverlay=function(t,i,e){return new Xe(t,i,e)},t.VideoOverlay=Je,t.videoOverlay=function(t,i,e){return new Je(t,i,e)},t.SVGOverlay=$e,t.svgOverlay=function(t,i,e){return new $e(t,i,e)},t.DivOverlay=Qe,t.Popup=tn,t.popup=function(t,i){return new tn(t,i)},t.Tooltip=en,t.tooltip=function(t,i){return new en(t,i)},t.Icon=Se,t.icon=function(t){return new Se(t)},t.DivIcon=nn,t.divIcon=function(t){return new nn(t)},t.Marker=ke,t.marker=function(t,i){return new ke(t,i)},t.TileLayer=sn,t.tileLayer=rn,t.GridLayer=on,t.gridLayer=function(t){return new on(t)},t.SVG=pn,t.svg=mn,t.Renderer=hn,t.Canvas=un,t.canvas=ln,t.Path=Be,t.CircleMarker=Ae,t.circleMarker=function(t,i){return new Ae(t,i)},t.Circle=Ie,t.circle=function(t,i,e){return new Ie(t,i,e)},t.Polyline=Oe,t.polyline=function(t,i){return new Oe(t,i)},t.Polygon=Re,t.polygon=function(t,i){return new Re(t,i)},t.Rectangle=fn,t.rectangle=function(t,i){return new fn(t,i)},t.Map=Ki,t.map=function(t,i){return new Ki(t,i)};var bn=window.L;t.noConflict=function(){return window.L=bn,this},window.L=t});
6
  //# sourceMappingURL=leaflet.js.map
2
  * Leaflet 1.7.1, a JS library for interactive maps. http://leafletjs.com
3
  * (c) 2010-2019 Vladimir Agafonkin, (c) 2010-2011 CloudMade
4
  */
5
+ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.L={})}(this,function(t){"use strict";function h(t){for(var i,e,n=1,o=arguments.length;n<o;n++)for(i in e=arguments[n])t[i]=e[i];return t}var s=Object.create||function(t){return i.prototype=t,new i};function i(){}function p(t,i){var e=Array.prototype.slice;if(t.bind)return t.bind.apply(t,e.call(arguments,1));var n=e.call(arguments,2);return function(){return t.apply(i,n.length?n.concat(e.call(arguments)):arguments)}}var e=0;function m(t){return t._leaflet_id=t._leaflet_id||++e,t._leaflet_id}function n(t,i,e){var n,o,s=function(){n=!1,o&&(r.apply(e,o),o=!1)},r=function(){n?o=arguments:(t.apply(e,arguments),setTimeout(s,i),n=!0)};return r}function o(t,i,e){var n=i[1],o=i[0],s=n-o;return t===n&&e?t:((t-o)%s+s)%s+o}function a(){return!1}function r(t,i){var e=Math.pow(10,void 0===i?6:i);return Math.round(t*e)/e}function u(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function l(t){return u(t).split(/\s+/)}function c(t,i){for(var e in Object.prototype.hasOwnProperty.call(t,"options")||(t.options=t.options?s(t.options):{}),i)t.options[e]=i[e];return t.options}function _(t,i,e){var n=[];for(var o in t)n.push(encodeURIComponent(e?o.toUpperCase():o)+"="+encodeURIComponent(t[o]));return(i&&-1!==i.indexOf("?")?"&":"?")+n.join("&")}var d=/\{ *([\w_-]+) *\}/g;function f(t,n){return t.replace(d,function(t,i){var e=n[i];if(void 0===e)throw new Error("No value provided for variable "+t);return"function"==typeof e&&(e=e(n)),e})}var g=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function v(t,i){for(var e=0;e<t.length;e++)if(t[e]===i)return e;return-1}var y="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function x(t){return window["webkit"+t]||window["moz"+t]||window["ms"+t]}var w=0;function P(t){var i=+new Date,e=Math.max(0,16-(i-w));return w=i+e,window.setTimeout(t,e)}var b=window.requestAnimationFrame||x("RequestAnimationFrame")||P,T=window.cancelAnimationFrame||x("CancelAnimationFrame")||x("CancelRequestAnimationFrame")||function(t){window.clearTimeout(t)};function M(t,i,e){if(!e||b!==P)return b.call(window,p(t,i));t.call(i)}function z(t){t&&T.call(window,t)}var C={extend:h,create:s,bind:p,lastId:e,stamp:m,throttle:n,wrapNum:o,falseFn:a,formatNum:r,trim:u,splitWords:l,setOptions:c,getParamString:_,template:f,isArray:g,indexOf:v,emptyImageUrl:y,requestFn:b,cancelFn:T,requestAnimFrame:M,cancelAnimFrame:z};function S(){}S.extend=function(t){function i(){this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()}var e=i.__super__=this.prototype,n=s(e);for(var o in(n.constructor=i).prototype=n,this)Object.prototype.hasOwnProperty.call(this,o)&&"prototype"!==o&&"__super__"!==o&&(i[o]=this[o]);return t.statics&&(h(i,t.statics),delete t.statics),t.includes&&(function(t){if("undefined"==typeof L||!L||!L.Mixin)return;t=g(t)?t:[t];for(var i=0;i<t.length;i++)t[i]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",(new Error).stack)}(t.includes),h.apply(null,[n].concat(t.includes)),delete t.includes),n.options&&(t.options=h(s(n.options),t.options)),h(n,t),n._initHooks=[],n.callInitHooks=function(){if(!this._initHooksCalled){e.callInitHooks&&e.callInitHooks.call(this),this._initHooksCalled=!0;for(var t=0,i=n._initHooks.length;t<i;t++)n._initHooks[t].call(this)}},i},S.include=function(t){return h(this.prototype,t),this},S.mergeOptions=function(t){return h(this.prototype.options,t),this},S.addInitHook=function(t){var i=Array.prototype.slice.call(arguments,1),e="function"==typeof t?t:function(){this[t].apply(this,i)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(e),this};var Z={on:function(t,i,e){if("object"==typeof t)for(var n in t)this._on(n,t[n],i);else for(var o=0,s=(t=l(t)).length;o<s;o++)this._on(t[o],i,e);return this},off:function(t,i,e){if(t)if("object"==typeof t)for(var n in t)this._off(n,t[n],i);else for(var o=0,s=(t=l(t)).length;o<s;o++)this._off(t[o],i,e);else delete this._events;return this},_on:function(t,i,e){this._events=this._events||{};var n=this._events[t];n||(n=[],this._events[t]=n),e===this&&(e=void 0);for(var o={fn:i,ctx:e},s=n,r=0,a=s.length;r<a;r++)if(s[r].fn===i&&s[r].ctx===e)return;s.push(o)},_off:function(t,i,e){var n,o,s;if(this._events&&(n=this._events[t]))if(i){if(e===this&&(e=void 0),n)for(o=0,s=n.length;o<s;o++){var r=n[o];if(r.ctx===e&&r.fn===i)return r.fn=a,this._firingCount&&(this._events[t]=n=n.slice()),void n.splice(o,1)}}else{for(o=0,s=n.length;o<s;o++)n[o].fn=a;delete this._events[t]}},fire:function(t,i,e){if(!this.listens(t,e))return this;var n=h({},i,{type:t,target:this,sourceTarget:i&&i.sourceTarget||this});if(this._events){var o=this._events[t];if(o){this._firingCount=this._firingCount+1||1;for(var s=0,r=o.length;s<r;s++){var a=o[s];a.fn.call(a.ctx||this,n)}this._firingCount--}}return e&&this._propagateEvent(n),this},listens:function(t,i){var e=this._events&&this._events[t];if(e&&e.length)return!0;if(i)for(var n in this._eventParents)if(this._eventParents[n].listens(t,i))return!0;return!1},once:function(t,i,e){if("object"==typeof t){for(var n in t)this.once(n,t[n],i);return this}var o=p(function(){this.off(t,i,e).off(t,o,e)},this);return this.on(t,i,e).on(t,o,e)},addEventParent:function(t){return this._eventParents=this._eventParents||{},this._eventParents[m(t)]=t,this},removeEventParent:function(t){return this._eventParents&&delete this._eventParents[m(t)],this},_propagateEvent:function(t){for(var i in this._eventParents)this._eventParents[i].fire(t.type,h({layer:t.target,propagatedFrom:t.target},t),!0)}};Z.addEventListener=Z.on,Z.removeEventListener=Z.clearAllEventListeners=Z.off,Z.addOneTimeEventListener=Z.once,Z.fireEvent=Z.fire,Z.hasEventListeners=Z.listens;var E=S.extend(Z);function k(t,i,e){this.x=e?Math.round(t):t,this.y=e?Math.round(i):i}var B=Math.trunc||function(t){return 0<t?Math.floor(t):Math.ceil(t)};function A(t,i,e){return t instanceof k?t:g(t)?new k(t[0],t[1]):null==t?t:"object"==typeof t&&"x"in t&&"y"in t?new k(t.x,t.y):new k(t,i,e)}function I(t,i){if(t)for(var e=i?[t,i]:t,n=0,o=e.length;n<o;n++)this.extend(e[n])}function O(t,i){return!t||t instanceof I?t:new I(t,i)}function R(t,i){if(t)for(var e=i?[t,i]:t,n=0,o=e.length;n<o;n++)this.extend(e[n])}function N(t,i){return t instanceof R?t:new R(t,i)}function D(t,i,e){if(isNaN(t)||isNaN(i))throw new Error("Invalid LatLng object: ("+t+", "+i+")");this.lat=+t,this.lng=+i,void 0!==e&&(this.alt=+e)}function j(t,i,e){return t instanceof D?t:g(t)&&"object"!=typeof t[0]?3===t.length?new D(t[0],t[1],t[2]):2===t.length?new D(t[0],t[1]):null:null==t?t:"object"==typeof t&&"lat"in t?new D(t.lat,"lng"in t?t.lng:t.lon,t.alt):void 0===i?null:new D(t,i,e)}k.prototype={clone:function(){return new k(this.x,this.y)},add:function(t){return this.clone()._add(A(t))},_add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.clone()._subtract(A(t))},_subtract:function(t){return this.x-=t.x,this.y-=t.y,this},divideBy:function(t){return this.clone()._divideBy(t)},_divideBy:function(t){return this.x/=t,this.y/=t,this},multiplyBy:function(t){return this.clone()._multiplyBy(t)},_multiplyBy:function(t){return this.x*=t,this.y*=t,this},scaleBy:function(t){return new k(this.x*t.x,this.y*t.y)},unscaleBy:function(t){return new k(this.x/t.x,this.y/t.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=B(this.x),this.y=B(this.y),this},distanceTo:function(t){var i=(t=A(t)).x-this.x,e=t.y-this.y;return Math.sqrt(i*i+e*e)},equals:function(t){return(t=A(t)).x===this.x&&t.y===this.y},contains:function(t){return t=A(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)},toString:function(){return"Point("+r(this.x)+", "+r(this.y)+")"}},I.prototype={extend:function(t){return t=A(t),this.min||this.max?(this.min.x=Math.min(t.x,this.min.x),this.max.x=Math.max(t.x,this.max.x),this.min.y=Math.min(t.y,this.min.y),this.max.y=Math.max(t.y,this.max.y)):(this.min=t.clone(),this.max=t.clone()),this},getCenter:function(t){return new k((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,t)},getBottomLeft:function(){return new k(this.min.x,this.max.y)},getTopRight:function(){return new k(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(t){var i,e;return(t=("number"==typeof t[0]||t instanceof k?A:O)(t))instanceof I?(i=t.min,e=t.max):i=e=t,i.x>=this.min.x&&e.x<=this.max.x&&i.y>=this.min.y&&e.y<=this.max.y},intersects:function(t){t=O(t);var i=this.min,e=this.max,n=t.min,o=t.max,s=o.x>=i.x&&n.x<=e.x,r=o.y>=i.y&&n.y<=e.y;return s&&r},overlaps:function(t){t=O(t);var i=this.min,e=this.max,n=t.min,o=t.max,s=o.x>i.x&&n.x<e.x,r=o.y>i.y&&n.y<e.y;return s&&r},isValid:function(){return!(!this.min||!this.max)}},R.prototype={extend:function(t){var i,e,n=this._southWest,o=this._northEast;if(t instanceof D)e=i=t;else{if(!(t instanceof R))return t?this.extend(j(t)||N(t)):this;if(i=t._southWest,e=t._northEast,!i||!e)return this}return n||o?(n.lat=Math.min(i.lat,n.lat),n.lng=Math.min(i.lng,n.lng),o.lat=Math.max(e.lat,o.lat),o.lng=Math.max(e.lng,o.lng)):(this._southWest=new D(i.lat,i.lng),this._northEast=new D(e.lat,e.lng)),this},pad:function(t){var i=this._southWest,e=this._northEast,n=Math.abs(i.lat-e.lat)*t,o=Math.abs(i.lng-e.lng)*t;return new R(new D(i.lat-n,i.lng-o),new D(e.lat+n,e.lng+o))},getCenter:function(){return new D((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new D(this.getNorth(),this.getWest())},getSouthEast:function(){return new D(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(t){t=("number"==typeof t[0]||t instanceof D||"lat"in t?j:N)(t);var i,e,n=this._southWest,o=this._northEast;return t instanceof R?(i=t.getSouthWest(),e=t.getNorthEast()):i=e=t,i.lat>=n.lat&&e.lat<=o.lat&&i.lng>=n.lng&&e.lng<=o.lng},intersects:function(t){t=N(t);var i=this._southWest,e=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>=i.lat&&n.lat<=e.lat,r=o.lng>=i.lng&&n.lng<=e.lng;return s&&r},overlaps:function(t){t=N(t);var i=this._southWest,e=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>i.lat&&n.lat<e.lat,r=o.lng>i.lng&&n.lng<e.lng;return s&&r},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(t,i){return!!t&&(t=N(t),this._southWest.equals(t.getSouthWest(),i)&&this._northEast.equals(t.getNorthEast(),i))},isValid:function(){return!(!this._southWest||!this._northEast)}};var W,H={latLngToPoint:function(t,i){var e=this.projection.project(t),n=this.scale(i);return this.transformation._transform(e,n)},pointToLatLng:function(t,i){var e=this.scale(i),n=this.transformation.untransform(t,e);return this.projection.unproject(n)},project:function(t){return this.projection.project(t)},unproject:function(t){return this.projection.unproject(t)},scale:function(t){return 256*Math.pow(2,t)},zoom:function(t){return Math.log(t/256)/Math.LN2},getProjectedBounds:function(t){if(this.infinite)return null;var i=this.projection.bounds,e=this.scale(t);return new I(this.transformation.transform(i.min,e),this.transformation.transform(i.max,e))},infinite:!(D.prototype={equals:function(t,i){return!!t&&(t=j(t),Math.max(Math.abs(this.lat-t.lat),Math.abs(this.lng-t.lng))<=(void 0===i?1e-9:i))},toString:function(t){return"LatLng("+r(this.lat,t)+", "+r(this.lng,t)+")"},distanceTo:function(t){return F.distance(this,j(t))},wrap:function(){return F.wrapLatLng(this)},toBounds:function(t){var i=180*t/40075017,e=i/Math.cos(Math.PI/180*this.lat);return N([this.lat-i,this.lng-e],[this.lat+i,this.lng+e])},clone:function(){return new D(this.lat,this.lng,this.alt)}}),wrapLatLng:function(t){var i=this.wrapLng?o(t.lng,this.wrapLng,!0):t.lng;return new D(this.wrapLat?o(t.lat,this.wrapLat,!0):t.lat,i,t.alt)},wrapLatLngBounds:function(t){var i=t.getCenter(),e=this.wrapLatLng(i),n=i.lat-e.lat,o=i.lng-e.lng;if(0==n&&0==o)return t;var s=t.getSouthWest(),r=t.getNorthEast();return new R(new D(s.lat-n,s.lng-o),new D(r.lat-n,r.lng-o))}},F=h({},H,{wrapLng:[-180,180],R:6371e3,distance:function(t,i){var e=Math.PI/180,n=t.lat*e,o=i.lat*e,s=Math.sin((i.lat-t.lat)*e/2),r=Math.sin((i.lng-t.lng)*e/2),a=s*s+Math.cos(n)*Math.cos(o)*r*r,h=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));return this.R*h}}),U=6378137,V={R:U,MAX_LATITUDE:85.0511287798,project:function(t){var i=Math.PI/180,e=this.MAX_LATITUDE,n=Math.max(Math.min(e,t.lat),-e),o=Math.sin(n*i);return new k(this.R*t.lng*i,this.R*Math.log((1+o)/(1-o))/2)},unproject:function(t){var i=180/Math.PI;return new D((2*Math.atan(Math.exp(t.y/this.R))-Math.PI/2)*i,t.x*i/this.R)},bounds:new I([-(W=U*Math.PI),-W],[W,W])};function q(t,i,e,n){if(g(t))return this._a=t[0],this._b=t[1],this._c=t[2],void(this._d=t[3]);this._a=t,this._b=i,this._c=e,this._d=n}function G(t,i,e,n){return new q(t,i,e,n)}q.prototype={transform:function(t,i){return this._transform(t.clone(),i)},_transform:function(t,i){return i=i||1,t.x=i*(this._a*t.x+this._b),t.y=i*(this._c*t.y+this._d),t},untransform:function(t,i){return i=i||1,new k((t.x/i-this._b)/this._a,(t.y/i-this._d)/this._c)}};var K,Y=h({},F,{code:"EPSG:3857",projection:V,transformation:G(K=.5/(Math.PI*V.R),.5,-K,.5)}),X=h({},Y,{code:"EPSG:900913"});function J(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function $(t,i){for(var e,n,o,s,r="",a=0,h=t.length;a<h;a++){for(e=0,n=(o=t[a]).length;e<n;e++)r+=(e?"L":"M")+(s=o[e]).x+" "+s.y;r+=i?Zt?"z":"x":""}return r||"M0 0"}var Q=document.documentElement.style,tt="ActiveXObject"in window,it=tt&&!document.addEventListener,et="msLaunchUri"in navigator&&!("documentMode"in document),nt=kt("webkit"),ot=kt("android"),st=kt("android 2")||kt("android 3"),rt=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),at=ot&&kt("Google")&&rt<537&&!("AudioNode"in window),ht=!!window.opera,ut=!et&&kt("chrome"),lt=kt("gecko")&&!nt&&!ht&&!tt,ct=!ut&&kt("safari"),_t=kt("phantom"),dt="OTransition"in Q,pt=0===navigator.platform.indexOf("Win"),mt=tt&&"transition"in Q,ft="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!st,gt="MozPerspective"in Q,vt=!window.L_DISABLE_3D&&(mt||ft||gt)&&!dt&&!_t,yt="undefined"!=typeof orientation||kt("mobile"),xt=yt&&nt,wt=yt&&ft,Pt=!window.PointerEvent&&window.MSPointerEvent,Lt=!(!window.PointerEvent&&!Pt),bt=!window.L_NO_TOUCH&&(Lt||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch),Tt=yt&&ht,Mt=yt&&lt,zt=1<(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI),Ct=function(){var t=!1;try{var i=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassiveEventSupport",a,i),window.removeEventListener("testPassiveEventSupport",a,i)}catch(t){}return t}(),St=!!document.createElement("canvas").getContext,Zt=!(!document.createElementNS||!J("svg").createSVGRect),Et=!Zt&&function(){try{var t=document.createElement("div");t.innerHTML='<v:shape adj="1"/>';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(t){return!1}}();function kt(t){return 0<=navigator.userAgent.toLowerCase().indexOf(t)}var Bt={ie:tt,ielt9:it,edge:et,webkit:nt,android:ot,android23:st,androidStock:at,opera:ht,chrome:ut,gecko:lt,safari:ct,phantom:_t,opera12:dt,win:pt,ie3d:mt,webkit3d:ft,gecko3d:gt,any3d:vt,mobile:yt,mobileWebkit:xt,mobileWebkit3d:wt,msPointer:Pt,pointer:Lt,touch:bt,mobileOpera:Tt,mobileGecko:Mt,retina:zt,passiveEvents:Ct,canvas:St,svg:Zt,vml:Et},At=Pt?"MSPointerDown":"pointerdown",It=Pt?"MSPointerMove":"pointermove",Ot=Pt?"MSPointerUp":"pointerup",Rt=Pt?"MSPointerCancel":"pointercancel",Nt={},Dt=!1;function jt(t,i,e,n){function o(t){Ut(t,r)}var s,r,a,h,u,l,c,_;function d(t){t.pointerType===(t.MSPOINTER_TYPE_MOUSE||"mouse")&&0===t.buttons||Ut(t,h)}return"touchstart"===i?(u=t,l=e,c=n,_=p(function(t){t.MSPOINTER_TYPE_TOUCH&&t.pointerType===t.MSPOINTER_TYPE_TOUCH&&Ri(t),Ut(t,l)}),u["_leaflet_touchstart"+c]=_,u.addEventListener(At,_,!1),Dt||(document.addEventListener(At,Wt,!0),document.addEventListener(It,Ht,!0),document.addEventListener(Ot,Ft,!0),document.addEventListener(Rt,Ft,!0),Dt=!0)):"touchmove"===i?(h=e,(a=t)["_leaflet_touchmove"+n]=d,a.addEventListener(It,d,!1)):"touchend"===i&&(r=e,(s=t)["_leaflet_touchend"+n]=o,s.addEventListener(Ot,o,!1),s.addEventListener(Rt,o,!1)),this}function Wt(t){Nt[t.pointerId]=t}function Ht(t){Nt[t.pointerId]&&(Nt[t.pointerId]=t)}function Ft(t){delete Nt[t.pointerId]}function Ut(t,i){for(var e in t.touches=[],Nt)t.touches.push(Nt[e]);t.changedTouches=[t],i(t)}var Vt=Pt?"MSPointerDown":Lt?"pointerdown":"touchstart",qt=Pt?"MSPointerUp":Lt?"pointerup":"touchend",Gt="_leaflet_";var Kt,Yt,Xt,Jt,$t,Qt,ti=fi(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),ii=fi(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),ei="webkitTransition"===ii||"OTransition"===ii?ii+"End":"transitionend";function ni(t){return"string"==typeof t?document.getElementById(t):t}function oi(t,i){var e,n=t.style[i]||t.currentStyle&&t.currentStyle[i];return n&&"auto"!==n||!document.defaultView||(n=(e=document.defaultView.getComputedStyle(t,null))?e[i]:null),"auto"===n?null:n}function si(t,i,e){var n=document.createElement(t);return n.className=i||"",e&&e.appendChild(n),n}function ri(t){var i=t.parentNode;i&&i.removeChild(t)}function ai(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function hi(t){var i=t.parentNode;i&&i.lastChild!==t&&i.appendChild(t)}function ui(t){var i=t.parentNode;i&&i.firstChild!==t&&i.insertBefore(t,i.firstChild)}function li(t,i){if(void 0!==t.classList)return t.classList.contains(i);var e=pi(t);return 0<e.length&&new RegExp("(^|\\s)"+i+"(\\s|$)").test(e)}function ci(t,i){var e;if(void 0!==t.classList)for(var n=l(i),o=0,s=n.length;o<s;o++)t.classList.add(n[o]);else li(t,i)||di(t,((e=pi(t))?e+" ":"")+i)}function _i(t,i){void 0!==t.classList?t.classList.remove(i):di(t,u((" "+pi(t)+" ").replace(" "+i+" "," ")))}function di(t,i){void 0===t.className.baseVal?t.className=i:t.className.baseVal=i}function pi(t){return t.correspondingElement&&(t=t.correspondingElement),void 0===t.className.baseVal?t.className:t.className.baseVal}function mi(t,i){"opacity"in t.style?t.style.opacity=i:"filter"in t.style&&function(t,i){var e=!1,n="DXImageTransform.Microsoft.Alpha";try{e=t.filters.item(n)}catch(t){if(1===i)return}i=Math.round(100*i),e?(e.Enabled=100!==i,e.Opacity=i):t.style.filter+=" progid:"+n+"(opacity="+i+")"}(t,i)}function fi(t){for(var i=document.documentElement.style,e=0;e<t.length;e++)if(t[e]in i)return t[e];return!1}function gi(t,i,e){var n=i||new k(0,0);t.style[ti]=(mt?"translate("+n.x+"px,"+n.y+"px)":"translate3d("+n.x+"px,"+n.y+"px,0)")+(e?" scale("+e+")":"")}function vi(t,i){t._leaflet_pos=i,vt?gi(t,i):(t.style.left=i.x+"px",t.style.top=i.y+"px")}function yi(t){return t._leaflet_pos||new k(0,0)}function xi(){zi(window,"dragstart",Ri)}function wi(){Si(window,"dragstart",Ri)}function Pi(t){for(;-1===t.tabIndex;)t=t.parentNode;t.style&&(Li(),Qt=($t=t).style.outline,t.style.outline="none",zi(window,"keydown",Li))}function Li(){$t&&($t.style.outline=Qt,Qt=$t=void 0,Si(window,"keydown",Li))}function bi(t){for(;!((t=t.parentNode).offsetWidth&&t.offsetHeight||t===document.body););return t}function Ti(t){var i=t.getBoundingClientRect();return{x:i.width/t.offsetWidth||1,y:i.height/t.offsetHeight||1,boundingClientRect:i}}Jt="onselectstart"in document?(Xt=function(){zi(window,"selectstart",Ri)},function(){Si(window,"selectstart",Ri)}):(Yt=fi(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]),Xt=function(){var t;Yt&&(t=document.documentElement.style,Kt=t[Yt],t[Yt]="none")},function(){Yt&&(document.documentElement.style[Yt]=Kt,Kt=void 0)});var Mi={TRANSFORM:ti,TRANSITION:ii,TRANSITION_END:ei,get:ni,getStyle:oi,create:si,remove:ri,empty:ai,toFront:hi,toBack:ui,hasClass:li,addClass:ci,removeClass:_i,setClass:di,getClass:pi,setOpacity:mi,testProp:fi,setTransform:gi,setPosition:vi,getPosition:yi,disableTextSelection:Xt,enableTextSelection:Jt,disableImageDrag:xi,enableImageDrag:wi,preventOutline:Pi,restoreOutline:Li,getSizedParentNode:bi,getScale:Ti};function zi(t,i,e,n){if("object"==typeof i)for(var o in i)ki(t,o,i[o],e);else for(var s=0,r=(i=l(i)).length;s<r;s++)ki(t,i[s],e,n);return this}var Ci="_leaflet_events";function Si(t,i,e,n){if("object"==typeof i)for(var o in i)Bi(t,o,i[o],e);else if(i)for(var s=0,r=(i=l(i)).length;s<r;s++)Bi(t,i[s],e,n);else{for(var a in t[Ci])Bi(t,a,t[Ci][a]);delete t[Ci]}return this}function Zi(){return Lt&&(!et&&!ct)}var Ei={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function ki(i,t,e,n){var o=t+m(e)+(n?"_"+m(n):"");if(i[Ci]&&i[Ci][o])return this;var s,r,a,h,u,l,c=function(t){return e.call(n||i,t||window.event)},_=c;function d(t){if(Lt){if(!t.isPrimary)return;if("mouse"===t.pointerType)return}else if(1<t.touches.length)return;var i=Date.now(),e=i-(h||i);u=t.touches?t.touches[0]:t,l=0<e&&e<=250,h=i}function p(t){if(l&&!u.cancelBubble){if(Lt){if("mouse"===t.pointerType)return;var i,e,n={};for(e in u)i=u[e],n[e]=i&&i.bind?i.bind(u):i;u=n}u.type="dblclick",u.button=0,r(u),h=null}}Lt&&0===t.indexOf("touch")?jt(i,t,c,o):bt&&"dblclick"===t&&!Zi()?(r=c,l=!1,(s=i)[Gt+Vt+(a=o)]=d,s[Gt+qt+a]=p,s[Gt+"dblclick"+a]=r,s.addEventListener(Vt,d,!!Ct&&{passive:!1}),s.addEventListener(qt,p,!!Ct&&{passive:!1}),s.addEventListener("dblclick",r,!1)):"addEventListener"in i?"touchstart"===t||"touchmove"===t||"wheel"===t||"mousewheel"===t?i.addEventListener(Ei[t]||t,c,!!Ct&&{passive:!1}):"mouseenter"===t||"mouseleave"===t?(c=function(t){t=t||window.event,Vi(i,t)&&_(t)},i.addEventListener(Ei[t],c,!1)):i.addEventListener(t,_,!1):"attachEvent"in i&&i.attachEvent("on"+t,c),i[Ci]=i[Ci]||{},i[Ci][o]=c}function Bi(t,i,e,n){var o,s,r,a,h,u,l,c,_=i+m(e)+(n?"_"+m(n):""),d=t[Ci]&&t[Ci][_];if(!d)return this;Lt&&0===i.indexOf("touch")?(c=(u=t)["_leaflet_"+(l=i)+_],"touchstart"===l?u.removeEventListener(At,c,!1):"touchmove"===l?u.removeEventListener(It,c,!1):"touchend"===l&&(u.removeEventListener(Ot,c,!1),u.removeEventListener(Rt,c,!1))):bt&&"dblclick"===i&&!Zi()?(r=(o=t)[Gt+Vt+(s=_)],a=o[Gt+qt+s],h=o[Gt+"dblclick"+s],o.removeEventListener(Vt,r,!!Ct&&{passive:!1}),o.removeEventListener(qt,a,!!Ct&&{passive:!1}),o.removeEventListener("dblclick",h,!1)):"removeEventListener"in t?t.removeEventListener(Ei[i]||i,d,!1):"detachEvent"in t&&t.detachEvent("on"+i,d),t[Ci][_]=null}function Ai(t){return t.stopPropagation?t.stopPropagation():t.originalEvent?t.originalEvent._stopped=!0:t.cancelBubble=!0,Ui(t),this}function Ii(t){return ki(t,"wheel",Ai),this}function Oi(t){return zi(t,"mousedown touchstart dblclick",Ai),ki(t,"click",Fi),this}function Ri(t){return t.preventDefault?t.preventDefault():t.returnValue=!1,this}function Ni(t){return Ri(t),Ai(t),this}function Di(t,i){if(!i)return new k(t.clientX,t.clientY);var e=Ti(i),n=e.boundingClientRect;return new k((t.clientX-n.left)/e.x-i.clientLeft,(t.clientY-n.top)/e.y-i.clientTop)}var ji=pt&&ut?2*window.devicePixelRatio:lt?window.devicePixelRatio:1;function Wi(t){return et?t.wheelDeltaY/2:t.deltaY&&0===t.deltaMode?-t.deltaY/ji:t.deltaY&&1===t.deltaMode?20*-t.deltaY:t.deltaY&&2===t.deltaMode?60*-t.deltaY:t.deltaX||t.deltaZ?0:t.wheelDelta?(t.wheelDeltaY||t.wheelDelta)/2:t.detail&&Math.abs(t.detail)<32765?20*-t.detail:t.detail?t.detail/-32765*60:0}var Hi={};function Fi(t){Hi[t.type]=!0}function Ui(t){var i=Hi[t.type];return Hi[t.type]=!1,i}function Vi(t,i){var e=i.relatedTarget;if(!e)return!0;try{for(;e&&e!==t;)e=e.parentNode}catch(t){return!1}return e!==t}var qi={on:zi,off:Si,stopPropagation:Ai,disableScrollPropagation:Ii,disableClickPropagation:Oi,preventDefault:Ri,stop:Ni,getMousePosition:Di,getWheelDelta:Wi,fakeStop:Fi,skipped:Ui,isExternalTarget:Vi,addListener:zi,removeListener:Si},Gi=E.extend({run:function(t,i,e,n){this.stop(),this._el=t,this._inProgress=!0,this._duration=e||.25,this._easeOutPower=1/Math.max(n||.5,.2),this._startPos=yi(t),this._offset=i.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=M(this._animate,this),this._step()},_step:function(t){var i=new Date-this._startTime,e=1e3*this._duration;i<e?this._runFrame(this._easeOut(i/e),t):(this._runFrame(1),this._complete())},_runFrame:function(t,i){var e=this._startPos.add(this._offset.multiplyBy(t));i&&e._round(),vi(this._el,e),this.fire("step")},_complete:function(){z(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(t){return 1-Math.pow(1-t,this._easeOutPower)}}),Ki=E.extend({options:{crs:Y,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(t,i){i=c(this,i),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(t),this._initLayout(),this._onResize=p(this._onResize,this),this._initEvents(),i.maxBounds&&this.setMaxBounds(i.maxBounds),void 0!==i.zoom&&(this._zoom=this._limitZoom(i.zoom)),i.center&&void 0!==i.zoom&&this.setView(j(i.center),i.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=ii&&vt&&!Tt&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),zi(this._proxy,ei,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(t,i,e){if((i=void 0===i?this._zoom:this._limitZoom(i),t=this._limitCenter(j(t),i,this.options.maxBounds),e=e||{},this._stop(),this._loaded&&!e.reset&&!0!==e)&&(void 0!==e.animate&&(e.zoom=h({animate:e.animate},e.zoom),e.pan=h({animate:e.animate,duration:e.duration},e.pan)),this._zoom!==i?this._tryAnimatedZoom&&this._tryAnimatedZoom(t,i,e.zoom):this._tryAnimatedPan(t,e.pan)))return clearTimeout(this._sizeTimer),this;return this._resetView(t,i),this},setZoom:function(t,i){return this._loaded?this.setView(this.getCenter(),t,{zoom:i}):(this._zoom=t,this)},zoomIn:function(t,i){return t=t||(vt?this.options.zoomDelta:1),this.setZoom(this._zoom+t,i)},zoomOut:function(t,i){return t=t||(vt?this.options.zoomDelta:1),this.setZoom(this._zoom-t,i)},setZoomAround:function(t,i,e){var n=this.getZoomScale(i),o=this.getSize().divideBy(2),s=(t instanceof k?t:this.latLngToContainerPoint(t)).subtract(o).multiplyBy(1-1/n),r=this.containerPointToLatLng(o.add(s));return this.setView(r,i,{zoom:e})},_getBoundsCenterZoom:function(t,i){i=i||{},t=t.getBounds?t.getBounds():N(t);var e=A(i.paddingTopLeft||i.padding||[0,0]),n=A(i.paddingBottomRight||i.padding||[0,0]),o=this.getBoundsZoom(t,!1,e.add(n));if((o="number"==typeof i.maxZoom?Math.min(i.maxZoom,o):o)===1/0)return{center:t.getCenter(),zoom:o};var s=n.subtract(e).divideBy(2),r=this.project(t.getSouthWest(),o),a=this.project(t.getNorthEast(),o);return{center:this.unproject(r.add(a).divideBy(2).add(s),o),zoom:o}},fitBounds:function(t,i){if(!(t=N(t)).isValid())throw new Error("Bounds are not valid.");var e=this._getBoundsCenterZoom(t,i);return this.setView(e.center,e.zoom,i)},fitWorld:function(t){return this.fitBounds([[-90,-180],[90,180]],t)},panTo:function(t,i){return this.setView(t,this._zoom,{pan:i})},panBy:function(t,i){return i=i||{},(t=A(t).round()).x||t.y?(!0===i.animate||this.getSize().contains(t)?(this._panAnim||(this._panAnim=new Gi,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),i.noMoveStart||this.fire("movestart"),!1!==i.animate?(ci(this._mapPane,"leaflet-pan-anim"),e=this._getMapPanePos().subtract(t).round(),this._panAnim.run(this._mapPane,e,i.duration||.25,i.easeLinearity)):(this._rawPanBy(t),this.fire("move").fire("moveend"))):this._resetView(this.unproject(this.project(this.getCenter()).add(t)),this.getZoom()),this):this.fire("moveend");var e},flyTo:function(s,r,t){if(!1===(t=t||{}).animate||!vt)return this.setView(s,r,t);this._stop();var a=this.project(this.getCenter()),h=this.project(s),i=this.getSize(),u=this._zoom;s=j(s),r=void 0===r?u:r;var l=Math.max(i.x,i.y),n=l*this.getZoomScale(u,r),c=h.distanceTo(a)||1,_=1.42,o=_*_;function e(t){var i=(n*n-l*l+(t?-1:1)*o*o*c*c)/(2*(t?n:l)*o*c),e=Math.sqrt(i*i+1)-i;return e<1e-9?-18:Math.log(e)}function d(t){return(Math.exp(t)-Math.exp(-t))/2}function p(t){return(Math.exp(t)+Math.exp(-t))/2}var m=e(0);function f(t){return l*(p(m)*(d(i=m+_*t)/p(i))-d(m))/o;var i}var g=Date.now(),v=(e(1)-m)/_,y=t.duration?1e3*t.duration:1e3*v*.8;return this._moveStart(!0,t.noMoveStart),function t(){var i,e,n=(Date.now()-g)/y,o=(i=n,(1-Math.pow(1-i,1.5))*v);n<=1?(this._flyToFrame=M(t,this),this._move(this.unproject(a.add(h.subtract(a).multiplyBy(f(o)/c)),u),this.getScaleZoom(l/(e=o,l*(p(m)/p(m+_*e))),u),{flyTo:!0})):this._move(s,r)._moveEnd(!0)}.call(this),this},flyToBounds:function(t,i){var e=this._getBoundsCenterZoom(t,i);return this.flyTo(e.center,e.zoom,i)},setMaxBounds:function(t){return(t=N(t)).isValid()?(this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this.options.maxBounds=t,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this.off("moveend",this._panInsideMaxBounds))},setMinZoom:function(t){var i=this.options.minZoom;return this.options.minZoom=t,this._loaded&&i!==t&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(t):this},setMaxZoom:function(t){var i=this.options.maxZoom;return this.options.maxZoom=t,this._loaded&&i!==t&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,i){this._enforcingBounds=!0;var e=this.getCenter(),n=this._limitCenter(e,this._zoom,N(t));return e.equals(n)||this.panTo(n,i),this._enforcingBounds=!1,this},panInside:function(t,i){var e,n,o=A((i=i||{}).paddingTopLeft||i.padding||[0,0]),s=A(i.paddingBottomRight||i.padding||[0,0]),r=this.getCenter(),a=this.project(r),h=this.project(t),u=this.getPixelBounds(),l=u.getSize().divideBy(2),c=O([u.min.add(o),u.max.subtract(s)]);return c.contains(h)||(this._enforcingBounds=!0,e=a.subtract(h),n=A(h.x+e.x,h.y+e.y),(h.x<c.min.x||h.x>c.max.x)&&(n.x=a.x-e.x,0<e.x?n.x+=l.x-o.x:n.x-=l.x-s.x),(h.y<c.min.y||h.y>c.max.y)&&(n.y=a.y-e.y,0<e.y?n.y+=l.y-o.y:n.y-=l.y-s.y),this.panTo(this.unproject(n),i),this._enforcingBounds=!1),this},invalidateSize:function(t){if(!this._loaded)return this;t=h({animate:!1,pan:!0},!0===t?{animate:!0}:t);var i=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var e=this.getSize(),n=i.divideBy(2).round(),o=e.divideBy(2).round(),s=n.subtract(o);return s.x||s.y?(t.animate&&t.pan?this.panBy(s):(t.pan&&this._rawPanBy(s),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(p(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:i,newSize:e})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){if(t=this._locateOptions=h({timeout:1e4,watch:!1},t),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var i=p(this._handleGeolocationResponse,this),e=p(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(i,e,t):navigator.geolocation.getCurrentPosition(i,e,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var i=t.code,e=t.message||(1===i?"permission denied":2===i?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:i,message:"Geolocation error: "+e+"."})},_handleGeolocationResponse:function(t){var i,e=new D(t.coords.latitude,t.coords.longitude),n=e.toBounds(2*t.coords.accuracy),o=this._locateOptions;o.setView&&(i=this.getBoundsZoom(n),this.setView(e,o.maxZoom?Math.min(i,o.maxZoom):i));var s={latlng:e,bounds:n,timestamp:t.timestamp};for(var r in t.coords)"number"==typeof t.coords[r]&&(s[r]=t.coords[r]);this.fire("locationfound",s)},addHandler:function(t,i){if(!i)return this;var e=this[t]=new i(this);return this._handlers.push(e),this.options[t]&&e.enable(),this},remove:function(){if(this._initEvents(!0),this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=void 0,this._containerId=void 0}var t;for(t in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),ri(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(z(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[t].remove();for(t in this._panes)ri(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(t,i){var e=si("div","leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),i||this._mapPane);return t&&(this._panes[t]=e),e},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds();return new R(this.unproject(t.getBottomLeft()),this.unproject(t.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,i,e){t=N(t),e=A(e||[0,0]);var n=this.getZoom()||0,o=this.getMinZoom(),s=this.getMaxZoom(),r=t.getNorthWest(),a=t.getSouthEast(),h=this.getSize().subtract(e),u=O(this.project(a,n),this.project(r,n)).getSize(),l=vt?this.options.zoomSnap:1,c=h.x/u.x,_=h.y/u.y,d=i?Math.max(c,_):Math.min(c,_),n=this.getScaleZoom(d,n);return l&&(n=Math.round(n/(l/100))*(l/100),n=i?Math.ceil(n/l)*l:Math.floor(n/l)*l),Math.max(o,Math.min(s,n))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new k(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,i){var e=this._getTopLeftPoint(t,i);return new I(e,e.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(void 0===t?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,i){var e=this.options.crs;return i=void 0===i?this._zoom:i,e.scale(t)/e.scale(i)},getScaleZoom:function(t,i){var e=this.options.crs;i=void 0===i?this._zoom:i;var n=e.zoom(t*e.scale(i));return isNaN(n)?1/0:n},project:function(t,i){return i=void 0===i?this._zoom:i,this.options.crs.latLngToPoint(j(t),i)},unproject:function(t,i){return i=void 0===i?this._zoom:i,this.options.crs.pointToLatLng(A(t),i)},layerPointToLatLng:function(t){var i=A(t).add(this.getPixelOrigin());return this.unproject(i)},latLngToLayerPoint:function(t){return this.project(j(t))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(j(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(N(t))},distance:function(t,i){return this.options.crs.distance(j(t),j(i))},containerPointToLayerPoint:function(t){return A(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return A(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var i=this.containerPointToLayerPoint(A(t));return this.layerPointToLatLng(i)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(j(t)))},mouseEventToContainerPoint:function(t){return Di(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var i=this._container=ni(t);if(!i)throw new Error("Map container not found.");if(i._leaflet_id)throw new Error("Map container is already initialized.");zi(i,"scroll",this._onScroll,this),this._containerId=m(i)},_initLayout:function(){var t=this._container;this._fadeAnimated=this.options.fadeAnimation&&vt,ci(t,"leaflet-container"+(bt?" leaflet-touch":"")+(zt?" leaflet-retina":"")+(it?" leaflet-oldie":"")+(ct?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var i=oi(t,"position");"absolute"!==i&&"relative"!==i&&"fixed"!==i&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),vi(this._mapPane,new k(0,0)),this.createPane("tilePane"),this.createPane("shadowPane"),this.createPane("overlayPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(ci(t.markerPane,"leaflet-zoom-hide"),ci(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,i){vi(this._mapPane,new k(0,0));var e=!this._loaded;this._loaded=!0,i=this._limitZoom(i),this.fire("viewprereset");var n=this._zoom!==i;this._moveStart(n,!1)._move(t,i)._moveEnd(n),this.fire("viewreset"),e&&this.fire("load")},_moveStart:function(t,i){return t&&this.fire("zoomstart"),i||this.fire("movestart"),this},_move:function(t,i,e){void 0===i&&(i=this._zoom);var n=this._zoom!==i;return this._zoom=i,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),(n||e&&e.pinch)&&this.fire("zoom",e),this.fire("move",e)},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return z(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){vi(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(t){this._targets={};var i=t?Si:zi;i((this._targets[m(this._container)]=this)._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&i(window,"resize",this._onResize,this),vt&&this.options.transform3DLimit&&(t?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){z(this._resizeRequest),this._resizeRequest=M(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,i){for(var e,n=[],o="mouseout"===i||"mouseover"===i,s=t.target||t.srcElement,r=!1;s;){if((e=this._targets[m(s)])&&("click"===i||"preclick"===i)&&!t._simulated&&this._draggableMoved(e)){r=!0;break}if(e&&e.listens(i,!0)){if(o&&!Vi(s,t))break;if(n.push(e),o)break}if(s===this._container)break;s=s.parentNode}return n.length||r||o||!Vi(s,t)||(n=[this]),n},_handleDOMEvent:function(t){var i;this._loaded&&!Ui(t)&&("mousedown"!==(i=t.type)&&"keypress"!==i&&"keyup"!==i&&"keydown"!==i||Pi(t.target||t.srcElement),this._fireDOMEvent(t,i))},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,i,e){var n;if("click"===t.type&&((n=h({},t)).type="preclick",this._fireDOMEvent(n,n.type,e)),!t._stopped&&(e=(e||[]).concat(this._findEventTargets(t,i))).length){var o=e[0];"contextmenu"===i&&o.listens(i,!0)&&Ri(t);var s,r={originalEvent:t};"keypress"!==t.type&&"keydown"!==t.type&&"keyup"!==t.type&&(s=o.getLatLng&&(!o._radius||o._radius<=10),r.containerPoint=s?this.latLngToContainerPoint(o.getLatLng()):this.mouseEventToContainerPoint(t),r.layerPoint=this.containerPointToLayerPoint(r.containerPoint),r.latlng=s?o.getLatLng():this.layerPointToLatLng(r.layerPoint));for(var a=0;a<e.length;a++)if(e[a].fire(i,r,!0),r.originalEvent._stopped||!1===e[a].options.bubblingMouseEvents&&-1!==v(this._mouseEvents,i))return}},_draggableMoved:function(t){return(t=t.dragging&&t.dragging.enabled()?t:this).dragging&&t.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var t=0,i=this._handlers.length;t<i;t++)this._handlers[t].disable()},whenReady:function(t,i){return this._loaded?t.call(i||this,{target:this}):this.on("load",t,i),this},_getMapPanePos:function(){return yi(this._mapPane)||new k(0,0)},_moved:function(){var t=this._getMapPanePos();return t&&!t.equals([0,0])},_getTopLeftPoint:function(t,i){return(t&&void 0!==i?this._getNewPixelOrigin(t,i):this.getPixelOrigin()).subtract(this._getMapPanePos())},_getNewPixelOrigin:function(t,i){var e=this.getSize()._divideBy(2);return this.project(t,i)._subtract(e)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(t,i,e){var n=this._getNewPixelOrigin(e,i);return this.project(t,i)._subtract(n)},_latLngBoundsToNewLayerBounds:function(t,i,e){var n=this._getNewPixelOrigin(e,i);return O([this.project(t.getSouthWest(),i)._subtract(n),this.project(t.getNorthWest(),i)._subtract(n),this.project(t.getSouthEast(),i)._subtract(n),this.project(t.getNorthEast(),i)._subtract(n)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(t){return this.latLngToLayerPoint(t).subtract(this._getCenterLayerPoint())},_limitCenter:function(t,i,e){if(!e)return t;var n=this.project(t,i),o=this.getSize().divideBy(2),s=new I(n.subtract(o),n.add(o)),r=this._getBoundsOffset(s,e,i);return r.round().equals([0,0])?t:this.unproject(n.add(r),i)},_limitOffset:function(t,i){if(!i)return t;var e=this.getPixelBounds(),n=new I(e.min.add(t),e.max.add(t));return t.add(this._getBoundsOffset(n,i))},_getBoundsOffset:function(t,i,e){var n=O(this.project(i.getNorthEast(),e),this.project(i.getSouthWest(),e)),o=n.min.subtract(t.min),s=n.max.subtract(t.max);return new k(this._rebound(o.x,-s.x),this._rebound(o.y,-s.y))},_rebound:function(t,i){return 0<t+i?Math.round(t-i)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(i))},_limitZoom:function(t){var i=this.getMinZoom(),e=this.getMaxZoom(),n=vt?this.options.zoomSnap:1;return n&&(t=Math.round(t/n)*n),Math.max(i,Math.min(e,t))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){_i(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,i){var e=this._getCenterOffset(t)._trunc();return!(!0!==(i&&i.animate)&&!this.getSize().contains(e))&&(this.panBy(e,i),!0)},_createAnimProxy:function(){var t=this._proxy=si("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(t),this.on("zoomanim",function(t){var i=ti,e=this._proxy.style[i];gi(this._proxy,this.project(t.center,t.zoom),this.getZoomScale(t.zoom,1)),e===this._proxy.style[i]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ri(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var t=this.getCenter(),i=this.getZoom();gi(this._proxy,this.project(t,i),this.getZoomScale(i,1))},_catchTransitionEnd:function(t){this._animatingZoom&&0<=t.propertyName.indexOf("transform")&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,i,e){if(this._animatingZoom)return!0;if(e=e||{},!this._zoomAnimated||!1===e.animate||this._nothingToAnimate()||Math.abs(i-this._zoom)>this.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(i),o=this._getCenterOffset(t)._divideBy(1-1/n);return!(!0!==e.animate&&!this.getSize().contains(o))&&(M(function(){this._moveStart(!0,!1)._animateZoom(t,i,!0)},this),!0)},_animateZoom:function(t,i,e,n){this._mapPane&&(e&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=i,ci(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:i,noUpdate:n}),setTimeout(p(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&_i(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom),M(function(){this._moveEnd(!0)},this))}});function Yi(t){return new Xi(t)}var Xi=S.extend({options:{position:"topright"},initialize:function(t){c(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var i=this._map;return i&&i.removeControl(this),this.options.position=t,i&&i.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var i=this._container=this.onAdd(t),e=this.getPosition(),n=t._controlCorners[e];return ci(i,"leaflet-control"),-1!==e.indexOf("bottom")?n.insertBefore(i,n.firstChild):n.appendChild(i),this._map.on("unload",this.remove,this),this},remove:function(){return this._map&&(ri(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null),this},_refocusOnMap:function(t){this._map&&t&&0<t.screenX&&0<t.screenY&&this._map.getContainer().focus()}});Ki.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.remove(),this},_initControlPos:function(){var n=this._controlCorners={},o="leaflet-",s=this._controlContainer=si("div",o+"control-container",this._container);function t(t,i){var e=o+t+" "+o+i;n[t+i]=si("div",e,s)}t("top","left"),t("top","right"),t("bottom","left"),t("bottom","right")},_clearControlPos:function(){for(var t in this._controlCorners)ri(this._controlCorners[t]);ri(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Ji=Xi.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(t,i,e,n){return e<n?-1:n<e?1:0}},initialize:function(t,i,e){for(var n in c(this,e),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,t)this._addLayer(t[n],n);for(n in i)this._addLayer(i[n],n,!0)},onAdd:function(t){this._initLayout(),this._update(),(this._map=t).on("zoomend",this._checkDisabledLayers,this);for(var i=0;i<this._layers.length;i++)this._layers[i].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(t){return Xi.prototype.addTo.call(this,t),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var t=0;t<this._layers.length;t++)this._layers[t].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(t,i){return this._addLayer(t,i),this._map?this._update():this},addOverlay:function(t,i){return this._addLayer(t,i,!0),this._map?this._update():this},removeLayer:function(t){t.off("add remove",this._onLayerChange,this);var i=this._getLayer(m(t));return i&&this._layers.splice(this._layers.indexOf(i),1),this._map?this._update():this},expand:function(){ci(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var t=this._map.getSize().y-(this._container.offsetTop+50);return t<this._section.clientHeight?(ci(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=t+"px"):_i(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return _i(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var t="leaflet-control-layers",i=this._container=si("div",t),e=this.options.collapsed;i.setAttribute("aria-haspopup",!0),Oi(i),Ii(i);var n=this._section=si("section",t+"-list");e&&(this._map.on("click",this.collapse,this),ot||zi(i,{mouseenter:this.expand,mouseleave:this.collapse},this));var o=this._layersLink=si("a",t+"-toggle",i);o.href="#",o.title="Layers",bt?(zi(o,"click",Ni),zi(o,"click",this.expand,this)):zi(o,"focus",this.expand,this),e||this.expand(),this._baseLayersList=si("div",t+"-base",n),this._separator=si("div",t+"-separator",n),this._overlaysList=si("div",t+"-overlays",n),i.appendChild(n)},_getLayer:function(t){for(var i=0;i<this._layers.length;i++)if(this._layers[i]&&m(this._layers[i].layer)===t)return this._layers[i]},_addLayer:function(t,i,e){this._map&&t.on("add remove",this._onLayerChange,this),this._layers.push({layer:t,name:i,overlay:e}),this.options.sortLayers&&this._layers.sort(p(function(t,i){return this.options.sortFunction(t.layer,i.layer,t.name,i.name)},this)),this.options.autoZIndex&&t.setZIndex&&(this._lastZIndex++,t.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;ai(this._baseLayersList),ai(this._overlaysList),this._layerControlInputs=[];for(var t,i,e,n=0,o=0;o<this._layers.length;o++)e=this._layers[o],this._addItem(e),i=i||e.overlay,t=t||!e.overlay,n+=e.overlay?0:1;return this.options.hideSingleBase&&(t=t&&1<n,this._baseLayersList.style.display=t?"":"none"),this._separator.style.display=i&&t?"":"none",this},_onLayerChange:function(t){this._handlingClick||this._update();var i=this._getLayer(m(t.target)),e=i.overlay?"add"===t.type?"overlayadd":"overlayremove":"add"===t.type?"baselayerchange":null;e&&this._map.fire(e,i)},_createRadioElement:function(t,i){var e='<input type="radio" class="leaflet-control-layers-selector" name="'+t+'"'+(i?' checked="checked"':"")+"/>",n=document.createElement("div");return n.innerHTML=e,n.firstChild},_addItem:function(t){var i,e=document.createElement("label"),n=this._map.hasLayer(t.layer);t.overlay?((i=document.createElement("input")).type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=n):i=this._createRadioElement("leaflet-base-layers_"+m(this),n),this._layerControlInputs.push(i),i.layerId=m(t.layer),zi(i,"click",this._onInputClick,this);var o=document.createElement("span");o.innerHTML=" "+t.name;var s=document.createElement("div");return e.appendChild(s),s.appendChild(i),s.appendChild(o),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(e),this._checkDisabledLayers(),e},_onInputClick:function(){var t,i,e=this._layerControlInputs,n=[],o=[];this._handlingClick=!0;for(var s=e.length-1;0<=s;s--)t=e[s],i=this._getLayer(t.layerId).layer,t.checked?n.push(i):t.checked||o.push(i);for(s=0;s<o.length;s++)this._map.hasLayer(o[s])&&this._map.removeLayer(o[s]);for(s=0;s<n.length;s++)this._map.hasLayer(n[s])||this._map.addLayer(n[s]);this._handlingClick=!1,this._refocusOnMap()},_checkDisabledLayers:function(){for(var t,i,e=this._layerControlInputs,n=this._map.getZoom(),o=e.length-1;0<=o;o--)t=e[o],i=this._getLayer(t.layerId).layer,t.disabled=void 0!==i.options.minZoom&&n<i.options.minZoom||void 0!==i.options.maxZoom&&n>i.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expand:function(){return this.expand()},_collapse:function(){return this.collapse()}}),$i=Xi.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"&#x2212;",zoomOutTitle:"Zoom out"},onAdd:function(t){var i="leaflet-control-zoom",e=si("div",i+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,i+"-in",e,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,i+"-out",e,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),e},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(t.shiftKey?3:1))},_zoomOut:function(t){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,i,e,n,o){var s=si("a",e,n);return s.innerHTML=t,s.href="#",s.title=i,s.setAttribute("role","button"),s.setAttribute("aria-label",i),Oi(s),zi(s,"click",Ni),zi(s,"click",o,this),zi(s,"click",this._refocusOnMap,this),s},_updateDisabled:function(){var t=this._map,i="leaflet-disabled";_i(this._zoomInButton,i),_i(this._zoomOutButton,i),!this._disabled&&t._zoom!==t.getMinZoom()||ci(this._zoomOutButton,i),!this._disabled&&t._zoom!==t.getMaxZoom()||ci(this._zoomInButton,i)}});Ki.mergeOptions({zoomControl:!0}),Ki.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new $i,this.addControl(this.zoomControl))});var Qi=Xi.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var i="leaflet-control-scale",e=si("div",i),n=this.options;return this._addScales(n,i+"-line",e),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),e},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,i,e){t.metric&&(this._mScale=si("div",i,e)),t.imperial&&(this._iScale=si("div",i,e))},_update:function(){var t=this._map,i=t.getSize().y/2,e=t.distance(t.containerPointToLatLng([0,i]),t.containerPointToLatLng([this.options.maxWidth,i]));this._updateScales(e)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var i=this._getRoundNum(t),e=i<1e3?i+" m":i/1e3+" km";this._updateScale(this._mScale,e,i/t)},_updateImperial:function(t){var i,e,n,o=3.2808399*t;5280<o?(i=o/5280,e=this._getRoundNum(i),this._updateScale(this._iScale,e+" mi",e/i)):(n=this._getRoundNum(o),this._updateScale(this._iScale,n+" ft",n/o))},_updateScale:function(t,i,e){t.style.width=Math.round(this.options.maxWidth*e)+"px",t.innerHTML=i},_getRoundNum:function(t){var i=Math.pow(10,(Math.floor(t)+"").length-1),e=t/i;return i*(e=10<=e?10:5<=e?5:3<=e?3:2<=e?2:1)}}),te=Xi.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>'},initialize:function(t){c(this,t),this._attributions={}},onAdd:function(t){for(var i in(t.attributionControl=this)._container=si("div","leaflet-control-attribution"),Oi(this._container),t._layers)t._layers[i].getAttribution&&this.addAttribution(t._layers[i].getAttribution());return this._update(),this._container},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t&&(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update()),this},removeAttribution:function(t){return t&&this._attributions[t]&&(this._attributions[t]--,this._update()),this},_update:function(){if(this._map){var t=[];for(var i in this._attributions)this._attributions[i]&&t.push(i);var e=[];this.options.prefix&&e.push(this.options.prefix),t.length&&e.push(t.join(", ")),this._container.innerHTML=e.join(" | ")}}});Ki.mergeOptions({attributionControl:!0}),Ki.addInitHook(function(){this.options.attributionControl&&(new te).addTo(this)});Xi.Layers=Ji,Xi.Zoom=$i,Xi.Scale=Qi,Xi.Attribution=te,Yi.layers=function(t,i,e){return new Ji(t,i,e)},Yi.zoom=function(t){return new $i(t)},Yi.scale=function(t){return new Qi(t)},Yi.attribution=function(t){return new te(t)};var ie=S.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});ie.addTo=function(t,i){return t.addHandler(i,this),this};var ee,ne={Events:Z},oe=bt?"touchstart mousedown":"mousedown",se={mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},re={mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"},ae=E.extend({options:{clickTolerance:3},initialize:function(t,i,e,n){c(this,n),this._element=t,this._dragStartTarget=i||t,this._preventOutline=e},enable:function(){this._enabled||(zi(this._dragStartTarget,oe,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(ae._dragging===this&&this.finishDrag(),Si(this._dragStartTarget,oe,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){var i,e;!t._simulated&&this._enabled&&(this._moved=!1,li(this._element,"leaflet-zoom-anim")||ae._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||((ae._dragging=this)._preventOutline&&Pi(this._element),xi(),Xt(),this._moving||(this.fire("down"),i=t.touches?t.touches[0]:t,e=bi(this._element),this._startPoint=new k(i.clientX,i.clientY),this._parentScale=Ti(e),zi(document,re[t.type],this._onMove,this),zi(document,se[t.type],this._onUp,this))))},_onMove:function(t){var i,e;!t._simulated&&this._enabled&&(t.touches&&1<t.touches.length?this._moved=!0:((e=new k((i=t.touches&&1===t.touches.length?t.touches[0]:t).clientX,i.clientY)._subtract(this._startPoint)).x||e.y)&&(Math.abs(e.x)+Math.abs(e.y)<this.options.clickTolerance||(e.x/=this._parentScale.x,e.y/=this._parentScale.y,Ri(t),this._moved||(this.fire("dragstart"),this._moved=!0,this._startPos=yi(this._element).subtract(e),ci(document.body,"leaflet-dragging"),this._lastTarget=t.target||t.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),ci(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(e),this._moving=!0,z(this._animRequest),this._lastEvent=t,this._animRequest=M(this._updatePosition,this,!0))))},_updatePosition:function(){var t={originalEvent:this._lastEvent};this.fire("predrag",t),vi(this._element,this._newPos),this.fire("drag",t)},_onUp:function(t){!t._simulated&&this._enabled&&this.finishDrag()},finishDrag:function(){for(var t in _i(document.body,"leaflet-dragging"),this._lastTarget&&(_i(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),re)Si(document,re[t],this._onMove,this),Si(document,se[t],this._onUp,this);wi(),Jt(),this._moved&&this._moving&&(z(this._animRequest),this.fire("dragend",{distance:this._newPos.distanceTo(this._startPos)})),this._moving=!1,ae._dragging=!1}});function he(t,i){if(!i||!t.length)return t.slice();var e=i*i;return t=function(t,i){var e=t.length,n=new(typeof Uint8Array!=void 0+""?Uint8Array:Array)(e);n[0]=n[e-1]=1,function t(i,e,n,o,s){var r,a,h,u=0;for(a=o+1;a<=s-1;a++)h=de(i[a],i[o],i[s],!0),u<h&&(r=a,u=h);n<u&&(e[r]=1,t(i,e,n,o,r),t(i,e,n,r,s))}(t,n,i,0,e-1);var o,s=[];for(o=0;o<e;o++)n[o]&&s.push(t[o]);return s}(t=function(t,i){for(var e=[t[0]],n=1,o=0,s=t.length;n<s;n++)(function(t,i){var e=i.x-t.x,n=i.y-t.y;return e*e+n*n})(t[n],t[o])>i&&(e.push(t[n]),o=n);o<s-1&&e.push(t[s-1]);return e}(t,e),e)}function ue(t,i,e){return Math.sqrt(de(t,i,e,!0))}function le(t,i,e,n,o){var s,r,a,h=n?ee:_e(t,e),u=_e(i,e);for(ee=u;;){if(!(h|u))return[t,i];if(h&u)return!1;a=_e(r=ce(t,i,s=h||u,e,o),e),s===h?(t=r,h=a):(i=r,u=a)}}function ce(t,i,e,n,o){var s,r,a=i.x-t.x,h=i.y-t.y,u=n.min,l=n.max;return 8&e?(s=t.x+a*(l.y-t.y)/h,r=l.y):4&e?(s=t.x+a*(u.y-t.y)/h,r=u.y):2&e?(s=l.x,r=t.y+h*(l.x-t.x)/a):1&e&&(s=u.x,r=t.y+h*(u.x-t.x)/a),new k(s,r,o)}function esc_attr_e(t,i){var e=0;return t.x<i.min.x?e|=1:t.x>i.max.x&&(e|=2),t.y<i.min.y?e|=4:t.y>i.max.y&&(e|=8),e}function de(t,i,e,n){var o,s=i.x,r=i.y,a=e.x-s,h=e.y-r,u=a*a+h*h;return 0<u&&(1<(o=((t.x-s)*a+(t.y-r)*h)/u)?(s=e.x,r=e.y):0<o&&(s+=a*o,r+=h*o)),a=t.x-s,h=t.y-r,n?a*a+h*h:new k(s,r)}function pe(t){return!g(t[0])||"object"!=typeof t[0][0]&&void 0!==t[0][0]}function me(t){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),pe(t)}var fe={simplify:he,pointToSegmentDistance:ue,closestPointOnSegment:function(t,i,e){return de(t,i,e)},clipSegment:le,_getEdgeIntersection:ce,_getBitCode:_e,_sqClosestPointOnSegment:de,isFlat:pe,_flat:me};function ge(t,i,e){for(var n,o,s,r,a,h,u,l=[1,4,2,8],c=0,_=t.length;c<_;c++)t[c]._code=_e(t[c],i);for(s=0;s<4;s++){for(h=l[s],n=[],c=0,o=(_=t.length)-1;c<_;o=c++)r=t[c],a=t[o],r._code&h?a._code&h||((u=ce(a,r,h,i,e))._code=_e(u,i),n.push(u)):(a._code&h&&((u=ce(a,r,h,i,e))._code=_e(u,i),n.push(u)),n.push(r));t=n}return t}var ve,ye={clipPolygon:ge},xe={project:function(t){return new k(t.lng,t.lat)},unproject:function(t){return new D(t.y,t.x)},bounds:new I([-180,-90],[180,90])},we={R:6378137,R_MINOR:6356752.314245179,bounds:new I([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(t){var i=Math.PI/180,e=this.R,n=t.lat*i,o=this.R_MINOR/e,s=Math.sqrt(1-o*o),r=s*Math.sin(n),a=Math.tan(Math.PI/4-n/2)/Math.pow((1-r)/(1+r),s/2),n=-e*Math.log(Math.max(a,1e-10));return new k(t.lng*i*e,n)},unproject:function(t){for(var i,e=180/Math.PI,n=this.R,o=this.R_MINOR/n,s=Math.sqrt(1-o*o),r=Math.exp(-t.y/n),a=Math.PI/2-2*Math.atan(r),h=0,u=.1;h<15&&1e-7<Math.abs(u);h++)i=s*Math.sin(a),i=Math.pow((1-i)/(1+i),s/2),a+=u=Math.PI/2-2*Math.atan(r*i)-a;return new D(a*e,t.x*e/n)}},Pe={LonLat:xe,Mercator:we,SphericalMercator:V},Le=h({},F,{code:"EPSG:3395",projection:we,transformation:G(ve=.5/(Math.PI*we.R),.5,-ve,.5)}),be=h({},F,{code:"EPSG:4326",projection:xe,transformation:G(1/180,1,-1/180,.5)}),Te=h({},H,{projection:xe,transformation:G(1,0,-1,0),scale:function(t){return Math.pow(2,t)},zoom:function(t){return Math.log(t)/Math.LN2},distance:function(t,i){var e=i.lng-t.lng,n=i.lat-t.lat;return Math.sqrt(e*e+n*n)},infinite:!0});H.Earth=F,H.EPSG3395=Le,H.EPSG3857=Y,H.EPSG900913=X,H.EPSG4326=be,H.Simple=Te;var Me=E.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(t){return t.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(t){return t&&t.removeLayer(this),this},getPane:function(t){return this._map.getPane(t?this.options[t]||t:this.options.pane)},addInteractiveTarget:function(t){return this._map._targets[m(t)]=this},removeInteractiveTarget:function(t){return delete this._map._targets[m(t)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(t){var i,e=t.target;e.hasLayer(this)&&(this._map=e,this._zoomAnimated=e._zoomAnimated,this.getEvents&&(i=this.getEvents(),e.on(i,this),this.once("remove",function(){e.off(i,this)},this)),this.onAdd(e),this.getAttribution&&e.attributionControl&&e.attributionControl.addAttribution(this.getAttribution()),this.fire("add"),e.fire("layeradd",{layer:this}))}});Ki.include({addLayer:function(t){if(!t._layerAdd)throw new Error("The provided object is not a Layer.");var i=m(t);return this._layers[i]||((this._layers[i]=t)._mapToAdd=this,t.beforeAdd&&t.beforeAdd(this),this.whenReady(t._layerAdd,t)),this},removeLayer:function(t){var i=m(t);return this._layers[i]&&(this._loaded&&t.onRemove(this),t.getAttribution&&this.attributionControl&&this.attributionControl.removeAttribution(t.getAttribution()),delete this._layers[i],this._loaded&&(this.fire("layerremove",{layer:t}),t.fire("remove")),t._map=t._mapToAdd=null),this},hasLayer:function(t){return!!t&&m(t)in this._layers},eachLayer:function(t,i){for(var e in this._layers)t.call(i,this._layers[e]);return this},_addLayers:function(t){for(var i=0,e=(t=t?g(t)?t:[t]:[]).length;i<e;i++)this.addLayer(t[i])},_addZoomLimit:function(t){!isNaN(t.options.maxZoom)&&isNaN(t.options.minZoom)||(this._zoomBoundLayers[m(t)]=t,this._updateZoomLevels())},_removeZoomLimit:function(t){var i=m(t);this._zoomBoundLayers[i]&&(delete this._zoomBoundLayers[i],this._updateZoomLevels())},_updateZoomLevels:function(){var t=1/0,i=-1/0,e=this._getZoomSpan();for(var n in this._zoomBoundLayers)var o=this._zoomBoundLayers[n].options,t=void 0===o.minZoom?t:Math.min(t,o.minZoom),i=void 0===o.maxZoom?i:Math.max(i,o.maxZoom);this._layersMaxZoom=i===-1/0?void 0:i,this._layersMinZoom=t===1/0?void 0:t,e!==this._getZoomSpan()&&this.fire("zoomlevelschange"),void 0===this.options.maxZoom&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var ze=Me.extend({initialize:function(t,i){var e,n;if(c(this,i),this._layers={},t)for(e=0,n=t.length;e<n;e++)this.addLayer(t[e])},addLayer:function(t){var i=this.getLayerId(t);return this._layers[i]=t,this._map&&this._map.addLayer(t),this},removeLayer:function(t){var i=t in this._layers?t:this.getLayerId(t);return this._map&&this._layers[i]&&this._map.removeLayer(this._layers[i]),delete this._layers[i],this},hasLayer:function(t){return!!t&&("number"==typeof t?t:this.getLayerId(t))in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(t){var i,e,n=Array.prototype.slice.call(arguments,1);for(i in this._layers)(e=this._layers[i])[t]&&e[t].apply(e,n);return this},onAdd:function(t){this.eachLayer(t.addLayer,t)},onRemove:function(t){this.eachLayer(t.removeLayer,t)},eachLayer:function(t,i){for(var e in this._layers)t.call(i,this._layers[e]);return this},getLayer:function(t){return this._layers[t]},getLayers:function(){var t=[];return this.eachLayer(t.push,t),t},setZIndex:function(t){return this.invoke("setZIndex",t)},getLayerId:m}),Ce=ze.extend({addLayer:function(t){return this.hasLayer(t)?this:(t.addEventParent(this),ze.prototype.addLayer.call(this,t),this.fire("layeradd",{layer:t}))},removeLayer:function(t){return this.hasLayer(t)?(t in this._layers&&(t=this._layers[t]),t.removeEventParent(this),ze.prototype.removeLayer.call(this,t),this.fire("layerremove",{layer:t})):this},setStyle:function(t){return this.invoke("setStyle",t)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var t=new R;for(var i in this._layers){var e=this._layers[i];t.extend(e.getBounds?e.getBounds():e.getLatLng())}return t}}),Se=S.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0]},initialize:function(t){c(this,t)},createIcon:function(t){return this._createIcon("icon",t)},createShadow:function(t){return this._createIcon("shadow",t)},_createIcon:function(t,i){var e=this._getIconUrl(t);if(!e){if("icon"===t)throw new Error("iconUrl not set in Icon options (see the docs).");return null}var n=this._createImg(e,i&&"IMG"===i.tagName?i:null);return this._setIconStyles(n,t),n},_setIconStyles:function(t,i){var e=this.options,n=e[i+"Size"];"number"==typeof n&&(n=[n,n]);var o=A(n),s=A("shadow"===i&&e.shadowAnchor||e.iconAnchor||o&&o.divideBy(2,!0));t.className="leaflet-marker-"+i+" "+(e.className||""),s&&(t.style.marginLeft=-s.x+"px",t.style.marginTop=-s.y+"px"),o&&(t.style.width=o.x+"px",t.style.height=o.y+"px")},_createImg:function(t,i){return(i=i||document.createElement("img")).src=t,i},_getIconUrl:function(t){return zt&&this.options[t+"RetinaUrl"]||this.options[t+"Url"]}});var Ze=Se.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(t){return Ze.imagePath||(Ze.imagePath=this._detectIconPath()),(this.options.imagePath||Ze.imagePath)+Se.prototype._getIconUrl.call(this,t)},_detectIconPath:function(){var t=si("div","leaflet-default-icon-path",document.body),i=oi(t,"background-image")||oi(t,"backgroundImage");return document.body.removeChild(t),i=null===i||0!==i.indexOf("url")?"":i.replace(/^url\(["']?/,"").replace(/marker-icon\.png["']?\)$/,"")}}),Ee=ie.extend({initialize:function(t){this._marker=t},addHooks:function(){var t=this._marker._icon;this._draggable||(this._draggable=new ae(t,t,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),ci(t,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&_i(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(t){var i,e=this._marker,n=e._map,o=this._marker.options.autoPanSpeed,s=this._marker.options.autoPanPadding,r=yi(e._icon),a=n.getPixelBounds(),h=n.getPixelOrigin(),u=O(a.min._subtract(h).add(s),a.max._subtract(h).subtract(s));u.contains(r)||(i=A((Math.max(u.max.x,r.x)-u.max.x)/(a.max.x-u.max.x)-(Math.min(u.min.x,r.x)-u.min.x)/(a.min.x-u.min.x),(Math.max(u.max.y,r.y)-u.max.y)/(a.max.y-u.max.y)-(Math.min(u.min.y,r.y)-u.min.y)/(a.min.y-u.min.y)).multiplyBy(o),n.panBy(i,{animate:!1}),this._draggable._newPos._add(i),this._draggable._startPos._add(i),vi(e._icon,this._draggable._newPos),this._onDrag(t),this._panRequest=M(this._adjustPan.bind(this,t)))},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(t){this._marker.options.autoPan&&(z(this._panRequest),this._panRequest=M(this._adjustPan.bind(this,t)))},_onDrag:function(t){var i=this._marker,e=i._shadow,n=yi(i._icon),o=i._map.layerPointToLatLng(n);e&&vi(e,n),i._latlng=o,t.latlng=o,t.oldLatLng=this._oldLatLng,i.fire("move",t).fire("drag",t)},_onDragEnd:function(t){z(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",t)}}),ke=Me.extend({options:{icon:new Ze,interactive:!0,keyboard:!0,title:"",alt:"",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingMouseEvents:!1,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(t,i){c(this,i),this._latlng=j(t)},onAdd:function(t){this._zoomAnimated=this._zoomAnimated&&t.options.markerZoomAnimation,this._zoomAnimated&&t.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(t){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&t.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(t){var i=this._latlng;return this._latlng=j(t),this.update(),this.fire("move",{oldLatLng:i,latlng:this._latlng})},setZIndexOffset:function(t){return this.options.zIndexOffset=t,this.update()},getIcon:function(){return this.options.icon},setIcon:function(t){return this.options.icon=t,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){var t;return this._icon&&this._map&&(t=this._map.latLngToLayerPoint(this._latlng).round(),this._setPos(t)),this},_initIcon:function(){var t=this.options,i="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),e=t.icon.createIcon(this._icon),n=!1;e!==this._icon&&(this._icon&&this._removeIcon(),n=!0,t.title&&(e.title=t.title),"IMG"===e.tagName&&(e.alt=t.alt||"")),ci(e,i),t.keyboard&&(e.tabIndex="0"),this._icon=e,t.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex});var o=t.icon.createShadow(this._shadow),s=!1;o!==this._shadow&&(this._removeShadow(),s=!0),o&&(ci(o,i),o.alt=""),this._shadow=o,t.opacity<1&&this._updateOpacity(),n&&this.getPane().appendChild(this._icon),this._initInteraction(),o&&s&&this.getPane(t.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),ri(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&ri(this._shadow),this._shadow=null},_setPos:function(t){this._icon&&vi(this._icon,t),this._shadow&&vi(this._shadow,t),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(t){this._icon&&(this._icon.style.zIndex=this._zIndex+t)},_animateZoom:function(t){var i=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center).round();this._setPos(i)},_initInteraction:function(){var t;this.options.interactive&&(ci(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),Ee&&(t=this.options.draggable,this.dragging&&(t=this.dragging.enabled(),this.dragging.disable()),this.dragging=new Ee(this),t&&this.dragging.enable()))},setOpacity:function(t){return this.options.opacity=t,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var t=this.options.opacity;this._icon&&mi(this._icon,t),this._shadow&&mi(this._shadow,t)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});var Be=Me.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(t){this._renderer=t.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(t){return c(this,t),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&t&&Object.prototype.hasOwnProperty.call(t,"weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+this._renderer.options.tolerance}}),Ae=Be.extend({options:{fill:!0,radius:10},initialize:function(t,i){c(this,i),this._latlng=j(t),this._radius=this.options.radius},setLatLng:function(t){var i=this._latlng;return this._latlng=j(t),this.redraw(),this.fire("move",{oldLatLng:i,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(t){return this.options.radius=this._radius=t,this.redraw()},getRadius:function(){return this._radius},setStyle:function(t){var i=t&&t.radius||this._radius;return Be.prototype.setStyle.call(this,t),this.setRadius(i),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var t=this._radius,i=this._radiusY||t,e=this._clickTolerance(),n=[t+e,i+e];this._pxBounds=new I(this._point.subtract(n),this._point.add(n))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(t){return t.distanceTo(this._point)<=this._radius+this._clickTolerance()}});var Ie=Ae.extend({initialize:function(t,i,e){if("number"==typeof i&&(i=h({},e,{radius:i})),c(this,i),this._latlng=j(t),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(t){return this._mRadius=t,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var t=[this._radius,this._radiusY||this._radius];return new R(this._map.layerPointToLatLng(this._point.subtract(t)),this._map.layerPointToLatLng(this._point.add(t)))},setStyle:Be.prototype.setStyle,_project:function(){var t,i,e,n,o,s,r,a,h=this._latlng.lng,u=this._latlng.lat,l=this._map,c=l.options.crs;c.distance===F.distance?(t=Math.PI/180,i=this._mRadius/F.R/t,e=l.project([u+i,h]),n=l.project([u-i,h]),o=e.add(n).divideBy(2),s=l.unproject(o).lat,r=Math.acos((Math.cos(i*t)-Math.sin(u*t)*Math.sin(s*t))/(Math.cos(u*t)*Math.cos(s*t)))/t,!isNaN(r)&&0!==r||(r=i/Math.cos(Math.PI/180*u)),this._point=o.subtract(l.getPixelOrigin()),this._radius=isNaN(r)?0:o.x-l.project([s,h-r]).x,this._radiusY=o.y-e.y):(a=c.unproject(c.project(this._latlng).subtract([this._mRadius,0])),this._point=l.latLngToLayerPoint(this._latlng),this._radius=this._point.x-l.latLngToLayerPoint(a).x),this._updateBounds()}});var Oe=Be.extend({options:{smoothFactor:1,noClip:!1},initialize:function(t,i){c(this,i),this._setLatLngs(t)},getLatLngs:function(){return this._latlngs},setLatLngs:function(t){return this._setLatLngs(t),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(t){for(var i,e,n=1/0,o=null,s=de,r=0,a=this._parts.length;r<a;r++)for(var h=this._parts[r],u=1,l=h.length;u<l;u++){var c=s(t,i=h[u-1],e=h[u],!0);c<n&&(n=c,o=s(t,i,e))}return o&&(o.distance=Math.sqrt(n)),o},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");var t,i,e,n,o,s,r,a=this._rings[0],h=a.length;if(!h)return null;for(i=t=0;t<h-1;t++)i+=a[t].distanceTo(a[t+1])/2;if(0===i)return this._map.layerPointToLatLng(a[0]);for(n=t=0;t<h-1;t++)if(o=a[t],s=a[t+1],i<(n+=e=o.distanceTo(s)))return r=(n-i)/e,this._map.layerPointToLatLng([s.x-r*(s.x-o.x),s.y-r*(s.y-o.y)])},getBounds:function(){return this._bounds},addLatLng:function(t,i){return i=i||this._defaultShape(),t=j(t),i.push(t),this._bounds.extend(t),this.redraw()},_setLatLngs:function(t){this._bounds=new R,this._latlngs=this._convertLatLngs(t)},_defaultShape:function(){return pe(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(t){for(var i=[],e=pe(t),n=0,o=t.length;n<o;n++)e?(i[n]=j(t[n]),this._bounds.extend(i[n])):i[n]=this._convertLatLngs(t[n]);return i},_project:function(){var t=new I;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,t),this._bounds.isValid()&&t.isValid()&&(this._rawPxBounds=t,this._updateBounds())},_updateBounds:function(){var t=this._clickTolerance(),i=new k(t,t);this._pxBounds=new I([this._rawPxBounds.min.subtract(i),this._rawPxBounds.max.add(i)])},_projectLatlngs:function(t,i,e){var n,o,s=t[0]instanceof D,r=t.length;if(s){for(o=[],n=0;n<r;n++)o[n]=this._map.latLngToLayerPoint(t[n]),e.extend(o[n]);i.push(o)}else for(n=0;n<r;n++)this._projectLatlngs(t[n],i,e)},_clipPoints:function(){var t=this._renderer._bounds;if(this._parts=[],this._pxBounds&&this._pxBounds.intersects(t))if(this.options.noClip)this._parts=this._rings;else for(var i,e,n,o,s=this._parts,r=0,a=0,h=this._rings.length;r<h;r++)for(i=0,e=(o=this._rings[r]).length;i<e-1;i++)(n=le(o[i],o[i+1],t,i,!0))&&(s[a]=s[a]||[],s[a].push(n[0]),n[1]===o[i+1]&&i!==e-2||(s[a].push(n[1]),a++))},_simplifyPoints:function(){for(var t=this._parts,i=this.options.smoothFactor,e=0,n=t.length;e<n;e++)t[e]=he(t[e],i)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(t,i){var e,n,o,s,r,a,h=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(t))return!1;for(e=0,s=this._parts.length;e<s;e++)for(n=0,o=(r=(a=this._parts[e]).length)-1;n<r;o=n++)if((i||0!==n)&&ue(t,a[o],a[n])<=h)return!0;return!1}});Oe._flat=me;var Re=Oe.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");var t,i,e,n,o,s,r,a,h,u=this._rings[0],l=u.length;if(!l)return null;for(t=s=r=a=0,i=l-1;t<l;i=t++)e=u[t],n=u[i],o=e.y*n.x-n.y*e.x,r+=(e.x+n.x)*o,a+=(e.y+n.y)*o,s+=3*o;return h=0===s?u[0]:[r/s,a/s],this._map.layerPointToLatLng(h)},_convertLatLngs:function(t){var i=Oe.prototype._convertLatLngs.call(this,t),e=i.length;return 2<=e&&i[0]instanceof D&&i[0].equals(i[e-1])&&i.pop(),i},_setLatLngs:function(t){Oe.prototype._setLatLngs.call(this,t),pe(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return pe(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,i=this.options.weight,e=new k(i,i),t=new I(t.min.subtract(e),t.max.add(e));if(this._parts=[],this._pxBounds&&this._pxBounds.intersects(t))if(this.options.noClip)this._parts=this._rings;else for(var n,o=0,s=this._rings.length;o<s;o++)(n=ge(this._rings[o],t,!0)).length&&this._parts.push(n)},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(t){var i,e,n,o,s,r,a,h,u=!1;if(!this._pxBounds||!this._pxBounds.contains(t))return!1;for(o=0,a=this._parts.length;o<a;o++)for(s=0,r=(h=(i=this._parts[o]).length)-1;s<h;r=s++)e=i[s],n=i[r],e.y>t.y!=n.y>t.y&&t.x<(n.x-e.x)*(t.y-e.y)/(n.y-e.y)+e.x&&(u=!u);return u||Oe.prototype._containsPoint.call(this,t,!0)}});var Ne=Ce.extend({initialize:function(t,i){c(this,i),this._layers={},t&&this.addData(t)},addData:function(t){var i,e,n,o=g(t)?t:t.features;if(o){for(i=0,e=o.length;i<e;i++)((n=o[i]).geometries||n.geometry||n.features||n.coordinates)&&this.addData(n);return this}var s=this.options;if(s.filter&&!s.filter(t))return this;var r=De(t,s);return r?(r.feature=qe(t),r.defaultOptions=r.options,this.resetStyle(r),s.onEachFeature&&s.onEachFeature(t,r),this.addLayer(r)):this},resetStyle:function(t){return void 0===t?this.eachLayer(this.resetStyle,this):(t.options=h({},t.defaultOptions),this._setLayerStyle(t,this.options.style),this)},setStyle:function(i){return this.eachLayer(function(t){this._setLayerStyle(t,i)},this)},_setLayerStyle:function(t,i){t.setStyle&&("function"==typeof i&&(i=i(t.feature)),t.setStyle(i))}});function De(t,i){var e,n,o,s,r="Feature"===t.type?t.geometry:t,a=r?r.coordinates:null,h=[],u=i&&i.pointToLayer,l=i&&i.coordsToLatLng||We;if(!a&&!r)return null;switch(r.type){case"Point":return je(u,t,e=l(a),i);case"MultiPoint":for(o=0,s=a.length;o<s;o++)e=l(a[o]),h.push(je(u,t,e,i));return new Ce(h);case"LineString":case"MultiLineString":return n=He(a,"LineString"===r.type?0:1,l),new Oe(n,i);case"Polygon":case"MultiPolygon":return n=He(a,"Polygon"===r.type?1:2,l),new Re(n,i);case"GeometryCollection":for(o=0,s=r.geometries.length;o<s;o++){var c=De({geometry:r.geometries[o],type:"Feature",properties:t.properties},i);c&&h.push(c)}return new Ce(h);default:throw new Error("Invalid GeoJSON object.")}}function je(t,i,e,n){return t?t(i,e):new ke(e,n&&n.markersInheritOptions&&n)}function We(t){return new D(t[1],t[0],t[2])}function He(t,i,e){for(var n,o=[],s=0,r=t.length;s<r;s++)n=i?He(t[s],i-1,e):(e||We)(t[s]),o.push(n);return o}function Fe(t,i){return i="number"==typeof i?i:6,void 0!==t.alt?[r(t.lng,i),r(t.lat,i),r(t.alt,i)]:[r(t.lng,i),r(t.lat,i)]}function Ue(t,i,e,n){for(var o=[],s=0,r=t.length;s<r;s++)o.push(i?Ue(t[s],i-1,e,n):Fe(t[s],n));return!i&&e&&o.push(o[0]),o}function Ve(t,i){return t.feature?h({},t.feature,{geometry:i}):qe(i)}function qe(t){return"Feature"===t.type||"FeatureCollection"===t.type?t:{type:"Feature",properties:{},geometry:t}}var Ge={toGeoJSON:function(t){return Ve(this,{type:"Point",coordinates:Fe(this.getLatLng(),t)})}};function Ke(t,i){return new Ne(t,i)}ke.include(Ge),Ie.include(Ge),Ae.include(Ge),Oe.include({toGeoJSON:function(t){var i=!pe(this._latlngs);return Ve(this,{type:(i?"Multi":"")+"LineString",coordinates:Ue(this._latlngs,i?1:0,!1,t)})}}),Re.include({toGeoJSON:function(t){var i=!pe(this._latlngs),e=i&&!pe(this._latlngs[0]),n=Ue(this._latlngs,e?2:i?1:0,!0,t);return i||(n=[n]),Ve(this,{type:(e?"Multi":"")+"Polygon",coordinates:n})}}),ze.include({toMultiPoint:function(i){var e=[];return this.eachLayer(function(t){e.push(t.toGeoJSON(i).geometry.coordinates)}),Ve(this,{type:"MultiPoint",coordinates:e})},toGeoJSON:function(n){var t=this.feature&&this.feature.geometry&&this.feature.geometry.type;if("MultiPoint"===t)return this.toMultiPoint(n);var o="GeometryCollection"===t,s=[];return this.eachLayer(function(t){var i,e;t.toGeoJSON&&(i=t.toGeoJSON(n),o?s.push(i.geometry):"FeatureCollection"===(e=qe(i)).type?s.push.apply(s,e.features):s.push(e))}),o?Ve(this,{geometries:s,type:"GeometryCollection"}):{type:"FeatureCollection",features:s}}});var Ye=Ke,Xe=Me.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(t,i,e){this._url=t,this._bounds=N(i),c(this,e)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(ci(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){ri(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(t){return this.options.opacity=t,this._image&&this._updateOpacity(),this},setStyle:function(t){return t.opacity&&this.setOpacity(t.opacity),this},bringToFront:function(){return this._map&&hi(this._image),this},bringToBack:function(){return this._map&&ui(this._image),this},setUrl:function(t){return this._url=t,this._image&&(this._image.src=t),this},setBounds:function(t){return this._bounds=N(t),this._map&&this._reset(),this},getEvents:function(){var t={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var t="IMG"===this._url.tagName,i=this._image=t?this._url:si("img");ci(i,"leaflet-image-layer"),this._zoomAnimated&&ci(i,"leaflet-zoom-animated"),this.options.className&&ci(i,this.options.className),i.onselectstart=a,i.onmousemove=a,i.onload=p(this.fire,this,"load"),i.onerror=p(this._overlayOnError,this,"error"),!this.options.crossOrigin&&""!==this.options.crossOrigin||(i.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),t?this._url=i.src:(i.src=this._url,i.alt=this.options.alt)},_animateZoom:function(t){var i=this._map.getZoomScale(t.zoom),e=this._map._latLngBoundsToNewLayerBounds(this._bounds,t.zoom,t.center).min;gi(this._image,e,i)},_reset:function(){var t=this._image,i=new I(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),e=i.getSize();vi(t,i.min),t.style.width=e.x+"px",t.style.height=e.y+"px"},_updateOpacity:function(){mi(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var t=this.options.errorOverlayUrl;t&&this._url!==t&&(this._url=t,this._image.src=t)}}),Je=Xe.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1},_initImage:function(){var t="VIDEO"===this._url.tagName,i=this._image=t?this._url:si("video");if(ci(i,"leaflet-image-layer"),this._zoomAnimated&&ci(i,"leaflet-zoom-animated"),this.options.className&&ci(i,this.options.className),i.onselectstart=a,i.onmousemove=a,i.onloadeddata=p(this.fire,this,"load"),t){for(var e=i.getElementsByTagName("source"),n=[],o=0;o<e.length;o++)n.push(e[o].src);this._url=0<e.length?n:[i.src]}else{g(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(i.style,"objectFit")&&(i.style.objectFit="fill"),i.autoplay=!!this.options.autoplay,i.loop=!!this.options.loop,i.muted=!!this.options.muted;for(var s=0;s<this._url.length;s++){var r=si("source");r.src=this._url[s],i.appendChild(r)}}}});var $e=Xe.extend({_initImage:function(){var t=this._image=this._url;ci(t,"leaflet-image-layer"),this._zoomAnimated&&ci(t,"leaflet-zoom-animated"),this.options.className&&ci(t,this.options.className),t.onselectstart=a,t.onmousemove=a}});var Qe=Me.extend({options:{offset:[0,7],className:"",pane:"popupPane"},initialize:function(t,i){c(this,t),this._source=i},onAdd:function(t){this._zoomAnimated=t._zoomAnimated,this._container||this._initLayout(),t._fadeAnimated&&mi(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),t._fadeAnimated&&mi(this._container,1),this.bringToFront()},onRemove:function(t){t._fadeAnimated?(mi(this._container,0),this._removeTimeout=setTimeout(p(ri,void 0,this._container),200)):ri(this._container)},getLatLng:function(){return this._latlng},setLatLng:function(t){return this._latlng=j(t),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(t){return this._content=t,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var t={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&hi(this._container),this},bringToBack:function(){return this._map&&ui(this._container),this},_prepareOpen:function(t,i,e){if(i instanceof Me||(e=i,i=t),i instanceof Ce)for(var n in t._layers){i=t._layers[n];break}if(!e)if(i.getCenter)e=i.getCenter();else{if(!i.getLatLng)throw new Error("Unable to get source layer LatLng.");e=i.getLatLng()}return this._source=i,this.update(),e},_updateContent:function(){if(this._content){var t=this._contentNode,i="function"==typeof this._content?this._content(this._source||this):this._content;if("string"==typeof i)t.innerHTML=i;else{for(;t.hasChildNodes();)t.removeChild(t.firstChild);t.appendChild(i)}this.fire("contentupdate")}},_updatePosition:function(){var t,i,e,n,o;this._map&&(t=this._map.latLngToLayerPoint(this._latlng),i=A(this.options.offset),e=this._getAnchor(),this._zoomAnimated?vi(this._container,t.add(e)):i=i.add(t).add(e),n=this._containerBottom=-i.y,o=this._containerLeft=-Math.round(this._containerWidth/2)+i.x,this._container.style.bottom=n+"px",this._container.style.left=o+"px")},_getAnchor:function(){return[0,0]}}),tn=Qe.extend({options:{maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:""},openOn:function(t){return t.openPopup(this),this},onAdd:function(t){Qe.prototype.onAdd.call(this,t),t.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof Be||this._source.on("preclick",Ai))},onRemove:function(t){Qe.prototype.onRemove.call(this,t),t.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof Be||this._source.off("preclick",Ai))},getEvents:function(){var t=Qe.prototype.getEvents.call(this);return(void 0!==this.options.closeOnClick?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(t.preclick=this._close),this.options.keepInView&&(t.moveend=this._adjustPan),t},_close:function(){this._map&&this._map.closePopup(this)},_initLayout:function(){var t,i="leaflet-popup",e=this._container=si("div",i+" "+(this.options.className||"")+" leaflet-zoom-animated"),n=this._wrapper=si("div",i+"-content-wrapper",e);this._contentNode=si("div",i+"-content",n),Oi(e),Ii(this._contentNode),zi(e,"contextmenu",Ai),this._tipContainer=si("div",i+"-tip-container",e),this._tip=si("div",i+"-tip",this._tipContainer),this.options.closeButton&&((t=this._closeButton=si("a",i+"-close-button",e)).href="#close",t.innerHTML="&#215;",zi(t,"click",this._onCloseButtonClick,this))},_updateLayout:function(){var t=this._contentNode,i=t.style;i.width="",i.whiteSpace="nowrap";var e=t.offsetWidth,e=Math.min(e,this.options.maxWidth);e=Math.max(e,this.options.minWidth),i.width=e+1+"px",i.whiteSpace="",i.height="";var n=t.offsetHeight,o=this.options.maxHeight,s="leaflet-popup-scrolled";o&&o<n?(i.height=o+"px",ci(t,s)):_i(t,s),this._containerWidth=this._container.offsetWidth},_animateZoom:function(t){var i=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),e=this._getAnchor();vi(this._container,i.add(e))},_adjustPan:function(){var t,i,e,n,o,s,r,a,h,u,l,c;this.options.autoPan&&(this._map._panAnim&&this._map._panAnim.stop(),t=this._map,i=parseInt(oi(this._container,"marginBottom"),10)||0,e=this._container.offsetHeight+i,n=this._containerWidth,(o=new k(this._containerLeft,-e-this._containerBottom))._add(yi(this._container)),s=t.layerPointToContainerPoint(o),r=A(this.options.autoPanPadding),a=A(this.options.autoPanPaddingTopLeft||r),h=A(this.options.autoPanPaddingBottomRight||r),u=t.getSize(),c=l=0,s.x+n+h.x>u.x&&(l=s.x+n-u.x+h.x),s.x-l-a.x<0&&(l=s.x-a.x),s.y+e+h.y>u.y&&(c=s.y+e-u.y+h.y),s.y-c-a.y<0&&(c=s.y-a.y),(l||c)&&t.fire("autopanstart").panBy([l,c]))},_onCloseButtonClick:function(t){this._close(),Ni(t)},_getAnchor:function(){return A(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}});Ki.mergeOptions({closePopupOnClick:!0}),Ki.include({openPopup:function(t,i,e){return t instanceof tn||(t=new tn(e).setContent(t)),i&&t.setLatLng(i),this.hasLayer(t)?this:(this._popup&&this._popup.options.autoClose&&this.closePopup(),this._popup=t,this.addLayer(t))},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&this.removeLayer(t),this}}),Me.include({bindPopup:function(t,i){return t instanceof tn?(c(t,i),(this._popup=t)._source=this):(this._popup&&!i||(this._popup=new tn(i,this)),this._popup.setContent(t)),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t,i){return this._popup&&this._map&&(i=this._popup._prepareOpen(this,t,i),this._map.openPopup(this._popup,i)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(t){return this._popup&&(this._popup._map?this.closePopup():this.openPopup(t)),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var i=t.layer||t.target;this._popup&&this._map&&(Ni(t),i instanceof Be?this.openPopup(t.layer||t.target,t.latlng):this._map.hasLayer(this._popup)&&this._popup._source===i?this.closePopup():this.openPopup(i,t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var en=Qe.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,interactive:!1,opacity:.9},onAdd:function(t){Qe.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&this._source.fire("tooltipopen",{tooltip:this},!0)},onRemove:function(t){Qe.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&this._source.fire("tooltipclose",{tooltip:this},!0)},getEvents:function(){var t=Qe.prototype.getEvents.call(this);return bt&&!this.options.permanent&&(t.preclick=this._close),t},_close:function(){this._map&&this._map.closeTooltip(this)},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=si("div",t)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var i,e=this._map,n=this._container,o=e.latLngToContainerPoint(e.getCenter()),s=e.layerPointToContainerPoint(t),r=this.options.direction,a=n.offsetWidth,h=n.offsetHeight,u=A(this.options.offset),l=this._getAnchor(),c="top"===r?(i=a/2,h):"bottom"===r?(i=a/2,0):(i="center"===r?a/2:"right"===r?0:"left"===r?a:s.x<o.x?(r="right",0):(r="left",a+2*(u.x+l.x)),h/2);t=t.subtract(A(i,c,!0)).add(u).add(l),_i(n,"leaflet-tooltip-right"),_i(n,"leaflet-tooltip-left"),_i(n,"leaflet-tooltip-top"),_i(n,"leaflet-tooltip-bottom"),ci(n,"leaflet-tooltip-"+r),vi(n,t)},_updatePosition:function(){var t=this._map.latLngToLayerPoint(this._latlng);this._setPosition(t)},setOpacity:function(t){this.options.opacity=t,this._container&&mi(this._container,t)},_animateZoom:function(t){var i=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center);this._setPosition(i)},_getAnchor:function(){return A(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}});Ki.include({openTooltip:function(t,i,e){return t instanceof en||(t=new en(e).setContent(t)),i&&t.setLatLng(i),this.hasLayer(t)?this:this.addLayer(t)},closeTooltip:function(t){return t&&this.removeLayer(t),this}}),Me.include({bindTooltip:function(t,i){return t instanceof en?(c(t,i),(this._tooltip=t)._source=this):(this._tooltip&&!i||(this._tooltip=new en(i,this)),this._tooltip.setContent(t)),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(t){var i,e;!t&&this._tooltipHandlersAdded||(i=t?"off":"on",e={remove:this.closeTooltip,move:this._moveTooltip},this._tooltip.options.permanent?e.add=this._openTooltip:(e.mouseover=this._openTooltip,e.mouseout=this.closeTooltip,this._tooltip.options.sticky&&(e.mousemove=this._moveTooltip),bt&&(e.click=this._openTooltip)),this[i](e),this._tooltipHandlersAdded=!t)},openTooltip:function(t,i){return this._tooltip&&this._map&&(i=this._tooltip._prepareOpen(this,t,i),this._map.openTooltip(this._tooltip,i),this._tooltip.options.interactive&&this._tooltip._container&&(ci(this._tooltip._container,"leaflet-clickable"),this.addInteractiveTarget(this._tooltip._container))),this},closeTooltip:function(){return this._tooltip&&(this._tooltip._close(),this._tooltip.options.interactive&&this._tooltip._container&&(_i(this._tooltip._container,"leaflet-clickable"),this.removeInteractiveTarget(this._tooltip._container))),this},toggleTooltip:function(t){return this._tooltip&&(this._tooltip._map?this.closeTooltip():this.openTooltip(t)),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(t){return this._tooltip&&this._tooltip.setContent(t),this},getTooltip:function(){return this._tooltip},_openTooltip:function(t){var i=t.layer||t.target;this._tooltip&&this._map&&this.openTooltip(i,this._tooltip.options.sticky?t.latlng:void 0)},_moveTooltip:function(t){var i,e,n=t.latlng;this._tooltip.options.sticky&&t.originalEvent&&(i=this._map.mouseEventToContainerPoint(t.originalEvent),e=this._map.containerPointToLayerPoint(i),n=this._map.layerPointToLatLng(e)),this._tooltip.setLatLng(n)}});var nn=Se.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(t){var i,e=t&&"DIV"===t.tagName?t:document.createElement("div"),n=this.options;return n.html instanceof Element?(ai(e),e.appendChild(n.html)):e.innerHTML=!1!==n.html?n.html:"",n.bgPos&&(i=A(n.bgPos),e.style.backgroundPosition=-i.x+"px "+-i.y+"px"),this._setIconStyles(e,"icon"),e},createShadow:function(){return null}});Se.Default=Ze;var on=Me.extend({options:{tileSize:256,opacity:1,updateWhenIdle:yt,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(t){c(this,t)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView(),this._update()},beforeAdd:function(t){t._addZoomLimit(this)},onRemove:function(t){this._removeAllTiles(),ri(this._container),t._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(hi(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(ui(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(t){return this.options.opacity=t,this._updateOpacity(),this},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){return this._map&&(this._removeAllTiles(),this._update()),this},getEvents:function(){var t={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=n(this._onMoveEnd,this.options.updateInterval,this)),t.move=this._onMove),this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},createTile:function(){return document.createElement("div")},getTileSize:function(){var t=this.options.tileSize;return t instanceof k?t:new k(t,t)},_updateZIndex:function(){this._container&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(t){for(var i,e=this.getPane().children,n=-t(-1/0,1/0),o=0,s=e.length;o<s;o++)i=e[o].style.zIndex,e[o]!==this._container&&i&&(n=t(n,+i));isFinite(n)&&(this.options.zIndex=n+t(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!it){mi(this._container,this.options.opacity);var t=+new Date,i=!1,e=!1;for(var n in this._tiles){var o,s=this._tiles[n];s.current&&s.loaded&&(o=Math.min(1,(t-s.loaded)/200),mi(s.el,o),o<1?i=!0:(s.active?e=!0:this._onOpaqueTile(s),s.active=!0))}e&&!this._noPrune&&this._pruneTiles(),i&&(z(this._fadeFrame),this._fadeFrame=M(this._updateOpacity,this))}},_onOpaqueTile:a,_initContainer:function(){this._container||(this._container=si("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var t=this._tileZoom,i=this.options.maxZoom;if(void 0!==t){for(var e in this._levels)e=Number(e),this._levels[e].el.children.length||e===t?(this._levels[e].el.style.zIndex=i-Math.abs(t-e),this._onUpdateLevel(e)):(ri(this._levels[e].el),this._removeTilesAtZoom(e),this._onRemoveLevel(e),delete this._levels[e]);var n=this._levels[t],o=this._map;return n||((n=this._levels[t]={}).el=si("div","leaflet-tile-container leaflet-zoom-animated",this._container),n.el.style.zIndex=i,n.origin=o.project(o.unproject(o.getPixelOrigin()),t).round(),n.zoom=t,this._setZoomTransform(n,o.getCenter(),o.getZoom()),a(n.el.offsetWidth),this._onCreateLevel(n)),this._level=n}},_onUpdateLevel:a,_onRemoveLevel:a,_onCreateLevel:a,_pruneTiles:function(){if(this._map){var t,i,e,n=this._map.getZoom();if(n>this.options.maxZoom||n<this.options.minZoom)this._removeAllTiles();else{for(t in this._tiles)(e=this._tiles[t]).retain=e.current;for(t in this._tiles){(e=this._tiles[t]).current&&!e.active&&(i=e.coords,this._retainParent(i.x,i.y,i.z,i.z-5)||this._retainChildren(i.x,i.y,i.z,i.z+2))}for(t in this._tiles)this._tiles[t].retain||this._removeTile(t)}}},_removeTilesAtZoom:function(t){for(var i in this._tiles)this._tiles[i].coords.z===t&&this._removeTile(i)},_removeAllTiles:function(){for(var t in this._tiles)this._removeTile(t)},_invalidateAll:function(){for(var t in this._levels)ri(this._levels[t].el),this._onRemoveLevel(Number(t)),delete this._levels[t];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(t,i,e,n){var o=Math.floor(t/2),s=Math.floor(i/2),r=e-1,a=new k(+o,+s);a.z=+r;var h=this._tileCoordsToKey(a),u=this._tiles[h];return u&&u.active?u.retain=!0:(u&&u.loaded&&(u.retain=!0),n<r&&this._retainParent(o,s,r,n))},_retainChildren:function(t,i,e,n){for(var o=2*t;o<2*t+2;o++)for(var s=2*i;s<2*i+2;s++){var r=new k(o,s);r.z=e+1;var a=this._tileCoordsToKey(r),h=this._tiles[a];h&&h.active?h.retain=!0:(h&&h.loaded&&(h.retain=!0),e+1<n&&this._retainChildren(o,s,e+1,n))}},_resetView:function(t){var i=t&&(t.pinch||t.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),i,i)},_animateZoom:function(t){this._setView(t.center,t.zoom,!0,t.noUpdate)},_clampZoom:function(t){var i=this.options;return void 0!==i.minNativeZoom&&t<i.minNativeZoom?i.minNativeZoom:void 0!==i.maxNativeZoom&&i.maxNativeZoom<t?i.maxNativeZoom:t},_setView:function(t,i,e,n){var o=Math.round(i),o=void 0!==this.options.maxZoom&&o>this.options.maxZoom||void 0!==this.options.minZoom&&o<this.options.minZoom?void 0:this._clampZoom(o),s=this.options.updateWhenZooming&&o!==this._tileZoom;n&&!s||(this._tileZoom=o,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),void 0!==o&&this._update(t),e||this._pruneTiles(),this._noPrune=!!e),this._setZoomTransforms(t,i)},_setZoomTransforms:function(t,i){for(var e in this._levels)this._setZoomTransform(this._levels[e],t,i)},_setZoomTransform:function(t,i,e){var n=this._map.getZoomScale(e,t.zoom),o=t.origin.multiplyBy(n).subtract(this._map._getNewPixelOrigin(i,e)).round();vt?gi(t.el,o,n):vi(t.el,o)},_resetGrid:function(){var t=this._map,i=t.options.crs,e=this._tileSize=this.getTileSize(),n=this._tileZoom,o=this._map.getPixelWorldBounds(this._tileZoom);o&&(this._globalTileRange=this._pxBoundsToTileRange(o)),this._wrapX=i.wrapLng&&!this.options.noWrap&&[Math.floor(t.project([0,i.wrapLng[0]],n).x/e.x),Math.ceil(t.project([0,i.wrapLng[1]],n).x/e.y)],this._wrapY=i.wrapLat&&!this.options.noWrap&&[Math.floor(t.project([i.wrapLat[0],0],n).y/e.x),Math.ceil(t.project([i.wrapLat[1],0],n).y/e.y)]},_onMoveEnd:function(){this._map&&!this._map._animatingZoom&&this._update()},_getTiledPixelBounds:function(t){var i=this._map,e=i._animatingZoom?Math.max(i._animateToZoom,i.getZoom()):i.getZoom(),n=i.getZoomScale(e,this._tileZoom),o=i.project(t,this._tileZoom).floor(),s=i.getSize().divideBy(2*n);return new I(o.subtract(s),o.add(s))},_update:function(t){var i=this._map;if(i){var e=this._clampZoom(i.getZoom());if(void 0===t&&(t=i.getCenter()),void 0!==this._tileZoom){var n=this._getTiledPixelBounds(t),o=this._pxBoundsToTileRange(n),s=o.getCenter(),r=[],a=this.options.keepBuffer,h=new I(o.getBottomLeft().subtract([a,-a]),o.getTopRight().add([a,-a]));if(!(isFinite(o.min.x)&&isFinite(o.min.y)&&isFinite(o.max.x)&&isFinite(o.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var u in this._tiles){var l=this._tiles[u].coords;l.z===this._tileZoom&&h.contains(new k(l.x,l.y))||(this._tiles[u].current=!1)}if(1<Math.abs(e-this._tileZoom))this._setView(t,e);else{for(var c=o.min.y;c<=o.max.y;c++)for(var _=o.min.x;_<=o.max.x;_++){var d,p=new k(_,c);p.z=this._tileZoom,this._isValidTile(p)&&((d=this._tiles[this._tileCoordsToKey(p)])?d.current=!0:r.push(p))}if(r.sort(function(t,i){return t.distanceTo(s)-i.distanceTo(s)}),0!==r.length){this._loading||(this._loading=!0,this.fire("loading"));for(var m=document.createDocumentFragment(),_=0;_<r.length;_++)this._addTile(r[_],m);this._level.el.appendChild(m)}}}}},_isValidTile:function(t){var i=this._map.options.crs;if(!i.infinite){var e=this._globalTileRange;if(!i.wrapLng&&(t.x<e.min.x||t.x>e.max.x)||!i.wrapLat&&(t.y<e.min.y||t.y>e.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return N(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var i=this._map,e=this.getTileSize(),n=t.scaleBy(e),o=n.add(e);return[i.unproject(n,t.z),i.unproject(o,t.z)]},_tileCoordsToBounds:function(t){var i=this._tileCoordsToNwSe(t),e=new R(i[0],i[1]);return this.options.noWrap||(e=this._map.wrapLatLngBounds(e)),e},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var i=t.split(":"),e=new k(+i[0],+i[1]);return e.z=+i[2],e},_removeTile:function(t){var i=this._tiles[t];i&&(ri(i.el),delete this._tiles[t],this.fire("tileunload",{tile:i.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){ci(t,"leaflet-tile");var i=this.getTileSize();t.style.width=i.x+"px",t.style.height=i.y+"px",t.onselectstart=a,t.onmousemove=a,it&&this.options.opacity<1&&mi(t,this.options.opacity),ot&&!st&&(t.style.WebkitBackfaceVisibility="hidden")},_addTile:function(t,i){var e=this._getTilePos(t),n=this._tileCoordsToKey(t),o=this.createTile(this._wrapCoords(t),p(this._tileReady,this,t));this._initTile(o),this.createTile.length<2&&M(p(this._tileReady,this,t,null,o)),vi(o,e),this._tiles[n]={el:o,coords:t,current:!0},i.appendChild(o),this.fire("tileloadstart",{tile:o,coords:t})},_tileReady:function(t,i,e){i&&this.fire("tileerror",{error:i,tile:e,coords:t});var n=this._tileCoordsToKey(t);(e=this._tiles[n])&&(e.loaded=+new Date,this._map._fadeAnimated?(mi(e.el,0),z(this._fadeFrame),this._fadeFrame=M(this._updateOpacity,this)):(e.active=!0,this._pruneTiles()),i||(ci(e.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:e.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),it||!this._map._fadeAnimated?M(this._pruneTiles,this):setTimeout(p(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var i=new k(this._wrapX?o(t.x,this._wrapX):t.x,this._wrapY?o(t.y,this._wrapY):t.y);return i.z=t.z,i},_pxBoundsToTileRange:function(t){var i=this.getTileSize();return new I(t.min.unscaleBy(i).floor(),t.max.unscaleBy(i).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}});var sn=on.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1},initialize:function(t,i){this._url=t,(i=c(this,i)).detectRetina&&zt&&0<i.maxZoom&&(i.tileSize=Math.floor(i.tileSize/2),i.zoomReverse?(i.zoomOffset--,i.minZoom++):(i.zoomOffset++,i.maxZoom--),i.minZoom=Math.max(0,i.minZoom)),"string"==typeof i.subdomains&&(i.subdomains=i.subdomains.split("")),ot||this.on("tileunload",this._onTileRemove)},setUrl:function(t,i){return this._url===t&&void 0===i&&(i=!0),this._url=t,i||this.redraw(),this},createTile:function(t,i){var e=document.createElement("img");return zi(e,"load",p(this._tileOnLoad,this,i,e)),zi(e,"error",p(this._tileOnError,this,i,e)),!this.options.crossOrigin&&""!==this.options.crossOrigin||(e.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),e.alt="",e.setAttribute("role","presentation"),e.src=this.getTileUrl(t),e},getTileUrl:function(t){var i,e={r:zt?"@2x":"",s:this._getSubdomain(t),x:t.x,y:t.y,z:this._getZoomForUrl()};return this._map&&!this._map.options.crs.infinite&&(i=this._globalTileRange.max.y-t.y,this.options.tms&&(e.y=i),e["-y"]=i),f(this._url,h(e,this.options))},_tileOnLoad:function(t,i){it?setTimeout(p(t,this,null,i),0):t(null,i)},_tileOnError:function(t,i,e){var n=this.options.errorTileUrl;n&&i.getAttribute("src")!==n&&(i.src=n),t(e,i)},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,i=this.options.maxZoom;return this.options.zoomReverse&&(t=i-t),t+this.options.zoomOffset},_getSubdomain:function(t){var i=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[i]},_abortLoading:function(){var t,i;for(t in this._tiles)this._tiles[t].coords.z!==this._tileZoom&&((i=this._tiles[t].el).onload=a,i.onerror=a,i.complete||(i.src=y,ri(i),delete this._tiles[t]))},_removeTile:function(t){var i=this._tiles[t];if(i)return at||i.el.setAttribute("src",y),on.prototype._removeTile.call(this,t)},_tileReady:function(t,i,e){if(this._map&&(!e||e.getAttribute("src")!==y))return on.prototype._tileReady.call(this,t,i,e)}});function rn(t,i){return new sn(t,i)}var an=sn.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(t,i){this._url=t;var e=h({},this.defaultWmsParams);for(var n in i)n in this.options||(e[n]=i[n]);var o=(i=c(this,i)).detectRetina&&zt?2:1,s=this.getTileSize();e.width=s.x*o,e.height=s.y*o,this.wmsParams=e},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var i=1.3<=this._wmsVersion?"crs":"srs";this.wmsParams[i]=this._crs.code,sn.prototype.onAdd.call(this,t)},getTileUrl:function(t){var i=this._tileCoordsToNwSe(t),e=this._crs,n=O(e.project(i[0]),e.project(i[1])),o=n.min,s=n.max,r=(1.3<=this._wmsVersion&&this._crs===be?[o.y,o.x,s.y,s.x]:[o.x,o.y,s.x,s.y]).join(","),a=sn.prototype.getTileUrl.call(this,t);return a+_(this.wmsParams,a,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+r},setParams:function(t,i){return h(this.wmsParams,t),i||this.redraw(),this}});sn.WMS=an,rn.wms=function(t,i){return new an(t,i)};var hn=Me.extend({options:{padding:.1,tolerance:0},initialize:function(t){c(this,t),m(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),this._zoomAnimated&&ci(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var t={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(t.zoomanim=this._onAnimZoom),t},_onAnimZoom:function(t){this._updateTransform(t.center,t.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(t,i){var e=this._map.getZoomScale(i,this._zoom),n=yi(this._container),o=this._map.getSize().multiplyBy(.5+this.options.padding),s=this._map.project(this._center,i),r=this._map.project(t,i).subtract(s),a=o.multiplyBy(-e).add(n).add(o).subtract(r);vt?gi(this._container,a,e):vi(this._container,a)},_reset:function(){for(var t in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[t]._reset()},_onZoomEnd:function(){for(var t in this._layers)this._layers[t]._project()},_updatePaths:function(){for(var t in this._layers)this._layers[t]._update()},_update:function(){var t=this.options.padding,i=this._map.getSize(),e=this._map.containerPointToLayerPoint(i.multiplyBy(-t)).round();this._bounds=new I(e,e.add(i.multiplyBy(1+2*t)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),un=hn.extend({getEvents:function(){var t=hn.prototype.getEvents.call(this);return t.viewprereset=this._onViewPreReset,t},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){hn.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=document.createElement("canvas");zi(t,"mousemove",this._onMouseMove,this),zi(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this),zi(t,"mouseout",this._handleMouseOut,this),this._ctx=t.getContext("2d")},_destroyContainer:function(){z(this._redrawRequest),delete this._ctx,ri(this._container),Si(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){for(var t in this._redrawBounds=null,this._layers)this._layers[t]._update();this._redraw()}},_update:function(){var t,i,e,n;this._map._animatingZoom&&this._bounds||(hn.prototype._update.call(this),t=this._bounds,i=this._container,e=t.getSize(),n=zt?2:1,vi(i,t.min),i.width=n*e.x,i.height=n*e.y,i.style.width=e.x+"px",i.style.height=e.y+"px",zt&&this._ctx.scale(2,2),this._ctx.translate(-t.min.x,-t.min.y),this.fire("update"))},_reset:function(){hn.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(t){this._updateDashArray(t);var i=(this._layers[m(t)]=t)._order={layer:t,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=i),this._drawLast=i,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(t){var i=t._order,e=i.next,n=i.prev;e?e.prev=n:this._drawLast=n,n?n.next=e:this._drawFirst=e,delete t._order,delete this._layers[m(t)],this._requestRedraw(t)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(t){if("string"==typeof t.options.dashArray){for(var i,e=t.options.dashArray.split(/[, ]+/),n=[],o=0;o<e.length;o++){if(i=Number(e[o]),isNaN(i))return;n.push(i)}t.options._dashArray=n}else t.options._dashArray=t.options.dashArray},_requestRedraw:function(t){this._map&&(this._extendRedrawBounds(t),this._redrawRequest=this._redrawRequest||M(this._redraw,this))},_extendRedrawBounds:function(t){var i;t._pxBounds&&(i=(t.options.weight||0)+1,this._redrawBounds=this._redrawBounds||new I,this._redrawBounds.extend(t._pxBounds.min.subtract([i,i])),this._redrawBounds.extend(t._pxBounds.max.add([i,i])))},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var t,i=this._redrawBounds;i?(t=i.getSize(),this._ctx.clearRect(i.min.x,i.min.y,t.x,t.y)):(this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore())},_draw:function(){var t,i,e=this._redrawBounds;this._ctx.save(),e&&(i=e.getSize(),this._ctx.beginPath(),this._ctx.rect(e.min.x,e.min.y,i.x,i.y),this._ctx.clip()),this._drawing=!0;for(var n=this._drawFirst;n;n=n.next)t=n.layer,(!e||t._pxBounds&&t._pxBounds.intersects(e))&&t._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(t,i){if(this._drawing){var e,n,o,s,r=t._parts,a=r.length,h=this._ctx;if(a){for(h.beginPath(),e=0;e<a;e++){for(n=0,o=r[e].length;n<o;n++)s=r[e][n],h[n?"lineTo":"moveTo"](s.x,s.y);i&&h.closePath()}this._fillStroke(h,t)}}},_updateCircle:function(t){var i,e,n,o;this._drawing&&!t._empty()&&(i=t._point,e=this._ctx,n=Math.max(Math.round(t._radius),1),1!=(o=(Math.max(Math.round(t._radiusY),1)||n)/n)&&(e.save(),e.scale(1,o)),e.beginPath(),e.arc(i.x,i.y/o,n,0,2*Math.PI,!1),1!=o&&e.restore(),this._fillStroke(e,t))},_fillStroke:function(t,i){var e=i.options;e.fill&&(t.globalAlpha=e.fillOpacity,t.fillStyle=e.fillColor||e.color,t.fill(e.fillRule||"evenodd")),e.stroke&&0!==e.weight&&(t.setLineDash&&t.setLineDash(i.options&&i.options._dashArray||[]),t.globalAlpha=e.opacity,t.lineWidth=e.weight,t.strokeStyle=e.color,t.lineCap=e.lineCap,t.lineJoin=e.lineJoin,t.stroke())},_onClick:function(t){for(var i,e,n=this._map.mouseEventToLayerPoint(t),o=this._drawFirst;o;o=o.next)(i=o.layer).options.interactive&&i._containsPoint(n)&&(("click"===t.type||"preclick"!==t.type)&&this._map._draggableMoved(i)||(e=i));e&&(Fi(t),this._fireEvent([e],t))},_onMouseMove:function(t){var i;!this._map||this._map.dragging.moving()||this._map._animatingZoom||(i=this._map.mouseEventToLayerPoint(t),this._handleMouseHover(t,i))},_handleMouseOut:function(t){var i=this._hoveredLayer;i&&(_i(this._container,"leaflet-interactive"),this._fireEvent([i],t,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(t,i){if(!this._mouseHoverThrottled){for(var e,n,o=this._drawFirst;o;o=o.next)(e=o.layer).options.interactive&&e._containsPoint(i)&&(n=e);n!==this._hoveredLayer&&(this._handleMouseOut(t),n&&(ci(this._container,"leaflet-interactive"),this._fireEvent([n],t,"mouseover"),this._hoveredLayer=n)),this._hoveredLayer&&this._fireEvent([this._hoveredLayer],t),this._mouseHoverThrottled=!0,setTimeout(p(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(t,i,e){this._map._fireDOMEvent(i,e||i.type,t)},_bringToFront:function(t){var i,e,n=t._order;n&&(i=n.next,e=n.prev,i&&((i.prev=e)?e.next=i:i&&(this._drawFirst=i),n.prev=this._drawLast,(this._drawLast.next=n).next=null,this._drawLast=n,this._requestRedraw(t)))},_bringToBack:function(t){var i,e,n=t._order;n&&(i=n.next,(e=n.prev)&&((e.next=i)?i.prev=e:e&&(this._drawLast=e),n.prev=null,n.next=this._drawFirst,this._drawFirst.prev=n,this._drawFirst=n,this._requestRedraw(t)))}});function ln(t){return St?new un(t):null}var cn=function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(t){return document.createElement("<lvml:"+t+' class="lvml">')}}catch(t){return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_n={_initContainer:function(){this._container=si("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(hn.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var i=t._container=cn("shape");ci(i,"leaflet-vml-shape "+(this.options.className||"")),i.coordsize="1 1",t._path=cn("path"),i.appendChild(t._path),this._updateStyle(t),this._layers[m(t)]=t},_addPath:function(t){var i=t._container;this._container.appendChild(i),t.options.interactive&&t.addInteractiveTarget(i)},_removePath:function(t){var i=t._container;ri(i),t.removeInteractiveTarget(i),delete this._layers[m(t)]},_updateStyle:function(t){var i=t._stroke,e=t._fill,n=t.options,o=t._container;o.stroked=!!n.stroke,o.filled=!!n.fill,n.stroke?(i=i||(t._stroke=cn("stroke")),o.appendChild(i),i.weight=n.weight+"px",i.color=n.color,i.opacity=n.opacity,n.dashArray?i.dashStyle=g(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):i.dashStyle="",i.endcap=n.lineCap.replace("butt","flat"),i.joinstyle=n.lineJoin):i&&(o.removeChild(i),t._stroke=null),n.fill?(e=e||(t._fill=cn("fill")),o.appendChild(e),e.color=n.fillColor||n.color,e.opacity=n.fillOpacity):e&&(o.removeChild(e),t._fill=null)},_updateCircle:function(t){var i=t._point.round(),e=Math.round(t._radius),n=Math.round(t._radiusY||e);this._setPath(t,t._empty()?"M0 0":"AL "+i.x+","+i.y+" "+e+","+n+" 0,23592600")},_setPath:function(t,i){t._path.v=i},_bringToFront:function(t){hi(t._container)},_bringToBack:function(t){ui(t._container)}},dn=Et?cn:J,pn=hn.extend({getEvents:function(){var t=hn.prototype.getEvents.call(this);return t.zoomstart=this._onZoomStart,t},_initContainer:function(){this._container=dn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=dn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ri(this._container),Si(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_onZoomStart:function(){this._update()},_update:function(){var t,i,e;this._map._animatingZoom&&this._bounds||(hn.prototype._update.call(this),i=(t=this._bounds).getSize(),e=this._container,this._svgSize&&this._svgSize.equals(i)||(this._svgSize=i,e.setAttribute("width",i.x),e.setAttribute("height",i.y)),vi(e,t.min),e.setAttribute("viewBox",[t.min.x,t.min.y,i.x,i.y].join(" ")),this.fire("update"))},_initPath:function(t){var i=t._path=dn("path");t.options.className&&ci(i,t.options.className),t.options.interactive&&ci(i,"leaflet-interactive"),this._updateStyle(t),this._layers[m(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){ri(t._path),t.removeInteractiveTarget(t._path),delete this._layers[m(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var i=t._path,e=t.options;i&&(e.stroke?(i.setAttribute("stroke",e.color),i.setAttribute("stroke-opacity",e.opacity),i.setAttribute("stroke-width",e.weight),i.setAttribute("stroke-linecap",e.lineCap),i.setAttribute("stroke-linejoin",e.lineJoin),e.dashArray?i.setAttribute("stroke-dasharray",e.dashArray):i.removeAttribute("stroke-dasharray"),e.dashOffset?i.setAttribute("stroke-dashoffset",e.dashOffset):i.removeAttribute("stroke-dashoffset")):i.setAttribute("stroke","none"),e.fill?(i.setAttribute("fill",e.fillColor||e.color),i.setAttribute("fill-opacity",e.fillOpacity),i.setAttribute("fill-rule",e.fillRule||"evenodd")):i.setAttribute("fill","none"))},_updatePoly:function(t,i){this._setPath(t,$(t._parts,i))},_updateCircle:function(t){var i=t._point,e=Math.max(Math.round(t._radius),1),n="a"+e+","+(Math.max(Math.round(t._radiusY),1)||e)+" 0 1,0 ",o=t._empty()?"M0 0":"M"+(i.x-e)+","+i.y+n+2*e+",0 "+n+2*-e+",0 ";this._setPath(t,o)},_setPath:function(t,i){t._path.setAttribute("d",i)},_bringToFront:function(t){hi(t._path)},_bringToBack:function(t){ui(t._path)}});function mn(t){return Zt||Et?new pn(t):null}Et&&pn.include(_n),Ki.include({getRenderer:function(t){var i=(i=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer)||(this._renderer=this._createRenderer());return this.hasLayer(i)||this.addLayer(i),i},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var i=this._paneRenderers[t];return void 0===i&&(i=this._createRenderer({pane:t}),this._paneRenderers[t]=i),i},_createRenderer:function(t){return this.options.preferCanvas&&ln(t)||mn(t)}});var fn=Re.extend({initialize:function(t,i){Re.prototype.initialize.call(this,this._boundsToLatLngs(t),i)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=N(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});pn.create=dn,pn.pointsToPath=$,Ne.geometryToLayer=De,Ne.coordsToLatLng=We,Ne.coordsToLatLngs=He,Ne.latLngToCoords=Fe,Ne.latLngsToCoords=Ue,Ne.getFeature=Ve,Ne.asFeature=qe,Ki.mergeOptions({boxZoom:!0});var gn=ie.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){zi(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Si(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ri(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),Xt(),xi(),this._startPoint=this._map.mouseEventToContainerPoint(t),zi(document,{contextmenu:Ni,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=si("div","leaflet-zoom-box",this._container),ci(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var i=new I(this._point,this._startPoint),e=i.getSize();vi(this._box,i.min),this._box.style.width=e.x+"px",this._box.style.height=e.y+"px"},_finish:function(){this._moved&&(ri(this._box),_i(this._container,"leaflet-crosshair")),Jt(),wi(),Si(document,{contextmenu:Ni,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){var i;1!==t.which&&1!==t.button||(this._finish(),this._moved&&(this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(p(this._resetState,this),0),i=new R(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point)),this._map.fitBounds(i).fire("boxzoomend",{boxZoomBounds:i})))},_onKeyDown:function(t){27===t.keyCode&&this._finish()}});Ki.addInitHook("addHandler","boxZoom",gn),Ki.mergeOptions({doubleClickZoom:!0});var vn=ie.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var i=this._map,e=i.getZoom(),n=i.options.zoomDelta,o=t.originalEvent.shiftKey?e-n:e+n;"center"===i.options.doubleClickZoom?i.setZoom(o):i.setZoomAround(t.containerPoint,o)}});Ki.addInitHook("addHandler","doubleClickZoom",vn),Ki.mergeOptions({dragging:!0,inertia:!st,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var yn=ie.extend({addHooks:function(){var t;this._draggable||(t=this._map,this._draggable=new ae(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))),ci(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){_i(this._map._container,"leaflet-grab"),_i(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t,i=this._map;i._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity?(t=N(this._map.options.maxBounds),this._offsetLimit=O(this._map.latLngToContainerPoint(t.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(t.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))):this._offsetLimit=null,i.fire("movestart").fire("dragstart"),i.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){var i,e;this._map.options.inertia&&(i=this._lastTime=+new Date,e=this._lastPos=this._draggable._absPos||this._draggable._newPos,this._positions.push(e),this._times.push(i),this._prunePositions(i)),this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;1<this._positions.length&&50<t-this._times[0];)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var t=this._map.getSize().divideBy(2),i=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=i.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(t,i){return t-(t-i)*this._viscosity},_onPreDragLimit:function(){var t,i;this._viscosity&&this._offsetLimit&&(t=this._draggable._newPos.subtract(this._draggable._startPos),i=this._offsetLimit,t.x<i.min.x&&(t.x=this._viscousLimit(t.x,i.min.x)),t.y<i.min.y&&(t.y=this._viscousLimit(t.y,i.min.y)),t.x>i.max.x&&(t.x=this._viscousLimit(t.x,i.max.x)),t.y>i.max.y&&(t.y=this._viscousLimit(t.y,i.max.y)),this._draggable._newPos=this._draggable._startPos.add(t))},_onPreDragWrap:function(){var t=this._worldWidth,i=Math.round(t/2),e=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-i+e)%t+i-e,s=(n+i+e)%t-i-e,r=Math.abs(o+e)<Math.abs(s+e)?o:s;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=r},_onDragEnd:function(t){var i,e,n,o,s,r,a,h,u,l=this._map,c=l.options,_=!c.inertia||this._times.length<2;l.fire("dragend",t),_?l.fire("moveend"):(this._prunePositions(+new Date),i=this._lastPos.subtract(this._positions[0]),e=(this._lastTime-this._times[0])/1e3,n=c.easeLinearity,s=(o=i.multiplyBy(n/e)).distanceTo([0,0]),r=Math.min(c.inertiaMaxSpeed,s),a=o.multiplyBy(r/s),h=r/(c.inertiaDeceleration*n),(u=a.multiplyBy(-h/2).round()).x||u.y?(u=l._limitOffset(u,l.options.maxBounds),M(function(){l.panBy(u,{duration:h,easeLinearity:n,noMoveStart:!0,animate:!0})})):l.fire("moveend"))}});Ki.addInitHook("addHandler","dragging",yn),Ki.mergeOptions({keyboard:!0,keyboardPanDelta:80});var xn=ie.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(t){this._map=t,this._setPanDelta(t.options.keyboardPanDelta),this._setZoomDelta(t.options.zoomDelta)},addHooks:function(){var t=this._map._container;t.tabIndex<=0&&(t.tabIndex="0"),zi(t,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),Si(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){var t,i,e,n;this._focused||(t=document.body,i=document.documentElement,e=t.scrollTop||i.scrollTop,n=t.scrollLeft||i.scrollLeft,this._map._container.focus(),window.scrollTo(n,e))},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(t){for(var i=this._panKeys={},e=this.keyCodes,n=0,o=e.left.length;n<o;n++)i[e.left[n]]=[-1*t,0];for(n=0,o=e.right.length;n<o;n++)i[e.right[n]]=[t,0];for(n=0,o=e.down.length;n<o;n++)i[e.down[n]]=[0,t];for(n=0,o=e.up.length;n<o;n++)i[e.up[n]]=[0,-1*t]},_setZoomDelta:function(t){for(var i=this._zoomKeys={},e=this.keyCodes,n=0,o=e.zoomIn.length;n<o;n++)i[e.zoomIn[n]]=t;for(n=0,o=e.zoomOut.length;n<o;n++)i[e.zoomOut[n]]=-t},_addHooks:function(){zi(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){Si(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(t){if(!(t.altKey||t.ctrlKey||t.metaKey)){var i,e=t.keyCode,n=this._map;if(e in this._panKeys)n._panAnim&&n._panAnim._inProgress||(i=this._panKeys[e],t.shiftKey&&(i=A(i).multiplyBy(3)),n.panBy(i),n.options.maxBounds&&n.panInsideBounds(n.options.maxBounds));else if(e in this._zoomKeys)n.setZoom(n.getZoom()+(t.shiftKey?3:1)*this._zoomKeys[e]);else{if(27!==e||!n._popup||!n._popup.options.closeOnEscapeKey)return;n.closePopup()}Ni(t)}}});Ki.addInitHook("addHandler","keyboard",xn),Ki.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var wn=ie.extend({addHooks:function(){zi(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){Si(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(t){var i=Wi(t),e=this._map.options.wheelDebounceTime;this._delta+=i,this._lastMousePos=this._map.mouseEventToContainerPoint(t),this._startTime||(this._startTime=+new Date);var n=Math.max(e-(new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(p(this._performZoom,this),n),Ni(t)},_performZoom:function(){var t=this._map,i=t.getZoom(),e=this._map.options.zoomSnap||0;t._stop();var n=this._delta/(4*this._map.options.wheelPxPerZoomLevel),o=4*Math.log(2/(1+Math.exp(-Math.abs(n))))/Math.LN2,s=e?Math.ceil(o/e)*e:o,r=t._limitZoom(i+(0<this._delta?s:-s))-i;this._delta=0,this._startTime=null,r&&("center"===t.options.scrollWheelZoom?t.setZoom(i+r):t.setZoomAround(this._lastMousePos,i+r))}});Ki.addInitHook("addHandler","scrollWheelZoom",wn),Ki.mergeOptions({tap:!0,tapTolerance:15});var Pn=ie.extend({addHooks:function(){zi(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Si(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(t.touches){if(Ri(t),this._fireClick=!0,1<t.touches.length)return this._fireClick=!1,void clearTimeout(this._holdTimeout);var i=t.touches[0],e=i.target;this._startPos=this._newPos=new k(i.clientX,i.clientY),e.tagName&&"a"===e.tagName.toLowerCase()&&ci(e,"leaflet-active"),this._holdTimeout=setTimeout(p(function(){this._isTapValid()&&(this._fireClick=!1,this._onUp(),this._simulateEvent("contextmenu",i))},this),1e3),this._simulateEvent("mousedown",i),zi(document,{touchmove:this._onMove,touchend:this._onUp},this)}},_onUp:function(t){var i,e;clearTimeout(this._holdTimeout),Si(document,{touchmove:this._onMove,touchend:this._onUp},this),this._fireClick&&t&&t.changedTouches&&((e=(i=t.changedTouches[0]).target)&&e.tagName&&"a"===e.tagName.toLowerCase()&&_i(e,"leaflet-active"),this._simulateEvent("mouseup",i),this._isTapValid()&&this._simulateEvent("click",i))},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_onMove:function(t){var i=t.touches[0];this._newPos=new k(i.clientX,i.clientY),this._simulateEvent("mousemove",i)},_simulateEvent:function(t,i){var e=document.createEvent("MouseEvents");e._simulated=!0,i.target._simulatedClick=!0,e.initMouseEvent(t,!0,!0,window,1,i.screenX,i.screenY,i.clientX,i.clientY,!1,!1,!1,!1,0,null),i.target.dispatchEvent(e)}});!bt||Lt&&!ct||Ki.addInitHook("addHandler","tap",Pn),Ki.mergeOptions({touchZoom:bt&&!st,bounceAtZoomLimits:!0});var Ln=ie.extend({addHooks:function(){ci(this._map._container,"leaflet-touch-zoom"),zi(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){_i(this._map._container,"leaflet-touch-zoom"),Si(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var i,e,n=this._map;!t.touches||2!==t.touches.length||n._animatingZoom||this._zooming||(i=n.mouseEventToContainerPoint(t.touches[0]),e=n.mouseEventToContainerPoint(t.touches[1]),this._centerPoint=n.getSize()._divideBy(2),this._startLatLng=n.containerPointToLatLng(this._centerPoint),"center"!==n.options.touchZoom&&(this._pinchStartLatLng=n.containerPointToLatLng(i.add(e)._divideBy(2))),this._startDist=i.distanceTo(e),this._startZoom=n.getZoom(),this._moved=!1,this._zooming=!0,n._stop(),zi(document,"touchmove",this._onTouchMove,this),zi(document,"touchend",this._onTouchEnd,this),Ri(t))},_onTouchMove:function(t){if(t.touches&&2===t.touches.length&&this._zooming){var i=this._map,e=i.mouseEventToContainerPoint(t.touches[0]),n=i.mouseEventToContainerPoint(t.touches[1]),o=e.distanceTo(n)/this._startDist;if(this._zoom=i.getScaleZoom(o,this._startZoom),!i.options.bounceAtZoomLimits&&(this._zoom<i.getMinZoom()&&o<1||this._zoom>i.getMaxZoom()&&1<o)&&(this._zoom=i._limitZoom(this._zoom)),"center"===i.options.touchZoom){if(this._center=this._startLatLng,1==o)return}else{var s=e._add(n)._divideBy(2)._subtract(this._centerPoint);if(1==o&&0===s.x&&0===s.y)return;this._center=i.unproject(i.project(this._pinchStartLatLng,this._zoom).subtract(s),this._zoom)}this._moved||(i._moveStart(!0,!1),this._moved=!0),z(this._animRequest);var r=p(i._move,i,this._center,this._zoom,{pinch:!0,round:!1});this._animRequest=M(r,this,!0),Ri(t)}},_onTouchEnd:function(){this._moved&&this._zooming?(this._zooming=!1,z(this._animRequest),Si(document,"touchmove",this._onTouchMove,this),Si(document,"touchend",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))):this._zooming=!1}});Ki.addInitHook("addHandler","touchZoom",Ln),Ki.BoxZoom=gn,Ki.DoubleClickZoom=vn,Ki.Drag=yn,Ki.Keyboard=xn,Ki.ScrollWheelZoom=wn,Ki.Tap=Pn,Ki.TouchZoom=Ln,t.version="1.7.1",t.Control=Xi,t.control=Yi,t.Browser=Bt,t.Evented=E,t.Mixin=ne,t.Util=C,t.Class=S,t.Handler=ie,t.extend=h,t.bind=p,t.stamp=m,t.setOptions=c,t.DomEvent=qi,t.DomUtil=Mi,t.PosAnimation=Gi,t.Draggable=ae,t.LineUtil=fe,t.PolyUtil=ye,t.Point=k,t.point=A,t.Bounds=I,t.bounds=O,t.Transformation=q,t.transformation=G,t.Projection=Pe,t.LatLng=D,t.latLng=j,t.LatLngBounds=R,t.latLngBounds=N,t.CRS=H,t.GeoJSON=Ne,t.geoJSON=Ke,t.geoJson=Ye,t.Layer=Me,t.LayerGroup=ze,t.layerGroup=function(t,i){return new ze(t,i)},t.FeatureGroup=Ce,t.featureGroup=function(t,i){return new Ce(t,i)},t.ImageOverlay=Xe,t.imageOverlay=function(t,i,e){return new Xe(t,i,e)},t.VideoOverlay=Je,t.videoOverlay=function(t,i,e){return new Je(t,i,e)},t.SVGOverlay=$e,t.svgOverlay=function(t,i,e){return new $e(t,i,e)},t.DivOverlay=Qe,t.Popup=tn,t.popup=function(t,i){return new tn(t,i)},t.Tooltip=en,t.tooltip=function(t,i){return new en(t,i)},t.Icon=Se,t.icon=function(t){return new Se(t)},t.DivIcon=nn,t.divIcon=function(t){return new nn(t)},t.Marker=ke,t.marker=function(t,i){return new ke(t,i)},t.TileLayer=sn,t.tileLayer=rn,t.GridLayer=on,t.gridLayer=function(t){return new on(t)},t.SVG=pn,t.svg=mn,t.Renderer=hn,t.Canvas=un,t.canvas=ln,t.Path=Be,t.CircleMarker=Ae,t.circleMarker=function(t,i){return new Ae(t,i)},t.Circle=Ie,t.circle=function(t,i,e){return new Ie(t,i,e)},t.Polyline=Oe,t.polyline=function(t,i){return new Oe(t,i)},t.Polygon=Re,t.polygon=function(t,i){return new Re(t,i)},t.Rectangle=fn,t.rectangle=function(t,i){return new fn(t,i)},t.Map=Ki,t.map=function(t,i){return new Ki(t,i)};var bn=window.L;t.noConflict=function(){return window.L=bn,this},window.L=t});
6
  //# sourceMappingURL=leaflet.js.map
assets/js/sportspress.js CHANGED
@@ -1,119 +1,138 @@
1
  function sp_viewport() {
2
- var e = window, a = 'inner';
3
- if (!('innerWidth' in window )) {
4
- a = 'client';
5
- e = document.documentElement || document.body;
6
- }
7
- return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
8
  }
9
 
10
  (function($) {
11
 
12
  /* Header */
13
- if ( ! $('.sp-header').length ) {
14
- $('body').prepend( '<div class="sp-header sp-header-loaded"></div>' );
15
  }
16
 
17
  /* Countdown */
18
- $("[data-countdown]").each(function() {
19
- var $this = $(this);
20
- // Get countdown time
21
- var countDownDate = new Date($(this).data('countdown')).getTime();
22
- // Iterate every second
23
- var x = setInterval(function() {
24
-
25
- // Get todays date and time
26
- var now = new Date();
27
-
28
- // Convert curent date and time to UTC
29
- var tzDifference = now.getTimezoneOffset();
30
- var nowutc = new Date(now.getTime() + tzDifference * 60 * 1000);
31
-
32
- // Find the distance between now and the count down date
33
- var distance = countDownDate - nowutc;
34
- if ( distance < 0 ) {
35
- distance = 0;
36
- }
37
-
38
- // Time calculations for days, hours, minutes and seconds
39
- var days = Math.floor(distance / (1000 * 60 * 60 * 24));
40
- var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
41
- var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
42
- var seconds = Math.floor((distance % (1000 * 60)) / 1000);
43
-
44
- // Output the result
45
- $this.html("<span>"+(days < 10 ? '0' + days : days)+" <small>" + localized_strings.days + "</small></span> "
46
- + "<span>"+('0' + hours).slice(-2)+" <small>" + localized_strings.hrs + "</small></span> "
47
- + "<span>"+('0' + minutes).slice(-2)+" <small>" + localized_strings.mins + "</small></span> "
48
- + "<span>"+('0' + seconds).slice(-2)+" <small>" + localized_strings.secs + "</small></span>" );
49
- }, 1000);
50
- });
 
 
 
 
 
 
 
51
 
52
  /* Scrollable Tables */
53
- $(".sp-scrollable-table").wrap("<div class=\"sp-scrollable-table-wrapper\"></div>");
54
-
55
  /* Selector Redirect */
56
- $(".sp-selector-redirect").change(function() {
57
- window.location = $(this).val();
58
- });
 
 
59
 
60
  /* Template Tabs */
61
- $(".sp-tab-menu-item a").click(function() {
62
- $template = $(this).data("sp-tab");
63
- $(this).closest(".sp-tab-menu-item").addClass("sp-tab-menu-item-active").siblings(".sp-tab-menu-item").removeClass("sp-tab-menu-item-active");
64
- $(this).closest(".sp-tab-group").find(".sp-tab-content-"+$template).show().siblings(".sp-tab-content").hide();
65
- return false;
66
- });
 
 
67
 
68
  /* API method to get paging information */
69
  $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
70
  {
71
- return {
72
- "iStart": oSettings._iDisplayStart,
73
- "iEnd": oSettings.fnDisplayEnd(),
74
- "iLength": oSettings._iDisplayLength,
75
- "iTotal": oSettings.fnRecordsTotal(),
76
- "iFilteredTotal": oSettings.fnRecordsDisplay(),
77
- "iPage": oSettings._iDisplayLength === -1 ?
78
- 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
79
- "iTotalPages": oSettings._iDisplayLength === -1 ?
80
- 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
81
- };
82
  }
83
 
84
  /* Data Tables */
85
- $(".sp-data-table").each(function() {
86
- sortable = $(this).hasClass("sp-sortable-table");
87
- paginated = $(this).hasClass("sp-paginated-table");
88
- display_length = parseInt($(this).attr("data-sp-rows"));
89
- if ( display_length == undefined || isNaN( display_length ) ) display_length = 10;
90
- if ( $(this).find("tbody tr").length <= display_length ) paginated = false;
91
- if ( sortable || paginated ) {
92
- $(this).dataTable({
93
- "order": [],
94
- "autoWidth": false,
95
- "searching": false,
96
- "info": false,
97
- "paging": paginated,
98
- "lengthChange": false,
99
- "pagingType": "simple_numbers",
100
- "pageLength": display_length,
101
- "ordering": sortable,
102
- "language": {
103
- "aria": {
104
- "sortAscending": "",
105
- "sortDescending": ""
106
- },
107
- "paginate": {
108
- "previous": localized_strings.previous,
109
- "next": localized_strings.next,
110
- }
111
- },
112
- "columnDefs": [
113
- { "type": "num-fmt", "targets": [ ".data-number", ".data-rank" ] },
114
- ]
115
- });
 
 
 
 
 
 
 
 
116
  }
117
- });
118
 
119
- })(jQuery);
1
  function sp_viewport() {
2
+ var e = window, a = 'inner';
3
+ if ( ! ('innerWidth' in window )) {
4
+ a = 'client';
5
+ e = document.documentElement || document.body;
6
+ }
7
+ return { width : e[ a + 'Width' ] , height : e[ a + 'Height' ] };
8
  }
9
 
10
  (function($) {
11
 
12
  /* Header */
13
+ if ( ! $( '.sp-header' ).length ) {
14
+ $( 'body' ).prepend( '<div class="sp-header sp-header-loaded"></div>' );
15
  }
16
 
17
  /* Countdown */
18
+ $( "[data-countdown]" ).each(
19
+ function() {
20
+ var $this = $( this );
21
+ // Get countdown time
22
+ var countDownDate = new Date( $( this ).data( 'countdown' ) ).getTime();
23
+ // Iterate every second
24
+ var x = setInterval(
25
+ function() {
26
+
27
+ // Get todays date and time
28
+ var now = new Date();
29
+
30
+ // Convert curent date and time to UTC
31
+ var tzDifference = now.getTimezoneOffset();
32
+ var nowutc = new Date( now.getTime() + tzDifference * 60 * 1000 );
33
+
34
+ // Find the distance between now and the count down date
35
+ var distance = countDownDate - nowutc;
36
+ if ( distance < 0 ) {
37
+ distance = 0;
38
+ }
39
+
40
+ // Time calculations for days, hours, minutes and seconds
41
+ var days = Math.floor( distance / (1000 * 60 * 60 * 24) );
42
+ var hours = Math.floor( (distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) );
43
+ var minutes = Math.floor( (distance % (1000 * 60 * 60)) / (1000 * 60) );
44
+ var seconds = Math.floor( (distance % (1000 * 60)) / 1000 );
45
+
46
+ // Output the result
47
+ $this.html(
48
+ "<span>" + (days < 10 ? '0' + days : days) + " <small>" + localized_strings.days + "</small></span> "
49
+ + "<span>" + ('0' + hours).slice( -2 ) + " <small>" + localized_strings.hrs + "</small></span> "
50
+ + "<span>" + ('0' + minutes).slice( -2 ) + " <small>" + localized_strings.mins + "</small></span> "
51
+ + "<span>" + ('0' + seconds).slice( -2 ) + " <small>" + localized_strings.secs + "</small></span>"
52
+ );
53
+ },
54
+ 1000
55
+ );
56
+ }
57
+ );
58
 
59
  /* Scrollable Tables */
60
+ $( ".sp-scrollable-table" ).wrap( "<div class=\"sp-scrollable-table-wrapper\"></div>" );
61
+
62
  /* Selector Redirect */
63
+ $( ".sp-selector-redirect" ).change(
64
+ function() {
65
+ window.location = $( this ).val();
66
+ }
67
+ );
68
 
69
  /* Template Tabs */
70
+ $( ".sp-tab-menu-item a" ).click(
71
+ function() {
72
+ $template = $( this ).data( "sp-tab" );
73
+ $( this ).closest( ".sp-tab-menu-item" ).addClass( "sp-tab-menu-item-active" ).siblings( ".sp-tab-menu-item" ).removeClass( "sp-tab-menu-item-active" );
74
+ $( this ).closest( ".sp-tab-group" ).find( ".sp-tab-content-" + $template ).show().siblings( ".sp-tab-content" ).hide();
75
+ return false;
76
+ }
77
+ );
78
 
79
  /* API method to get paging information */
80
  $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
81
  {
82
+ return {
83
+ "iStart": oSettings._iDisplayStart,
84
+ "iEnd": oSettings.fnDisplayEnd(),
85
+ "iLength": oSettings._iDisplayLength,
86
+ "iTotal": oSettings.fnRecordsTotal(),
87
+ "iFilteredTotal": oSettings.fnRecordsDisplay(),
88
+ "iPage": oSettings._iDisplayLength === -1 ?
89
+ 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
90
+ "iTotalPages": oSettings._iDisplayLength === -1 ?
91
+ 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
92
+ };
93
  }
94
 
95
  /* Data Tables */
96
+ $( ".sp-data-table" ).each(
97
+ function() {
98
+ sortable = $( this ).hasClass( "sp-sortable-table" );
99
+ paginated = $( this ).hasClass( "sp-paginated-table" );
100
+ display_length = parseInt( $( this ).attr( "data-sp-rows" ) );
101
+ if ( display_length == undefined || isNaN( display_length ) ) {
102
+ display_length = 10;
103
+ }
104
+ if ( $( this ).find( "tbody tr" ).length <= display_length ) {
105
+ paginated = false;
106
+ }
107
+ if ( sortable || paginated ) {
108
+ $( this ).dataTable(
109
+ {
110
+ "order": [],
111
+ "autoWidth": false,
112
+ "searching": false,
113
+ "info": false,
114
+ "paging": paginated,
115
+ "lengthChange": false,
116
+ "pagingType": "simple_numbers",
117
+ "pageLength": display_length,
118
+ "ordering": sortable,
119
+ "language": {
120
+ "aria": {
121
+ "sortAscending": "",
122
+ "sortDescending": ""
123
+ },
124
+ "paginate": {
125
+ "previous": localized_strings.previous,
126
+ "next": localized_strings.next,
127
+ }
128
+ },
129
+ "columnDefs": [
130
+ { "type": "num-fmt", "targets": [ ".data-number", ".data-rank" ] },
131
+ ]
132
+ }
133
+ );
134
+ }
135
  }
136
+ );
137
 
138
+ })( jQuery );
changelog.txt CHANGED
@@ -1,5 +1,22 @@
1
  == SportsPress Changelog ==
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  = 2.7.8 =
4
  * Fix - Event results, box scores, and players stats not updating via REST API.
5
 
1
  == SportsPress Changelog ==
2
 
3
+ = 2.7.9 =
4
+ * Tweak - Add support for event format in REST API.
5
+ * Tweak - Add "Order" and "Order by" selection fields for countdown widget.
6
+ * Tweak - Add option to display event status in countdown widget.
7
+ * Tweak - Add ability to filter events by format in calendar template.
8
+ * Tweak - Update TGM plugin activation library.
9
+ * Fix - Remove plugin headers from modules for improved compatibility.
10
+ * Fix - Reverse order not applying to teams in event lists.
11
+ * Fix - Add validation to user inputs for improved security.
12
+ * Fix - Sanitize all user inputs for improved security.
13
+ * Fix - Escape all outputs in admin for improved security.
14
+ * Fix - Filtering based on format for event blocks.
15
+ * Fix - Last week and next week filter not applying to player lists.
16
+ * Fix - Deselecting a selected team in settings.
17
+ * Fix - PHP 8.0 deprecated warnings.
18
+ * Localization - Add nationalities and flags for French Guiana, French Polynesia, Guadeloupe, Greenland, Martinique, Reunion, and Sint Maarten.
19
+
20
  = 2.7.8 =
21
  * Fix - Event results, box scores, and players stats not updating via REST API.
22
 
feeds/ical.php CHANGED
@@ -2,21 +2,23 @@
2
  /**
3
  * iCal Feed
4
  *
5
- * @author ThemeBoy
6
- * @category Feeds
7
- * @package SportsPress/Feeds
8
  * @version 2.7.5
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( 'sp_calendar' !== get_post_type( $post ) ) {
14
- wp_die( __( 'ERROR: This is not a valid feed template.', 'sportspress' ), '', array( 'response' => 404 ) );
15
  }
16
 
17
  // Get events in calendar
18
  $calendar = new SP_Calendar( $post );
19
- $events = $calendar->data();
20
 
21
  // Get blog locale
22
  $locale = substr( get_locale(), 0, 2 );
@@ -29,41 +31,43 @@ $timezone = sanitize_option( 'timezone_string', get_option( 'timezone_string' )
29
 
30
  // Get the URL
31
  $url = add_query_arg( 'feed', 'sp-ical', get_post_permalink( $post ) );
32
- $url = wordwrap( $url , 60, "\r\n\t", true );
33
 
34
  $output =
35
  "BEGIN:VCALENDAR\r\n" .
36
  "VERSION:2.0\r\n" .
37
- "PRODID:-//ThemeBoy//SportsPress//" . strtoupper( $locale ) . "\r\n" .
38
  "CALSCALE:GREGORIAN\r\n" .
39
  "METHOD:PUBLISH\r\n" .
40
- "URL:" . $url . "\r\n" .
41
- "X-FROM-URL:" . $url . "\r\n" .
42
- "NAME:" . $post->post_title . "\r\n" .
43
- "X-WR-CALNAME:" . $post->post_title . "\r\n" .
44
- "DESCRIPTION:" . $post->post_title . "\r\n" .
45
- "X-WR-CALDESC:" . $post->post_title . "\r\n" .
46
  "REFRESH-INTERVAL;VALUE=DURATION:PT2M\r\n" .
47
  "X-PUBLISHED-TTL:PT2M\r\n" .
48
- "TZID:" . $timezone . "\r\n" .
49
- "X-WR-TIMEZONE:" . $timezone . "\r\n";
50
 
51
  // Loop through each event
52
- foreach ( $events as $event):
53
 
54
  // Define date format
55
  $date_format = 'Ymd\THis';
56
 
57
  // Get description
58
- $description = preg_replace( '/([\,;])/','\\\$1', $event->post_content );
59
- $description = wordwrap( $description , 60, "\n\t" );
60
 
61
- // Initialize end time
62
  $end = new DateTime( $event->post_date );
63
 
64
  // Get full time minutes
65
  $minutes = get_post_meta( $event->ID, 'sp_minutes', true );
66
- if ( '' === $minutes ) $minutes = get_option( 'sportspress_event_minutes', 90 );
 
 
67
 
68
  // Add full time minutes to end time
69
  $end->add( new DateInterval( 'PT' . $minutes . 'M' ) );
@@ -74,7 +78,7 @@ foreach ( $events as $event):
74
  // Get venue information
75
  $venues = get_the_terms( $event->ID, 'sp_venue' );
76
  if ( $venues ) {
77
- $venue = reset( $venues );
78
  $location .= $venue->name;
79
 
80
  // Get venue term meta
@@ -84,11 +88,11 @@ foreach ( $events as $event):
84
  // Add details to location
85
  $address = sp_array_value( $meta, 'sp_address', false );
86
  if ( false !== $address ) {
87
- $location = $venue->name . '\, ' . preg_replace('/([\,;])/','\\\$1', $address);
88
  }
89
 
90
  // Generate geo tag
91
- $latitude = sp_array_value( $meta, 'sp_latitude', false );
92
  $longitude = sp_array_value( $meta, 'sp_longitude', false );
93
  if ( false !== $latitude && false !== $longitude ) {
94
  $geo = $latitude . ';' . $longitude;
@@ -96,17 +100,19 @@ foreach ( $events as $event):
96
  $geo = false;
97
  }
98
  }
99
- $location = wordwrap( $location , 60, "\r\n\t" );
100
 
101
  // Get title or write summary based on scores
102
  $results = array();
103
- $teams = (array)get_post_meta( $event->ID, 'sp_team', false );
104
- $teams = array_filter( $teams );
105
- $teams = array_unique( $teams );
106
  if ( ! empty( $teams ) ) {
107
  $event_results = get_post_meta( $event->ID, 'sp_results', true );
108
- foreach( $teams as $team_id ) {
109
- if ( ! $team_id ) continue;
 
 
110
  $team = get_post( $team_id );
111
 
112
  if ( $team ) {
@@ -134,51 +140,57 @@ foreach ( $events as $event):
134
  } else {
135
  $summary = $event->post_title;
136
  }
137
-
138
- //Convert &#[0-9]+ entities to UTF-8
139
- $summary = preg_replace_callback("/(&#[0-9]+;)/", function($m) { return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $summary);
140
-
 
 
 
 
 
 
141
  $summary = apply_filters( 'sportspress_ical_feed_summary', $summary, $event );
142
-
143
  // Append to output string
144
  $output .=
145
  "BEGIN:VEVENT\r\n" .
146
- "SUMMARY:" . preg_replace( '/([\,;])/','\\\$1', $summary ) . "\r\n" .
147
  "UID:$event->ID\r\n" .
148
  "STATUS:CONFIRMED\r\n" .
149
- "DTSTAMP:19700101T000000\r\n".
150
- "DTSTART:" . mysql2date( $date_format, $event->post_date ) . "\r\n" .
151
- "DTEND:" . $end->format( $date_format ) . "\r\n" .
152
- "LAST-MODIFIED:" . mysql2date( $date_format, $event->post_modified_gmt ) . "\r\n";
153
 
154
  if ( $description ) {
155
- $output .= "DESCRIPTION:" . $description . "\r\n";
156
  }
157
 
158
  if ( $location ) {
159
- $output .= "LOCATION:" . $location . "\r\n";
160
  }
161
 
162
  if ( $geo ) {
163
- $output .= "GEO:" . $geo . "\r\n";
164
  }
165
 
166
  $output .= "END:VEVENT\r\n";
167
  endforeach;
168
 
169
  // End output
170
- $output .= "END:VCALENDAR";
171
 
172
  // Print headers
173
- header('Content-type: text/calendar; charset=utf-8');
174
 
175
  // The E-Tag is not being changed when the output file is generated – Some Webdav clients do not like this and
176
  // do not then 'see' that the file has changed – updates to the calendars are then not displayed to the user.
177
  // Props @garygomm https://wordpress.org/support/topic/calendar-feed-issue-not-updating-after-change/
178
- $etag = md5($output);
179
- header('Etag:' . '"'.$etag.'"');
180
 
181
- header('Content-Disposition: inline; filename=' . $post->post_name . '.ics');
182
 
183
  // Print content
184
- echo $output;
2
  /**
3
  * iCal Feed
4
  *
5
+ * @author ThemeBoy
6
+ * @category Feeds
7
+ * @package SportsPress/Feeds
8
  * @version 2.7.5
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( 'sp_calendar' !== get_post_type( $post ) ) {
16
+ wp_die( esc_html__( 'ERROR: This is not a valid feed template.', 'sportspress' ), '', array( 'response' => 404 ) );
17
  }
18
 
19
  // Get events in calendar
20
  $calendar = new SP_Calendar( $post );
21
+ $events = $calendar->data();
22
 
23
  // Get blog locale
24
  $locale = substr( get_locale(), 0, 2 );
31
 
32
  // Get the URL
33
  $url = add_query_arg( 'feed', 'sp-ical', get_post_permalink( $post ) );
34
+ $url = wordwrap( $url, 60, "\r\n\t", true );
35
 
36
  $output =
37
  "BEGIN:VCALENDAR\r\n" .
38
  "VERSION:2.0\r\n" .
39
+ 'PRODID:-//ThemeBoy//SportsPress//' . strtoupper( $locale ) . "\r\n" .
40
  "CALSCALE:GREGORIAN\r\n" .
41
  "METHOD:PUBLISH\r\n" .
42
+ 'URL:' . $url . "\r\n" .
43
+ 'X-FROM-URL:' . $url . "\r\n" .
44
+ 'NAME:' . $post->post_title . "\r\n" .
45
+ 'X-WR-CALNAME:' . $post->post_title . "\r\n" .
46
+ 'DESCRIPTION:' . $post->post_title . "\r\n" .
47
+ 'X-WR-CALDESC:' . $post->post_title . "\r\n" .
48
  "REFRESH-INTERVAL;VALUE=DURATION:PT2M\r\n" .
49
  "X-PUBLISHED-TTL:PT2M\r\n" .
50
+ 'TZID:' . $timezone . "\r\n" .
51
+ 'X-WR-TIMEZONE:' . $timezone . "\r\n";
52
 
53
  // Loop through each event
54
+ foreach ( $events as $event ) :
55
 
56
  // Define date format
57
  $date_format = 'Ymd\THis';
58
 
59
  // Get description
60
+ $description = preg_replace( '/([\,;])/', '\\\$1', $event->post_content );
61
+ $description = wordwrap( $description, 60, "\n\t" );
62
 
63
+ // Initialize end time
64
  $end = new DateTime( $event->post_date );
65
 
66
  // Get full time minutes
67
  $minutes = get_post_meta( $event->ID, 'sp_minutes', true );
68
+ if ( '' === $minutes ) {
69
+ $minutes = get_option( 'sportspress_event_minutes', 90 );
70
+ }
71
 
72
  // Add full time minutes to end time
73
  $end->add( new DateInterval( 'PT' . $minutes . 'M' ) );
78
  // Get venue information
79
  $venues = get_the_terms( $event->ID, 'sp_venue' );
80
  if ( $venues ) {
81
+ $venue = reset( $venues );
82
  $location .= $venue->name;
83
 
84
  // Get venue term meta
88
  // Add details to location
89
  $address = sp_array_value( $meta, 'sp_address', false );
90
  if ( false !== $address ) {
91
+ $location = $venue->name . '\, ' . preg_replace( '/([\,;])/', '\\\$1', $address );
92
  }
93
 
94
  // Generate geo tag
95
+ $latitude = sp_array_value( $meta, 'sp_latitude', false );
96
  $longitude = sp_array_value( $meta, 'sp_longitude', false );
97
  if ( false !== $latitude && false !== $longitude ) {
98
  $geo = $latitude . ';' . $longitude;
100
  $geo = false;
101
  }
102
  }
103
+ $location = wordwrap( $location, 60, "\r\n\t" );
104
 
105
  // Get title or write summary based on scores
106
  $results = array();
107
+ $teams = (array) get_post_meta( $event->ID, 'sp_team', false );
108
+ $teams = array_filter( $teams );
109
+ $teams = array_unique( $teams );
110
  if ( ! empty( $teams ) ) {
111
  $event_results = get_post_meta( $event->ID, 'sp_results', true );
112
+ foreach ( $teams as $team_id ) {
113
+ if ( ! $team_id ) {
114
+ continue;
115
+ }
116
  $team = get_post( $team_id );
117
 
118
  if ( $team ) {
140
  } else {
141
  $summary = $event->post_title;
142
  }
143
+
144
+ // Convert &#[0-9]+ entities to UTF-8
145
+ $summary = preg_replace_callback(
146
+ '/(&#[0-9]+;)/',
147
+ function( $m ) {
148
+ return mb_convert_encoding( $m[1], 'UTF-8', 'HTML-ENTITIES' );
149
+ },
150
+ $summary
151
+ );
152
+
153
  $summary = apply_filters( 'sportspress_ical_feed_summary', $summary, $event );
154
+
155
  // Append to output string
156
  $output .=
157
  "BEGIN:VEVENT\r\n" .
158
+ 'SUMMARY:' . preg_replace( '/([\,;])/', '\\\$1', $summary ) . "\r\n" .
159
  "UID:$event->ID\r\n" .
160
  "STATUS:CONFIRMED\r\n" .
161
+ "DTSTAMP:19700101T000000\r\n" .
162
+ 'DTSTART:' . mysql2date( $date_format, $event->post_date ) . "\r\n" .
163
+ 'DTEND:' . $end->format( $date_format ) . "\r\n" .
164
+ 'LAST-MODIFIED:' . mysql2date( $date_format, $event->post_modified_gmt ) . "\r\n";
165
 
166
  if ( $description ) {
167
+ $output .= 'DESCRIPTION:' . $description . "\r\n";
168
  }
169
 
170
  if ( $location ) {
171
+ $output .= 'LOCATION:' . $location . "\r\n";
172
  }
173
 
174
  if ( $geo ) {
175
+ $output .= 'GEO:' . $geo . "\r\n";
176
  }
177
 
178
  $output .= "END:VEVENT\r\n";
179
  endforeach;
180
 
181
  // End output
182
+ $output .= 'END:VCALENDAR';
183
 
184
  // Print headers
185
+ header( 'Content-type: text/calendar; charset=utf-8' );
186
 
187
  // The E-Tag is not being changed when the output file is generated – Some Webdav clients do not like this and
188
  // do not then 'see' that the file has changed – updates to the calendars are then not displayed to the user.
189
  // Props @garygomm https://wordpress.org/support/topic/calendar-feed-issue-not-updating-after-change/
190
+ $etag = md5( $output );
191
+ header( 'Etag:' . '"' . $etag . '"' );
192
 
193
+ header( 'Content-Disposition: inline; filename=' . $post->post_name . '.ics' );
194
 
195
  // Print content
196
+ echo wp_kses_post( $output );
includes/abstracts/abstract-sp-custom-post.php CHANGED
@@ -4,11 +4,11 @@
4
  *
5
  * The SportsPress custom post class handles individual post data.
6
  *
7
- * @class SP_Custom_Post
8
- * @version 2.6.5
9
- * @package SportsPress/Abstracts
10
- * @category Abstract Class
11
- * @author ThemeBoy
12
  */
13
  abstract class SP_Custom_Post {
14
 
@@ -25,11 +25,11 @@ abstract class SP_Custom_Post {
25
  * @param mixed $post
26
  */
27
  public function __construct( $post ) {
28
- if ( $post instanceof WP_Post || $post instanceof SP_Custom_Post ):
29
  $this->ID = absint( $post->ID );
30
  $this->post = $post;
31
- else:
32
- $this->ID = absint( $post );
33
  $this->post = get_post( $this->ID );
34
  endif;
35
  }
@@ -53,9 +53,9 @@ abstract class SP_Custom_Post {
53
  * @return bool
54
  */
55
  public function __get( $key ) {
56
- if ( ! isset( $key ) ):
57
  return $this->post;
58
- else:
59
  $value = get_post_meta( $this->ID, 'sp_' . $key, true );
60
  endif;
61
 
@@ -77,7 +77,7 @@ abstract class SP_Custom_Post {
77
  *
78
  * @access public
79
  * @param string $taxonomy The taxonomy.
80
- * @return array|false|WP_Error See `get_the_terms()`
81
  */
82
  public function get_terms_sorted_by_sp_order( $taxonomy ) {
83
  $terms = get_the_terms( $this->ID, $taxonomy );
4
  *
5
  * The SportsPress custom post class handles individual post data.
6
  *
7
+ * @class SP_Custom_Post
8
+ * @version 2.6.5
9
+ * @package SportsPress/Abstracts
10
+ * @category Abstract Class
11
+ * @author ThemeBoy
12
  */
13
  abstract class SP_Custom_Post {
14
 
25
  * @param mixed $post
26
  */
27
  public function __construct( $post ) {
28
+ if ( $post instanceof WP_Post || $post instanceof SP_Custom_Post ) :
29
  $this->ID = absint( $post->ID );
30
  $this->post = $post;
31
+ else :
32
+ $this->ID = absint( $post );
33
  $this->post = get_post( $this->ID );
34
  endif;
35
  }
53
  * @return bool
54
  */
55
  public function __get( $key ) {
56
+ if ( ! isset( $key ) ) :
57
  return $this->post;
58
+ else :
59
  $value = get_post_meta( $this->ID, 'sp_' . $key, true );
60
  endif;
61
 
77
  *
78
  * @access public
79
  * @param string $taxonomy The taxonomy.
80
+ * @return array|false|WP_Error See `get_the_terms()`
81
  */
82
  public function get_terms_sorted_by_sp_order( $taxonomy ) {
83
  $terms = get_the_terms( $this->ID, $taxonomy );
includes/abstracts/abstract-sp-secondary-post.php CHANGED
@@ -4,70 +4,70 @@
4
  *
5
  * The SportsPress secondary post class extends custom posts with handling of secondary post types.
6
  *
7
- * @class SP_Secondary_Post
8
  * @version 2.5.3
9
- * @package SportsPress/Abstracts
10
- * @category Abstract Class
11
- * @author ThemeBoy
12
  */
13
  abstract class SP_Secondary_Post extends SP_Custom_Post {
14
 
15
- /** @var string The date filter for events. */
16
- public $date = 0;
17
 
18
- /** @var string The date to range from. */
19
- public $from = 'now';
20
 
21
- /** @var string The date to range to. */
22
- public $to = 'now';
23
 
24
- /** @var string The number of days to query in the past. */
25
- public $past = 0;
26
 
27
- /** @var string The number of days to query in the future. */
28
- public $future = 0;
29
 
30
- /** @var boolean Determines whether the date range is relative. */
31
- public $relative = false;
32
 
33
- /**
34
- * __construct function.
35
- *
36
- * @access public
37
- * @param mixed $post
38
- */
39
- public function __construct( $post ) {
40
- if ( $post instanceof WP_Post || $post instanceof SP_Secondary_Post ):
41
- $this->ID = absint( $post->ID );
42
- $this->post = $post;
43
- else:
44
- $this->ID = absint( $post );
45
- $this->post = get_post( $this->ID );
46
- endif;
47
- }
48
 
49
- public function range( $where = '', $format = 'Y-m-d' ) {
50
- $from = new DateTime( $this->from );
51
- $to = new DateTime( $this->to );
52
 
53
- $to->modify( '+1 day' );
54
 
55
- $where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
56
 
57
- return $where;
58
- }
59
 
60
- public function relative( $where = '', $format = 'Y-m-d' ) {
61
- $from = new DateTime( 'now' );
62
- $to = new DateTime( 'now' );
63
 
64
- $from->modify( '-' . abs( (int) $this->past ) . ' day' );
65
- $to->modify( '+' . abs( (int) $this->future ) . ' day' );
66
 
67
- $to->modify( '+1 day' );
68
 
69
- $where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
70
 
71
- return $where;
72
- }
73
  }
4
  *
5
  * The SportsPress secondary post class extends custom posts with handling of secondary post types.
6
  *
7
+ * @class SP_Secondary_Post
8
  * @version 2.5.3
9
+ * @package SportsPress/Abstracts
10
+ * @category Abstract Class
11
+ * @author ThemeBoy
12
  */
13
  abstract class SP_Secondary_Post extends SP_Custom_Post {
14
 
15
+ /** @var string The date filter for events. */
16
+ public $date = 0;
17
 
18
+ /** @var string The date to range from. */
19
+ public $from = 'now';
20
 
21
+ /** @var string The date to range to. */
22
+ public $to = 'now';
23
 
24
+ /** @var string The number of days to query in the past. */
25
+ public $past = 0;
26
 
27
+ /** @var string The number of days to query in the future. */
28
+ public $future = 0;
29
 
30
+ /** @var boolean Determines whether the date range is relative. */
31
+ public $relative = false;
32
 
33
+ /**
34
+ * __construct function.
35
+ *
36
+ * @access public
37
+ * @param mixed $post
38
+ */
39
+ public function __construct( $post ) {
40
+ if ( $post instanceof WP_Post || $post instanceof SP_Secondary_Post ) :
41
+ $this->ID = absint( $post->ID );
42
+ $this->post = $post;
43
+ else :
44
+ $this->ID = absint( $post );
45
+ $this->post = get_post( $this->ID );
46
+ endif;
47
+ }
48
 
49
+ public function range( $where = '', $format = 'Y-m-d' ) {
50
+ $from = new DateTime( $this->from );
51
+ $to = new DateTime( $this->to );
52
 
53
+ $to->modify( '+1 day' );
54
 
55
+ $where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
56
 
57
+ return $where;
58
+ }
59
 
60
+ public function relative( $where = '', $format = 'Y-m-d' ) {
61
+ $from = new DateTime( 'now' );
62
+ $to = new DateTime( 'now' );
63
 
64
+ $from->modify( '-' . abs( (int) $this->past ) . ' day' );
65
+ $to->modify( '+' . abs( (int) $this->future ) . ' day' );
66
 
67
+ $to->modify( '+1 day' );
68
 
69
+ $where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
70
 
71
+ return $where;
72
+ }
73
  }
includes/admin/class-sp-admin-ajax.php CHANGED
@@ -6,10 +6,10 @@ if ( ! defined( 'ABSPATH' ) ) {
6
  /**
7
  * SportsPress Admin.
8
  *
9
- * @class SP_Admin_AJAX
10
- * @author ThemeBoy
11
- * @category Admin
12
- * @package SportsPress/Admin
13
  * @version 1.7
14
  */
15
  class SP_Admin_AJAX {
@@ -31,7 +31,7 @@ class SP_Admin_AJAX {
31
  function save_primary_result() {
32
  check_ajax_referer( 'sp-save-primary-result', 'nonce' );
33
 
34
- $primary_result = sanitize_key( $_POST['primary_result'] );
35
 
36
  update_option( 'sportspress_primary_result', $primary_result );
37
  wp_send_json_success();
@@ -45,7 +45,7 @@ class SP_Admin_AJAX {
45
  function save_primary_performance() {
46
  check_ajax_referer( 'sp-save-primary-performance', 'nonce' );
47
 
48
- $primary_performance = sanitize_key( $_POST['primary_performance'] );
49
 
50
  update_option( 'sportspress_primary_performance', $primary_performance );
51
  wp_send_json_success();
@@ -59,10 +59,10 @@ class SP_Admin_AJAX {
59
  function save_inline_results() {
60
  check_ajax_referer( 'sp-save-inline-results', 'nonce' );
61
 
62
- $id = sp_array_value( $_POST, 'post_id' );
63
  $results = sp_array_value( $_POST, 'results' );
64
 
65
- if ( sp_update_main_results ( $id, $results ) ) {
66
  wp_send_json_success();
67
  } else {
68
  wp_send_json_error();
6
  /**
7
  * SportsPress Admin.
8
  *
9
+ * @class SP_Admin_AJAX
10
+ * @author ThemeBoy
11
+ * @category Admin
12
+ * @package SportsPress/Admin
13
  * @version 1.7
14
  */
15
  class SP_Admin_AJAX {
31
  function save_primary_result() {
32
  check_ajax_referer( 'sp-save-primary-result', 'nonce' );
33
 
34
+ $primary_result = sanitize_key( $_POST['primary_result'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
35
 
36
  update_option( 'sportspress_primary_result', $primary_result );
37
  wp_send_json_success();
45
  function save_primary_performance() {
46
  check_ajax_referer( 'sp-save-primary-performance', 'nonce' );
47
 
48
+ $primary_performance = sanitize_key( $_POST['primary_performance'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
49
 
50
  update_option( 'sportspress_primary_performance', $primary_performance );
51
  wp_send_json_success();
59
  function save_inline_results() {
60
  check_ajax_referer( 'sp-save-inline-results', 'nonce' );
61
 
62
+ $id = sp_array_value( $_POST, 'post_id' );
63
  $results = sp_array_value( $_POST, 'results' );
64
 
65
+ if ( sp_update_main_results( $id, $results ) ) {
66
  wp_send_json_success();
67
  } else {
68
  wp_send_json_error();
includes/admin/class-sp-admin-assets.php CHANGED
@@ -2,144 +2,149 @@
2
  /**
3
  * Load assets.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin
8
  * @version 2.6.15
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( ! class_exists( 'SP_Admin_Assets' ) ) :
14
 
15
- /**
16
- * SP_Admin_Assets Class
17
- */
18
- class SP_Admin_Assets {
19
-
20
- /**
21
- * Hook in tabs.
22
- */
23
- public function __construct() {
24
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
25
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
26
- }
27
-
28
  /**
29
- * Enqueue styles
30
  */
31
- public function admin_styles( $hook ) {
32
- // Sitewide menu CSS
33
- wp_enqueue_style( 'sportspress-admin-menu-styles', SP()->plugin_url() . '/assets/css/menu.css', array(), SP_VERSION );
34
-
35
- $screen = get_current_screen();
36
-
37
- if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
38
- // Admin styles for SP pages only
39
- wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' );
40
- wp_enqueue_style( 'wp-color-picker' );
41
- wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
42
- } elseif ( strpos( $screen->id, 'sportspress-config' ) !== false ) {
43
- wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
44
  }
45
 
46
- if ( strpos( $screen->id, 'sportspress-overview' ) !== false ) {
47
- wp_enqueue_style( 'sportspress-admin-slickmap', SP()->plugin_url() . '/assets/css/slickmap.css', array(), '1.1.0' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
- if ( in_array( $screen->id, array( 'dashboard' ) ) ) {
51
- wp_enqueue_style( 'sportspress-admin-dashboard-styles', SP()->plugin_url() . '/assets/css/dashboard.css', array(), SP_VERSION );
52
- }
 
 
53
 
54
- if ( in_array( $screen->id, array( 'customize' ) ) ) {
55
- wp_enqueue_style( 'sportspress-admin-customize-styles', SP()->plugin_url() . '/assets/css/customize.css', array(), SP_VERSION );
56
- }
57
 
58
- if ( in_array( $screen->id, array( 'sp_result', 'sp_performance', 'sp_column', 'sp_statistic' ) ) ) {
59
- wp_enqueue_style( 'sportspress-admin-equation-styles', SP()->plugin_url() . '/assets/css/equation.css', array(), SP_VERSION );
60
- }
61
 
62
- if ( in_array( $screen->id, apply_filters( 'sportspress_admin_datepicker_screen_ids', array( 'sp_calendar', 'sp_table', 'sp_list', 'widgets' ) ) ) || in_array( $hook, array('post.php', 'post-new.php') ) ) {
63
- wp_enqueue_style( 'jquery-ui-style' , '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css' );
64
- wp_enqueue_style( 'sportspress-admin-datepicker-styles', SP()->plugin_url() . '/assets/css/datepicker.css', array( 'jquery-ui-style' ), SP_VERSION );
65
- }
66
 
67
- do_action( 'sportspress_admin_css', $screen );
68
- }
69
-
70
- /**
71
- * Enqueue scripts
72
- */
73
- public function admin_scripts($hook) {
74
- global $wp_query, $post;
75
-
76
- $screen = get_current_screen();
77
 
78
- // Register scripts
79
- wp_register_script( 'chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
80
 
81
- wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
82
 
83
- wp_register_script( 'jquery-caret', SP()->plugin_url() . '/assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
84
 
85
- wp_register_script( 'jquery-fitvids', SP()->plugin_url() . '/assets/js/jquery.fitvids.js', array( 'jquery' ), '1.1', true );
86
 
87
- wp_register_script( 'sportspress-admin-equationbuilder', SP()->plugin_url() . '/assets/js/admin/equationbuilder.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable' ), SP_VERSION, true );
88
 
89
- wp_register_script( 'sportspress-admin-colorpicker', SP()->plugin_url() . '/assets/js/admin/colorpicker.js', array( 'jquery', 'wp-color-picker', 'iris' ), SP_VERSION, true );
 
90
 
91
- wp_register_script( 'sportspress-admin-widgets', SP()->plugin_url() . '/assets/js/admin/widgets.js', array( 'jquery' ), SP_VERSION, true );
 
 
 
 
 
 
 
 
 
92
 
93
- wp_register_script( 'sportspress-admin-quickeditor', SP()->plugin_url() . '/assets/js/admin/quickeditor.js', array( 'jquery' ), SP_VERSION, true );
 
 
 
 
 
 
 
 
 
 
 
94
 
95
- // SportsPress admin pages
96
- if ( in_array( $screen->id, sp_get_screen_ids() ) || strpos( $screen->id, 'sportspress-config' ) || in_array($hook, array('post.php', 'post-new.php') ) ) {
 
97
 
98
- wp_enqueue_script( 'jquery' );
99
- wp_enqueue_script( 'chosen' );
100
- wp_enqueue_script( 'jquery-ui-core' );
101
- wp_enqueue_script( 'jquery-ui-draggable' );
102
- wp_enqueue_script( 'jquery-ui-droppable' );
103
- wp_enqueue_script( 'jquery-ui-sortable' );
104
- wp_enqueue_script( 'jquery-tiptip' );
105
- wp_enqueue_script( 'jquery-caret' );
106
- wp_enqueue_script( 'jquery-fitvids' );
107
- wp_enqueue_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret', 'jquery-fitvids' ), SP_VERSION, true );
108
-
109
- $strings = apply_filters( 'sportspress_localized_strings', array(
110
- 'none' => __( 'None', 'sportspress' ),
111
- 'remove_text' => __( '&mdash; Remove &mdash;', 'sportspress' ),
112
- 'days' => __( 'days', 'sportspress' ),
113
- 'hrs' => __( 'hrs', 'sportspress' ),
114
- 'mins' => __( 'mins', 'sportspress' ),
115
- 'secs' => __( 'secs', 'sportspress' ),
116
- 'displaying_posts' => html_entity_decode( __( 'Displaying %s&#8211;%s of %s', 'sportspress' ) ),
117
- ) );
118
 
119
- // Localize scripts
120
- wp_localize_script( 'sportspress-admin', 'localized_strings', $strings );
121
- }
 
122
 
123
- if ( in_array( $screen->id, array( 'widgets' ) ) ) {
124
- wp_enqueue_script( 'sportspress-admin-widgets' );
125
- }
 
126
 
127
- // Edit color
128
- if ( in_array( $screen->id, array( 'sp_outcome' ) ) ) {
129
- wp_enqueue_script( 'sportspress-admin-colorpicker' );
130
- }
131
-
132
- // Edit equation
133
- if ( in_array( $screen->id, array( 'sp_result', 'sp_performance', 'sp_column', 'sp_statistic' ) ) ) {
134
- wp_enqueue_script( 'sportspress-admin-equationbuilder' );
135
- }
136
-
137
- // Quick edit
138
- if ( in_array( $screen->id, array( 'edit-sp_player' ) ) ) {
139
- wp_enqueue_script( 'sportspress-admin-quickeditor' );
140
  }
141
  }
142
- }
143
 
144
  endif;
145
 
2
  /**
3
  * Load assets.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin
8
  * @version 2.6.15
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( ! class_exists( 'SP_Admin_Assets' ) ) :
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  /**
18
+ * SP_Admin_Assets Class
19
  */
20
+ class SP_Admin_Assets {
21
+
22
+ /**
23
+ * Hook in tabs.
24
+ */
25
+ public function __construct() {
26
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
27
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
 
 
 
 
 
28
  }
29
 
30
+ /**
31
+ * Enqueue styles
32
+ */
33
+ public function admin_styles( $hook ) {
34
+ // Sitewide menu CSS
35
+ wp_enqueue_style( 'sportspress-admin-menu-styles', SP()->plugin_url() . '/assets/css/menu.css', array(), SP_VERSION );
36
+
37
+ $screen = get_current_screen();
38
+
39
+ if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
40
+ // Admin styles for SP pages only
41
+ wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' );
42
+ wp_enqueue_style( 'wp-color-picker' );
43
+ wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
44
+ } elseif ( strpos( $screen->id, 'sportspress-config' ) !== false ) {
45
+ wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
46
+ }
47
+
48
+ if ( strpos( $screen->id, 'sportspress-overview' ) !== false ) {
49
+ wp_enqueue_style( 'sportspress-admin-slickmap', SP()->plugin_url() . '/assets/css/slickmap.css', array(), '1.1.0' );
50
+ }
51
+
52
+ if ( in_array( $screen->id, array( 'dashboard' ) ) ) {
53
+ wp_enqueue_style( 'sportspress-admin-dashboard-styles', SP()->plugin_url() . '/assets/css/dashboard.css', array(), SP_VERSION );
54
+ }
55
+
56
+ if ( in_array( $screen->id, array( 'customize' ) ) ) {
57
+ wp_enqueue_style( 'sportspress-admin-customize-styles', SP()->plugin_url() . '/assets/css/customize.css', array(), SP_VERSION );
58
+ }
59
+
60
+ if ( in_array( $screen->id, array( 'sp_result', 'sp_performance', 'sp_column', 'sp_statistic' ) ) ) {
61
+ wp_enqueue_style( 'sportspress-admin-equation-styles', SP()->plugin_url() . '/assets/css/equation.css', array(), SP_VERSION );
62
+ }
63
+
64
+ if ( in_array( $screen->id, apply_filters( 'sportspress_admin_datepicker_screen_ids', array( 'sp_calendar', 'sp_table', 'sp_list', 'widgets' ) ) ) || in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
65
+ wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css' );
66
+ wp_enqueue_style( 'sportspress-admin-datepicker-styles', SP()->plugin_url() . '/assets/css/datepicker.css', array( 'jquery-ui-style' ), SP_VERSION );
67
+ }
68
+
69
+ do_action( 'sportspress_admin_css', $screen );
70
  }
71
 
72
+ /**
73
+ * Enqueue scripts
74
+ */
75
+ public function admin_scripts( $hook ) {
76
+ global $wp_query, $post;
77
 
78
+ $screen = get_current_screen();
 
 
79
 
80
+ // Register scripts
81
+ wp_register_script( 'chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
 
82
 
83
+ wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
 
 
 
84
 
85
+ wp_register_script( 'jquery-caret', SP()->plugin_url() . '/assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
 
 
 
 
 
 
 
 
 
86
 
87
+ wp_register_script( 'jquery-fitvids', SP()->plugin_url() . '/assets/js/jquery.fitvids.js', array( 'jquery' ), '1.1', true );
 
88
 
89
+ wp_register_script( 'sportspress-admin-equationbuilder', SP()->plugin_url() . '/assets/js/admin/equationbuilder.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable' ), SP_VERSION, true );
90
 
91
+ wp_register_script( 'sportspress-admin-colorpicker', SP()->plugin_url() . '/assets/js/admin/colorpicker.js', array( 'jquery', 'wp-color-picker', 'iris' ), SP_VERSION, true );
92
 
93
+ wp_register_script( 'sportspress-admin-widgets', SP()->plugin_url() . '/assets/js/admin/widgets.js', array( 'jquery' ), SP_VERSION, true );
94
 
95
+ wp_register_script( 'sportspress-admin-quickeditor', SP()->plugin_url() . '/assets/js/admin/quickeditor.js', array( 'jquery' ), SP_VERSION, true );
96
 
97
+ // SportsPress admin pages
98
+ if ( in_array( $screen->id, sp_get_screen_ids() ) || strpos( $screen->id, 'sportspress-config' ) || in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
99
 
100
+ wp_enqueue_script( 'jquery' );
101
+ wp_enqueue_script( 'chosen' );
102
+ wp_enqueue_script( 'jquery-ui-core' );
103
+ wp_enqueue_script( 'jquery-ui-draggable' );
104
+ wp_enqueue_script( 'jquery-ui-droppable' );
105
+ wp_enqueue_script( 'jquery-ui-sortable' );
106
+ wp_enqueue_script( 'jquery-tiptip' );
107
+ wp_enqueue_script( 'jquery-caret' );
108
+ wp_enqueue_script( 'jquery-fitvids' );
109
+ wp_enqueue_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret', 'jquery-fitvids' ), SP_VERSION, true );
110
 
111
+ $strings = apply_filters(
112
+ 'sportspress_localized_strings',
113
+ array(
114
+ 'none' => esc_attr__( 'None', 'sportspress' ),
115
+ 'remove_text' => esc_attr__( '&mdash; Remove &mdash;', 'sportspress' ),
116
+ 'days' => esc_attr__( 'days', 'sportspress' ),
117
+ 'hrs' => esc_attr__( 'hrs', 'sportspress' ),
118
+ 'mins' => esc_attr__( 'mins', 'sportspress' ),
119
+ 'secs' => esc_attr__( 'secs', 'sportspress' ),
120
+ 'displaying_posts' => html_entity_decode( esc_attr__( 'Displaying %1$s&#8211;%2$s of %3$s', 'sportspress' ) ),
121
+ )
122
+ );
123
 
124
+ // Localize scripts
125
+ wp_localize_script( 'sportspress-admin', 'localized_strings', $strings );
126
+ }
127
 
128
+ if ( in_array( $screen->id, array( 'widgets' ) ) ) {
129
+ wp_enqueue_script( 'sportspress-admin-widgets' );
130
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
+ // Edit color
133
+ if ( in_array( $screen->id, array( 'sp_outcome' ) ) ) {
134
+ wp_enqueue_script( 'sportspress-admin-colorpicker' );
135
+ }
136
 
137
+ // Edit equation
138
+ if ( in_array( $screen->id, array( 'sp_result', 'sp_performance', 'sp_column', 'sp_statistic' ) ) ) {
139
+ wp_enqueue_script( 'sportspress-admin-equationbuilder' );
140
+ }
141
 
142
+ // Quick edit
143
+ if ( in_array( $screen->id, array( 'edit-sp_player' ) ) ) {
144
+ wp_enqueue_script( 'sportspress-admin-quickeditor' );
145
+ }
 
 
 
 
 
 
 
 
 
146
  }
147
  }
 
148
 
149
  endif;
150
 
includes/admin/class-sp-admin-dashboard.php CHANGED
@@ -2,101 +2,130 @@
2
  /**
3
  * Admin Dashboard
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin
8
- * @version 2.6.8
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( ! class_exists( 'SP_Admin_Dashboard' ) ) :
14
 
15
- /**
16
- * SP_Admin_Dashboard Class
17
- */
18
- class SP_Admin_Dashboard {
19
 
20
- /**
21
- * Hook in tabs.
22
- */
23
- public function __construct() {
24
- // Only hook in admin parts if the user has admin access
25
- if ( current_user_can( 'view_sportspress_reports' ) || current_user_can( 'manage_sportspress' ) || current_user_can( 'publish_sp_events' ) ) {
26
- add_action( 'wp_dashboard_setup', array( $this, 'init' ) );
27
- }
28
- }
29
 
30
- /**
31
- * Init dashboard widgets
32
- */
33
- public function init() {
34
- wp_add_dashboard_widget( 'sportspress_dashboard_status', __( 'SportsPress', 'sportspress' ), array( $this, 'status_widget' ) );
35
- add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 );
36
- }
 
37
 
38
- /**
39
- * Add links to At a Glance
40
- */
41
- function glance_items( $items = array() ) {
42
- $post_types = apply_filters( 'sportspress_glance_items', array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) );
43
- foreach ( $post_types as $type ):
44
- if ( ! post_type_exists( $type ) ) continue;
45
- $num_posts = wp_count_posts( $type );
46
- if ( $num_posts ):
47
- $published = intval( $num_posts->publish );
48
- $post_type = get_post_type_object( $type );
49
- $text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'sportspress' );
50
- $text = sprintf( $text, number_format_i18n( $published ) );
51
- if ( current_user_can( $post_type->cap->edit_posts ) ):
52
- $output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $text . '</a>';
53
- else:
54
- $output = '<span>' . $text . '</span>';
55
- endif;
56
- echo '<li class="post-count ' . $post_type->name . '-count">' . $output . '</li>';
57
- endif;
58
- endforeach;
59
- return $items;
60
- }
 
 
61
 
62
- /**
63
- * Show status widget
64
- */
65
- public function status_widget() {
66
- ?>
67
- <ul class="sp_status_list">
68
- <?php
69
- $count = wp_count_posts( 'sp_event' );
70
- $scheduled_count = isset( $count->future ) ? $count->future : 0;
71
- $published_count = isset( $count->publish ) ? $count->publish : 0;
72
- $next_event = sp_get_next_event();
73
- if ( $next_event ):
74
- $now = new DateTime( current_time( 'mysql', 0 ) );
75
- $date = new DateTime( $next_event->post_date );
76
- $interval = date_diff( $now, $date );
77
- ?>
78
- <li class="countdown" data-countdown="<?php echo str_replace( '-', '/', get_gmt_from_date( $next_event->post_date ) ); ?>">
79
- <a href="<?php echo get_edit_post_link( $next_event->ID ); ?>">
80
- <?php printf( __( '<strong>%s</strong> until next event', 'sportspress' ), $interval->days . ' ' . __( 'days', 'sportspress' ) . ' ' . sprintf( '%02s:%02s:%02s', $interval->h, $interval->i, $interval->s ) ); ?>
81
- (<?php echo $next_event->post_title; ?>)
82
- </a>
83
- </li>
84
- <?php endif; ?>
85
- <li class="events-scheduled">
86
- <a href="<?php echo admin_url( 'edit.php?post_type=sp_event&post_status=future' ); ?>">
87
- <?php printf( _n( '<strong>%s event</strong> scheduled', '<strong>%s events</strong> scheduled', $scheduled_count, 'sportspress' ), $scheduled_count ); ?>
88
- </a>
89
- </li>
90
- <li class="events-published">
91
- <a href="<?php echo admin_url( 'edit.php?post_type=sp_event&post_status=publish' ); ?>">
92
- <?php printf( _n( '<strong>%s event</strong> published', '<strong>%s events</strong> published', $published_count, 'sportspress' ), $published_count ); ?>
93
- </a>
94
- </li>
95
- </ul>
96
- <?php
97
- }
98
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
  endif;
101
 
102
- return new SP_Admin_Dashboard();
2
  /**
3
  * Admin Dashboard
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( ! class_exists( 'SP_Admin_Dashboard' ) ) :
16
 
17
+ /**
18
+ * SP_Admin_Dashboard Class
19
+ */
20
+ class SP_Admin_Dashboard {
21
 
22
+ /**
23
+ * Hook in tabs.
24
+ */
25
+ public function __construct() {
26
+ // Only hook in admin parts if the user has admin access
27
+ if ( current_user_can( 'view_sportspress_reports' ) || current_user_can( 'manage_sportspress' ) || current_user_can( 'publish_sp_events' ) ) {
28
+ add_action( 'wp_dashboard_setup', array( $this, 'init' ) );
29
+ }
30
+ }
31
 
32
+ /**
33
+ * Init dashboard widgets
34
+ */
35
+ public function init() {
36
+ // wp_add_dashboard_widget( 'sportspress_dashboard_news', esc_attr__( 'Sports News', 'sportspress' ), array( $this, 'news_widget' ), null, null, 'side' );
37
+ wp_add_dashboard_widget( 'sportspress_dashboard_status', esc_attr__( 'SportsPress', 'sportspress' ), array( $this, 'status_widget' ) );
38
+ add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 );
39
+ }
40
 
41
+ /**
42
+ * Add links to At a Glance
43
+ */
44
+ function glance_items( $items = array() ) {
45
+ $post_types = apply_filters( 'sportspress_glance_items', array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) );
46
+ foreach ( $post_types as $type ) :
47
+ if ( ! post_type_exists( $type ) ) {
48
+ continue;
49
+ }
50
+ $num_posts = wp_count_posts( $type );
51
+ if ( $num_posts ) :
52
+ $published = intval( $num_posts->publish );
53
+ $post_type = get_post_type_object( $type );
54
+ $text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'sportspress' );
55
+ $text = sprintf( $text, number_format_i18n( $published ) );
56
+ if ( current_user_can( $post_type->cap->edit_posts ) ) :
57
+ $output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $text . '</a>';
58
+ else :
59
+ $output = '<span>' . $text . '</span>';
60
+ endif;
61
+ echo '<li class="post-count ' . esc_attr( $post_type->name ) . '-count">' . wp_kses_post( $output ) . '</li>';
62
+ endif;
63
+ endforeach;
64
+ return $items;
65
+ }
66
 
67
+ /**
68
+ * Show status widget
69
+ */
70
+ public function status_widget() {
71
+ ?>
72
+ <ul class="sp_status_list">
73
+ <?php
74
+ $count = wp_count_posts( 'sp_event' );
75
+ $scheduled_count = isset( $count->future ) ? $count->future : 0;
76
+ $published_count = isset( $count->publish ) ? $count->publish : 0;
77
+ $next_event = sp_get_next_event();
78
+ if ( $next_event ) :
79
+ $now = new DateTime( current_time( 'mysql', 0 ) );
80
+ $date = new DateTime( $next_event->post_date );
81
+ $interval = date_diff( $now, $date );
82
+ ?>
83
+ <li class="countdown" data-countdown="<?php echo esc_attr( str_replace( '-', '/', get_gmt_from_date( $next_event->post_date ) ) ); ?>">
84
+ <a href="<?php echo esc_url( get_edit_post_link( $next_event->ID ) ); ?>">
85
+ <?php printf( esc_html__( '<strong>%s</strong> until next event', 'sportspress' ), esc_html( $interval->days ) . ' ' . esc_html__( 'days', 'sportspress' ) . ' ' . sprintf( '%02s:%02s:%02s', esc_html( $interval->h ), esc_html( $interval->i ), esc_html( $interval->s ) ) ); ?>
86
+ (<?php echo esc_html( $next_event->post_title ); ?>)
87
+ </a>
88
+ </li>
89
+ <?php endif; ?>
90
+ <li class="events-scheduled">
91
+ <a href="<?php echo esc_url( admin_url( 'edit.php?post_type=sp_event&post_status=future' ).'savvas' ); ?>">
92
+ <?php printf( wp_kses_post( _n( '<strong>%s event</strong> scheduled', '<strong>%s events</strong> scheduled', $scheduled_count, 'sportspress' ) ), esc_attr( $scheduled_count ) ); ?>
93
+ </a>
94
+ </li>
95
+ <li class="events-published">
96
+ <a href="<?php echo esc_url( admin_url( 'edit.php?post_type=sp_event&post_status=publish' ) ); ?>">
97
+ <?php printf( wp_kses_post( _n( '<strong>%s event</strong> published', '<strong>%s events</strong> published', $published_count, 'sportspress' ) ), esc_attr( $published_count ) ); ?>
98
+ </a>
99
+ </li>
100
+ </ul>
101
+ <?php
102
+ }
103
+
104
+ /**
105
+ * Show news widget
106
+ */
107
+ public function news_widget() {
108
+ $rss = fetch_feed( 'https://tboy.co/sportsnews/' );
109
+ if ( ! is_wp_error( $rss ) ) { // Checks that the object is created correctly
110
+ // Figure out how many total items there are, but limit it to 2.
111
+ $maxitems = $rss->get_item_quantity( 5 );
112
+ // Build an array of all the items, starting with element 0 (first element).
113
+ $rss_items = $rss->get_items( 0, $maxitems );
114
+ }
115
+ if ( ! empty( $maxitems ) ) {
116
+ ?>
117
+ <div class="rss-widget">
118
+ <ul>
119
+ <?php foreach ( $rss_items as $item ) { ?>
120
+ <li><a class="rsswidget" href="<?php echo esc_url( $item->get_permalink() ); ?>" target="_blank"><?php echo esc_attr( $item->get_title() ); ?></a> <span class="rss-date"><?php echo esc_html( $item->get_date( 'j F Y' ) ); ?></span></li>
121
+ <?php } ?>
122
+ </ul>
123
+ </div>
124
+ <?php
125
+ }
126
+ }
127
+ }
128
 
129
  endif;
130
 
131
+ return new SP_Admin_Dashboard();
includes/admin/class-sp-admin-editor.php CHANGED
@@ -4,11 +4,11 @@
4
  *
5
  * Methods which tweak the WP Editor.
6
  *
7
- * @author ThemeBoy
8
- * @category Admin
9
- * @package SportsPress/Admin
10
  * @version 2.4
11
- */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit; // Exit if accessed directly
@@ -51,8 +51,8 @@ class SP_Admin_Editor {
51
  * @return array
52
  */
53
  public function add_tinymce_lang( $arr ) {
54
- $arr['sp_shortcodes_button'] = SP()->plugin_path() . '/assets/js/admin/editor-lang.php';
55
- return $arr;
56
  }
57
 
58
  /**
4
  *
5
  * Methods which tweak the WP Editor.
6
  *
7
+ * @author ThemeBoy
8
+ * @category Admin
9
+ * @package SportsPress/Admin
10
  * @version 2.4
11
+ */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) {
14
  exit; // Exit if accessed directly
51
  * @return array
52
  */
53
  public function add_tinymce_lang( $arr ) {
54
+ $arr['sp_shortcodes_button'] = SP()->plugin_path() . '/assets/js/admin/editor-lang.php';
55
+ return $arr;
56
  }
57
 
58
  /**
includes/admin/class-sp-admin-importers.php CHANGED
@@ -2,166 +2,172 @@
2
  /**
3
  * Setup importers for SP data.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin
8
- * @version 2.5.1
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( ! class_exists( 'SP_Admin_Importers' ) ) :
14
 
15
- /**
16
- * SP_Admin_Importers Class
17
- */
18
- class SP_Admin_Importers {
19
-
20
  /**
21
- * Hook in tabs.
22
  */
23
- public function __construct() {
24
- add_action( 'admin_init', array( $this, 'register_importers' ) );
25
- }
26
 
27
- /**
28
- * Add menu items
29
- */
30
- public function register_importers() {
31
- global $pagenow;
32
- $importers = apply_filters( 'sportspress_importers', array(
33
- 'sp_event_csv' => array(
34
- 'name' => __( 'SportsPress Events (CSV)', 'sportspress' ),
35
- 'description' => __( 'Import <strong>events</strong> from a csv file.', 'sportspress'),
36
- 'callback' => array( $this, 'events_importer' ),
37
- ),
38
- 'sp_fixture_csv' => array(
39
- 'name' => __( 'SportsPress Fixtures (CSV)', 'sportspress' ),
40
- 'description' => __( 'Import <strong>upcoming events</strong> from a csv file.', 'sportspress'),
41
- 'callback' => array( $this, 'fixtures_importer' ),
42
- ),
43
- 'sp_team_csv' => array(
44
- 'name' => __( 'SportsPress Teams (CSV)', 'sportspress' ),
45
- 'description' => __( 'Import <strong>teams</strong> from a csv file.', 'sportspress'),
46
- 'callback' => array( $this, 'teams_importer' ),
47
- ),
48
- 'sp_player_csv' => array(
49
- 'name' => __( 'SportsPress Players (CSV)', 'sportspress' ),
50
- 'description' => __( 'Import <strong>players</strong> from a csv file.', 'sportspress'),
51
- 'callback' => array( $this, 'players_importer' ),
52
- ),
53
- 'sp_staff_csv' => array(
54
- 'name' => __( 'SportsPress Staff (CSV)', 'sportspress' ),
55
- 'description' => __( 'Import <strong>staff</strong> from a csv file.', 'sportspress'),
56
- 'callback' => array( $this, 'staff_importer' ),
57
- ),
58
- ) );
59
-
60
- if ( 'import.php' !== $pagenow ) {
61
- $importers['sp_event_performance_csv'] = array(
62
- 'name' => __( 'SportsPress Box Score (CSV)', 'sportspress' ),
63
- 'description' => '<a href="' . admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ) . '">' . sprintf( __( 'Select %s', 'sportspress' ), __( 'Event', 'sportspress' ) ) . '</a>',
64
- 'callback' => array( $this, 'event_performance_importer' ),
 
 
 
65
  );
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
 
68
- foreach ( $importers as $id => $importer ) {
69
- register_importer( $id, $importer['name'], $importer['description'], $importer['callback'] );
 
 
 
 
 
 
 
 
 
70
  }
71
- }
72
 
73
- /**
74
- * Add menu item
75
- */
76
- public function events_importer() {
77
- $this->includes();
78
-
79
- require 'importers/class-sp-event-importer.php';
80
-
81
- // Dispatch
82
- $importer = new SP_Event_Importer();
83
- $importer->dispatch();
84
- }
85
 
86
- /**
87
- * Add menu item
88
- */
89
- public function event_performance_importer() {
90
- $this->includes();
91
-
92
- require 'importers/class-sp-event-performance-importer.php';
93
-
94
- // Dispatch
95
- $importer = new SP_Event_Performance_Importer();
96
- $importer->dispatch();
97
- }
98
 
99
- /**
100
- * Add menu item
101
- */
102
- public function fixtures_importer() {
103
- $this->includes();
104
-
105
- require 'importers/class-sp-fixture-importer.php';
106
-
107
- // Dispatch
108
- $importer = new SP_Fixture_Importer();
109
- $importer->dispatch();
110
- }
111
 
112
- /**
113
- * Add menu item
114
- */
115
- public function teams_importer() {
116
- $this->includes();
117
-
118
- require 'importers/class-sp-team-importer.php';
119
-
120
- // Dispatch
121
- $importer = new SP_Team_Importer();
122
- $importer->dispatch();
123
- }
124
 
125
- /**
126
- * Add menu item
127
- */
128
- public function players_importer() {
129
- $this->includes();
130
-
131
- require 'importers/class-sp-player-importer.php';
132
-
133
- // Dispatch
134
- $importer = new SP_Player_Importer();
135
- $importer->dispatch();
136
- }
137
 
138
- /**
139
- * Add menu item
140
- */
141
- public function staff_importer() {
142
- $this->includes();
143
 
144
- require 'importers/class-sp-staff-importer.php';
 
 
 
 
145
 
146
- // Dispatch
147
- $importer = new SP_Staff_Importer();
148
- $importer->dispatch();
149
- }
 
 
 
 
 
 
 
 
 
 
150
 
151
- public static function includes() {
152
- // Load Importer API
153
- require_once ABSPATH . 'wp-admin/includes/import.php';
 
 
 
 
 
 
 
154
 
155
- if ( ! class_exists( 'WP_Importer' ) ) {
156
- $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
157
- if ( file_exists( $class_wp_importer ) )
158
- require $class_wp_importer;
159
- }
160
 
161
- require 'importers/class-sp-importer.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
163
- }
164
 
165
  endif;
166
 
167
- return new SP_Admin_Importers();
2
  /**
3
  * Setup importers for SP data.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin
8
+ * @version 2.5.1
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( ! class_exists( 'SP_Admin_Importers' ) ) :
16
 
 
 
 
 
 
17
  /**
18
+ * SP_Admin_Importers Class
19
  */
20
+ class SP_Admin_Importers {
 
 
21
 
22
+ /**
23
+ * Hook in tabs.
24
+ */
25
+ public function __construct() {
26
+ add_action( 'admin_init', array( $this, 'register_importers' ) );
27
+ }
28
+
29
+ /**
30
+ * Add menu items
31
+ */
32
+ public function register_importers() {
33
+ global $pagenow;
34
+ $importers = apply_filters(
35
+ 'sportspress_importers',
36
+ array(
37
+ 'sp_event_csv' => array(
38
+ 'name' => esc_attr__( 'SportsPress Events (CSV)', 'sportspress' ),
39
+ 'description' => esc_attr__( 'Import <strong>events</strong> from a csv file.', 'sportspress' ),
40
+ 'callback' => array( $this, 'events_importer' ),
41
+ ),
42
+ 'sp_fixture_csv' => array(
43
+ 'name' => esc_attr__( 'SportsPress Fixtures (CSV)', 'sportspress' ),
44
+ 'description' => esc_attr__( 'Import <strong>upcoming events</strong> from a csv file.', 'sportspress' ),
45
+ 'callback' => array( $this, 'fixtures_importer' ),
46
+ ),
47
+ 'sp_team_csv' => array(
48
+ 'name' => esc_attr__( 'SportsPress Teams (CSV)', 'sportspress' ),
49
+ 'description' => esc_attr__( 'Import <strong>teams</strong> from a csv file.', 'sportspress' ),
50
+ 'callback' => array( $this, 'teams_importer' ),
51
+ ),
52
+ 'sp_player_csv' => array(
53
+ 'name' => esc_attr__( 'SportsPress Players (CSV)', 'sportspress' ),
54
+ 'description' => esc_attr__( 'Import <strong>players</strong> from a csv file.', 'sportspress' ),
55
+ 'callback' => array( $this, 'players_importer' ),
56
+ ),
57
+ 'sp_staff_csv' => array(
58
+ 'name' => esc_attr__( 'SportsPress Staff (CSV)', 'sportspress' ),
59
+ 'description' => esc_attr__( 'Import <strong>staff</strong> from a csv file.', 'sportspress' ),
60
+ 'callback' => array( $this, 'staff_importer' ),
61
+ ),
62
+ )
63
  );
64
+
65
+ if ( 'import.php' !== $pagenow ) {
66
+ $importers['sp_event_performance_csv'] = array(
67
+ 'name' => esc_attr__( 'SportsPress Box Score (CSV)', 'sportspress' ),
68
+ 'description' => '<a href="' . admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ) . '">' . sprintf( esc_attr__( 'Select %s', 'sportspress' ), esc_attr__( 'Event', 'sportspress' ) ) . '</a>',
69
+ 'callback' => array( $this, 'event_performance_importer' ),
70
+ );
71
+ }
72
+
73
+ foreach ( $importers as $id => $importer ) {
74
+ register_importer( $id, $importer['name'], $importer['description'], $importer['callback'] );
75
+ }
76
  }
77
 
78
+ /**
79
+ * Add menu item
80
+ */
81
+ public function events_importer() {
82
+ $this->includes();
83
+
84
+ require 'importers/class-sp-event-importer.php';
85
+
86
+ // Dispatch
87
+ $importer = new SP_Event_Importer();
88
+ $importer->dispatch();
89
  }
 
90
 
91
+ /**
92
+ * Add menu item
93
+ */
94
+ public function event_performance_importer() {
95
+ $this->includes();
 
 
 
 
 
 
 
96
 
97
+ require 'importers/class-sp-event-performance-importer.php';
 
 
 
 
 
 
 
 
 
 
 
98
 
99
+ // Dispatch
100
+ $importer = new SP_Event_Performance_Importer();
101
+ $importer->dispatch();
102
+ }
 
 
 
 
 
 
 
 
103
 
104
+ /**
105
+ * Add menu item
106
+ */
107
+ public function fixtures_importer() {
108
+ $this->includes();
 
 
 
 
 
 
 
109
 
110
+ require 'importers/class-sp-fixture-importer.php';
 
 
 
 
 
 
 
 
 
 
 
111
 
112
+ // Dispatch
113
+ $importer = new SP_Fixture_Importer();
114
+ $importer->dispatch();
115
+ }
 
116
 
117
+ /**
118
+ * Add menu item
119
+ */
120
+ public function teams_importer() {
121
+ $this->includes();
122
 
123
+ require 'importers/class-sp-team-importer.php';
124
+
125
+ // Dispatch
126
+ $importer = new SP_Team_Importer();
127
+ $importer->dispatch();
128
+ }
129
+
130
+ /**
131
+ * Add menu item
132
+ */
133
+ public function players_importer() {
134
+ $this->includes();
135
+
136
+ require 'importers/class-sp-player-importer.php';
137
 
138
+ // Dispatch
139
+ $importer = new SP_Player_Importer();
140
+ $importer->dispatch();
141
+ }
142
+
143
+ /**
144
+ * Add menu item
145
+ */
146
+ public function staff_importer() {
147
+ $this->includes();
148
 
149
+ require 'importers/class-sp-staff-importer.php';
 
 
 
 
150
 
151
+ // Dispatch
152
+ $importer = new SP_Staff_Importer();
153
+ $importer->dispatch();
154
+ }
155
+
156
+ public static function includes() {
157
+ // Load Importer API
158
+ require_once ABSPATH . 'wp-admin/includes/import.php';
159
+
160
+ if ( ! class_exists( 'WP_Importer' ) ) {
161
+ $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
162
+ if ( file_exists( $class_wp_importer ) ) {
163
+ require $class_wp_importer;
164
+ }
165
+ }
166
+
167
+ require 'importers/class-sp-importer.php';
168
+ }
169
  }
 
170
 
171
  endif;
172
 
173
+ return new SP_Admin_Importers();
includes/admin/class-sp-admin-menus.php CHANGED
@@ -2,282 +2,292 @@
2
  /**
3
  * Setup menus in WP admin.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin
8
- * @version 2.5.1
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( ! class_exists( 'SP_Admin_Menus' ) ) :
14
 
15
- /**
16
- * SP_Admin_Menus Class
17
- */
18
- class SP_Admin_Menus {
19
-
20
  /**
21
- * Hook in tabs.
22
  */
23
- public function __construct() {
24
- add_filter( 'admin_menu', array( $this, 'menu_clean' ), 5 );
25
- add_action( 'admin_menu', array( $this, 'admin_menu' ), 6 );
26
- add_action( 'admin_menu', array( $this, 'config_menu' ), 7 );
27
- add_action( 'admin_menu', array( $this, 'leagues_menu' ), 20 );
28
- add_action( 'admin_menu', array( $this, 'seasons_menu' ), 21 );
29
-
30
- add_action( 'admin_head', array( $this, 'menu_highlight' ) );
31
- add_action( 'admin_head', array( $this, 'menu_rename' ) );
32
- add_action( 'parent_file', array( $this, 'parent_file' ) );
33
- add_filter( 'menu_order', array( $this, 'menu_order' ) );
34
- add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
35
- add_filter( 'sportspress_sitemap_taxonomy_post_types', array( $this, 'sitemap_taxonomy_post_types' ), 10, 2 );
36
- }
 
 
 
 
 
37
 
38
- /**
39
- * Add menu item
40
- */
41
- public function admin_menu() {
42
- global $menu;
43
 
44
- if ( current_user_can( 'manage_sportspress' ) )
45
- $menu[] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
 
46
 
47
- $main_page = add_menu_page( __( 'SportsPress', 'sportspress' ), __( 'SportsPress', 'sportspress' ), 'manage_sportspress', 'sportspress', array( $this, 'settings_page' ), apply_filters( 'sportspress_menu_icon', null ), '51.5' );
48
- }
49
 
50
- /**
51
- * Add menu item
52
- */
53
- public function config_menu() {
54
- add_submenu_page( 'sportspress', __( 'Configure', 'sportspress' ), __( 'Configure', 'sportspress' ), 'manage_sportspress', 'sportspress-config', array( $this, 'config_page' ) );
55
- }
56
 
57
- /**
58
- * Add menu item
59
- */
60
- public function leagues_menu() {
61
- add_submenu_page( 'sportspress', __( 'Leagues', 'sportspress' ), __( 'Leagues', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_league');
62
- }
63
 
64
- /**
65
- * Add menu item
66
- */
67
- public function seasons_menu() {
68
- add_submenu_page( 'sportspress', __( 'Seasons', 'sportspress' ), __( 'Seasons', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_season');
69
- }
70
 
71
- /**
72
- * Highlights the correct top level admin menu item for post type add screens.
73
- *
74
- * @access public
75
- * @return void
76
- */
77
- public function menu_highlight() {
78
- global $typenow;
79
- $screen = get_current_screen();
80
- if ( ! is_object( $screen ) ) return;
81
- if ( $screen->id == 'sp_role' ) {
82
- $this->highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit-tags.php?taxonomy=sp_role&post_type=sp_staff' );
83
- } elseif ( is_sp_config_type( $typenow ) ) {
84
- $this->highlight_admin_menu( 'sportspress', 'sportspress-config' );
85
- } elseif ( $typenow == 'sp_calendar' ) {
86
- $this->highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' );
87
- } elseif ( $typenow == 'sp_table' ) {
88
- $this->highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );
89
- } elseif ( $typenow == 'sp_list' ) {
90
- $this->highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' );
 
 
 
91
  }
92
- }
93
 
94
- /**
95
- * Renames admin menu items.
96
- *
97
- * @access public
98
- * @return void
99
- */
100
- public function menu_rename() {
101
- global $menu, $submenu;
 
 
 
 
 
102
 
103
- if ( isset( $submenu['sportspress'] ) && isset( $submenu['sportspress'][0] ) && isset( $submenu['sportspress'][0][0] ) )
104
- $submenu['sportspress'][0][0] = __( 'Settings', 'sportspress' );
105
- }
 
 
 
 
 
106
 
107
- public function parent_file( $parent_file ) {
108
- global $current_screen;
109
- $taxonomy = $current_screen->taxonomy;
110
- if ( in_array( $taxonomy, array( 'sp_league', 'sp_season' ) ) )
111
- $parent_file = 'sportspress';
112
- return $parent_file;
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
- /**
116
- * Reorder the SP menu items in admin.
117
- *
118
- * @param mixed $menu_order
119
- * @return array
120
- */
121
- public function menu_order( $menu_order ) {
122
- // Initialize our custom order array
123
- $sportspress_menu_order = array();
124
-
125
- // Get the index of our custom separator
126
- $sportspress_separator = array_search( 'separator-sportspress', $menu_order );
127
-
128
- // Get index of menu items
129
- $sportspress_event = array_search( 'edit.php?post_type=sp_event', $menu_order );
130
- $sportspress_team = array_search( 'edit.php?post_type=sp_team', $menu_order );
131
- $sportspress_player = array_search( 'edit.php?post_type=sp_player', $menu_order );
132
- $sportspress_staff = array_search( 'edit.php?post_type=sp_staff', $menu_order );
133
-
134
- // Loop through menu order and do some rearranging
135
- foreach ( $menu_order as $index => $item ):
136
-
137
- if ( ( ( 'sportspress' ) == $item ) ):
138
- $sportspress_menu_order[] = 'separator-sportspress';
139
- $sportspress_menu_order[] = $item;
140
- $sportspress_menu_order[] = 'edit.php?post_type=sp_event';
141
- $sportspress_menu_order[] = 'edit.php?post_type=sp_team';
142
- $sportspress_menu_order[] = 'edit.php?post_type=sp_player';
143
- $sportspress_menu_order[] = 'edit.php?post_type=sp_staff';
144
- unset( $menu_order[ $sportspress_separator ] );
145
- unset( $menu_order[ $sportspress_event ] );
146
- unset( $menu_order[ $sportspress_team ] );
147
- unset( $menu_order[ $sportspress_player ] );
148
- unset( $menu_order[ $sportspress_staff ] );
149
-
150
- // Apply to added menu items
151
- $menu_items = apply_filters( 'sportspress_menu_items', array() );
152
- foreach ( $menu_items as $menu_item ):
153
- $sportspress_menu_order[] = $menu_item;
154
- $index = array_search( $menu_item, $menu_order );
155
- unset( $menu_order[ $index ] );
156
- endforeach;
157
-
158
- elseif ( !in_array( $item, array( 'separator-sportspress' ) ) ) :
159
- $sportspress_menu_order[] = $item;
160
  endif;
161
 
162
- endforeach;
 
 
 
 
 
163
 
164
- // Return order
165
- return $sportspress_menu_order;
166
- }
 
 
167
 
168
- /**
169
- * custom_menu_order
170
- * @return bool
171
- */
172
- public function custom_menu_order() {
173
- if ( ! current_user_can( 'manage_sportspress' ) )
174
- return false;
175
- return true;
176
- }
177
 
178
- /**
179
- * Clean the SP menu items in admin.
180
- */
181
- public function menu_clean() {
182
- global $menu, $submenu, $current_user;
183
-
184
- // Find where our separator is in the menu
185
- foreach( $menu as $key => $data ):
186
- if ( is_array( $data ) && array_key_exists( 2, $data ) && $data[2] == 'edit.php?post_type=sp_separator' )
187
- $separator_position = $key;
188
- endforeach;
189
-
190
- // Swap our separator post type with a menu separator
191
- if ( isset( $separator_position ) ):
192
- $menu[ $separator_position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
193
- endif;
194
-
195
- // Remove "Leagues" and "Seasons" links from Events submenu
196
- if ( isset( $submenu['edit.php?post_type=sp_event'] ) ):
197
- $submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_leagues' ) );
198
- $submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_seasons' ) );
199
- endif;
200
-
201
- // Remove "Venues", "Leagues" and "Seasons" links from Teams submenu
202
- if ( isset( $submenu['edit.php?post_type=sp_team'] ) ):
203
- $submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_venues' ) );
204
- $submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_leagues' ) );
205
- $submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_seasons' ) );
206
- endif;
207
-
208
- // Remove "Leagues" and "Seasons" links from Players submenu
209
- if ( isset( $submenu['edit.php?post_type=sp_player'] ) ):
210
- $submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_leagues' ) );
211
- $submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_seasons' ) );
212
- endif;
213
-
214
- // Remove "Leagues" and "Seasons" links from Staff submenu
215
- if ( isset( $submenu['edit.php?post_type=sp_staff'] ) ):
216
- $submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_leagues' ) );
217
- $submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_seasons' ) );
218
- endif;
219
-
220
- $user_roles = $current_user->roles;
221
- $user_role = array_shift($user_roles);
222
-
223
- if ( in_array( $user_role, array( 'sp_player', 'sp_staff', 'sp_event_manager', 'sp_team_manager' ) ) ):
224
- remove_menu_page( 'upload.php' );
225
- remove_menu_page( 'edit-comments.php' );
226
- remove_menu_page( 'tools.php' );
227
- endif;
228
- }
229
 
230
- /**
231
- * Init the config page
232
- */
233
- public function config_page() {
234
- include( 'views/html-admin-config.php' );
235
- }
236
 
237
- /**
238
- * Init the settings page
239
- */
240
- public function settings_page() {
241
- include_once( 'class-sp-admin-settings.php' );
242
- SP_Admin_Settings::output();
243
- }
244
 
245
- public function remove_add_new( $arr = array() ) {
246
- return $arr[0] != __( 'Add New', 'sportspress' );
247
- }
 
 
 
 
248
 
249
- public function remove_leagues( $arr = array() ) {
250
- return $arr[0] != __( 'Leagues', 'sportspress' );
251
- }
252
 
253
- public function remove_positions( $arr = array() ) {
254
- return $arr[0] != __( 'Positions', 'sportspress' );
255
- }
256
 
257
- public function remove_seasons( $arr = array() ) {
258
- return $arr[0] != __( 'Seasons', 'sportspress' );
259
- }
260
 
261
- public function remove_venues( $arr = array() ) {
262
- return $arr[0] != __( 'Venues', 'sportspress' );
263
- }
264
 
265
- public static function highlight_admin_menu( $p = 'sportspress', $s = 'sportspress' ) {
266
- global $parent_file, $submenu_file;
267
- $parent_file = $p;
268
- $submenu_file = $s;
269
- }
270
 
271
- public static function sitemap_taxonomy_post_types( $post_types = array(), $taxonomy ) {
272
- $post_types = array_intersect( $post_types, sp_primary_post_types() );
273
- // Remove teams from venues taxonomy post type array
274
- if ( $taxonomy === 'sp_venue' && ( $key = array_search( 'sp_team', $post_types ) ) !== false ):
275
- unset( $post_types[ $key ] );
276
- endif;
277
 
278
- return $post_types;
 
 
 
 
 
 
 
 
279
  }
280
- }
281
 
282
  endif;
283
 
2
  /**
3
  * Setup menus in WP admin.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( ! class_exists( 'SP_Admin_Menus' ) ) :
16
 
 
 
 
 
 
17
  /**
18
+ * SP_Admin_Menus Class
19
  */
20
+ class SP_Admin_Menus {
21
+
22
+ /**
23
+ * Hook in tabs.
24
+ */
25
+ public function __construct() {
26
+ add_filter( 'admin_menu', array( $this, 'menu_clean' ), 5 );
27
+ add_action( 'admin_menu', array( $this, 'admin_menu' ), 6 );
28
+ add_action( 'admin_menu', array( $this, 'config_menu' ), 7 );
29
+ add_action( 'admin_menu', array( $this, 'leagues_menu' ), 20 );
30
+ add_action( 'admin_menu', array( $this, 'seasons_menu' ), 21 );
31
+
32
+ add_action( 'admin_head', array( $this, 'menu_highlight' ) );
33
+ add_action( 'admin_head', array( $this, 'menu_rename' ) );
34
+ add_action( 'parent_file', array( $this, 'parent_file' ) );
35
+ add_filter( 'menu_order', array( $this, 'menu_order' ) );
36
+ add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
37
+ add_filter( 'sportspress_sitemap_taxonomy_post_types', array( $this, 'sitemap_taxonomy_post_types' ), 10, 2 );
38
+ }
39
 
40
+ /**
41
+ * Add menu item
42
+ */
43
+ public function admin_menu() {
44
+ global $menu;
45
 
46
+ if ( current_user_can( 'manage_sportspress' ) ) {
47
+ $menu[] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
48
+ }
49
 
50
+ $main_page = add_menu_page( esc_attr__( 'SportsPress', 'sportspress' ), esc_attr__( 'SportsPress', 'sportspress' ), 'manage_sportspress', 'sportspress', array( $this, 'settings_page' ), apply_filters( 'sportspress_menu_icon', null ), '51.5' );
51
+ }
52
 
53
+ /**
54
+ * Add menu item
55
+ */
56
+ public function config_menu() {
57
+ add_submenu_page( 'sportspress', esc_attr__( 'Configure', 'sportspress' ), esc_attr__( 'Configure', 'sportspress' ), 'manage_sportspress', 'sportspress-config', array( $this, 'config_page' ) );
58
+ }
59
 
60
+ /**
61
+ * Add menu item
62
+ */
63
+ public function leagues_menu() {
64
+ add_submenu_page( 'sportspress', esc_attr__( 'Leagues', 'sportspress' ), esc_attr__( 'Leagues', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_league' );
65
+ }
66
 
67
+ /**
68
+ * Add menu item
69
+ */
70
+ public function seasons_menu() {
71
+ add_submenu_page( 'sportspress', esc_attr__( 'Seasons', 'sportspress' ), esc_attr__( 'Seasons', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_season' );
72
+ }
73
 
74
+ /**
75
+ * Highlights the correct top level admin menu item for post type add screens.
76
+ *
77
+ * @access public
78
+ * @return void
79
+ */
80
+ public function menu_highlight() {
81
+ global $typenow;
82
+ $screen = get_current_screen();
83
+ if ( ! is_object( $screen ) ) {
84
+ return;
85
+ }
86
+ if ( $screen->id == 'sp_role' ) {
87
+ $this->highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit-tags.php?taxonomy=sp_role&post_type=sp_staff' );
88
+ } elseif ( is_sp_config_type( $typenow ) ) {
89
+ $this->highlight_admin_menu( 'sportspress', 'sportspress-config' );
90
+ } elseif ( $typenow == 'sp_calendar' ) {
91
+ $this->highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' );
92
+ } elseif ( $typenow == 'sp_table' ) {
93
+ $this->highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );
94
+ } elseif ( $typenow == 'sp_list' ) {
95
+ $this->highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' );
96
+ }
97
  }
 
98
 
99
+ /**
100
+ * Renames admin menu items.
101
+ *
102
+ * @access public
103
+ * @return void
104
+ */
105
+ public function menu_rename() {
106
+ global $menu, $submenu;
107
+
108
+ if ( isset( $submenu['sportspress'] ) && isset( $submenu['sportspress'][0] ) && isset( $submenu['sportspress'][0][0] ) ) {
109
+ $submenu['sportspress'][0][0] = esc_attr__( 'Settings', 'sportspress' );
110
+ }
111
+ }
112
 
113
+ public function parent_file( $parent_file ) {
114
+ global $current_screen;
115
+ $taxonomy = $current_screen->taxonomy;
116
+ if ( in_array( $taxonomy, array( 'sp_league', 'sp_season' ) ) ) {
117
+ $parent_file = 'sportspress';
118
+ }
119
+ return $parent_file;
120
+ }
121
 
122
+ /**
123
+ * Reorder the SP menu items in admin.
124
+ *
125
+ * @param mixed $menu_order
126
+ * @return array
127
+ */
128
+ public function menu_order( $menu_order ) {
129
+ // Initialize our custom order array
130
+ $sportspress_menu_order = array();
131
+
132
+ // Get the index of our custom separator
133
+ $sportspress_separator = array_search( 'separator-sportspress', $menu_order );
134
+
135
+ // Get index of menu items
136
+ $sportspress_event = array_search( 'edit.php?post_type=sp_event', $menu_order );
137
+ $sportspress_team = array_search( 'edit.php?post_type=sp_team', $menu_order );
138
+ $sportspress_player = array_search( 'edit.php?post_type=sp_player', $menu_order );
139
+ $sportspress_staff = array_search( 'edit.php?post_type=sp_staff', $menu_order );
140
+
141
+ // Loop through menu order and do some rearranging
142
+ foreach ( $menu_order as $index => $item ) :
143
+
144
+ if ( ( ( 'sportspress' ) == $item ) ) :
145
+ $sportspress_menu_order[] = 'separator-sportspress';
146
+ $sportspress_menu_order[] = $item;
147
+ $sportspress_menu_order[] = 'edit.php?post_type=sp_event';
148
+ $sportspress_menu_order[] = 'edit.php?post_type=sp_team';
149
+ $sportspress_menu_order[] = 'edit.php?post_type=sp_player';
150
+ $sportspress_menu_order[] = 'edit.php?post_type=sp_staff';
151
+ unset( $menu_order[ $sportspress_separator ] );
152
+ unset( $menu_order[ $sportspress_event ] );
153
+ unset( $menu_order[ $sportspress_team ] );
154
+ unset( $menu_order[ $sportspress_player ] );
155
+ unset( $menu_order[ $sportspress_staff ] );
156
+
157
+ // Apply to added menu items
158
+ $menu_items = apply_filters( 'sportspress_menu_items', array() );
159
+ foreach ( $menu_items as $menu_item ) :
160
+ $sportspress_menu_order[] = $menu_item;
161
+ $index = array_search( $menu_item, $menu_order );
162
+ unset( $menu_order[ $index ] );
163
+ endforeach;
164
+
165
+ elseif ( ! in_array( $item, array( 'separator-sportspress' ) ) ) :
166
+ $sportspress_menu_order[] = $item;
167
+ endif;
168
+
169
+ endforeach;
170
+
171
+ // Return order
172
+ return $sportspress_menu_order;
173
+ }
174
 
175
+ /**
176
+ * custom_menu_order
177
+ *
178
+ * @return bool
179
+ */
180
+ public function custom_menu_order() {
181
+ if ( ! current_user_can( 'manage_sportspress' ) ) {
182
+ return false;
183
+ }
184
+ return true;
185
+ }
186
+
187
+ /**
188
+ * Clean the SP menu items in admin.
189
+ */
190
+ public function menu_clean() {
191
+ global $menu, $submenu, $current_user;
192
+
193
+ // Find where our separator is in the menu
194
+ foreach ( $menu as $key => $data ) :
195
+ if ( is_array( $data ) && array_key_exists( 2, $data ) && $data[2] == 'edit.php?post_type=sp_separator' ) {
196
+ $separator_position = $key;
197
+ }
198
+ endforeach;
199
+
200
+ // Swap our separator post type with a menu separator
201
+ if ( isset( $separator_position ) ) :
202
+ $menu[ $separator_position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
203
+ endif;
204
+
205
+ // Remove "Leagues" and "Seasons" links from Events submenu
206
+ if ( isset( $submenu['edit.php?post_type=sp_event'] ) ) :
207
+ $submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_leagues' ) );
208
+ $submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_seasons' ) );
 
 
 
 
 
 
 
 
 
 
 
209
  endif;
210
 
211
+ // Remove "Venues", "Leagues" and "Seasons" links from Teams submenu
212
+ if ( isset( $submenu['edit.php?post_type=sp_team'] ) ) :
213
+ $submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_venues' ) );
214
+ $submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_leagues' ) );
215
+ $submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_seasons' ) );
216
+ endif;
217
 
218
+ // Remove "Leagues" and "Seasons" links from Players submenu
219
+ if ( isset( $submenu['edit.php?post_type=sp_player'] ) ) :
220
+ $submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_leagues' ) );
221
+ $submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_seasons' ) );
222
+ endif;
223
 
224
+ // Remove "Leagues" and "Seasons" links from Staff submenu
225
+ if ( isset( $submenu['edit.php?post_type=sp_staff'] ) ) :
226
+ $submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_leagues' ) );
227
+ $submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_seasons' ) );
228
+ endif;
 
 
 
 
229
 
230
+ $user_roles = $current_user->roles;
231
+ $user_role = array_shift( $user_roles );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
 
233
+ if ( in_array( $user_role, array( 'sp_player', 'sp_staff', 'sp_event_manager', 'sp_team_manager' ) ) ) :
234
+ remove_menu_page( 'upload.php' );
235
+ remove_menu_page( 'edit-comments.php' );
236
+ remove_menu_page( 'tools.php' );
237
+ endif;
238
+ }
239
 
240
+ /**
241
+ * Init the config page
242
+ */
243
+ public function config_page() {
244
+ include 'views/html-admin-config.php';
245
+ }
 
246
 
247
+ /**
248
+ * Init the settings page
249
+ */
250
+ public function settings_page() {
251
+ include_once 'class-sp-admin-settings.php';
252
+ SP_Admin_Settings::output();
253
+ }
254
 
255
+ public function remove_add_new( $arr = array() ) {
256
+ return $arr[0] != esc_attr__( 'Add New', 'sportspress' );
257
+ }
258
 
259
+ public function remove_leagues( $arr = array() ) {
260
+ return $arr[0] != esc_attr__( 'Leagues', 'sportspress' );
261
+ }
262
 
263
+ public function remove_positions( $arr = array() ) {
264
+ return $arr[0] != esc_attr__( 'Positions', 'sportspress' );
265
+ }
266
 
267
+ public function remove_seasons( $arr = array() ) {
268
+ return $arr[0] != esc_attr__( 'Seasons', 'sportspress' );
269
+ }
270
 
271
+ public function remove_venues( $arr = array() ) {
272
+ return $arr[0] != esc_attr__( 'Venues', 'sportspress' );
273
+ }
 
 
274
 
275
+ public static function highlight_admin_menu( $p = 'sportspress', $s = 'sportspress' ) {
276
+ global $parent_file, $submenu_file;
277
+ $parent_file = $p;
278
+ $submenu_file = $s;
279
+ }
 
280
 
281
+ public static function sitemap_taxonomy_post_types( $post_types = array(), $taxonomy = 'sp_venue' ) {
282
+ $post_types = array_intersect( $post_types, sp_primary_post_types() );
283
+ // Remove teams from venues taxonomy post type array
284
+ if ( $taxonomy === 'sp_venue' && ( $key = array_search( 'sp_team', $post_types ) ) !== false ) :
285
+ unset( $post_types[ $key ] );
286
+ endif;
287
+
288
+ return $post_types;
289
+ }
290
  }
 
291
 
292
  endif;
293
 
includes/admin/class-sp-admin-notices.php CHANGED
@@ -2,145 +2,149 @@
2
  /**
3
  * Display notices in admin.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin
8
  * @version 2.3
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( ! class_exists( 'SP_Admin_Notices' ) ) :
14
 
15
- /**
16
- * SP_Admin_Notices Class
17
- */
18
- class SP_Admin_Notices {
19
-
20
  /**
21
- * Hook in tabs.
22
  */
23
- public function __construct() {
24
- add_action( 'switch_theme', array( $this, 'reset_admin_notices' ) );
25
- add_action( 'sportspress_updated', array( $this, 'reset_admin_notices' ) );
26
- add_action( 'admin_print_styles', array( $this, 'add_notices' ) );
27
- }
 
 
 
 
 
28
 
29
- /**
30
- * Reset notices for themes when switched or a new version of SP is installed
31
- */
32
- public function reset_admin_notices() {
33
- update_option( 'sportspress_admin_notices', array( 'template_files', 'theme_support' ) );
34
- }
35
 
36
- /**
37
- * Add notices + styles if needed.
38
- */
39
- public function add_notices() {
40
- $screen = get_current_screen();
41
- $notices = get_option( 'sportspress_admin_notices', array() );
42
 
43
- if ( ! is_object( $screen ) ) return;
 
 
44
 
45
- if ( ! get_option( 'sportspress_completed_setup' ) && ! in_array( $screen->id, array( 'dashboard_page_sp-about', 'dashboard_page_sp-credits', 'dashboard_page_sp-translators' ) ) ) {
46
- wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
47
- add_action( 'admin_notices', array( $this, 'setup_notice' ) );
48
- }
49
 
50
- if ( 'post' == $screen->base ) {
51
- $post_id = get_the_ID();
52
- if ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) {
53
- add_action( 'admin_notices', array( $this, 'no_access_notice' ) );
 
54
  }
55
- }
56
 
57
- if ( ! empty( $_GET['hide_theme_support_notice'] ) ) {
58
- $notices = array_diff( $notices, array( 'theme_support' ) );
59
- update_option( 'sportspress_admin_notices', $notices );
60
- }
61
 
62
- if ( ! empty( $_GET['hide_template_files_notice'] ) ) {
63
- $notices = array_diff( $notices, array( 'template_files' ) );
64
- update_option( 'sportspress_admin_notices', $notices );
65
- }
 
 
 
66
 
67
- if ( in_array( 'theme_support', $notices ) && ! current_theme_supports( 'sportspress' ) && ! in_array( $screen->id, array( 'toplevel_page_sportspress', 'dashboard_page_sp-about', 'dashboard_page_sp-credits', 'dashboard_page_sp-translators' ) ) ) {
68
- $template = get_option( 'template' );
 
 
 
69
 
70
- if ( ! in_array( $template, array( 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) {
71
- wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
72
- add_action( 'admin_notices', array( $this, 'theme_check_notice' ) );
73
  }
74
  }
75
 
76
- if ( in_array( 'template_files', $notices ) ) {
77
- wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
78
- add_action( 'admin_notices', array( $this, 'template_file_check_notice' ) );
 
 
79
  }
80
- }
81
-
82
- /**
83
- * Show the setup notices
84
- */
85
- public function setup_notice() {
86
- include( 'views/html-notice-install.php' );
87
- }
88
-
89
- /**
90
- * Displays a notice when the user doesn't have access to edit a post type
91
- */
92
- public function no_access_notice() {
93
- include( 'views/html-notice-no-access.php' );
94
- }
95
 
96
- /**
97
- * Show the Theme Check notice
98
- */
99
- public function theme_check_notice() {
100
- include( 'views/html-notice-theme-support.php' );
101
- }
102
 
103
- /**
104
- * Show a notice highlighting bad template files
105
- */
106
- public function template_file_check_notice() {
107
- if ( isset( $_GET['page'] ) && 'sportspress' == $_GET['page'] && isset( $_GET['tab'] ) && 'status' == $_GET['tab'] ) {
108
- return;
109
  }
110
 
111
- $status = include( 'class-sp-admin-status.php' );
112
- $core_templates = $status->scan_template_files( SP()->plugin_path() . '/templates' );
113
- $outdated = false;
114
-
115
- foreach ( $core_templates as $file ) {
116
- $theme_file = false;
117
- if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
118
- $theme_file = get_stylesheet_directory() . '/' . $file;
119
- } elseif ( file_exists( get_stylesheet_directory() . '/sportspress/' . $file ) ) {
120
- $theme_file = get_stylesheet_directory() . '/sportspress/' . $file;
121
- } elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
122
- $theme_file = get_template_directory() . '/' . $file;
123
- } elseif( file_exists( get_template_directory() . '/sportspress/' . $file ) ) {
124
- $theme_file = get_template_directory() . '/sportspress/' . $file;
125
  }
126
 
127
- if ( $theme_file ) {
128
- $core_version = $status->get_file_version( SP()->plugin_path() . '/templates/' . $file );
129
- $theme_version = $status->get_file_version( $theme_file );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
- if ( $core_version && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) {
132
- $outdated = true;
133
- break;
 
134
  }
135
  }
136
- }
137
 
138
- if ( $outdated ) {
139
- include( 'views/html-notice-template-check.php' );
 
140
  }
141
  }
142
- }
143
 
144
  endif;
145
 
146
- return new SP_Admin_Notices();
2
  /**
3
  * Display notices in admin.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin
8
  * @version 2.3
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( ! class_exists( 'SP_Admin_Notices' ) ) :
16
 
 
 
 
 
 
17
  /**
18
+ * SP_Admin_Notices Class
19
  */
20
+ class SP_Admin_Notices {
21
+
22
+ /**
23
+ * Hook in tabs.
24
+ */
25
+ public function __construct() {
26
+ add_action( 'switch_theme', array( $this, 'reset_admin_notices' ) );
27
+ add_action( 'sportspress_updated', array( $this, 'reset_admin_notices' ) );
28
+ add_action( 'admin_print_styles', array( $this, 'add_notices' ) );
29
+ }
30
 
31
+ /**
32
+ * Reset notices for themes when switched or a new version of SP is installed
33
+ */
34
+ public function reset_admin_notices() {
35
+ update_option( 'sportspress_admin_notices', array( 'template_files', 'theme_support' ) );
36
+ }
37
 
38
+ /**
39
+ * Add notices + styles if needed.
40
+ */
41
+ public function add_notices() {
42
+ $screen = get_current_screen();
43
+ $notices = get_option( 'sportspress_admin_notices', array() );
44
 
45
+ if ( ! is_object( $screen ) ) {
46
+ return;
47
+ }
48
 
49
+ if ( ! get_option( 'sportspress_completed_setup' ) && ! in_array( $screen->id, array( 'dashboard_page_sp-about', 'dashboard_page_sp-credits', 'dashboard_page_sp-translators' ) ) ) {
50
+ wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
51
+ add_action( 'admin_notices', array( $this, 'setup_notice' ) );
52
+ }
53
 
54
+ if ( 'post' == $screen->base ) {
55
+ $post_id = get_the_ID();
56
+ if ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) {
57
+ add_action( 'admin_notices', array( $this, 'no_access_notice' ) );
58
+ }
59
  }
 
60
 
61
+ if ( ! empty( $_GET['hide_theme_support_notice'] ) ) {
62
+ $notices = array_diff( $notices, array( 'theme_support' ) );
63
+ update_option( 'sportspress_admin_notices', $notices );
64
+ }
65
 
66
+ if ( ! empty( $_GET['hide_template_files_notice'] ) ) {
67
+ $notices = array_diff( $notices, array( 'template_files' ) );
68
+ update_option( 'sportspress_admin_notices', $notices );
69
+ }
70
+
71
+ if ( in_array( 'theme_support', $notices ) && ! current_theme_supports( 'sportspress' ) && ! in_array( $screen->id, array( 'toplevel_page_sportspress', 'dashboard_page_sp-about', 'dashboard_page_sp-credits', 'dashboard_page_sp-translators' ) ) ) {
72
+ $template = get_option( 'template' );
73
 
74
+ if ( ! in_array( $template, array( 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) {
75
+ wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
76
+ add_action( 'admin_notices', array( $this, 'theme_check_notice' ) );
77
+ }
78
+ }
79
 
80
+ if ( in_array( 'template_files', $notices ) ) {
81
+ wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
82
+ add_action( 'admin_notices', array( $this, 'template_file_check_notice' ) );
83
  }
84
  }
85
 
86
+ /**
87
+ * Show the setup notices
88
+ */
89
+ public function setup_notice() {
90
+ include 'views/html-notice-install.php';
91
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
+ /**
94
+ * Displays a notice when the user doesn't have access to edit a post type
95
+ */
96
+ public function no_access_notice() {
97
+ include 'views/html-notice-no-access.php';
98
+ }
99
 
100
+ /**
101
+ * Show the Theme Check notice
102
+ */
103
+ public function theme_check_notice() {
104
+ include 'views/html-notice-theme-support.php';
 
105
  }
106
 
107
+ /**
108
+ * Show a notice highlighting bad template files
109
+ */
110
+ public function template_file_check_notice() {
111
+ if ( isset( $_GET['page'] ) && 'sportspress' == $_GET['page'] && isset( $_GET['tab'] ) && 'status' == $_GET['tab'] ) {
112
+ return;
 
 
 
 
 
 
 
 
113
  }
114
 
115
+ $status = include 'class-sp-admin-status.php';
116
+ $core_templates = $status->scan_template_files( SP()->plugin_path() . '/templates' );
117
+ $outdated = false;
118
+
119
+ foreach ( $core_templates as $file ) {
120
+ $theme_file = false;
121
+ if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
122
+ $theme_file = get_stylesheet_directory() . '/' . $file;
123
+ } elseif ( file_exists( get_stylesheet_directory() . '/sportspress/' . $file ) ) {
124
+ $theme_file = get_stylesheet_directory() . '/sportspress/' . $file;
125
+ } elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
126
+ $theme_file = get_template_directory() . '/' . $file;
127
+ } elseif ( file_exists( get_template_directory() . '/sportspress/' . $file ) ) {
128
+ $theme_file = get_template_directory() . '/sportspress/' . $file;
129
+ }
130
+
131
+ if ( $theme_file ) {
132
+ $core_version = $status->get_file_version( SP()->plugin_path() . '/templates/' . $file );
133
+ $theme_version = $status->get_file_version( $theme_file );
134
 
135
+ if ( $core_version && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) {
136
+ $outdated = true;
137
+ break;
138
+ }
139
  }
140
  }
 
141
 
142
+ if ( $outdated ) {
143
+ include 'views/html-notice-template-check.php';
144
+ }
145
  }
146
  }
 
147
 
148
  endif;
149
 
150
+ return new SP_Admin_Notices();
includes/admin/class-sp-admin-permalink-settings.php CHANGED
@@ -2,102 +2,111 @@
2
  /**
3
  * Adds settings to the permalinks admin settings page.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin
8
- * @version 2.5
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( ! class_exists( 'SP_Admin_Permalink_Settings' ) ) :
14
 
15
- /**
16
- * SP_Admin_Permalink_Settings Class
17
- */
18
- class SP_Admin_Permalink_Settings {
19
-
20
  /**
21
- * Hook in tabs.
22
  */
23
- public function __construct() {
24
- $this->slugs = apply_filters( 'sportspress_permalink_slugs', array(
25
- array( 'event', __( 'Events', 'sportspress' ) ),
26
- array( 'venue', __( 'Venues', 'sportspress' ) ),
27
- array( 'calendar', __( 'Calendars', 'sportspress' ) ),
28
- array( 'team', __( 'Teams', 'sportspress' ) ),
29
- array( 'league', __( 'Leagues', 'sportspress' ) ),
30
- array( 'season', __( 'Seasons', 'sportspress' ) ),
31
- array( 'table', __( 'League Tables', 'sportspress' ) ),
32
- array( 'player', __( 'Players', 'sportspress' ) ),
33
- array( 'position', __( 'Positions', 'sportspress' ) ),
34
- array( 'list', __( 'Player Lists', 'sportspress' ) ),
35
- array( 'staff', __( 'Staff', 'sportspress' ) ),
36
- ) );
37
 
38
- add_action( 'admin_init', array( $this, 'settings_init' ) );
39
- add_action( 'admin_init', array( $this, 'settings_save' ) );
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
- /**
43
- * Init our settings
44
- */
45
- public function settings_init() {
46
- // Add a section to the permalinks page
47
- add_settings_section( 'sportspress-permalink', __( 'SportsPress', 'sportspress' ), array( $this, 'settings' ), 'permalink' );
48
 
49
- // Add our settings
50
- foreach ( $this->slugs as $slug ):
51
- add_settings_field(
52
- $slug[0], // id
53
- $slug[1], // setting title
54
- array( $this, 'slug_input' ), // display callback
55
- 'permalink', // settings page
56
- 'sportspress-permalink' // settings section
57
- );
58
- endforeach;
59
- }
60
 
61
- /**
62
- * Show a slug input box.
63
- */
64
- public function slug_input() {
65
- $slug = array_shift( $this->slugs );
66
- $key = $slug[0];
67
- $text = get_option( 'sportspress_' . $key . '_slug', null );
68
- ?><fieldset><input id="sportspress_<?php echo $key; ?>_slug" name="sportspress_<?php echo $key; ?>_slug" type="text" class="regular-text code" value="<?php echo $text; ?>" placeholder="<?php echo $key; ?>"></fieldset><?php
69
- }
 
 
70
 
71
- /**
72
- * Show the settings
73
- */
74
- public function settings() {
75
- echo wpautop( __( 'These settings control the permalinks used for SportsPress. These settings only apply when <strong>not using "default" permalinks above</strong>.', 'sportspress' ) );
76
- }
 
 
 
 
77
 
78
- /**
79
- * Save the settings
80
- */
81
- public function settings_save() {
82
- if ( ! is_admin() )
83
- return;
84
 
85
- if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['sportspress_event_slug'] ) ):
86
- foreach ( $this->slugs as $slug ):
87
- $key = 'sportspress_' . $slug[0] . '_slug';
88
- $value = null;
89
- if ( isset( $_POST[ $key ] ) )
90
- $value = sanitize_text_field( $_POST[ $key ] );
91
- if ( empty( $value ) )
92
- delete_option( $key );
93
- else
94
- update_option( $key, $value );
95
- endforeach;
96
- sp_flush_rewrite_rules();
97
- endif;
 
 
 
 
 
 
 
 
 
 
 
98
  }
99
- }
100
 
101
  endif;
102
 
103
- return new SP_Admin_Permalink_Settings();
2
  /**
3
  * Adds settings to the permalinks admin settings page.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( ! class_exists( 'SP_Admin_Permalink_Settings' ) ) :
16
 
 
 
 
 
 
17
  /**
18
+ * SP_Admin_Permalink_Settings Class
19
  */
20
+ class SP_Admin_Permalink_Settings {
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ /**
23
+ * Hook in tabs.
24
+ */
25
+ public function __construct() {
26
+ $this->slugs = apply_filters(
27
+ 'sportspress_permalink_slugs',
28
+ array(
29
+ array( 'event', esc_attr__( 'Events', 'sportspress' ) ),
30
+ array( 'venue', esc_attr__( 'Venues', 'sportspress' ) ),
31
+ array( 'calendar', esc_attr__( 'Calendars', 'sportspress' ) ),
32
+ array( 'team', esc_attr__( 'Teams', 'sportspress' ) ),
33
+ array( 'league', esc_attr__( 'Leagues', 'sportspress' ) ),
34
+ array( 'season', esc_attr__( 'Seasons', 'sportspress' ) ),
35
+ array( 'table', esc_attr__( 'League Tables', 'sportspress' ) ),
36
+ array( 'player', esc_attr__( 'Players', 'sportspress' ) ),
37
+ array( 'position', esc_attr__( 'Positions', 'sportspress' ) ),
38
+ array( 'list', esc_attr__( 'Player Lists', 'sportspress' ) ),
39
+ array( 'staff', esc_attr__( 'Staff', 'sportspress' ) ),
40
+ )
41
+ );
42
 
43
+ add_action( 'admin_init', array( $this, 'settings_init' ) );
44
+ add_action( 'admin_init', array( $this, 'settings_save' ) );
45
+ }
 
 
 
46
 
47
+ /**
48
+ * Init our settings
49
+ */
50
+ public function settings_init() {
51
+ // Add a section to the permalinks page
52
+ add_settings_section( 'sportspress-permalink', esc_attr__( 'SportsPress', 'sportspress' ), array( $this, 'settings' ), 'permalink' );
 
 
 
 
 
53
 
54
+ // Add our settings
55
+ foreach ( $this->slugs as $slug ) :
56
+ add_settings_field(
57
+ $slug[0], // id
58
+ $slug[1], // setting title
59
+ array( $this, 'slug_input' ), // display callback
60
+ 'permalink', // settings page
61
+ 'sportspress-permalink' // settings section
62
+ );
63
+ endforeach;
64
+ }
65
 
66
+ /**
67
+ * Show a slug input box.
68
+ */
69
+ public function slug_input() {
70
+ $slug = array_shift( $this->slugs );
71
+ $key = $slug[0];
72
+ $text = get_option( 'sportspress_' . $key . '_slug', null );
73
+ ?><fieldset><input id="sportspress_<?php echo esc_attr( $key ); ?>_slug" name="sportspress_<?php echo esc_attr( $key ); ?>_slug" type="text" class="regular-text code" value="<?php echo esc_attr( $text ); ?>" placeholder="<?php echo esc_attr( $key ); ?>"></fieldset>
74
+ <?php
75
+ }
76
 
77
+ /**
78
+ * Show the settings
79
+ */
80
+ public function settings() {
81
+ echo wp_kses_post( wpautop( esc_attr__( 'These settings control the permalinks used for SportsPress. These settings only apply when <strong>not using "default" permalinks above</strong>.', 'sportspress' ) ) );
82
+ }
83
 
84
+ /**
85
+ * Save the settings
86
+ */
87
+ public function settings_save() {
88
+ if ( ! is_admin() ) {
89
+ return;
90
+ }
91
+
92
+ if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['sportspress_event_slug'] ) ) :
93
+ foreach ( $this->slugs as $slug ) :
94
+ $key = 'sportspress_' . $slug[0] . '_slug';
95
+ $value = null;
96
+ if ( isset( $_POST[ $key ] ) ) {
97
+ $value = sanitize_text_field( wp_unslash( $_POST[ $key ] ) );
98
+ }
99
+ if ( empty( $value ) ) {
100
+ delete_option( $key );
101
+ } else {
102
+ update_option( $key, $value );
103
+ }
104
+ endforeach;
105
+ sp_flush_rewrite_rules();
106
+ endif;
107
+ }
108
  }
 
109
 
110
  endif;
111
 
112
+ return new SP_Admin_Permalink_Settings();
includes/admin/class-sp-admin-post-types.php CHANGED
@@ -2,122 +2,126 @@
2
  /**
3
  * Post Types Admin
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin
8
  * @version 2.0
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( ! class_exists( 'SP_Admin_Post_Types' ) ) :
14
 
15
- /**
16
- * SP_Admin_Post_Types Class
17
- */
18
- class SP_Admin_Post_Types {
19
-
20
  /**
21
- * Constructor
22
  */
23
- public function __construct() {
24
- add_action( 'admin_init', array( $this, 'include_post_type_handlers' ) );
25
- add_action( 'save_post', array( $this, 'unflag_post' ) );
26
- add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
27
- add_filter( 'sportspress_meta_boxes', array( $this, 'meta_boxes' ) );
28
- }
 
 
 
 
 
29
 
30
- /**
31
- * Conditonally load classes and functions only needed when viewing a post type.
32
- */
33
- public function include_post_type_handlers() {
34
- include_once( 'post-types/class-sp-admin-meta-boxes.php' );
35
- include_once( 'post-types/class-sp-admin-cpt-result.php' );
36
- include_once( 'post-types/class-sp-admin-cpt-outcome.php' );
37
- include_once( 'post-types/class-sp-admin-cpt-performance.php' );
38
- include_once( 'post-types/class-sp-admin-cpt-column.php' );
39
- include_once( 'post-types/class-sp-admin-cpt-metric.php' );
40
- include_once( 'post-types/class-sp-admin-cpt-statistic.php' );
41
- include_once( 'post-types/class-sp-admin-cpt-event.php' );
42
- include_once( 'post-types/class-sp-admin-cpt-team.php' );
43
- include_once( 'post-types/class-sp-admin-cpt-player.php' );
44
- include_once( 'post-types/class-sp-admin-cpt-staff.php' );
45
- do_action( 'sportspress_include_post_type_handlers' );
46
- }
47
 
48
- /**
49
- * Unflag preset and sample posts.
50
- */
51
- public function unflag_post( $post_id ) {
52
- $post_types = sp_post_types();
53
- $config_types = sp_config_types();
54
- $post_type = get_post_type( $post_id );
55
- if ( in_array( $post_type, $post_types ) ):
56
- delete_post_meta( $post_id, '_sp_sample' );
57
- elseif ( in_array( $post_type, $config_types ) ):
58
- delete_post_meta( $post_id, '_sp_preset' );
59
- endif;
60
- }
61
 
62
- /**
63
- * Change messages when a post type is updated.
64
- *
65
- * @param array $messages
66
- * @return array
67
- */
68
- public function post_updated_messages( $messages ) {
69
- global $typenow, $post;
70
 
71
- if ( is_sp_config_type( $typenow ) ):
72
- $obj = get_post_type_object( $typenow );
73
 
74
- for ( $i = 0; $i <= 10; $i++ ):
75
- $messages['post'][ $i ] = __( 'Settings saved.', 'sportspress' ) .
76
  ' <a href="' . esc_url( admin_url( 'edit.php?post_type=' . $typenow ) ) . '">' .
77
  __( 'View All', 'sportspress' ) . '</a>';
78
- endfor;
79
- elseif ( is_sp_post_type( $typenow ) ):
80
- $obj = get_post_type_object( $typenow );
81
 
82
- $messages['post'][1] = __( 'Changes saved.', 'sportspress' ) .
83
- ' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
84
 
85
- $messages['post'][4] = __( 'Changes saved.', 'sportspress' );
86
 
87
- $messages['post'][6] = __( 'Success!', 'sportspress' ) .
88
- ' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
89
 
90
- $messages['post'][7] = __( 'Changes saved.', 'sportspress' );
91
 
92
- $messages['post'][8] = __( 'Success!', 'sportspress' ) .
93
- ' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
94
- sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
95
 
96
- $messages['post'][9] = sprintf(
97
- __( 'Scheduled for: <b>%1$s</b>.', 'sportspress' ),
98
- date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ) .
99
- ' <a target="_blank" href="' . esc_url( get_permalink($post->ID) ) . '">' .
100
- sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
 
 
101
 
102
- $messages['post'][10] = __( 'Success!', 'sportspress' ) .
103
- ' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
104
- sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
105
- endif;
106
 
107
- return $messages;
108
- }
109
 
110
- /**
111
- * Remove meta boxes as needed
112
- */
113
- public static function meta_boxes( $meta_boxes ) {
114
- if ( 'manual' != get_option( 'sportspress_player_columns', 'auto' ) ) {
115
- unset( $meta_boxes['sp_player']['columns'] );
 
 
116
  }
117
- return $meta_boxes;
118
  }
119
- }
120
 
121
  endif;
122
 
123
- return new SP_Admin_Post_Types();
2
  /**
3
  * Post Types Admin
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin
8
  * @version 2.0
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( ! class_exists( 'SP_Admin_Post_Types' ) ) :
16
 
 
 
 
 
 
17
  /**
18
+ * SP_Admin_Post_Types Class
19
  */
20
+ class SP_Admin_Post_Types {
21
+
22
+ /**
23
+ * Constructor
24
+ */
25
+ public function __construct() {
26
+ add_action( 'admin_init', array( $this, 'include_post_type_handlers' ) );
27
+ add_action( 'save_post', array( $this, 'unflag_post' ) );
28
+ add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
29
+ add_filter( 'sportspress_meta_boxes', array( $this, 'meta_boxes' ) );
30
+ }
31
 
32
+ /**
33
+ * Conditonally load classes and functions only needed when viewing a post type.
34
+ */
35
+ public function include_post_type_handlers() {
36
+ include_once 'post-types/class-sp-admin-meta-boxes.php';
37
+ include_once 'post-types/class-sp-admin-cpt-result.php';
38
+ include_once 'post-types/class-sp-admin-cpt-outcome.php';
39
+ include_once 'post-types/class-sp-admin-cpt-performance.php';
40
+ include_once 'post-types/class-sp-admin-cpt-column.php';
41
+ include_once 'post-types/class-sp-admin-cpt-metric.php';
42
+ include_once 'post-types/class-sp-admin-cpt-statistic.php';
43
+ include_once 'post-types/class-sp-admin-cpt-event.php';
44
+ include_once 'post-types/class-sp-admin-cpt-team.php';
45
+ include_once 'post-types/class-sp-admin-cpt-player.php';
46
+ include_once 'post-types/class-sp-admin-cpt-staff.php';
47
+ do_action( 'sportspress_include_post_type_handlers' );
48
+ }
49
 
50
+ /**
51
+ * Unflag preset and sample posts.
52
+ */
53
+ public function unflag_post( $post_id ) {
54
+ $post_types = sp_post_types();
55
+ $config_types = sp_config_types();
56
+ $post_type = get_post_type( $post_id );
57
+ if ( in_array( $post_type, $post_types ) ) :
58
+ delete_post_meta( $post_id, '_sp_sample' );
59
+ elseif ( in_array( $post_type, $config_types ) ) :
60
+ delete_post_meta( $post_id, '_sp_preset' );
61
+ endif;
62
+ }
63
 
64
+ /**
65
+ * Change messages when a post type is updated.
66
+ *
67
+ * @param array $messages
68
+ * @return array
69
+ */
70
+ public function post_updated_messages( $messages ) {
71
+ global $typenow, $post;
72
 
73
+ if ( is_sp_config_type( $typenow ) ) :
74
+ $obj = get_post_type_object( $typenow );
75
 
76
+ for ( $i = 0; $i <= 10; $i++ ) :
77
+ $messages['post'][ $i ] = esc_attr__( 'Settings saved.', 'sportspress' ) .
78
  ' <a href="' . esc_url( admin_url( 'edit.php?post_type=' . $typenow ) ) . '">' .
79
  __( 'View All', 'sportspress' ) . '</a>';
80
+ endfor;
81
+ elseif ( is_sp_post_type( $typenow ) ) :
82
+ $obj = get_post_type_object( $typenow );
83
 
84
+ $messages['post'][1] = esc_attr__( 'Changes saved.', 'sportspress' ) .
85
+ ' <a href="' . esc_url( get_permalink( $post->ID ) ) . '">' . $obj->labels->view_item . '</a>';
86
 
87
+ $messages['post'][4] = esc_attr__( 'Changes saved.', 'sportspress' );
88
 
89
+ $messages['post'][6] = esc_attr__( 'Success!', 'sportspress' ) .
90
+ ' <a href="' . esc_url( get_permalink( $post->ID ) ) . '">' . $obj->labels->view_item . '</a>';
91
 
92
+ $messages['post'][7] = esc_attr__( 'Changes saved.', 'sportspress' );
93
 
94
+ $messages['post'][8] = esc_attr__( 'Success!', 'sportspress' ) .
95
+ ' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '">' .
96
+ sprintf( esc_attr__( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
97
 
98
+ $messages['post'][9] = sprintf(
99
+ __( 'Scheduled for: <b>%1$s</b>.', 'sportspress' ),
100
+ date_i18n( esc_attr__( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ),
101
+ esc_url( get_permalink( $post->ID ) )
102
+ ) .
103
+ ' <a target="_blank" href="' . esc_url( get_permalink( $post->ID ) ) . '">' .
104
+ sprintf( esc_attr__( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
105
 
106
+ $messages['post'][10] = esc_attr__( 'Success!', 'sportspress' ) .
107
+ ' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '">' .
108
+ sprintf( esc_attr__( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
109
+ endif;
110
 
111
+ return $messages;
112
+ }
113
 
114
+ /**
115
+ * Remove meta boxes as needed
116
+ */
117
+ public static function meta_boxes( $meta_boxes ) {
118
+ if ( 'manual' != get_option( 'sportspress_player_columns', 'auto' ) ) {
119
+ unset( $meta_boxes['sp_player']['columns'] );
120
+ }
121
+ return $meta_boxes;
122
  }
 
123
  }
 
124
 
125
  endif;
126
 
127
+ return new SP_Admin_Post_Types();
includes/admin/class-sp-admin-sample-data.php CHANGED
@@ -4,11 +4,11 @@
4
  *
5
  * The SportsPress admin sample data class stores demo content.
6
  *
7
- * @class SP_Admin_Sample_Data
8
- * @version 2.5
9
- * @package SportsPress/Admin
10
- * @category Class
11
- * @author ThemeBoy
12
  */
13
  class SP_Admin_Sample_Data {
14
 
@@ -23,18 +23,18 @@ class SP_Admin_Sample_Data {
23
 
24
  // Initialize inserted ids array
25
  $inserted_ids = array(
26
- 'sp_league' => array(),
27
- 'sp_season' => array(),
28
- 'sp_venue' => array(),
29
  'sp_position' => array(),
30
- 'sp_role' => array(),
31
- 'sp_event' => array(),
32
  'sp_calendar' => array(),
33
- 'sp_team' => array(),
34
- 'sp_table' => array(),
35
- 'sp_player' => array(),
36
- 'sp_list' => array(),
37
- 'sp_staff' => array(),
38
  );
39
 
40
  // Terms to insert
@@ -44,33 +44,33 @@ class SP_Admin_Sample_Data {
44
  $taxonomies['sp_league'] = array( _x( 'Primary League', 'example', 'sportspress' ), _x( 'Secondary League', 'example', 'sportspress' ) );
45
 
46
  // Seasons
47
- $current_year = date( 'Y' );
48
- $current_year = intval( $current_year );
49
  $taxonomies['sp_season'] = array( $current_year - 1, $current_year, $current_year + 1 );
50
 
51
  // Venues
52
- $taxonomies['sp_venue'] = array(
53
  array(
54
  'name' => 'Bentleigh',
55
  'meta' => array(
56
- 'sp_address' => '12A Bolinda Street, Bentleigh VIC 3204, Australia',
57
- 'sp_latitude' => -37.920537,
58
  'sp_longitude' => 145.043199,
59
  ),
60
  ),
61
  array(
62
  'name' => 'Essendon',
63
  'meta' => array(
64
- 'sp_address' => '74 Napier Street, Essendon VIC 3040, Australia',
65
- 'sp_latitude' => -37.751940,
66
  'sp_longitude' => 144.919549,
67
  ),
68
  ),
69
  array(
70
  'name' => 'Kensington',
71
  'meta' => array(
72
- 'sp_address' => '50 Altona Street, Kensington, Victoria, Australia',
73
- 'sp_latitude' => -37.797789,
74
  'sp_longitude' => 144.924709,
75
  ),
76
  ),
@@ -92,14 +92,21 @@ class SP_Admin_Sample_Data {
92
  }
93
 
94
  // Insert term
95
- $inserted = wp_insert_term( $name, $taxonomy, array( 'description' => $name, 'slug' => sanitize_title( $name ) ) );
 
 
 
 
 
 
 
96
 
97
  // Add meta to term if is array
98
  if ( ! is_wp_error( $inserted ) && is_array( $term ) && array_key_exists( 'meta', $term ) ) {
99
  $t_id = sp_array_value( $inserted, 'term_id', 1 );
100
  $meta = sp_array_value( $term, 'meta' );
101
  update_option( "taxonomy_$t_id", $meta );
102
-
103
  // Add to inserted ids array
104
  $inserted_ids[ $taxonomy ][] = $t_id;
105
  }
@@ -113,15 +120,15 @@ class SP_Admin_Sample_Data {
113
  $teams = array(
114
  array(
115
  'name' => 'Bluebirds',
116
- 'url' => 'http://tboy.co/bluebirds',
117
  ),
118
  array(
119
  'name' => 'Eagles',
120
- 'url' => 'http://tboy.co/eagles',
121
  ),
122
  array(
123
  'name' => 'Kangaroos',
124
- 'url' => 'http://tboy.co/kangaroos',
125
  ),
126
  );
127
 
@@ -160,19 +167,35 @@ class SP_Admin_Sample_Data {
160
  * Insert teams
161
  */
162
  foreach ( $teams as $index => $team ) {
163
- $post['post_title'] = $team['name'];
164
- $post['post_type'] = 'sp_team';
165
- $post['post_status'] = 'publish';
166
- $post['post_content'] = sprintf( $sample_content, __( 'Team', 'sportspress' ), __( 'Teams', 'sportspress' ), add_query_arg( 'post_type', 'sp_team', admin_url( 'edit.php' ) ) );
167
 
168
  // Terms
169
  $post['tax_input'] = array();
170
- $taxonomies = array( 'sp_league', 'sp_season' );
171
  foreach ( $taxonomies as $taxonomy ) {
172
- $post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) );
173
- };
 
 
 
 
 
 
174
 
175
- $post['tax_input']['sp_venue'] = get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $index ) );
 
 
 
 
 
 
 
 
 
 
176
 
177
  // Insert post
178
  $id = wp_insert_post( $post );
@@ -189,13 +212,13 @@ class SP_Admin_Sample_Data {
189
 
190
  // Get columns
191
  $columns = array( 'team' );
192
- $args = array(
193
- 'post_type' => array( 'sp_performance', 'sp_statistic' ),
194
  'posts_per_page' => 2,
195
- 'orderby' => 'menu_order',
196
- 'order' => 'ASC',
197
  );
198
- $vars = get_posts( $args );
199
  foreach ( $vars as $var ) {
200
  $columns[] = $var->post_name;
201
  }
@@ -204,24 +227,39 @@ class SP_Admin_Sample_Data {
204
  * Insert players
205
  */
206
  foreach ( $players as $index => $name ) {
207
- $post['post_title'] = $name;
208
- $post['post_type'] = 'sp_player';
209
- $post['post_status'] = 'publish';
210
- $post['post_content'] = sprintf( $sample_content, __( 'Player', 'sportspress' ), __( 'Players', 'sportspress' ), add_query_arg( 'post_type', 'sp_player', admin_url( 'edit.php' ) ) );
211
 
212
  // Terms
213
  $post['tax_input'] = array();
214
- $taxonomies = array( 'sp_league', 'sp_season' );
215
  foreach ( $taxonomies as $taxonomy ) {
216
- $post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) );
217
- };
 
 
 
 
 
 
218
  $taxonomies = array( 'sp_position' );
219
  foreach ( $taxonomies as $taxonomy ) {
220
- $terms = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'slug', 'number' => 1, 'offset' => $index % 4 ) );
 
 
 
 
 
 
 
 
 
221
  if ( $terms && ! is_wp_error( $terms ) ) {
222
  $post['tax_input'][ $taxonomy ] = $terms;
223
  }
224
- };
225
 
226
  // Insert post
227
  $id = wp_insert_post( $post );
@@ -233,13 +271,13 @@ class SP_Admin_Sample_Data {
233
  update_post_meta( $id, '_sp_sample', 1 );
234
 
235
  // Calculate meta
236
- $nationality = array_rand( $countries->countries );
237
- $team_index = floor( $index / 4 );
238
  $past_team_index = ( $team_index + 1 ) % 3;
239
- $current_team = sp_array_value( $inserted_ids['sp_team'], $team_index, 0 );
240
- $past_team = sp_array_value( $inserted_ids['sp_team'], $past_team_index, 0 );
241
- $primary_league = reset( $post['tax_input']['sp_league'] );
242
- $season_teams = $season_stats = array();
243
  foreach ( $post['tax_input']['sp_season'] as $season_index => $season_id ) {
244
  $season_stats[ $season_id ] = array();
245
  if ( $season_index == 0 ) {
@@ -253,7 +291,7 @@ class SP_Admin_Sample_Data {
253
  }
254
  }
255
  }
256
- $player_stats = array( $primary_league => $season_stats );
257
  $player_leagues = array( $primary_league => $season_teams );
258
 
259
  // Update meta
@@ -268,30 +306,32 @@ class SP_Admin_Sample_Data {
268
  }
269
 
270
  // Get columns
271
- $columns = array();
272
- $args = array(
273
- 'post_type' => 'sp_performance',
274
  'posts_per_page' => -1,
275
- 'orderby' => 'menu_order',
276
- 'order' => 'ASC',
277
  );
278
  $performance_posts = get_posts( $args );
279
  foreach ( $performance_posts as $performance_post ) {
280
- if ( sizeof( $columns ) >= 5 ) continue;
 
 
281
  $columns[] = $performance_post->post_name;
282
  }
283
- $args = array(
284
- 'post_type' => 'sp_result',
285
  'posts_per_page' => -1,
286
- 'orderby' => 'menu_order',
287
- 'order' => 'ASC',
288
  );
289
- $result_posts = get_posts( $args );
290
- $args = array(
291
- 'post_type' => 'sp_outcome',
292
  'posts_per_page' => -1,
293
- 'orderby' => 'menu_order',
294
- 'order' => 'ASC',
295
  );
296
  $outcome_posts = get_posts( $args );
297
 
@@ -299,22 +339,37 @@ class SP_Admin_Sample_Data {
299
  * Insert staff
300
  */
301
  foreach ( $staff as $index => $name ) {
302
- $post['post_title'] = $name;
303
- $post['post_type'] = 'sp_staff';
304
- $post['post_status'] = 'publish';
305
- $post['post_content'] = sprintf( $sample_content, __( 'Staff', 'sportspress' ), __( 'Staff', 'sportspress' ), add_query_arg( 'post_type', 'sp_staff', admin_url( 'edit.php' ) ) );
306
 
307
  // Terms
308
  $post['tax_input'] = array();
309
- $taxonomies = array( 'sp_league', 'sp_season' );
310
  foreach ( $taxonomies as $taxonomy ) {
311
- $post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) );
312
- };
 
 
 
 
 
 
313
  $taxonomies = array( 'sp_role' );
314
  foreach ( $taxonomies as $taxonomy ) {
315
- $terms = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'slug', 'number' => 1, 'offset' => $index % 4 ) );
 
 
 
 
 
 
 
 
 
316
  $post['tax_input'][ $taxonomy ] = $terms;
317
- };
318
 
319
  // Insert post
320
  $id = wp_insert_post( $post );
@@ -326,8 +381,8 @@ class SP_Admin_Sample_Data {
326
  update_post_meta( $id, '_sp_sample', 1 );
327
 
328
  // Calculate meta
329
- $team_index = floor( $index / 4 );
330
- $past_teams = $inserted_ids['sp_team'];
331
  $current_team = sp_array_value( $past_teams, $team_index, 0 );
332
  unset( $past_teams[ $team_index ] );
333
 
@@ -347,27 +402,67 @@ class SP_Admin_Sample_Data {
347
  // Determine team index and post status
348
  $i = $index % 3;
349
  if ( $index < 3 ) {
350
- $post_status = 'publish';
351
- $post_year = $current_year - 1;
352
- $event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
 
 
 
 
 
 
 
 
 
353
  } else {
354
- $post_status = 'future';
355
- $post_year = $current_year + 1;
356
- $event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'DESC', 'number' => 1 ) );
 
 
 
 
 
 
 
 
 
357
  }
358
  // The away team should be the next inserted team, or the first if this is the last event
359
- if ( $i == 2 ) $away_index = 0;
360
- else $away_index = $i + 1;
 
 
 
361
  $post = array(
362
- 'post_title' => $teams[ $i ]['name'] . ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ' . $teams[ $away_index ]['name'],
363
- 'post_type' => 'sp_event',
364
- 'post_status' => $post_status,
365
- 'post_content' => sprintf( $sample_content, __( 'Event', 'sportspress' ), __( 'Events', 'sportspress' ), add_query_arg( 'post_type', 'sp_event', admin_url( 'edit.php' ) ) ),
366
- 'post_date' => $post_year . '-' . sprintf( '%02d', 3 + $i * 3 ) . '-' . sprintf( '%02d', 5 + $i * 10 ) . ' ' . ( 18 + $i ) . ':00:00',
367
- 'tax_input' => array(
368
- 'sp_league' => get_terms( 'sp_league', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ),
 
 
 
 
 
 
 
 
 
369
  'sp_season' => $event_season,
370
- 'sp_venue' => get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $i ) ),
 
 
 
 
 
 
 
 
 
 
371
  ),
372
  );
373
 
@@ -383,23 +478,23 @@ class SP_Admin_Sample_Data {
383
  // Calculate home and away team ids
384
  $home_team_index = ( $i ) % 3;
385
  $away_team_index = ( $i + 1 ) % 3;
386
- $home_team_id = sp_array_value( $inserted_ids['sp_team'], $home_team_index, 0 );
387
- $away_team_id = sp_array_value( $inserted_ids['sp_team'], $away_team_index, 0 );
388
- $event_teams = array(
389
  $home_team_id,
390
  $away_team_id,
391
  );
392
 
393
  // Initialize meta
394
  $event_players = array( 0 );
395
- $performance = $results = array();
396
 
397
  if ( $home_team_id ) {
398
  // Add home team player performance
399
  $performance[ $home_team_id ] = array();
400
  for ( $j = 0; $j < 4; $j ++ ) {
401
- $player_id = sp_array_value( $inserted_ids['sp_player'], $home_team_index * 4 + $j );
402
- $event_players[] = $player_id;
403
  $player_performance = array();
404
  foreach ( $performance_posts as $performance_post ) {
405
  $player_performance[ $performance_post->post_name ] = rand( 0, 1 );
@@ -413,7 +508,9 @@ class SP_Admin_Sample_Data {
413
  $results[ $home_team_id ][ $result_post->post_name ] = 1 + $result_post_index;
414
  }
415
  $outcome = reset( $outcome_posts );
416
- if ( is_object( $outcome ) ) $results[ $home_team_id ]['outcome'] = array( $outcome->post_name );
 
 
417
  }
418
 
419
  // Separate teams with zero
@@ -422,8 +519,8 @@ class SP_Admin_Sample_Data {
422
  if ( $away_team_id ) {
423
  $performance[ $away_team_id ] = array();
424
  for ( $j = 0; $j < 4; $j ++ ) {
425
- $player_id = sp_array_value( $inserted_ids['sp_player'], $away_team_index * 4 + $j );
426
- $event_players[] = $player_id;
427
  $player_performance = array();
428
  foreach ( $performance_posts as $performance_post ) {
429
  $player_performance[ $performance_post->post_name ] = rand( 0, 1 );
@@ -437,15 +534,17 @@ class SP_Admin_Sample_Data {
437
  $results[ $away_team_id ][ $result_post->post_name ] = '0';
438
  }
439
  $outcome = next( $outcome_posts );
440
- if ( is_object( $outcome ) ) $results[ $away_team_id ]['outcome'] = array( $outcome->post_name );
 
 
441
  }
442
 
443
  if ( 'publish' === $post_status ) {
444
  // Swap results for last event only
445
  if ( $i == 2 ) {
446
- $k = array_keys( $results );
447
- $v = array_values( $results );
448
- $rv = array_reverse( $v );
449
  $results = array_combine( $k, $rv );
450
  }
451
 
@@ -466,10 +565,10 @@ class SP_Admin_Sample_Data {
466
  * Insert calendar
467
  */
468
  $post = array(
469
- 'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ),
470
- 'post_type' => 'sp_calendar',
471
- 'post_status' => 'publish',
472
- 'post_content' => sprintf( $sample_content, __( 'Calendar', 'sportspress' ), __( 'Calendars', 'sportspress' ), add_query_arg( 'post_type', 'sp_calendar', admin_url( 'edit.php' ) ) )
473
  );
474
 
475
  // Insert post
@@ -495,16 +594,32 @@ class SP_Admin_Sample_Data {
495
  /*
496
  * Insert league table
497
  */
498
- $leagues = get_terms( 'sp_league', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
499
- $league = reset( $leagues );
500
- $seasons = get_terms( 'sp_season', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
501
- $season = reset( $seasons );
502
- $post = array(
503
- 'post_title' => $league->name . ' ' . $season->name,
504
- 'post_type' => 'sp_table',
505
- 'post_status' => 'publish',
506
- 'post_content' => sprintf( $sample_content, __( 'League Table', 'sportspress' ), __( 'League Tables', 'sportspress' ), add_query_arg( 'post_type', 'sp_table', admin_url( 'edit.php' ) ) ),
507
- 'tax_input' => array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
508
  'sp_league' => $league->term_id,
509
  'sp_season' => $season->term_id,
510
  ),
@@ -520,12 +635,12 @@ class SP_Admin_Sample_Data {
520
  update_post_meta( $id, '_sp_sample', 1 );
521
 
522
  // Get columns
523
- $columns = array();
524
- $args = array(
525
- 'post_type' => 'sp_column',
526
  'posts_per_page' => 8,
527
- 'orderby' => 'menu_order',
528
- 'order' => 'ASC',
529
  );
530
  $column_posts = get_posts( $args );
531
  foreach ( $column_posts as $column_post ) {
@@ -542,10 +657,10 @@ class SP_Admin_Sample_Data {
542
  */
543
  foreach ( $inserted_ids['sp_team'] as $index => $team_id ) {
544
  $post = array(
545
- 'post_title' => get_the_title( $team_id ) . ' ' . _x( 'Roster', 'example', 'sportspress' ),
546
- 'post_type' => 'sp_list',
547
- 'post_status' => 'publish',
548
- 'post_content' => sprintf( $sample_content, __( 'Player List', 'sportspress' ), __( 'Player Lists', 'sportspress' ), add_query_arg( 'post_type', 'sp_list', admin_url( 'edit.php' ) ) ),
549
  );
550
 
551
  // Insert post
@@ -561,12 +676,12 @@ class SP_Admin_Sample_Data {
561
  $list_players = array_slice( $inserted_ids['sp_player'], $index * 4, 4 );
562
 
563
  // Get columns
564
- $columns = array();
565
- $args = array(
566
- 'post_type' => array( 'sp_metric' ),
567
  'posts_per_page' => 2,
568
- 'orderby' => 'menu_order',
569
- 'order' => 'ASC',
570
  );
571
  $column_posts = get_posts( $args );
572
  foreach ( $column_posts as $column_post ) {
@@ -587,10 +702,10 @@ class SP_Admin_Sample_Data {
587
  * Insert player list for player ranking
588
  */
589
  $post = array(
590
- 'post_title' => _x( 'Player Ranking', 'example', 'sportspress' ),
591
- 'post_type' => 'sp_list',
592
- 'post_status' => 'publish',
593
- 'post_content' => sprintf( $sample_content, __( 'Player List', 'sportspress' ), __( 'Player Lists', 'sportspress' ), add_query_arg( 'post_type', 'sp_list', admin_url( 'edit.php' ) ) ),
594
  );
595
 
596
  // Insert post
@@ -603,9 +718,11 @@ class SP_Admin_Sample_Data {
603
  update_post_meta( $id, '_sp_sample', 1 );
604
 
605
  // Get columns
606
- $columns = array( 'team' );
607
  $performance_post = reset( $performance_posts );
608
- if ( is_object( $performance_post ) ) $columns[] = $performance_post->post_name;
 
 
609
 
610
  // Update meta
611
  update_post_meta( $id, 'sp_format', 'list' );
@@ -613,7 +730,9 @@ class SP_Admin_Sample_Data {
613
  update_post_meta( $id, 'sp_columns', $columns );
614
  update_post_meta( $id, 'sp_grouping', '0' );
615
  update_post_meta( $id, 'sp_order', 'DESC' );
616
- if ( is_object( $performance_post ) ) update_post_meta( $id, 'sp_orderby', $performance_post->post_name );
 
 
617
 
618
  /*
619
  * Update player list and league table per team
@@ -631,21 +750,21 @@ class SP_Admin_Sample_Data {
631
  */
632
  public static function delete_posts() {
633
  $post_types = sp_post_types();
634
- $args = array(
635
- 'post_type' => $post_types,
636
  'posts_per_page' => -1,
637
- 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
638
- 'meta_query' => array(
639
  array(
640
- 'key' => '_sp_sample',
641
- 'value' => 1
642
- )
643
  ),
644
  );
645
 
646
  // Delete posts
647
  $old_posts = get_posts( $args );
648
- foreach( $old_posts as $post ):
649
  wp_delete_post( $post->ID, true );
650
  endforeach;
651
  }
4
  *
5
  * The SportsPress admin sample data class stores demo content.
6
  *
7
+ * @class SP_Admin_Sample_Data
8
+ * @version 2.5
9
+ * @package SportsPress/Admin
10
+ * @category Class
11
+ * @author ThemeBoy
12
  */
13
  class SP_Admin_Sample_Data {
14
 
23
 
24
  // Initialize inserted ids array
25
  $inserted_ids = array(
26
+ 'sp_league' => array(),
27
+ 'sp_season' => array(),
28
+ 'sp_venue' => array(),
29
  'sp_position' => array(),
30
+ 'sp_role' => array(),
31
+ 'sp_event' => array(),
32
  'sp_calendar' => array(),
33
+ 'sp_team' => array(),
34
+ 'sp_table' => array(),
35
+ 'sp_player' => array(),
36
+ 'sp_list' => array(),
37
+ 'sp_staff' => array(),
38
  );
39
 
40
  // Terms to insert
44
  $taxonomies['sp_league'] = array( _x( 'Primary League', 'example', 'sportspress' ), _x( 'Secondary League', 'example', 'sportspress' ) );
45
 
46
  // Seasons
47
+ $current_year = date( 'Y' );
48
+ $current_year = intval( $current_year );
49
  $taxonomies['sp_season'] = array( $current_year - 1, $current_year, $current_year + 1 );
50
 
51
  // Venues
52
+ $taxonomies['sp_venue'] = array(
53
  array(
54
  'name' => 'Bentleigh',
55
  'meta' => array(
56
+ 'sp_address' => '12A Bolinda Street, Bentleigh VIC 3204, Australia',
57
+ 'sp_latitude' => -37.920537,
58
  'sp_longitude' => 145.043199,
59
  ),
60
  ),
61
  array(
62
  'name' => 'Essendon',
63
  'meta' => array(
64
+ 'sp_address' => '74 Napier Street, Essendon VIC 3040, Australia',
65
+ 'sp_latitude' => -37.751940,
66
  'sp_longitude' => 144.919549,
67
  ),
68
  ),
69
  array(
70
  'name' => 'Kensington',
71
  'meta' => array(
72
+ 'sp_address' => '50 Altona Street, Kensington, Victoria, Australia',
73
+ 'sp_latitude' => -37.797789,
74
  'sp_longitude' => 144.924709,
75
  ),
76
  ),
92
  }
93
 
94
  // Insert term
95
+ $inserted = wp_insert_term(
96
+ $name,
97
+ $taxonomy,
98
+ array(
99
+ 'description' => $name,
100
+ 'slug' => sanitize_title( $name ),
101
+ )
102
+ );
103
 
104
  // Add meta to term if is array
105
  if ( ! is_wp_error( $inserted ) && is_array( $term ) && array_key_exists( 'meta', $term ) ) {
106
  $t_id = sp_array_value( $inserted, 'term_id', 1 );
107
  $meta = sp_array_value( $term, 'meta' );
108
  update_option( "taxonomy_$t_id", $meta );
109
+
110
  // Add to inserted ids array
111
  $inserted_ids[ $taxonomy ][] = $t_id;
112
  }
120
  $teams = array(
121
  array(
122
  'name' => 'Bluebirds',
123
+ 'url' => 'http://tboy.co/bluebirds',
124
  ),
125
  array(
126
  'name' => 'Eagles',
127
+ 'url' => 'http://tboy.co/eagles',
128
  ),
129
  array(
130
  'name' => 'Kangaroos',
131
+ 'url' => 'http://tboy.co/kangaroos',
132
  ),
133
  );
134
 
167
  * Insert teams
168
  */
169
  foreach ( $teams as $index => $team ) {
170
+ $post['post_title'] = $team['name'];
171
+ $post['post_type'] = 'sp_team';
172
+ $post['post_status'] = 'publish';
173
+ $post['post_content'] = sprintf( $sample_content, esc_attr__( 'Team', 'sportspress' ), esc_attr__( 'Teams', 'sportspress' ), add_query_arg( 'post_type', 'sp_team', admin_url( 'edit.php' ) ) );
174
 
175
  // Terms
176
  $post['tax_input'] = array();
177
+ $taxonomies = array( 'sp_league', 'sp_season' );
178
  foreach ( $taxonomies as $taxonomy ) {
179
+ $post['tax_input'][ $taxonomy ] = get_terms(
180
+ $taxonomy,
181
+ array(
182
+ 'hide_empty' => 0,
183
+ 'fields' => 'ids',
184
+ )
185
+ );
186
+ }
187
 
188
+ $post['tax_input']['sp_venue'] = get_terms(
189
+ 'sp_venue',
190
+ array(
191
+ 'hide_empty' => 0,
192
+ 'fields' => 'ids',
193
+ 'orderby' => 'id',
194
+ 'order' => 'ASC',
195
+ 'number' => 1,
196
+ 'offset' => $index,
197
+ )
198
+ );
199
 
200
  // Insert post
201
  $id = wp_insert_post( $post );
212
 
213
  // Get columns
214
  $columns = array( 'team' );
215
+ $args = array(
216
+ 'post_type' => array( 'sp_performance', 'sp_statistic' ),
217
  'posts_per_page' => 2,
218
+ 'orderby' => 'menu_order',
219
+ 'order' => 'ASC',
220
  );
221
+ $vars = get_posts( $args );
222
  foreach ( $vars as $var ) {
223
  $columns[] = $var->post_name;
224
  }
227
  * Insert players
228
  */
229
  foreach ( $players as $index => $name ) {
230
+ $post['post_title'] = $name;
231
+ $post['post_type'] = 'sp_player';
232
+ $post['post_status'] = 'publish';
233
+ $post['post_content'] = sprintf( $sample_content, esc_attr__( 'Player', 'sportspress' ), esc_attr__( 'Players', 'sportspress' ), add_query_arg( 'post_type', 'sp_player', admin_url( 'edit.php' ) ) );
234
 
235
  // Terms
236
  $post['tax_input'] = array();
237
+ $taxonomies = array( 'sp_league', 'sp_season' );
238
  foreach ( $taxonomies as $taxonomy ) {
239
+ $post['tax_input'][ $taxonomy ] = get_terms(
240
+ $taxonomy,
241
+ array(
242
+ 'hide_empty' => 0,
243
+ 'fields' => 'ids',
244
+ )
245
+ );
246
+ }
247
  $taxonomies = array( 'sp_position' );
248
  foreach ( $taxonomies as $taxonomy ) {
249
+ $terms = get_terms(
250
+ $taxonomy,
251
+ array(
252
+ 'hide_empty' => 0,
253
+ 'fields' => 'ids',
254
+ 'orderby' => 'slug',
255
+ 'number' => 1,
256
+ 'offset' => $index % 4,
257
+ )
258
+ );
259
  if ( $terms && ! is_wp_error( $terms ) ) {
260
  $post['tax_input'][ $taxonomy ] = $terms;
261
  }
262
+ }
263
 
264
  // Insert post
265
  $id = wp_insert_post( $post );
271
  update_post_meta( $id, '_sp_sample', 1 );
272
 
273
  // Calculate meta
274
+ $nationality = array_rand( $countries->countries );
275
+ $team_index = floor( $index / 4 );
276
  $past_team_index = ( $team_index + 1 ) % 3;
277
+ $current_team = sp_array_value( $inserted_ids['sp_team'], $team_index, 0 );
278
+ $past_team = sp_array_value( $inserted_ids['sp_team'], $past_team_index, 0 );
279
+ $primary_league = reset( $post['tax_input']['sp_league'] );
280
+ $season_teams = $season_stats = array();
281
  foreach ( $post['tax_input']['sp_season'] as $season_index => $season_id ) {
282
  $season_stats[ $season_id ] = array();
283
  if ( $season_index == 0 ) {
291
  }
292
  }
293
  }
294
+ $player_stats = array( $primary_league => $season_stats );
295
  $player_leagues = array( $primary_league => $season_teams );
296
 
297
  // Update meta
306
  }
307
 
308
  // Get columns
309
+ $columns = array();
310
+ $args = array(
311
+ 'post_type' => 'sp_performance',
312
  'posts_per_page' => -1,
313
+ 'orderby' => 'menu_order',
314
+ 'order' => 'ASC',
315
  );
316
  $performance_posts = get_posts( $args );
317
  foreach ( $performance_posts as $performance_post ) {
318
+ if ( sizeof( $columns ) >= 5 ) {
319
+ continue;
320
+ }
321
  $columns[] = $performance_post->post_name;
322
  }
323
+ $args = array(
324
+ 'post_type' => 'sp_result',
325
  'posts_per_page' => -1,
326
+ 'orderby' => 'menu_order',
327
+ 'order' => 'ASC',
328
  );
329
+ $result_posts = get_posts( $args );
330
+ $args = array(
331
+ 'post_type' => 'sp_outcome',
332
  'posts_per_page' => -1,
333
+ 'orderby' => 'menu_order',
334
+ 'order' => 'ASC',
335
  );
336
  $outcome_posts = get_posts( $args );
337
 
339
  * Insert staff
340
  */
341
  foreach ( $staff as $index => $name ) {
342
+ $post['post_title'] = $name;
343
+ $post['post_type'] = 'sp_staff';
344
+ $post['post_status'] = 'publish';
345
+ $post['post_content'] = sprintf( $sample_content, esc_attr__( 'Staff', 'sportspress' ), esc_attr__( 'Staff', 'sportspress' ), add_query_arg( 'post_type', 'sp_staff', admin_url( 'edit.php' ) ) );
346
 
347
  // Terms
348
  $post['tax_input'] = array();
349
+ $taxonomies = array( 'sp_league', 'sp_season' );
350
  foreach ( $taxonomies as $taxonomy ) {
351
+ $post['tax_input'][ $taxonomy ] = get_terms(
352
+ $taxonomy,
353
+ array(
354
+ 'hide_empty' => 0,
355
+ 'fields' => 'ids',
356
+ )
357
+ );
358
+ }
359
  $taxonomies = array( 'sp_role' );
360
  foreach ( $taxonomies as $taxonomy ) {
361
+ $terms = get_terms(
362
+ $taxonomy,
363
+ array(
364
+ 'hide_empty' => 0,
365
+ 'fields' => 'ids',
366
+ 'orderby' => 'slug',
367
+ 'number' => 1,
368
+ 'offset' => $index % 4,
369
+ )
370
+ );
371
  $post['tax_input'][ $taxonomy ] = $terms;
372
+ }
373
 
374
  // Insert post
375
  $id = wp_insert_post( $post );
381
  update_post_meta( $id, '_sp_sample', 1 );
382
 
383
  // Calculate meta
384
+ $team_index = floor( $index / 4 );
385
+ $past_teams = $inserted_ids['sp_team'];
386
  $current_team = sp_array_value( $past_teams, $team_index, 0 );
387
  unset( $past_teams[ $team_index ] );
388
 
402
  // Determine team index and post status
403
  $i = $index % 3;
404
  if ( $index < 3 ) {
405
+ $post_status = 'publish';
406
+ $post_year = $current_year - 1;
407
+ $event_season = get_terms(
408
+ 'sp_season',
409
+ array(
410
+ 'hide_empty' => 0,
411
+ 'fields' => 'ids',
412
+ 'orderby' => 'id',
413
+ 'order' => 'ASC',
414
+ 'number' => 1,
415
+ )
416
+ );
417
  } else {
418
+ $post_status = 'future';
419
+ $post_year = $current_year + 1;
420
+ $event_season = get_terms(
421
+ 'sp_season',
422
+ array(
423
+ 'hide_empty' => 0,
424
+ 'fields' => 'ids',
425
+ 'orderby' => 'id',
426
+ 'order' => 'DESC',
427
+ 'number' => 1,
428
+ )
429
+ );
430
  }
431
  // The away team should be the next inserted team, or the first if this is the last event
432
+ if ( $i == 2 ) {
433
+ $away_index = 0;
434
+ } else {
435
+ $away_index = $i + 1;
436
+ }
437
  $post = array(
438
+ 'post_title' => $teams[ $i ]['name'] . ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ' . $teams[ $away_index ]['name'],
439
+ 'post_type' => 'sp_event',
440
+ 'post_status' => $post_status,
441
+ 'post_content' => sprintf( $sample_content, esc_attr__( 'Event', 'sportspress' ), esc_attr__( 'Events', 'sportspress' ), add_query_arg( 'post_type', 'sp_event', admin_url( 'edit.php' ) ) ),
442
+ 'post_date' => $post_year . '-' . sprintf( '%02d', 3 + $i * 3 ) . '-' . sprintf( '%02d', 5 + $i * 10 ) . ' ' . ( 18 + $i ) . ':00:00',
443
+ 'tax_input' => array(
444
+ 'sp_league' => get_terms(
445
+ 'sp_league',
446
+ array(
447
+ 'hide_empty' => 0,
448
+ 'fields' => 'ids',
449
+ 'orderby' => 'id',
450
+ 'order' => 'ASC',
451
+ 'number' => 1,
452
+ )
453
+ ),
454
  'sp_season' => $event_season,
455
+ 'sp_venue' => get_terms(
456
+ 'sp_venue',
457
+ array(
458
+ 'hide_empty' => 0,
459
+ 'fields' => 'ids',
460
+ 'orderby' => 'id',
461
+ 'order' => 'ASC',
462
+ 'number' => 1,
463
+ 'offset' => $i,
464
+ )
465
+ ),
466
  ),
467
  );
468
 
478
  // Calculate home and away team ids
479
  $home_team_index = ( $i ) % 3;
480
  $away_team_index = ( $i + 1 ) % 3;
481
+ $home_team_id = sp_array_value( $inserted_ids['sp_team'], $home_team_index, 0 );
482
+ $away_team_id = sp_array_value( $inserted_ids['sp_team'], $away_team_index, 0 );
483
+ $event_teams = array(
484
  $home_team_id,
485
  $away_team_id,
486
  );
487
 
488
  // Initialize meta
489
  $event_players = array( 0 );
490
+ $performance = $results = array();
491
 
492
  if ( $home_team_id ) {
493
  // Add home team player performance
494
  $performance[ $home_team_id ] = array();
495
  for ( $j = 0; $j < 4; $j ++ ) {
496
+ $player_id = sp_array_value( $inserted_ids['sp_player'], $home_team_index * 4 + $j );
497
+ $event_players[] = $player_id;
498
  $player_performance = array();
499
  foreach ( $performance_posts as $performance_post ) {
500
  $player_performance[ $performance_post->post_name ] = rand( 0, 1 );
508
  $results[ $home_team_id ][ $result_post->post_name ] = 1 + $result_post_index;
509
  }
510
  $outcome = reset( $outcome_posts );
511
+ if ( is_object( $outcome ) ) {
512
+ $results[ $home_team_id ]['outcome'] = array( $outcome->post_name );
513
+ }
514
  }
515
 
516
  // Separate teams with zero
519
  if ( $away_team_id ) {
520
  $performance[ $away_team_id ] = array();
521
  for ( $j = 0; $j < 4; $j ++ ) {
522
+ $player_id = sp_array_value( $inserted_ids['sp_player'], $away_team_index * 4 + $j );
523
+ $event_players[] = $player_id;
524
  $player_performance = array();
525
  foreach ( $performance_posts as $performance_post ) {
526
  $player_performance[ $performance_post->post_name ] = rand( 0, 1 );
534
  $results[ $away_team_id ][ $result_post->post_name ] = '0';
535
  }
536
  $outcome = next( $outcome_posts );
537
+ if ( is_object( $outcome ) ) {
538
+ $results[ $away_team_id ]['outcome'] = array( $outcome->post_name );
539
+ }
540
  }
541
 
542
  if ( 'publish' === $post_status ) {
543
  // Swap results for last event only
544
  if ( $i == 2 ) {
545
+ $k = array_keys( $results );
546
+ $v = array_values( $results );
547
+ $rv = array_reverse( $v );
548
  $results = array_combine( $k, $rv );
549
  }
550
 
565
  * Insert calendar
566
  */
567
  $post = array(
568
+ 'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ),
569
+ 'post_type' => 'sp_calendar',
570
+ 'post_status' => 'publish',
571
+ 'post_content' => sprintf( $sample_content, esc_attr__( 'Calendar', 'sportspress' ), esc_attr__( 'Calendars', 'sportspress' ), add_query_arg( 'post_type', 'sp_calendar', admin_url( 'edit.php' ) ) ),
572
  );
573
 
574
  // Insert post
594
  /*
595
  * Insert league table
596
  */
597
+ $leagues = get_terms(
598
+ 'sp_league',
599
+ array(
600
+ 'hide_empty' => 0,
601
+ 'orderby' => 'id',
602
+ 'order' => 'ASC',
603
+ 'number' => 1,
604
+ )
605
+ );
606
+ $league = reset( $leagues );
607
+ $seasons = get_terms(
608
+ 'sp_season',
609
+ array(
610
+ 'hide_empty' => 0,
611
+ 'orderby' => 'id',
612
+ 'order' => 'ASC',
613
+ 'number' => 1,
614
+ )
615
+ );
616
+ $season = reset( $seasons );
617
+ $post = array(
618
+ 'post_title' => $league->name . ' ' . $season->name,
619
+ 'post_type' => 'sp_table',
620
+ 'post_status' => 'publish',
621
+ 'post_content' => sprintf( $sample_content, esc_attr__( 'League Table', 'sportspress' ), esc_attr__( 'League Tables', 'sportspress' ), add_query_arg( 'post_type', 'sp_table', admin_url( 'edit.php' ) ) ),
622
+ 'tax_input' => array(
623
  'sp_league' => $league->term_id,
624
  'sp_season' => $season->term_id,
625
  ),
635
  update_post_meta( $id, '_sp_sample', 1 );
636
 
637
  // Get columns
638
+ $columns = array();
639
+ $args = array(
640
+ 'post_type' => 'sp_column',
641
  'posts_per_page' => 8,
642
+ 'orderby' => 'menu_order',
643
+ 'order' => 'ASC',
644
  );
645
  $column_posts = get_posts( $args );
646
  foreach ( $column_posts as $column_post ) {
657
  */
658
  foreach ( $inserted_ids['sp_team'] as $index => $team_id ) {
659
  $post = array(
660
+ 'post_title' => get_the_title( $team_id ) . ' ' . _x( 'Roster', 'example', 'sportspress' ),
661
+ 'post_type' => 'sp_list',
662
+ 'post_status' => 'publish',
663
+ 'post_content' => sprintf( $sample_content, esc_attr__( 'Player List', 'sportspress' ), esc_attr__( 'Player Lists', 'sportspress' ), add_query_arg( 'post_type', 'sp_list', admin_url( 'edit.php' ) ) ),
664
  );
665
 
666
  // Insert post
676
  $list_players = array_slice( $inserted_ids['sp_player'], $index * 4, 4 );
677
 
678
  // Get columns
679
+ $columns = array();
680
+ $args = array(
681
+ 'post_type' => array( 'sp_metric' ),
682
  'posts_per_page' => 2,
683
+ 'orderby' => 'menu_order',
684
+ 'order' => 'ASC',
685
  );
686
  $column_posts = get_posts( $args );
687
  foreach ( $column_posts as $column_post ) {
702
  * Insert player list for player ranking
703
  */
704
  $post = array(
705
+ 'post_title' => _x( 'Player Ranking', 'example', 'sportspress' ),
706
+ 'post_type' => 'sp_list',
707
+ 'post_status' => 'publish',
708
+ 'post_content' => sprintf( $sample_content, esc_attr__( 'Player List', 'sportspress' ), esc_attr__( 'Player Lists', 'sportspress' ), add_query_arg( 'post_type', 'sp_list', admin_url( 'edit.php' ) ) ),
709
  );
710
 
711
  // Insert post
718
  update_post_meta( $id, '_sp_sample', 1 );
719
 
720
  // Get columns
721
+ $columns = array( 'team' );
722
  $performance_post = reset( $performance_posts );
723
+ if ( is_object( $performance_post ) ) {
724
+ $columns[] = $performance_post->post_name;
725
+ }
726
 
727
  // Update meta
728
  update_post_meta( $id, 'sp_format', 'list' );
730
  update_post_meta( $id, 'sp_columns', $columns );
731
  update_post_meta( $id, 'sp_grouping', '0' );
732
  update_post_meta( $id, 'sp_order', 'DESC' );
733
+ if ( is_object( $performance_post ) ) {
734
+ update_post_meta( $id, 'sp_orderby', $performance_post->post_name );
735
+ }
736
 
737
  /*
738
  * Update player list and league table per team
750
  */
751
  public static function delete_posts() {
752
  $post_types = sp_post_types();
753
+ $args = array(
754
+ 'post_type' => $post_types,
755
  'posts_per_page' => -1,
756
+ 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
757
+ 'meta_query' => array(
758
  array(
759
+ 'key' => '_sp_sample',
760
+ 'value' => 1,
761
+ ),
762
  ),
763
  );
764
 
765
  // Delete posts
766
  $old_posts = get_posts( $args );
767
+ foreach ( $old_posts as $post ) :
768
  wp_delete_post( $post->ID, true );
769
  endforeach;
770
  }
includes/admin/class-sp-admin-settings.php CHANGED
@@ -5,734 +5,824 @@
5
  * @author ThemeBoy
6
  * @category Admin
7
  * @package SportsPress/Admin
8
- * @version 2.6.1
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( ! class_exists( 'SP_Admin_Settings' ) ) :
14
 
15
- /**
16
- * SP_Admin_Settings
17
- */
18
- class SP_Admin_Settings {
19
-
20
- private static $settings = array();
21
- private static $errors = array();
22
- private static $messages = array();
23
- private static $overrides = array();
24
-
25
  /**
26
- * Include the settings page classes
27
  */
28
- public static function get_settings_pages() {
29
- if ( empty( self::$settings ) ) {
30
- $settings = array();
31
 
32
- include_once( 'class-sp-admin-sports.php' );
33
- include_once( 'settings/class-sp-settings-page.php' );
 
 
34
 
35
- $settings[] = include( 'settings/class-sp-settings-modules.php' );
36
- $settings[] = include( 'settings/class-sp-settings-general.php' );
37
- $settings[] = include( 'settings/class-sp-settings-events.php' );
38
- $settings[] = include( 'settings/class-sp-settings-teams.php' );
39
- $settings[] = include( 'settings/class-sp-settings-players.php' );
40
- $settings[] = include( 'settings/class-sp-settings-staff.php' );
41
 
42
- $settings = apply_filters( 'sportspress_get_settings_pages', $settings );
 
43
 
44
- $settings[] = include( 'settings/class-sp-settings-text.php' );
 
 
 
 
 
45
 
46
- if (
47
- ( ! is_multisite() && current_user_can( 'manage_options' ) ) ||
48
- ( is_multisite() && current_user_can( 'manage_network_options' ) )
49
- ) {
50
- $settings[] = include( 'settings/class-sp-settings-licenses.php' );
51
- }
52
-
53
- $settings[] = include( 'settings/class-sp-settings-status.php' );
54
 
55
- self::$settings = apply_filters( 'sportspress_get_settings_config_pages', $settings );
56
- }
57
- return self::$settings;
58
- }
59
 
60
- /**
61
- * Save the settings
62
- */
63
- public static function save() {
64
- global $current_section, $current_tab;
65
-
66
- if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'sportspress-settings' ) )
67
- die( __( 'Action failed. Please refresh the page and retry.', 'sportspress' ) );
68
 
69
- // Trigger actions
70
- do_action( 'sportspress_settings_save_' . $current_tab );
71
- do_action( 'sportspress_update_options_' . $current_tab );
72
- do_action( 'sportspress_update_options' );
73
 
74
- self::add_message( __( 'Your settings have been saved.', 'sportspress' ) );
 
 
 
75
 
76
- do_action( 'sportspress_settings_saved' );
77
- }
 
 
 
78
 
79
- /**
80
- * Add a message
81
- * @param string $text
82
- */
83
- public static function add_message( $text ) {
84
- self::$messages[] = $text;
85
- }
86
 
87
- /**
88
- * Add an override
89
- * @param string $text
90
- */
91
- public static function add_override( $text ) {
92
- self::$overrides[] = $text;
93
- }
94
 
95
- /**
96
- * Add an error
97
- * @param string $text
98
- */
99
- public static function add_error( $text ) {
100
- self::$errors[] = $text;
101
- }
102
 
103
- /**
104
- * Output messages + overrides + errors
105
- */
106
- public static function show_messages() {
107
- if ( sizeof( self::$errors ) > 0 ) {
108
- foreach ( self::$errors as $error )
109
- echo '<div id="message" class="error fade"><p><strong>' . esc_html( $error ) . '</strong></p></div>';
110
- } elseif ( sizeof( self::$overrides ) > 0 ) {
111
- foreach ( self::$overrides as $override )
112
- echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $override ) . '</strong></p></div>';
113
- } elseif ( sizeof( self::$messages ) > 0 ) {
114
- foreach ( self::$messages as $message )
115
- echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $message ) . '</strong></p></div>';
116
  }
117
- }
118
 
119
- /**
120
- * Settings page.
121
- *
122
- * Handles the display of the main sportspress settings page in admin.
123
- *
124
- * @access public
125
- * @return void
126
- */
127
- public static function output() {
128
- global $current_section, $current_tab;
129
 
130
- do_action( 'sportspress_settings_start' );
 
 
 
 
 
 
 
131
 
132
- wp_enqueue_script( 'sportspress_settings', SP()->plugin_url() . '/assets/js/admin/settings.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'chosen' ), SP()->version, true );
 
 
 
 
 
 
 
133
 
134
- wp_localize_script( 'sportspress_settings', 'localized_strings', array(
135
- 'none' => __( 'None', 'sportspress' )
136
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
- // Include settings pages
139
- self::get_settings_pages();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
- // Get current tab/section
142
- $current_tab = empty( $_GET['tab'] ) ? 'modules' : sanitize_title( $_GET['tab'] );
143
- $current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( $_REQUEST['section'] );
 
144
 
145
- // Save settings if data has been posted
146
- if ( ! empty( $_POST ) )
147
- self::save();
148
 
149
- // Add any posted messages
150
- if ( ! empty( $_GET['sp_error'] ) )
151
- self::add_error( stripslashes( $_GET['sp_error'] ) );
152
 
153
- if ( ! empty( $_GET['sp_message'] ) )
154
- self::add_message( stripslashes( $_GET['sp_message'] ) );
155
 
156
- self::show_messages();
 
157
 
158
- // Get tabs for the settings page
159
- $tabs = apply_filters( 'sportspress_settings_tabs_array', array() );
 
 
 
 
 
 
 
160
 
161
- include 'views/html-admin-settings.php';
162
- }
163
 
164
- /**
165
- * Get a setting from the settings API.
166
- *
167
- * @param mixed $option
168
- * @return string
169
- */
170
- public static function get_option( $option_name, $default = '' ) {
171
- // Array value
172
- if ( strstr( $option_name, '[' ) ) {
173
 
174
- parse_str( html_entity_decode( $option_name ), $option_array );
 
175
 
176
- // Option name is first key
177
- $option_name = current( array_keys( $option_array ) );
178
 
179
- // Get value
180
- $option_values = get_option( $option_name, '' );
 
 
 
181
 
182
- $key = key( $option_array[ $option_name ] );
 
 
 
183
 
184
- if ( isset( $option_values[ $key ] ) )
185
- $option_value = $option_values[ $key ];
186
- else
187
- $option_value = null;
 
188
 
189
- // Single value
190
- } else {
191
- $option_value = get_option( $option_name, null );
192
  }
193
 
194
- if ( is_array( $option_value ) )
195
- $option_value = array_map( 'stripslashes', $option_value );
196
- elseif ( ! is_null( $option_value ) )
197
- $option_value = stripslashes( $option_value );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
- return $option_value === null ? $default : $option_value;
200
- }
 
 
 
201
 
202
- /**
203
- * Output admin fields.
204
- *
205
- * Loops though the sportspress options array and outputs each field.
206
- *
207
- * @access public
208
- * @param array $options Opens array to output
209
- */
210
- public static function output_fields( $options ) {
211
- foreach ( $options as $value ) {
212
- if ( ! isset( $value['type'] ) ) continue;
213
- if ( ! isset( $value['id'] ) ) $value['id'] = '';
214
- if ( ! isset( $value['title'] ) ) $value['title'] = isset( $value['name'] ) ? $value['name'] : '';
215
- if ( ! isset( $value['class'] ) ) $value['class'] = '';
216
- if ( ! isset( $value['css'] ) ) $value['css'] = '';
217
- if ( ! isset( $value['default'] ) ) $value['default'] = '';
218
- if ( ! isset( $value['desc'] ) ) $value['desc'] = '';
219
- if ( ! isset( $value['desc_tip'] ) ) $value['desc_tip'] = false;
220
- if ( ! isset( $value['placeholder'] ) ) $value['placeholder'] = '';
221
-
222
- // Custom attribute handling
223
- $custom_attributes = array();
224
-
225
- if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) )
226
- foreach ( $value['custom_attributes'] as $attribute => $attribute_value )
227
- $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
228
-
229
- // Description handling
230
- if ( $value['desc_tip'] === true ) {
231
- $description = '';
232
- $tip = $value['desc'];
233
- } elseif ( ! empty( $value['desc_tip'] ) ) {
234
- $description = $value['desc'];
235
- $tip = $value['desc_tip'];
236
- } elseif ( ! empty( $value['desc'] ) ) {
237
- $description = $value['desc'];
238
- $tip = '';
239
- } else {
240
- $description = $tip = '';
241
- }
242
 
243
- if ( $description && in_array( $value['type'], array( 'textarea', 'radio' ) ) ) {
244
- $description = '<p style="margin-top:0">' . wp_kses_post( $description ) . '</p>';
245
- } elseif ( $description && in_array( $value['type'], array( 'checkbox' ) ) ) {
246
- $description = wp_kses_post( $description );
247
- } elseif ( $description && in_array( $value['type'], array( 'select' ) ) ) {
248
- $description = '<p class="description">' . wp_kses_post( $description ) . '</p>';
249
- } elseif ( $description ) {
250
- $description = '<span class="description">' . wp_kses_post( $description ) . '</span>';
251
- }
252
 
253
- if ( $tip && in_array( $value['type'], array( 'checkbox' ) ) ) {
254
 
255
- $tip = '<p class="description">' . $tip . '</p>';
256
 
257
- } elseif ( $tip ) {
258
 
259
- $tip = '<i class="dashicons dashicons-editor-help sp-desc-tip" title="' . esc_attr( $tip ) . '" />';
260
 
261
- }
262
 
263
- // Switch based on type
264
- switch( $value['type'] ) {
265
-
266
- // Section Titles
267
- case 'title':
268
- echo '<div class="sp-settings-section sp-settings-section-' . sanitize_title( sp_array_value( $value, 'id' ) ) . '">';
269
- echo '<a name="sp-settings-section-' . sanitize_title( sp_array_value( $value, 'id' ) ) . '"></a>';
270
- if ( ! empty( $value['title'] ) ) {
271
- echo '<h3>' . esc_html( $value['title'] ) . '</h3>';
272
- }
273
- if ( ! empty( $value['desc'] ) ) {
274
- echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) );
275
- }
276
- echo '<table class="form-table">'. "\n\n";
277
- if ( ! empty( $value['id'] ) ) {
278
- do_action( 'sportspress_settings_' . sanitize_title( $value['id'] ) );
279
- }
280
- break;
281
-
282
- // Section Ends
283
- case 'sectionend':
284
- if ( ! empty( $value['id'] ) ) {
285
- do_action( 'sportspress_settings_' . sanitize_title( $value['id'] ) . '_end' );
286
- }
287
- echo '</table>';
288
- if ( ! empty( $value['id'] ) ) {
289
- do_action( 'sportspress_settings_' . sanitize_title( $value['id'] ) . '_after' );
290
- }
291
- echo '</div>';
292
- break;
293
-
294
- // Standard text inputs and subtypes like 'number'
295
- case 'text':
296
- case 'email':
297
- case 'number':
298
- case 'color' :
299
- case 'password' :
300
-
301
- $type = $value['type'];
302
- $class = '';
303
- $option_value = self::get_option( $value['id'], $value['default'] );
304
-
305
- if ( $value['type'] == 'color' ) {
306
- $type = 'text';
307
- $value['class'] .= 'colorpick';
308
- $description .= '<div id="colorPickerDiv_' . esc_attr( $value['id'] ) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>';
309
- }
310
-
311
- ?><tr valign="top">
312
  <th scope="row" class="titledesc">
313
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
314
- <?php echo $tip; ?>
315
  </th>
316
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
317
- <input
318
- name="<?php echo esc_attr( $value['id'] ); ?>"
319
- id="<?php echo esc_attr( $value['id'] ); ?>"
320
- type="<?php echo esc_attr( $type ); ?>"
321
- style="<?php echo esc_attr( $value['css'] ); ?>"
322
- value="<?php echo esc_attr( $option_value ); ?>"
323
- placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
324
- class="<?php echo esc_attr( $value['class'] ); ?>"
325
- <?php echo implode( ' ', $custom_attributes ); ?>
326
- /> <?php echo $description; ?>
327
- </td>
328
- </tr><?php
329
- break;
330
-
331
- // Textarea
332
- case 'textarea':
333
-
334
- $option_value = self::get_option( $value['id'], $value['default'] );
335
-
336
- ?><tr valign="top">
 
337
  <th scope="row" class="titledesc">
338
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
339
- <?php echo $tip; ?>
340
  </th>
341
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
342
- <?php echo $description; ?>
343
-
344
- <textarea
345
- name="<?php echo esc_attr( $value['id'] ); ?>"
346
- id="<?php echo esc_attr( $value['id'] ); ?>"
347
- style="<?php echo esc_attr( $value['css'] ); ?>"
348
- class="<?php echo esc_attr( $value['class'] ); ?>"
349
- <?php echo implode( ' ', $custom_attributes ); ?>
350
- ><?php echo esc_textarea( $option_value ); ?></textarea>
351
- </td>
352
- </tr><?php
353
- break;
354
-
355
- // Select boxes
356
- case 'select' :
357
- case 'multiselect' :
358
-
359
- $option_value = self::get_option( $value['id'], $value['default'] );
360
-
361
- ?><tr valign="top">
 
362
  <th scope="row" class="titledesc">
363
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
364
- <?php echo $tip; ?>
365
  </th>
366
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
367
- <select
368
- name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>"
369
- id="<?php echo esc_attr( $value['id'] ); ?>"
370
- style="<?php echo esc_attr( $value['css'] ); ?>"
371
- class="chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
372
- <?php echo implode( ' ', $custom_attributes ); ?>
373
- <?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
374
- >
375
- <?php
376
- foreach ( $value['options'] as $key => $val ) {
377
- ?>
378
- <option value="<?php echo esc_attr( $key ); ?>" <?php
379
-
380
- if ( is_array( $option_value ) )
381
- selected( in_array( $key, $option_value ), true );
382
- else
383
- selected( $option_value, $key );
384
-
385
- ?>><?php echo $val ?></option>
386
- <?php
387
- }
388
- ?>
389
- </select> <?php echo $description; ?>
390
- </td>
391
- </tr><?php
392
- break;
393
-
394
- // Select boxes with optgroup
395
- case 'groupselect' :
396
-
397
- $option_value = self::get_option( $value['id'], $value['default'] );
398
-
399
- ?><tr valign="top">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  <th scope="row" class="titledesc">
401
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
402
- <?php echo $tip; ?>
403
  </th>
404
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
405
- <select
406
- name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>"
407
- id="<?php echo esc_attr( $value['id'] ); ?>"
408
- style="<?php echo esc_attr( $value['css'] ); ?>"
409
- class="chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
410
- <?php echo implode( ' ', $custom_attributes ); ?>
411
- <?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
412
- >
413
- <?php
414
- foreach ( $value['options'] as $group => $options ) {
415
- ?>
416
- <optgroup label="<?php _e( $group, 'sportspress' ); ?>">
417
- <?php
418
- foreach ( $options as $key => $val ) {
419
- ?>
420
- <option value="<?php echo esc_attr( $key ); ?>" <?php
421
-
422
- if ( is_array( $option_value ) )
423
- selected( in_array( $key, $option_value ), true );
424
- else
425
- selected( $option_value, $key );
426
-
427
- ?>><?php echo $val ?></option>
428
- <?php
429
- }
430
- ?>
431
- </optgroup>
432
- <?php
433
- }
434
- ?>
435
- </select> <?php echo $description; ?>
436
- </td>
437
- </tr><?php
438
- break;
439
-
440
- // Select sport
441
- case 'sport' :
442
-
443
- $default = apply_filters( 'sportspress_default_sport', 'soccer' );
444
- $option_value = self::get_option( $value['id'], $value['default'] );
445
- if ( 'none' === $option_value ) $option_value = $default;
446
-
447
- $categories = SP_Admin_Sports::sport_category_names();
448
-
449
- ?><tr valign="top">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
  <th scope="row" class="titledesc">
451
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
452
- <?php echo $tip; ?>
453
  </th>
454
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
455
- <select
456
- name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>"
457
- id="<?php echo esc_attr( $value['id'] ); ?>"
458
- style="<?php echo esc_attr( $value['css'] ); ?>"
459
- class="sp-select-sport chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
460
- <?php echo implode( ' ', $custom_attributes ); ?>
461
- <?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
462
- >
463
- <?php
464
- foreach ( $value['options'] as $group => $options ) {
465
- ?>
466
- <optgroup label="<?php echo sp_array_value( $categories, $group, $group ); ?>">
467
- <?php
468
- foreach ( $options as $key => $val ) {
469
- ?>
470
- <option value="<?php echo esc_attr( $key ); ?>" <?php
471
-
472
- if ( is_array( $option_value ) )
473
- selected( in_array( $key, $option_value ), true );
474
- else
475
- selected( $option_value, $key );
476
-
477
- ?>><?php echo $val ?></option>
478
- <?php
479
- }
480
- ?>
481
- </optgroup>
482
- <?php
483
- }
484
- ?>
485
- </select> <?php echo $description; ?> <a class="button button-small sp-configure-sport" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress-config' ), 'admin.php' ) ) ); ?>"><?php _e( 'Configure', 'sportspress' ); ?></a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  <p>
487
  <label>
488
  <input type="checkbox" name="add_sample_data" id="add_sample_data" <?php checked( sp_array_value( $value, 'welcome' ) ); ?>>
489
- <?php _e( 'Install demo content', 'sportspress' ); ?>
490
  </label>
491
  </p>
492
- </td>
493
- </tr><?php
494
- break;
495
-
496
- // Radio inputs
497
- case 'radio' :
498
 
499
- $option_value = self::get_option( $value['id'], $value['default'] );
 
 
500
 
501
- ?><tr valign="top">
 
502
  <th scope="row" class="titledesc">
503
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
504
- <?php echo $tip; ?>
505
  </th>
506
- <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
507
- <fieldset>
508
- <?php echo $description; ?>
509
- <ul>
510
- <?php
511
- foreach ( $value['options'] as $key => $val ) {
512
- ?>
513
- <li>
514
- <label><input
515
- name="<?php echo esc_attr( $value['id'] ); ?>"
516
- value="<?php echo $key; ?>"
517
- type="radio"
518
- style="<?php echo esc_attr( $value['css'] ); ?>"
519
- class="<?php echo esc_attr( $value['class'] ); ?>"
520
- <?php echo implode( ' ', $custom_attributes ); ?>
521
- <?php checked( $key, $option_value ); ?>
522
- /> <?php echo $val ?></label>
523
- </li>
524
- <?php
525
- }
526
- ?>
527
- </ul>
528
- </fieldset>
529
- </td>
530
- </tr><?php
531
- break;
532
-
533
- // Checkbox input
534
- case 'checkbox' :
535
-
536
- $option_value = self::get_option( $value['id'], $value['default'] );
537
- $visbility_class = array();
538
-
539
- if ( ! isset( $value['hide_if_checked'] ) ) {
540
- $value['hide_if_checked'] = false;
541
- }
542
- if ( ! isset( $value['show_if_checked'] ) ) {
543
- $value['show_if_checked'] = false;
544
- }
545
- if ( $value['hide_if_checked'] == 'yes' || $value['show_if_checked'] == 'yes' ) {
546
- $visbility_class[] = 'hidden_option';
547
- }
548
- if ( $value['hide_if_checked'] == 'option' ) {
549
- $visbility_class[] = 'hide_options_if_checked';
550
- }
551
- if ( $value['show_if_checked'] == 'option' ) {
552
- $visbility_class[] = 'show_options_if_checked';
553
- }
554
-
555
- if ( ! isset( $value['checkboxgroup'] ) || 'start' == $value['checkboxgroup'] ) {
556
- ?>
557
- <tr valign="top" class="<?php echo esc_attr( implode( ' ', $visbility_class ) ); ?>">
558
- <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?></th>
559
  <td class="forminp forminp-checkbox">
560
  <fieldset>
561
- <?php
562
- } else {
563
- ?>
564
- <fieldset class="<?php echo esc_attr( implode( ' ', $visbility_class ) ); ?>">
565
- <?php
566
- }
567
-
568
- if ( ! empty( $value['title'] ) ) {
569
- ?>
570
- <legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ) ?></span></legend>
571
- <?php
572
- }
573
-
574
- ?>
575
- <label for="<?php echo $value['id'] ?>">
576
  <input
577
  name="<?php echo esc_attr( $value['id'] ); ?>"
578
  id="<?php echo esc_attr( $value['id'] ); ?>"
579
  type="checkbox"
580
  value="1"
581
- <?php checked( $option_value, 'yes'); ?>
582
- <?php echo implode( ' ', $custom_attributes ); ?>
583
- /> <?php echo $description ?>
584
- </label> <?php echo $tip; ?>
585
- <?php
586
 
587
- if ( ! isset( $value['checkboxgroup'] ) || 'end' == $value['checkboxgroup'] ) {
588
- ?>
589
  </fieldset>
590
  </td>
591
  </tr>
592
- <?php
593
- } else {
594
- ?>
595
  </fieldset>
596
- <?php
597
- }
598
- break;
599
-
600
- // Default: run an action
601
- default:
602
- do_action( 'sportspress_admin_field_' . $value['type'], $value );
603
- break;
604
- }
 
605
  }
606
- }
607
-
608
- /**
609
- * Save admin fields.
610
- *
611
- * Loops though the sportspress options array and outputs each field.
612
- *
613
- * @access public
614
- * @param array $options Opens array to output
615
- * @return bool
616
- */
617
- public static function save_fields( $options ) {
618
- if ( empty( $_POST ) )
619
- return false;
620
-
621
- // Options to update will be stored here
622
- $update_options = array();
623
-
624
- // Loop options and get values to save
625
- foreach ( $options as $value ) {
626
-
627
- if ( ! isset( $value['id'] ) )
628
- continue;
629
-
630
- $type = isset( $value['type'] ) ? sanitize_title( $value['type'] ) : '';
631
-
632
- // Get the option name
633
- $option_value = null;
634
-
635
- switch ( $type ) {
636
-
637
- // Standard types
638
- case 'checkbox' :
639
-
640
- if ( isset( $_POST[ $value['id'] ] ) ) {
641
- $option_value = 'yes';
642
- } else {
643
- $option_value = 'no';
644
- }
645
 
646
- break;
647
-
648
- case 'textarea' :
649
-
650
- if ( isset( $_POST[$value['id']] ) ) {
651
- $option_value = wp_kses_post( trim( stripslashes( $_POST[ $value['id'] ] ) ) );
652
- } else {
653
- $option_value = '';
654
- }
655
-
656
- break;
657
-
658
- case 'text' :
659
- case 'email':
660
- case 'number':
661
- case 'select' :
662
- case 'groupselect' :
663
- case 'sport' :
664
- case 'color' :
665
- case 'password' :
666
- case 'radio' :
667
-
668
- if ( isset( $_POST[$value['id']] ) ) {
669
- $option_value = sanitize_text_field( stripslashes( $_POST[ $value['id'] ] ) );
670
- } else {
671
- $option_value = '';
672
- }
673
-
674
- break;
675
-
676
- // Special types
677
- case "multiselect" :
678
- case "multi_select_countries" :
679
 
680
- // Get countries array
681
- if ( isset( $_POST[ $value['id'] ] ) )
682
- $selected_countries = array_map( 'sanitize_text_field', array_map( 'stripslashes', (array) $_POST[ $value['id'] ] ) );
683
- else
684
- $selected_countries = array();
685
 
686
- $option_value = $selected_countries;
 
687
 
688
- break;
 
 
689
 
690
- // Custom handling
691
- default :
692
 
693
- do_action( 'sportspress_update_option_' . $type, $value );
 
694
 
695
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
696
 
697
- }
698
 
699
- if ( ! is_null( $option_value ) ) {
700
- // Check if option is an array
701
- if ( strstr( $value['id'], '[' ) ) {
702
 
703
- parse_str( $value['id'], $option_array );
704
 
705
- // Option name is first key
706
- $option_name = current( array_keys( $option_array ) );
707
 
708
- // Get old option value
709
- if ( ! isset( $update_options[ $option_name ] ) )
710
- $update_options[ $option_name ] = get_option( $option_name, array() );
 
711
 
712
- if ( ! is_array( $update_options[ $option_name ] ) )
713
- $update_options[ $option_name ] = array();
 
714
 
715
- // Set keys and value
716
- $key = key( $option_array[ $option_name ] );
717
 
718
- $update_options[ $option_name ][ $key ] = $option_value;
719
 
720
- // Single value
721
- } else {
722
- $update_options[ $value['id'] ] = $option_value;
 
723
  }
724
- }
725
 
726
- // Custom handling
727
- do_action( 'sportspress_update_option', $value );
728
- }
729
 
730
- // Now save the options
731
- foreach( $update_options as $name => $value )
732
- update_option( $name, $value );
 
733
 
734
- return true;
 
735
  }
736
- }
737
 
738
  endif;
5
  * @author ThemeBoy
6
  * @category Admin
7
  * @package SportsPress/Admin
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( ! class_exists( 'SP_Admin_Settings' ) ) :
16
 
 
 
 
 
 
 
 
 
 
 
17
  /**
18
+ * SP_Admin_Settings
19
  */
20
+ class SP_Admin_Settings {
 
 
21
 
22
+ private static $settings = array();
23
+ private static $errors = array();
24
+ private static $messages = array();
25
+ private static $overrides = array();
26
 
27
+ /**
28
+ * Include the settings page classes
29
+ */
30
+ public static function get_settings_pages() {
31
+ if ( empty( self::$settings ) ) {
32
+ $settings = array();
33
 
34
+ include_once 'class-sp-admin-sports.php';
35
+ include_once 'settings/class-sp-settings-page.php';
36
 
37
+ $settings[] = include 'settings/class-sp-settings-modules.php';
38
+ $settings[] = include 'settings/class-sp-settings-general.php';
39
+ $settings[] = include 'settings/class-sp-settings-events.php';
40
+ $settings[] = include 'settings/class-sp-settings-teams.php';
41
+ $settings[] = include 'settings/class-sp-settings-players.php';
42
+ $settings[] = include 'settings/class-sp-settings-staff.php';
43
 
44
+ $settings = apply_filters( 'sportspress_get_settings_pages', $settings );
 
 
 
 
 
 
 
45
 
46
+ $settings[] = include 'settings/class-sp-settings-text.php';
 
 
 
47
 
48
+ if (
49
+ ( ! is_multisite() && current_user_can( 'manage_options' ) ) ||
50
+ ( is_multisite() && current_user_can( 'manage_network_options' ) )
51
+ ) {
52
+ $settings[] = include 'settings/class-sp-settings-licenses.php';
53
+ }
 
 
54
 
55
+ $settings[] = include 'settings/class-sp-settings-status.php';
 
 
 
56
 
57
+ self::$settings = apply_filters( 'sportspress_get_settings_config_pages', $settings );
58
+ }
59
+ return self::$settings;
60
+ }
61
 
62
+ /**
63
+ * Save the settings
64
+ */
65
+ public static function save() {
66
+ global $current_section, $current_tab;
67
 
68
+ if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'sportspress-settings' ) ) {
69
+ die( esc_html__( 'Action failed. Please refresh the page and retry.', 'sportspress' ) );
70
+ }
 
 
 
 
71
 
72
+ // Trigger actions
73
+ do_action( 'sportspress_settings_save_' . $current_tab );
74
+ do_action( 'sportspress_update_options_' . $current_tab );
75
+ do_action( 'sportspress_update_options' );
 
 
 
76
 
77
+ self::add_message( esc_attr__( 'Your settings have been saved.', 'sportspress' ) );
 
 
 
 
 
 
78
 
79
+ do_action( 'sportspress_settings_saved' );
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
 
81
 
82
+ /**
83
+ * Add a message
84
+ *
85
+ * @param string $text
86
+ */
87
+ public static function add_message( $text ) {
88
+ self::$messages[] = $text;
89
+ }
 
 
90
 
91
+ /**
92
+ * Add an override
93
+ *
94
+ * @param string $text
95
+ */
96
+ public static function add_override( $text ) {
97
+ self::$overrides[] = $text;
98
+ }
99
 
100
+ /**
101
+ * Add an error
102
+ *
103
+ * @param string $text
104
+ */
105
+ public static function add_error( $text ) {
106
+ self::$errors[] = $text;
107
+ }
108
 
109
+ /**
110
+ * Output messages + overrides + errors
111
+ */
112
+ public static function show_messages() {
113
+ if ( sizeof( self::$errors ) > 0 ) {
114
+ foreach ( self::$errors as $error ) {
115
+ echo '<div id="message" class="error fade"><p><strong>' . esc_html( $error ) . '</strong></p></div>';
116
+ }
117
+ } elseif ( sizeof( self::$overrides ) > 0 ) {
118
+ foreach ( self::$overrides as $override ) {
119
+ echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $override ) . '</strong></p></div>';
120
+ }
121
+ } elseif ( sizeof( self::$messages ) > 0 ) {
122
+ foreach ( self::$messages as $message ) {
123
+ echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $message ) . '</strong></p></div>';
124
+ }
125
+ }
126
+ }
127
 
128
+ /**
129
+ * Settings page.
130
+ *
131
+ * Handles the display of the main sportspress settings page in admin.
132
+ *
133
+ * @access public
134
+ * @return void
135
+ */
136
+ public static function output() {
137
+ global $current_section, $current_tab;
138
+
139
+ do_action( 'sportspress_settings_start' );
140
+
141
+ wp_enqueue_script( 'sportspress_settings', SP()->plugin_url() . '/assets/js/admin/settings.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'chosen' ), SP()->version, true );
142
+
143
+ wp_localize_script(
144
+ 'sportspress_settings',
145
+ 'localized_strings',
146
+ array(
147
+ 'none' => esc_attr__( 'None', 'sportspress' ),
148
+ )
149
+ );
150
+
151
+ // Include settings pages
152
+ self::get_settings_pages();
153
+
154
+ // Get current tab/section
155
+ $current_tab = empty( $_GET['tab'] ) ? 'modules' : sanitize_title( wp_unslash( $_GET['tab'] ) );
156
+ $current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( wp_unslash( $_REQUEST['section'] ) );
157
+
158
+ // Save settings if data has been posted
159
+ if ( ! empty( $_POST ) ) {
160
+ self::save();
161
+ }
162
 
163
+ // Add any posted messages
164
+ if ( ! empty( $_GET['sp_error'] ) ) {
165
+ self::add_error( stripslashes( sanitize_text_field( wp_unslash( $_GET['sp_error'] ) ) ) );
166
+ }
167
 
168
+ if ( ! empty( $_GET['sp_message'] ) ) {
169
+ self::add_message( stripslashes( sanitize_text_field( wp_unslash( $_GET['sp_message'] ) ) ) );
170
+ }
171
 
172
+ self::show_messages();
 
 
173
 
174
+ // Get tabs for the settings page
175
+ $tabs = apply_filters( 'sportspress_settings_tabs_array', array() );
176
 
177
+ include 'views/html-admin-settings.php';
178
+ }
179
 
180
+ /**
181
+ * Get a setting from the settings API.
182
+ *
183
+ * @param mixed $option
184
+ * @return string
185
+ */
186
+ public static function get_option( $option_name, $default = '' ) {
187
+ // Array value
188
+ if ( strstr( $option_name, '[' ) ) {
189
 
190
+ parse_str( html_entity_decode( $option_name ), $option_array );
 
191
 
192
+ // Option name is first key
193
+ $option_name = current( array_keys( $option_array ) );
 
 
 
 
 
 
 
194
 
195
+ // Get value
196
+ $option_values = get_option( $option_name, '' );
197
 
198
+ $key = key( $option_array[ $option_name ] );
 
199
 
200
+ if ( isset( $option_values[ $key ] ) ) {
201
+ $option_value = $option_values[ $key ];
202
+ } else {
203
+ $option_value = null;
204
+ }
205
 
206
+ // Single value
207
+ } else {
208
+ $option_value = get_option( $option_name, null );
209
+ }
210
 
211
+ if ( is_array( $option_value ) ) {
212
+ $option_value = array_map( 'stripslashes', $option_value );
213
+ } elseif ( ! is_null( $option_value ) ) {
214
+ $option_value = stripslashes( $option_value );
215
+ }
216
 
217
+ return $option_value === null ? $default : $option_value;
 
 
218
  }
219
 
220
+ /**
221
+ * Output admin fields.
222
+ *
223
+ * Loops though the sportspress options array and outputs each field.
224
+ *
225
+ * @access public
226
+ * @param array $options Opens array to output
227
+ */
228
+ public static function output_fields( $options ) {
229
+ foreach ( $options as $value ) {
230
+ if ( ! isset( $value['type'] ) ) {
231
+ continue;
232
+ }
233
+ if ( ! isset( $value['id'] ) ) {
234
+ $value['id'] = '';
235
+ }
236
+ if ( ! isset( $value['title'] ) ) {
237
+ $value['title'] = isset( $value['name'] ) ? $value['name'] : '';
238
+ }
239
+ if ( ! isset( $value['class'] ) ) {
240
+ $value['class'] = '';
241
+ }
242
+ if ( ! isset( $value['css'] ) ) {
243
+ $value['css'] = '';
244
+ }
245
+ if ( ! isset( $value['default'] ) ) {
246
+ $value['default'] = '';
247
+ }
248
+ if ( ! isset( $value['desc'] ) ) {
249
+ $value['desc'] = '';
250
+ }
251
+ if ( ! isset( $value['desc_tip'] ) ) {
252
+ $value['desc_tip'] = false;
253
+ }
254
+ if ( ! isset( $value['placeholder'] ) ) {
255
+ $value['placeholder'] = '';
256
+ }
257
+
258
+ // Custom attribute handling
259
+ $custom_attributes = array();
260
 
261
+ if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) {
262
+ foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) {
263
+ $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
264
+ }
265
+ }
266
 
267
+ // Description handling
268
+ if ( $value['desc_tip'] === true ) {
269
+ $description = '';
270
+ $tip = $value['desc'];
271
+ } elseif ( ! empty( $value['desc_tip'] ) ) {
272
+ $description = $value['desc'];
273
+ $tip = $value['desc_tip'];
274
+ } elseif ( ! empty( $value['desc'] ) ) {
275
+ $description = $value['desc'];
276
+ $tip = '';
277
+ } else {
278
+ $description = $tip = '';
279
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
281
+ if ( $description && in_array( $value['type'], array( 'textarea', 'radio' ) ) ) {
282
+ $description = '<p style="margin-top:0">' . wp_kses_post( $description ) . '</p>';
283
+ } elseif ( $description && in_array( $value['type'], array( 'checkbox' ) ) ) {
284
+ $description = wp_kses_post( $description );
285
+ } elseif ( $description && in_array( $value['type'], array( 'select' ) ) ) {
286
+ $description = '<p class="description">' . wp_kses_post( $description ) . '</p>';
287
+ } elseif ( $description ) {
288
+ $description = '<span class="description">' . wp_kses_post( $description ) . '</span>';
289
+ }
290
 
291
+ if ( $tip && in_array( $value['type'], array( 'checkbox' ) ) ) {
292
 
293
+ $tip = '<p class="description">' . $tip . '</p>';
294
 
295
+ } elseif ( $tip ) {
296
 
297
+ $tip = '<i class="dashicons dashicons-editor-help sp-desc-tip" title="' . $tip . '" />';
298
 
299
+ }
300
 
301
+ // Switch based on type
302
+ switch ( $value['type'] ) {
303
+
304
+ // Section Titles
305
+ case 'title':
306
+ echo '<div class="sp-settings-section sp-settings-section-' . esc_attr( sp_array_value( $value, 'id' ) ) . '">';
307
+ echo '<a name="sp-settings-section-' . esc_attr( sp_array_value( $value, 'id' ) ) . '"></a>';
308
+ if ( ! empty( $value['title'] ) ) {
309
+ echo '<h3>' . esc_html( $value['title'] ) . '</h3>';
310
+ }
311
+ if ( ! empty( $value['desc'] ) ) {
312
+ echo wp_kses_post( wpautop( wptexturize( $value['desc'] ) ) );
313
+ }
314
+ echo '<table class="form-table">' . "\n\n";
315
+ if ( ! empty( $value['id'] ) ) {
316
+ do_action( 'sportspress_settings_' . sanitize_title( $value['id'] ) );
317
+ }
318
+ break;
319
+
320
+ // Section Ends
321
+ case 'sectionend':
322
+ if ( ! empty( $value['id'] ) ) {
323
+ do_action( 'sportspress_settings_' . sanitize_title( $value['id'] ) . '_end' );
324
+ }
325
+ echo '</table>';
326
+ if ( ! empty( $value['id'] ) ) {
327
+ do_action( 'sportspress_settings_' . sanitize_title( $value['id'] ) . '_after' );
328
+ }
329
+ echo '</div>';
330
+ break;
331
+
332
+ // Standard text inputs and subtypes like 'number'
333
+ case 'text':
334
+ case 'email':
335
+ case 'number':
336
+ case 'color':
337
+ case 'password':
338
+ $type = $value['type'];
339
+ $class = '';
340
+ $option_value = self::get_option( $value['id'], $value['default'] );
341
+
342
+ if ( $value['type'] == 'color' ) {
343
+ $type = 'text';
344
+ $value['class'] .= 'colorpick';
345
+ $description .= '<div id="colorPickerDiv_' . esc_attr( $value['id'] ) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>';
346
+ }
347
+
348
+ ?><tr valign="top">
 
349
  <th scope="row" class="titledesc">
350
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
351
+ <?php echo esc_html( $tip ); ?>
352
  </th>
353
+ <td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
354
+ <input
355
+ name="<?php echo esc_attr( $value['id'] ); ?>"
356
+ id="<?php echo esc_attr( $value['id'] ); ?>"
357
+ type="<?php echo esc_attr( $type ); ?>"
358
+ style="<?php echo esc_attr( $value['css'] ); ?>"
359
+ value="<?php echo esc_attr( $option_value ); ?>"
360
+ placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
361
+ class="<?php echo esc_attr( $value['class'] ); ?>"
362
+ <?php echo esc_html( implode( ' ', $custom_attributes ) ); ?>
363
+ /> <?php echo wp_kses_post( $description ); ?>
364
+ </td>
365
+ </tr>
366
+ <?php
367
+ break;
368
+
369
+ // Textarea
370
+ case 'textarea':
371
+ $option_value = self::get_option( $value['id'], $value['default'] );
372
+
373
+ ?>
374
+ <tr valign="top">
375
  <th scope="row" class="titledesc">
376
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
377
+ <?php echo esc_html( $tip ); ?>
378
  </th>
379
+ <td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
380
+ <?php echo wp_kses_post( $description ); ?>
381
+
382
+ <textarea
383
+ name="<?php echo esc_attr( $value['id'] ); ?>"
384
+ id="<?php echo esc_attr( $value['id'] ); ?>"
385
+ style="<?php echo esc_attr( $value['css'] ); ?>"
386
+ class="<?php echo esc_attr( $value['class'] ); ?>"
387
+ <?php echo esc_html( implode( ' ', $custom_attributes ) ); ?>
388
+ ><?php echo esc_textarea( $option_value ); ?></textarea>
389
+ </td>
390
+ </tr>
391
+ <?php
392
+ break;
393
+
394
+ // Select boxes
395
+ case 'select':
396
+ case 'multiselect':
397
+ $option_value = self::get_option( $value['id'], $value['default'] );
398
+
399
+ ?>
400
+ <tr valign="top">
401
  <th scope="row" class="titledesc">
402
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
403
+ <?php echo esc_html( $tip ); ?>
404
  </th>
405
+ <td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
406
+ <select
407
+ name="<?php echo esc_attr( $value['id'] ); ?>
408
+ <?php
409
+ if ( $value['type'] == 'multiselect' ) {
410
+ echo '[]';}
411
+ ?>
412
+ "
413
+ id="<?php echo esc_attr( $value['id'] ); ?>"
414
+ style="<?php echo esc_attr( $value['css'] ); ?>"
415
+ class="chosen-select
416
+ <?php
417
+ if ( is_rtl() ) :
418
+ ?>
419
+ chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
420
+ <?php echo esc_html( implode( ' ', $custom_attributes ) ); ?>
421
+ <?php
422
+ if ( $value['type'] == 'multiselect' ) {
423
+ echo 'multiple="multiple"';}
424
+ ?>
425
+ >
426
+ <?php
427
+ foreach ( $value['options'] as $key => $val ) {
428
+ ?>
429
+ <option value="<?php echo esc_attr( $key ); ?>"
430
+ <?php
431
+
432
+ if ( is_array( $option_value ) ) {
433
+ selected( in_array( $key, $option_value ), true );
434
+ } else {
435
+ selected( $option_value, $key );
436
+ }
437
+
438
+ ?>
439
+ ><?php echo esc_attr( $val ); ?></option>
440
+ <?php
441
+ }
442
+ ?>
443
+ </select> <?php echo wp_kses_post( $description ); ?>
444
+ </td>
445
+ </tr>
446
+ <?php
447
+ break;
448
+
449
+ // Select boxes with optgroup
450
+ case 'groupselect':
451
+ $option_value = self::get_option( $value['id'], $value['default'] );
452
+
453
+ ?>
454
+ <tr valign="top">
455
  <th scope="row" class="titledesc">
456
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
457
+ <?php echo esc_html( $tip ); ?>
458
  </th>
459
+ <td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
460
+ <select
461
+ name="<?php echo esc_attr( $value['id'] ); ?>
462
+ <?php
463
+ if ( $value['type'] == 'multiselect' ) {
464
+ echo '[]';}
465
+ ?>
466
+ "
467
+ id="<?php echo esc_attr( $value['id'] ); ?>"
468
+ style="<?php echo esc_attr( $value['css'] ); ?>"
469
+ class="chosen-select
470
+ <?php
471
+ if ( is_rtl() ) :
472
+ ?>
473
+ chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
474
+ <?php echo esc_html( implode( ' ', $custom_attributes ) ); ?>
475
+ <?php
476
+ if ( $value['type'] == 'multiselect' ) {
477
+ echo 'multiple="multiple"';}
478
+ ?>
479
+ >
480
+ <?php
481
+ foreach ( $value['options'] as $group => $options ) {
482
+ ?>
483
+ <optgroup label="<?php esc_attr_e( $group, 'sportspress' ); ?>">
484
+ <?php
485
+ foreach ( $options as $key => $val ) {
486
+ ?>
487
+ <option value="<?php echo esc_attr( $key ); ?>"
488
+ <?php
489
+
490
+ if ( is_array( $option_value ) ) {
491
+ selected( in_array( $key, $option_value ), true );
492
+ } else {
493
+ selected( $option_value, $key );
494
+ }
495
+
496
+ ?>
497
+ ><?php echo esc_attr( $val ); ?></option>
498
+ <?php
499
+ }
500
+ ?>
501
+ </optgroup>
502
+ <?php
503
+ }
504
+ ?>
505
+ </select> <?php echo wp_kses_post( $description ); ?>
506
+ </td>
507
+ </tr>
508
+ <?php
509
+ break;
510
+
511
+ // Select sport
512
+ case 'sport':
513
+ $default = apply_filters( 'sportspress_default_sport', 'soccer' );
514
+ $option_value = self::get_option( $value['id'], $value['default'] );
515
+ if ( 'none' === $option_value ) {
516
+ $option_value = $default;
517
+ }
518
+
519
+ $categories = SP_Admin_Sports::sport_category_names();
520
+
521
+ ?>
522
+ <tr valign="top">
523
  <th scope="row" class="titledesc">
524
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
525
+ <?php echo esc_html( $tip ); ?>
526
  </th>
527
+ <td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
528
+ <select
529
+ name="<?php echo esc_attr( $value['id'] ); ?>
530
+ <?php
531
+ if ( $value['type'] == 'multiselect' ) {
532
+ echo '[]';}
533
+ ?>
534
+ "
535
+ id="<?php echo esc_attr( $value['id'] ); ?>"
536
+ style="<?php echo esc_attr( $value['css'] ); ?>"
537
+ class="sp-select-sport chosen-select
538
+ <?php
539
+ if ( is_rtl() ) :
540
+ ?>
541
+ chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
542
+ <?php echo esc_html( implode( ' ', $custom_attributes ) ); ?>
543
+ <?php
544
+ if ( $value['type'] == 'multiselect' ) {
545
+ echo 'multiple="multiple"';}
546
+ ?>
547
+ >
548
+ <?php
549
+ foreach ( $value['options'] as $group => $options ) {
550
+ ?>
551
+ <optgroup label="<?php echo esc_attr( sp_array_value( $categories, $group, $group ) ); ?>">
552
+ <?php
553
+ foreach ( $options as $key => $val ) {
554
+ ?>
555
+ <option value="<?php echo esc_attr( $key ); ?>"
556
+ <?php
557
+
558
+ if ( is_array( $option_value ) ) {
559
+ selected( in_array( $key, $option_value ), true );
560
+ } else {
561
+ selected( $option_value, $key );
562
+ }
563
+
564
+ ?>
565
+ ><?php echo esc_attr( $val ); ?></option>
566
+ <?php
567
+ }
568
+ ?>
569
+ </optgroup>
570
+ <?php
571
+ }
572
+ ?>
573
+ </select> <?php echo wp_kses_post( $description ); ?> <a class="button button-small sp-configure-sport" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress-config' ), 'admin.php' ) ) ); ?>"><?php esc_html_e( 'Configure', 'sportspress' ); ?></a>
574
  <p>
575
  <label>
576
  <input type="checkbox" name="add_sample_data" id="add_sample_data" <?php checked( sp_array_value( $value, 'welcome' ) ); ?>>
577
+ <?php esc_html_e( 'Install demo content', 'sportspress' ); ?>
578
  </label>
579
  </p>
580
+ </td>
581
+ </tr>
582
+ <?php
583
+ break;
 
 
584
 
585
+ // Radio inputs
586
+ case 'radio':
587
+ $option_value = self::get_option( $value['id'], $value['default'] );
588
 
589
+ ?>
590
+ <tr valign="top">
591
  <th scope="row" class="titledesc">
592
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
593
+ <?php echo wp_kses_post( $tip ); ?>
594
  </th>
595
+ <td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
596
+ <fieldset>
597
+ <?php echo wp_kses_post( $description ); ?>
598
+ <ul>
599
+ <?php
600
+ foreach ( $value['options'] as $key => $val ) {
601
+ ?>
602
+ <li>
603
+ <label><input
604
+ name="<?php echo esc_attr( $value['id'] ); ?>"
605
+ value="<?php echo esc_attr( $key ); ?>"
606
+ type="radio"
607
+ style="<?php echo esc_attr( $value['css'] ); ?>"
608
+ class="<?php echo esc_attr( $value['class'] ); ?>"
609
+ <?php echo esc_html( implode( ' ', $custom_attributes ) ); ?>
610
+ <?php checked( $key, $option_value ); ?>
611
+ /> <?php echo esc_attr( $val ); ?></label>
612
+ </li>
613
+ <?php
614
+ }
615
+ ?>
616
+ </ul>
617
+ </fieldset>
618
+ </td>
619
+ </tr>
620
+ <?php
621
+ break;
622
+
623
+ // Checkbox input
624
+ case 'checkbox':
625
+ $option_value = self::get_option( $value['id'], $value['default'] );
626
+ $visbility_class = array();
627
+
628
+ if ( ! isset( $value['hide_if_checked'] ) ) {
629
+ $value['hide_if_checked'] = false;
630
+ }
631
+ if ( ! isset( $value['show_if_checked'] ) ) {
632
+ $value['show_if_checked'] = false;
633
+ }
634
+ if ( $value['hide_if_checked'] == 'yes' || $value['show_if_checked'] == 'yes' ) {
635
+ $visbility_class[] = 'hidden_option';
636
+ }
637
+ if ( $value['hide_if_checked'] == 'option' ) {
638
+ $visbility_class[] = 'hide_options_if_checked';
639
+ }
640
+ if ( $value['show_if_checked'] == 'option' ) {
641
+ $visbility_class[] = 'show_options_if_checked';
642
+ }
643
+
644
+ if ( ! isset( $value['checkboxgroup'] ) || 'start' == $value['checkboxgroup'] ) {
645
+ ?>
646
+ <tr valign="top" class="<?php echo esc_attr( implode( ' ', $visbility_class ) ); ?>">
647
+ <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?></th>
648
  <td class="forminp forminp-checkbox">
649
  <fieldset>
650
+ <?php
651
+ } else {
652
+ ?>
653
+ <fieldset class="<?php echo esc_attr( implode( ' ', $visbility_class ) ); ?>">
654
+ <?php
655
+ }
656
+
657
+ if ( ! empty( $value['title'] ) ) {
658
+ ?>
659
+ <legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ); ?></span></legend>
660
+ <?php
661
+ }
662
+
663
+ ?>
664
+ <label for="<?php echo esc_attr( $value['id'] ); ?>">
665
  <input
666
  name="<?php echo esc_attr( $value['id'] ); ?>"
667
  id="<?php echo esc_attr( $value['id'] ); ?>"
668
  type="checkbox"
669
  value="1"
670
+ <?php checked( $option_value, 'yes' ); ?>
671
+ <?php echo esc_html( implode( ' ', $custom_attributes ) ); ?>
672
+ /> <?php echo wp_kses_post( $description ); ?>
673
+ </label> <?php echo wp_kses_post( $tip ); ?>
674
+ <?php
675
 
676
+ if ( ! isset( $value['checkboxgroup'] ) || 'end' == $value['checkboxgroup'] ) {
677
+ ?>
678
  </fieldset>
679
  </td>
680
  </tr>
681
+ <?php
682
+ } else {
683
+ ?>
684
  </fieldset>
685
+ <?php
686
+ }
687
+ break;
688
+
689
+ // Default: run an action
690
+ default:
691
+ do_action( 'sportspress_admin_field_' . $value['type'], $value );
692
+ break;
693
+ }
694
+ }
695
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
696
 
697
+ /**
698
+ * Save admin fields.
699
+ *
700
+ * Loops though the sportspress options array and outputs each field.
701
+ *
702
+ * @access public
703
+ * @param array $options Opens array to output
704
+ * @return bool
705
+ */
706
+ public static function save_fields( $options ) {
707
+ if ( empty( $_POST ) ) {
708
+ return false;
709
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
710
 
711
+ // Options to update will be stored here
712
+ $update_options = array();
 
 
 
713
 
714
+ // Loop options and get values to save
715
+ foreach ( $options as $value ) {
716
 
717
+ if ( ! isset( $value['id'] ) ) {
718
+ continue;
719
+ }
720
 
721
+ $type = isset( $value['type'] ) ? esc_attr( $value['type'] ) : '';
 
722
 
723
+ // Get the option name
724
+ $option_value = null;
725
 
726
+ switch ( $type ) {
727
+
728
+ // Standard types
729
+ case 'checkbox':
730
+ if ( isset( $_POST[ $value['id'] ] ) ) {
731
+ $option_value = 'yes';
732
+ } else {
733
+ $option_value = 'no';
734
+ }
735
+
736
+ break;
737
+
738
+ case 'textarea':
739
+ if ( isset( $_POST[ $value['id'] ] ) ) {
740
+ $option_value = wp_kses_post( trim( stripslashes( sanitize_text_field( wp_unslash( $_POST[ $value['id'] ] ) ) ) ) );
741
+ } else {
742
+ $option_value = '';
743
+ }
744
+
745
+ break;
746
+
747
+ case 'text':
748
+ case 'email':
749
+ case 'number':
750
+ case 'select':
751
+ case 'groupselect':
752
+ case 'sport':
753
+ case 'color':
754
+ case 'password':
755
+ case 'radio':
756
+ if ( isset( $_POST[ $value['id'] ] ) ) {
757
+ $option_value = sanitize_text_field( wp_unslash( $_POST[ $value['id'] ] ) );
758
+ } else {
759
+ $option_value = '';
760
+ }
761
+
762
+ break;
763
+
764
+ // Special types
765
+ case 'multiselect':
766
+ case 'multi_select_countries':
767
+ // Get countries array
768
+ if ( isset( $_POST[ $value['id'] ] ) ) {
769
+ $selected_countries = array_map( 'sanitize_text_field', array_map( 'wp_unslash', (array) $_POST[ $value['id'] ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
770
+ } else {
771
+ $selected_countries = array();
772
+ }
773
+
774
+ $option_value = $selected_countries;
775
+
776
+ break;
777
+
778
+ // Custom handling
779
+ default:
780
+ do_action( 'sportspress_update_option_' . $type, $value );
781
+
782
+ break;
783
 
784
+ }
785
 
786
+ if ( ! is_null( $option_value ) ) {
787
+ // Check if option is an array
788
+ if ( strstr( $value['id'], '[' ) ) {
789
 
790
+ parse_str( $value['id'], $option_array );
791
 
792
+ // Option name is first key
793
+ $option_name = current( array_keys( $option_array ) );
794
 
795
+ // Get old option value
796
+ if ( ! isset( $update_options[ $option_name ] ) ) {
797
+ $update_options[ $option_name ] = get_option( $option_name, array() );
798
+ }
799
 
800
+ if ( ! is_array( $update_options[ $option_name ] ) ) {
801
+ $update_options[ $option_name ] = array();
802
+ }
803
 
804
+ // Set keys and value
805
+ $key = key( $option_array[ $option_name ] );
806
 
807
+ $update_options[ $option_name ][ $key ] = $option_value;
808
 
809
+ // Single value
810
+ } else {
811
+ $update_options[ $value['id'] ] = $option_value;
812
+ }
813
  }
 
814
 
815
+ // Custom handling
816
+ do_action( 'sportspress_update_option', $value );
817
+ }
818
 
819
+ // Now save the options
820
+ foreach ( $update_options as $name => $value ) {
821
+ update_option( $name, $value );
822
+ }
823
 
824
+ return true;
825
+ }
826
  }
 
827
 
828
  endif;
includes/admin/class-sp-admin-setup-wizard.php CHANGED
@@ -9,10 +9,10 @@
9
  * @author WooThemes
10
  * @category Admin
11
  * @package SportsPress/Admin
12
- * @version 2.6.15
13
- */
14
  if ( ! defined( 'ABSPATH' ) ) {
15
- exit;
16
  }
17
 
18
  /**
@@ -20,774 +20,872 @@ if ( ! defined( 'ABSPATH' ) ) {
20
  */
21
  class SP_Admin_Setup_Wizard {
22
 
23
- /** @var string Current Step */
24
- private $step = '';
25
-
26
- /** @var array Steps for the setup wizard */
27
- private $steps = array();
28
-
29
- /** @var array Tweets user can optionally send after install */
30
- private $tweets = array(
31
- "Someone give me a high five, I just set up a new sports data website with #SportsPress and #WordPress!"
32
- );
33
-
34
- /**
35
- * Hook in tabs.
36
- */
37
- public function __construct() {
38
- if ( apply_filters( 'sportspress_enable_setup_wizard', true ) && current_user_can( 'manage_sportspress' ) ) {
39
- add_action( 'admin_menu', array( $this, 'admin_menus' ) );
40
- add_action( 'admin_init', array( $this, 'setup_wizard' ) );
41
- }
42
- }
43
-
44
- /**
45
- * Add admin menus/screens.
46
- */
47
- public function admin_menus() {
48
- add_dashboard_page( '', '', 'manage_options', 'sp-setup', '' );
49
- }
50
-
51
- /**
52
- * Show the setup wizard.
53
- */
54
- public function setup_wizard() {
55
- if ( empty( $_GET['page'] ) || 'sp-setup' !== $_GET['page'] ) {
56
- return;
57
- }
58
- $this->steps = array(
59
- 'introduction' => array(
60
- 'name' => __( 'Introduction', 'sportspress' ),
61
- 'view' => array( $this, 'sp_setup_introduction' ),
62
- 'handler' => ''
63
- ),
64
- 'basics' => array(
65
- 'name' => __( 'Basic Setup', 'sportspress' ),
66
- 'view' => array( $this, 'sp_setup_basics' ),
67
- 'handler' => array( $this, 'sp_setup_basics_save' )
68
- ),
69
- 'teams' => array(
70
- 'name' => __( 'Teams', 'sportspress' ),
71
- 'view' => array( $this, 'sp_setup_teams' ),
72
- 'handler' => array( $this, 'sp_setup_teams_save' )
73
- ),
74
- 'players_staff' => array(
75
- 'name' => __( 'Players', 'sportspress' ) . ' &amp; ' . __( 'Staff', 'sportspress' ),
76
- 'view' => array( $this, 'sp_setup_players_staff' ),
77
- 'handler' => array( $this, 'sp_setup_players_staff_save' ),
78
- ),
79
- 'venue' => array(
80
- 'name' => __( 'Venue', 'sportspress' ),
81
- 'view' => array( $this, 'sp_setup_venue' ),
82
- 'handler' => array( $this, 'sp_setup_venue_save' ),
83
- ),
84
- 'pages' => array(
85
- 'name' => __( 'Pages', 'sportspress' ),
86
- 'view' => array( $this, 'sp_setup_pages' ),
87
- 'handler' => array( $this, 'sp_setup_pages_save' )
88
- ),
89
- 'next_steps' => array(
90
- 'name' => __( 'Ready!', 'sportspress' ),
91
- 'view' => array( $this, 'sp_setup_ready' ),
92
- 'handler' => ''
93
- )
94
- );
95
- $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
96
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
97
-
98
- wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' );
99
- wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
100
- wp_enqueue_style( 'sportspress-setup', SP()->plugin_url() . '/assets/css/setup.css', array( 'dashicons', 'install' ), SP_VERSION );
101
-
102
- wp_register_script( 'chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
103
- wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
104
- wp_register_script( 'sportspress-setup', SP()->plugin_url() . '/assets/js/admin/sportspress-setup.js', array( 'jquery', 'chosen', 'jquery-tiptip' ), SP_VERSION, true );
105
-
106
- do_action( 'sp_setup_geocoder_scripts' );
107
-
108
- $strings = apply_filters( 'sportspress_localized_strings', array(
109
- 'none' => __( 'None', 'sportspress' ),
110
- 'remove_text' => __( '&mdash; Remove &mdash;', 'sportspress' ),
111
- ) );
112
-
113
- // Localize scripts
114
- wp_localize_script( 'sportspress-setup', 'localized_strings', $strings );
115
-
116
- if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
117
- call_user_func( $this->steps[ $this->step ]['handler'] );
118
- }
119
-
120
- ob_start();
121
- $this->setup_wizard_header();
122
- $this->setup_wizard_steps();
123
- $this->setup_wizard_content();
124
- $this->setup_wizard_footer();
125
- exit;
126
- }
127
-
128
- public function get_next_step_link() {
129
- $keys = array_keys( $this->steps );
130
- return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) + 1 ] );
131
- }
132
-
133
- /**
134
- * Setup Wizard Header.
135
- */
136
- public function setup_wizard_header() {
137
- ?>
138
- <!DOCTYPE html>
139
- <html <?php language_attributes(); ?>>
140
- <head>
141
- <meta name="viewport" content="width=device-width" />
142
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
143
- <title><?php _e( 'SportsPress', 'sportspress' ); ?> &rsaquo; <?php echo $this->steps[ $this->step ]['name']; ?></title>
144
- <?php do_action( 'admin_print_styles' ); ?>
145
- <?php do_action( 'admin_head' ); ?>
146
- </head>
147
- <body class="sp-setup wp-core-ui">
148
- <h1 id="sp-logo"><?php echo apply_filters( 'sportspress_logo', '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/modules/sportspress' . ( class_exists( 'SportsPress_Pro' ) ? '-pro' : '' ) . '.png" alt="' . __( 'SportsPress', 'sportspress' ) . '">' ); ?></h1>
149
- <?php
150
- }
151
-
152
- /**
153
- * Setup Wizard Footer.
154
- */
155
- public function setup_wizard_footer() {
156
- ?>
157
- <?php if ( 'next_steps' === $this->step ) : ?>
158
- <p class="sp-return-to-dashboard"><a href="<?php echo esc_url( admin_url( 'index.php?page=sp-about' ) ); ?>"><?php _e( 'Return to the WordPress Dashboard', 'sportspress' ); ?></a></p>
159
- <?php endif; ?>
160
- <?php wp_print_scripts( 'sportspress-setup' ); ?>
161
- </body>
162
- </html>
163
- <?php
164
- }
165
-
166
- /**
167
- * Output the steps.
168
- */
169
- public function setup_wizard_steps() {
170
- $ouput_steps = $this->steps;
171
- array_shift( $ouput_steps );
172
- ?>
173
- <ol class="sp-setup-steps">
174
- <?php foreach ( $ouput_steps as $step_key => $step ) : ?>
175
- <li class="<?php
176
- if ( $step_key === $this->step ) {
177
- echo 'active';
178
- } elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
179
- echo 'done';
180
- }
181
- ?>"><?php echo esc_html( $step['name'] ); ?></li>
182
- <?php endforeach; ?>
183
- </ol>
184
- <?php
185
- }
186
-
187
- /**
188
- * Output the content for the current step.
189
- */
190
- public function setup_wizard_content() {
191
- echo '<div class="sp-setup-content">';
192
- call_user_func( $this->steps[ $this->step ]['view'] );
193
- echo '</div>';
194
- }
195
-
196
- /**
197
- * Introduction Step.
198
- */
199
- public function sp_setup_introduction() {
200
- ?>
201
- <h1><?php _e( 'Welcome to SportsPress', 'sportspress' ); ?></h1>
202
- <p><?php _e( 'Thank you for choosing SportsPress to power your sports website! This quick setup wizard will help you configure the basic settings. <strong>It’s completely optional and shouldn’t take longer than five minutes.</strong>', 'sportspress' ); ?></p>
203
- <p><?php _e( 'No time right now? If you don’t want to go through the wizard, you can skip and return to the WordPress dashboard. Come back anytime if you change your mind!', 'sportspress' ); ?></p>
204
- <p class="sp-setup-actions step">
205
- <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button-primary button button-large button-next"><?php _e( 'Let\'s Go!', 'sportspress' ); ?></a>
206
- <a href="<?php echo esc_url( admin_url( 'index.php?page=sp-about' ) ); ?>" class="button button-large button-muted"><?php _e( 'Not right now', 'sportspress' ); ?></a>
207
- </p>
208
- <?php
209
- }
210
-
211
- /**
212
- * Basic Setup.
213
- */
214
- public function sp_setup_basics() {
215
- $class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
216
- ?>
217
- <h1><?php _e( 'Basic Setup', 'sportspress' ); ?></h1>
218
- <form method="post">
219
- <p><?php _e( 'Select your timezone and sport to get started.', 'sportspress' ); ?></p>
220
- <table class="form-table" cellspacing="0">
221
- <tr>
222
- <th scope="row"><?php _e( 'Timezone', 'sportspress' ); ?> <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'Choose a city in the same timezone as you.', 'sportspress' ); ?>"></i></th>
223
- <td>
224
- <select id="timezone_string" name="timezone_string" class="<?php echo esc_attr( $class ); ?>">
225
- <?php
226
- $current_offset = get_option('gmt_offset');
227
- $tzstring = get_option('timezone_string');
228
-
229
- $check_zone_info = true;
230
-
231
- // Remove old Etc mappings. Fallback to gmt_offset.
232
- if ( false !== strpos($tzstring,'Etc/GMT') )
233
- $tzstring = '';
234
-
235
- if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists
236
- $check_zone_info = false;
237
- if ( 0 == $current_offset )
238
- $tzstring = 'UTC+0';
239
- elseif ($current_offset < 0)
240
- $tzstring = 'UTC' . $current_offset;
241
- else
242
- $tzstring = 'UTC+' . $current_offset;
243
- }
244
- echo wp_timezone_choice( $tzstring );
245
- ?>
246
- </select>
247
- </td>
248
- </tr>
249
- <tr>
250
- <th scope="row"><?php echo _x( 'Sport', 'Page title', 'sportspress' ); ?></th>
251
- <td>
252
- <?php
253
- $options = SP_Admin_Sports::get_preset_options();
254
- $default = apply_filters( 'sportspress_default_sport', 'soccer' );
255
- $sport = get_option( 'sportspress_sport', $default );
256
- if ( 'none' === $sport ) $sport = $default;
257
- $categories = SP_Admin_Sports::sport_category_names();
258
- ?>
259
- <select name="sport" id="sport" class="sp-select-sport <?php echo esc_attr( $class ); ?>">
260
- <?php
261
- foreach ( $options as $group => $options ) {
262
- ?>
263
- <optgroup label="<?php echo sp_array_value( $categories, $group, $group ); ?>">
264
- <?php
265
- foreach ( $options as $key => $val ) {
266
- ?>
267
- <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $sport, $key ); ?>><?php echo $val ?></option>
268
- <?php
269
- }
270
- ?>
271
- </optgroup>
272
- <?php
273
- }
274
- ?>
275
- </select>
276
- </td>
277
- </tr>
278
- <tr>
279
- <th scope="row"><?php _e( 'Main League', 'sportspress' ); ?> <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'The name of a league or division.', 'sportspress' ); ?>"></i></th>
280
- <td>
281
- <input name="league" type="text" class="widefat" value="<?php _ex( 'Primary League', 'example', 'sportspress' ); ?>">
282
- </td>
283
- </tr>
284
- <tr>
285
- <th scope="row"><?php _e( 'Current Season', 'sportspress' ); ?></th>
286
- <td>
287
- <input name="season" type="text" class="widefat" value="<?php echo date( 'Y' ); ?>">
288
- </td>
289
- </tr>
290
- </table>
291
-
292
- <p class="sp-setup-actions step">
293
- <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'sportspress' ); ?>" name="save_step" />
294
- <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next button-muted"><?php _e( 'Skip this step', 'sportspress' ); ?></a>
295
- <?php wp_nonce_field( 'sp-setup' ); ?>
296
- </p>
297
- </form>
298
- <?php
299
- }
300
-
301
- /**
302
- * Save Basic Settings.
303
- */
304
- public function sp_setup_basics_save() {
305
- check_admin_referer( 'sp-setup' );
306
-
307
- // Update timezone
308
- $timezone_string = $_POST['timezone_string'];
309
- if ( ! empty( $timezone_string ) && preg_match( '/^UTC[+-]/', $timezone_string ) ) {
310
- $gmt_offset = $timezone_string;
311
- $gmt_offset = preg_replace( '/UTC\+?/', '', $gmt_offset );
312
- $timezone_string = '';
313
- }
314
-
315
- if ( isset( $timezone_string ) )
316
- update_option( 'timezone_string', $timezone_string );
317
-
318
- if ( isset( $gmt_offset ) )
319
- update_option( 'gmt_offset', $gmt_offset );
320
-
321
- // Update sport
322
- $sport = sanitize_text_field( $_POST['sport'] );
323
- if ( ! empty( $sport ) && get_option( 'sportspress_sport', null ) !== $sport ) {
324
- SP_Admin_Sports::apply_preset( $sport );
325
- }
326
- update_option( 'sportspress_sport', $sport );
327
-
328
- // Insert league
329
- $league = sanitize_text_field( $_POST['league'] );
330
- if ( ! is_string( $league ) || empty( $league ) ) {
331
- $league = _x( 'Primary League', 'example', 'sportspress' );
332
- }
333
- $inserted = wp_insert_term( $league, 'sp_league' );
334
- if ( ! is_wp_error( $inserted ) ) {
335
- update_option( 'sportspress_league', sp_array_value( $inserted, 'term_id', null ) );
336
- }
337
-
338
- // Insert season
339
- $season = sanitize_text_field( $_POST['season'] );
340
- if ( ! is_string( $season ) || empty( $season ) ) {
341
- $season = date( 'Y' );
342
- }
343
- $inserted = wp_insert_term( $season, 'sp_season' );
344
- if ( ! is_wp_error( $inserted ) ) {
345
- update_option( 'sportspress_season', sp_array_value( $inserted, 'term_id', null ) );
346
- }
347
-
348
- wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
349
- exit;
350
- }
351
-
352
- /**
353
- * Team Setup.
354
- */
355
- public function sp_setup_teams() {
356
- $class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
357
- ?>
358
- <h1><?php _e( 'Team Setup', 'sportspress' ); ?></h1>
359
- <form method="post">
360
- <p><?php _e( "Great! Now let's add some teams.", 'sportspress' ); ?></p>
361
- <table class="form-table" cellspacing="0">
362
- <tr>
363
- <th scope="row"><?php _e( 'Home Team', 'sportspress' ); ?></th>
364
- <td>
365
- <input name="home_team" type="text" class="widefat" placeholder="<?php _e( 'What is your team called?', 'sportspress' ); ?>">
366
- </td>
367
- </tr>
368
- <tr>
369
- <th scope="row"><?php _e( 'Rival Team', 'sportspress' ); ?></th>
370
- <td>
371
- <input name="away_team" type="text" class="widefat" placeholder="<?php _e( 'Who are you playing against next?', 'sportspress' ); ?>">
372
- <p class="description"><?php _e( "You can add more teams later.", 'sportspress' ); ?></p>
373
- </td>
374
- </tr>
375
- </table>
376
-
377
- <p class="sp-setup-actions step">
378
- <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'sportspress' ); ?>" name="save_step" />
379
- <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next button-muted"><?php _e( 'Skip this step', 'sportspress' ); ?></a>
380
- <?php wp_nonce_field( 'sp-setup' ); ?>
381
- </p>
382
- </form>
383
- <?php
384
- }
385
-
386
- /**
387
- * Save Team Settings.
388
- */
389
- public function sp_setup_teams_save() {
390
- check_admin_referer( 'sp-setup' );
391
-
392
- // Add away team
393
- $post['post_title'] = $_POST['away_team'];
394
- $post['post_type'] = 'sp_team';
395
- $post['post_status'] = 'publish';
396
- $post['tax_input'] = array();
397
- $taxonomies = array( 'sp_league', 'sp_season' );
398
- foreach ( $taxonomies as $taxonomy ) {
399
- $post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) );
400
- };
401
- wp_insert_post( $post );
402
-
403
- // Add home team
404
- $post['post_title'] = $_POST['home_team'];
405
- wp_insert_post( $post );
406
-
407
- wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
408
- exit;
409
- }
410
-
411
- /**
412
- * Players & Staff Setup.
413
- */
414
- public function sp_setup_players_staff() {
415
- $positions = (array) get_terms( 'sp_position', array( 'hide_empty' => 0, 'orderby' => 'slug', 'fields' => 'names' ) )
416
- ?>
417
- <h1><?php esc_html_e( 'Player & Staff Setup', 'sportspress' ); ?></h1>
418
- <form method="post">
419
- <p><?php _e( "Let's add players and a staff member.", 'sportspress' ); ?></p>
420
- <table class="form-table" cellspacing="0">
421
- <tr>
422
- <th scope="row"><?php _e( 'Players', 'sportspress' ); ?> <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'Enter a squad number, name, and position for each player.', 'sportspress' ); ?>"></i></th>
423
- <td>
424
- <ul>
425
- <?php for ( $i = 0; $i < 3; $i++ ) { ?>
426
- <li class="player"><input name="players[<?php echo $i; ?>][number]" type="text" class="player-number" placeholder="#" value="<?php echo $i + 1; ?>"> <input name="players[<?php echo $i; ?>][name]" type="text" placeholder="<?php _e( 'Name', 'sportspress' ); ?>"> <input name="players[<?php echo $i; ?>][position]" type="text" placeholder="<?php _e( 'Position', 'sportspress' ); ?>" <?php if ( sizeof( $positions ) ) { ?> value="<?php echo $positions[ $i % sizeof( $positions ) ]; ?>"<?php } ?>></li>
427
- <?php } ?>
428
- </ul>
429
- <p class="description"><?php _e( "You can add more players later.", 'sportspress' ); ?></p>
430
- </td>
431
- </tr>
432
- <tr>
433
- <th scope="row"><?php _e( 'Staff', 'sportspress' ); ?></th>
434
- <td>
435
- <ul>
436
- <li class="staff"><input name="staff" type="text" class="staff-name" placeholder="<?php _e( 'Name', 'sportspress' ); ?>"> <input name="role" type="text" placeholder="<?php _e( 'Job', 'sportspress' ); ?>" value="Coach"></li>
437
- </ul>
438
- </td>
439
- </tr>
440
- </table>
441
-
442
- <p class="sp-setup-actions step">
443
- <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'sportspress' ); ?>" name="save_step" />
444
- <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next button-muted"><?php _e( 'Skip this step', 'sportspress' ); ?></a>
445
- <?php wp_nonce_field( 'sp-setup' ); ?>
446
- </p>
447
- </form>
448
- <?php
449
- }
450
-
451
- /**
452
- * Save Player & Staff Settings.
453
- */
454
- public function sp_setup_players_staff_save() {
455
- check_admin_referer( 'sp-setup' );
456
-
457
- // Get home team
458
- $teams = (array) get_posts( array( 'posts_per_page' => 1, 'post_type' => 'sp_team', 'fields' => 'ids' ) );
459
- $team = reset( $teams );
460
-
461
- // Add players
462
- $post['post_type'] = 'sp_player';
463
- $post['post_status'] = 'publish';
464
- $post['tax_input'] = array();
465
- $taxonomies = array( 'sp_league', 'sp_season' );
466
- foreach ( $taxonomies as $taxonomy ) {
467
- $post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) );
468
- };
469
- if ( is_array( $_POST['players'] ) ) {
470
- foreach ( $_POST['players'] as $i => $player ) {
471
- if ( empty( $player['name'] ) ) continue;
472
-
473
- $post['post_title'] = $player['name'];
474
- $id = wp_insert_post( $post );
475
-
476
- // Add squad number
477
- $number = sp_array_value( $player, 'number' );
478
- update_post_meta( $id, 'sp_number', $number );
479
-
480
- // Add position
481
- wp_set_object_terms( $id, sp_array_value( $player, 'position', __( 'Position', 'sportspress' ) ), 'sp_position', false );
482
-
483
- // Add team
484
- if ( $team ) {
485
- update_post_meta( $id, 'sp_team', $team );
486
- update_post_meta( $id, 'sp_current_team', $team );
487
- }
488
- }
489
- }
490
-
491
- // Add staff
492
- if ( ! empty( $_POST['staff'] ) ) {
493
-
494
- $post['post_type'] = 'sp_staff';
495
- $post['post_title'] = $_POST['staff'];
496
- $id = wp_insert_post( $post );
497
-
498
- // Add role
499
- wp_set_object_terms( $id, sp_array_value( $_POST, 'role', 'Coach' ), 'sp_role', false );
500
-
501
- // Add team
502
- if ( $team ) {
503
- update_post_meta( $id, 'sp_team', $team );
504
- update_post_meta( $id, 'sp_current_team', $team );
505
- }
506
- }
507
-
508
- wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
509
- exit;
510
- }
511
-
512
- /**
513
- * Venue Step.
514
- */
515
- public function sp_setup_venue() {
516
- do_action( 'sp_setup_venue_geocoder_scripts' );
517
- ?>
518
- <h1><?php _e( 'Venue Setup', 'sportspress' ); ?></h1>
519
- <form method="post">
520
- <p><?php _e( "Enter the details of your home venue.", 'sportspress' ); ?></p>
521
- <table class="form-table" cellspacing="0">
522
- <tr>
523
- <th scope="row"><?php _e( 'Name', 'sportspress' ); ?></th>
524
- <td>
525
- <input name="venue" type="text" placeholder="<?php _e( 'Venue', 'sportspress' ); ?>">
526
- </td>
527
- </tr>
528
- <tr>
529
- <th scope="row"><?php _e( 'Address', 'sportspress' ); ?></th>
530
- <td>
531
- <input name="address" id="sp_address" class="sp-address" type="text" value="Marvel Stadium, Melbourne">
532
- <div id="sp-location-picker" class="sp-location-picker" style="width: 95%; height: 320px"></div>
533
- <p class="description"><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
534
- <input name="latitude" id="sp_latitude" class="sp-latitude" type="hidden" value="-37.8165647">
535
- <input name="longitude" id="sp_longitude" class="sp-longitude" type="hidden" value="144.9475055">
536
- </td>
537
- </tr>
538
- </table>
539
-
540
- <p class="sp-setup-actions step">
541
- <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'sportspress' ); ?>" name="save_step" />
542
- <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next button-muted"><?php _e( 'Skip this step', 'sportspress' ); ?></a>
543
- <?php wp_nonce_field( 'sp-setup' ); ?>
544
- </p>
545
- </form>
546
- <?php
547
- do_action( 'sp_admin_geocoder_scripts' );
548
- }
549
-
550
- /**
551
- * Venue Settings.
552
- */
553
- public function sp_setup_venue_save() {
554
- check_admin_referer( 'sp-setup' );
555
-
556
- // Get home team
557
- $teams = (array) get_posts( array( 'posts_per_page' => 1, 'post_type' => 'sp_team', 'fields' => 'ids' ) );
558
- $team = reset( $teams );
559
-
560
- // Insert venue
561
- $venue = sanitize_text_field( $_POST['venue'] );
562
- if ( ! is_string( $venue ) || empty( $venue ) ) {
563
- $venue = sp_array_value( $_POST, 'address', __( 'Venue', 'sportspress' ) );
564
- }
565
- $inserted = wp_insert_term( $venue, 'sp_venue' );
566
-
567
- // Add address and coordinates to venue
568
- if ( ! is_wp_error( $inserted ) ) {
569
- $t_id = sp_array_value( $inserted, 'term_id', 1 );
570
-
571
- if ( $team ) {
572
- wp_set_object_terms( $team, $t_id, 'sp_venue', true );
573
- }
574
-
575
- $meta = array(
576
- 'sp_address' => sp_array_value( $_POST, 'address' ),
577
- 'sp_latitude' => sp_array_value( $_POST, 'latitude' ),
578
- 'sp_longitude' => sp_array_value( $_POST, 'longitude' ),
579
- );
580
- update_option( "taxonomy_$t_id", $meta );
581
- }
582
-
583
- wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
584
- exit;
585
- }
586
-
587
- /**
588
- * Pages Step.
589
- */
590
- public function sp_setup_pages() {
591
- $pages = apply_filters( 'sportspress_setup_pages', array(
592
- 'sp_calendar' => __( 'Organize and publish calendars using different layouts.', 'sportspress' ),
593
- 'sp_table' => __( 'Create automated league tables to keep track of team standings.', 'sportspress' ),
594
- 'sp_list' => __( 'Create team rosters, player galleries, and ranking charts.', 'sportspress' ),
595
- ) );
596
- ?>
597
- <h1><?php _e( 'Pages', 'sportspress' ); ?></h1>
598
- <form method="post">
599
- <p><?php printf( __( 'The following will be created automatically (if they do not already exist):', 'sportspress' ), '<a href="' . esc_url( admin_url( 'edit.php?post_type=page' ) ) . '" target="_blank">', '</a>' ); ?></p>
600
- <table class="form-table" cellspacing="0">
601
- <?php foreach ( $pages as $post_type => $description ) { ?>
602
- <?php
603
- $obj = get_post_type_object( $post_type );
604
- if ( ! is_object( $obj ) ) continue;
605
- ?>
606
- <tr>
607
- <th scope="row"><?php echo $obj->labels->singular_name; ?></th>
608
- <td><?php echo $description; ?></td>
609
- </tr>
610
- <?php } ?>
611
- </table>
612
-
613
- <p><?php printf( __( 'Once created, these pages can be managed from your admin dashboard.', 'sportspress' ), '<a href="' . esc_url( admin_url( 'edit.php?post_type=page' ) ) . '" target="_blank">', '</a>', '<a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '" target="_blank">', '</a>' ); ?></p>
614
-
615
- <p class="sp-setup-actions step">
616
- <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'sportspress' ); ?>" name="save_step" />
617
- <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next button-muted"><?php _e( 'Skip this step', 'sportspress' ); ?></a>
618
- <?php wp_nonce_field( 'sp-setup' ); ?>
619
- </p>
620
- </form>
621
- <?php
622
- }
623
-
624
- /**
625
- * Pages Settings.
626
- */
627
- public function sp_setup_pages_save() {
628
- check_admin_referer( 'sp-setup' );
629
-
630
- $pages = apply_filters( 'sportspress_setup_pages', array(
631
- 'sp_calendar' => __( 'Organize and publish calendars using different layouts.', 'sportspress' ),
632
- 'sp_table' => __( 'Create automated league tables to keep track of team standings.', 'sportspress' ),
633
- 'sp_list' => __( 'Create team rosters, player galleries, and ranking charts.', 'sportspress' ),
634
- ) );
635
-
636
- // Initialize post
637
- $post = array( 'post_status' => 'publish' );
638
- $sample_content = _x( 'This is an example %1$s. As a new SportsPress user, you should go to <a href=\"%3$s\">your dashboard</a> to delete this %1$s and create new %2$s for your content. Have fun!', 'example', 'sportspress' );
639
-
640
- // Insert posts
641
- foreach ( $pages as $post_type => $description ) {
642
- $obj = get_post_type_object( $post_type );
643
- if ( ! is_object( $obj ) ) continue;
644
-
645
- // Skip if post exists
646
- $posts = get_posts( array( 'posts_per_page' => 1, 'post_type' => $post_type ) );
647
- if ( $posts ) continue;
648
-
649
- // Add post args
650
- $post['post_title'] = $obj->labels->singular_name;
651
- $post['post_type'] = $post_type;
652
- $post['post_content'] = sprintf( $sample_content, $obj->labels->singular_name, $obj->labels->name, add_query_arg( 'post_type', $post_type, admin_url( 'edit.php' ) ) );
653
-
654
- // Insert post
655
- $id = wp_insert_post( $post );
656
-
657
- // Flag as sample
658
- update_post_meta( $id, '_sp_sample', 1 );
659
- }
660
-
661
- wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
662
- exit;
663
- }
664
-
665
- /**
666
- * Actions on the final step.
667
- */
668
- private function sp_setup_ready_actions() {
669
- delete_option( '_sp_needs_welcome' );
670
- update_option( 'sportspress_installed', 1 );
671
- update_option( 'sportspress_completed_setup', 1 );
672
- delete_transient( '_sp_activation_redirect' );
673
-
674
- // Check if first event already exists
675
- $events = get_posts(
676
- array(
677
- 'post_type' => 'sp_event',
678
- 'posts_per_page' => 1,
679
- 'post_status' => 'draft',
680
- 'meta_query' => array(
681
- array(
682
- 'key' => '_sp_first',
683
- 'value' => 1
684
- )
685
- )
686
- )
687
- );
688
-
689
- if ( $events ) {
690
- $event = reset( $events );
691
- return $event->ID;
692
- }
693
-
694
- // Get teams
695
- $team_post_type = 'sp_team';
696
- if ( 'player' === get_option( 'sportspress_mode', 'team' ) ) {
697
- $team_post_type = 'sp_player';
698
- }
699
- $teams = get_posts( array( 'posts_per_page' => 2, 'post_type' => $team_post_type ) );
700
-
701
- // Get players
702
- $players = (array) get_posts( array( 'posts_per_page' => 3, 'post_type' => 'sp_player', 'fields' => 'ids' ) );
703
-
704
- // Get staff
705
- $staff = (array) get_posts( array( 'posts_per_page' => 1, 'post_type' => 'sp_staff', 'fields' => 'ids' ) );
706
-
707
- // Initialize post
708
- $post['post_type'] = 'sp_event';
709
- $post['post_status'] = 'draft';
710
- $post['tax_input'] = array();
711
-
712
- // Add taxonomies
713
- $taxonomies = array( 'sp_league', 'sp_season', 'sp_venue' );
714
- foreach ( $taxonomies as $taxonomy ) {
715
- $post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids', 'number' => 1 ) );
716
- };
717
-
718
- // Add post title
719
- if ( is_array( $teams ) && sizeof( $teams ) ) {
720
- $team_names = array();
721
- foreach ( $teams as $team ) {
722
- if ( ! $team ) continue;
723
- $team_names[] = $team->post_title;
724
- }
725
- $post['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
726
- } else {
727
- $post['post_title'] = __( 'Event', 'sportspress' );
728
- }
729
-
730
- // Insert event
731
- $id = wp_insert_post( $post );
732
-
733
- // Add teams
734
- if ( is_array( $teams ) && sizeof( $teams ) ) {
735
- foreach ( $teams as $team ) {
736
- if ( ! $team ) continue;
737
- add_post_meta( $id, 'sp_team', $team->ID );
738
- }
739
- }
740
-
741
- // Add players
742
- add_post_meta( $id, 'sp_player', 0 );
743
- foreach ( $players as $player ) {
744
- if ( ! $player ) continue;
745
- add_post_meta( $id, 'sp_player', $player );
746
- }
747
- add_post_meta( $id, 'sp_player', 0 );
748
-
749
- update_post_meta( $id, '_sp_first', 1 );
750
-
751
- return $id;
752
- }
753
-
754
- /**
755
- * Final step.
756
- */
757
- public function sp_setup_ready() {
758
- $id = $this->sp_setup_ready_actions();
759
- shuffle( $this->tweets );
760
-
761
- $steps = apply_filters( 'sportspress_setup_wizard_next_steps', array(
762
- 'first' => array(
763
- 'label' => __( 'Next Steps', 'sportspress' ),
764
- 'content' => '<a class="button button-primary button-large button-first-event" href="' . esc_url( admin_url( 'post.php?post=' . $id . '&action=edit' ) ) . '">' . __( 'Schedule your first event!', 'sportspress' ) . '</a>',
765
- ),
766
- 'last' => array(
767
- 'label' => __( 'Upgrade to Pro', 'sportspress' ),
768
- 'content' => __( 'Get SportsPress Pro to get access to all modules. You can upgrade any time without losing any of your data.', 'sportspress' ) . ' <a href="' . apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ) . '" target="_blank">' . __( 'Learn more', 'sportspress' ) . '</a>',
769
- ),
770
- ) );
771
- ?>
772
- <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://tboy.co/sp" data-text="<?php echo esc_attr( $this->tweets[0] ); ?>" data-via="ThemeBoy" data-size="large">Tweet</a>
773
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
774
-
775
- <h1><?php _e( 'Thanks for installing!', 'sportspress' ); ?></h1>
776
-
777
- <div class="sp-banner"><img src="//ps.w.org/sportspress/assets/banner-772x250.png"></div>
778
-
779
- <div class="sp-setup-next-steps">
780
- <?php foreach ( $steps as $class => $step ) { ?>
781
- <div class="sp-setup-next-steps-<?php echo $class; ?>">
782
- <h2><?php echo $step['label']; ?></h2>
783
- <ul>
784
- <li><?php echo $step['content']; ?></li>
785
- </ul>
786
- </div>
787
- <?php } ?>
788
- </div>
789
- <?php
790
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
791
  }
792
 
793
  new SP_Admin_Setup_Wizard();
9
  * @author WooThemes
10
  * @category Admin
11
  * @package SportsPress/Admin
12
+ * @version 2.7.9
13
+ */
14
  if ( ! defined( 'ABSPATH' ) ) {
15
+ exit;
16
  }
17
 
18
  /**
20
  */
21
  class SP_Admin_Setup_Wizard {
22
 
23
+ /** @var string Current Step */
24
+ private $step = '';
25
+
26
+ /** @var array Steps for the setup wizard */
27
+ private $steps = array();
28
+
29
+ /** @var array Tweets user can optionally send after install */
30
+ private $tweets = array(
31
+ 'Someone give me a high five, I just set up a new sports data website with #SportsPress and #WordPress!',
32
+ );
33
+
34
+ /**
35
+ * Hook in tabs.
36
+ */
37
+ public function __construct() {
38
+ if ( apply_filters( 'sportspress_enable_setup_wizard', true ) && current_user_can( 'manage_sportspress' ) ) {
39
+ add_action( 'admin_menu', array( $this, 'admin_menus' ) );
40
+ add_action( 'admin_init', array( $this, 'setup_wizard' ) );
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Add admin menus/screens.
46
+ */
47
+ public function admin_menus() {
48
+ add_dashboard_page( '', '', 'manage_options', 'sp-setup', '' );
49
+ }
50
+
51
+ /**
52
+ * Show the setup wizard.
53
+ */
54
+ public function setup_wizard() {
55
+ if ( empty( $_GET['page'] ) || 'sp-setup' !== $_GET['page'] ) {
56
+ return;
57
+ }
58
+ $this->steps = array(
59
+ 'introduction' => array(
60
+ 'name' => esc_attr__( 'Introduction', 'sportspress' ),
61
+ 'view' => array( $this, 'sp_setup_introduction' ),
62
+ 'handler' => '',
63
+ ),
64
+ 'basics' => array(
65
+ 'name' => esc_attr__( 'Basic Setup', 'sportspress' ),
66
+ 'view' => array( $this, 'sp_setup_basics' ),
67
+ 'handler' => array( $this, 'sp_setup_basics_save' ),
68
+ ),
69
+ 'teams' => array(
70
+ 'name' => esc_attr__( 'Teams', 'sportspress' ),
71
+ 'view' => array( $this, 'sp_setup_teams' ),
72
+ 'handler' => array( $this, 'sp_setup_teams_save' ),
73
+ ),
74
+ 'players_staff' => array(
75
+ 'name' => esc_attr__( 'Players', 'sportspress' ) . ' &amp; ' . esc_attr__( 'Staff', 'sportspress' ),
76
+ 'view' => array( $this, 'sp_setup_players_staff' ),
77
+ 'handler' => array( $this, 'sp_setup_players_staff_save' ),
78
+ ),
79
+ 'venue' => array(
80
+ 'name' => esc_attr__( 'Venue', 'sportspress' ),
81
+ 'view' => array( $this, 'sp_setup_venue' ),
82
+ 'handler' => array( $this, 'sp_setup_venue_save' ),
83
+ ),
84
+ 'pages' => array(
85
+ 'name' => esc_attr__( 'Pages', 'sportspress' ),
86
+ 'view' => array( $this, 'sp_setup_pages' ),
87
+ 'handler' => array( $this, 'sp_setup_pages_save' ),
88
+ ),
89
+ 'next_steps' => array(
90
+ 'name' => esc_attr__( 'Ready!', 'sportspress' ),
91
+ 'view' => array( $this, 'sp_setup_ready' ),
92
+ 'handler' => '',
93
+ ),
94
+ );
95
+ $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
96
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
97
+
98
+ wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' );
99
+ wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
100
+ wp_enqueue_style( 'sportspress-setup', SP()->plugin_url() . '/assets/css/setup.css', array( 'dashicons', 'install' ), SP_VERSION );
101
+
102
+ wp_register_script( 'chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
103
+ wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
104
+ wp_register_script( 'sportspress-setup', SP()->plugin_url() . '/assets/js/admin/sportspress-setup.js', array( 'jquery', 'chosen', 'jquery-tiptip' ), SP_VERSION, true );
105
+
106
+ do_action( 'sp_setup_geocoder_scripts' );
107
+
108
+ $strings = apply_filters(
109
+ 'sportspress_localized_strings',
110
+ array(
111
+ 'none' => esc_attr__( 'None', 'sportspress' ),
112
+ 'remove_text' => esc_attr__( '&mdash; Remove &mdash;', 'sportspress' ),
113
+ )
114
+ );
115
+
116
+ // Localize scripts
117
+ wp_localize_script( 'sportspress-setup', 'localized_strings', $strings );
118
+
119
+ if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
120
+ call_user_func( $this->steps[ $this->step ]['handler'] );
121
+ }
122
+
123
+ ob_start();
124
+ $this->setup_wizard_header();
125
+ $this->setup_wizard_steps();
126
+ $this->setup_wizard_content();
127
+ $this->setup_wizard_footer();
128
+ exit;
129
+ }
130
+
131
+ public function get_next_step_link() {
132
+ $keys = array_keys( $this->steps );
133
+ return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) + 1 ] );
134
+ }
135
+
136
+ /**
137
+ * Setup Wizard Header.
138
+ */
139
+ public function setup_wizard_header() {
140
+ ?>
141
+ <!DOCTYPE html>
142
+ <html <?php language_attributes(); ?>>
143
+ <head>
144
+ <meta name="viewport" content="width=device-width" />
145
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
146
+ <title><?php esc_html_e( 'SportsPress', 'sportspress' ); ?> &rsaquo; <?php echo esc_html( $this->steps[ $this->step ]['name'] ); ?></title>
147
+ <?php do_action( 'admin_print_styles' ); ?>
148
+ <?php do_action( 'admin_head' ); ?>
149
+ </head>
150
+ <body class="sp-setup wp-core-ui">
151
+ <h1 id="sp-logo"><?php echo wp_kses_post( apply_filters( 'sportspress_logo', '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/modules/sportspress' . ( class_exists( 'SportsPress_Pro' ) ? '-pro' : '' ) . '.png" alt="' . esc_attr__( 'SportsPress', 'sportspress' ) . '">' ) ); ?></h1>
152
+ <?php
153
+ }
154
+
155
+ /**
156
+ * Setup Wizard Footer.
157
+ */
158
+ public function setup_wizard_footer() {
159
+ ?>
160
+ <?php if ( 'next_steps' === $this->step ) : ?>
161
+ <p class="sp-return-to-dashboard"><a href="<?php echo esc_url( admin_url( 'index.php?page=sp-about' ) ); ?>"><?php esc_html_e( 'Return to the WordPress Dashboard', 'sportspress' ); ?></a></p>
162
+ <?php endif; ?>
163
+ <?php wp_print_scripts( 'sportspress-setup' ); ?>
164
+ </body>
165
+ </html>
166
+ <?php
167
+ }
168
+
169
+ /**
170
+ * Output the steps.
171
+ */
172
+ public function setup_wizard_steps() {
173
+ $ouput_steps = $this->steps;
174
+ array_shift( $ouput_steps );
175
+ ?>
176
+ <ol class="sp-setup-steps">
177
+ <?php foreach ( $ouput_steps as $step_key => $step ) : ?>
178
+ <li class="
179
+ <?php
180
+ if ( $step_key === $this->step ) {
181
+ echo 'active';
182
+ } elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
183
+ echo 'done';
184
+ }
185
+ ?>
186
+ "><?php echo esc_html( $step['name'] ); ?></li>
187
+ <?php endforeach; ?>
188
+ </ol>
189
+ <?php
190
+ }
191
+
192
+ /**
193
+ * Output the content for the current step.
194
+ */
195
+ public function setup_wizard_content() {
196
+ echo '<div class="sp-setup-content">';
197
+ call_user_func( $this->steps[ $this->step ]['view'] );
198
+ echo '</div>';
199
+ }
200
+
201
+ /**
202
+ * Introduction Step.
203
+ */
204
+ public function sp_setup_introduction() {
205
+ ?>
206
+ <h1><?php esc_html_e( 'Welcome to SportsPress', 'sportspress' ); ?></h1>
207
+ <p><?php esc_html_e( 'Thank you for choosing SportsPress to power your sports website! This quick setup wizard will help you configure the basic settings. <strong>It’s completely optional and shouldn’t take longer than five minutes.</strong>', 'sportspress' ); ?></p>
208
+ <p><?php esc_html_e( 'No time right now? If you don’t want to go through the wizard, you can skip and return to the WordPress dashboard. Come back anytime if you change your mind!', 'sportspress' ); ?></p>
209
+ <p class="sp-setup-actions step">
210
+ <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button-primary button button-large button-next"><?php esc_html_e( 'Let\'s Go!', 'sportspress' ); ?></a>
211
+ <a href="<?php echo esc_url( admin_url( 'index.php?page=sp-about' ) ); ?>" class="button button-large button-muted"><?php esc_html_e( 'Not right now', 'sportspress' ); ?></a>
212
+ </p>
213
+ <?php
214
+ }
215
+
216
+ /**
217
+ * Basic Setup.
218
+ */
219
+ public function sp_setup_basics() {
220
+ $class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
221
+ ?>
222
+ <h1><?php esc_html_e( 'Basic Setup', 'sportspress' ); ?></h1>
223
+ <form method="post">
224
+ <p><?php esc_html_e( 'Select your timezone and sport to get started.', 'sportspress' ); ?></p>
225
+ <table class="form-table" cellspacing="0">
226
+ <tr>
227
+ <th scope="row"><?php esc_html_e( 'Timezone', 'sportspress' ); ?> <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php esc_attr_e( 'Choose a city in the same timezone as you.', 'sportspress' ); ?>"></i></th>
228
+ <td>
229
+ <select id="timezone_string" name="timezone_string" class="<?php echo esc_attr( $class ); ?>">
230
+ <?php
231
+ $current_offset = get_option( 'gmt_offset' );
232
+ $tzstring = get_option( 'timezone_string' );
233
+
234
+ $check_zone_info = true;
235
+
236
+ // Remove old Etc mappings. Fallback to gmt_offset.
237
+ if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
238
+ $tzstring = '';
239
+ }
240
+
241
+ if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
242
+ $check_zone_info = false;
243
+ if ( 0 == $current_offset ) {
244
+ $tzstring = 'UTC+0';
245
+ } elseif ( $current_offset < 0 ) {
246
+ $tzstring = 'UTC' . $current_offset;
247
+ } else {
248
+ $tzstring = 'UTC+' . $current_offset;
249
+ }
250
+ }
251
+ echo esc_attr( wp_timezone_choice( $tzstring ) );
252
+ ?>
253
+ </select>
254
+ </td>
255
+ </tr>
256
+ <tr>
257
+ <th scope="row"><?php echo esc_html_x( 'Sport', 'Page title', 'sportspress' ); ?></th>
258
+ <td>
259
+ <?php
260
+ $options = SP_Admin_Sports::get_preset_options();
261
+ $default = apply_filters( 'sportspress_default_sport', 'soccer' );
262
+ $sport = get_option( 'sportspress_sport', $default );
263
+ if ( 'none' === $sport ) {
264
+ $sport = $default;
265
+ }
266
+ $categories = SP_Admin_Sports::sport_category_names();
267
+ ?>
268
+ <select name="sport" id="sport" class="sp-select-sport <?php echo esc_attr( $class ); ?>">
269
+ <?php
270
+ foreach ( $options as $group => $options ) {
271
+ ?>
272
+ <optgroup label="<?php echo esc_attr( sp_array_value( $categories, $group, $group ) ); ?>">
273
+ <?php
274
+ foreach ( $options as $key => $val ) {
275
+ ?>
276
+ <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $sport, $key ); ?>><?php echo esc_html( $val ); ?></option>
277
+ <?php
278
+ }
279
+ ?>
280
+ </optgroup>
281
+ <?php
282
+ }
283
+ ?>
284
+ </select>
285
+ </td>
286
+ </tr>
287
+ <tr>
288
+ <th scope="row"><?php esc_html_e( 'Main League', 'sportspress' ); ?> <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php esc_attr_e( 'The name of a league or division.', 'sportspress' ); ?>"></i></th>
289
+ <td>
290
+ <input name="league" type="text" class="widefat" value="<?php echo esc_attr_x( 'Primary League', 'example', 'sportspress' ); ?>">
291
+ </td>
292
+ </tr>
293
+ <tr>
294
+ <th scope="row"><?php esc_html_e( 'Current Season', 'sportspress' ); ?></th>
295
+ <td>
296
+ <input name="season" type="text" class="widefat" value="<?php echo esc_attr( date( 'Y' ) ); ?>">
297
+ </td>
298
+ </tr>
299
+ </table>
300
+
301
+ <p class="sp-setup-actions step">
302
+ <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'sportspress' ); ?>" name="save_step" />
303
+ <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next button-muted"><?php esc_html_e( 'Skip this step', 'sportspress' ); ?></a>
304
+ <?php wp_nonce_field( 'sp-setup' ); ?>
305
+ </p>
306
+ </form>
307
+ <?php
308
+ }
309
+
310
+ /**
311
+ * Save Basic Settings.
312
+ */
313
+ public function sp_setup_basics_save() {
314
+ check_admin_referer( 'sp-setup' );
315
+
316
+ // Update timezone
317
+ $timezone_string = sanitize_text_field( wp_unslash( $_POST['timezone_string'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
318
+ if ( ! empty( $timezone_string ) && preg_match( '/^UTC[+-]/', $timezone_string ) ) {
319
+ $gmt_offset = $timezone_string;
320
+ $gmt_offset = preg_replace( '/UTC\+?/', '', $gmt_offset );
321
+ $timezone_string = '';
322
+ }
323
+
324
+ if ( isset( $timezone_string ) ) {
325
+ update_option( 'timezone_string', $timezone_string );
326
+ }
327
+
328
+ if ( isset( $gmt_offset ) ) {
329
+ update_option( 'gmt_offset', $gmt_offset );
330
+ }
331
+
332
+ // Update sport
333
+ $sport = sanitize_text_field( wp_unslash( $_POST['sport'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
334
+ if ( ! empty( $sport ) && get_option( 'sportspress_sport', null ) !== $sport ) {
335
+ SP_Admin_Sports::apply_preset( $sport );
336
+ }
337
+ update_option( 'sportspress_sport', $sport );
338
+
339
+ // Insert league
340
+ $league = sanitize_text_field( wp_unslash( $_POST['league'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
341
+ if ( ! is_string( $league ) || empty( $league ) ) {
342
+ $league = _x( 'Primary League', 'example', 'sportspress' );
343
+ }
344
+ $inserted = wp_insert_term( $league, 'sp_league' );
345
+ if ( ! is_wp_error( $inserted ) ) {
346
+ update_option( 'sportspress_league', sp_array_value( $inserted, 'term_id', null ) );
347
+ }
348
+
349
+ // Insert season
350
+ $season = sanitize_text_field( wp_unslash( $_POST['season'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
351
+ if ( ! is_string( $season ) || empty( $season ) ) {
352
+ $season = date( 'Y' );
353
+ }
354
+ $inserted = wp_insert_term( $season, 'sp_season' );
355
+ if ( ! is_wp_error( $inserted ) ) {
356
+ update_option( 'sportspress_season', sp_array_value( $inserted, 'term_id', null ) );
357
+ }
358
+
359
+ wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
360
+ exit;
361
+ }
362
+
363
+ /**
364
+ * Team Setup.
365
+ */
366
+ public function sp_setup_teams() {
367
+ $class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
368
+ ?>
369
+ <h1><?php esc_html_e( 'Team Setup', 'sportspress' ); ?></h1>
370
+ <form method="post">
371
+ <p><?php esc_html_e( "Great! Now let's add some teams.", 'sportspress' ); ?></p>
372
+ <table class="form-table" cellspacing="0">
373
+ <tr>
374
+ <th scope="row"><?php esc_html_e( 'Home Team', 'sportspress' ); ?></th>
375
+ <td>
376
+ <input name="home_team" type="text" class="widefat" placeholder="<?php esc_html_e( 'What is your team called?', 'sportspress' ); ?>">
377
+ </td>
378
+ </tr>
379
+ <tr>
380
+ <th scope="row"><?php esc_html_e( 'Rival Team', 'sportspress' ); ?></th>
381
+ <td>
382
+ <input name="away_team" type="text" class="widefat" placeholder="<?php esc_html_e( 'Who are you playing against next?', 'sportspress' ); ?>">
383
+ <p class="description"><?php esc_html_e( 'You can add more teams later.', 'sportspress' ); ?></p>
384
+ </td>
385
+ </tr>
386
+ </table>
387
+
388
+ <p class="sp-setup-actions step">
389
+ <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'sportspress' ); ?>" name="save_step" />
390
+ <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next button-muted"><?php esc_html_e( 'Skip this step', 'sportspress' ); ?></a>
391
+ <?php wp_nonce_field( 'sp-setup' ); ?>
392
+ </p>
393
+ </form>
394
+ <?php
395
+ }
396
+
397
+ /**
398
+ * Save Team Settings.
399
+ */
400
+ public function sp_setup_teams_save() {
401
+ check_admin_referer( 'sp-setup' );
402
+
403
+ // Add away team
404
+ $post['post_title'] = sanitize_text_field( wp_unslash( $_POST['away_team'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
405
+ $post['post_type'] = 'sp_team';
406
+ $post['post_status'] = 'publish';
407
+ $post['tax_input'] = array();
408
+ $taxonomies = array( 'sp_league', 'sp_season' );
409
+ foreach ( $taxonomies as $taxonomy ) {
410
+ $post['tax_input'][ $taxonomy ] = get_terms(
411
+ $taxonomy,
412
+ array(
413
+ 'hide_empty' => 0,
414
+ 'fields' => 'ids',
415
+ )
416
+ );
417
+ }
418
+ wp_insert_post( $post );
419
+
420
+ // Add home team
421
+ $post['post_title'] = sanitize_text_field( wp_unslash( $_POST['home_team'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
422
+ wp_insert_post( $post );
423
+
424
+ wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
425
+ exit;
426
+ }
427
+
428
+ /**
429
+ * Players & Staff Setup.
430
+ */
431
+ public function sp_setup_players_staff() {
432
+ $positions = (array) get_terms(
433
+ 'sp_position',
434
+ array(
435
+ 'hide_empty' => 0,
436
+ 'orderby' => 'slug',
437
+ 'fields' => 'names',
438
+ )
439
+ )
440
+ ?>
441
+ <h1><?php esc_html_e( 'Player & Staff Setup', 'sportspress' ); ?></h1>
442
+ <form method="post">
443
+ <p><?php esc_html_e( "Let's add players and a staff member.", 'sportspress' ); ?></p>
444
+ <table class="form-table" cellspacing="0">
445
+ <tr>
446
+ <th scope="row"><?php esc_html_e( 'Players', 'sportspress' ); ?> <i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php esc_attr_e( 'Enter a squad number, name, and position for each player.', 'sportspress' ); ?>"></i></th>
447
+ <td>
448
+ <ul>
449
+ <?php for ( $i = 0; $i < 3; $i++ ) { ?>
450
+ <li class="player"><input name="players[<?php echo esc_attr( $i ); ?>][number]" type="text" class="player-number" placeholder="#" value="<?php echo esc_attr( $i + 1 ); ?>"> <input name="players[<?php echo esc_attr( $i ); ?>][name]" type="text" placeholder="<?php esc_attr_e( 'Name', 'sportspress' ); ?>"> <input name="players[<?php echo esc_attr( $i ); ?>][position]" type="text" placeholder="<?php esc_attr_e( 'Position', 'sportspress' ); ?>"
451
+ <?php
452
+ if ( sizeof( $positions ) ) {
453
+ ?>
454
+ value="<?php echo esc_attr( $positions[ $i % sizeof( $positions ) ] ); ?>"<?php } ?>></li>
455
+ <?php } ?>
456
+ </ul>
457
+ <p class="description"><?php esc_html_e( 'You can add more players later.', 'sportspress' ); ?></p>
458
+ </td>
459
+ </tr>
460
+ <tr>
461
+ <th scope="row"><?php esc_html_e( 'Staff', 'sportspress' ); ?></th>
462
+ <td>
463
+ <ul>
464
+ <li class="staff"><input name="staff" type="text" class="staff-name" placeholder="<?php esc_attr_e( 'Name', 'sportspress' ); ?>"> <input name="role" type="text" placeholder="<?php esc_attr_e( 'Job', 'sportspress' ); ?>" value="Coach"></li>
465
+ </ul>
466
+ </td>
467
+ </tr>
468
+ </table>
469
+
470
+ <p class="sp-setup-actions step">
471
+ <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'sportspress' ); ?>" name="save_step" />
472
+ <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next button-muted"><?php esc_html_e( 'Skip this step', 'sportspress' ); ?></a>
473
+ <?php wp_nonce_field( 'sp-setup' ); ?>
474
+ </p>
475
+ </form>
476
+ <?php
477
+ }
478
+
479
+ /**
480
+ * Save Player & Staff Settings.
481
+ */
482
+ public function sp_setup_players_staff_save() {
483
+ check_admin_referer( 'sp-setup' );
484
+
485
+ // Get home team
486
+ $teams = (array) get_posts(
487
+ array(
488
+ 'posts_per_page' => 1,
489
+ 'post_type' => 'sp_team',
490
+ 'fields' => 'ids',
491
+ )
492
+ );
493
+ $team = reset( $teams );
494
+
495
+ // Add players
496
+ $post['post_type'] = 'sp_player';
497
+ $post['post_status'] = 'publish';
498
+ $post['tax_input'] = array();
499
+ $taxonomies = array( 'sp_league', 'sp_season' );
500
+ foreach ( $taxonomies as $taxonomy ) {
501
+ $post['tax_input'][ $taxonomy ] = get_terms(
502
+ $taxonomy,
503
+ array(
504
+ 'hide_empty' => 0,
505
+ 'fields' => 'ids',
506
+ )
507
+ );
508
+ }
509
+ if ( is_array( $_POST['players'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
510
+ foreach ( $_POST['players'] as $i => $player ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
511
+ if ( empty( $player['name'] ) ) {
512
+ continue;
513
+ }
514
+
515
+ $post['post_title'] = $player['name'];
516
+ $id = wp_insert_post( $post );
517
+
518
+ // Add squad number
519
+ $number = sanitize_text_field( sp_array_value( $player, 'number' ) );
520
+ update_post_meta( $id, 'sp_number', $number );
521
+
522
+ // Add position
523
+ wp_set_object_terms( $id, sp_array_value( $player, 'position', esc_attr__( 'Position', 'sportspress' ) ), 'sp_position', false );
524
+
525
+ // Add team
526
+ if ( $team ) {
527
+ update_post_meta( $id, 'sp_team', $team );
528
+ update_post_meta( $id, 'sp_current_team', $team );
529
+ }
530
+ }
531
+ }
532
+
533
+ // Add staff
534
+ if ( ! empty( $_POST['staff'] ) ) {
535
+
536
+ $post['post_type'] = 'sp_staff';
537
+ $post['post_title'] = sanitize_text_field( wp_unslash( $_POST['staff'] ) );
538
+ $id = wp_insert_post( $post );
539
+
540
+ // Add role
541
+ wp_set_object_terms( $id, sp_array_value( $_POST, 'role', 'Coach' ), 'sp_role', false );
542
+
543
+ // Add team
544
+ if ( $team ) {
545
+ update_post_meta( $id, 'sp_team', $team );
546
+ update_post_meta( $id, 'sp_current_team', $team );
547
+ }
548
+ }
549
+
550
+ wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
551
+ exit;
552
+ }
553
+
554
+ /**
555
+ * Venue Step.
556
+ */
557
+ public function sp_setup_venue() {
558
+ do_action( 'sp_setup_venue_geocoder_scripts' );
559
+ ?>
560
+ <h1><?php esc_html_e( 'Venue Setup', 'sportspress' ); ?></h1>
561
+ <form method="post">
562
+ <p><?php esc_html_e( 'Enter the details of your home venue.', 'sportspress' ); ?></p>
563
+ <table class="form-table" cellspacing="0">
564
+ <tr>
565
+ <th scope="row"><?php esc_html_e( 'Name', 'sportspress' ); ?></th>
566
+ <td>
567
+ <input name="venue" type="text" placeholder="<?php esc_attr_e( 'Venue', 'sportspress' ); ?>">
568
+ </td>
569
+ </tr>
570
+ <tr>
571
+ <th scope="row"><?php esc_html_e( 'Address', 'sportspress' ); ?></th>
572
+ <td>
573
+ <input name="address" id="sp_address" class="sp-address" type="text" value="Marvel Stadium, Melbourne">
574
+ <div id="sp-location-picker" class="sp-location-picker" style="width: 95%; height: 320px"></div>
575
+ <p class="description"><?php esc_html_e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
576
+ <input name="latitude" id="sp_latitude" class="sp-latitude" type="hidden" value="-37.8165647">
577
+ <input name="longitude" id="sp_longitude" class="sp-longitude" type="hidden" value="144.9475055">
578
+ </td>
579
+ </tr>
580
+ </table>
581
+
582
+ <p class="sp-setup-actions step">
583
+ <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'sportspress' ); ?>" name="save_step" />
584
+ <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next button-muted"><?php esc_html_e( 'Skip this step', 'sportspress' ); ?></a>
585
+ <?php wp_nonce_field( 'sp-setup' ); ?>
586
+ </p>
587
+ </form>
588
+ <?php
589
+ do_action( 'sp_admin_geocoder_scripts' );
590
+ }
591
+
592
+ /**
593
+ * Venue Settings.
594
+ */
595
+ public function sp_setup_venue_save() {
596
+ check_admin_referer( 'sp-setup' );
597
+
598
+ // Get home team
599
+ $teams = (array) get_posts(
600
+ array(
601
+ 'posts_per_page' => 1,
602
+ 'post_type' => 'sp_team',
603
+ 'fields' => 'ids',
604
+ )
605
+ );
606
+ $team = reset( $teams );
607
+
608
+ // Insert venue
609
+ $venue = sanitize_text_field( wp_unslash( $_POST['venue'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
610
+ if ( ! is_string( $venue ) || empty( $venue ) ) {
611
+ $venue = sp_array_value( $_POST, 'address', esc_attr__( 'Venue', 'sportspress' ) );
612
+ }
613
+ $inserted = wp_insert_term( $venue, 'sp_venue' );
614
+
615
+ // Add address and coordinates to venue
616
+ if ( ! is_wp_error( $inserted ) ) {
617
+ $t_id = sp_array_value( $inserted, 'term_id', 1 );
618
+
619
+ if ( $team ) {
620
+ wp_set_object_terms( $team, $t_id, 'sp_venue', true );
621
+ }
622
+
623
+ $meta = array(
624
+ 'sp_address' => sanitize_text_field( sp_array_value( $_POST, 'address' ) ),
625
+ 'sp_latitude' => sanitize_text_field( sp_array_value( $_POST, 'latitude' ) ),
626
+ 'sp_longitude' => sanitize_text_field( sp_array_value( $_POST, 'longitude' ) ),
627
+ );
628
+ update_option( "taxonomy_$t_id", $meta );
629
+ }
630
+
631
+ wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
632
+ exit;
633
+ }
634
+
635
+ /**
636
+ * Pages Step.
637
+ */
638
+ public function sp_setup_pages() {
639
+ $pages = apply_filters(
640
+ 'sportspress_setup_pages',
641
+ array(
642
+ 'sp_calendar' => esc_attr__( 'Organize and publish calendars using different layouts.', 'sportspress' ),
643
+ 'sp_table' => esc_attr__( 'Create automated league tables to keep track of team standings.', 'sportspress' ),
644
+ 'sp_list' => esc_attr__( 'Create team rosters, player galleries, and ranking charts.', 'sportspress' ),
645
+ )
646
+ );
647
+ ?>
648
+ <h1><?php esc_html_e( 'Pages', 'sportspress' ); ?></h1>
649
+ <form method="post">
650
+ <p><?php printf( esc_html__( 'The following will be created automatically (if they do not already exist):', 'sportspress' ), '<a href="' . esc_url( admin_url( 'edit.php?post_type=page' ) ) . '" target="_blank">', '</a>' ); ?></p>
651
+ <table class="form-table" cellspacing="0">
652
+ <?php foreach ( $pages as $post_type => $description ) { ?>
653
+ <?php
654
+ $obj = get_post_type_object( $post_type );
655
+ if ( ! is_object( $obj ) ) {
656
+ continue;
657
+ }
658
+ ?>
659
+ <tr>
660
+ <th scope="row"><?php echo esc_html( $obj->labels->singular_name ); ?></th>
661
+ <td><?php echo wp_kses_post( $description ); ?></td>
662
+ </tr>
663
+ <?php } ?>
664
+ </table>
665
+
666
+ <p><?php printf( esc_html__( 'Once created, these pages can be managed from your admin dashboard.', 'sportspress' ), '<a href="' . esc_url( admin_url( 'edit.php?post_type=page' ) ) . '" target="_blank">', '</a>', '<a href="' . esc_url( admin_url( 'nav-menus.php' ) ) . '" target="_blank">', '</a>' ); ?></p>
667
+
668
+ <p class="sp-setup-actions step">
669
+ <input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'sportspress' ); ?>" name="save_step" />
670
+ <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button button-large button-next button-muted"><?php esc_html_e( 'Skip this step', 'sportspress' ); ?></a>
671
+ <?php wp_nonce_field( 'sp-setup' ); ?>
672
+ </p>
673
+ </form>
674
+ <?php
675
+ }
676
+
677
+ /**
678
+ * Pages Settings.
679
+ */
680
+ public function sp_setup_pages_save() {
681
+ check_admin_referer( 'sp-setup' );
682
+
683
+ $pages = apply_filters(
684
+ 'sportspress_setup_pages',
685
+ array(
686
+ 'sp_calendar' => esc_attr__( 'Organize and publish calendars using different layouts.', 'sportspress' ),
687
+ 'sp_table' => esc_attr__( 'Create automated league tables to keep track of team standings.', 'sportspress' ),
688
+ 'sp_list' => esc_attr__( 'Create team rosters, player galleries, and ranking charts.', 'sportspress' ),
689
+ )
690
+ );
691
+
692
+ // Initialize post
693
+ $post = array( 'post_status' => 'publish' );
694
+ $sample_content = _x( 'This is an example %1$s. As a new SportsPress user, you should go to <a href=\"%3$s\">your dashboard</a> to delete this %1$s and create new %2$s for your content. Have fun!', 'example', 'sportspress' );
695
+
696
+ // Insert posts
697
+ foreach ( $pages as $post_type => $description ) {
698
+ $obj = get_post_type_object( $post_type );
699
+ if ( ! is_object( $obj ) ) {
700
+ continue;
701
+ }
702
+
703
+ // Skip if post exists
704
+ $posts = get_posts(
705
+ array(
706
+ 'posts_per_page' => 1,
707
+ 'post_type' => $post_type,
708
+ )
709
+ );
710
+ if ( $posts ) {
711
+ continue;
712
+ }
713
+
714
+ // Add post args
715
+ $post['post_title'] = $obj->labels->singular_name;
716
+ $post['post_type'] = $post_type;
717
+ $post['post_content'] = sprintf( $sample_content, $obj->labels->singular_name, $obj->labels->name, add_query_arg( 'post_type', $post_type, admin_url( 'edit.php' ) ) );
718
+
719
+ // Insert post
720
+ $id = wp_insert_post( $post );
721
+
722
+ // Flag as sample
723
+ update_post_meta( $id, '_sp_sample', 1 );
724
+ }
725
+
726
+ wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
727
+ exit;
728
+ }
729
+
730
+ /**
731
+ * Actions on the final step.
732
+ */
733
+ private function sp_setup_ready_actions() {
734
+ delete_option( '_sp_needs_welcome' );
735
+ update_option( 'sportspress_installed', 1 );
736
+ update_option( 'sportspress_completed_setup', 1 );
737
+ delete_transient( '_sp_activation_redirect' );
738
+
739
+ // Check if first event already exists
740
+ $events = get_posts(
741
+ array(
742
+ 'post_type' => 'sp_event',
743
+ 'posts_per_page' => 1,
744
+ 'post_status' => 'draft',
745
+ 'meta_query' => array(
746
+ array(
747
+ 'key' => '_sp_first',
748
+ 'value' => 1,
749
+ ),
750
+ ),
751
+ )
752
+ );
753
+
754
+ if ( $events ) {
755
+ $event = reset( $events );
756
+ return $event->ID;
757
+ }
758
+
759
+ // Get teams
760
+ $team_post_type = 'sp_team';
761
+ if ( 'player' === get_option( 'sportspress_mode', 'team' ) ) {
762
+ $team_post_type = 'sp_player';
763
+ }
764
+ $teams = get_posts(
765
+ array(
766
+ 'posts_per_page' => 2,
767
+ 'post_type' => $team_post_type,
768
+ )
769
+ );
770
+
771
+ // Get players
772
+ $players = (array) get_posts(
773
+ array(
774
+ 'posts_per_page' => 3,
775
+ 'post_type' => 'sp_player',
776
+ 'fields' => 'ids',
777
+ )
778
+ );
779
+
780
+ // Get staff
781
+ $staff = (array) get_posts(
782
+ array(
783
+ 'posts_per_page' => 1,
784
+ 'post_type' => 'sp_staff',
785
+ 'fields' => 'ids',
786
+ )
787
+ );
788
+
789
+ // Initialize post
790
+ $post['post_type'] = 'sp_event';
791
+ $post['post_status'] = 'draft';
792
+ $post['tax_input'] = array();
793
+
794
+ // Add taxonomies
795
+ $taxonomies = array( 'sp_league', 'sp_season', 'sp_venue' );
796
+ foreach ( $taxonomies as $taxonomy ) {
797
+ $post['tax_input'][ $taxonomy ] = get_terms(
798
+ $taxonomy,
799
+ array(
800
+ 'hide_empty' => 0,
801
+ 'fields' => 'ids',
802
+ 'number' => 1,
803
+ )
804
+ );
805
+ }
806
+
807
+ // Add post title
808
+ if ( is_array( $teams ) && sizeof( $teams ) ) {
809
+ $team_names = array();
810
+ foreach ( $teams as $team ) {
811
+ if ( ! $team ) {
812
+ continue;
813
+ }
814
+ $team_names[] = $team->post_title;
815
+ }
816
+ $post['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
817
+ } else {
818
+ $post['post_title'] = esc_attr__( 'Event', 'sportspress' );
819
+ }
820
+
821
+ // Insert event
822
+ $id = wp_insert_post( $post );
823
+
824
+ // Add teams
825
+ if ( is_array( $teams ) && sizeof( $teams ) ) {
826
+ foreach ( $teams as $team ) {
827
+ if ( ! $team ) {
828
+ continue;
829
+ }
830
+ add_post_meta( $id, 'sp_team', $team->ID );
831
+ }
832
+ }
833
+
834
+ // Add players
835
+ add_post_meta( $id, 'sp_player', 0 );
836
+ foreach ( $players as $player ) {
837
+ if ( ! $player ) {
838
+ continue;
839
+ }
840
+ add_post_meta( $id, 'sp_player', $player );
841
+ }
842
+ add_post_meta( $id, 'sp_player', 0 );
843
+
844
+ update_post_meta( $id, '_sp_first', 1 );
845
+
846
+ return $id;
847
+ }
848
+
849
+ /**
850
+ * Final step.
851
+ */
852
+ public function sp_setup_ready() {
853
+ $id = $this->sp_setup_ready_actions();
854
+ shuffle( $this->tweets );
855
+
856
+ $steps = apply_filters(
857
+ 'sportspress_setup_wizard_next_steps',
858
+ array(
859
+ 'first' => array(
860
+ 'label' => esc_attr__( 'Next Steps', 'sportspress' ),
861
+ 'content' => '<a class="button button-primary button-large button-first-event" href="' . esc_url( admin_url( 'post.php?post=' . $id . '&action=edit' ) ) . '">' . esc_attr__( 'Schedule your first event!', 'sportspress' ) . '</a>',
862
+ ),
863
+ 'last' => array(
864
+ 'label' => esc_attr__( 'Upgrade to Pro', 'sportspress' ),
865
+ 'content' => esc_attr__( 'Get SportsPress Pro to get access to all modules. You can upgrade any time without losing any of your data.', 'sportspress' ) . ' <a href="' . apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ) . '" target="_blank">' . esc_attr__( 'Learn more', 'sportspress' ) . '</a>',
866
+ ),
867
+ )
868
+ );
869
+ ?>
870
+ <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://tboy.co/sp" data-text="<?php echo esc_attr( $this->tweets[0] ); ?>" data-via="ThemeBoy" data-size="large">Tweet</a>
871
+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
872
+
873
+ <h1><?php esc_html_e( 'Thanks for installing!', 'sportspress' ); ?></h1>
874
+
875
+ <div class="sp-banner"><img src="//ps.w.org/sportspress/assets/banner-772x250.png"></div>
876
+
877
+ <div class="sp-setup-next-steps">
878
+ <?php foreach ( $steps as $class => $step ) { ?>
879
+ <div class="sp-setup-next-steps-<?php echo esc_attr( $class ); ?>">
880
+ <h2><?php echo esc_html( $step['label'] ); ?></h2>
881
+ <ul>
882
+ <li><?php echo wp_kses_post( $step['content'] ); ?></li>
883
+ </ul>
884
+ </div>
885
+ <?php } ?>
886
+ </div>
887
+ <?php
888
+ }
889
  }
890
 
891
  new SP_Admin_Setup_Wizard();
includes/admin/class-sp-admin-sports.php CHANGED
@@ -4,11 +4,11 @@
4
  *
5
  * The SportsPress admin sports class stores preset sport data.
6
  *
7
- * @class SP_Admin_Sports
8
- * @version 2.6
9
- * @package SportsPress/Admin
10
- * @category Class
11
- * @author ThemeBoy
12
  */
13
  class SP_Admin_Sports {
14
 
@@ -20,18 +20,18 @@ class SP_Admin_Sports {
20
  */
21
  public static function get_presets() {
22
  if ( empty( self::$presets ) ) {
23
- $presets = array();
24
  self::$options = array(
25
- 'team-sports' => array(),
26
  'racket-sports' => array(),
27
- 'water-sports' => array(),
28
  'target-sports' => array(),
29
- 'esports' => array(),
30
- 'other' => array(),
31
  );
32
 
33
  foreach ( self::$options as $slug => $options ) {
34
- $dir = scandir( SP()->plugin_path() . '/presets/' . $slug );
35
  $files = array();
36
  if ( $dir ) {
37
  foreach ( $dir as $key => $value ) {
@@ -40,13 +40,15 @@ class SP_Admin_Sports {
40
  }
41
  }
42
  }
43
- foreach( $files as $file ) {
44
  $json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $slug . '/' . $file );
45
- $data = json_decode( $json_data, true );
46
- if ( ! is_array( $data ) ) continue;
47
- $id = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file );
 
 
48
  $presets[ $id ] = $data;
49
- $name = array_key_exists( 'name', $data ) ? __( $data['name'], 'sportspress' ) : $id;
50
 
51
  // Conditionally append filename in parentheses for clarity
52
  if ( false === strpos( str_replace( ' ', '', strtolower( $data['name'] ) ), str_replace( '-', '', $id ) ) ) {
@@ -69,15 +71,19 @@ class SP_Admin_Sports {
69
 
70
  public static function get_preset( $id ) {
71
  $json_data = @file_get_contents( SP()->plugin_path() . '/presets/' . $id . '.json', true );
72
-
73
- if ( $json_data ) return json_decode( $json_data, true );
74
-
 
 
75
  $dir = scandir( SP()->plugin_path() . '/presets' );
76
  if ( $dir ) {
77
  foreach ( $dir as $key => $value ) {
78
  if ( substr( $value, 0, 1 ) !== '.' && strpos( $value, '.' ) === false ) {
79
  $json_data = @file_get_contents( SP()->plugin_path() . '/presets/' . $value . '/' . $id . '.json', true );
80
- if ( $json_data ) return json_decode( $json_data, true );
 
 
81
  }
82
  }
83
  }
@@ -99,19 +105,21 @@ class SP_Admin_Sports {
99
 
100
  // Positions
101
  $positions = sp_array_value( $preset, 'positions', array() );
102
- $i = 0;
103
  foreach ( $positions as $position ) {
104
  if ( is_string( $position ) ) {
105
- $name = $position;
106
  $sections = array( 0, 1 );
107
  } else {
108
- $name = sp_array_value( $position, 'name', __( 'Position', 'sportspress' ) );
109
  $sections = sp_array_value( $position, 'sections', array( 0, 1 ) );
110
  }
111
  $term = wp_insert_term( $name, 'sp_position' );
112
- if ( is_wp_error( $term ) ) continue;
113
- $t_id = $term['term_id'];
114
- $term_meta = get_option( "taxonomy_$t_id" );
 
 
115
  $term_meta['sp_sections'] = $sections;
116
  update_option( "taxonomy_$t_id", $term_meta );
117
  update_term_meta( $t_id, 'sp_order', $i + 1 );
@@ -120,11 +128,13 @@ class SP_Admin_Sports {
120
 
121
  // Outcomes
122
  $post_type = 'sp_outcome';
123
- $outcomes = sp_array_value( $preset, 'outcomes', array() );
124
  self::delete_preset_posts( $post_type );
125
  foreach ( $outcomes as $index => $outcome ) {
126
  $post = self::get_post_array( $outcome, $post_type );
127
- if ( empty( $post ) ) continue;
 
 
128
  $id = self::insert_preset_post( $post, $index );
129
  update_post_meta( $id, 'sp_abbreviation', sp_array_value( $outcome, 'abbreviation', null ) );
130
  update_post_meta( $id, 'sp_condition', sp_array_value( $outcome, 'condition', null ) );
@@ -132,14 +142,18 @@ class SP_Admin_Sports {
132
 
133
  // Results
134
  $post_type = 'sp_result';
135
- $results = sp_array_value( $preset, 'results', array() );
136
  self::delete_preset_posts( $post_type );
137
  $primary_result = 0;
138
  foreach ( $results as $index => $result ) {
139
  $post = self::get_post_array( $result, $post_type );
140
- if ( empty( $post ) ) continue;
 
 
141
  $id = self::insert_preset_post( $post, $index );
142
- if ( is_array( $result ) && array_key_exists( 'primary', $result ) ) $primary_result = $post['post_name'];
 
 
143
  update_post_meta( $id, 'sp_equation', sp_array_value( $result, 'equation', null ) );
144
  }
145
 
@@ -147,12 +161,14 @@ class SP_Admin_Sports {
147
  $i = 0;
148
 
149
  // Performance
150
- $post_type = 'sp_performance';
151
  $performances = sp_array_value( $preset, 'performance', array() );
152
  self::delete_preset_posts( $post_type );
153
  foreach ( $performances as $index => $performance ) {
154
  $post = self::get_post_array( $performance, $post_type );
155
- if ( empty( $post ) ) continue;
 
 
156
  $id = self::insert_preset_post( $post, $index );
157
  if ( isset( $performance['position'] ) ) {
158
  wp_set_object_terms( $id, $performance['position'], 'sp_position', false );
@@ -170,11 +186,13 @@ class SP_Admin_Sports {
170
 
171
  // Columns
172
  $post_type = 'sp_column';
173
- $columns = sp_array_value( $preset, 'columns', array() );
174
  self::delete_preset_posts( $post_type );
175
  foreach ( $columns as $index => $column ) {
176
  $post = self::get_post_array( $column, $post_type );
177
- if ( empty( $post ) ) continue;
 
 
178
  $id = self::insert_preset_post( $post, $index );
179
  update_post_meta( $id, 'sp_equation', sp_array_value( $column, 'equation', null ) );
180
  update_post_meta( $id, 'sp_precision', sp_array_value( $column, 'precision', 0 ) );
@@ -184,40 +202,45 @@ class SP_Admin_Sports {
184
 
185
  // Metrics
186
  $post_type = 'sp_metric';
187
- $metrics = sp_array_value( $preset, 'metrics', array() );
188
  self::delete_preset_posts( $post_type );
189
  foreach ( $metrics as $index => $metric ) {
190
  $post = self::get_post_array( $metric, $post_type );
191
- if ( empty( $post ) ) continue;
 
 
192
  $id = self::insert_preset_post( $post, $i + $index );
193
  $i ++;
194
  }
195
-
196
  // Event Specs
197
  $post_type = 'sp_spec';
198
- $specs = sp_array_value( $preset, 'specs', array() );
199
  self::delete_preset_posts( $post_type );
200
  foreach ( $specs as $index => $spec ) {
201
  $post = self::get_post_array( $spec, $post_type );
202
- if ( empty( $post ) ) continue;
 
 
203
  $id = self::insert_preset_post( $post, $i + $index );
204
  $i ++;
205
  }
206
 
207
  // Statistics
208
- $post_type = 'sp_statistic';
209
  $statistics = sp_array_value( $preset, 'statistics', array() );
210
  self::delete_preset_posts( $post_type );
211
  foreach ( $statistics as $index => $statistic ) {
212
  $post = self::get_post_array( $statistic, $post_type );
213
- if ( empty( $post ) ) continue;
 
 
214
  $id = self::insert_preset_post( $post, $i + $index );
215
  update_post_meta( $id, 'sp_equation', sp_array_value( $statistic, 'equation', null ) );
216
  update_post_meta( $id, 'sp_precision', sp_array_value( $statistic, 'precision', 0 ) );
217
  update_post_meta( $id, 'sp_type', sp_array_value( $statistic, 'type', 'total' ) );
218
  }
219
 
220
-
221
  // Options
222
  $options = sp_array_value( $preset, 'options', array() );
223
  foreach ( $options as $option => $value ) {
@@ -230,20 +253,20 @@ class SP_Admin_Sports {
230
 
231
  public static function delete_preset_posts( $post_type = null ) {
232
  $args = array(
233
- 'post_type' => $post_type,
234
  'posts_per_page' => -1,
235
- 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
236
- 'meta_query' => array(
237
  array(
238
- 'key' => '_sp_preset',
239
- 'value' => 1
240
- )
241
- )
242
  );
243
 
244
  // Delete posts
245
  $old_posts = get_posts( $args );
246
- foreach( $old_posts as $post ):
247
  wp_delete_post( $post->ID, true );
248
  endforeach;
249
  }
@@ -252,15 +275,19 @@ class SP_Admin_Sports {
252
  $post_array = array();
253
  if ( is_string( $post ) ) {
254
  $post_array['post_title'] = $post;
255
- $post_array['post_name'] = sp_get_eos_safe_slug( $post_array['post_title'] );
256
  } elseif ( is_array( $post ) ) {
257
- if ( ! array_key_exists( 'name', $post ) ) $post_array = array();
 
 
258
  $post_array['post_title'] = $post['name'];
259
- $post_array['post_name'] = sp_array_value( $post, 'id', sp_get_eos_safe_slug( $post_array['post_title'] ) );
260
  }
261
 
262
  // Return empty array if post with same slug already exists
263
- if ( get_page_by_path( $post_array['post_name'], OBJECT, $post_type ) ) return array();
 
 
264
 
265
  // Set post type
266
  $post_array['post_type'] = $post_type;
@@ -275,9 +302,9 @@ class SP_Admin_Sports {
275
 
276
  public static function insert_preset_post( $post, $index = 0 ) {
277
  // Increment menu order by 10 and publish post
278
- $post['menu_order'] = $index * 10 + 10;
279
  $post['post_status'] = 'publish';
280
- $id = wp_insert_post( $post );
281
 
282
  // Flag as preset
283
  update_post_meta( $id, '_sp_preset', 1 );
@@ -287,21 +314,26 @@ class SP_Admin_Sports {
287
 
288
  /**
289
  * Sport category names
 
290
  * @return null
291
  */
292
  public static function sport_category_names() {
293
- return apply_filters( 'sportspress_sport_categories', array(
294
- 'team-sports' => __( 'Team Sports', 'sportspress' ),
295
- 'racket-sports' => __( 'Racket Sports', 'sportspress' ),
296
- 'water-sports' => __( 'Water Sports', 'sportspress' ),
297
- 'target-sports' => __( 'Target Sports', 'sportspress' ),
298
- 'esports' => __( 'Esports', 'sportspress' ),
299
- 'other' => __( 'Other', 'sportspress' ),
300
- ) );
 
 
 
301
  }
302
 
303
  /**
304
  * Sport preset names for localization
 
305
  * @return null
306
  */
307
  public static function sport_preset_names() {
4
  *
5
  * The SportsPress admin sports class stores preset sport data.
6
  *
7
+ * @class SP_Admin_Sports
8
+ * @version 2.6
9
+ * @package SportsPress/Admin
10
+ * @category Class
11
+ * @author ThemeBoy
12
  */
13
  class SP_Admin_Sports {
14
 
20
  */
21
  public static function get_presets() {
22
  if ( empty( self::$presets ) ) {
23
+ $presets = array();
24
  self::$options = array(
25
+ 'team-sports' => array(),
26
  'racket-sports' => array(),
27
+ 'water-sports' => array(),
28
  'target-sports' => array(),
29
+ 'esports' => array(),
30
+ 'other' => array(),
31
  );
32
 
33
  foreach ( self::$options as $slug => $options ) {
34
+ $dir = scandir( SP()->plugin_path() . '/presets/' . $slug );
35
  $files = array();
36
  if ( $dir ) {
37
  foreach ( $dir as $key => $value ) {
40
  }
41
  }
42
  }
43
+ foreach ( $files as $file ) {
44
  $json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $slug . '/' . $file );
45
+ $data = json_decode( $json_data, true );
46
+ if ( ! is_array( $data ) ) {
47
+ continue;
48
+ }
49
+ $id = preg_replace( '/\\.[^.\\s]{3,4}$/', '', $file );
50
  $presets[ $id ] = $data;
51
+ $name = array_key_exists( 'name', $data ) ? esc_attr__( $data['name'], 'sportspress' ) : $id;
52
 
53
  // Conditionally append filename in parentheses for clarity
54
  if ( false === strpos( str_replace( ' ', '', strtolower( $data['name'] ) ), str_replace( '-', '', $id ) ) ) {
71
 
72
  public static function get_preset( $id ) {
73
  $json_data = @file_get_contents( SP()->plugin_path() . '/presets/' . $id . '.json', true );
74
+
75
+ if ( $json_data ) {
76
+ return json_decode( $json_data, true );
77
+ }
78
+
79
  $dir = scandir( SP()->plugin_path() . '/presets' );
80
  if ( $dir ) {
81
  foreach ( $dir as $key => $value ) {
82
  if ( substr( $value, 0, 1 ) !== '.' && strpos( $value, '.' ) === false ) {
83
  $json_data = @file_get_contents( SP()->plugin_path() . '/presets/' . $value . '/' . $id . '.json', true );
84
+ if ( $json_data ) {
85
+ return json_decode( $json_data, true );
86
+ }
87
  }
88
  }
89
  }
105
 
106
  // Positions
107
  $positions = sp_array_value( $preset, 'positions', array() );
108
+ $i = 0;
109
  foreach ( $positions as $position ) {
110
  if ( is_string( $position ) ) {
111
+ $name = $position;
112
  $sections = array( 0, 1 );
113
  } else {
114
+ $name = sp_array_value( $position, 'name', esc_attr__( 'Position', 'sportspress' ) );
115
  $sections = sp_array_value( $position, 'sections', array( 0, 1 ) );
116
  }
117
  $term = wp_insert_term( $name, 'sp_position' );
118
+ if ( is_wp_error( $term ) ) {
119
+ continue;
120
+ }
121
+ $t_id = $term['term_id'];
122
+ $term_meta = get_option( "taxonomy_$t_id" );
123
  $term_meta['sp_sections'] = $sections;
124
  update_option( "taxonomy_$t_id", $term_meta );
125
  update_term_meta( $t_id, 'sp_order', $i + 1 );
128
 
129
  // Outcomes
130
  $post_type = 'sp_outcome';
131
+ $outcomes = sp_array_value( $preset, 'outcomes', array() );
132
  self::delete_preset_posts( $post_type );
133
  foreach ( $outcomes as $index => $outcome ) {
134
  $post = self::get_post_array( $outcome, $post_type );
135
+ if ( empty( $post ) ) {
136
+ continue;
137
+ }
138
  $id = self::insert_preset_post( $post, $index );
139
  update_post_meta( $id, 'sp_abbreviation', sp_array_value( $outcome, 'abbreviation', null ) );
140
  update_post_meta( $id, 'sp_condition', sp_array_value( $outcome, 'condition', null ) );
142
 
143
  // Results
144
  $post_type = 'sp_result';
145
+ $results = sp_array_value( $preset, 'results', array() );
146
  self::delete_preset_posts( $post_type );
147
  $primary_result = 0;
148
  foreach ( $results as $index => $result ) {
149
  $post = self::get_post_array( $result, $post_type );
150
+ if ( empty( $post ) ) {
151
+ continue;
152
+ }
153
  $id = self::insert_preset_post( $post, $index );
154
+ if ( is_array( $result ) && array_key_exists( 'primary', $result ) ) {
155
+ $primary_result = $post['post_name'];
156
+ }
157
  update_post_meta( $id, 'sp_equation', sp_array_value( $result, 'equation', null ) );
158
  }
159
 
161
  $i = 0;
162
 
163
  // Performance
164
+ $post_type = 'sp_performance';
165
  $performances = sp_array_value( $preset, 'performance', array() );
166
  self::delete_preset_posts( $post_type );
167
  foreach ( $performances as $index => $performance ) {
168
  $post = self::get_post_array( $performance, $post_type );
169
+ if ( empty( $post ) ) {
170
+ continue;
171
+ }
172
  $id = self::insert_preset_post( $post, $index );
173
  if ( isset( $performance['position'] ) ) {
174
  wp_set_object_terms( $id, $performance['position'], 'sp_position', false );
186
 
187
  // Columns
188
  $post_type = 'sp_column';
189
+ $columns = sp_array_value( $preset, 'columns', array() );
190
  self::delete_preset_posts( $post_type );
191
  foreach ( $columns as $index => $column ) {
192
  $post = self::get_post_array( $column, $post_type );
193
+ if ( empty( $post ) ) {
194
+ continue;
195
+ }
196
  $id = self::insert_preset_post( $post, $index );
197
  update_post_meta( $id, 'sp_equation', sp_array_value( $column, 'equation', null ) );
198
  update_post_meta( $id, 'sp_precision', sp_array_value( $column, 'precision', 0 ) );
202
 
203
  // Metrics
204
  $post_type = 'sp_metric';
205
+ $metrics = sp_array_value( $preset, 'metrics', array() );
206
  self::delete_preset_posts( $post_type );
207
  foreach ( $metrics as $index => $metric ) {
208
  $post = self::get_post_array( $metric, $post_type );
209
+ if ( empty( $post ) ) {
210
+ continue;
211
+ }
212
  $id = self::insert_preset_post( $post, $i + $index );
213
  $i ++;
214
  }
215
+
216
  // Event Specs
217
  $post_type = 'sp_spec';
218
+ $specs = sp_array_value( $preset, 'specs', array() );
219
  self::delete_preset_posts( $post_type );
220
  foreach ( $specs as $index => $spec ) {
221
  $post = self::get_post_array( $spec, $post_type );
222
+ if ( empty( $post ) ) {
223
+ continue;
224
+ }
225
  $id = self::insert_preset_post( $post, $i + $index );
226
  $i ++;
227
  }
228
 
229
  // Statistics
230
+ $post_type = 'sp_statistic';
231
  $statistics = sp_array_value( $preset, 'statistics', array() );
232
  self::delete_preset_posts( $post_type );
233
  foreach ( $statistics as $index => $statistic ) {
234
  $post = self::get_post_array( $statistic, $post_type );
235
+ if ( empty( $post ) ) {
236
+ continue;
237
+ }
238
  $id = self::insert_preset_post( $post, $i + $index );
239
  update_post_meta( $id, 'sp_equation', sp_array_value( $statistic, 'equation', null ) );
240
  update_post_meta( $id, 'sp_precision', sp_array_value( $statistic, 'precision', 0 ) );
241
  update_post_meta( $id, 'sp_type', sp_array_value( $statistic, 'type', 'total' ) );
242
  }
243
 
 
244
  // Options
245
  $options = sp_array_value( $preset, 'options', array() );
246
  foreach ( $options as $option => $value ) {
253
 
254
  public static function delete_preset_posts( $post_type = null ) {
255
  $args = array(
256
+ 'post_type' => $post_type,
257
  'posts_per_page' => -1,
258
+ 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
259
+ 'meta_query' => array(
260
  array(
261
+ 'key' => '_sp_preset',
262
+ 'value' => 1,
263
+ ),
264
+ ),
265
  );
266
 
267
  // Delete posts
268
  $old_posts = get_posts( $args );
269
+ foreach ( $old_posts as $post ) :
270
  wp_delete_post( $post->ID, true );
271
  endforeach;
272
  }
275
  $post_array = array();
276
  if ( is_string( $post ) ) {
277
  $post_array['post_title'] = $post;
278
+ $post_array['post_name'] = sp_get_eos_safe_slug( $post_array['post_title'] );
279
  } elseif ( is_array( $post ) ) {
280
+ if ( ! array_key_exists( 'name', $post ) ) {
281
+ $post_array = array();
282
+ }
283
  $post_array['post_title'] = $post['name'];
284
+ $post_array['post_name'] = sp_array_value( $post, 'id', sp_get_eos_safe_slug( $post_array['post_title'] ) );
285
  }
286
 
287
  // Return empty array if post with same slug already exists
288
+ if ( get_page_by_path( $post_array['post_name'], OBJECT, $post_type ) ) {
289
+ return array();
290
+ }
291
 
292
  // Set post type
293
  $post_array['post_type'] = $post_type;
302
 
303
  public static function insert_preset_post( $post, $index = 0 ) {
304
  // Increment menu order by 10 and publish post
305
+ $post['menu_order'] = $index * 10 + 10;
306
  $post['post_status'] = 'publish';
307
+ $id = wp_insert_post( $post );
308
 
309
  // Flag as preset
310
  update_post_meta( $id, '_sp_preset', 1 );
314
 
315
  /**
316
  * Sport category names
317
+ *
318
  * @return null
319
  */
320
  public static function sport_category_names() {
321
+ return apply_filters(
322
+ 'sportspress_sport_categories',
323
+ array(
324
+ 'team-sports' => esc_attr__( 'Team Sports', 'sportspress' ),
325
+ 'racket-sports' => esc_attr__( 'Racket Sports', 'sportspress' ),
326
+ 'water-sports' => esc_attr__( 'Water Sports', 'sportspress' ),
327
+ 'target-sports' => esc_attr__( 'Target Sports', 'sportspress' ),
328
+ 'esports' => esc_attr__( 'Esports', 'sportspress' ),
329
+ 'other' => esc_attr__( 'Other', 'sportspress' ),
330
+ )
331
+ );
332
  }
333
 
334
  /**
335
  * Sport preset names for localization
336
+ *
337
  * @return null
338
  */
339
  public static function sport_preset_names() {
includes/admin/class-sp-admin-status.php CHANGED
@@ -2,75 +2,78 @@
2
  /**
3
  * Debug/Status page
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin
8
  * @version 1.4
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( ! class_exists( 'SP_Admin_Status' ) ) :
14
 
15
- /**
16
- * SP_Admin_Status Class
17
- */
18
- class SP_Admin_Status {
19
-
20
  /**
21
- * Retrieve metadata from a file. Based on WP Core's get_file_data function
22
- *
23
- * @since 0.8
24
- * @param string $file Path to the file
25
- * @param array $all_headers List of headers, in the format array('HeaderKey' => 'Header Name')
26
  */
27
- public function get_file_version( $file ) {
28
- // We don't need to write to the file, so just open for reading.
29
- $fp = fopen( $file, 'r' );
30
 
31
- // Pull only the first 8kiB of the file in.
32
- $file_data = fread( $fp, 8192 );
 
 
 
 
 
 
 
 
33
 
34
- // PHP will close file handle, but we are good citizens.
35
- fclose( $fp );
36
 
37
- // Make sure we catch CR-only line endings.
38
- $file_data = str_replace( "\r", "\n", $file_data );
39
- $version = '';
40
 
41
- if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] )
42
- $version = _cleanup_header_comment( $match[1] );
 
43
 
44
- return $version ;
45
- }
46
-
47
- /**
48
- * Scan the template files
49
- *
50
- * @access public
51
- * @param string $template_path
52
- * @return array
53
- */
54
- public function scan_template_files( $template_path ) {
55
- $files = scandir( $template_path );
56
- $result = array();
57
- if ( $files ) {
58
- foreach ( $files as $key => $value ) {
59
- if ( ! in_array( $value, array( ".",".." ) ) ) {
60
- if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
61
- $sub_files = $this->scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
62
- foreach ( $sub_files as $sub_file ) {
63
- $result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
 
 
 
 
 
 
 
64
  }
65
- } else {
66
- $result[] = $value;
67
  }
68
  }
69
  }
 
70
  }
71
- return $result;
72
  }
73
- }
74
 
75
  endif;
76
 
2
  /**
3
  * Debug/Status page
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin
8
  * @version 1.4
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( ! class_exists( 'SP_Admin_Status' ) ) :
16
 
 
 
 
 
 
17
  /**
18
+ * SP_Admin_Status Class
 
 
 
 
19
  */
20
+ class SP_Admin_Status {
 
 
21
 
22
+ /**
23
+ * Retrieve metadata from a file. Based on WP Core's get_file_data function
24
+ *
25
+ * @since 0.8
26
+ * @param string $file Path to the file
27
+ * @param array $all_headers List of headers, in the format array('HeaderKey' => 'Header Name')
28
+ */
29
+ public function get_file_version( $file ) {
30
+ // We don't need to write to the file, so just open for reading.
31
+ $fp = fopen( $file, 'r' );
32
 
33
+ // Pull only the first 8kiB of the file in.
34
+ $file_data = fread( $fp, 8192 );
35
 
36
+ // PHP will close file handle, but we are good citizens.
37
+ fclose( $fp );
 
38
 
39
+ // Make sure we catch CR-only line endings.
40
+ $file_data = str_replace( "\r", "\n", $file_data );
41
+ $version = '';
42
 
43
+ if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
44
+ $version = _cleanup_header_comment( $match[1] );
45
+ }
46
+
47
+ return $version;
48
+ }
49
+
50
+ /**
51
+ * Scan the template files
52
+ *
53
+ * @access public
54
+ * @param string $template_path
55
+ * @return array
56
+ */
57
+ public function scan_template_files( $template_path ) {
58
+ $files = scandir( $template_path );
59
+ $result = array();
60
+ if ( $files ) {
61
+ foreach ( $files as $key => $value ) {
62
+ if ( ! in_array( $value, array( '.', '..' ) ) ) {
63
+ if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
64
+ $sub_files = $this->scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
65
+ foreach ( $sub_files as $sub_file ) {
66
+ $result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
67
+ }
68
+ } else {
69
+ $result[] = $value;
70
  }
 
 
71
  }
72
  }
73
  }
74
+ return $result;
75
  }
 
76
  }
 
77
 
78
  endif;
79
 
includes/admin/class-sp-admin-taxonomies.php CHANGED
@@ -6,11 +6,11 @@ if ( ! defined( 'ABSPATH' ) ) {
6
  /**
7
  * Handles taxonomies in admin
8
  *
9
- * @class SP_Admin_Taxonomies
10
- * @version 2.6.15
11
- * @package SportsPress/Admin
12
- * @category Class
13
- * @author ThemeBoy
14
  */
15
  class SP_Admin_Taxonomies {
16
 
@@ -71,16 +71,16 @@ class SP_Admin_Taxonomies {
71
  * @param mixed $term Term (category) being edited
72
  */
73
  public function edit_taxonomy_fields( $term ) {
74
- $t_id = $term->term_id;
75
  ?>
76
  <?php if ( function_exists( 'get_term_meta' ) ) { ?>
77
  <?php $order = get_term_meta( $t_id, 'sp_order', true ); ?>
78
  <tr class="form-field">
79
- <th scope="row" valign="top"><label for="sp_order"><?php _e( 'Order', 'sportspress' ); ?></label></th>
80
  <td><input name="sp_order" class="sp-number-input" type="text" step="1" size="4" id="sp_order" value="<?php echo (int) $order; ?>"></td>
81
  </tr>
82
  <?php } ?>
83
- <?php
84
  }
85
 
86
  /**
@@ -91,45 +91,45 @@ class SP_Admin_Taxonomies {
91
  */
92
  public function add_venue_fields() {
93
  $args = array(
94
- 'orderby' => 'id',
95
- 'order' => 'DESC',
96
  'hide_empty' => false,
97
- 'number' => 1,
98
  );
99
 
100
  // Get latitude and longitude from the last added venue
101
  $terms = get_terms( 'sp_venue', $args );
102
- if ( $terms && array_key_exists( 0, $terms) && is_object( reset( $terms ) ) ):
103
- $term = reset( $terms );
104
- $t_id = $term->term_id;
105
  $term_meta = get_option( "taxonomy_$t_id" );
106
- $latitude = sp_array_value( $term_meta, 'sp_latitude', '-37.8165647' );
107
  $longitude = sp_array_value( $term_meta, 'sp_longitude', '144.9475055' );
108
- $address = sp_array_value( $term_meta, 'sp_address', '' );
109
  endif;
110
  // Sanitize latitude and longitude, fallback to default.
111
- if( ! is_numeric( $latitude) || ! is_numeric( $longitude) ):
112
- $latitude = '-37.8165647';
113
  $longitude = '144.9475055';
114
  endif;
115
  ?>
116
  <div class="form-field">
117
  <div id="sp-location-picker" class="sp-location-picker" style="width: 95%; height: 320px"></div>
118
- <p><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
119
  </div>
120
  <div class="form-field">
121
- <label for="term_meta[sp_address]"><?php _e( 'Address', 'sportspress' ); ?></label>
122
  <input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="<?php echo esc_attr( $address ); ?>">
123
  </div>
124
  <div class="form-field">
125
- <label for="term_meta[sp_latitude]"><?php _e( 'Latitude', 'sportspress' ); ?></label>
126
  <input type="text" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="<?php echo esc_attr( $latitude ); ?>">
127
  </div>
128
  <div class="form-field">
129
- <label for="term_meta[sp_longitude]"><?php _e( 'Longitude', 'sportspress' ); ?></label>
130
  <input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo esc_attr( $longitude ); ?>">
131
  </div>
132
- <?php
133
  do_action( 'sp_admin_geocoder_scripts' );
134
  }
135
 
@@ -140,37 +140,37 @@ class SP_Admin_Taxonomies {
140
  * @param mixed $term Term (category) being edited
141
  */
142
  public function edit_venue_fields( $term ) {
143
- $t_id = $term->term_id;
144
- $term_meta = get_option( "taxonomy_$t_id" );
145
- $latitude = is_numeric( esc_attr( $term_meta['sp_latitude'] ) ) ? esc_attr( $term_meta['sp_latitude'] ) : '';
146
- $longitude = is_numeric( esc_attr( $term_meta['sp_longitude'] ) ) ? esc_attr( $term_meta['sp_longitude'] ) : '';
147
- $address = esc_attr( $term_meta['sp_address'] ) ? esc_attr( $term_meta['sp_address'] ) : '';
148
  ?>
149
  <tr class="form-field">
150
  <td colspan="2">
151
  <p><div id="sp-location-picker" class="sp-location-picker" style="width: 95%; height: 320px"></div></p>
152
- <p class="description"><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
153
  </td>
154
  </tr>
155
  <tr class="form-field">
156
- <th scope="row" valign="top"><label for="term_meta[sp_address]"><?php _e( 'Address', 'sportspress' ); ?></label></th>
157
  <td>
158
- <input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="<?php echo $address; ?>">
159
  </td>
160
  </tr>
161
  <tr class="form-field">
162
- <th scope="row" valign="top"><label for="term_meta[sp_latitude]"><?php _e( 'Latitude', 'sportspress' ); ?></label></th>
163
  <td>
164
- <input type="text" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="<?php echo $latitude; ?>">
165
  </td>
166
  </tr>
167
  <tr class="form-field">
168
- <th scope="row" valign="top"><label for="term_meta[sp_longitude]"><?php _e( 'Longitude', 'sportspress' ); ?></label></th>
169
  <td>
170
- <input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo $longitude; ?>">
171
  </td>
172
  </tr>
173
- <?php
174
  do_action( 'sp_admin_geocoder_scripts' );
175
  }
176
 
@@ -183,17 +183,30 @@ class SP_Admin_Taxonomies {
183
  public function add_position_fields() {
184
  ?>
185
  <div class="form-field">
186
- <label><?php _e( 'Statistics', 'sportspress' ); ?></label>
187
- <select name="term_meta[sp_sections][]" id="term_meta[sp_sections][]" class="widefat chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>" multiple="multiple">
 
 
 
 
188
  <?php
189
- $options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
190
- foreach ( $options as $key => $value ):
191
- printf( '<option value="%s" %s>%s</option>', $key, selected( true ), $value );
 
 
 
 
 
 
 
 
 
192
  endforeach;
193
  ?>
194
  </select>
195
  </div>
196
- <?php
197
  }
198
 
199
  /**
@@ -203,18 +216,31 @@ class SP_Admin_Taxonomies {
203
  * @param mixed $term Term (category) being edited
204
  */
205
  public function edit_position_fields( $term ) {
206
- $t_id = $term->term_id;
207
  $sections = sp_get_term_sections( $t_id );
208
  ?>
209
  <tr class="form-field">
210
- <th scope="row" valign="top"><label for="term_meta[sp_sections]"><?php _e( 'Statistics', 'sportspress' ); ?></label></th>
211
  <input type="hidden" name="term_meta[sp_sections]" value="">
212
  <td>
213
- <select name="term_meta[sp_sections][]" id="term_meta[sp_sections][]" class="widefat chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>" multiple="multiple">
 
 
 
 
214
  <?php
215
- $options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
216
- foreach ( $options as $key => $value ):
217
- printf( '<option value="%s" %s>%s</option>', $key, selected( in_array( $key, $sections ), true, false ), $value );
 
 
 
 
 
 
 
 
 
218
  endforeach;
219
  ?>
220
  </select>
@@ -223,11 +249,11 @@ class SP_Admin_Taxonomies {
223
  <?php if ( function_exists( 'get_term_meta' ) ) { ?>
224
  <?php $order = get_term_meta( $t_id, 'sp_order', true ); ?>
225
  <tr class="form-field">
226
- <th scope="row" valign="top"><label for="sp_order"><?php _e( 'Order', 'sportspress' ); ?></label></th>
227
  <td><input name="sp_order" class="sp-number-input" type="text" step="1" size="4" id="sp_order" value="<?php echo (int) $order; ?>"></td>
228
  </tr>
229
  <?php } ?>
230
- <?php
231
  }
232
 
233
  /**
@@ -239,18 +265,18 @@ class SP_Admin_Taxonomies {
239
  */
240
  public function save_fields( $term_id ) {
241
  if ( isset( $_POST['term_meta'] ) ) {
242
- $t_id = $term_id;
243
  $term_meta = get_option( "taxonomy_$t_id" );
244
- $cat_keys = array_keys( $_POST['term_meta'] );
245
  foreach ( $cat_keys as $key ) {
246
- if ( isset ( $_POST['term_meta'][ $key ] ) ) {
247
- $term_meta[$key] = $_POST['term_meta'][ $key ];
248
  }
249
  }
250
  update_option( "taxonomy_$t_id", $term_meta );
251
  }
252
  if ( function_exists( 'add_term_meta' ) ) {
253
- update_term_meta( $term_id, 'sp_order', (int) sp_array_value( $_POST, 'sp_order', 0 ) );
254
  }
255
  }
256
 
@@ -263,13 +289,15 @@ class SP_Admin_Taxonomies {
263
  */
264
  public function taxonomy_columns( $columns ) {
265
  $new_columns = array();
266
-
267
- if ( function_exists( 'get_term_meta' ) ) $new_columns['sp_order'] = __( 'Order', 'sportspress' );
268
 
269
- if ( array_key_exists('posts', $columns) ) {
270
- $new_columns['posts'] = $columns['posts'];
 
271
 
272
- unset( $columns['posts'] );
 
 
 
273
  }
274
 
275
  return array_merge( $columns, $new_columns );
@@ -283,12 +311,12 @@ class SP_Admin_Taxonomies {
283
  * @return array
284
  */
285
  public function venue_columns( $columns ) {
286
- $new_columns = array();
287
- $new_columns['sp_address'] = __( 'Address', 'sportspress' );
288
-
289
- if ( array_key_exists('posts', $columns) ) {
290
- $new_columns['posts'] = $columns['posts'];
291
- unset( $columns['posts'] );
292
  }
293
 
294
  unset( $columns['description'] );
@@ -305,14 +333,16 @@ class SP_Admin_Taxonomies {
305
  * @return array
306
  */
307
  public function position_columns( $columns ) {
308
- $new_columns = array();
309
- $new_columns['sp_sections'] = __( 'Statistics', 'sportspress' );
 
 
 
 
310
 
311
- if ( function_exists( 'get_term_meta' ) ) $new_columns['sp_order'] = __( 'Order', 'sportspress' );
312
-
313
- if ( array_key_exists('posts', $columns) ) {
314
- $new_columns['posts'] = $columns['posts'];
315
- unset( $columns['posts'] );
316
  }
317
 
318
  unset( $columns['description'] );
@@ -341,13 +371,22 @@ class SP_Admin_Taxonomies {
341
  $columns .= $address;
342
 
343
  } elseif ( $column == 'sp_sections' ) {
344
-
345
- $options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
 
 
 
 
 
 
 
 
 
346
 
347
  $sections = sp_get_term_sections( $id );
348
-
349
  $section_names = array();
350
-
351
  if ( is_array( $sections ) ) {
352
  foreach ( $sections as $section ) {
353
  if ( array_key_exists( $section, $options ) ) {
@@ -355,7 +394,7 @@ class SP_Admin_Taxonomies {
355
  }
356
  }
357
  }
358
-
359
  $columns .= implode( ', ', $section_names );
360
 
361
  } elseif ( $column == 'sp_order' ) {
6
  /**
7
  * Handles taxonomies in admin
8
  *
9
+ * @class SP_Admin_Taxonomies
10
+ * @version 2.7.9
11
+ * @package SportsPress/Admin
12
+ * @category Class
13
+ * @author ThemeBoy
14
  */
15
  class SP_Admin_Taxonomies {
16
 
71
  * @param mixed $term Term (category) being edited
72
  */
73
  public function edit_taxonomy_fields( $term ) {
74
+ $t_id = $term->term_id;
75
  ?>
76
  <?php if ( function_exists( 'get_term_meta' ) ) { ?>
77
  <?php $order = get_term_meta( $t_id, 'sp_order', true ); ?>
78
  <tr class="form-field">
79
+ <th scope="row" valign="top"><label for="sp_order"><?php esc_html_e( 'Order', 'sportspress' ); ?></label></th>
80
  <td><input name="sp_order" class="sp-number-input" type="text" step="1" size="4" id="sp_order" value="<?php echo (int) $order; ?>"></td>
81
  </tr>
82
  <?php } ?>
83
+ <?php
84
  }
85
 
86
  /**
91
  */
92
  public function add_venue_fields() {
93
  $args = array(
94
+ 'orderby' => 'id',
95
+ 'order' => 'DESC',
96
  'hide_empty' => false,
97
+ 'number' => 1,
98
  );
99
 
100
  // Get latitude and longitude from the last added venue
101
  $terms = get_terms( 'sp_venue', $args );
102
+ if ( $terms && array_key_exists( 0, $terms ) && is_object( reset( $terms ) ) ) :
103
+ $term = reset( $terms );
104
+ $t_id = $term->term_id;
105
  $term_meta = get_option( "taxonomy_$t_id" );
106
+ $latitude = sp_array_value( $term_meta, 'sp_latitude', '-37.8165647' );
107
  $longitude = sp_array_value( $term_meta, 'sp_longitude', '144.9475055' );
108
+ $address = sp_array_value( $term_meta, 'sp_address', '' );
109
  endif;
110
  // Sanitize latitude and longitude, fallback to default.
111
+ if ( ! is_numeric( $latitude ) || ! is_numeric( $longitude ) ) :
112
+ $latitude = '-37.8165647';
113
  $longitude = '144.9475055';
114
  endif;
115
  ?>
116
  <div class="form-field">
117
  <div id="sp-location-picker" class="sp-location-picker" style="width: 95%; height: 320px"></div>
118
+ <p><?php esc_html_e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
119
  </div>
120
  <div class="form-field">
121
+ <label for="term_meta[sp_address]"><?php esc_html_e( 'Address', 'sportspress' ); ?></label>
122
  <input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="<?php echo esc_attr( $address ); ?>">
123
  </div>
124
  <div class="form-field">
125
+ <label for="term_meta[sp_latitude]"><?php esc_html_e( 'Latitude', 'sportspress' ); ?></label>
126
  <input type="text" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="<?php echo esc_attr( $latitude ); ?>">
127
  </div>
128
  <div class="form-field">
129
+ <label for="term_meta[sp_longitude]"><?php esc_html_e( 'Longitude', 'sportspress' ); ?></label>
130
  <input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo esc_attr( $longitude ); ?>">
131
  </div>
132
+ <?php
133
  do_action( 'sp_admin_geocoder_scripts' );
134
  }
135
 
140
  * @param mixed $term Term (category) being edited
141
  */
142
  public function edit_venue_fields( $term ) {
143
+ $t_id = $term->term_id;
144
+ $term_meta = get_option( "taxonomy_$t_id" );
145
+ $latitude = is_numeric( $term_meta['sp_latitude'] ) ? $term_meta['sp_latitude'] : '';
146
+ $longitude = is_numeric( $term_meta['sp_longitude'] ) ? $term_meta['sp_longitude'] : '';
147
+ $address = $term_meta['sp_address'] ? $term_meta['sp_address'] : '';
148
  ?>
149
  <tr class="form-field">
150
  <td colspan="2">
151
  <p><div id="sp-location-picker" class="sp-location-picker" style="width: 95%; height: 320px"></div></p>
152
+ <p class="description"><?php esc_html_e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
153
  </td>
154
  </tr>
155
  <tr class="form-field">
156
+ <th scope="row" valign="top"><label for="term_meta[sp_address]"><?php esc_html_e( 'Address', 'sportspress' ); ?></label></th>
157
  <td>
158
+ <input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="<?php echo esc_attr( $address ); ?>">
159
  </td>
160
  </tr>
161
  <tr class="form-field">
162
+ <th scope="row" valign="top"><label for="term_meta[sp_latitude]"><?php esc_html_e( 'Latitude', 'sportspress' ); ?></label></th>
163
  <td>
164
+ <input type="text" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="<?php echo esc_attr( $latitude ); ?>">
165
  </td>
166
  </tr>
167
  <tr class="form-field">
168
+ <th scope="row" valign="top"><label for="term_meta[sp_longitude]"><?php esc_html_e( 'Longitude', 'sportspress' ); ?></label></th>
169
  <td>
170
+ <input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo esc_attr( $longitude ); ?>">
171
  </td>
172
  </tr>
173
+ <?php
174
  do_action( 'sp_admin_geocoder_scripts' );
175
  }
176
 
183
  public function add_position_fields() {
184
  ?>
185
  <div class="form-field">
186
+ <label><?php esc_html_e( 'Statistics', 'sportspress' ); ?></label>
187
+ <select name="term_meta[sp_sections][]" id="term_meta[sp_sections][]" class="widefat chosen-select
188
+ <?php
189
+ if ( is_rtl() ) :
190
+ ?>
191
+ chosen-rtl<?php endif; ?>" multiple="multiple">
192
  <?php
193
+ $options = apply_filters(
194
+ 'sportspress_performance_sections',
195
+ array(
196
+ 0 => esc_attr__( 'Offense', 'sportspress' ),
197
+ 1 => esc_attr__(
198
+ 'Defense',
199
+ 'sportspress'
200
+ ),
201
+ )
202
+ );
203
+ foreach ( $options as $key => $value ) :
204
+ printf( '<option value="%s" %s>%s</option>', esc_attr( $key ), selected( true ), esc_html( $value ) );
205
  endforeach;
206
  ?>
207
  </select>
208
  </div>
209
+ <?php
210
  }
211
 
212
  /**
216
  * @param mixed $term Term (category) being edited
217
  */
218
  public function edit_position_fields( $term ) {
219
+ $t_id = $term->term_id;
220
  $sections = sp_get_term_sections( $t_id );
221
  ?>
222
  <tr class="form-field">
223
+ <th scope="row" valign="top"><label for="term_meta[sp_sections]"><?php esc_html_e( 'Statistics', 'sportspress' ); ?></label></th>
224
  <input type="hidden" name="term_meta[sp_sections]" value="">
225
  <td>
226
+ <select name="term_meta[sp_sections][]" id="term_meta[sp_sections][]" class="widefat chosen-select
227
+ <?php
228
+ if ( is_rtl() ) :
229
+ ?>
230
+ chosen-rtl<?php endif; ?>" multiple="multiple">
231
  <?php
232
+ $options = apply_filters(
233
+ 'sportspress_performance_sections',
234
+ array(
235
+ 0 => esc_attr__( 'Offense', 'sportspress' ),
236
+ 1 => esc_attr__(
237
+ 'Defense',
238
+ 'sportspress'
239
+ ),
240
+ )
241
+ );
242
+ foreach ( $options as $key => $value ) :
243
+ printf( '<option value="%s" %s>%s</option>', esc_attr( $key ), selected( in_array( $key, $sections ), true, false ), esc_html( $value ) );
244
  endforeach;
245
  ?>
246
  </select>
249
  <?php if ( function_exists( 'get_term_meta' ) ) { ?>
250
  <?php $order = get_term_meta( $t_id, 'sp_order', true ); ?>
251
  <tr class="form-field">
252
+ <th scope="row" valign="top"><label for="sp_order"><?php esc_html_e( 'Order', 'sportspress' ); ?></label></th>
253
  <td><input name="sp_order" class="sp-number-input" type="text" step="1" size="4" id="sp_order" value="<?php echo (int) $order; ?>"></td>
254
  </tr>
255
  <?php } ?>
256
+ <?php
257
  }
258
 
259
  /**
265
  */
266
  public function save_fields( $term_id ) {
267
  if ( isset( $_POST['term_meta'] ) ) {
268
+ $t_id = $term_id;
269
  $term_meta = get_option( "taxonomy_$t_id" );
270
+ $cat_keys = array_keys( wp_unslash( $_POST['term_meta'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
271
  foreach ( $cat_keys as $key ) {
272
+ if ( isset( $_POST['term_meta'][ $key ] ) ) {
273
+ $term_meta[ $key ] = sanitize_text_field( wp_unslash( $_POST['term_meta'][ $key ] ) );
274
  }
275
  }
276
  update_option( "taxonomy_$t_id", $term_meta );
277
  }
278
  if ( function_exists( 'add_term_meta' ) ) {
279
+ update_term_meta( $term_id, 'sp_order', (int) sp_array_value( $_POST, 'sp_order', 0, 'int' ) );
280
  }
281
  }
282
 
289
  */
290
  public function taxonomy_columns( $columns ) {
291
  $new_columns = array();
 
 
292
 
293
+ if ( function_exists( 'get_term_meta' ) ) {
294
+ $new_columns['sp_order'] = esc_attr__( 'Order', 'sportspress' );
295
+ }
296
 
297
+ if ( array_key_exists( 'posts', $columns ) ) {
298
+ $new_columns['posts'] = $columns['posts'];
299
+
300
+ unset( $columns['posts'] );
301
  }
302
 
303
  return array_merge( $columns, $new_columns );
311
  * @return array
312
  */
313
  public function venue_columns( $columns ) {
314
+ $new_columns = array();
315
+ $new_columns['sp_address'] = esc_attr__( 'Address', 'sportspress' );
316
+
317
+ if ( array_key_exists( 'posts', $columns ) ) {
318
+ $new_columns['posts'] = $columns['posts'];
319
+ unset( $columns['posts'] );
320
  }
321
 
322
  unset( $columns['description'] );
333
  * @return array
334
  */
335
  public function position_columns( $columns ) {
336
+ $new_columns = array();
337
+ $new_columns['sp_sections'] = esc_attr__( 'Statistics', 'sportspress' );
338
+
339
+ if ( function_exists( 'get_term_meta' ) ) {
340
+ $new_columns['sp_order'] = esc_attr__( 'Order', 'sportspress' );
341
+ }
342
 
343
+ if ( array_key_exists( 'posts', $columns ) ) {
344
+ $new_columns['posts'] = $columns['posts'];
345
+ unset( $columns['posts'] );
 
 
346
  }
347
 
348
  unset( $columns['description'] );
371
  $columns .= $address;
372
 
373
  } elseif ( $column == 'sp_sections' ) {
374
+
375
+ $options = apply_filters(
376
+ 'sportspress_performance_sections',
377
+ array(
378
+ 0 => esc_attr__( 'Offense', 'sportspress' ),
379
+ 1 => esc_attr__(
380
+ 'Defense',
381
+ 'sportspress'
382
+ ),
383
+ )
384
+ );
385
 
386
  $sections = sp_get_term_sections( $id );
387
+
388
  $section_names = array();
389
+
390
  if ( is_array( $sections ) ) {
391
  foreach ( $sections as $section ) {
392
  if ( array_key_exists( $section, $options ) ) {
394
  }
395
  }
396
  }
397
+
398
  $columns .= implode( ', ', $section_names );
399
 
400
  } elseif ( $column == 'sp_order' ) {
includes/admin/class-sp-admin-welcome.php CHANGED
@@ -9,405 +9,448 @@
9
  * @author ThemeBoy
10
  * @category Admin
11
  * @package SportsPress/Admin
12
- * @version 2.6.17
13
- */
14
 
15
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
16
 
17
  /**
18
  * SP_Admin_Welcome class.
19
  */
20
  class SP_Admin_Welcome {
21
 
22
- private $plugin;
23
-
24
- /**
25
- * __construct function.
26
- *
27
- * @access public
28
- * @return void
29
- */
30
- public function __construct() {
31
- $this->plugin = 'sportspress/sportspress.php';
32
-
33
- add_action( 'admin_menu', array( $this, 'admin_menus') );
34
- add_action( 'admin_head', array( $this, 'admin_head' ) );
35
- add_action( 'admin_init', array( $this, 'welcome' ) );
36
- }
37
-
38
- /**
39
- * Add admin menus/screens
40
- *
41
- * @access public
42
- * @return void
43
- */
44
- public function admin_menus() {
45
- if ( empty( $_GET['page'] ) ) {
46
- return;
47
- }
48
-
49
- $welcome_page_name = __( 'About SportsPress', 'sportspress' );
50
- $welcome_page_title = __( 'Welcome to SportsPress', 'sportspress' );
51
-
52
- switch ( $_GET['page'] ) {
53
- case 'sp-about' :
54
- $page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-about', array( $this, 'about_screen' ) );
55
- add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
56
- break;
57
- case 'sp-credits' :
58
- $page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-credits', array( $this, 'credits_screen' ) );
59
- add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
60
- break;
61
- case 'sp-translators' :
62
- $page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-translators', array( $this, 'translators_screen' ) );
63
- add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
64
- break;
65
- }
66
- }
67
-
68
- /**
69
- * admin_css function.
70
- *
71
- * @access public
72
- * @return void
73
- */
74
- public function admin_css() {
75
- wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ), array(), SP_VERSION );
76
- }
77
-
78
- /**
79
- * Add styles just for this page, and remove dashboard page links.
80
- *
81
- * @access public
82
- * @return void
83
- */
84
- public function admin_head() {
85
- remove_submenu_page( 'index.php', 'sp-about' );
86
- remove_submenu_page( 'index.php', 'sp-credits' );
87
- remove_submenu_page( 'index.php', 'sp-translators' );
88
- }
89
-
90
- /**
91
- * Into text/links shown on all about pages.
92
- *
93
- * @access private
94
- * @return void
95
- */
96
- private function intro() {
97
-
98
- // Flush after upgrades
99
- if ( ! empty( $_GET['sp-updated'] ) || ! empty( $_GET['sp-installed'] ) )
100
- flush_rewrite_rules();
101
-
102
- // Get major version number
103
- $version = explode( '.', SP()->version, 3 );
104
- unset( $version[2] );
105
- $display_version = implode( '.', $version );
106
- ?>
107
- <h1 class="sp-welcome-logo"><?php echo apply_filters( 'sportspress_logo', '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/welcome/sportspress' . ( class_exists( 'SportsPress_Pro' ) ? '-pro' : '' ) . '.png" alt="' . __( 'SportsPress', 'sportspress' ) . '">' ); ?></h1>
108
-
109
- <div class="sp-badge"><?php printf( __( 'Version %s', 'sportspress' ), SP()->version ); ?></div>
110
-
111
- <div class="about-text sp-about-text">
112
- <?php
113
- if ( ! empty( $_GET['sp-installed'] ) )
114
- $message = __( 'Thanks, all done!', 'sportspress' );
115
- elseif ( ! empty( $_GET['sp-updated'] ) )
116
- $message = __( 'Thank you for updating to the latest version!', 'sportspress' );
117
- else
118
- $message = __( 'Thanks for installing!', 'sportspress' );
119
-
120
- printf( __( '%s SportsPress %s has lots of refinements we think you&#8217;ll love.', 'sportspress' ), $message, $display_version );
121
- ?>
122
- </div>
123
-
124
- <p class="sportspress-actions">
125
- <a href="<?php echo admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ); ?>" class="button button-primary"><?php _e( 'Settings', 'sportspress' ); ?></a>
126
- <a href="<?php echo esc_url( apply_filters( 'sportspress_docs_url', 'http://tboy.co/docs', 'sportspress' ) ); ?>" class="docs button button-primary"><?php _e( 'Docs', 'sportspress' ); ?></a>
127
- <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://wordpress.org/plugins/sportspress" data-text="An open-source (free) #WordPress plugin that helps you build professional league websites" data-via="ThemeBoy" data-size="large" data-hashtags="SportsPress">Tweet</a>
128
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
129
- </p>
130
-
131
- <h2 class="nav-tab-wrapper">
132
- <a class="nav-tab <?php if ( $_GET['page'] == 'sp-about' ) echo 'nav-tab-active'; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-about' ), 'index.php' ) ) ); ?>">
133
- <?php _e( 'Welcome', 'sportspress' ); ?>
134
- </a><a class="nav-tab <?php if ( $_GET['page'] == 'sp-credits' ) echo 'nav-tab-active'; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-credits' ), 'index.php' ) ) ); ?>">
135
- <?php _e( 'Credits', 'sportspress' ); ?>
136
- </a>
137
- </h2>
138
- <?php
139
- }
140
-
141
- /**
142
- * Output the about screen.
143
- */
144
- public function about_screen() {
145
- include_once( 'class-sp-admin-settings.php' );
146
- $class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
147
- ?>
148
- <div class="wrap about-wrap about-sportspress-wrap">
149
-
150
- <?php $this->intro(); ?>
151
-
152
- <?php
153
- // Save settings
154
- if ( isset( $_POST['timezone_string'] ) ):
155
- update_option( 'timezone_string', $_POST['timezone_string'] );
156
- update_option( 'sportspress_basic_setup', 1 );
157
- endif;
158
- if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) ):
159
- $sport = $_POST['sportspress_sport'];
160
- SP_Admin_Sports::apply_preset( $sport );
161
- update_option( 'sportspress_sport', $_POST['sportspress_sport'] );
162
- delete_option( '_sp_needs_welcome' );
163
- update_option( 'sportspress_installed', 1 );
164
- ?>
165
- <div id="message" class="updated sportspress-message">
166
- <p><strong><?php _e( 'Your settings have been saved.', 'sportspress' ); ?></strong></p>
167
- </div>
168
- <?php
169
- endif;
170
- if ( isset( $_POST['add_sample_data'] ) ):
171
- SP_Admin_Sample_Data::delete_posts();
172
- SP_Admin_Sample_Data::insert_posts();
173
- endif;
174
-
175
- do_action( 'sportspress_before_welcome_features' );
176
- ?>
177
- <div class="feature-section one-col">
178
- <div class="col">
179
- <h2>New Features 🌟</h2>
180
- </div>
181
- </div>
182
-
183
- <div class="feature-section three-col">
184
- <div class="col">
185
- <img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-conditional-equations.png" alt="Screenshot">
186
- <h3>Conditional Equations</h3>
187
- <p>Use the newly introduced conditional operators <strong>&gt;</strong>, <strong>&lt;</strong>, <strong>&equiv;</strong>, <strong>&ne;</strong>, <strong>&ge;</strong>, and <strong>&le;</strong> to calculate the relationship between variables, then insert that calculation into more complex equations. Visit the <a href="<?php echo add_query_arg( array( 'page' => 'sportspress-config' ), admin_url( 'admin.php' ) ); ?>">Configure</a> page to edit variables and equations.</p>
188
- </div>
189
- <div class="col">
190
- <img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-event-specs.png" alt="Screenshot">
191
- <h3>Event Specs</h3>
192
- <p>Measure and display additional details per event using the new <strong>Event Specs</strong> variables. They are customizable and can be useful for keeping track of information like player of the match, attendance, and venue weather.
193
- </div>
194
- <div class="col">
195
- <img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-next-team.png" alt="Screenshot">
196
- <h3>Next Team Column</h3>
197
- <p>Provide a quick overview of who each team is playing next using the new <strong>Next Team</strong> preset for <a href="<?php echo add_query_arg( array( 'post_type' => 'sp_column' ), admin_url( 'edit.php' ) ); ?>">league table columns</a>. This will automatically display the next team's name or logo that links to the next match for each team in the table.<p>
198
- </div>
199
- </div>
200
-
201
- <?php if ( ! class_exists( 'SportsPress_Pro' ) ) { ?>
202
- <hr>
203
-
204
- <div class="feature-section one-col">
205
- <div class="col">
206
- <h2>SportsPress Pro Updates 🏆</h2>
207
- </div>
208
- </div>
209
-
210
- <div class="feature-section three-col">
211
- <div class="col">
212
- <img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-results-matrix.png" alt="Results Matrix">
213
- <h3>Results Matrix</h3>
214
- <p>Display matches between home and away team in a grid. Create or select an existing calendar and select the <strong>Matrix</strong> layout to convert the calendar to an interactive results matrix!</p>
215
- </div>
216
- <div class="col">
217
- <img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-midseason-transfers.png" alt="Midseason Transfers">
218
- <h3>Midseason Transfers</h3>
219
- <p>Keep track of players that switched teams during a season by adding one or more extra rows to their statistics table. Display the team and partial statistics before and after the transfer.<p>
220
- </div>
221
- <div class="col">
222
- <img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-vertical-timelines.png" alt="Vertical Timelines">
223
- <h3>Vertical Timelines</h3>
224
- <p>Display a match commentary style play-by-play timeline within events. <a href="<?php echo esc_url( apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ) ); ?>">Upgrade to SportsPress Pro</a> to get access to <strong>Timelines</strong> and other pro features.<p>
225
- </div>
226
- </div>
227
-
228
- <a class="button button-primary button-hero" href="<?php echo esc_url( apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ) ); ?>"><?php _e( 'Upgrade to Pro', 'sportspress' ); ?></a>
229
-
230
- <p><?php _e( 'Get SportsPress Pro to get access to all modules. You can upgrade any time without losing any of your data.','sportspress' ); ?></p>
231
- <?php } ?>
232
-
233
- <hr>
234
-
235
- <div class="feature-section one-col">
236
- <div class="col">
237
- <h2>Player Data Improvements</h2>
238
- </div>
239
- </div>
240
-
241
- <div class="feature-section three-col">
242
- <div class="col">
243
- <h3>Player Assignments</h3>
244
- <p>Players will now be saved using a new data format that allows them to belong to multiple leagues, seasons, and teams and be accurately selected in <a href="<?php echo add_query_arg( array( 'post_type' => 'sp_list' ), admin_url( 'edit.php' ) ); ?>">player lists</a>.</p>
245
- </div>
246
- <div class="col">
247
- <h3>Current Team Column</h3>
248
- <p>The <strong>Team</strong> column in player lists will now display only the current team that player belongs to, determined by the <strong>Current Team</strong> setting of each player.</p>
249
- </div>
250
- <div class="col">
251
- <h3>Squad Number Zero</h3>
252
- <p>It's now possible to import players with the squad number <strong>0 (zero)</strong> or any other value that would previously be interpreted as empty.</p>
253
- </div>
254
- </div>
255
-
256
- <hr>
257
-
258
- <div class="feature-section one-col">
259
- <div class="col">
260
- <h2>Other Notes</h2>
261
- </div>
262
- </div>
263
-
264
- <div class="feature-section three-col">
265
- <div class="col">
266
- <h3>Countdown Images</h3>
267
- <p>A new option has been added to the <strong>Countdown</strong> widget, allowing you to display a featured image from the next event.</p>
268
- </div>
269
- <div class="col">
270
- <h3>Relative Date in Shortcodes</h3>
271
- <p>You'll now be able to select a relative date range when inserting calendar-related shortcodes from the visual editor.</p>
272
- </div>
273
- <div class="col">
274
- <h3>Short Names</h3>
275
- <p>Teams have been given a <strong>Short Name</strong> setting in addition to the existing <strong>Abbreviation</strong> for added customizability.</p>
276
- </div>
277
- </div>
278
-
279
- <?php do_action( 'sportspress_after_welcome_features' ); ?>
280
-
281
- <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><?php _e( 'Go to SportsPress Settings', 'sportspress' ); ?></a>
282
- </div>
283
- <?php
284
- }
285
-
286
- /**
287
- * Output the credits.
288
- */
289
- public function credits_screen() {
290
- ?>
291
- <div class="wrap about-wrap about-sportspress-wrap">
292
- <?php $this->intro(); ?>
293
-
294
- <p class="about-description"><?php printf( __( 'SportsPress is developed and maintained by a worldwide team of passionate individuals and backed by an awesome developer community. Want to see your name? <a href="%s">Contribute to SportsPress</a>.', 'sportspress' ), 'https://github.com/ThemeBoy/SportsPress/blob/master/CONTRIBUTING.md' ); ?></p>
295
-
296
- <div class="sp-feature feature-section col one-col">
297
- <?php echo $this->contributors(); ?>
298
- </div>
299
- </div>
300
- <?php
301
- }
302
-
303
- /**
304
- * Output the translators screen
305
- */
306
- public function translators_screen() {
307
- ?>
308
- <div class="wrap about-wrap about-sportspress-wrap">
309
-
310
- <?php $this->intro(); ?>
311
-
312
- <p class="about-description"><?php printf( __( 'SportsPress has been kindly translated into several other languages thanks to our translation team. Want to see your name? <a href="%s">Translate SportsPress</a>.', 'sportspress' ), 'https://translate.wordpress.org/projects/wp-plugins/sportspress' ); ?></p>
313
- </div>
314
- <?php
315
- }
316
-
317
- /**
318
- * Render Contributors List
319
- *
320
- * @access public
321
- * @return string $contributor_list HTML formatted list of contributors.
322
- */
323
- public function contributors() {
324
- $contributors = $this->get_contributors();
325
-
326
- if ( empty( $contributors ) ) {
327
- return '';
328
- }
329
-
330
- $contributor_list = '<ul class="wp-people-group">';
331
-
332
- foreach ( $contributors as $contributor ) {
333
- $contributor_list .= '<li class="wp-person">';
334
- $contributor_list .= sprintf( '<a href="%s" title="%s">',
335
- esc_url( 'https://github.com/' . $contributor->login ),
336
- esc_html( sprintf( __( 'View %s', 'sportspress' ), $contributor->login ) )
337
- );
338
- $contributor_list .= sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) );
339
- $contributor_list .= '</a>';
340
- $contributor_list .= sprintf( '<a class="web" href="%s">%s</a>', esc_url( 'https://github.com/' . $contributor->login ), esc_html( $contributor->login ) );
341
- $contributor_list .= '</a>';
342
- $contributor_list .= '</li>';
343
- }
344
-
345
- $contributor_list .= '</ul>';
346
-
347
- return $contributor_list;
348
- }
349
-
350
- /**
351
- * Retrieve list of contributors from GitHub.
352
- *
353
- * @access public
354
- * @return mixed
355
- */
356
- public function get_contributors() {
357
- $contributors = get_transient( 'sportspress_contributors' );
358
-
359
- if ( false !== $contributors ) {
360
- return $contributors;
361
- }
362
-
363
- $response = wp_remote_get( 'https://api.github.com/repos/ThemeBoy/SportsPress/contributors', array( 'sslverify' => false ) );
364
-
365
- if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
366
- return array();
367
- }
368
-
369
- $contributors = json_decode( wp_remote_retrieve_body( $response ) );
370
-
371
- if ( ! is_array( $contributors ) ) {
372
- return array();
373
- }
374
-
375
- set_transient( 'sportspress_contributors', $contributors, HOUR_IN_SECONDS );
376
-
377
- return $contributors;
378
- }
379
-
380
- /**
381
- * Sends user to the welcome page on first activation
382
- */
383
- public function welcome() {
384
-
385
- // Bail if no activation redirect transient is set
386
- if ( ! get_transient( '_sp_activation_redirect' ) )
387
- return;
388
-
389
- // Delete the redirect transient
390
- delete_transient( '_sp_activation_redirect' );
391
-
392
- // Bail if we are waiting to install or update via the interface update/install links
393
- if ( get_option( '_sp_needs_update' ) == 1 || get_option( '_sp_needs_pages' ) == 1 )
394
- return;
395
-
396
- // Bail if activating from network, or bulk, or within an iFrame
397
- if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) )
398
- return;
399
-
400
- if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] ) && ( isset( $_GET['plugin'] ) && strstr( $_GET['plugin'], 'sportspress.php' ) ) )
401
- return;
402
-
403
- if ( ! get_option( 'sportspress_completed_setup' ) ) {
404
- wp_redirect( admin_url( 'admin.php?page=sp-setup' ) );
405
- exit;
406
- }
407
-
408
- wp_redirect( admin_url( 'index.php?page=sp-about' ) );
409
- exit;
410
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  }
412
 
413
  new SP_Admin_Welcome();
9
  * @author ThemeBoy
10
  * @category Admin
11
  * @package SportsPress/Admin
12
+ * @version 2.7.9
13
+ */
14
 
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit; // Exit if accessed directly
17
+ }
18
 
19
  /**
20
  * SP_Admin_Welcome class.
21
  */
22
  class SP_Admin_Welcome {
23
 
24
+ private $plugin;
25
+
26
+ /**
27
+ * __construct function.
28
+ *
29
+ * @access public
30
+ * @return void
31
+ */
32
+ public function __construct() {
33
+ $this->plugin = 'sportspress/sportspress.php';
34
+
35
+ add_action( 'admin_menu', array( $this, 'admin_menus' ) );
36
+ add_action( 'admin_head', array( $this, 'admin_head' ) );
37
+ add_action( 'admin_init', array( $this, 'welcome' ) );
38
+ }
39
+
40
+ /**
41
+ * Add admin menus/screens
42
+ *
43
+ * @access public
44
+ * @return void
45
+ */
46
+ public function admin_menus() {
47
+ if ( empty( $_GET['page'] ) ) {
48
+ return;
49
+ }
50
+
51
+ $welcome_page_name = esc_attr__( 'About SportsPress', 'sportspress' );
52
+ $welcome_page_title = esc_attr__( 'Welcome to SportsPress', 'sportspress' );
53
+
54
+ switch ( $_GET['page'] ) {
55
+ case 'sp-about':
56
+ $page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-about', array( $this, 'about_screen' ) );
57
+ add_action( 'admin_print_styles-' . $page, array( $this, 'admin_css' ) );
58
+ break;
59
+ case 'sp-credits':
60
+ $page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-credits', array( $this, 'credits_screen' ) );
61
+ add_action( 'admin_print_styles-' . $page, array( $this, 'admin_css' ) );
62
+ break;
63
+ case 'sp-translators':
64
+ $page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-translators', array( $this, 'translators_screen' ) );
65
+ add_action( 'admin_print_styles-' . $page, array( $this, 'admin_css' ) );
66
+ break;
67
+ }
68
+ }
69
+
70
+ /**
71
+ * admin_css function.
72
+ *
73
+ * @access public
74
+ * @return void
75
+ */
76
+ public function admin_css() {
77
+ wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ), array(), SP_VERSION );
78
+ }
79
+
80
+ /**
81
+ * Add styles just for this page, and remove dashboard page links.
82
+ *
83
+ * @access public
84
+ * @return void
85
+ */
86
+ public function admin_head() {
87
+ remove_submenu_page( 'index.php', 'sp-about' );
88
+ remove_submenu_page( 'index.php', 'sp-credits' );
89
+ remove_submenu_page( 'index.php', 'sp-translators' );
90
+ }
91
+
92
+ /**
93
+ * Into text/links shown on all about pages.
94
+ *
95
+ * @access private
96
+ * @return void
97
+ */
98
+ private function intro() {
99
+
100
+ // Flush after upgrades
101
+ if ( ! empty( $_GET['sp-updated'] ) || ! empty( $_GET['sp-installed'] ) ) {
102
+ flush_rewrite_rules();
103
+ }
104
+
105
+ // Get major version number
106
+ $version = explode( '.', SP()->version, 3 );
107
+ unset( $version[2] );
108
+ $display_version = implode( '.', $version );
109
+ ?>
110
+ <h1 class="sp-welcome-logo"><?php echo wp_kses_post( apply_filters( 'sportspress_logo', '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/welcome/sportspress' . ( class_exists( 'SportsPress_Pro' ) ? '-pro' : '' ) . '.png" alt="' . esc_attr__( 'SportsPress', 'sportspress' ) . '">' ) ); ?></h1>
111
+
112
+ <div class="sp-badge"><?php printf( esc_html__( 'Version %s', 'sportspress' ), esc_html( SP()->version ) ); ?></div>
113
+
114
+ <div class="about-text sp-about-text">
115
+ <?php
116
+ if ( ! empty( $_GET['sp-installed'] ) ) {
117
+ $message = esc_attr__( 'Thanks, all done!', 'sportspress' );
118
+ } elseif ( ! empty( $_GET['sp-updated'] ) ) {
119
+ $message = esc_attr__( 'Thank you for updating to the latest version!', 'sportspress' );
120
+ } else {
121
+ $message = esc_attr__( 'Thanks for installing!', 'sportspress' );
122
+ }
123
+
124
+ printf( esc_html__( '%1$s SportsPress %2$s has lots of refinements we think you&#8217;ll love.', 'sportspress' ), esc_html( $message ), esc_html( $display_version ) );
125
+ ?>
126
+ </div>
127
+
128
+ <a href="
129
+ <?php
130
+ echo esc_url( admin_url(
131
+ add_query_arg(
132
+ array(
133
+ 'page' => 'sportspress',
134
+ 'tab' => 'general',
135
+ ),
136
+ 'admin.php'
137
+ )
138
+ ) );
139
+ ?>
140
+ " class="button button-primary"><?php esc_html_e( 'Settings', 'sportspress' ); ?></a>
141
+ <a href="<?php echo esc_url( apply_filters( 'sportspress_docs_url', 'http://tboy.co/docs', 'sportspress' ) ); ?>" class="docs button button-primary"><?php esc_html_e( 'Docs', 'sportspress' ); ?></a>
142
+ <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://wordpress.org/plugins/sportspress" data-text="An open-source (free) #WordPress plugin that helps you build professional league websites" data-via="ThemeBoy" data-size="large" data-hashtags="SportsPress">Tweet</a>
143
+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
144
+ </p>
145
+
146
+ <h2 class="nav-tab-wrapper">
147
+ <a class="nav-tab
148
+ <?php
149
+ if ( sanitize_key( $_GET['page'] ) == 'sp-about' ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
150
+ echo 'nav-tab-active';}
151
+ ?>
152
+ " href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-about' ), 'index.php' ) ) ); ?>">
153
+ <?php esc_html_e( 'Welcome', 'sportspress' ); ?>
154
+ </a><a class="nav-tab
155
+ <?php
156
+ if ( sanitize_key( $_GET['page'] ) == 'sp-credits' ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
157
+ echo 'nav-tab-active';}
158
+ ?>
159
+ " href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-credits' ), 'index.php' ) ) ); ?>">
160
+ <?php esc_html_e( 'Credits', 'sportspress' ); ?>
161
+ </a>
162
+ </h2>
163
+ <?php
164
+ }
165
+
166
+ /**
167
+ * Output the about screen.
168
+ */
169
+ public function about_screen() {
170
+ include_once 'class-sp-admin-settings.php';
171
+ $class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
172
+ ?>
173
+ <div class="wrap about-wrap about-sportspress-wrap">
174
+
175
+ <?php $this->intro(); ?>
176
+
177
+ <?php
178
+ // Save settings
179
+ if ( isset( $_POST['timezone_string'] ) ) :
180
+ update_option( 'timezone_string', sanitize_text_field( wp_unslash( $_POST['timezone_string'] ) ) );
181
+ update_option( 'sportspress_basic_setup', 1 );
182
+ endif;
183
+ if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) ) :
184
+ $sport = sanitize_text_field( wp_unslash( $_POST['sportspress_sport'] ) );
185
+ SP_Admin_Sports::apply_preset( $sport );
186
+ update_option( 'sportspress_sport', $sport );
187
+ delete_option( '_sp_needs_welcome' );
188
+ update_option( 'sportspress_installed', 1 );
189
+ ?>
190
+ <div id="message" class="updated sportspress-message">
191
+ <p><strong><?php esc_html_e( 'Your settings have been saved.', 'sportspress' ); ?></strong></p>
192
+ </div>
193
+ <?php
194
+ endif;
195
+ if ( isset( $_POST['add_sample_data'] ) ) :
196
+ SP_Admin_Sample_Data::delete_posts();
197
+ SP_Admin_Sample_Data::insert_posts();
198
+ endif;
199
+
200
+ do_action( 'sportspress_before_welcome_features' );
201
+ ?>
202
+ <div class="feature-section one-col">
203
+ <div class="col">
204
+ <h2>New Features 🌟</h2>
205
+ </div>
206
+ </div>
207
+
208
+ <div class="feature-section three-col">
209
+ <div class="col">
210
+ <img src="<?php echo esc_url( plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/welcome/screenshot-conditional-equations.png' );?>" alt="Screenshot">
211
+ <h3>Conditional Equations</h3>
212
+ <p>Use the newly introduced conditional operators <strong>&gt;</strong>, <strong>&lt;</strong>, <strong>&equiv;</strong>, <strong>&ne;</strong>, <strong>&ge;</strong>, and <strong>&le;</strong> to calculate the relationship between variables, then insert that calculation into more complex equations. Visit the <a href="<?php echo esc_url( add_query_arg( array( 'page' => 'sportspress-config' ), admin_url( 'admin.php' ) ) ); ?>">Configure</a> page to edit variables and equations.</p>
213
+ </div>
214
+ <div class="col">
215
+ <img src="<?php echo esc_url( plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/welcome/screenshot-event-specs.png' );?>" alt="Screenshot">
216
+ <h3>Event Specs</h3>
217
+ <p>Measure and display additional details per event using the new <strong>Event Specs</strong> variables. They are customizable and can be useful for keeping track of information like player of the match, attendance, and venue weather.
218
+ </div>
219
+ <div class="col">
220
+ <img src="<?php echo esc_url( plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/welcome/screenshot-next-team.png' );?>" alt="Screenshot">
221
+ <h3>Next Team Column</h3>
222
+ <p>Provide a quick overview of who each team is playing next using the new <strong>Next Team</strong> preset for <a href="<?php echo esc_url( add_query_arg( array( 'post_type' => 'sp_column' ), admin_url( 'edit.php' ) ) ); ?>">league table columns</a>. This will automatically display the next team's name or logo that links to the next match for each team in the table.<p>
223
+ </div>
224
+ </div>
225
+
226
+ <?php if ( ! class_exists( 'SportsPress_Pro' ) ) { ?>
227
+ <hr>
228
+
229
+ <div class="feature-section one-col">
230
+ <div class="col">
231
+ <h2>SportsPress Pro Updates 🏆</h2>
232
+ </div>
233
+ </div>
234
+
235
+ <div class="feature-section three-col">
236
+ <div class="col">
237
+ <img src="<?php echo esc_url( plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/welcome/screenshot-results-matrix.png' );?>" alt="Results Matrix">
238
+ <h3>Results Matrix</h3>
239
+ <p>Display matches between home and away team in a grid. Create or select an existing calendar and select the <strong>Matrix</strong> layout to convert the calendar to an interactive results matrix!</p>
240
+ </div>
241
+ <div class="col">
242
+ <img src="<?php echo esc_url( plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/welcome/screenshot-midseason-transfers.png' );?>" alt="Midseason Transfers">
243
+ <h3>Midseason Transfers</h3>
244
+ <p>Keep track of players that switched teams during a season by adding one or more extra rows to their statistics table. Display the team and partial statistics before and after the transfer.<p>
245
+ </div>
246
+ <div class="col">
247
+ <img src="<?php echo esc_url( plugin_dir_url( SP_PLUGIN_FILE ) . 'assets/images/welcome/screenshot-vertical-timelines.png' );?>" alt="Vertical Timelines">
248
+ <h3>Vertical Timelines</h3>
249
+ <p>Display a match commentary style play-by-play timeline within events. <a href="<?php echo esc_url( apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ) ); ?>">Upgrade to SportsPress Pro</a> to get access to <strong>Timelines</strong> and other pro features.<p>
250
+ </div>
251
+ </div>
252
+
253
+ <a class="button button-primary button-hero" href="<?php echo esc_url( apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ) ); ?>"><?php esc_html_e( 'Upgrade to Pro', 'sportspress' ); ?></a>
254
+
255
+ <p><?php esc_html_e( 'Get SportsPress Pro to get access to all modules. You can upgrade any time without losing any of your data.', 'sportspress' ); ?></p>
256
+ <?php } ?>
257
+
258
+ <hr>
259
+
260
+ <div class="feature-section one-col">
261
+ <div class="col">
262
+ <h2>Player Data Improvements</h2>
263
+ </div>
264
+ </div>
265
+
266
+ <div class="feature-section three-col">
267
+ <div class="col">
268
+ <h3>Player Assignments</h3>
269
+ <p>Players will now be saved using a new data format that allows them to belong to multiple leagues, seasons, and teams and be accurately selected in <a href="<?php echo esc_url( add_query_arg( array( 'post_type' => 'sp_list' ), admin_url( 'edit.php' ) ) ); ?>">player lists</a>.</p>
270
+ </div>
271
+ <div class="col">
272
+ <h3>Current Team Column</h3>
273
+ <p>The <strong>Team</strong> column in player lists will now display only the current team that player belongs to, determined by the <strong>Current Team</strong> setting of each player.</p>
274
+ </div>
275
+ <div class="col">
276
+ <h3>Squad Number Zero</h3>
277
+ <p>It's now possible to import players with the squad number <strong>0 (zero)</strong> or any other value that would previously be interpreted as empty.</p>
278
+ </div>
279
+ </div>
280
+
281
+ <hr>
282
+
283
+ <div class="feature-section one-col">
284
+ <div class="col">
285
+ <h2>Other Notes</h2>
286
+ </div>
287
+ </div>
288
+
289
+ <div class="feature-section three-col">
290
+ <div class="col">
291
+ <h3>Countdown Images</h3>
292
+ <p>A new option has been added to the <strong>Countdown</strong> widget, allowing you to display a featured image from the next event.</p>
293
+ </div>
294
+ <div class="col">
295
+ <h3>Relative Date in Shortcodes</h3>
296
+ <p>You'll now be able to select a relative date range when inserting calendar-related shortcodes from the visual editor.</p>
297
+ </div>
298
+ <div class="col">
299
+ <h3>Short Names</h3>
300
+ <p>Teams have been given a <strong>Short Name</strong> setting in addition to the existing <strong>Abbreviation</strong> for added customizability.</p>
301
+ </div>
302
+ </div>
303
+
304
+ <?php do_action( 'sportspress_after_welcome_features' ); ?>
305
+ <a href="
306
+ <?php
307
+ echo esc_url(
308
+ admin_url(
309
+ add_query_arg(
310
+ array(
311
+ 'page' => 'sportspress',
312
+ 'tab' => 'general',
313
+ ),
314
+ 'admin.php'
315
+ )
316
+ )
317
+ );
318
+ ?>
319
+ "><?php esc_html_e( 'Go to SportsPress Settings', 'sportspress' ); ?></a>
320
+ </div>
321
+ <?php
322
+ }
323
+
324
+ /**
325
+ * Output the credits.
326
+ */
327
+ public function credits_screen() {
328
+ ?>
329
+ <div class="wrap about-wrap about-sportspress-wrap">
330
+ <?php $this->intro(); ?>
331
+
332
+ <p class="about-description"><?php printf( wp_kses_post( esc_attr__( 'SportsPress is developed and maintained by a worldwide team of passionate individuals and backed by an awesome developer community. Want to see your name? <a href="%s">Contribute to SportsPress</a>.', 'sportspress' ) ), 'https://github.com/ThemeBoy/SportsPress/blob/master/CONTRIBUTING.md' ); ?></p>
333
+
334
+ <div class="sp-feature feature-section col one-col">
335
+ <?php echo wp_kses_post( $this->contributors() ); ?>
336
+ </div>
337
+ </div>
338
+ <?php
339
+ }
340
+
341
+ /**
342
+ * Output the translators screen
343
+ */
344
+ public function translators_screen() {
345
+ ?>
346
+ <div class="wrap about-wrap about-sportspress-wrap">
347
+
348
+ <?php $this->intro(); ?>
349
+
350
+ <p class="about-description"><?php printf( wp_kses_post( esc_attr__( 'SportsPress has been kindly translated into several other languages thanks to our translation team. Want to see your name? <a href="%s">Translate SportsPress</a>.', 'sportspress' ) ), 'https://translate.wordpress.org/projects/wp-plugins/sportspress' ); ?></p>
351
+ </div>
352
+ <?php
353
+ }
354
+
355
+ /**
356
+ * Render Contributors List
357
+ *
358
+ * @access public
359
+ * @return string $contributor_list HTML formatted list of contributors.
360
+ */
361
+ public function contributors() {
362
+ $contributors = $this->get_contributors();
363
+
364
+ if ( empty( $contributors ) ) {
365
+ return '';
366
+ }
367
+
368
+ $contributor_list = '<ul class="wp-people-group">';
369
+
370
+ foreach ( $contributors as $contributor ) {
371
+ $contributor_list .= '<li class="wp-person">';
372
+ $contributor_list .= sprintf(
373
+ '<a href="%s" title="%s">',
374
+ esc_url( 'https://github.com/' . $contributor->login ),
375
+ esc_html( sprintf( esc_attr__( 'View %s', 'sportspress' ), $contributor->login ) )
376
+ );
377
+ $contributor_list .= sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) );
378
+ $contributor_list .= '</a>';
379
+ $contributor_list .= sprintf( '<a class="web" href="%s">%s</a>', esc_url( 'https://github.com/' . $contributor->login ), esc_html( $contributor->login ) );
380
+ $contributor_list .= '</a>';
381
+ $contributor_list .= '</li>';
382
+ }
383
+
384
+ $contributor_list .= '</ul>';
385
+
386
+ return $contributor_list;
387
+ }
388
+
389
+ /**
390
+ * Retrieve list of contributors from GitHub.
391
+ *
392
+ * @access public
393
+ * @return mixed
394
+ */
395
+ public function get_contributors() {
396
+ $contributors = get_transient( 'sportspress_contributors' );
397
+
398
+ if ( false !== $contributors ) {
399
+ return $contributors;
400
+ }
401
+
402
+ $response = wp_remote_get( 'https://api.github.com/repos/ThemeBoy/SportsPress/contributors', array( 'sslverify' => false ) );
403
+
404
+ if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
405
+ return array();
406
+ }
407
+
408
+ $contributors = json_decode( wp_remote_retrieve_body( $response ) );
409
+
410
+ if ( ! is_array( $contributors ) ) {
411
+ return array();
412
+ }
413
+
414
+ set_transient( 'sportspress_contributors', $contributors, HOUR_IN_SECONDS );
415
+
416
+ return $contributors;
417
+ }
418
+
419
+ /**
420
+ * Sends user to the welcome page on first activation
421
+ */
422
+ public function welcome() {
423
+
424
+ // Bail if no activation redirect transient is set
425
+ if ( ! get_transient( '_sp_activation_redirect' ) ) {
426
+ return;
427
+ }
428
+
429
+ // Delete the redirect transient
430
+ delete_transient( '_sp_activation_redirect' );
431
+
432
+ // Bail if we are waiting to install or update via the interface update/install links
433
+ if ( get_option( '_sp_needs_update' ) == 1 || get_option( '_sp_needs_pages' ) == 1 ) {
434
+ return;
435
+ }
436
+
437
+ // Bail if activating from network, or bulk, or within an iFrame
438
+ if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) ) {
439
+ return;
440
+ }
441
+
442
+ if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == sanitize_key( $_GET['action'] ) ) && ( isset( $_GET['plugin'] ) && strstr( $_GET['plugin'], 'sportspress.php' ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
443
+ return;
444
+ }
445
+
446
+ if ( ! get_option( 'sportspress_completed_setup' ) ) {
447
+ wp_redirect( admin_url( 'admin.php?page=sp-setup' ) );
448
+ exit;
449
+ }
450
+
451
+ wp_redirect( admin_url( 'index.php?page=sp-about' ) );
452
+ exit;
453
+ }
454
  }
455
 
456
  new SP_Admin_Welcome();
includes/admin/class-sp-admin.php CHANGED
@@ -6,11 +6,11 @@ if ( ! defined( 'ABSPATH' ) ) {
6
  /**
7
  * SportsPress Admin.
8
  *
9
- * @class SP_Admin
10
- * @author ThemeBoy
11
- * @category Admin
12
- * @package SportsPress/Admin
13
- * @version 2.5.1
14
  */
15
  class SP_Admin {
16
 
@@ -36,32 +36,32 @@ class SP_Admin {
36
  */
37
  public function includes() {
38
  // Functions
39
- include_once( 'sp-admin-functions.php' );
40
 
41
  // Classes
42
- include_once( 'class-sp-admin-post-types.php' );
43
- include_once( 'class-sp-admin-taxonomies.php' );
44
- include_once( 'class-sp-admin-ajax.php' );
45
 
46
  // Classes we only need if the ajax is not-ajax
47
  if ( ! is_ajax() ) {
48
- include( 'class-sp-admin-menus.php' );
49
- include( 'class-sp-admin-welcome.php' );
50
- include( 'class-sp-admin-notices.php' );
51
- include( 'class-sp-admin-assets.php' );
52
- include( 'class-sp-admin-permalink-settings.php' );
53
-
54
- if ( 'yes' == get_option( 'sportspress_rich_editing', 'yes' ) ):
55
- include( 'class-sp-admin-editor.php' );
56
  endif;
57
  }
58
 
59
  // Setup/welcome
60
  if ( ! empty( $_GET['page'] ) ) {
61
  switch ( $_GET['page'] ) {
62
- case 'sp-setup' :
63
- include_once( 'class-sp-admin-setup-wizard.php' );
64
- break;
65
  }
66
  }
67
  }
@@ -73,8 +73,8 @@ class SP_Admin {
73
  $screen = get_current_screen();
74
 
75
  switch ( $screen->id ) {
76
- case 'dashboard' :
77
- include( 'class-sp-admin-dashboard.php' );
78
  break;
79
  }
80
  }
@@ -85,7 +85,7 @@ class SP_Admin {
85
  public function prevent_admin_access() {
86
  $prevent_access = false;
87
 
88
- if ( 'yes' == get_option( 'sportspress_lock_down_admin' ) && ! is_ajax() && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_sportspress' ) ) && basename( $_SERVER["SCRIPT_FILENAME"] ) !== 'admin-post.php' ) {
89
  $prevent_access = true;
90
  }
91
 
@@ -109,9 +109,9 @@ class SP_Admin {
109
  <script type="text/javascript">
110
  (function($) {
111
  $(".wrap .page-title-action").first().after(
112
- $("<a class=\"add-new-h2\" href=\"<?php echo esc_url( admin_url( add_query_arg( array( 'import' => 'sp_fixture_csv' ), 'admin.php' ) ) ); ?>\"><?php _e( 'Import Fixtures', 'sportspress' ); ?></a>")
113
  ).after(
114
- $("<a class=\"add-new-h2\" href=\"<?php echo esc_url( admin_url( add_query_arg( array( 'import' => 'sp_event_csv' ), 'admin.php' ) ) ); ?>\"><?php _e( 'Import Events', 'sportspress' ); ?></a>")
115
  );
116
  })(jQuery);
117
  </script>
@@ -123,7 +123,7 @@ class SP_Admin {
123
  <script type="text/javascript">
124
  (function($) {
125
  $(".wrap .page-title-action").first().after(
126
- $("<a class=\"add-new-h2\" href=\"<?php echo esc_url( admin_url( add_query_arg( array( 'import' => $typenow . '_csv' ), 'admin.php' ) ) ); ?>\"><?php _e( 'Import', 'sportspress' ); ?></a>")
127
  );
128
  })(jQuery);
129
  </script>
@@ -134,4 +134,4 @@ class SP_Admin {
134
  }
135
  }
136
 
137
- return new SP_Admin();
6
  /**
7
  * SportsPress Admin.
8
  *
9
+ * @class SP_Admin
10
+ * @author ThemeBoy
11
+ * @category Admin
12
+ * @package SportsPress/Admin
13
+ * @version 2.5.1
14
  */
15
  class SP_Admin {
16
 
36
  */
37
  public function includes() {
38
  // Functions
39
+ include_once 'sp-admin-functions.php';
40
 
41
  // Classes
42
+ include_once 'class-sp-admin-post-types.php';
43
+ include_once 'class-sp-admin-taxonomies.php';
44
+ include_once 'class-sp-admin-ajax.php';
45
 
46
  // Classes we only need if the ajax is not-ajax
47
  if ( ! is_ajax() ) {
48
+ include 'class-sp-admin-menus.php';
49
+ include 'class-sp-admin-welcome.php';
50
+ include 'class-sp-admin-notices.php';
51
+ include 'class-sp-admin-assets.php';
52
+ include 'class-sp-admin-permalink-settings.php';
53
+
54
+ if ( 'yes' == get_option( 'sportspress_rich_editing', 'yes' ) ) :
55
+ include 'class-sp-admin-editor.php';
56
  endif;
57
  }
58
 
59
  // Setup/welcome
60
  if ( ! empty( $_GET['page'] ) ) {
61
  switch ( $_GET['page'] ) {
62
+ case 'sp-setup':
63
+ include_once 'class-sp-admin-setup-wizard.php';
64
+ break;
65
  }
66
  }
67
  }
73
  $screen = get_current_screen();
74
 
75
  switch ( $screen->id ) {
76
+ case 'dashboard':
77
+ include 'class-sp-admin-dashboard.php';
78
  break;
79
  }
80
  }
85
  public function prevent_admin_access() {
86
  $prevent_access = false;
87
 
88
+ if ( 'yes' == get_option( 'sportspress_lock_down_admin' ) && ! is_ajax() && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_sportspress' ) ) && basename( $_SERVER['SCRIPT_FILENAME'] ) !== 'admin-post.php' ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
89
  $prevent_access = true;
90
  }
91
 
109
  <script type="text/javascript">
110
  (function($) {
111
  $(".wrap .page-title-action").first().after(
112
+ $("<a class=\"add-new-h2\" href=\"<?php echo esc_url( admin_url( add_query_arg( array( 'import' => 'sp_fixture_csv' ), 'admin.php' ) ) ); ?>\"><?php esc_html_e( 'Import Fixtures', 'sportspress' ); ?></a>")
113
  ).after(
114
+ $("<a class=\"add-new-h2\" href=\"<?php echo esc_url( admin_url( add_query_arg( array( 'import' => 'sp_event_csv' ), 'admin.php' ) ) ); ?>\"><?php esc_html_e( 'Import Events', 'sportspress' ); ?></a>")
115
  );
116
  })(jQuery);
117
  </script>
123
  <script type="text/javascript">
124
  (function($) {
125
  $(".wrap .page-title-action").first().after(
126
+ $("<a class=\"add-new-h2\" href=\"<?php echo esc_url( admin_url( add_query_arg( array( 'import' => $typenow . '_csv' ), 'admin.php' ) ) ); ?>\"><?php esc_html_e( 'Import', 'sportspress' ); ?></a>")
127
  );
128
  })(jQuery);
129
  </script>
134
  }
135
  }
136
 
137
+ return new SP_Admin();
includes/admin/importers/class-sp-event-importer.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Event importer - import events into SportsPress.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Importers
8
- * @version 2.7.1
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( class_exists( 'WP_Importer' ) ) {
14
  class SP_Event_Importer extends SP_Importer {
@@ -20,20 +22,21 @@ if ( class_exists( 'WP_Importer' ) ) {
20
  * @return void
21
  */
22
  public function __construct() {
23
- $this->import_page = 'sp_event_csv';
24
- $this->import_label = __( 'Import Events', 'sportspress' );
25
- $this->columns = array(
26
- 'post_date' => __( 'Date', 'sportspress' ),
27
- 'post_time' => __( 'Time', 'sportspress' ),
28
- 'sp_venue' => __( 'Venue', 'sportspress' ),
29
- 'sp_team' => __( 'Teams', 'sportspress' ),
30
- 'sp_results' => __( 'Results', 'sportspress' ),
31
- 'sp_outcome' => __( 'Outcome', 'sportspress' ),
32
- 'sp_player' => __( 'Players', 'sportspress' ),
33
  );
34
  $performance_labels = sp_get_var_labels( 'sp_performance' );
35
- if ( $performance_labels && is_array( $performance_labels ) && sizeof( $performance_labels ) )
36
  $this->columns = array_merge( $this->columns, $performance_labels );
 
37
  }
38
 
39
  /**
@@ -47,7 +50,7 @@ if ( class_exists( 'WP_Importer' ) ) {
47
  function import( $array = array(), $columns = array( 'post_title' ) ) {
48
  $this->imported = $this->skipped = 0;
49
 
50
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
51
  $this->footer();
52
  die();
53
  endif;
@@ -55,30 +58,32 @@ if ( class_exists( 'WP_Importer' ) ) {
55
  $rows = array_chunk( $array, sizeof( $columns ) );
56
 
57
  // Get event format, league, and season from post vars
58
- $event_format = ( empty( $_POST['sp_format'] ) ? false : $_POST['sp_format'] );
59
- $league = ( sp_array_value( $_POST, 'sp_league', '-1' ) == '-1' ? false : $_POST['sp_league'] );
60
- $season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : $_POST['sp_season'] );
61
- $date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : $_POST['sp_date_format'] );
62
 
63
  // Get labels from result and performance post types
64
- $result_labels = sp_get_var_labels( 'sp_result' );
65
  $performance_labels = sp_get_var_labels( 'sp_performance' );
66
 
67
- foreach ( $rows as $row ):
68
 
69
  $row = array_filter( $row );
70
 
71
- if ( empty( $row ) ) continue;
 
 
72
 
73
  $meta = array();
74
 
75
- foreach ( $columns as $index => $key ):
76
  $meta[ $key ] = sp_array_value( $row, $index );
77
  endforeach;
78
 
79
  // Slice array into event, team, and player
80
- $event = array_slice( $row, 0, 3 );
81
- $team = array_slice( $row, 3, 3 );
82
  $player = array_slice( $row, 6 );
83
 
84
  // Get event details
@@ -105,16 +110,16 @@ if ( class_exists( 'WP_Importer' ) ) {
105
  $player = array(
106
  sp_array_value( $meta, 'sp_player' ),
107
  );
108
- unset( $meta['sp_player' ] );
109
- foreach ( $performance_labels as $key => $label ):
110
  $player[] = sp_array_value( $meta, $key, '' );
111
  endforeach;
112
 
113
  // Add new event if date is given
114
- if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ):
115
 
116
  // Add player performance to last event if available
117
- if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ):
118
  update_post_meta( $id, 'sp_players', $players );
119
  endif;
120
 
@@ -122,9 +127,9 @@ if ( class_exists( 'WP_Importer' ) ) {
122
  list( $date, $time, $venue ) = $event;
123
 
124
  // Format date
125
- $date = str_replace( '/', '-', trim( $date ) );
126
  $date_array = explode( '-', $date );
127
- switch ( $date_format ):
128
  case 'dd/mm/yyyy':
129
  $date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
130
  substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
@@ -142,12 +147,17 @@ if ( class_exists( 'WP_Importer' ) ) {
142
  endswitch;
143
 
144
  // Add time to date if given
145
- if ( ! empty( $time ) ):
146
  $date .= ' ' . trim( $time );
147
  endif;
148
 
149
  // Define post type args
150
- $args = array( 'post_type' => 'sp_event', 'post_status' => 'publish', 'post_date' => $date, 'post_title' => __( 'Event', 'sportspress' ) );
 
 
 
 
 
151
 
152
  // Insert event
153
  $id = wp_insert_post( $args );
@@ -159,17 +169,17 @@ if ( class_exists( 'WP_Importer' ) ) {
159
  update_post_meta( $id, '_sp_import', 1 );
160
 
161
  // Update event format
162
- if ( $event_format ):
163
  update_post_meta( $id, 'sp_format', $event_format );
164
  endif;
165
 
166
  // Update league
167
- if ( $league ):
168
  wp_set_object_terms( $id, $league, 'sp_league', false );
169
  endif;
170
 
171
  // Update season
172
- if ( $season ):
173
  wp_set_object_terms( $id, $season, 'sp_season', false );
174
  endif;
175
 
@@ -182,7 +192,7 @@ if ( class_exists( 'WP_Importer' ) ) {
182
  endif;
183
 
184
  // Add new team if team name is given
185
- if ( sizeof( $team ) > 0 && ! empty( $team[0] ) ):
186
 
187
  // List team columns
188
  list( $team_name, $result, $outcome ) = $team;
@@ -191,20 +201,31 @@ if ( class_exists( 'WP_Importer' ) ) {
191
  $team_object = get_page_by_title( stripslashes( $team_name ), OBJECT, 'sp_team' );
192
 
193
  // Get or insert team
194
- if ( $team_object ):
195
 
196
  // Make sure team is published
197
- if ( $team_object->post_status != 'publish' ):
198
- wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
 
 
 
 
 
199
  endif;
200
 
201
  // Get team ID
202
  $team_id = $team_object->ID;
203
 
204
- else:
205
 
206
  // Insert team
207
- $team_id = wp_insert_post( array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $team_name ) ) );
 
 
 
 
 
 
208
 
209
  // Flag as import
210
  update_post_meta( $team_id, '_sp_import', 1 );
@@ -212,17 +233,17 @@ if ( class_exists( 'WP_Importer' ) ) {
212
  endif;
213
 
214
  // Update league
215
- if ( $league ):
216
  wp_set_object_terms( $team_id, $league, 'sp_league', true );
217
  endif;
218
 
219
  // Update season
220
- if ( $season ):
221
  wp_set_object_terms( $team_id, $season, 'sp_season', true );
222
  endif;
223
 
224
  // Add to event if exists
225
- if ( isset( $id ) ):
226
 
227
  // Add team to event
228
  add_post_meta( $id, 'sp_team', $team_id );
@@ -235,21 +256,21 @@ if ( class_exists( 'WP_Importer' ) ) {
235
 
236
  // Create team results array from result keys
237
  $team_results = array();
238
- if ( sizeof( $result_labels ) > 0 ):
239
- foreach( $result_labels as $key => $label ):
240
  $team_results[ $key ] = trim( array_shift( $results ) );
241
  endforeach;
242
- $team_results[ 'outcome' ] = array();
243
  endif;
244
 
245
  // Explode outcomes into array
246
  $outcomes = explode( '|', $outcome );
247
 
248
  // Add outcome slugs to team outcomes array
249
- foreach ( $outcomes as $outcome ):
250
 
251
  // Continue if outcome doesn't exist
252
- if ( $outcome == null ):
253
  continue;
254
  endif;
255
 
@@ -259,24 +280,35 @@ if ( class_exists( 'WP_Importer' ) ) {
259
  // Get or insert outcome
260
  $outcome_object = get_page_by_title( stripslashes( $outcome ), OBJECT, 'sp_outcome' );
261
 
262
- if ( $outcome_object ):
263
 
264
  // Make sure outcome is published
265
- if ( $outcome_object->post_status != 'publish' ):
266
- wp_update_post( array( 'ID' => $outcome_object->ID, 'post_status' => 'publish' ) );
 
 
 
 
 
267
  endif;
268
 
269
  // Get outcome slug
270
  $outcome_slug = $outcome_object->post_name;
271
 
272
- else:
273
 
274
  // Insert outcome
275
- $outcome_id = wp_insert_post( array( 'post_type' => 'sp_outcome', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $outcome ) ) );
 
 
 
 
 
 
276
 
277
  // Get outcome slug
278
- $post_data = get_post( $outcome_id, ARRAY_A );
279
- $outcome_slug = $post_data['post_name'];
280
 
281
  // Flag as import
282
  update_post_meta( $outcome_id, '_sp_import', 1 );
@@ -284,7 +316,7 @@ if ( class_exists( 'WP_Importer' ) ) {
284
  endif;
285
 
286
  // Add to team results array
287
- $team_results[ 'outcome' ][] = $outcome_slug;
288
 
289
  endforeach;
290
 
@@ -292,7 +324,7 @@ if ( class_exists( 'WP_Importer' ) ) {
292
  $event_results = get_post_meta( $id, 'sp_results', true );
293
 
294
  // Create new array if results not exists
295
- if ( ! $event_results ):
296
  $event_results = array();
297
  endif;
298
 
@@ -306,7 +338,7 @@ if ( class_exists( 'WP_Importer' ) ) {
306
  $title = get_the_title( $id );
307
 
308
  // Initialize event name
309
- if ( __( 'Event', 'sportspress' ) === $title ) {
310
  $title = '';
311
  } else {
312
  $title .= ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ';
@@ -317,9 +349,9 @@ if ( class_exists( 'WP_Importer' ) ) {
317
 
318
  // Update event with new name
319
  $post = array(
320
- 'ID' => $id,
321
  'post_title' => $title,
322
- 'post_name' => $id,
323
  );
324
  wp_update_post( $post );
325
 
@@ -328,7 +360,7 @@ if ( class_exists( 'WP_Importer' ) ) {
328
  endif;
329
 
330
  // Add new player if player name is given
331
- if ( sizeof( $player ) > 0 && ! empty( $player[0] ) ):
332
 
333
  // Get and unset player name leaving us with the performance
334
  $player_name = $player[0];
@@ -338,11 +370,16 @@ if ( class_exists( 'WP_Importer' ) ) {
338
  $player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
339
 
340
  // Get or insert player
341
- if ( $player_object ):
342
 
343
  // Make sure player is published
344
- if ( $player_object->post_status != 'publish' ):
345
- wp_update_post( array( 'ID' => $player_object->ID, 'post_status' => 'publish' ) );
 
 
 
 
 
346
  endif;
347
 
348
  // Get player ID
@@ -351,10 +388,16 @@ if ( class_exists( 'WP_Importer' ) ) {
351
  // Get player number
352
  $player_number = get_post_meta( $player_id, 'sp_number', true );
353
 
354
- else:
355
 
356
  // Insert player
357
- $player_id = wp_insert_post( array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $player_name ) ) );
 
 
 
 
 
 
358
 
359
  // Flag as import
360
  update_post_meta( $player_id, '_sp_import', 1 );
@@ -368,29 +411,29 @@ if ( class_exists( 'WP_Importer' ) ) {
368
  endif;
369
 
370
  // Update league
371
- if ( $league ):
372
  wp_set_object_terms( $player_id, $league, 'sp_league', true );
373
  endif;
374
 
375
  // Update season
376
- if ( $season ):
377
  wp_set_object_terms( $player_id, $season, 'sp_season', true );
378
  endif;
379
 
380
  // Add to event if exists
381
- if ( isset( $id ) ):
382
 
383
  // Add player to event
384
  add_post_meta( $id, 'sp_player', $player_id );
385
 
386
  // Add player performance to array if team is available
387
- if ( isset( $team_id ) ):
388
 
389
  // Initialize performance array
390
  $performance = array( 'number' => $player_number );
391
 
392
  // Map keys to player performance
393
- foreach ( $performance_labels as $key => $label ):
394
  $performance[ $key ] = array_shift( $player );
395
  endforeach;
396
  $players[ $team_id ][ $player_id ] = $performance;
@@ -398,17 +441,17 @@ if ( class_exists( 'WP_Importer' ) ) {
398
  // Get player teams
399
  $player_teams = get_post_meta( $player_id, 'sp_team', false );
400
  $current_team = get_post_meta( $player_id, 'sp_current_team', true );
401
- $past_teams = get_post_meta( $player_id, 'sp_past_team', false );
402
 
403
  // Add team if not exists in player
404
- if ( ! in_array( $team_id, $player_teams ) ):
405
  add_post_meta( $player_id, 'sp_team', $team_id );
406
  endif;
407
 
408
  // Add as past team or set current team if not set
409
- if ( ! $current_team ):
410
  update_post_meta( $player_id, 'sp_current_team', $team_id );
411
- elseif ( $current_team != $team_id && ! in_array( $team_id, $past_teams ) ):
412
  add_post_meta( $player_id, 'sp_past_team', $team_id );
413
  endif;
414
 
@@ -421,13 +464,13 @@ if ( class_exists( 'WP_Importer' ) ) {
421
  endforeach;
422
 
423
  // Add player performance to last event if available
424
- if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ):
425
  update_post_meta( $id, 'sp_players', $players );
426
  endif;
427
 
428
  // Show Result
429
  echo '<div class="updated settings-error below-h2"><p>
430
- '.sprintf( __( 'Import complete - imported <strong>%s</strong> events and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
431
  </p></div>';
432
 
433
  $this->import_end();
@@ -437,7 +480,7 @@ if ( class_exists( 'WP_Importer' ) ) {
437
  * Performs post-import cleanup of files and the cache
438
  */
439
  function import_end() {
440
- echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_event') . '">' . __( 'View Events', 'sportspress' ) . '</a>' . '</p>';
441
 
442
  do_action( 'import_end' );
443
  }
@@ -450,9 +493,9 @@ if ( class_exists( 'WP_Importer' ) ) {
450
  */
451
  function greet() {
452
  echo '<div class="narrow">';
453
- echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
454
- echo '<p>' . sprintf( __( 'Events need to be defined with columns in a specific order (3+ columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/events-sample.csv' ) . '</p>';
455
- echo '<p>' . sprintf( __( 'Supports CSV files generated by <a href="%s">LeagueLobster</a>.', 'sportspress' ), 'http://tboy.co/leaguelobster' ) . '</p>';
456
  wp_import_upload_form( 'admin.php?import=sp_event_csv&step=1' );
457
  echo '</div>';
458
  }
@@ -468,73 +511,77 @@ if ( class_exists( 'WP_Importer' ) ) {
468
  <table class="form-table">
469
  <tbody>
470
  <tr>
471
- <th scope="row"><label><?php _e( 'Format', 'sportspress' ); ?></label><br/></th>
472
  <td class="forminp forminp-radio" id="sp_formatdiv">
473
  <fieldset id="post-formats-select">
474
  <ul>
475
  <?php
476
- foreach( (new SP_Formats)->event as $name => $title ) {
477
- ?>
478
- <li><input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo $name; ?>" value="<?php echo $name; ?>" checked="checked"> <label for="post-format-<?php echo $name; ?>" class="post-format-icon post-format-<?php echo $name; ?>"><?php echo $title; ?></label></li>
479
  <?php
480
- }
481
  ?>
482
  </ul>
483
  </fieldset>
484
  </td>
485
  </tr>
486
  <tr>
487
- <th scope="row"><label><?php _e( 'League', 'sportspress' ); ?></label><br/></th>
488
- <td><?php
 
489
  $args = array(
490
- 'taxonomy' => 'sp_league',
491
- 'name' => 'sp_league',
492
- 'values' => 'slug',
493
- 'show_option_none' => __( '&mdash; Not set &mdash;', 'sportspress' ),
494
  );
495
- if ( ! sp_dropdown_taxonomies( $args ) ):
496
- echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
497
- sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
498
  endif;
499
- ?></td>
 
500
  </tr>
501
  <tr>
502
- <th scope="row"><label><?php _e( 'Season', 'sportspress' ); ?></label><br/></th>
503
- <td><?php
 
504
  $args = array(
505
- 'taxonomy' => 'sp_season',
506
- 'name' => 'sp_season',
507
- 'values' => 'slug',
508
- 'show_option_none' => __( '&mdash; Not set &mdash;', 'sportspress' ),
509
  );
510
- if ( ! sp_dropdown_taxonomies( $args ) ):
511
- echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
512
- sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
513
  endif;
514
- ?></td>
 
515
  </tr>
516
  <tr>
517
  <th scope="row" class="titledesc">
518
- <?php _e( 'Date Format', 'sportspress' ); ?>
519
  </th>
520
- <td class="forminp forminp-radio">
521
- <fieldset>
522
- <ul>
523
  <li>
524
- <label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
525
- </li>
526
  <li>
527
- <label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
528
- </li>
529
  <li>
530
- <label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
531
- </li>
532
  </ul>
533
- </fieldset>
534
- </td>
535
- </tr>
536
- </tbody>
537
- </table>
538
  <?php
539
  }
540
  }
2
  /**
3
  * Event importer - import events into SportsPress.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Importers
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( class_exists( 'WP_Importer' ) ) {
16
  class SP_Event_Importer extends SP_Importer {
22
  * @return void
23
  */
24
  public function __construct() {
25
+ $this->import_page = 'sp_event_csv';
26
+ $this->import_label = esc_attr__( 'Import Events', 'sportspress' );
27
+ $this->columns = array(
28
+ 'post_date' => esc_attr__( 'Date', 'sportspress' ),
29
+ 'post_time' => esc_attr__( 'Time', 'sportspress' ),
30
+ 'sp_venue' => esc_attr__( 'Venue', 'sportspress' ),
31
+ 'sp_team' => esc_attr__( 'Teams', 'sportspress' ),
32
+ 'sp_results' => esc_attr__( 'Results', 'sportspress' ),
33
+ 'sp_outcome' => esc_attr__( 'Outcome', 'sportspress' ),
34
+ 'sp_player' => esc_attr__( 'Players', 'sportspress' ),
35
  );
36
  $performance_labels = sp_get_var_labels( 'sp_performance' );
37
+ if ( $performance_labels && is_array( $performance_labels ) && sizeof( $performance_labels ) ) {
38
  $this->columns = array_merge( $this->columns, $performance_labels );
39
+ }
40
  }
41
 
42
  /**
50
  function import( $array = array(), $columns = array( 'post_title' ) ) {
51
  $this->imported = $this->skipped = 0;
52
 
53
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
54
  $this->footer();
55
  die();
56
  endif;
58
  $rows = array_chunk( $array, sizeof( $columns ) );
59
 
60
  // Get event format, league, and season from post vars
61
+ $event_format = ( empty( $_POST['sp_format'] ) ? false : sanitize_key( $_POST['sp_format'] ) );
62
+ $league = ( sp_array_value( $_POST, 'sp_league', '-1' ) == '-1' ? false : sanitize_key( $_POST['sp_league'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
63
+ $season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : sanitize_key( $_POST['sp_season'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
64
+ $date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : sanitize_text_field( wp_unslash( $_POST['sp_date_format'] ) ) );
65
 
66
  // Get labels from result and performance post types
67
+ $result_labels = sp_get_var_labels( 'sp_result' );
68
  $performance_labels = sp_get_var_labels( 'sp_performance' );
69
 
70
+ foreach ( $rows as $row ) :
71
 
72
  $row = array_filter( $row );
73
 
74
+ if ( empty( $row ) ) {
75
+ continue;
76
+ }
77
 
78
  $meta = array();
79
 
80
+ foreach ( $columns as $index => $key ) :
81
  $meta[ $key ] = sp_array_value( $row, $index );
82
  endforeach;
83
 
84
  // Slice array into event, team, and player
85
+ $event = array_slice( $row, 0, 3 );
86
+ $team = array_slice( $row, 3, 3 );
87
  $player = array_slice( $row, 6 );
88
 
89
  // Get event details
110
  $player = array(
111
  sp_array_value( $meta, 'sp_player' ),
112
  );
113
+ unset( $meta['sp_player'] );
114
+ foreach ( $performance_labels as $key => $label ) :
115
  $player[] = sp_array_value( $meta, $key, '' );
116
  endforeach;
117
 
118
  // Add new event if date is given
119
+ if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ) :
120
 
121
  // Add player performance to last event if available
122
+ if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ) :
123
  update_post_meta( $id, 'sp_players', $players );
124
  endif;
125
 
127
  list( $date, $time, $venue ) = $event;
128
 
129
  // Format date
130
+ $date = str_replace( '/', '-', trim( $date ) );
131
  $date_array = explode( '-', $date );
132
+ switch ( $date_format ) :
133
  case 'dd/mm/yyyy':
134
  $date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
135
  substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
147
  endswitch;
148
 
149
  // Add time to date if given
150
+ if ( ! empty( $time ) ) :
151
  $date .= ' ' . trim( $time );
152
  endif;
153
 
154
  // Define post type args
155
+ $args = array(
156
+ 'post_type' => 'sp_event',
157
+ 'post_status' => 'publish',
158
+ 'post_date' => $date,
159
+ 'post_title' => esc_attr__( 'Event', 'sportspress' ),
160
+ );
161
 
162
  // Insert event
163
  $id = wp_insert_post( $args );
169
  update_post_meta( $id, '_sp_import', 1 );
170
 
171
  // Update event format
172
+ if ( $event_format ) :
173
  update_post_meta( $id, 'sp_format', $event_format );
174
  endif;
175
 
176
  // Update league
177
+ if ( $league ) :
178
  wp_set_object_terms( $id, $league, 'sp_league', false );
179
  endif;
180
 
181
  // Update season
182
+ if ( $season ) :
183
  wp_set_object_terms( $id, $season, 'sp_season', false );
184
  endif;
185
 
192
  endif;
193
 
194
  // Add new team if team name is given
195
+ if ( sizeof( $team ) > 0 && ! empty( $team[0] ) ) :
196
 
197
  // List team columns
198
  list( $team_name, $result, $outcome ) = $team;
201
  $team_object = get_page_by_title( stripslashes( $team_name ), OBJECT, 'sp_team' );
202
 
203
  // Get or insert team
204
+ if ( $team_object ) :
205
 
206
  // Make sure team is published
207
+ if ( $team_object->post_status != 'publish' ) :
208
+ wp_update_post(
209
+ array(
210
+ 'ID' => $team_object->ID,
211
+ 'post_status' => 'publish',
212
+ )
213
+ );
214
  endif;
215
 
216
  // Get team ID
217
  $team_id = $team_object->ID;
218
 
219
+ else :
220
 
221
  // Insert team
222
+ $team_id = wp_insert_post(
223
+ array(
224
+ 'post_type' => 'sp_team',
225
+ 'post_status' => 'publish',
226
+ 'post_title' => wp_strip_all_tags( $team_name ),
227
+ )
228
+ );
229
 
230
  // Flag as import
231
  update_post_meta( $team_id, '_sp_import', 1 );
233
  endif;
234
 
235
  // Update league
236
+ if ( $league ) :
237
  wp_set_object_terms( $team_id, $league, 'sp_league', true );
238
  endif;
239
 
240
  // Update season
241
+ if ( $season ) :
242
  wp_set_object_terms( $team_id, $season, 'sp_season', true );
243
  endif;
244
 
245
  // Add to event if exists
246
+ if ( isset( $id ) ) :
247
 
248
  // Add team to event
249
  add_post_meta( $id, 'sp_team', $team_id );
256
 
257
  // Create team results array from result keys
258
  $team_results = array();
259
+ if ( sizeof( $result_labels ) > 0 ) :
260
+ foreach ( $result_labels as $key => $label ) :
261
  $team_results[ $key ] = trim( array_shift( $results ) );
262
  endforeach;
263
+ $team_results['outcome'] = array();
264
  endif;
265
 
266
  // Explode outcomes into array
267
  $outcomes = explode( '|', $outcome );
268
 
269
  // Add outcome slugs to team outcomes array
270
+ foreach ( $outcomes as $outcome ) :
271
 
272
  // Continue if outcome doesn't exist
273
+ if ( $outcome == null ) :
274
  continue;
275
  endif;
276
 
280
  // Get or insert outcome
281
  $outcome_object = get_page_by_title( stripslashes( $outcome ), OBJECT, 'sp_outcome' );
282
 
283
+ if ( $outcome_object ) :
284
 
285
  // Make sure outcome is published
286
+ if ( $outcome_object->post_status != 'publish' ) :
287
+ wp_update_post(
288
+ array(
289
+ 'ID' => $outcome_object->ID,
290
+ 'post_status' => 'publish',
291
+ )
292
+ );
293
  endif;
294
 
295
  // Get outcome slug
296
  $outcome_slug = $outcome_object->post_name;
297
 
298
+ else :
299
 
300
  // Insert outcome
301
+ $outcome_id = wp_insert_post(
302
+ array(
303
+ 'post_type' => 'sp_outcome',
304
+ 'post_status' => 'publish',
305
+ 'post_title' => wp_strip_all_tags( $outcome ),
306
+ )
307
+ );
308
 
309
  // Get outcome slug
310
+ $post_data = get_post( $outcome_id, ARRAY_A );
311
+ $outcome_slug = $post_data['post_name'];
312
 
313
  // Flag as import
314
  update_post_meta( $outcome_id, '_sp_import', 1 );
316
  endif;
317
 
318
  // Add to team results array
319
+ $team_results['outcome'][] = $outcome_slug;
320
 
321
  endforeach;
322
 
324
  $event_results = get_post_meta( $id, 'sp_results', true );
325
 
326
  // Create new array if results not exists
327
+ if ( ! $event_results ) :
328
  $event_results = array();
329
  endif;
330
 
338
  $title = get_the_title( $id );
339
 
340
  // Initialize event name
341
+ if ( esc_attr__( 'Event', 'sportspress' ) === $title ) {
342
  $title = '';
343
  } else {
344
  $title .= ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ';
349
 
350
  // Update event with new name
351
  $post = array(
352
+ 'ID' => $id,
353
  'post_title' => $title,
354
+ 'post_name' => $id,
355
  );
356
  wp_update_post( $post );
357
 
360
  endif;
361
 
362
  // Add new player if player name is given
363
+ if ( sizeof( $player ) > 0 && ! empty( $player[0] ) ) :
364
 
365
  // Get and unset player name leaving us with the performance
366
  $player_name = $player[0];
370
  $player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
371
 
372
  // Get or insert player
373
+ if ( $player_object ) :
374
 
375
  // Make sure player is published
376
+ if ( $player_object->post_status != 'publish' ) :
377
+ wp_update_post(
378
+ array(
379
+ 'ID' => $player_object->ID,
380
+ 'post_status' => 'publish',
381
+ )
382
+ );
383
  endif;
384
 
385
  // Get player ID
388
  // Get player number
389
  $player_number = get_post_meta( $player_id, 'sp_number', true );
390
 
391
+ else :
392
 
393
  // Insert player
394
+ $player_id = wp_insert_post(
395
+ array(
396
+ 'post_type' => 'sp_player',
397
+ 'post_status' => 'publish',
398
+ 'post_title' => wp_strip_all_tags( $player_name ),
399
+ )
400
+ );
401
 
402
  // Flag as import
403
  update_post_meta( $player_id, '_sp_import', 1 );
411
  endif;
412
 
413
  // Update league
414
+ if ( $league ) :
415
  wp_set_object_terms( $player_id, $league, 'sp_league', true );
416
  endif;
417
 
418
  // Update season
419
+ if ( $season ) :
420
  wp_set_object_terms( $player_id, $season, 'sp_season', true );
421
  endif;
422
 
423
  // Add to event if exists
424
+ if ( isset( $id ) ) :
425
 
426
  // Add player to event
427
  add_post_meta( $id, 'sp_player', $player_id );
428
 
429
  // Add player performance to array if team is available
430
+ if ( isset( $team_id ) ) :
431
 
432
  // Initialize performance array
433
  $performance = array( 'number' => $player_number );
434
 
435
  // Map keys to player performance
436
+ foreach ( $performance_labels as $key => $label ) :
437
  $performance[ $key ] = array_shift( $player );
438
  endforeach;
439
  $players[ $team_id ][ $player_id ] = $performance;
441
  // Get player teams
442
  $player_teams = get_post_meta( $player_id, 'sp_team', false );
443
  $current_team = get_post_meta( $player_id, 'sp_current_team', true );
444
+ $past_teams = get_post_meta( $player_id, 'sp_past_team', false );
445
 
446
  // Add team if not exists in player
447
+ if ( ! in_array( $team_id, $player_teams ) ) :
448
  add_post_meta( $player_id, 'sp_team', $team_id );
449
  endif;
450
 
451
  // Add as past team or set current team if not set
452
+ if ( ! $current_team ) :
453
  update_post_meta( $player_id, 'sp_current_team', $team_id );
454
+ elseif ( $current_team != $team_id && ! in_array( $team_id, $past_teams ) ) :
455
  add_post_meta( $player_id, 'sp_past_team', $team_id );
456
  endif;
457
 
464
  endforeach;
465
 
466
  // Add player performance to last event if available
467
+ if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ) :
468
  update_post_meta( $id, 'sp_players', $players );
469
  endif;
470
 
471
  // Show Result
472
  echo '<div class="updated settings-error below-h2"><p>
473
+ ' . sprintf( esc_html__( 'Import complete - imported <strong>%1$s</strong> events and skipped <strong>%2$s</strong>.', 'sportspress' ), esc_html( $this->imported ), esc_html( $this->skipped ) ) . '
474
  </p></div>';
475
 
476
  $this->import_end();
480
  * Performs post-import cleanup of files and the cache
481
  */
482
  function import_end() {
483
+ echo '<p>' . esc_html__( 'All done!', 'sportspress' ) . ' <a href="' . esc_url( admin_url( 'edit.php?post_type=sp_event' ) ) . '">' . esc_html__( 'View Events', 'sportspress' ) . '</a>' . '</p>';
484
 
485
  do_action( 'import_end' );
486
  }
493
  */
494
  function greet() {
495
  echo '<div class="narrow">';
496
+ echo '<p>' . esc_html__( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
497
+ echo '<p>' . sprintf( wp_kses_post( esc_attr__( 'Events need to be defined with columns in a specific order (3+ columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ) ), esc_url( plugin_dir_url( SP_PLUGIN_FILE ) ) . 'dummy-data/events-sample.csv' ) . '</p>';
498
+ echo '<p>' . sprintf( wp_kses_post( esc_attr__( 'Supports CSV files generated by <a href="%s">LeagueLobster</a>.', 'sportspress' ) ), 'http://tboy.co/leaguelobster' ) . '</p>';
499
  wp_import_upload_form( 'admin.php?import=sp_event_csv&step=1' );
500
  echo '</div>';
501
  }
511
  <table class="form-table">
512
  <tbody>
513
  <tr>
514
+ <th scope="row"><label><?php esc_html_e( 'Format', 'sportspress' ); ?></label><br/></th>
515
  <td class="forminp forminp-radio" id="sp_formatdiv">
516
  <fieldset id="post-formats-select">
517
  <ul>
518
  <?php
519
+ foreach ( ( new SP_Formats() )->event as $name => $title ) {
520
+ ?>
521
+ <li><input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( $name ); ?>" checked="checked"> <label for="post-format-<?php echo esc_attr( $name ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $name ); ?>"><?php echo esc_html( $title ); ?></label></li>
522
  <?php
523
+ }
524
  ?>
525
  </ul>
526
  </fieldset>
527
  </td>
528
  </tr>
529
  <tr>
530
+ <th scope="row"><label><?php esc_html_e( 'League', 'sportspress' ); ?></label><br/></th>
531
+ <td>
532
+ <?php
533
  $args = array(
534
+ 'taxonomy' => 'sp_league',
535
+ 'name' => 'sp_league',
536
+ 'values' => 'slug',
537
+ 'show_option_none' => esc_attr__( '&mdash; Not set &mdash;', 'sportspress' ),
538
  );
539
+ if ( ! sp_dropdown_taxonomies( $args ) ) :
540
+ echo '<p>' . esc_html__( 'None', 'sportspress' ) . '</p>';
541
+ sp_taxonomy_adder( 'sp_league', 'sp_team', esc_attr__( 'Add New', 'sportspress' ) );
542
  endif;
543
+ ?>
544
+ </td>
545
  </tr>
546
  <tr>
547
+ <th scope="row"><label><?php esc_html_e( 'Season', 'sportspress' ); ?></label><br/></th>
548
+ <td>
549
+ <?php
550
  $args = array(
551
+ 'taxonomy' => 'sp_season',
552
+ 'name' => 'sp_season',
553
+ 'values' => 'slug',
554
+ 'show_option_none' => esc_attr__( '&mdash; Not set &mdash;', 'sportspress' ),
555
  );
556
+ if ( ! sp_dropdown_taxonomies( $args ) ) :
557
+ echo '<p>' . esc_html__( 'None', 'sportspress' ) . '</p>';
558
+ sp_taxonomy_adder( 'sp_season', 'sp_team', esc_attr__( 'Add New', 'sportspress' ) );
559
  endif;
560
+ ?>
561
+ </td>
562
  </tr>
563
  <tr>
564
  <th scope="row" class="titledesc">
565
+ <?php esc_html_e( 'Date Format', 'sportspress' ); ?>
566
  </th>
567
+ <td class="forminp forminp-radio">
568
+ <fieldset>
569
+ <ul>
570
  <li>
571
+ <label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
572
+ </li>
573
  <li>
574
+ <label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
575
+ </li>
576
  <li>
577
+ <label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
578
+ </li>
579
  </ul>
580
+ </fieldset>
581
+ </td>
582
+ </tr>
583
+ </tbody>
584
+ </table>
585
  <?php
586
  }
587
  }
includes/admin/importers/class-sp-event-performance-importer.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Event Performance importer - import box scores into SportsPress.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Importers
8
- * @version 2.5.1
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( class_exists( 'WP_Importer' ) ) {
14
  class SP_Event_Performance_Importer extends SP_Importer {
@@ -20,14 +22,15 @@ if ( class_exists( 'WP_Importer' ) ) {
20
  * @return void
21
  */
22
  public function __construct() {
23
- $this->import_page = 'sp_event_performance_csv';
24
- $this->import_label = __( 'Import Box Score', 'sportspress' );
25
- $this->columns = array(
26
- 'sp_player' => __( 'Player', 'sportspress' ),
27
  );
28
  $performance_labels = sp_get_var_labels( 'sp_performance' );
29
- if ( $performance_labels && is_array( $performance_labels ) && sizeof( $performance_labels ) )
30
  $this->columns = array_merge( $this->columns, $performance_labels );
 
31
  }
32
 
33
  /**
@@ -41,7 +44,7 @@ if ( class_exists( 'WP_Importer' ) ) {
41
  function import( $array = array(), $columns = array( 'sp_player' ) ) {
42
  $this->imported = $this->skipped = 0;
43
 
44
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
45
  $this->footer();
46
  die();
47
  endif;
@@ -49,39 +52,47 @@ if ( class_exists( 'WP_Importer' ) ) {
49
  $rows = array_chunk( $array, sizeof( $columns ) );
50
 
51
  // Get event ID and team ID from post vars
52
- $event = ( empty( $_POST['sp_event'] ) ? false : $_POST['sp_event'] );
53
- $teams = ( empty( $_POST['sp_teams'] ) ? false : $_POST['sp_teams'] );
54
- $index = ( empty( $_POST['sp_index'] ) ? false : $_POST['sp_index'] );
55
- $team = ( empty( $_POST['sp_team'] ) ? false : $_POST['sp_team'] );
56
 
57
- $team_players = array( 0 );
58
  $team_performance = array();
59
- $name_index = (int) array_search( 'sp_player', $columns );
60
 
61
- foreach ( $rows as $row ):
62
 
63
  $row = array_filter( $row );
64
 
65
- if ( empty( $row ) ) continue;
 
 
66
 
67
  $player_name = sp_array_value( $row, $name_index );
68
-
69
- if ( ! $player_name ):
70
  $this->skipped ++;
71
  continue;
72
  endif;
73
 
74
  $player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
75
 
76
- if ( $player_object ):
77
 
78
  // Get player ID
79
  $player_id = $player_object->ID;
80
 
81
- else:
82
 
83
  // Insert player
84
- $player_id = wp_insert_post( array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $player_name ) ) );
 
 
 
 
 
 
85
 
86
  // Flag as import
87
  update_post_meta( $player_id, '_sp_import', 1 );
@@ -89,10 +100,12 @@ if ( class_exists( 'WP_Importer' ) ) {
89
  endif;
90
 
91
  $team_players[] = $player_id;
92
- $player = array();
93
 
94
- foreach ( $columns as $i => $key ):
95
- if ( 'sp_player' === $key ) continue;
 
 
96
  $player[ $key ] = sp_array_value( $row, $i, '' );
97
  endforeach;
98
 
@@ -100,13 +113,13 @@ if ( class_exists( 'WP_Importer' ) ) {
100
 
101
  endforeach;
102
 
103
- if ( $event && $team ):
104
  $the_players = get_post_meta( $event, 'sp_player', false );
105
- $players = array();
106
- for ( $i = 0; $i < $teams; $i++ ):
107
- if ( $index == $i ):
108
  array_push( $players, $team_players );
109
- else:
110
  array_push( $players, sp_array_between( $the_players, 0, $i ) );
111
  endif;
112
  endfor;
@@ -114,15 +127,15 @@ if ( class_exists( 'WP_Importer' ) ) {
114
 
115
  $this->imported = sizeof( $team_players ) - 1;
116
 
117
- $performance = (array) get_post_meta( $event, 'sp_players', true );
118
- $performance = array_filter( $performance );
119
  $performance[ $team ] = $team_performance;
120
  update_post_meta( $event, 'sp_players', $performance );
121
  endif;
122
 
123
  // Show Result
124
  echo '<div class="updated settings-error below-h2"><p>
125
- '.sprintf( __( 'Import complete - imported <strong>%s</strong> rows and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
126
  </p></div>';
127
 
128
  $this->import_end( $event );
@@ -132,7 +145,15 @@ if ( class_exists( 'WP_Importer' ) ) {
132
  * Performs post-import cleanup of files and the cache
133
  */
134
  function import_end( $event = 0 ) {
135
- echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( add_query_arg( array( 'post' => $event, 'action' => 'edit' ), 'post.php' ) ) . '">' . __( 'View Event', 'sportspress' ) . '</a>' . '</p>';
 
 
 
 
 
 
 
 
136
 
137
  do_action( 'import_end' );
138
  }
@@ -149,12 +170,18 @@ if ( class_exists( 'WP_Importer' ) ) {
149
  echo '<div class="narrow">';
150
 
151
  if ( $event ) {
152
- $args = array_merge( $_REQUEST, array( 'import' => 'sp_event_performance_csv', 'step' => '1' ) );
153
- echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
154
- echo '<p>' . sprintf( __( 'Box scores need to be defined with columns in a specific order. <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/event-performance-sample.csv' ) . '</p>';
 
 
 
 
 
 
155
  wp_import_upload_form( add_query_arg( $args, 'admin.php' ) );
156
  } else {
157
- echo '<p><a href="' . admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ) . '">' . sprintf( __( 'Select %s', 'sportspress' ), __( 'Event', 'sportspress' ) ) . '</a></p>';
158
  }
159
 
160
  echo '</div>';
@@ -167,35 +194,35 @@ if ( class_exists( 'WP_Importer' ) ) {
167
  * @return void
168
  */
169
  function options() {
170
- $event = sp_array_value( $_REQUEST, 'event', 0 );
171
- $teams = sp_array_value( $_REQUEST, 'teams', 0 );
172
- $index = sp_array_value( $_REQUEST, 'index', 0 );
173
- $team = sp_array_value( $_REQUEST, 'team', 0 );
174
  $include = get_post_meta( $event, 'sp_team', false );
175
  ?>
176
  <table class="form-table">
177
  <tbody>
178
  <tr>
179
- <th scope="row"><label><?php _e( 'Event', 'sportspress' ); ?></label><br/></th>
180
  <td>
181
- <a href="<?php echo get_post_permalink( $event ); ?>" target="_blank">
182
- <?php echo get_the_title( $event ); ?>
183
  </a>
184
- <input type="hidden" name="sp_event" value="<?php echo $event; ?>">
185
- <input type="hidden" name="sp_teams" value="<?php echo $teams; ?>">
186
- <input type="hidden" name="sp_index" value="<?php echo $index; ?>">
187
  </td>
188
  </tr>
189
  <tr>
190
- <th scope="row"><label><?php _e( 'Team', 'sportspress' ); ?></label><br/></th>
191
  <td>
192
  <?php
193
  $args = array(
194
  'post_type' => 'sp_team',
195
- 'name' => 'sp_team',
196
- 'values' => 'ID',
197
- 'selected' => $team,
198
- 'include' => $include,
199
  );
200
  sp_dropdown_pages( $args );
201
  ?>
2
  /**
3
  * Event Performance importer - import box scores into SportsPress.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Importers
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( class_exists( 'WP_Importer' ) ) {
16
  class SP_Event_Performance_Importer extends SP_Importer {
22
  * @return void
23
  */
24
  public function __construct() {
25
+ $this->import_page = 'sp_event_performance_csv';
26
+ $this->import_label = esc_attr__( 'Import Box Score', 'sportspress' );
27
+ $this->columns = array(
28
+ 'sp_player' => esc_attr__( 'Player', 'sportspress' ),
29
  );
30
  $performance_labels = sp_get_var_labels( 'sp_performance' );
31
+ if ( $performance_labels && is_array( $performance_labels ) && sizeof( $performance_labels ) ) {
32
  $this->columns = array_merge( $this->columns, $performance_labels );
33
+ }
34
  }
35
 
36
  /**
44
  function import( $array = array(), $columns = array( 'sp_player' ) ) {
45
  $this->imported = $this->skipped = 0;
46
 
47
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
48
  $this->footer();
49
  die();
50
  endif;
52
  $rows = array_chunk( $array, sizeof( $columns ) );
53
 
54
  // Get event ID and team ID from post vars
55
+ $event = ( empty( $_POST['sp_event'] ) ? false : sanitize_text_field( wp_unslash( $_POST['sp_event'] ) ) );
56
+ $teams = ( empty( $_POST['sp_teams'] ) ? false : sanitize_text_field( wp_unslash( $_POST['sp_teams'] ) ) );
57
+ $index = ( empty( $_POST['sp_index'] ) ? false : sanitize_text_field( wp_unslash( $_POST['sp_index'] ) ) );
58
+ $team = ( empty( $_POST['sp_team'] ) ? false : sanitize_text_field( wp_unslash( $_POST['sp_team'] ) ) );
59
 
60
+ $team_players = array( 0 );
61
  $team_performance = array();
62
+ $name_index = (int) array_search( 'sp_player', $columns );
63
 
64
+ foreach ( $rows as $row ) :
65
 
66
  $row = array_filter( $row );
67
 
68
+ if ( empty( $row ) ) {
69
+ continue;
70
+ }
71
 
72
  $player_name = sp_array_value( $row, $name_index );
73
+
74
+ if ( ! $player_name ) :
75
  $this->skipped ++;
76
  continue;
77
  endif;
78
 
79
  $player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
80
 
81
+ if ( $player_object ) :
82
 
83
  // Get player ID
84
  $player_id = $player_object->ID;
85
 
86
+ else :
87
 
88
  // Insert player
89
+ $player_id = wp_insert_post(
90
+ array(
91
+ 'post_type' => 'sp_player',
92
+ 'post_status' => 'publish',
93
+ 'post_title' => wp_strip_all_tags( $player_name ),
94
+ )
95
+ );
96
 
97
  // Flag as import
98
  update_post_meta( $player_id, '_sp_import', 1 );
100
  endif;
101
 
102
  $team_players[] = $player_id;
103
+ $player = array();
104
 
105
+ foreach ( $columns as $i => $key ) :
106
+ if ( 'sp_player' === $key ) {
107
+ continue;
108
+ }
109
  $player[ $key ] = sp_array_value( $row, $i, '' );
110
  endforeach;
111
 
113
 
114
  endforeach;
115
 
116
+ if ( $event && $team ) :
117
  $the_players = get_post_meta( $event, 'sp_player', false );
118
+ $players = array();
119
+ for ( $i = 0; $i < $teams; $i++ ) :
120
+ if ( $index == $i ) :
121
  array_push( $players, $team_players );
122
+ else :
123
  array_push( $players, sp_array_between( $the_players, 0, $i ) );
124
  endif;
125
  endfor;
127
 
128
  $this->imported = sizeof( $team_players ) - 1;
129
 
130
+ $performance = (array) get_post_meta( $event, 'sp_players', true );
131
+ $performance = array_filter( $performance );
132
  $performance[ $team ] = $team_performance;
133
  update_post_meta( $event, 'sp_players', $performance );
134
  endif;
135
 
136
  // Show Result
137
  echo '<div class="updated settings-error below-h2"><p>
138
+ ' . sprintf( esc_html__( 'Import complete - imported <strong>%1$s</strong> rows and skipped <strong>%2$s</strong>.', 'sportspress' ), esc_html( $this->imported ), esc_html( $this->skipped ) ) . '
139
  </p></div>';
140
 
141
  $this->import_end( $event );
145
  * Performs post-import cleanup of files and the cache
146
  */
147
  function import_end( $event = 0 ) {
148
+ echo '<p>' . esc_html__( 'All done!', 'sportspress' ) . ' <a href="' . esc_url( admin_url(
149
+ add_query_arg(
150
+ array(
151
+ 'post' => $event,
152
+ 'action' => 'edit',
153
+ ),
154
+ 'post.php'
155
+ )
156
+ ) ) . '">' . esc_html__( 'View Event', 'sportspress' ) . '</a>' . '</p>';
157
 
158
  do_action( 'import_end' );
159
  }
170
  echo '<div class="narrow">';
171
 
172
  if ( $event ) {
173
+ $args = array_merge(
174
+ $_REQUEST,
175
+ array(
176
+ 'import' => 'sp_event_performance_csv',
177
+ 'step' => '1',
178
+ )
179
+ );
180
+ echo '<p>' . esc_html__( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
181
+ echo '<p>' . sprintf( wp_kses_post( esc_attr__( 'Box scores need to be defined with columns in a specific order. <a href="%s">Click here to download a sample</a>.', 'sportspress' ) ), esc_url( plugin_dir_url( SP_PLUGIN_FILE ) ) . 'dummy-data/event-performance-sample.csv' ) . '</p>';
182
  wp_import_upload_form( add_query_arg( $args, 'admin.php' ) );
183
  } else {
184
+ echo '<p><a href="' . esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ) ) . '">' . sprintf( esc_html__( 'Select %s', 'sportspress' ), esc_html__( 'Event', 'sportspress' ) ) . '</a></p>';
185
  }
186
 
187
  echo '</div>';
194
  * @return void
195
  */
196
  function options() {
197
+ $event = sp_array_value( $_REQUEST, 'event', 0, 'key' );
198
+ $teams = sp_array_value( $_REQUEST, 'teams', 0, 'key' );
199
+ $index = sp_array_value( $_REQUEST, 'index', 0, 'key' );
200
+ $team = sp_array_value( $_REQUEST, 'team', 0, 'key' );
201
  $include = get_post_meta( $event, 'sp_team', false );
202
  ?>
203
  <table class="form-table">
204
  <tbody>
205
  <tr>
206
+ <th scope="row"><label><?php esc_html_e( 'Event', 'sportspress' ); ?></label><br/></th>
207
  <td>
208
+ <a href="<?php echo esc_url( get_post_permalink( $event ) ); ?>" target="_blank">
209
+ <?php echo esc_html( get_the_title( $event ) ); ?>
210
  </a>
211
+ <input type="hidden" name="sp_event" value="<?php echo esc_attr( $event ); ?>">
212
+ <input type="hidden" name="sp_teams" value="<?php echo esc_attr( $teams ); ?>">
213
+ <input type="hidden" name="sp_index" value="<?php echo esc_attr( $index ); ?>">
214
  </td>
215
  </tr>
216
  <tr>
217
+ <th scope="row"><label><?php esc_html_e( 'Team', 'sportspress' ); ?></label><br/></th>
218
  <td>
219
  <?php
220
  $args = array(
221
  'post_type' => 'sp_team',
222
+ 'name' => 'sp_team',
223
+ 'values' => 'ID',
224
+ 'selected' => $team,
225
+ 'include' => $include,
226
  );
227
  sp_dropdown_pages( $args );
228
  ?>
includes/admin/importers/class-sp-fixture-importer.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Fixture importer - import fixtures into SportsPress.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Importers
8
- * @version 2.7
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( class_exists( 'WP_Importer' ) ) {
14
  class SP_Fixture_Importer extends SP_Importer {
@@ -20,17 +22,17 @@ if ( class_exists( 'WP_Importer' ) ) {
20
  * @return void
21
  */
22
  public function __construct() {
23
- $this->import_page = 'sp_fixture_csv';
24
- $this->import_label = __( 'Import Fixtures', 'sportspress' );
25
- $this->columns = array(
26
- 'post_date' => __( 'Date', 'sportspress' ),
27
- 'post_time' => __( 'Time', 'sportspress' ),
28
- 'sp_venue' => __( 'Venue', 'sportspress' ),
29
- 'sp_home' => __( 'Home', 'sportspress' ),
30
- 'sp_away' => __( 'Away', 'sportspress' ),
31
- 'sp_day' => __( 'Match Day', 'sportspress' ),
32
  );
33
- $this->optionals = array( 'sp_day' );
34
  }
35
 
36
  /**
@@ -44,7 +46,7 @@ if ( class_exists( 'WP_Importer' ) ) {
44
  function import( $array = array(), $columns = array( 'post_title' ) ) {
45
  $this->imported = $this->skipped = 0;
46
 
47
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
48
  $this->footer();
49
  die();
50
  endif;
@@ -52,20 +54,22 @@ if ( class_exists( 'WP_Importer' ) ) {
52
  $rows = array_chunk( $array, sizeof( $columns ) );
53
 
54
  // Get event format, league, and season from post vars
55
- $event_format = ( empty( $_POST['sp_format'] ) ? false : $_POST['sp_format'] );
56
- $league = ( sp_array_value( $_POST, 'sp_league', '-1' ) == '-1' ? false : $_POST['sp_league'] );
57
- $season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : $_POST['sp_season'] );
58
- $date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : $_POST['sp_date_format'] );
59
 
60
- foreach ( $rows as $row ):
61
 
62
  $row = array_filter( $row );
63
 
64
- if ( empty( $row ) ) continue;
 
 
65
 
66
  $meta = array();
67
 
68
- foreach ( $columns as $index => $key ):
69
  $meta[ $key ] = sp_array_value( $row, $index );
70
  endforeach;
71
 
@@ -83,15 +87,15 @@ if ( class_exists( 'WP_Importer' ) ) {
83
  );
84
 
85
  // Add new event if date is given
86
- if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ):
87
 
88
  // List event columns
89
  list( $date, $time, $venue, $day ) = $event;
90
 
91
  // Format date
92
- $date = str_replace( '/', '-', trim( $date ) );
93
  $date_array = explode( '-', $date );
94
- switch ( $date_format ):
95
  case 'dd/mm/yyyy':
96
  $date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
97
  substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
@@ -109,12 +113,17 @@ if ( class_exists( 'WP_Importer' ) ) {
109
  endswitch;
110
 
111
  // Add time to date if given
112
- if ( ! empty( $time ) ):
113
  $date .= ' ' . trim( $time );
114
  endif;
115
 
116
  // Define post type args
117
- $args = array( 'post_type' => 'sp_event', 'post_status' => 'publish', 'post_date' => $date, 'post_title' => __( 'Event', 'sportspress' ) );
 
 
 
 
 
118
 
119
  // Insert event
120
  $id = wp_insert_post( $args );
@@ -123,25 +132,25 @@ if ( class_exists( 'WP_Importer' ) ) {
123
  update_post_meta( $id, '_sp_import', 1 );
124
 
125
  // Update event format
126
- if ( $event_format ):
127
  update_post_meta( $id, 'sp_format', $event_format );
128
  endif;
129
 
130
  // Update league
131
- if ( $league ):
132
  wp_set_object_terms( $id, $league, 'sp_league', false );
133
  endif;
134
 
135
  // Update season
136
- if ( $season ):
137
  wp_set_object_terms( $id, $season, 'sp_season', false );
138
  endif;
139
 
140
  // Update venue
141
  if ( $venue == '' ) {
142
- $team = reset( $teams );
143
  $team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
144
- $venue = sp_get_the_term_id( $team_object->ID, 'sp_venue' );
145
  }
146
  wp_set_object_terms( $id, $venue, 'sp_venue', false );
147
 
@@ -156,30 +165,41 @@ if ( class_exists( 'WP_Importer' ) ) {
156
  endif;
157
 
158
  // Add teams to event
159
- if ( sizeof( $teams ) > 0 ):
160
 
161
- foreach ( $teams as $team_name ):
162
 
163
- if ( '' !== $team_name ):
164
 
165
  // Find out if team exists
166
  $team_object = get_page_by_title( stripslashes( $team_name ), OBJECT, 'sp_team' );
167
 
168
  // Get or insert team
169
- if ( $team_object ):
170
 
171
  // Make sure team is published
172
- if ( $team_object->post_status != 'publish' ):
173
- wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
 
 
 
 
 
174
  endif;
175
 
176
  // Get team ID
177
  $team_id = $team_object->ID;
178
 
179
- else:
180
 
181
  // Insert team
182
- $team_id = wp_insert_post( array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $team_name ) ) );
 
 
 
 
 
 
183
 
184
  // Flag as import
185
  update_post_meta( $team_id, '_sp_import', 1 );
@@ -187,17 +207,17 @@ if ( class_exists( 'WP_Importer' ) ) {
187
  endif;
188
 
189
  // Update league
190
- if ( $league ):
191
  wp_set_object_terms( $team_id, $league, 'sp_league', true );
192
  endif;
193
 
194
  // Update season
195
- if ( $season ):
196
  wp_set_object_terms( $team_id, $season, 'sp_season', true );
197
  endif;
198
 
199
  // Add to event if exists
200
- if ( isset( $id ) ):
201
 
202
  // Add team to event
203
  add_post_meta( $id, 'sp_team', $team_id );
@@ -206,7 +226,7 @@ if ( class_exists( 'WP_Importer' ) ) {
206
  $title = get_the_title( $id );
207
 
208
  // Initialize event name
209
- if ( __( 'Event', 'sportspress' ) === $title ) {
210
  $title = '';
211
  } else {
212
  $title .= ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ';
@@ -217,19 +237,19 @@ if ( class_exists( 'WP_Importer' ) ) {
217
 
218
  // Update event with new name
219
  $post = array(
220
- 'ID' => $id,
221
  'post_title' => $title,
222
- 'post_name' => $id,
223
  );
224
  wp_update_post( $post );
225
 
226
  endif;
227
 
228
- else:
229
 
230
  // Add empty team to event
231
  add_post_meta( $id, 'sp_team', -1 );
232
-
233
  endif;
234
 
235
  endforeach;
@@ -240,7 +260,7 @@ if ( class_exists( 'WP_Importer' ) ) {
240
 
241
  // Show Result
242
  echo '<div class="updated settings-error below-h2"><p>
243
- '.sprintf( __( 'Import complete - imported <strong>%s</strong> events and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
244
  </p></div>';
245
 
246
  $this->import_end();
@@ -250,7 +270,7 @@ if ( class_exists( 'WP_Importer' ) ) {
250
  * Performs post-import cleanup of files and the cache
251
  */
252
  function import_end() {
253
- echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_event') . '">' . __( 'View Fixtures', 'sportspress' ) . '</a>' . '</p>';
254
 
255
  do_action( 'import_end' );
256
  }
@@ -263,9 +283,9 @@ if ( class_exists( 'WP_Importer' ) ) {
263
  */
264
  function greet() {
265
  echo '<div class="narrow">';
266
- echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
267
- echo '<p>' . sprintf( __( 'Fixtures need to be defined with columns in a specific order (4+ columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/fixtures-sample.csv' ) . '</p>';
268
- echo '<p>' . sprintf( __( 'Supports CSV files generated by <a href="%s">LeagueLobster</a>.', 'sportspress' ), 'http://tboy.co/leaguelobster' ) . '</p>';
269
  wp_import_upload_form( 'admin.php?import=sp_fixture_csv&step=1' );
270
  echo '</div>';
271
  }
@@ -281,68 +301,72 @@ if ( class_exists( 'WP_Importer' ) ) {
281
  <table class="form-table">
282
  <tbody>
283
  <tr>
284
- <th scope="row"><label><?php _e( 'Format', 'sportspress' ); ?></label><br/></th>
285
  <td class="forminp forminp-radio" id="sp_formatdiv">
286
  <fieldset id="post-formats-select">
287
  <ul>
288
- <li><input type="radio" name="sp_format" class="post-format" id="post-format-league" value="league" checked="checked"> <label for="post-format-league" class="post-format-icon post-format-league"><?php _e( 'Competitive', 'sportspress' ); ?></label></li>
289
- <li><input type="radio" name="sp_format" class="post-format" id="post-format-friendly" value="friendly"> <label for="post-format-friendly" class="post-format-icon post-format-friendly"><?php _e( 'Friendly', 'sportspress' ); ?></label></li>
290
  <br>
291
  </fieldset>
292
  </td>
293
  </tr>
294
  <tr>
295
- <th scope="row"><label><?php _e( 'League', 'sportspress' ); ?></label><br/></th>
296
- <td><?php
 
297
  $args = array(
298
- 'taxonomy' => 'sp_league',
299
- 'name' => 'sp_league',
300
- 'values' => 'slug',
301
- 'show_option_none' => __( '&mdash; Not set &mdash;', 'sportspress' ),
302
  );
303
- if ( ! sp_dropdown_taxonomies( $args ) ):
304
- echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
305
- sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
306
  endif;
307
- ?></td>
 
308
  </tr>
309
  <tr>
310
- <th scope="row"><label><?php _e( 'Season', 'sportspress' ); ?></label><br/></th>
311
- <td><?php
 
312
  $args = array(
313
- 'taxonomy' => 'sp_season',
314
- 'name' => 'sp_season',
315
- 'values' => 'slug',
316
- 'show_option_none' => __( '&mdash; Not set &mdash;', 'sportspress' ),
317
  );
318
- if ( ! sp_dropdown_taxonomies( $args ) ):
319
- echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
320
- sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
321
  endif;
322
- ?></td>
 
323
  </tr>
324
  <tr>
325
  <th scope="row" class="titledesc">
326
- <?php _e( 'Date Format', 'sportspress' ); ?>
327
  </th>
328
- <td class="forminp forminp-radio">
329
- <fieldset>
330
- <ul>
331
  <li>
332
- <label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
333
- </li>
334
  <li>
335
- <label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
336
- </li>
337
  <li>
338
- <label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
339
- </li>
340
  </ul>
341
- </fieldset>
342
- </td>
343
- </tr>
344
- </tbody>
345
- </table>
346
  <?php
347
  }
348
  }
2
  /**
3
  * Fixture importer - import fixtures into SportsPress.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Importers
8
+ * @version 2.7
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( class_exists( 'WP_Importer' ) ) {
16
  class SP_Fixture_Importer extends SP_Importer {
22
  * @return void
23
  */
24
  public function __construct() {
25
+ $this->import_page = 'sp_fixture_csv';
26
+ $this->import_label = esc_attr__( 'Import Fixtures', 'sportspress' );
27
+ $this->columns = array(
28
+ 'post_date' => esc_attr__( 'Date', 'sportspress' ),
29
+ 'post_time' => esc_attr__( 'Time', 'sportspress' ),
30
+ 'sp_venue' => esc_attr__( 'Venue', 'sportspress' ),
31
+ 'sp_home' => esc_attr__( 'Home', 'sportspress' ),
32
+ 'sp_away' => esc_attr__( 'Away', 'sportspress' ),
33
+ 'sp_day' => esc_attr__( 'Match Day', 'sportspress' ),
34
  );
35
+ $this->optionals = array( 'sp_day' );
36
  }
37
 
38
  /**
46
  function import( $array = array(), $columns = array( 'post_title' ) ) {
47
  $this->imported = $this->skipped = 0;
48
 
49
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
50
  $this->footer();
51
  die();
52
  endif;
54
  $rows = array_chunk( $array, sizeof( $columns ) );
55
 
56
  // Get event format, league, and season from post vars
57
+ $event_format = ( empty( $_POST['sp_format'] ) ? false : sanitize_key( $_POST['sp_format'] ) );
58
+ $league = ( sp_array_value( $_POST, 'sp_league', '-1' ) == '-1' ? false : sanitize_key( $_POST['sp_league'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
59
+ $season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : sanitize_key( $_POST['sp_season'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
60
+ $date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : sanitize_text_field( wp_unslash( $_POST['sp_date_format'] ) ) );
61
 
62
+ foreach ( $rows as $row ) :
63
 
64
  $row = array_filter( $row );
65
 
66
+ if ( empty( $row ) ) {
67
+ continue;
68
+ }
69
 
70
  $meta = array();
71
 
72
+ foreach ( $columns as $index => $key ) :
73
  $meta[ $key ] = sp_array_value( $row, $index );
74
  endforeach;
75
 
87
  );
88
 
89
  // Add new event if date is given
90
+ if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ) :
91
 
92
  // List event columns
93
  list( $date, $time, $venue, $day ) = $event;
94
 
95
  // Format date
96
+ $date = str_replace( '/', '-', trim( $date ) );
97
  $date_array = explode( '-', $date );
98
+ switch ( $date_format ) :
99
  case 'dd/mm/yyyy':
100
  $date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
101
  substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
113
  endswitch;
114
 
115
  // Add time to date if given
116
+ if ( ! empty( $time ) ) :
117
  $date .= ' ' . trim( $time );
118
  endif;
119
 
120
  // Define post type args
121
+ $args = array(
122
+ 'post_type' => 'sp_event',
123
+ 'post_status' => 'publish',
124
+ 'post_date' => $date,
125
+ 'post_title' => esc_attr__( 'Event', 'sportspress' ),
126
+ );
127
 
128
  // Insert event
129
  $id = wp_insert_post( $args );
132
  update_post_meta( $id, '_sp_import', 1 );
133
 
134
  // Update event format
135
+ if ( $event_format ) :
136
  update_post_meta( $id, 'sp_format', $event_format );
137
  endif;
138
 
139
  // Update league
140
+ if ( $league ) :
141
  wp_set_object_terms( $id, $league, 'sp_league', false );
142
  endif;
143
 
144
  // Update season
145
+ if ( $season ) :
146
  wp_set_object_terms( $id, $season, 'sp_season', false );
147
  endif;
148
 
149
  // Update venue
150
  if ( $venue == '' ) {
151
+ $team = reset( $teams );
152
  $team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
153
+ $venue = sp_get_the_term_id( $team_object->ID, 'sp_venue' );
154
  }
155
  wp_set_object_terms( $id, $venue, 'sp_venue', false );
156
 
165
  endif;
166
 
167
  // Add teams to event
168
+ if ( sizeof( $teams ) > 0 ) :
169
 
170
+ foreach ( $teams as $team_name ) :
171
 
172
+ if ( '' !== $team_name ) :
173
 
174
  // Find out if team exists
175
  $team_object = get_page_by_title( stripslashes( $team_name ), OBJECT, 'sp_team' );
176
 
177
  // Get or insert team
178
+ if ( $team_object ) :
179
 
180
  // Make sure team is published
181
+ if ( $team_object->post_status != 'publish' ) :
182
+ wp_update_post(
183
+ array(
184
+ 'ID' => $team_object->ID,
185
+ 'post_status' => 'publish',
186
+ )
187
+ );
188
  endif;
189
 
190
  // Get team ID
191
  $team_id = $team_object->ID;
192
 
193
+ else :
194
 
195
  // Insert team
196
+ $team_id = wp_insert_post(
197
+ array(
198
+ 'post_type' => 'sp_team',
199
+ 'post_status' => 'publish',
200
+ 'post_title' => wp_strip_all_tags( $team_name ),
201
+ )
202
+ );
203
 
204
  // Flag as import
205
  update_post_meta( $team_id, '_sp_import', 1 );
207
  endif;
208
 
209
  // Update league
210
+ if ( $league ) :
211
  wp_set_object_terms( $team_id, $league, 'sp_league', true );
212
  endif;
213
 
214
  // Update season
215
+ if ( $season ) :
216
  wp_set_object_terms( $team_id, $season, 'sp_season', true );
217
  endif;
218
 
219
  // Add to event if exists
220
+ if ( isset( $id ) ) :
221
 
222
  // Add team to event
223
  add_post_meta( $id, 'sp_team', $team_id );
226
  $title = get_the_title( $id );
227
 
228
  // Initialize event name
229
+ if ( esc_attr__( 'Event', 'sportspress' ) === $title ) {
230
  $title = '';
231
  } else {
232
  $title .= ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ';
237
 
238
  // Update event with new name
239
  $post = array(
240
+ 'ID' => $id,
241
  'post_title' => $title,
242
+ 'post_name' => $id,
243
  );
244
  wp_update_post( $post );
245
 
246
  endif;
247
 
248
+ else :
249
 
250
  // Add empty team to event
251
  add_post_meta( $id, 'sp_team', -1 );
252
+
253
  endif;
254
 
255
  endforeach;
260
 
261
  // Show Result
262
  echo '<div class="updated settings-error below-h2"><p>
263
+ ' . sprintf( esc_html__( 'Import complete - imported <strong>%1$s</strong> events and skipped <strong>%2$s</strong>.', 'sportspress' ), esc_html( $this->imported ), esc_html( $this->skipped ) ) . '
264
  </p></div>';
265
 
266
  $this->import_end();
270
  * Performs post-import cleanup of files and the cache
271
  */
272
  function import_end() {
273
+ echo '<p>' . esc_html__( 'All done!', 'sportspress' ) . ' <a href="' . esc_url( admin_url( 'edit.php?post_type=sp_event' ) ) . '">' . esc_html__( 'View Fixtures', 'sportspress' ) . '</a>' . '</p>';
274
 
275
  do_action( 'import_end' );
276
  }
283
  */
284
  function greet() {
285
  echo '<div class="narrow">';
286
+ echo '<p>' . esc_html__( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
287
+ echo '<p>' . sprintf( wp_kses_post( esc_attr__( 'Fixtures need to be defined with columns in a specific order (4+ columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ) ), esc_url( plugin_dir_url( SP_PLUGIN_FILE ) ) . 'dummy-data/fixtures-sample.csv' ) . '</p>';
288
+ echo '<p>' . sprintf( wp_kses_post( esc_attr__( 'Supports CSV files generated by <a href="%s">LeagueLobster</a>.', 'sportspress' ) ), 'http://tboy.co/leaguelobster' ) . '</p>';
289
  wp_import_upload_form( 'admin.php?import=sp_fixture_csv&step=1' );
290
  echo '</div>';
291
  }
301
  <table class="form-table">
302
  <tbody>
303
  <tr>
304
+ <th scope="row"><label><?php esc_html_e( 'Format', 'sportspress' ); ?></label><br/></th>
305
  <td class="forminp forminp-radio" id="sp_formatdiv">
306
  <fieldset id="post-formats-select">
307
  <ul>
308
+ <li><input type="radio" name="sp_format" class="post-format" id="post-format-league" value="league" checked="checked"> <label for="post-format-league" class="post-format-icon post-format-league"><?php esc_html_e( 'Competitive', 'sportspress' ); ?></label></li>
309
+ <li><input type="radio" name="sp_format" class="post-format" id="post-format-friendly" value="friendly"> <label for="post-format-friendly" class="post-format-icon post-format-friendly"><?php esc_html_e( 'Friendly', 'sportspress' ); ?></label></li>
310
  <br>
311
  </fieldset>
312
  </td>
313
  </tr>
314
  <tr>
315
+ <th scope="row"><label><?php esc_html_e( 'League', 'sportspress' ); ?></label><br/></th>
316
+ <td>
317
+ <?php
318
  $args = array(
319
+ 'taxonomy' => 'sp_league',
320
+ 'name' => 'sp_league',
321
+ 'values' => 'slug',
322
+ 'show_option_none' => esc_attr__( '&mdash; Not set &mdash;', 'sportspress' ),
323
  );
324
+ if ( ! sp_dropdown_taxonomies( $args ) ) :
325
+ echo '<p>' . esc_html__( 'None', 'sportspress' ) . '</p>';
326
+ sp_taxonomy_adder( 'sp_league', 'sp_team', esc_attr__( 'Add New', 'sportspress' ) );
327
  endif;
328
+ ?>
329
+ </td>
330
  </tr>
331
  <tr>
332
+ <th scope="row"><label><?php esc_html_e( 'Season', 'sportspress' ); ?></label><br/></th>
333
+ <td>
334
+ <?php
335
  $args = array(
336
+ 'taxonomy' => 'sp_season',
337
+ 'name' => 'sp_season',
338
+ 'values' => 'slug',
339
+ 'show_option_none' => esc_attr__( '&mdash; Not set &mdash;', 'sportspress' ),
340
  );
341
+ if ( ! sp_dropdown_taxonomies( $args ) ) :
342
+ echo '<p>' . esc_html__( 'None', 'sportspress' ) . '</p>';
343
+ sp_taxonomy_adder( 'sp_season', 'sp_team', esc_attr__( 'Add New', 'sportspress' ) );
344
  endif;
345
+ ?>
346
+ </td>
347
  </tr>
348
  <tr>
349
  <th scope="row" class="titledesc">
350
+ <?php esc_html_e( 'Date Format', 'sportspress' ); ?>
351
  </th>
352
+ <td class="forminp forminp-radio">
353
+ <fieldset>
354
+ <ul>
355
  <li>
356
+ <label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
357
+ </li>
358
  <li>
359
+ <label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
360
+ </li>
361
  <li>
362
+ <label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
363
+ </li>
364
  </ul>
365
+ </fieldset>
366
+ </td>
367
+ </tr>
368
+ </tbody>
369
+ </table>
370
  <?php
371
  }
372
  }
includes/admin/importers/class-sp-importer.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * SportsPress Importer
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Importers
8
- * @version 2.6.8
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( class_exists( 'WP_Importer' ) ) {
14
  class SP_Importer extends WP_Importer {
@@ -21,7 +23,7 @@ if ( class_exists( 'WP_Importer' ) ) {
21
  var $imported;
22
  var $skipped;
23
  var $import_label;
24
- var $columns = array();
25
  var $optionals = array();
26
 
27
  /**
@@ -35,7 +37,7 @@ if ( class_exists( 'WP_Importer' ) ) {
35
  * Enqueue scripts
36
  */
37
  public function admin_scripts() {
38
- wp_enqueue_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret' ), SP_VERSION, true );
39
  }
40
 
41
  /**
@@ -46,32 +48,36 @@ if ( class_exists( 'WP_Importer' ) ) {
46
  function dispatch() {
47
  $this->header();
48
 
49
- if ( ! empty( $_POST['delimiter'] ) )
50
- $this->delimiter = stripslashes( trim( $_POST['delimiter'] ) );
 
51
 
52
- if ( ! $this->delimiter )
53
  $this->delimiter = ',';
 
54
 
55
  $step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
56
- switch ( $step ):
57
  case 0:
58
  $this->greet();
59
  break;
60
  case 1:
61
  check_admin_referer( 'import-upload' );
62
- if ( $this->handle_upload() ):
63
 
64
- if ( $this->id )
65
  $file = get_attached_file( $this->id );
66
- else
67
  $file = ABSPATH . $this->file_url;
 
68
 
69
  add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
70
 
71
- if ( function_exists( 'gc_enable' ) )
72
  gc_enable();
 
73
 
74
- @set_time_limit(0);
75
  @ob_flush();
76
  @flush();
77
 
@@ -80,9 +86,9 @@ if ( class_exists( 'WP_Importer' ) ) {
80
  break;
81
  case 2:
82
  check_admin_referer( 'import-upload' );
83
- if ( isset( $_POST['sp_import'] ) ):
84
- $columns = array_filter( sp_array_value( $_POST, 'sp_columns', array( 'post_title' ) ) );
85
- $this->import( $_POST['sp_import'], array_values( $columns ) );
86
  endif;
87
  break;
88
  endswitch;
@@ -98,10 +104,10 @@ if ( class_exists( 'WP_Importer' ) ) {
98
  */
99
  function dropdown( $selected ) {
100
  ?>
101
- <select name="sp_columns[]" data-index="<?php echo array_search( $selected, array_keys( $this->columns ) ); ?>">
102
- <option value="0">&mdash; <?php _e( 'Disable', 'sportspress' ); ?> &mdash;</option>
103
- <?php foreach ( $this->columns as $key => $label ): ?>
104
- <option value="<?php echo $key; ?>" <?php selected( $selected, $key ); ?>><?php echo $label; ?></option>
105
  <?php endforeach; ?>
106
  </select>
107
  <?php
@@ -119,79 +125,93 @@ if ( class_exists( 'WP_Importer' ) ) {
119
 
120
  $this->imported = $this->skipped = 0;
121
 
122
- if ( ! is_file($file) ):
123
  $this->footer();
124
  die();
125
  endif;
126
 
127
  ini_set( 'auto_detect_line_endings', '1' );
128
 
129
- if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ):
130
 
131
  $header = fgetcsv( $handle, 0, $this->delimiter );
132
 
133
- if ( sizeof( $header ) >= 1 ):
134
  $action = 'admin.php?import=' . $this->import_page . '&step=2';
135
  ?>
136
- <form enctype="multipart/form-data" id="import-upload-form" class="sportspress" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
137
  <?php $this->options(); ?>
138
  <table class="wp-list-table sp-data-table sp-import-table widefat fixed pages">
139
  <thead>
140
  <tr>
141
- <?php foreach ( $this->columns as $key => $label ): ?>
142
  <th scope="col" class="manage-column">
143
  <?php $this->dropdown( $key ); ?>
144
  </th>
145
  <?php endforeach; ?>
146
  <th scope="col" class="sp-actions-column">
147
- <a href="#" title="<?php _e( 'Insert row after', 'sportspress' ); ?>" class="dashicons dashicons-plus-alt sp-add-row sp-add-first"></a>
148
  </th>
149
  </tr>
150
  </thead>
151
  <tbody>
152
- <?php while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ): ?>
153
  <tr>
154
- <?php $index = 0; foreach ( $this->columns as $key => $label ): $value = sp_array_value( $row, $index ); ?>
 
 
 
 
155
  <td>
156
- <input type="text" class="widefat" value="<?php echo esc_attr( $value ); ?>" name="sp_import[]"<?php if ( in_array( $key, $this->optionals ) ) { ?> placeholder="<?php _e( 'Default', 'sportspress' ); ?>"<?php } ?>>
 
 
 
 
157
  </td>
158
- <?php $index ++; endforeach; ?>
 
 
 
159
  <td class="sp-actions-column">
160
- <a href="#" title="<?php _e( 'Delete row', 'sportspress' ); ?>" class="dashicons dashicons-dismiss sp-delete-row"></a>
161
- <a href="#" title="<?php _e( 'Insert row after', 'sportspress' ); ?>" class="dashicons dashicons-plus-alt sp-add-row"></a>
162
  </td>
163
  </tr>
164
- <?php $this->imported++; endwhile; ?>
 
 
 
165
  <tr>
166
- <?php foreach ( $this->columns as $key => $label ): ?>
167
  <td>
168
  <input type="text" class="widefat" name="sp_import[]">
169
  </td>
170
  <?php endforeach; ?>
171
  <td class="sp-actions-column">
172
- <a href="#" title="<?php _e( 'Insert row after', 'sportspress' ); ?>" class="dashicons dashicons-plus-alt sp-add-row"></a>
173
  </td>
174
  </tr>
175
- </tbody>
176
  </table>
177
  <p class="sp-post-count alignright">
178
- <?php printf( __( 'Displaying %s&#8211;%s of %s', 'sportspress' ), 1, $this->imported+1, $this->imported+1 ); ?>
179
  </p>
180
  <p class="submit">
181
  <input type="submit" class="button button-primary button-hero" value="<?php echo esc_attr( $this->import_label ); ?>" />
182
  </p>
183
  </form>
184
  <?php
185
- else:
186
 
187
- echo '<p><strong>' . __( 'Sorry, there has been an error.', 'sportspress' ) . '</strong><br />';
188
- _e( 'The CSV is invalid.', 'sportspress' ) . '</p>';
189
  $this->footer();
190
  die();
191
 
192
  endif;
193
 
194
- fclose( $handle );
195
  endif;
196
  }
197
 
@@ -199,7 +219,7 @@ if ( class_exists( 'WP_Importer' ) ) {
199
  * format_data_from_csv function.
200
  *
201
  * @access public
202
- * @param mixed $data
203
  * @param string $enc
204
  * @return string
205
  */
@@ -220,7 +240,7 @@ if ( class_exists( 'WP_Importer' ) ) {
220
  $file = wp_import_handle_upload();
221
 
222
  if ( isset( $file['error'] ) ) {
223
- echo '<p><strong>' . __( 'Sorry, there has been an error.', 'sportspress' ) . '</strong><br />';
224
  echo esc_html( $file['error'] ) . '</p>';
225
  return false;
226
  }
@@ -229,17 +249,16 @@ if ( class_exists( 'WP_Importer' ) ) {
229
 
230
  } else {
231
 
232
- if ( file_exists( ABSPATH . $_POST['file_url'] ) ) {
233
 
234
- $this->file_url = esc_attr( $_POST['file_url'] );
235
 
236
  } else {
237
 
238
- echo '<p><strong>' . __( 'Sorry, there has been an error.', 'sportspress' ) . '</strong></p>';
239
  return false;
240
 
241
  }
242
-
243
  }
244
 
245
  return true;
@@ -252,7 +271,7 @@ if ( class_exists( 'WP_Importer' ) ) {
252
  * @return void
253
  */
254
  function header() {
255
- echo '<div class="wrap"><h2>' . $this->import_label . '</h2>';
256
  }
257
 
258
  /**
@@ -276,6 +295,7 @@ if ( class_exists( 'WP_Importer' ) ) {
276
 
277
  /**
278
  * Added to http_request_timeout filter to force timeout at 60 seconds during import
 
279
  * @param int $val
280
  * @return int 60
281
  */
2
  /**
3
  * SportsPress Importer
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Importers
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( class_exists( 'WP_Importer' ) ) {
16
  class SP_Importer extends WP_Importer {
23
  var $imported;
24
  var $skipped;
25
  var $import_label;
26
+ var $columns = array();
27
  var $optionals = array();
28
 
29
  /**
37
  * Enqueue scripts
38
  */
39
  public function admin_scripts() {
40
+ wp_enqueue_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret' ), SP_VERSION, true );
41
  }
42
 
43
  /**
48
  function dispatch() {
49
  $this->header();
50
 
51
+ if ( ! empty( $_POST['delimiter'] ) ) {
52
+ $this->delimiter = stripslashes( trim( sanitize_text_field( wp_unslash( $_POST['delimiter'] ) ) ) );
53
+ }
54
 
55
+ if ( ! $this->delimiter ) {
56
  $this->delimiter = ',';
57
+ }
58
 
59
  $step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
60
+ switch ( $step ) :
61
  case 0:
62
  $this->greet();
63
  break;
64
  case 1:
65
  check_admin_referer( 'import-upload' );
66
+ if ( $this->handle_upload() ) :
67
 
68
+ if ( $this->id ) {
69
  $file = get_attached_file( $this->id );
70
+ } else {
71
  $file = ABSPATH . $this->file_url;
72
+ }
73
 
74
  add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
75
 
76
+ if ( function_exists( 'gc_enable' ) ) {
77
  gc_enable();
78
+ }
79
 
80
+ @set_time_limit( 0 );
81
  @ob_flush();
82
  @flush();
83
 
86
  break;
87
  case 2:
88
  check_admin_referer( 'import-upload' );
89
+ if ( isset( $_POST['sp_import'] ) ) :
90
+ $columns = array_filter( array_map( 'sanitize_key', array_map( 'wp_unslash', sp_array_value( $_POST, 'sp_columns', array( 'post_title' ) ) ) ) );
91
+ $this->import( $_POST['sp_import'], array_values( $columns ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
92
  endif;
93
  break;
94
  endswitch;
104
  */
105
  function dropdown( $selected ) {
106
  ?>
107
+ <select name="sp_columns[]" data-index="<?php echo esc_attr( array_search( $selected, array_keys( $this->columns ) ) ); ?>">
108
+ <option value="0">&mdash; <?php esc_html_e( 'Disable', 'sportspress' ); ?> &mdash;</option>
109
+ <?php foreach ( $this->columns as $key => $label ) : ?>
110
+ <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $selected, $key ); ?>><?php echo esc_html( $label ); ?></option>
111
  <?php endforeach; ?>
112
  </select>
113
  <?php
125
 
126
  $this->imported = $this->skipped = 0;
127
 
128
+ if ( ! is_file( $file ) ) :
129
  $this->footer();
130
  die();
131
  endif;
132
 
133
  ini_set( 'auto_detect_line_endings', '1' );
134
 
135
+ if ( ( $handle = fopen( $file, 'r' ) ) !== false ) :
136
 
137
  $header = fgetcsv( $handle, 0, $this->delimiter );
138
 
139
+ if ( sizeof( $header ) >= 1 ) :
140
  $action = 'admin.php?import=' . $this->import_page . '&step=2';
141
  ?>
142
+ <form enctype="multipart/form-data" id="import-upload-form" class="sportspress" method="post" action="<?php echo esc_attr( wp_nonce_url( $action, 'import-upload' ) ); ?>">
143
  <?php $this->options(); ?>
144
  <table class="wp-list-table sp-data-table sp-import-table widefat fixed pages">
145
  <thead>
146
  <tr>
147
+ <?php foreach ( $this->columns as $key => $label ) : ?>
148
  <th scope="col" class="manage-column">
149
  <?php $this->dropdown( $key ); ?>
150
  </th>
151
  <?php endforeach; ?>
152
  <th scope="col" class="sp-actions-column">
153
+ <a href="#" title="<?php esc_attr_e( 'Insert row after', 'sportspress' ); ?>" class="dashicons dashicons-plus-alt sp-add-row sp-add-first"></a>
154
  </th>
155
  </tr>
156
  </thead>
157
  <tbody>
158
+ <?php while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== false ) : ?>
159
  <tr>
160
+ <?php
161
+ $index = 0;
162
+ foreach ( $this->columns as $key => $label ) :
163
+ $value = sp_array_value( $row, $index );
164
+ ?>
165
  <td>
166
+ <input type="text" class="widefat" value="<?php echo esc_attr( $value ); ?>" name="sp_import[]"
167
+ <?php
168
+ if ( in_array( $key, $this->optionals ) ) {
169
+ ?>
170
+ placeholder="<?php esc_attr_e( 'Default', 'sportspress' ); ?>"<?php } ?>>
171
  </td>
172
+ <?php
173
+ $index ++;
174
+ endforeach;
175
+ ?>
176
  <td class="sp-actions-column">
177
+ <a href="#" title="<?php esc_attr_e( 'Delete row', 'sportspress' ); ?>" class="dashicons dashicons-dismiss sp-delete-row"></a>
178
+ <a href="#" title="<?php esc_attr_e( 'Insert row after', 'sportspress' ); ?>" class="dashicons dashicons-plus-alt sp-add-row"></a>
179
  </td>
180
  </tr>
181
+ <?php
182
+ $this->imported++;
183
+ endwhile;
184
+ ?>
185
  <tr>
186
+ <?php foreach ( $this->columns as $key => $label ) : ?>
187
  <td>
188
  <input type="text" class="widefat" name="sp_import[]">
189
  </td>
190
  <?php endforeach; ?>
191
  <td class="sp-actions-column">
192
+ <a href="#" title="<?php esc_attr_e( 'Insert row after', 'sportspress' ); ?>" class="dashicons dashicons-plus-alt sp-add-row"></a>
193
  </td>
194
  </tr>
195
+ </tbody>
196
  </table>
197
  <p class="sp-post-count alignright">
198
+ <?php printf( esc_html__( 'Displaying %1$s&#8211;%2$s of %3$s', 'sportspress' ), 1, esc_html( $this->imported + 1 ), esc_html( $this->imported + 1 ) ); ?>
199
  </p>
200
  <p class="submit">
201
  <input type="submit" class="button button-primary button-hero" value="<?php echo esc_attr( $this->import_label ); ?>" />
202
  </p>
203
  </form>
204
  <?php
205
+ else :
206
 
207
+ echo '<p><strong>' . esc_html__( 'Sorry, there has been an error.', 'sportspress' ) . '</strong><br />';
208
+ esc_html_e( 'The CSV is invalid.', 'sportspress' ) . '</p>';
209
  $this->footer();
210
  die();
211
 
212
  endif;
213
 
214
+ fclose( $handle );
215
  endif;
216
  }
217
 
219
  * format_data_from_csv function.
220
  *
221
  * @access public
222
+ * @param mixed $data
223
  * @param string $enc
224
  * @return string
225
  */
240
  $file = wp_import_handle_upload();
241
 
242
  if ( isset( $file['error'] ) ) {
243
+ echo '<p><strong>' . esc_html__( 'Sorry, there has been an error.', 'sportspress' ) . '</strong><br />';
244
  echo esc_html( $file['error'] ) . '</p>';
245
  return false;
246
  }
249
 
250
  } else {
251
 
252
+ if ( file_exists( ABSPATH . sanitize_url( wp_unslash( $_POST['file_url'] ) ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
253
 
254
+ $this->file_url = sanitize_url( wp_unslash( $_POST['file_url'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
255
 
256
  } else {
257
 
258
+ echo '<p><strong>' . esc_html__( 'Sorry, there has been an error.', 'sportspress' ) . '</strong></p>';
259
  return false;
260
 
261
  }
 
262
  }
263
 
264
  return true;
271
  * @return void
272
  */
273
  function header() {
274
+ echo '<div class="wrap"><h2>' . esc_html( $this->import_label ) . '</h2>';
275
  }
276
 
277
  /**
295
 
296
  /**
297
  * Added to http_request_timeout filter to force timeout at 60 seconds during import
298
+ *
299
  * @param int $val
300
  * @return int 60
301
  */
includes/admin/importers/class-sp-official-importer.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Official importer - import officials into SportsPress.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Importers
8
- * @version 2.5.1
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( class_exists( 'WP_Importer' ) ) {
14
  class SP_Official_Importer extends SP_Importer {
@@ -20,10 +22,10 @@ if ( class_exists( 'WP_Importer' ) ) {
20
  * @return void
21
  */
22
  public function __construct() {
23
- $this->import_page = 'sp_official_csv';
24
- $this->import_label = __( 'Import Officials', 'sportspress' );
25
- $this->columns = array(
26
- 'post_title' => __( 'Name', 'sportspress' ),
27
  );
28
  parent::__construct();
29
  }
@@ -39,33 +41,39 @@ if ( class_exists( 'WP_Importer' ) ) {
39
  function import( $array = array(), $columns = array( 'post_title' ) ) {
40
  $this->imported = $this->skipped = 0;
41
 
42
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
43
  $this->footer();
44
  die();
45
  endif;
46
 
47
  $rows = array_chunk( $array, sizeof( $columns ) );
48
 
49
- foreach ( $rows as $row ):
50
 
51
  $row = array_filter( $row );
52
 
53
- if ( empty( $row ) ) continue;
 
 
54
 
55
  $meta = array();
56
 
57
- foreach ( $columns as $index => $key ):
58
  $meta[ $key ] = sp_array_value( $row, $index );
59
  endforeach;
60
 
61
  $name = sp_array_value( $meta, 'post_title' );
62
 
63
- if ( ! $name ):
64
  $this->skipped++;
65
  continue;
66
  endif;
67
 
68
- $args = array( 'post_type' => 'sp_official', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
 
 
 
 
69
 
70
  $id = wp_insert_post( $args );
71
 
@@ -75,7 +83,7 @@ if ( class_exists( 'WP_Importer' ) ) {
75
 
76
  // Show Result
77
  echo '<div class="updated settings-error below-h2"><p>
78
- '.sprintf( __( 'Import complete - imported <strong>%s</strong> officials and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
79
  </p></div>';
80
 
81
  $this->import_end();
@@ -85,7 +93,7 @@ if ( class_exists( 'WP_Importer' ) ) {
85
  * Performs post-import cleanup of files and the cache
86
  */
87
  function import_end() {
88
- echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_official') . '">' . __( 'View Officials', 'sportspress' ) . '</a>' . '</p>';
89
 
90
  do_action( 'import_end' );
91
  }
@@ -97,7 +105,7 @@ if ( class_exists( 'WP_Importer' ) ) {
97
  * @return void
98
  */
99
  function header() {
100
- echo '<div class="wrap"><h2>' . __( 'Import Officials', 'sportspress' ) . '</h2>';
101
  }
102
 
103
  /**
@@ -108,8 +116,8 @@ if ( class_exists( 'WP_Importer' ) ) {
108
  */
109
  function greet() {
110
  echo '<div class="narrow">';
111
- echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
112
- echo '<p>' . sprintf( __( 'Officials need to be defined with columns in a specific order. <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/officials-sample.csv' ) . '</p>';
113
  wp_import_upload_form( 'admin.php?import=sp_official_csv&step=1' );
114
  echo '</div>';
115
  }
2
  /**
3
  * Official importer - import officials into SportsPress.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Importers
8
+ * @version 2.5.1
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( class_exists( 'WP_Importer' ) ) {
16
  class SP_Official_Importer extends SP_Importer {
22
  * @return void
23
  */
24
  public function __construct() {
25
+ $this->import_page = 'sp_official_csv';
26
+ $this->import_label = esc_attr__( 'Import Officials', 'sportspress' );
27
+ $this->columns = array(
28
+ 'post_title' => esc_attr__( 'Name', 'sportspress' ),
29
  );
30
  parent::__construct();
31
  }
41
  function import( $array = array(), $columns = array( 'post_title' ) ) {
42
  $this->imported = $this->skipped = 0;
43
 
44
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
45
  $this->footer();
46
  die();
47
  endif;
48
 
49
  $rows = array_chunk( $array, sizeof( $columns ) );
50
 
51
+ foreach ( $rows as $row ) :
52
 
53
  $row = array_filter( $row );
54
 
55
+ if ( empty( $row ) ) {
56
+ continue;
57
+ }
58
 
59
  $meta = array();
60
 
61
+ foreach ( $columns as $index => $key ) :
62
  $meta[ $key ] = sp_array_value( $row, $index );
63
  endforeach;
64
 
65
  $name = sp_array_value( $meta, 'post_title' );
66
 
67
+ if ( ! $name ) :
68
  $this->skipped++;
69
  continue;
70
  endif;
71
 
72
+ $args = array(
73
+ 'post_type' => 'sp_official',
74
+ 'post_status' => 'publish',
75
+ 'post_title' => wp_strip_all_tags( $name ),
76
+ );
77
 
78
  $id = wp_insert_post( $args );
79
 
83
 
84
  // Show Result
85
  echo '<div class="updated settings-error below-h2"><p>
86
+ ' . sprintf( esc_html__( 'Import complete - imported <strong>%1$s</strong> officials and skipped <strong>%2$s</strong>.', 'sportspress' ), esc_html( $this->imported ), esc_html( $this->skipped ) ) . '
87
  </p></div>';
88
 
89
  $this->import_end();
93
  * Performs post-import cleanup of files and the cache
94
  */
95
  function import_end() {
96
+ echo '<p>' . esc_html__( 'All done!', 'sportspress' ) . ' <a href="' . esc_url( admin_url( 'edit.php?post_type=sp_official' ) ) . '">' . esc_html__( 'View Officials', 'sportspress' ) . '</a>' . '</p>';
97
 
98
  do_action( 'import_end' );
99
  }
105
  * @return void
106
  */
107
  function header() {
108
+ echo '<div class="wrap"><h2>' . esc_html__( 'Import Officials', 'sportspress' ) . '</h2>';
109
  }
110
 
111
  /**
116
  */
117
  function greet() {
118
  echo '<div class="narrow">';
119
+ echo '<p>' . esc_html__( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
120
+ echo '<p>' . sprintf( wp_kses_post( esc_attr__( 'Officials need to be defined with columns in a specific order. <a href="%s">Click here to download a sample</a>.', 'sportspress' ) ), esc_url( plugin_dir_url( SP_PLUGIN_FILE ) ) . 'dummy-data/officials-sample.csv' ) . '</p>';
121
  wp_import_upload_form( 'admin.php?import=sp_official_csv&step=1' );
122
  echo '</div>';
123
  }
includes/admin/importers/class-sp-player-importer.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Player importer - import players into SportsPress.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Importers
8
  * @version 2.7
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( class_exists( 'WP_Importer' ) ) {
14
  class SP_Player_Importer extends SP_Importer {
@@ -20,17 +22,17 @@ if ( class_exists( 'WP_Importer' ) ) {
20
  * @return void
21
  */
22
  public function __construct() {
23
- $this->import_page = 'sp_player_csv';
24
- $this->import_label = __( 'Import Players', 'sportspress' );
25
- $this->columns = array(
26
- 'sp_number' => __( 'Squad Number', 'sportspress' ),
27
- 'post_title' => __( 'Name', 'sportspress' ),
28
- 'sp_position' => __( 'Positions', 'sportspress' ),
29
- 'sp_team' => __( 'Teams', 'sportspress' ),
30
- 'sp_league' => __( 'Leagues', 'sportspress' ),
31
- 'sp_season' => __( 'Seasons', 'sportspress' ),
32
- 'sp_nationality' => __( 'Nationality', 'sportspress' ),
33
- 'post_date' => __( 'Date of Birth', 'sportspress' ),
34
  );
35
  parent::__construct();
36
  }
@@ -46,21 +48,23 @@ if ( class_exists( 'WP_Importer' ) ) {
46
  function import( $array = array(), $columns = array( 'post_title' ) ) {
47
  $this->imported = $this->skipped = 0;
48
 
49
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
50
  $this->footer();
51
  die();
52
  endif;
53
 
54
  $rows = array_chunk( $array, sizeof( $columns ) );
55
-
56
  // Get Date of Birth format from post vars
57
- $date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : $_POST['sp_date_format'] );
58
 
59
- foreach ( $rows as $row ):
60
 
61
  $row = array_filter( $row, 'strlen' );
62
 
63
- if ( empty( $row ) ) continue;
 
 
64
 
65
  $meta = array();
66
 
@@ -76,17 +80,17 @@ if ( class_exists( 'WP_Importer' ) ) {
76
  $meta[ $p ] = '';
77
  }
78
 
79
- foreach ( $columns as $index => $key ):
80
  $meta[ $key ] = sp_array_value( $row, $index );
81
  endforeach;
82
 
83
  $name = sp_array_value( $meta, 'post_title' );
84
  $date = sp_array_value( $meta, 'post_date' );
85
-
86
  // Format date of birth
87
- $date = str_replace( '/', '-', trim( $date ) );
88
  $date_array = explode( '-', $date );
89
- switch ( $date_format ):
90
  case 'dd/mm/yyyy':
91
  $date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
92
  substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
@@ -103,28 +107,37 @@ if ( class_exists( 'WP_Importer' ) ) {
103
  substr( str_pad( sp_array_value( $date_array, 2, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 );
104
  endswitch;
105
 
106
- if ( ! $name ):
107
  $this->skipped++;
108
  continue;
109
  endif;
110
 
111
  // Get or insert player
112
  $player_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_player' ) : false;
113
- if ( $player_object ):
114
- if ( $player_object->post_status != 'publish' ):
115
- wp_update_post( array( 'ID' => $player_object->ID, 'post_status' => 'publish' ) );
 
 
 
 
 
116
  endif;
117
  $id = $player_object->ID;
118
  // Handle preservable data.
119
  foreach ( $preservable_metas_keys as $p ) {
120
- $terms = wp_get_object_terms( $id, $p, array( 'fields' => 'names' ) );
121
  $meta[ $p ] .= '|' . implode( '|', $terms );
122
  }
123
- else:
124
- $args = array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
 
 
 
 
125
  // Check if a DoB was set
126
- if( '0000-00-00' !== $date ){
127
- $args['post_date'] = $date;
128
  }
129
  $id = wp_insert_post( $args );
130
 
@@ -148,18 +161,29 @@ if ( class_exists( 'WP_Importer' ) ) {
148
  wp_set_object_terms( $id, $seasons, 'sp_season', false );
149
 
150
  // Update teams
151
- $teams = (array)explode( '|', sp_array_value( $meta, 'sp_team' ) );
152
- $i = 0;
153
- foreach ( $teams as $team ):
154
  // Get or insert team
155
  $team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
156
- if ( $team_object ):
157
- if ( $team_object->post_status != 'publish' ):
158
- wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
 
 
 
 
 
159
  endif;
160
  $team_id = $team_object->ID;
161
- else:
162
- $team_id = wp_insert_post( array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $team ) ) );
 
 
 
 
 
 
163
  // Flag as import
164
  update_post_meta( $team_id, '_sp_import', 1 );
165
  wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
@@ -170,7 +194,7 @@ if ( class_exists( 'WP_Importer' ) ) {
170
  add_post_meta( $id, 'sp_team', $team_id );
171
 
172
  // Update current team if first in array, otherwise use as past team
173
- if ( $i == 0 ):
174
  update_post_meta( $id, 'sp_current_team', $team_id );
175
  else :
176
  add_post_meta( $id, 'sp_past_team', $team_id );
@@ -181,7 +205,9 @@ if ( class_exists( 'WP_Importer' ) ) {
181
 
182
  // Update nationality
183
  $nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
184
- if ( $nationality == '*' ) $nationality = '';
 
 
185
  update_post_meta( $id, 'sp_nationality', $nationality );
186
 
187
  $this->imported++;
@@ -190,7 +216,7 @@ if ( class_exists( 'WP_Importer' ) ) {
190
 
191
  // Show Result
192
  echo '<div class="updated settings-error below-h2"><p>
193
- '.sprintf( __( 'Import complete - imported <strong>%s</strong> players and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
194
  </p></div>';
195
 
196
  $this->import_end();
@@ -200,7 +226,7 @@ if ( class_exists( 'WP_Importer' ) ) {
200
  * Performs post-import cleanup of files and the cache
201
  */
202
  function import_end() {
203
- echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_player') . '">' . __( 'View Players', 'sportspress' ) . '</a>' . '</p>';
204
 
205
  do_action( 'import_end' );
206
  }
@@ -212,7 +238,7 @@ if ( class_exists( 'WP_Importer' ) ) {
212
  * @return void
213
  */
214
  function header() {
215
- echo '<div class="wrap"><h2>' . __( 'Import Players', 'sportspress' ) . '</h2>';
216
  }
217
 
218
  /**
@@ -223,8 +249,8 @@ if ( class_exists( 'WP_Importer' ) ) {
223
  */
224
  function greet() {
225
  echo '<div class="narrow">';
226
- echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
227
- echo '<p>' . sprintf( __( 'Players need to be defined with columns in a specific order (8 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/players-sample.csv' ) . '</p>';
228
  wp_import_upload_form( 'admin.php?import=sp_player_csv&step=1' );
229
  echo '</div>';
230
  }
@@ -241,30 +267,30 @@ if ( class_exists( 'WP_Importer' ) ) {
241
  <tbody>
242
  <tr>
243
  <th scope="row" class="titledesc">
244
- <?php _e( 'Date of Birth Format', 'sportspress' ); ?>
245
  </th>
246
- <td class="forminp forminp-radio">
247
- <fieldset>
248
- <ul>
249
  <li>
250
- <label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
251
- </li>
252
  <li>
253
- <label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
254
- </li>
255
  <li>
256
- <label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
257
- </li>
258
  </ul>
259
- </fieldset>
260
- </td>
261
- </tr>
262
  <tr>
263
  <td>
264
  <label>
265
  <input type="hidden" name="merge" value="0">
266
  <input type="checkbox" name="merge" value="1" checked="checked">
267
- <?php _e( 'Merge duplicates', 'sportspress' ); ?>
268
  </label>
269
  </td>
270
  </tr>
2
  /**
3
  * Player importer - import players into SportsPress.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Importers
8
  * @version 2.7
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( class_exists( 'WP_Importer' ) ) {
16
  class SP_Player_Importer extends SP_Importer {
22
  * @return void
23
  */
24
  public function __construct() {
25
+ $this->import_page = 'sp_player_csv';
26
+ $this->import_label = esc_attr__( 'Import Players', 'sportspress' );
27
+ $this->columns = array(
28
+ 'sp_number' => esc_attr__( 'Squad Number', 'sportspress' ),
29
+ 'post_title' => esc_attr__( 'Name', 'sportspress' ),
30
+ 'sp_position' => esc_attr__( 'Positions', 'sportspress' ),
31
+ 'sp_team' => esc_attr__( 'Teams', 'sportspress' ),
32
+ 'sp_league' => esc_attr__( 'Leagues', 'sportspress' ),
33
+ 'sp_season' => esc_attr__( 'Seasons', 'sportspress' ),
34
+ 'sp_nationality' => esc_attr__( 'Nationality', 'sportspress' ),
35
+ 'post_date' => esc_attr__( 'Date of Birth', 'sportspress' ),
36
  );
37
  parent::__construct();
38
  }
48
  function import( $array = array(), $columns = array( 'post_title' ) ) {
49
  $this->imported = $this->skipped = 0;
50
 
51
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
52
  $this->footer();
53
  die();
54
  endif;
55
 
56
  $rows = array_chunk( $array, sizeof( $columns ) );
57
+
58
  // Get Date of Birth format from post vars
59
+ $date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : sanitize_text_field( wp_unslash( $_POST['sp_date_format'] ) ) );
60
 
61
+ foreach ( $rows as $row ) :
62
 
63
  $row = array_filter( $row, 'strlen' );
64
 
65
+ if ( empty( $row ) ) {
66
+ continue;
67
+ }
68
 
69
  $meta = array();
70
 
80
  $meta[ $p ] = '';
81
  }
82
 
83
+ foreach ( $columns as $index => $key ) :
84
  $meta[ $key ] = sp_array_value( $row, $index );
85
  endforeach;
86
 
87
  $name = sp_array_value( $meta, 'post_title' );
88
  $date = sp_array_value( $meta, 'post_date' );
89
+
90
  // Format date of birth
91
+ $date = str_replace( '/', '-', trim( $date ) );
92
  $date_array = explode( '-', $date );
93
+ switch ( $date_format ) :
94
  case 'dd/mm/yyyy':
95
  $date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
96
  substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
107
  substr( str_pad( sp_array_value( $date_array, 2, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 );
108
  endswitch;
109
 
110
+ if ( ! $name ) :
111
  $this->skipped++;
112
  continue;
113
  endif;
114
 
115
  // Get or insert player
116
  $player_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_player' ) : false;
117
+ if ( $player_object ) :
118
+ if ( $player_object->post_status != 'publish' ) :
119
+ wp_update_post(
120
+ array(
121
+ 'ID' => $player_object->ID,
122
+ 'post_status' => 'publish',
123
+ )
124
+ );
125
  endif;
126
  $id = $player_object->ID;
127
  // Handle preservable data.
128
  foreach ( $preservable_metas_keys as $p ) {
129
+ $terms = wp_get_object_terms( $id, $p, array( 'fields' => 'names' ) );
130
  $meta[ $p ] .= '|' . implode( '|', $terms );
131
  }
132
+ else :
133
+ $args = array(
134
+ 'post_type' => 'sp_player',
135
+ 'post_status' => 'publish',
136
+ 'post_title' => wp_strip_all_tags( $name ),
137
+ );
138
  // Check if a DoB was set
139
+ if ( '0000-00-00' !== $date ) {
140
+ $args['post_date'] = $date;
141
  }
142
  $id = wp_insert_post( $args );
143
 
161
  wp_set_object_terms( $id, $seasons, 'sp_season', false );
162
 
163
  // Update teams
164
+ $teams = (array) explode( '|', sp_array_value( $meta, 'sp_team' ) );
165
+ $i = 0;
166
+ foreach ( $teams as $team ) :
167
  // Get or insert team
168
  $team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
169
+ if ( $team_object ) :
170
+ if ( $team_object->post_status != 'publish' ) :
171
+ wp_update_post(
172
+ array(
173
+ 'ID' => $team_object->ID,
174
+ 'post_status' => 'publish',
175
+ )
176
+ );
177
  endif;
178
  $team_id = $team_object->ID;
179
+ else :
180
+ $team_id = wp_insert_post(
181
+ array(
182
+ 'post_type' => 'sp_team',
183
+ 'post_status' => 'publish',
184
+ 'post_title' => wp_strip_all_tags( $team ),
185
+ )
186
+ );
187
  // Flag as import
188
  update_post_meta( $team_id, '_sp_import', 1 );
189
  wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
194
  add_post_meta( $id, 'sp_team', $team_id );
195
 
196
  // Update current team if first in array, otherwise use as past team
197
+ if ( $i == 0 ) :
198
  update_post_meta( $id, 'sp_current_team', $team_id );
199
  else :
200
  add_post_meta( $id, 'sp_past_team', $team_id );
205
 
206
  // Update nationality
207
  $nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
208
+ if ( $nationality == '*' ) {
209
+ $nationality = '';
210
+ }
211
  update_post_meta( $id, 'sp_nationality', $nationality );
212
 
213
  $this->imported++;
216
 
217
  // Show Result
218
  echo '<div class="updated settings-error below-h2"><p>
219
+ ' . sprintf( esc_html__( 'Import complete - imported <strong>%1$s</strong> players and skipped <strong>%2$s</strong>.', 'sportspress' ), esc_html( $this->imported ), esc_html( $this->skipped ) ) . '
220
  </p></div>';
221
 
222
  $this->import_end();
226
  * Performs post-import cleanup of files and the cache
227
  */
228
  function import_end() {
229
+ echo '<p>' . esc_html__( 'All done!', 'sportspress' ) . ' <a href="' . esc_url( admin_url( 'edit.php?post_type=sp_player' ) ) . '">' . esc_html__( 'View Players', 'sportspress' ) . '</a>' . '</p>';
230
 
231
  do_action( 'import_end' );
232
  }
238
  * @return void
239
  */
240
  function header() {
241
+ echo '<div class="wrap"><h2>' . esc_html__( 'Import Players', 'sportspress' ) . '</h2>';
242
  }
243
 
244
  /**
249
  */
250
  function greet() {
251
  echo '<div class="narrow">';
252
+ echo '<p>' . esc_html__( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
253
+ echo '<p>' . sprintf( wp_kses_post( esc_attr__( 'Players need to be defined with columns in a specific order (8 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ) ), esc_url( plugin_dir_url( SP_PLUGIN_FILE ) ) . 'dummy-data/players-sample.csv' ) . '</p>';
254
  wp_import_upload_form( 'admin.php?import=sp_player_csv&step=1' );
255
  echo '</div>';
256
  }
267
  <tbody>
268
  <tr>
269
  <th scope="row" class="titledesc">
270
+ <?php esc_html_e( 'Date of Birth Format', 'sportspress' ); ?>
271
  </th>
272
+ <td class="forminp forminp-radio">
273
+ <fieldset>
274
+ <ul>
275
  <li>
276
+ <label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
277
+ </li>
278
  <li>
279
+ <label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
280
+ </li>
281
  <li>
282
+ <label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
283
+ </li>
284
  </ul>
285
+ </fieldset>
286
+ </td>
287
+ </tr>
288
  <tr>
289
  <td>
290
  <label>
291
  <input type="hidden" name="merge" value="0">
292
  <input type="checkbox" name="merge" value="1" checked="checked">
293
+ <?php esc_html_e( 'Merge duplicates', 'sportspress' ); ?>
294
  </label>
295
  </td>
296
  </tr>
includes/admin/importers/class-sp-staff-importer.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Staff importer - import staff into SportsPress.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Importers
8
- * @version 2.5.5
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( class_exists( 'WP_Importer' ) ) {
14
  class SP_Staff_Importer extends SP_Importer {
@@ -20,15 +22,15 @@ if ( class_exists( 'WP_Importer' ) ) {
20
  * @return void
21
  */
22
  public function __construct() {
23
- $this->import_page = 'sp_staff_csv';
24
- $this->import_label = __( 'Import Staff', 'sportspress' );
25
- $this->columns = array(
26
- 'post_title' => __( 'Name', 'sportspress' ),
27
- 'sp_role' => __( 'Jobs', 'sportspress' ),
28
- 'sp_team' => __( 'Teams', 'sportspress' ),
29
- 'sp_league' => __( 'Leagues', 'sportspress' ),
30
- 'sp_season' => __( 'Seasons', 'sportspress' ),
31
- 'sp_nationality' => __( 'Nationality', 'sportspress' ),
32
  );
33
  parent::__construct();
34
  }
@@ -44,42 +46,53 @@ if ( class_exists( 'WP_Importer' ) ) {
44
  function import( $array = array(), $columns = array( 'post_title' ) ) {
45
  $this->imported = $this->skipped = 0;
46
 
47
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
48
  $this->footer();
49
  die();
50
  endif;
51
 
52
  $rows = array_chunk( $array, sizeof( $columns ) );
53
 
54
- foreach ( $rows as $row ):
55
 
56
  $row = array_filter( $row );
57
 
58
- if ( empty( $row ) ) continue;
 
 
59
 
60
  $meta = array();
61
 
62
- foreach ( $columns as $index => $key ):
63
  $meta[ $key ] = sp_array_value( $row, $index );
64
  endforeach;
65
 
66
  $name = sp_array_value( $meta, 'post_title' );
67
 
68
- if ( ! $name ):
69
  $this->skipped++;
70
  continue;
71
  endif;
72
 
73
  // Get or insert staff
74
  $staff_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_staff' ) : false;
75
- if ( $staff_object ):
76
- if ( $staff_object->post_status != 'publish' ):
77
- wp_update_post( array( 'ID' => $staff_object->ID, 'post_status' => 'publish' ) );
 
 
 
 
 
78
  endif;
79
  $id = $staff_object->ID;
80
- else:
81
- $args = array( 'post_type' => 'sp_staff', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
82
- $id = wp_insert_post( $args );
 
 
 
 
83
 
84
  // Flag as import
85
  update_post_meta( $id, '_sp_import', 1 );
@@ -98,18 +111,29 @@ if ( class_exists( 'WP_Importer' ) ) {
98
  wp_set_object_terms( $id, $seasons, 'sp_season', false );
99
 
100
  // Update teams
101
- $teams = (array)explode( '|', sp_array_value( $meta, 'sp_team' ) );
102
- $i = 0;
103
- foreach ( $teams as $team ):
104
  // Get or insert team
105
  $team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
106
- if ( $team_object ):
107
- if ( $team_object->post_status != 'publish' ):
108
- wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
 
 
 
 
 
109
  endif;
110
  $team_id = $team_object->ID;
111
- else:
112
- $team_id = wp_insert_post( array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $team ) ) );
 
 
 
 
 
 
113
  // Flag as import
114
  update_post_meta( $team_id, '_sp_import', 1 );
115
  wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
@@ -120,7 +144,7 @@ if ( class_exists( 'WP_Importer' ) ) {
120
  add_post_meta( $id, 'sp_team', $team_id );
121
 
122
  // Update current team if first in array
123
- if ( $i == 0 ):
124
  update_post_meta( $id, 'sp_current_team', $team_id );
125
  endif;
126
 
@@ -129,7 +153,9 @@ if ( class_exists( 'WP_Importer' ) ) {
129
 
130
  // Update nationality
131
  $nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
132
- if ( $nationality == '*' ) $nationality = '';
 
 
133
  update_post_meta( $id, 'sp_nationality', $nationality );
134
 
135
  $this->imported++;
@@ -138,7 +164,7 @@ if ( class_exists( 'WP_Importer' ) ) {
138
 
139
  // Show Result
140
  echo '<div class="updated settings-error below-h2"><p>
141
- '.sprintf( __( 'Import complete - imported <strong>%s</strong> staff and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
142
  </p></div>';
143
 
144
  $this->import_end();
@@ -148,7 +174,7 @@ if ( class_exists( 'WP_Importer' ) ) {
148
  * Performs post-import cleanup of files and the cache
149
  */
150
  function import_end() {
151
- echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_staff') . '">' . __( 'View Staff', 'sportspress' ) . '</a>' . '</p>';
152
 
153
  do_action( 'import_end' );
154
  }
@@ -160,7 +186,7 @@ if ( class_exists( 'WP_Importer' ) ) {
160
  * @return void
161
  */
162
  function header() {
163
- echo '<div class="wrap"><h2>' . __( 'Import Staff', 'sportspress' ) . '</h2>';
164
  }
165
 
166
  /**
@@ -171,8 +197,8 @@ if ( class_exists( 'WP_Importer' ) ) {
171
  */
172
  function greet() {
173
  echo '<div class="narrow">';
174
- echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
175
- echo '<p>' . sprintf( __( 'Staff need to be defined with columns in a specific order (6 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/staff-sample.csv' ) . '</p>';
176
  wp_import_upload_form( 'admin.php?import=sp_staff_csv&step=1' );
177
  echo '</div>';
178
  }
@@ -192,7 +218,7 @@ if ( class_exists( 'WP_Importer' ) ) {
192
  <label>
193
  <input type="hidden" name="merge" value="0">
194
  <input type="checkbox" name="merge" value="1" checked="checked">
195
- <?php _e( 'Merge duplicates', 'sportspress' ); ?>
196
  </label>
197
  </td>
198
  </tr>
2
  /**
3
  * Staff importer - import staff into SportsPress.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Importers
8
+ * @version 2.5.5
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( class_exists( 'WP_Importer' ) ) {
16
  class SP_Staff_Importer extends SP_Importer {
22
  * @return void
23
  */
24
  public function __construct() {
25
+ $this->import_page = 'sp_staff_csv';
26
+ $this->import_label = esc_attr__( 'Import Staff', 'sportspress' );
27
+ $this->columns = array(
28
+ 'post_title' => esc_attr__( 'Name', 'sportspress' ),
29
+ 'sp_role' => esc_attr__( 'Jobs', 'sportspress' ),
30
+ 'sp_team' => esc_attr__( 'Teams', 'sportspress' ),
31
+ 'sp_league' => esc_attr__( 'Leagues', 'sportspress' ),
32
+ 'sp_season' => esc_attr__( 'Seasons', 'sportspress' ),
33
+ 'sp_nationality' => esc_attr__( 'Nationality', 'sportspress' ),
34
  );
35
  parent::__construct();
36
  }
46
  function import( $array = array(), $columns = array( 'post_title' ) ) {
47
  $this->imported = $this->skipped = 0;
48
 
49
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
50
  $this->footer();
51
  die();
52
  endif;
53
 
54
  $rows = array_chunk( $array, sizeof( $columns ) );
55
 
56
+ foreach ( $rows as $row ) :
57
 
58
  $row = array_filter( $row );
59
 
60
+ if ( empty( $row ) ) {
61
+ continue;
62
+ }
63
 
64
  $meta = array();
65
 
66
+ foreach ( $columns as $index => $key ) :
67
  $meta[ $key ] = sp_array_value( $row, $index );
68
  endforeach;
69
 
70
  $name = sp_array_value( $meta, 'post_title' );
71
 
72
+ if ( ! $name ) :
73
  $this->skipped++;
74
  continue;
75
  endif;
76
 
77
  // Get or insert staff
78
  $staff_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_staff' ) : false;
79
+ if ( $staff_object ) :
80
+ if ( $staff_object->post_status != 'publish' ) :
81
+ wp_update_post(
82
+ array(
83
+ 'ID' => $staff_object->ID,
84
+ 'post_status' => 'publish',
85
+ )
86
+ );
87
  endif;
88
  $id = $staff_object->ID;
89
+ else :
90
+ $args = array(
91
+ 'post_type' => 'sp_staff',
92
+ 'post_status' => 'publish',
93
+ 'post_title' => wp_strip_all_tags( $name ),
94
+ );
95
+ $id = wp_insert_post( $args );
96
 
97
  // Flag as import
98
  update_post_meta( $id, '_sp_import', 1 );
111
  wp_set_object_terms( $id, $seasons, 'sp_season', false );
112
 
113
  // Update teams
114
+ $teams = (array) explode( '|', sp_array_value( $meta, 'sp_team' ) );
115
+ $i = 0;
116
+ foreach ( $teams as $team ) :
117
  // Get or insert team
118
  $team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
119
+ if ( $team_object ) :
120
+ if ( $team_object->post_status != 'publish' ) :
121
+ wp_update_post(
122
+ array(
123
+ 'ID' => $team_object->ID,
124
+ 'post_status' => 'publish',
125
+ )
126
+ );
127
  endif;
128
  $team_id = $team_object->ID;
129
+ else :
130
+ $team_id = wp_insert_post(
131
+ array(
132
+ 'post_type' => 'sp_team',
133
+ 'post_status' => 'publish',
134
+ 'post_title' => wp_strip_all_tags( $team ),
135
+ )
136
+ );
137
  // Flag as import
138
  update_post_meta( $team_id, '_sp_import', 1 );
139
  wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
144
  add_post_meta( $id, 'sp_team', $team_id );
145
 
146
  // Update current team if first in array
147
+ if ( $i == 0 ) :
148
  update_post_meta( $id, 'sp_current_team', $team_id );
149
  endif;
150
 
153
 
154
  // Update nationality
155
  $nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
156
+ if ( $nationality == '*' ) {
157
+ $nationality = '';
158
+ }
159
  update_post_meta( $id, 'sp_nationality', $nationality );
160
 
161
  $this->imported++;
164
 
165
  // Show Result
166
  echo '<div class="updated settings-error below-h2"><p>
167
+ ' . sprintf( esc_html__( 'Import complete - imported <strong>%1$s</strong> staff and skipped <strong>%2$s</strong>.', 'sportspress' ), esc_html( $this->imported ), esc_html( $this->skipped ) ) . '
168
  </p></div>';
169
 
170
  $this->import_end();
174
  * Performs post-import cleanup of files and the cache
175
  */
176
  function import_end() {
177
+ echo '<p>' . esc_html__( 'All done!', 'sportspress' ) . ' <a href="' . esc_url( admin_url( 'edit.php?post_type=sp_staff' ) ) . '">' . esc_html__( 'View Staff', 'sportspress' ) . '</a>' . '</p>';
178
 
179
  do_action( 'import_end' );
180
  }
186
  * @return void
187
  */
188
  function header() {
189
+ echo '<div class="wrap"><h2>' . esc_html__( 'Import Staff', 'sportspress' ) . '</h2>';
190
  }
191
 
192
  /**
197
  */
198
  function greet() {
199
  echo '<div class="narrow">';
200
+ echo '<p>' . esc_html__( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
201
+ echo '<p>' . sprintf( wp_kses_post( esc_attr__( 'Staff need to be defined with columns in a specific order (6 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ) ), esc_url( plugin_dir_url( SP_PLUGIN_FILE ) ) . 'dummy-data/staff-sample.csv' ) . '</p>';
202
  wp_import_upload_form( 'admin.php?import=sp_staff_csv&step=1' );
203
  echo '</div>';
204
  }
218
  <label>
219
  <input type="hidden" name="merge" value="0">
220
  <input type="checkbox" name="merge" value="1" checked="checked">
221
+ <?php esc_html_e( 'Merge duplicates', 'sportspress' ); ?>
222
  </label>
223
  </td>
224
  </tr>
includes/admin/importers/class-sp-team-importer.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Team importer - import teams into SportsPress.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Importers
8
- * @version 2.5.5
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( class_exists( 'WP_Importer' ) ) {
14
  class SP_Team_Importer extends SP_Importer {
@@ -20,15 +22,15 @@ if ( class_exists( 'WP_Importer' ) ) {
20
  * @return void
21
  */
22
  public function __construct() {
23
- $this->import_page = 'sp_team_csv';
24
- $this->import_label = __( 'Import Teams', 'sportspress' );
25
- $this->columns = array(
26
- 'post_title' => __( 'Name', 'sportspress' ),
27
- 'sp_league' => __( 'Leagues', 'sportspress' ),
28
- 'sp_season' => __( 'Seasons', 'sportspress' ),
29
- 'sp_url' => __( 'Site URL', 'sportspress' ),
30
- 'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
31
- 'sp_venue' => __( 'Home', 'sportspress' ),
32
  );
33
  parent::__construct();
34
  }
@@ -44,42 +46,53 @@ if ( class_exists( 'WP_Importer' ) ) {
44
  function import( $array = array(), $columns = array( 'post_title' ) ) {
45
  $this->imported = $this->skipped = 0;
46
 
47
- if ( ! is_array( $array ) || ! sizeof( $array ) ):
48
  $this->footer();
49
  die();
50
  endif;
51
 
52
  $rows = array_chunk( $array, sizeof( $columns ) );
53
 
54
- foreach ( $rows as $row ):
55
 
56
  $row = array_filter( $row );
57
 
58
- if ( empty( $row ) ) continue;
 
 
59
 
60
  $meta = array();
61
 
62
- foreach ( $columns as $index => $key ):
63
  $meta[ $key ] = sp_array_value( $row, $index );
64
  endforeach;
65
 
66
  $name = sp_array_value( $meta, 'post_title' );
67
 
68
- if ( ! $name ):
69
  $this->skipped++;
70
  continue;
71
  endif;
72
 
73
  // Get or insert team
74
  $team_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_team' ) : false;
75
- if ( $team_object ):
76
- if ( $team_object->post_status != 'publish' ):
77
- wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
 
 
 
 
 
78
  endif;
79
  $id = $team_object->ID;
80
- else:
81
- $args = array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
82
- $id = wp_insert_post( $args );
 
 
 
 
83
 
84
  // Flag as import
85
  update_post_meta( $id, '_sp_import', 1 );
@@ -107,7 +120,7 @@ if ( class_exists( 'WP_Importer' ) ) {
107
 
108
  // Show Result
109
  echo '<div class="updated settings-error below-h2"><p>
110
- '.sprintf( __( 'Import complete - imported <strong>%s</strong> teams and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
111
  </p></div>';
112
 
113
  $this->import_end();
@@ -117,7 +130,7 @@ if ( class_exists( 'WP_Importer' ) ) {
117
  * Performs post-import cleanup of files and the cache
118
  */
119
  function import_end() {
120
- echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_team') . '">' . __( 'View Teams', 'sportspress' ) . '</a>' . '</p>';
121
 
122
  do_action( 'import_end' );
123
  }
@@ -130,8 +143,8 @@ if ( class_exists( 'WP_Importer' ) ) {
130
  */
131
  function greet() {
132
  echo '<div class="narrow">';
133
- echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
134
- echo '<p>' . sprintf( __( 'Teams need to be defined with columns in a specific order (3 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/teams-sample.csv' ) . '</p>';
135
  wp_import_upload_form( 'admin.php?import=sp_team_csv&step=1' );
136
  echo '</div>';
137
  }
@@ -151,7 +164,7 @@ if ( class_exists( 'WP_Importer' ) ) {
151
  <label>
152
  <input type="hidden" name="merge" value="0">
153
  <input type="checkbox" name="merge" value="1" checked="checked">
154
- <?php _e( 'Merge duplicates', 'sportspress' ); ?>
155
  </label>
156
  </td>
157
  </tr>
2
  /**
3
  * Team importer - import teams into SportsPress.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Importers
8
+ * @version 2.5.5
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( class_exists( 'WP_Importer' ) ) {
16
  class SP_Team_Importer extends SP_Importer {
22
  * @return void
23
  */
24
  public function __construct() {
25
+ $this->import_page = 'sp_team_csv';
26
+ $this->import_label = esc_attr__( 'Import Teams', 'sportspress' );
27
+ $this->columns = array(
28
+ 'post_title' => esc_attr__( 'Name', 'sportspress' ),
29
+ 'sp_league' => esc_attr__( 'Leagues', 'sportspress' ),
30
+ 'sp_season' => esc_attr__( 'Seasons', 'sportspress' ),
31
+ 'sp_url' => esc_attr__( 'Site URL', 'sportspress' ),
32
+ 'sp_abbreviation' => esc_attr__( 'Abbreviation', 'sportspress' ),
33
+ 'sp_venue' => esc_attr__( 'Home', 'sportspress' ),
34
  );
35
  parent::__construct();
36
  }
46
  function import( $array = array(), $columns = array( 'post_title' ) ) {
47
  $this->imported = $this->skipped = 0;
48
 
49
+ if ( ! is_array( $array ) || ! sizeof( $array ) ) :
50
  $this->footer();
51
  die();
52
  endif;
53
 
54
  $rows = array_chunk( $array, sizeof( $columns ) );
55
 
56
+ foreach ( $rows as $row ) :
57
 
58
  $row = array_filter( $row );
59
 
60
+ if ( empty( $row ) ) {
61
+ continue;
62
+ }
63
 
64
  $meta = array();
65
 
66
+ foreach ( $columns as $index => $key ) :
67
  $meta[ $key ] = sp_array_value( $row, $index );
68
  endforeach;
69
 
70
  $name = sp_array_value( $meta, 'post_title' );
71
 
72
+ if ( ! $name ) :
73
  $this->skipped++;
74
  continue;
75
  endif;
76
 
77
  // Get or insert team
78
  $team_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_team' ) : false;
79
+ if ( $team_object ) :
80
+ if ( $team_object->post_status != 'publish' ) :
81
+ wp_update_post(
82
+ array(
83
+ 'ID' => $team_object->ID,
84
+ 'post_status' => 'publish',
85
+ )
86
+ );
87
  endif;
88
  $id = $team_object->ID;
89
+ else :
90
+ $args = array(
91
+ 'post_type' => 'sp_team',
92
+ 'post_status' => 'publish',
93
+ 'post_title' => wp_strip_all_tags( $name ),
94
+ );
95
+ $id = wp_insert_post( $args );
96
 
97
  // Flag as import
98
  update_post_meta( $id, '_sp_import', 1 );
120
 
121
  // Show Result
122
  echo '<div class="updated settings-error below-h2"><p>
123
+ ' . sprintf( esc_html__( 'Import complete - imported <strong>%1$s</strong> teams and skipped <strong>%2$s</strong>.', 'sportspress' ), esc_html( $this->imported ), esc_html( $this->skipped ) ) . '
124
  </p></div>';
125
 
126
  $this->import_end();
130
  * Performs post-import cleanup of files and the cache
131
  */
132
  function import_end() {
133
+ echo '<p>' . esc_html__( 'All done!', 'sportspress' ) . ' <a href="' . esc_url( admin_url( 'edit.php?post_type=sp_team' ) ) . '">' . esc_html__( 'View Teams', 'sportspress' ) . '</a>' . '</p>';
134
 
135
  do_action( 'import_end' );
136
  }
143
  */
144
  function greet() {
145
  echo '<div class="narrow">';
146
+ echo '<p>' . esc_html__( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
147
+ echo '<p>' . sprintf( wp_kses_post( esc_attr__( 'Teams need to be defined with columns in a specific order (3 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ) ), esc_url( plugin_dir_url( SP_PLUGIN_FILE ) ) . 'dummy-data/teams-sample.csv' ) . '</p>';
148
  wp_import_upload_form( 'admin.php?import=sp_team_csv&step=1' );
149
  echo '</div>';
150
  }
164
  <label>
165
  <input type="hidden" name="merge" value="0">
166
  <input type="checkbox" name="merge" value="1" checked="checked">
167
+ <?php esc_html_e( 'Merge duplicates', 'sportspress' ); ?>
168
  </label>
169
  </td>
170
  </tr>
includes/admin/post-types/class-sp-admin-cpt-calendar.php CHANGED
@@ -2,160 +2,170 @@
2
  /**
3
  * Admin functions for the calendars post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 2.5
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Calendar' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Calendar Class
20
- */
21
- class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_calendar';
28
-
29
- // Admin Columns
30
- add_filter( 'manage_edit-sp_calendar_columns', array( $this, 'edit_columns' ) );
31
- add_action( 'manage_sp_calendar_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
32
-
33
- // Filtering
34
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
35
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
36
-
37
- // Call SP_Admin_CPT constructor
38
- parent::__construct();
39
- }
40
 
41
- /**
42
- * Change the columns shown in admin.
43
- */
44
- public function edit_columns( $existing_columns ) {
45
- unset( $existing_columns['author'], $existing_columns['date'] );
46
- $columns = array_merge( array(
47
- 'cb' => '<input type="checkbox" />',
48
- 'title' => __( 'Title', 'sportspress' ),
49
- 'sp_league' => __( 'League', 'sportspress' ),
50
- 'sp_season' => __( 'Season', 'sportspress' ),
51
- 'sp_venue' => __( 'Venue', 'sportspress' ),
52
- 'sp_team' => __( 'Team', 'sportspress' ),
53
- 'sp_events' => __( 'Events', 'sportspress' ),
54
- 'sp_layout' => __( 'Layout', 'sportspress' ),
55
- ), $existing_columns );
56
- return apply_filters( 'sportspress_calendar_admin_columns', $columns );
57
- }
58
 
59
- /**
60
- * Define our custom columns shown in admin.
61
- * @param string $column
62
- */
63
- public function custom_columns( $column, $post_id ) {
64
- switch ( $column ):
65
- case 'sp_league':
66
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
67
- break;
68
- case 'sp_season':
69
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
70
- break;
71
- case 'sp_venue':
72
- echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : __( 'All', 'sportspress' );
73
- break;
74
- case 'sp_team':
75
- $teams = (array)get_post_meta( $post_id, 'sp_team', false );
76
- $teams = array_filter( $teams );
77
- if ( empty( $teams ) ):
78
- echo __( 'All', 'sportspress' );
79
- else:
80
- $current_team = get_post_meta( $post_id, 'sp_current_team', true );
81
- foreach( $teams as $team_id ):
82
- if ( ! $team_id ) continue;
83
- $team = get_post( $team_id );
84
- if ( $team ):
85
- echo $team->post_title;
86
- if ( $team_id == $current_team ):
87
- echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
88
- endif;
89
- echo '<br>';
90
- endif;
91
- endforeach;
92
- endif;
93
- break;
94
- case 'sp_events':
95
- $calendar = new SP_Calendar( $post_id );
96
- echo sizeof( $calendar->data() );
97
- break;
98
- case 'sp_layout':
99
- echo sp_array_value( SP()->formats->calendar, get_post_meta( $post_id, 'sp_format', true ), '&mdash;' );
100
- break;
101
- endswitch;
102
- }
103
 
104
- /**
105
- * Show a category filter box
106
- */
107
- public function filters() {
108
- global $typenow, $wp_query;
109
-
110
- if ( $typenow != 'sp_calendar' )
111
- return;
112
-
113
- $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
114
- $args = array(
115
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
116
- 'taxonomy' => 'sp_league',
117
- 'name' => 'sp_league',
118
- 'selected' => $selected
119
- );
120
- sp_dropdown_taxonomies( $args );
121
-
122
- $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
123
- $args = array(
124
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
125
- 'taxonomy' => 'sp_season',
126
- 'name' => 'sp_season',
127
- 'selected' => $selected
128
- );
129
- sp_dropdown_taxonomies( $args );
130
-
131
- $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
132
- $args = array(
133
- 'post_type' => 'sp_team',
134
- 'name' => 'team',
135
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
136
- 'selected' => $selected,
137
- 'values' => 'ID',
138
- );
139
- wp_dropdown_pages( $args );
140
- }
141
 
142
- /**
143
- * Filter in admin based on options
144
- *
145
- * @param mixed $query
146
- */
147
- public function filters_query( $query ) {
148
- global $typenow, $wp_query;
149
 
150
- if ( $typenow == 'sp_calendar' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
- if ( ! empty( $_GET['team'] ) ) {
153
- $query->query_vars['meta_value'] = $_GET['team'];
154
- $query->query_vars['meta_key'] = 'sp_team';
155
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
  }
158
- }
159
 
160
  endif;
161
 
2
  /**
3
  * Admin functions for the calendars post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Calendar' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Calendar Class
23
  */
24
+ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_calendar';
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
+ // Admin Columns
33
+ add_filter( 'manage_edit-sp_calendar_columns', array( $this, 'edit_columns' ) );
34
+ add_action( 'manage_sp_calendar_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ // Filtering
37
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
38
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ // Call SP_Admin_CPT constructor
41
+ parent::__construct();
42
+ }
 
 
 
 
43
 
44
+ /**
45
+ * Change the columns shown in admin.
46
+ */
47
+ public function edit_columns( $existing_columns ) {
48
+ unset( $existing_columns['author'], $existing_columns['date'] );
49
+ $columns = array_merge(
50
+ array(
51
+ 'cb' => '<input type="checkbox" />',
52
+ 'title' => esc_attr__( 'Title', 'sportspress' ),
53
+ 'sp_league' => esc_attr__( 'League', 'sportspress' ),
54
+ 'sp_season' => esc_attr__( 'Season', 'sportspress' ),
55
+ 'sp_venue' => esc_attr__( 'Venue', 'sportspress' ),
56
+ 'sp_team' => esc_attr__( 'Team', 'sportspress' ),
57
+ 'sp_events' => esc_attr__( 'Events', 'sportspress' ),
58
+ 'sp_layout' => esc_attr__( 'Layout', 'sportspress' ),
59
+ ),
60
+ $existing_columns
61
+ );
62
+ return apply_filters( 'sportspress_calendar_admin_columns', $columns );
63
+ }
64
 
65
+ /**
66
+ * Define our custom columns shown in admin.
67
+ *
68
+ * @param string $column
69
+ */
70
+ public function custom_columns( $column, $post_id ) {
71
+ switch ( $column ) :
72
+ case 'sp_league':
73
+ echo get_the_terms( $post_id, 'sp_league' ) ? wp_kses_post( the_terms( $post_id, 'sp_league' ) ) : esc_html__( 'All', 'sportspress' );
74
+ break;
75
+ case 'sp_season':
76
+ echo get_the_terms( $post_id, 'sp_season' ) ? wp_kses_post( the_terms( $post_id, 'sp_season' ) ) : esc_html__( 'All', 'sportspress' );
77
+ break;
78
+ case 'sp_venue':
79
+ echo get_the_terms( $post_id, 'sp_venue' ) ? wp_kses_post( the_terms( $post_id, 'sp_venue' ) ) : esc_html__( 'All', 'sportspress' );
80
+ break;
81
+ case 'sp_team':
82
+ $teams = (array) get_post_meta( $post_id, 'sp_team', false );
83
+ $teams = array_filter( $teams );
84
+ if ( empty( $teams ) ) :
85
+ echo esc_html__( 'All', 'sportspress' );
86
+ else :
87
+ $current_team = get_post_meta( $post_id, 'sp_current_team', true );
88
+ foreach ( $teams as $team_id ) :
89
+ if ( ! $team_id ) {
90
+ continue;
91
+ }
92
+ $team = get_post( $team_id );
93
+ if ( $team ) :
94
+ echo esc_html( $team->post_title );
95
+ if ( $team_id == $current_team ) :
96
+ echo '<span class="dashicons dashicons-yes" title="' . esc_attr__( 'Current Team', 'sportspress' ) . '"></span>';
97
+ endif;
98
+ echo '<br>';
99
+ endif;
100
+ endforeach;
101
+ endif;
102
+ break;
103
+ case 'sp_events':
104
+ $calendar = new SP_Calendar( $post_id );
105
+ echo esc_html( sizeof( $calendar->data() ) );
106
+ break;
107
+ case 'sp_layout':
108
+ echo esc_html( sp_array_value( SP()->formats->calendar, get_post_meta( $post_id, 'sp_format', true ), '&mdash;' ) );
109
+ break;
110
+ endswitch;
111
+ }
112
+
113
+ /**
114
+ * Show a category filter box
115
+ */
116
+ public function filters() {
117
+ global $typenow, $wp_query;
118
+
119
+ if ( $typenow != 'sp_calendar' ) {
120
+ return;
121
+ }
122
+
123
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
124
+ $args = array(
125
+ 'show_option_all' => esc_attr__( 'Show all leagues', 'sportspress' ),
126
+ 'taxonomy' => 'sp_league',
127
+ 'name' => 'sp_league',
128
+ 'selected' => $selected,
129
+ );
130
+ sp_dropdown_taxonomies( $args );
131
+
132
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
133
+ $args = array(
134
+ 'show_option_all' => esc_attr__( 'Show all seasons', 'sportspress' ),
135
+ 'taxonomy' => 'sp_season',
136
+ 'name' => 'sp_season',
137
+ 'selected' => $selected,
138
+ );
139
+ sp_dropdown_taxonomies( $args );
140
+
141
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
142
+ $args = array(
143
+ 'post_type' => 'sp_team',
144
+ 'name' => 'team',
145
+ 'show_option_none' => esc_attr__( 'Show all teams', 'sportspress' ),
146
+ 'selected' => $selected,
147
+ 'values' => 'ID',
148
+ );
149
+ wp_dropdown_pages( $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
150
+ }
151
+
152
+ /**
153
+ * Filter in admin based on options
154
+ *
155
+ * @param mixed $query
156
+ */
157
+ public function filters_query( $query ) {
158
+ global $typenow, $wp_query;
159
+
160
+ if ( $typenow == 'sp_calendar' ) {
161
+
162
+ if ( ! empty( $_GET['team'] ) ) {
163
+ $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
164
+ $query->query_vars['meta_key'] = 'sp_team';
165
+ }
166
+ }
167
  }
168
  }
 
169
 
170
  endif;
171
 
includes/admin/post-types/class-sp-admin-cpt-column.php CHANGED
@@ -2,80 +2,84 @@
2
  /**
3
  * Admin functions for the columns post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 1.8
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Column' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Column Class
20
- */
21
- class SP_Admin_CPT_Column extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_column';
28
 
29
- // Admin Columns
30
- add_filter( 'manage_edit-sp_column_columns', array( $this, 'edit_columns' ) );
31
- add_action( 'manage_sp_column_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
32
-
33
- // Call SP_Admin_CPT constructor
34
- parent::__construct();
35
- }
36
 
37
- /**
38
- * Change the columns shown in admin.
39
- */
40
- public function edit_columns( $existing_columns ) {
41
- $columns = array(
42
- 'cb' => '<input type="checkbox" />',
43
- 'title' => __( 'Label', 'sportspress' ),
44
- 'sp_key' => __( 'Key', 'sportspress' ),
45
- 'sp_equation' => __( 'Equation', 'sportspress' ),
46
- 'sp_precision' => __( 'Decimal Places', 'sportspress' ),
47
- 'sp_order' => __( 'Sort Order', 'sportspress' ),
48
- 'sp_description' => __( 'Description', 'sportspress' ),
49
- );
50
- return apply_filters( 'sportspress_column_admin_columns', $columns );
51
- }
52
 
53
- /**
54
- * Define our custom columns shown in admin.
55
- * @param string $column
56
- */
57
- public function custom_columns( $column, $post_id ) {
58
- switch ( $column ):
59
- case 'sp_key':
60
- global $post;
61
- echo $post->post_name;
62
- break;
63
- case 'sp_equation':
64
- echo sp_get_post_equation( $post_id );
65
- break;
66
- case 'sp_precision':
67
- echo sp_get_post_precision( $post_id );
68
- break;
69
- case 'sp_order':
70
- echo sp_get_post_order( $post_id );
71
- break;
72
- case 'sp_description':
73
- global $post;
74
- echo '<span class="description">' . $post->post_excerpt . '</span>';
75
- break;
76
- endswitch;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
- }
79
 
80
  endif;
81
 
2
  /**
3
  * Admin functions for the columns post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Column' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Column Class
23
  */
24
+ class SP_Admin_CPT_Column extends SP_Admin_CPT {
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_column';
 
 
31
 
32
+ // Admin Columns
33
+ add_filter( 'manage_edit-sp_column_columns', array( $this, 'edit_columns' ) );
34
+ add_action( 'manage_sp_column_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ // Call SP_Admin_CPT constructor
37
+ parent::__construct();
38
+ }
39
+
40
+ /**
41
+ * Change the columns shown in admin.
42
+ */
43
+ public function edit_columns( $existing_columns ) {
44
+ $columns = array(
45
+ 'cb' => '<input type="checkbox" />',
46
+ 'title' => esc_attr__( 'Label', 'sportspress' ),
47
+ 'sp_key' => esc_attr__( 'Key', 'sportspress' ),
48
+ 'sp_equation' => esc_attr__( 'Equation', 'sportspress' ),
49
+ 'sp_precision' => esc_attr__( 'Decimal Places', 'sportspress' ),
50
+ 'sp_order' => esc_attr__( 'Sort Order', 'sportspress' ),
51
+ 'sp_description' => esc_attr__( 'Description', 'sportspress' ),
52
+ );
53
+ return apply_filters( 'sportspress_column_admin_columns', $columns );
54
+ }
55
+
56
+ /**
57
+ * Define our custom columns shown in admin.
58
+ *
59
+ * @param string $column
60
+ */
61
+ public function custom_columns( $column, $post_id ) {
62
+ switch ( $column ) :
63
+ case 'sp_key':
64
+ global $post;
65
+ echo esc_html( $post->post_name );
66
+ break;
67
+ case 'sp_equation':
68
+ echo wp_kses_post( sp_get_post_equation( $post_id ) );
69
+ break;
70
+ case 'sp_precision':
71
+ echo esc_html( sp_get_post_precision( $post_id ) );
72
+ break;
73
+ case 'sp_order':
74
+ echo esc_html( sp_get_post_order( $post_id ) );
75
+ break;
76
+ case 'sp_description':
77
+ global $post;
78
+ echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
79
+ break;
80
+ endswitch;
81
+ }
82
  }
 
83
 
84
  endif;
85
 
includes/admin/post-types/class-sp-admin-cpt-event.php CHANGED
@@ -2,350 +2,373 @@
2
  /**
3
  * Admin functions for the events post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 2.7.7
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Event' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Event Class
20
- */
21
- class SP_Admin_CPT_Event extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_event';
28
 
29
- // Post title fields
30
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
 
 
 
31
 
32
- // Empty data filter
33
- add_filter( 'wp_insert_post_empty_content', array( $this, 'wp_insert_post_empty_content' ), 99, 2 );
34
 
35
- // Before data updates
36
- add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 99, 2 );
37
 
38
- // Admin Columns
39
- add_filter( 'manage_edit-sp_event_columns', array( $this, 'edit_columns' ) );
40
- add_filter( 'manage_edit-sp_event_sortable_columns', array( $this, 'sortable_columns' ) );
41
- add_action( 'pre_get_posts', array( $this, 'orderby_columns' ) );
42
- add_action( 'manage_sp_event_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
43
 
44
- // Filtering
45
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
46
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
 
 
47
 
48
- // Post states
49
- add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
50
-
51
- // Call SP_Admin_CPT constructor
52
- parent::__construct();
53
- }
54
 
55
- /**
56
- * Change title boxes in admin.
57
- * @param string $text
58
- * @param object $post
59
- * @return string
60
- */
61
- public function enter_title_here( $text, $post ) {
62
- if ( $post->post_type == 'sp_event' )
63
- return __( '(Auto)', 'sportspress' );
64
-
65
- return $text;
66
- }
67
 
68
- /**
69
- * Mark as not empty when saving event if teams are selected for auto title.
70
- *
71
- * @param array $maybe_empty
72
- * @param array $postarr
73
- * @return bool
74
- */
75
- public function wp_insert_post_empty_content( $maybe_empty, $postarr ) {
76
- if ( $maybe_empty && 'sp_event' === sp_array_value( $postarr, 'post_type' ) ):
77
- $teams = sp_array_value( $postarr, 'sp_team', array() );
78
- $teams = array_filter( $teams );
79
- if ( sizeof( $teams ) ) return false;
80
- endif;
81
-
82
- return $maybe_empty;
83
- }
84
 
85
- /**
86
- * Auto-generate an event title based on the team playing if left blank.
87
- *
88
- * @param array $data
89
- * @param array $postarr
90
- * @return array
91
- */
92
- public function wp_insert_post_data( $data, $postarr ) {
93
- if ( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ):
 
 
94
 
95
- $teams = sp_array_value( $postarr, 'sp_team', array() );
96
- $teams = array_filter( $teams );
97
 
98
- $team_names = array();
99
- foreach ( $teams as $team ):
100
- while ( is_array( $team ) ) {
101
- $team = array_shift( array_filter( $team ) );
 
 
 
 
 
 
 
 
 
102
  }
103
- if ( $team > 0 ) $team_names[] = sp_team_short_name( $team );
104
- endforeach;
105
 
106
- $team_names = array_unique( $team_names );
 
107
 
108
- $reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
109
- if ( $reverse_teams ) {
110
- $team_names = array_reverse( $team_names );
111
- }
 
 
 
 
 
 
 
 
112
 
113
- $data['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
 
 
 
 
 
 
 
 
114
 
115
- endif;
116
 
117
- return $data;
118
- }
 
 
119
 
120
- /**
121
- * Change the columns shown in admin.
122
- */
123
- public function edit_columns( $existing_columns ) {
124
- unset( $existing_columns['author'], $existing_columns['comments'] );
125
- $columns = array_merge( array(
126
- 'cb' => '<input type="checkbox" />',
127
- 'sp_format' => '<span class="dashicons sp-icon-calendar sp-tip" title="' . __( 'Format', 'sportspress' ) . '"></span>',
128
- 'title' => null,
129
- 'date' => __( 'Date', 'sportspress' ),
130
- 'sp_time' => __( 'Time', 'sportspress' ),
131
- 'sp_team' => __( 'Teams', 'sportspress' ),
132
- 'sp_league' => __( 'League', 'sportspress' ),
133
- 'sp_season' => __( 'Season', 'sportspress' ),
134
- 'sp_venue' => __( 'Venue', 'sportspress' ),
135
- 'sp_day' => __( 'Match Day', 'sportspress' ),
136
- ), $existing_columns, array(
137
- 'title' => __( 'Event', 'sportspress' ),
138
- ) );
139
- return apply_filters( 'sportspress_event_admin_columns', $columns );
140
- }
141
 
142
- /**
143
- * Change the sortable columns in admin.
144
- */
145
- public function sortable_columns( $columns ) {
146
- $columns['sp_day'] = 'sp_day';
147
- return $columns;
148
- }
149
 
150
- /**
151
- * Define the sortable columns in admin.
152
- */
153
- public function orderby_columns( $query ) {
154
- if ( ! is_admin() ) return;
155
 
156
- $orderby = $query->get( 'orderby');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
- if ( 'sp_day' == $orderby ) {
159
- $query->set( 'meta_key','sp_day' );
160
- $query->set( 'orderby','meta_value_num' );
 
 
 
161
  }
162
- }
163
 
164
- /**
165
- * Define our custom columns shown in admin.
166
- * @param string $column
167
- */
168
- public function custom_columns( $column, $post_id ) {
169
- switch ( $column ):
170
- case 'sp_format':
171
- $format = get_post_meta( $post_id, 'sp_format', true );
172
- $formats = new SP_Formats();
173
- $event_formats = $formats->event;
174
- if ( array_key_exists( $format, $event_formats ) ):
175
- echo '<span class="dashicons sp-icon-' . $format . ' sp-tip" title="' . $event_formats[ $format ] . '"></span>';
176
- endif;
177
- break;
178
- case 'sp_time':
179
- echo apply_filters( 'sportspress_event_time_admin', get_post_time( 'H:i', false, $post_id, true ) );
180
- break;
181
- case 'sp_team':
182
- $teams = (array)get_post_meta( $post_id, 'sp_team', false );
183
- $teams = array_filter( $teams );
184
- $teams = array_unique( $teams );
185
- $reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
186
- if ( $reverse_teams ) {
187
- $teams = array_reverse( $teams , true );
188
- }
189
- if ( empty( $teams ) ):
190
- echo '&mdash;';
191
- else:
192
- $results = get_post_meta( $post_id, 'sp_results', true );
193
- $main_result = get_option( 'sportspress_primary_result', null );
194
- echo '<input type="hidden" name="sp_post_id" value="' . $post_id . '">';
195
- echo '<div class="sp-results">';
196
- foreach( $teams as $team_id ):
197
- if ( ! $team_id ) continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  $team = get_post( $team_id );
199
 
200
- if ( $team ):
201
  $team_results = sportspress_array_value( $results, $team_id, null );
202
 
203
- if ( $main_result ):
204
  $team_result = sportspress_array_value( $team_results, $main_result, null );
205
- else:
206
- if ( is_array( $team_results ) ):
207
  end( $team_results );
208
  $team_result = prev( $team_results );
209
  $main_result = key( $team_results );
210
- else:
211
  $team_result = null;
212
  endif;
213
  endif;
214
 
215
- if ( is_array( $team_results ) ):
216
  unset( $team_results['outcome'] );
217
  $team_results = array_filter( $team_results, 'sp_filter_non_empty' );
218
  $team_results = implode( ' | ', $team_results );
219
  endif;
220
 
221
- echo '<a class="sp-result sp-tip" tabindex="10" title="' . $team_results . '" data-team="' . $team_id . '" href="#">' . ( $team_result == '' ? '-' : apply_filters( 'sportspress_event_team_result_admin', $team_result, $post_id, $team_id ) ) . '</a>';
222
- echo '<input type="text" tabindex="10" class="sp-edit-result hidden small-text" data-team="' . $team_id . '" data-key="' . $main_result . '" value="' . $team_result . '"> ';
223
- echo $team->post_title;
224
  echo '<br>';
225
  endif;
226
- endforeach;
227
- echo '</div>';
228
- if ( current_user_can( 'edit_others_sp_events' ) ) {
229
- ?>
230
- <div class="row-actions sp-row-actions"><span class="inline hide-if-no-js"><a href="#" class="sp-edit-results"><?php _e( 'Edit Results', 'sportspress' ); ?></a></span></div>
231
  <p class="inline-edit-save sp-inline-edit-save hidden">
232
- <a href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
233
- <a href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
234
  </p>
235
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  }
237
- endif;
238
- break;
239
- case 'sp_league':
240
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '&mdash;';
241
- break;
242
- case 'sp_season':
243
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '&mdash;';
244
- break;
245
- case 'sp_venue':
246
- echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '&mdash;';
247
- break;
248
- case 'sp_day':
249
- $day = get_post_meta ( $post_id, 'sp_day', true );
250
- if ( '' === $day ) $day = __( 'Default', 'sportspress' );
251
- echo $day;
252
- break;
253
- endswitch;
254
- }
255
 
256
- /**
257
- * Show a category filter box
258
- */
259
- public function filters() {
260
- global $typenow, $wp_query;
261
-
262
- if ( $typenow != 'sp_event' )
263
- return;
264
-
265
- $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
266
- $args = array(
267
- 'post_type' => 'sp_team',
268
- 'name' => 'team',
269
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
270
- 'selected' => $selected,
271
- 'values' => 'ID',
272
- );
273
- wp_dropdown_pages( $args );
274
-
275
- $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
276
- $args = array(
277
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
278
- 'taxonomy' => 'sp_league',
279
- 'name' => 'sp_league',
280
- 'selected' => $selected
281
- );
282
- sp_dropdown_taxonomies( $args );
283
-
284
- $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
285
- $args = array(
286
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
287
- 'taxonomy' => 'sp_season',
288
- 'name' => 'sp_season',
289
- 'selected' => $selected
290
- );
291
- sp_dropdown_taxonomies( $args );
292
-
293
- $selected = isset( $_REQUEST['match_day'] ) ? $_REQUEST['match_day'] : null;
294
- echo '<input name="match_day" type="text" class="sp-tablenav-input" placeholder="' . __( 'Match Day', 'sportspress' ) . '" value="' . $selected . '">';
295
-
296
- if ( current_user_can( 'edit_others_sp_events' ) )
297
- wp_nonce_field( 'sp-save-inline-results', 'sp-inline-nonce', false );
298
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
 
300
- /**
301
- * Filter in admin based on options
302
- *
303
- * @param mixed $query
304
- */
305
- public function filters_query( $query ) {
306
- global $typenow, $wp_query;
307
-
308
- if ( $typenow == 'sp_event' ) {
309
- //Avoid overriding relation operator if already set
310
- if ( !isset( $query->query_vars['meta_query']['relation'] ) )
311
- $query->query_vars['meta_query']['relation'] = 'AND';
312
-
313
- if ( ! empty( $_GET['team'] ) ) {
314
- $query->query_vars['meta_query'][] = array(
315
- 'key' => 'sp_team',
316
- 'value' => $_GET['team'],
317
- );
318
  }
319
-
320
- if ( ! empty( $_GET['match_day'] ) ) {
321
- $query->query_vars['meta_query'][] = array(
322
- 'key' => 'sp_day',
323
- 'value' => $_GET['match_day'],
324
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  }
326
- }
327
- }
328
-
329
- /**
330
- * Replace displayed post state for events
331
- *
332
- * @param array $post_states
333
- * @param object $post
334
- */
335
- public function post_states( $post_states, $post ) {
336
- $status = get_post_meta( $post->ID, 'sp_status', true );
337
-
338
- if ( 'postponed' == $status ) {
339
- $post_states = array( __( 'Postponed', 'sportspress' ) );
340
- } elseif ( 'cancelled' == $status ) {
341
- $post_states = array( __( 'Canceled', 'sportspress' ) );
342
- } elseif ( 'tbd' == $status ) {
343
- $post_states = array( __( 'TBD', 'sportspress' ) );
344
- }
345
-
346
- return $post_states;
347
- }
348
- }
349
 
350
  endif;
351
 
2
  /**
3
  * Admin functions for the events post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Event' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Event Class
23
  */
24
+ class SP_Admin_CPT_Event extends SP_Admin_CPT {
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_event';
31
 
32
+ // Post title fields
33
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
34
 
35
+ // Empty data filter
36
+ add_filter( 'wp_insert_post_empty_content', array( $this, 'wp_insert_post_empty_content' ), 99, 2 );
37
 
38
+ // Before data updates
39
+ add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 99, 2 );
 
 
 
40
 
41
+ // Admin Columns
42
+ add_filter( 'manage_edit-sp_event_columns', array( $this, 'edit_columns' ) );
43
+ add_filter( 'manage_edit-sp_event_sortable_columns', array( $this, 'sortable_columns' ) );
44
+ add_action( 'pre_get_posts', array( $this, 'orderby_columns' ) );
45
+ add_action( 'manage_sp_event_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
46
 
47
+ // Filtering
48
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
49
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
 
 
 
50
 
51
+ // Post states
52
+ add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
 
 
 
 
 
 
 
 
 
 
53
 
54
+ // Call SP_Admin_CPT constructor
55
+ parent::__construct();
56
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
+ /**
59
+ * Change title boxes in admin.
60
+ *
61
+ * @param string $text
62
+ * @param object $post
63
+ * @return string
64
+ */
65
+ public function enter_title_here( $text, $post ) {
66
+ if ( $post->post_type == 'sp_event' ) {
67
+ return esc_attr__( '(Auto)', 'sportspress' );
68
+ }
69
 
70
+ return $text;
71
+ }
72
 
73
+ /**
74
+ * Mark as not empty when saving event if teams are selected for auto title.
75
+ *
76
+ * @param array $maybe_empty
77
+ * @param array $postarr
78
+ * @return bool
79
+ */
80
+ public function wp_insert_post_empty_content( $maybe_empty, $postarr ) {
81
+ if ( $maybe_empty && 'sp_event' === sp_array_value( $postarr, 'post_type' ) ) :
82
+ $teams = sp_array_value( $postarr, 'sp_team', array() );
83
+ $teams = array_filter( $teams );
84
+ if ( sizeof( $teams ) ) {
85
+ return false;
86
  }
87
+ endif;
 
88
 
89
+ return $maybe_empty;
90
+ }
91
 
92
+ /**
93
+ * Auto-generate an event title based on the team playing if left blank.
94
+ *
95
+ * @param array $data
96
+ * @param array $postarr
97
+ * @return array
98
+ */
99
+ public function wp_insert_post_data( $data, $postarr ) {
100
+ if ( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ) :
101
+
102
+ $teams = sp_array_value( $postarr, 'sp_team', array() );
103
+ $teams = array_filter( $teams );
104
 
105
+ $team_names = array();
106
+ foreach ( $teams as $team ) :
107
+ while ( is_array( $team ) ) {
108
+ $team = array_shift( array_filter( $team ) );
109
+ }
110
+ if ( $team > 0 ) {
111
+ $team_names[] = sp_team_short_name( $team );
112
+ }
113
+ endforeach;
114
 
115
+ $team_names = array_unique( $team_names );
116
 
117
+ $reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
118
+ if ( $reverse_teams ) {
119
+ $team_names = array_reverse( $team_names );
120
+ }
121
 
122
+ $data['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
+ endif;
 
 
 
 
 
 
125
 
126
+ return $data;
127
+ }
 
 
 
128
 
129
+ /**
130
+ * Change the columns shown in admin.
131
+ */
132
+ public function edit_columns( $existing_columns ) {
133
+ unset( $existing_columns['author'], $existing_columns['comments'] );
134
+ $columns = array_merge(
135
+ array(
136
+ 'cb' => '<input type="checkbox" />',
137
+ 'sp_format' => '<span class="dashicons sp-icon-calendar sp-tip" title="' . esc_attr__( 'Format', 'sportspress' ) . '"></span>',
138
+ 'title' => null,
139
+ 'date' => esc_attr__( 'Date', 'sportspress' ),
140
+ 'sp_time' => esc_attr__( 'Time', 'sportspress' ),
141
+ 'sp_team' => esc_attr__( 'Teams', 'sportspress' ),
142
+ 'sp_league' => esc_attr__( 'League', 'sportspress' ),
143
+ 'sp_season' => esc_attr__( 'Season', 'sportspress' ),
144
+ 'sp_venue' => esc_attr__( 'Venue', 'sportspress' ),
145
+ 'sp_day' => esc_attr__( 'Match Day', 'sportspress' ),
146
+ ),
147
+ $existing_columns,
148
+ array(
149
+ 'title' => esc_attr__( 'Event', 'sportspress' ),
150
+ )
151
+ );
152
+ return apply_filters( 'sportspress_event_admin_columns', $columns );
153
+ }
154
 
155
+ /**
156
+ * Change the sortable columns in admin.
157
+ */
158
+ public function sortable_columns( $columns ) {
159
+ $columns['sp_day'] = 'sp_day';
160
+ return $columns;
161
  }
 
162
 
163
+ /**
164
+ * Define the sortable columns in admin.
165
+ */
166
+ public function orderby_columns( $query ) {
167
+ if ( ! is_admin() ) {
168
+ return;
169
+ }
170
+
171
+ $orderby = $query->get( 'orderby' );
172
+
173
+ if ( 'sp_day' == $orderby ) {
174
+ $query->set( 'meta_key', 'sp_day' );
175
+ $query->set( 'orderby', 'meta_value_num' );
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Define our custom columns shown in admin.
181
+ *
182
+ * @param string $column
183
+ */
184
+ public function custom_columns( $column, $post_id ) {
185
+ switch ( $column ) :
186
+ case 'sp_format':
187
+ $format = get_post_meta( $post_id, 'sp_format', true );
188
+ $formats = new SP_Formats();
189
+ $event_formats = $formats->event;
190
+ if ( array_key_exists( $format, $event_formats ) ) :
191
+ echo '<span class="dashicons sp-icon-' . esc_attr( $format ) . ' sp-tip" title="' . esc_attr( $event_formats[ $format ] ) . '"></span>';
192
+ endif;
193
+ break;
194
+ case 'sp_time':
195
+ echo wp_kses_post( apply_filters( 'sportspress_event_time_admin', get_post_time( 'H:i', false, $post_id, true ) ) );
196
+ break;
197
+ case 'sp_team':
198
+ $teams = (array) get_post_meta( $post_id, 'sp_team', false );
199
+ $teams = array_filter( $teams );
200
+ $teams = array_unique( $teams );
201
+ $reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
202
+ if ( $reverse_teams ) {
203
+ $teams = array_reverse( $teams, true );
204
+ }
205
+ if ( empty( $teams ) ) :
206
+ echo '&mdash;';
207
+ else :
208
+ $results = get_post_meta( $post_id, 'sp_results', true );
209
+ $main_result = get_option( 'sportspress_primary_result', null );
210
+ echo '<input type="hidden" name="sp_post_id" value="' . esc_attr( $post_id ) . '">';
211
+ echo '<div class="sp-results">';
212
+ foreach ( $teams as $team_id ) :
213
+ if ( ! $team_id ) {
214
+ continue;
215
+ }
216
  $team = get_post( $team_id );
217
 
218
+ if ( $team ) :
219
  $team_results = sportspress_array_value( $results, $team_id, null );
220
 
221
+ if ( $main_result ) :
222
  $team_result = sportspress_array_value( $team_results, $main_result, null );
223
+ else :
224
+ if ( is_array( $team_results ) ) :
225
  end( $team_results );
226
  $team_result = prev( $team_results );
227
  $main_result = key( $team_results );
228
+ else :
229
  $team_result = null;
230
  endif;
231
  endif;
232
 
233
+ if ( is_array( $team_results ) ) :
234
  unset( $team_results['outcome'] );
235
  $team_results = array_filter( $team_results, 'sp_filter_non_empty' );
236
  $team_results = implode( ' | ', $team_results );
237
  endif;
238
 
239
+ echo '<a class="sp-result sp-tip" tabindex="10" title="' . esc_attr( $team_results ) . '" data-team="' . esc_attr( $team_id ) . '" href="#">' . ( esc_attr( $team_result ) == '' ? '-' : wp_kses_post( apply_filters( 'sportspress_event_team_result_admin', $team_result, $post_id, $team_id ) ) ) . '</a>';
240
+ echo '<input type="text" tabindex="10" class="sp-edit-result hidden small-text" data-team="' . esc_attr( $team_id ) . '" data-key="' . esc_attr( $main_result ) . '" value="' . esc_attr( $team_result ) . '"> ';
241
+ echo esc_html( $team->post_title );
242
  echo '<br>';
243
  endif;
244
+ endforeach;
245
+ echo '</div>';
246
+ if ( current_user_can( 'edit_others_sp_events' ) ) {
247
+ ?>
248
+ <div class="row-actions sp-row-actions"><span class="inline hide-if-no-js"><a href="#" class="sp-edit-results"><?php esc_html_e( 'Edit Results', 'sportspress' ); ?></a></span></div>
249
  <p class="inline-edit-save sp-inline-edit-save hidden">
250
+ <a href="#inline-edit" class="button-secondary cancel alignleft"><?php esc_html_e( 'Cancel' ); ?></a>
251
+ <a href="#inline-edit" class="button-primary save alignright"><?php esc_html_e( 'Update' ); ?></a>
252
  </p>
253
+ <?php
254
+ }
255
+ endif;
256
+ break;
257
+ case 'sp_league':
258
+ echo get_the_terms( $post_id, 'sp_league' ) ? wp_kses_post( the_terms( $post_id, 'sp_league' ) ) : '&mdash;';
259
+ break;
260
+ case 'sp_season':
261
+ echo get_the_terms( $post_id, 'sp_season' ) ? wp_kses_post( the_terms( $post_id, 'sp_season' ) ) : '&mdash;';
262
+ break;
263
+ case 'sp_venue':
264
+ echo get_the_terms( $post_id, 'sp_venue' ) ? wp_kses_post( the_terms( $post_id, 'sp_venue' ) ) : '&mdash;';
265
+ break;
266
+ case 'sp_day':
267
+ $day = get_post_meta( $post_id, 'sp_day', true );
268
+ if ( '' === $day ) {
269
+ $day = esc_attr__( 'Default', 'sportspress' );
270
  }
271
+ echo esc_html( $day );
272
+ break;
273
+ endswitch;
274
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
 
276
+ /**
277
+ * Show a category filter box
278
+ */
279
+ public function filters() {
280
+ global $typenow, $wp_query;
281
+
282
+ if ( $typenow != 'sp_event' ) {
283
+ return;
284
+ }
285
+
286
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
287
+ $args = array(
288
+ 'post_type' => 'sp_team',
289
+ 'name' => 'team',
290
+ 'show_option_none' => esc_attr__( 'Show all teams', 'sportspress' ),
291
+ 'selected' => $selected,
292
+ 'values' => 'ID',
293
+ );
294
+ wp_dropdown_pages( $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
295
+
296
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
297
+ $args = array(
298
+ 'show_option_all' => esc_attr__( 'Show all leagues', 'sportspress' ),
299
+ 'taxonomy' => 'sp_league',
300
+ 'name' => 'sp_league',
301
+ 'selected' => $selected,
302
+ );
303
+ sp_dropdown_taxonomies( $args );
304
+
305
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
306
+ $args = array(
307
+ 'show_option_all' => esc_attr__( 'Show all seasons', 'sportspress' ),
308
+ 'taxonomy' => 'sp_season',
309
+ 'name' => 'sp_season',
310
+ 'selected' => $selected,
311
+ );
312
+ sp_dropdown_taxonomies( $args );
313
+
314
+ $selected = isset( $_REQUEST['match_day'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['match_day'] ) ) : null;
315
+ echo '<input name="match_day" type="text" class="sp-tablenav-input" placeholder="' . esc_attr__( 'Match Day', 'sportspress' ) . '" value="' . esc_attr( $selected ) . '">';
316
+
317
+ if ( current_user_can( 'edit_others_sp_events' ) ) {
318
+ wp_nonce_field( 'sp-save-inline-results', 'sp-inline-nonce', false );
319
+ }
320
+ }
321
+
322
+ /**
323
+ * Filter in admin based on options
324
+ *
325
+ * @param mixed $query
326
+ */
327
+ public function filters_query( $query ) {
328
+ global $typenow, $wp_query;
329
+
330
+ if ( $typenow == 'sp_event' ) {
331
+ // Avoid overriding relation operator if already set
332
+ if ( ! isset( $query->query_vars['meta_query']['relation'] ) ) {
333
+ $query->query_vars['meta_query']['relation'] = 'AND';
334
+ }
335
 
336
+ if ( ! empty( $_GET['team'] ) ) {
337
+ $query->query_vars['meta_query'][] = array(
338
+ 'key' => 'sp_team',
339
+ 'value' => sanitize_key( $_GET['team'] ),
340
+ );
341
+ }
342
+
343
+ if ( ! empty( $_GET['match_day'] ) ) {
344
+ $query->query_vars['meta_query'][] = array(
345
+ 'key' => 'sp_day',
346
+ 'value' => sanitize_text_field( wp_unslash( $_GET['match_day'] ) ),
347
+ );
348
+ }
349
+ }
 
 
 
 
350
  }
351
+
352
+ /**
353
+ * Replace displayed post state for events
354
+ *
355
+ * @param array $post_states
356
+ * @param object $post
357
+ */
358
+ public function post_states( $post_states, $post ) {
359
+ $status = get_post_meta( $post->ID, 'sp_status', true );
360
+
361
+ if ( 'postponed' == $status ) {
362
+ $post_states = array( esc_attr__( 'Postponed', 'sportspress' ) );
363
+ } elseif ( 'cancelled' == $status ) {
364
+ $post_states = array( esc_attr__( 'Canceled', 'sportspress' ) );
365
+ } elseif ( 'tbd' == $status ) {
366
+ $post_states = array( esc_attr__( 'TBD', 'sportspress' ) );
367
+ }
368
+
369
+ return $post_states;
370
  }
371
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
 
373
  endif;
374
 
includes/admin/post-types/class-sp-admin-cpt-list.php CHANGED
@@ -2,154 +2,166 @@
2
  /**
3
  * Admin functions for the player lists post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 2.5
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_List' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_List Class
20
- */
21
- class SP_Admin_CPT_List extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_list';
28
-
29
- // Admin Columns
30
- add_filter( 'manage_edit-sp_list_columns', array( $this, 'edit_columns' ) );
31
- add_action( 'manage_sp_list_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
32
-
33
- // Filtering
34
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
35
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
36
-
37
- // Call SP_Admin_CPT constructor
38
- parent::__construct();
39
- }
40
 
41
- /**
42
- * Change the columns shown in admin.
43
- */
44
- public function edit_columns( $existing_columns ) {
45
- unset( $existing_columns['author'], $existing_columns['date'] );
46
- $columns = array_merge( array(
47
- 'cb' => '<input type="checkbox" />',
48
- 'title' => __( 'Title', 'sportspress' ),
49
- 'sp_league' => __( 'League', 'sportspress' ),
50
- 'sp_season' => __( 'Season', 'sportspress' ),
51
- 'sp_team' => __( 'Team', 'sportspress' ),
52
- 'sp_player' => __( 'Players', 'sportspress' ),
53
- 'sp_layout' => __( 'Layout', 'sportspress' ),
54
- ), $existing_columns );
55
- return apply_filters( 'sportspress_list_admin_columns', $columns );
56
- }
57
 
58
- /**
59
- * Define our custom columns shown in admin.
60
- * @param string $column
61
- */
62
- public function custom_columns( $column, $post_id ) {
63
- switch ( $column ):
64
- case 'sp_player':
65
- $select = get_post_meta( $post_id, 'sp_select', true );
66
- if ( 'manual' == $select ):
67
- $players = array_filter( get_post_meta( $post_id, 'sp_player' ) );
68
- echo sizeof( $players );
69
- else:
70
- _e( 'Auto', 'sportspress' );
71
- endif;
72
- break;
73
- case 'sp_league':
74
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
75
- break;
76
- case 'sp_season':
77
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
78
- break;
79
- case 'sp_team':
80
- $teams = (array)get_post_meta( $post_id, 'sp_team', false );
81
- $teams = array_filter( $teams );
82
- if ( empty( $teams ) ):
83
- echo __( 'All', 'sportspress' );
84
- else:
85
- foreach( $teams as $team_id ):
86
- if ( ! $team_id ) continue;
87
- $team = get_post( $team_id );
88
- if ( $team ) echo $team->post_title . '<br>';
89
- endforeach;
90
- endif;
91
- break;
92
- case 'sp_layout':
93
- echo sp_array_value( SP()->formats->list, get_post_meta( $post_id, 'sp_format', true ), '&mdash;' );
94
- break;
95
- endswitch;
96
- }
97
 
98
- /**
99
- * Show a category filter box
100
- */
101
- public function filters() {
102
- global $typenow, $wp_query;
103
-
104
- if ( $typenow != 'sp_list' )
105
- return;
106
-
107
- $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
108
- $args = array(
109
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
110
- 'taxonomy' => 'sp_league',
111
- 'name' => 'sp_league',
112
- 'selected' => $selected
113
- );
114
- sp_dropdown_taxonomies( $args );
115
-
116
- $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
117
- $args = array(
118
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
119
- 'taxonomy' => 'sp_season',
120
- 'name' => 'sp_season',
121
- 'selected' => $selected
122
- );
123
- sp_dropdown_taxonomies( $args );
124
-
125
- $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
126
- $args = array(
127
- 'post_type' => 'sp_team',
128
- 'name' => 'team',
129
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
130
- 'selected' => $selected,
131
- 'values' => 'ID',
132
- );
133
- wp_dropdown_pages( $args );
134
- }
135
 
136
- /**
137
- * Filter in admin based on options
138
- *
139
- * @param mixed $query
140
- */
141
- public function filters_query( $query ) {
142
- global $typenow, $wp_query;
143
 
144
- if ( $typenow == 'sp_list' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
- if ( ! empty( $_GET['team'] ) ) {
147
- $query->query_vars['meta_value'] = $_GET['team'];
148
- $query->query_vars['meta_key'] = 'sp_team';
149
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  }
151
  }
152
- }
153
 
154
  endif;
155
 
2
  /**
3
  * Admin functions for the player lists post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_List' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_List Class
23
  */
24
+ class SP_Admin_CPT_List extends SP_Admin_CPT {
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_list';
 
 
 
 
 
 
 
 
 
 
 
31
 
32
+ // Admin Columns
33
+ add_filter( 'manage_edit-sp_list_columns', array( $this, 'edit_columns' ) );
34
+ add_action( 'manage_sp_list_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ // Filtering
37
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
38
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ // Call SP_Admin_CPT constructor
41
+ parent::__construct();
42
+ }
 
 
 
 
43
 
44
+ /**
45
+ * Change the columns shown in admin.
46
+ */
47
+ public function edit_columns( $existing_columns ) {
48
+ unset( $existing_columns['author'], $existing_columns['date'] );
49
+ $columns = array_merge(
50
+ array(
51
+ 'cb' => '<input type="checkbox" />',
52
+ 'title' => esc_attr__( 'Title', 'sportspress' ),
53
+ 'sp_league' => esc_attr__( 'League', 'sportspress' ),
54
+ 'sp_season' => esc_attr__( 'Season', 'sportspress' ),
55
+ 'sp_team' => esc_attr__( 'Team', 'sportspress' ),
56
+ 'sp_player' => esc_attr__( 'Players', 'sportspress' ),
57
+ 'sp_layout' => esc_attr__( 'Layout', 'sportspress' ),
58
+ ),
59
+ $existing_columns
60
+ );
61
+ return apply_filters( 'sportspress_list_admin_columns', $columns );
62
+ }
63
+
64
+ /**
65
+ * Define our custom columns shown in admin.
66
+ *
67
+ * @param string $column
68
+ */
69
+ public function custom_columns( $column, $post_id ) {
70
+ switch ( $column ) :
71
+ case 'sp_player':
72
+ $select = get_post_meta( $post_id, 'sp_select', true );
73
+ if ( 'manual' == $select ) :
74
+ $players = array_filter( get_post_meta( $post_id, 'sp_player' ) );
75
+ echo esc_html( sizeof( $players ) );
76
+ else :
77
+ esc_html_e( 'Auto', 'sportspress' );
78
+ endif;
79
+ break;
80
+ case 'sp_league':
81
+ echo get_the_terms( $post_id, 'sp_league' ) ? wp_kses_post( the_terms( $post_id, 'sp_league' ) ) : esc_html__( 'All', 'sportspress' );
82
+ break;
83
+ case 'sp_season':
84
+ echo get_the_terms( $post_id, 'sp_season' ) ? wp_kses_post( the_terms( $post_id, 'sp_season' ) ) : esc_html__( 'All', 'sportspress' );
85
+ break;
86
+ case 'sp_team':
87
+ $teams = (array) get_post_meta( $post_id, 'sp_team', false );
88
+ $teams = array_filter( $teams );
89
+ if ( empty( $teams ) ) :
90
+ echo esc_html__( 'All', 'sportspress' );
91
+ else :
92
+ foreach ( $teams as $team_id ) :
93
+ if ( ! $team_id ) {
94
+ continue;
95
+ }
96
+ $team = get_post( $team_id );
97
+ if ( $team ) {
98
+ echo esc_html( $team->post_title ) . '<br>';
99
+ }
100
+ endforeach;
101
+ endif;
102
+ break;
103
+ case 'sp_layout':
104
+ echo esc_html( sp_array_value( SP()->formats->list, get_post_meta( $post_id, 'sp_format', true ), '&mdash;' ) );
105
+ break;
106
+ endswitch;
107
+ }
108
 
109
+ /**
110
+ * Show a category filter box
111
+ */
112
+ public function filters() {
113
+ global $typenow, $wp_query;
114
+
115
+ if ( $typenow != 'sp_list' ) {
116
+ return;
117
+ }
118
+
119
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
120
+ $args = array(
121
+ 'show_option_all' => esc_attr__( 'Show all leagues', 'sportspress' ),
122
+ 'taxonomy' => 'sp_league',
123
+ 'name' => 'sp_league',
124
+ 'selected' => $selected,
125
+ );
126
+ sp_dropdown_taxonomies( $args );
127
+
128
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
129
+ $args = array(
130
+ 'show_option_all' => esc_attr__( 'Show all seasons', 'sportspress' ),
131
+ 'taxonomy' => 'sp_season',
132
+ 'name' => 'sp_season',
133
+ 'selected' => $selected,
134
+ );
135
+ sp_dropdown_taxonomies( $args );
136
+
137
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
138
+ $args = array(
139
+ 'post_type' => 'sp_team',
140
+ 'name' => 'team',
141
+ 'show_option_none' => esc_attr__( 'Show all teams', 'sportspress' ),
142
+ 'selected' => $selected,
143
+ 'values' => 'ID',
144
+ );
145
+ wp_dropdown_pages( $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
146
+ }
147
+
148
+ /**
149
+ * Filter in admin based on options
150
+ *
151
+ * @param mixed $query
152
+ */
153
+ public function filters_query( $query ) {
154
+ global $typenow, $wp_query;
155
+
156
+ if ( $typenow == 'sp_list' ) {
157
+
158
+ if ( ! empty( $_GET['team'] ) ) {
159
+ $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
160
+ $query->query_vars['meta_key'] = 'sp_team';
161
+ }
162
+ }
163
  }
164
  }
 
165
 
166
  endif;
167
 
includes/admin/post-types/class-sp-admin-cpt-metric.php CHANGED
@@ -2,68 +2,72 @@
2
  /**
3
  * Admin functions for the columns post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 0.9
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Metric' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Metric Class
20
- */
21
- class SP_Admin_CPT_Metric extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_metric';
28
 
29
- // Admin Columns
30
- add_filter( 'manage_edit-sp_metric_columns', array( $this, 'edit_columns' ) );
31
- add_action( 'manage_sp_metric_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
32
-
33
- // Call SP_Admin_CPT constructor
34
- parent::__construct();
35
- }
36
 
37
- /**
38
- * Change the columns shown in admin.
39
- */
40
- public function edit_columns( $existing_columns ) {
41
- $columns = array(
42
- 'cb' => '<input type="checkbox" />',
43
- 'title' => __( 'Label', 'sportspress' ),
44
- 'sp_key' => __( 'Variable', 'sportspress' ),
45
- 'sp_description' => __( 'Description', 'sportspress' ),
46
- );
47
- return apply_filters( 'sportspress_metric_admin_columns', $columns );
48
- }
49
 
50
- /**
51
- * Define our custom columns shown in admin.
52
- * @param string $column
53
- */
54
- public function custom_columns( $column, $post_id ) {
55
- switch ( $column ):
56
- case 'sp_key':
57
- global $post;
58
- echo $post->post_name;
59
- break;
60
- case 'sp_description':
61
- global $post;
62
- echo '<span class="description">' . $post->post_excerpt . '</span>';
63
- break;
64
- endswitch;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
- }
67
 
68
  endif;
69
 
2
  /**
3
  * Admin functions for the columns post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Metric' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Metric Class
23
  */
24
+ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_metric';
 
 
31
 
32
+ // Admin Columns
33
+ add_filter( 'manage_edit-sp_metric_columns', array( $this, 'edit_columns' ) );
34
+ add_action( 'manage_sp_metric_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
35
 
36
+ // Call SP_Admin_CPT constructor
37
+ parent::__construct();
38
+ }
39
+
40
+ /**
41
+ * Change the columns shown in admin.
42
+ */
43
+ public function edit_columns( $existing_columns ) {
44
+ $columns = array(
45
+ 'cb' => '<input type="checkbox" />',
46
+ 'title' => esc_attr__( 'Label', 'sportspress' ),
47
+ 'sp_key' => esc_attr__( 'Variable', 'sportspress' ),
48
+ 'sp_description' => esc_attr__( 'Description', 'sportspress' ),
49
+ );
50
+ return apply_filters( 'sportspress_metric_admin_columns', $columns );
51
+ }
52
+
53
+ /**
54
+ * Define our custom columns shown in admin.
55
+ *
56
+ * @param string $column
57
+ */
58
+ public function custom_columns( $column, $post_id ) {
59
+ switch ( $column ) :
60
+ case 'sp_key':
61
+ global $post;
62
+ echo esc_html( $post->post_name );
63
+ break;
64
+ case 'sp_description':
65
+ global $post;
66
+ echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
67
+ break;
68
+ endswitch;
69
+ }
70
  }
 
71
 
72
  endif;
73
 
includes/admin/post-types/class-sp-admin-cpt-official.php CHANGED
@@ -2,51 +2,56 @@
2
  /**
3
  * Admin functions for the officials post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 2.5.1
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Official' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Official Class
20
- */
21
- class SP_Admin_CPT_Official extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_official';
28
-
29
- // Post title fields
30
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
31
-
32
- // Call SP_Admin_CPT constructor
33
- parent::__construct();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
- /**
37
- * Change title boxes in admin.
38
- * @param string $text
39
- * @param object $post
40
- * @return string
41
- */
42
- public function enter_title_here( $text, $post ) {
43
- if ( $post->post_type == 'sp_official' )
44
- return __( 'Name', 'sportspress' );
45
-
46
- return $text;
47
- }
48
- }
49
-
50
  endif;
51
 
52
  return new SP_Admin_CPT_Official();
2
  /**
3
  * Admin functions for the officials post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.5.1
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Official' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Official Class
23
  */
24
+ class SP_Admin_CPT_Official extends SP_Admin_CPT {
25
+
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_official';
31
+
32
+ // Post title fields
33
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
34
+
35
+ // Call SP_Admin_CPT constructor
36
+ parent::__construct();
37
+ }
38
+
39
+ /**
40
+ * Change title boxes in admin.
41
+ *
42
+ * @param string $text
43
+ * @param object $post
44
+ * @return string
45
+ */
46
+ public function enter_title_here( $text, $post ) {
47
+ if ( $post->post_type == 'sp_official' ) {
48
+ return esc_attr__( 'Name', 'sportspress' );
49
+ }
50
+
51
+ return $text;
52
+ }
53
  }
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  endif;
56
 
57
  return new SP_Admin_CPT_Official();
includes/admin/post-types/class-sp-admin-cpt-outcome.php CHANGED
@@ -2,73 +2,77 @@
2
  /**
3
  * Admin functions for the outcomes post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 0.9
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Outcome' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Outcome Class
20
- */
21
- class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_outcome';
28
 
29
- // Admin Columns
30
- add_filter( 'manage_edit-sp_outcome_columns', array( $this, 'edit_columns' ) );
31
- add_action( 'manage_sp_outcome_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
32
-
33
- // Call SP_Admin_CPT constructor
34
- parent::__construct();
35
- }
36
 
37
- /**
38
- * Change the columns shown in admin.
39
- */
40
- public function edit_columns( $existing_columns ) {
41
- $columns = array(
42
- 'cb' => '<input type="checkbox" />',
43
- 'title' => __( 'Label', 'sportspress' ),
44
- 'sp_key' => __( 'Variable', 'sportspress' ),
45
- 'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
46
- 'sp_description' => __( 'Description', 'sportspress' ),
47
- );
48
- return apply_filters( 'sportspress_outcome_admin_columns', $columns );
49
- }
50
 
51
- /**
52
- * Define our custom columns shown in admin.
53
- * @param string $column
54
- */
55
- public function custom_columns( $column, $post_id ) {
56
- switch ( $column ):
57
- case 'sp_key':
58
- global $post;
59
- echo $post->post_name;
60
- break;
61
- case 'sp_abbreviation':
62
- global $post;
63
- echo sp_get_post_abbreviation( $post->ID );
64
- break;
65
- case 'sp_description':
66
- global $post;
67
- echo '<span class="description">' . $post->post_excerpt . '</span>';
68
- break;
69
- endswitch;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
- }
72
 
73
  endif;
74
 
2
  /**
3
  * Admin functions for the outcomes post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Outcome' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Outcome Class
23
  */
24
+ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_outcome';
 
 
31
 
32
+ // Admin Columns
33
+ add_filter( 'manage_edit-sp_outcome_columns', array( $this, 'edit_columns' ) );
34
+ add_action( 'manage_sp_outcome_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
 
35
 
36
+ // Call SP_Admin_CPT constructor
37
+ parent::__construct();
38
+ }
39
+
40
+ /**
41
+ * Change the columns shown in admin.
42
+ */
43
+ public function edit_columns( $existing_columns ) {
44
+ $columns = array(
45
+ 'cb' => '<input type="checkbox" />',
46
+ 'title' => esc_attr__( 'Label', 'sportspress' ),
47
+ 'sp_key' => esc_attr__( 'Variable', 'sportspress' ),
48
+ 'sp_abbreviation' => esc_attr__( 'Abbreviation', 'sportspress' ),
49
+ 'sp_description' => esc_attr__( 'Description', 'sportspress' ),
50
+ );
51
+ return apply_filters( 'sportspress_outcome_admin_columns', $columns );
52
+ }
53
+
54
+ /**
55
+ * Define our custom columns shown in admin.
56
+ *
57
+ * @param string $column
58
+ */
59
+ public function custom_columns( $column, $post_id ) {
60
+ switch ( $column ) :
61
+ case 'sp_key':
62
+ global $post;
63
+ echo esc_html( $post->post_name );
64
+ break;
65
+ case 'sp_abbreviation':
66
+ global $post;
67
+ echo esc_html( sp_get_post_abbreviation( $post->ID ) );
68
+ break;
69
+ case 'sp_description':
70
+ global $post;
71
+ echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
72
+ break;
73
+ endswitch;
74
+ }
75
  }
 
76
 
77
  endif;
78
 
includes/admin/post-types/class-sp-admin-cpt-performance.php CHANGED
@@ -2,82 +2,86 @@
2
  /**
3
  * Admin functions for the performance post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 1.4
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Performance' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Performance Class
20
- */
21
- class SP_Admin_CPT_Performance extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_performance';
28
 
29
- // Admin Columns
30
- add_filter( 'manage_edit-sp_performance_columns', array( $this, 'edit_columns' ) );
31
- add_action( 'manage_sp_performance_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
32
-
33
- // Call SP_Admin_CPT constructor
34
- parent::__construct();
35
- }
36
 
37
- /**
38
- * Change the columns shown in admin.
39
- */
40
- public function edit_columns( $existing_columns ) {
41
- $columns = array(
42
- 'cb' => '<input type="checkbox" />',
43
- 'sp_icon' => __( 'Icon', 'sportspress' ),
44
- 'title' => __( 'Label', 'sportspress' ),
45
- 'sp_key' => __( 'Variable', 'sportspress' ),
46
- 'sp_section' => __( 'Category', 'sportspress' ),
47
- 'sp_config_format' => __( 'Format', 'sportspress' ),
48
- 'sp_description' => __( 'Description', 'sportspress' ),
49
- );
50
- return apply_filters( 'sportspress_performance_admin_columns', $columns );
51
- }
52
 
53
- /**
54
- * Define our custom columns shown in admin.
55
- * @param string $column
56
- */
57
- public function custom_columns( $column, $post_id ) {
58
- switch ( $column ):
59
- case 'sp_icon':
60
- echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
61
- break;
62
- case 'sp_key':
63
- global $post;
64
- echo $post->post_name;
65
- break;
66
- case 'sp_section':
67
- global $post;
68
- echo sp_get_post_section( $post->ID );
69
- break;
70
- case 'sp_config_format':
71
- global $post;
72
- echo sp_get_post_format( $post->ID );
73
- break;
74
- case 'sp_description':
75
- global $post;
76
- echo '<span class="description">' . $post->post_excerpt . '</span>';
77
- break;
78
- endswitch;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
- }
81
 
82
  endif;
83
 
2
  /**
3
  * Admin functions for the performance post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Performance' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Performance Class
23
  */
24
+ class SP_Admin_CPT_Performance extends SP_Admin_CPT {
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_performance';
 
 
31
 
32
+ // Admin Columns
33
+ add_filter( 'manage_edit-sp_performance_columns', array( $this, 'edit_columns' ) );
34
+ add_action( 'manage_sp_performance_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ // Call SP_Admin_CPT constructor
37
+ parent::__construct();
38
+ }
39
+
40
+ /**
41
+ * Change the columns shown in admin.
42
+ */
43
+ public function edit_columns( $existing_columns ) {
44
+ $columns = array(
45
+ 'cb' => '<input type="checkbox" />',
46
+ 'sp_icon' => esc_attr__( 'Icon', 'sportspress' ),
47
+ 'title' => esc_attr__( 'Label', 'sportspress' ),
48
+ 'sp_key' => esc_attr__( 'Variable', 'sportspress' ),
49
+ 'sp_section' => esc_attr__( 'Category', 'sportspress' ),
50
+ 'sp_config_format' => esc_attr__( 'Format', 'sportspress' ),
51
+ 'sp_description' => esc_attr__( 'Description', 'sportspress' ),
52
+ );
53
+ return apply_filters( 'sportspress_performance_admin_columns', $columns );
54
+ }
55
+
56
+ /**
57
+ * Define our custom columns shown in admin.
58
+ *
59
+ * @param string $column
60
+ */
61
+ public function custom_columns( $column, $post_id ) {
62
+ switch ( $column ) :
63
+ case 'sp_icon':
64
+ echo has_post_thumbnail( $post_id ) ? wp_kses_post( edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) ) : '';
65
+ break;
66
+ case 'sp_key':
67
+ global $post;
68
+ echo esc_html( $post->post_name );
69
+ break;
70
+ case 'sp_section':
71
+ global $post;
72
+ echo esc_html( sp_get_post_section( $post->ID ) );
73
+ break;
74
+ case 'sp_config_format':
75
+ global $post;
76
+ echo esc_html( sp_get_post_format( $post->ID ) );
77
+ break;
78
+ case 'sp_description':
79
+ global $post;
80
+ echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
81
+ break;
82
+ endswitch;
83
+ }
84
  }
 
85
 
86
  endif;
87
 
includes/admin/post-types/class-sp-admin-cpt-player.php CHANGED
@@ -2,371 +2,420 @@
2
  /**
3
  * Admin functions for the players post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 2.6
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Player' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Player Class
20
- */
21
- class SP_Admin_CPT_Player extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_player';
28
-
29
- // Post title fields
30
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
31
-
32
- // Admin columns
33
- add_filter( 'manage_edit-sp_player_columns', array( $this, 'edit_columns' ) );
34
- add_action( 'manage_sp_player_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
35
-
36
- // Filtering
37
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
38
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
39
-
40
- // Quick edit
41
- add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_number' ), 10, 2 );
42
- add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_teams' ), 10, 2 );
43
- add_action( 'save_post', array( $this, 'quick_save' ) );
44
-
45
- // Bulk edit
46
- add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit_teams' ), 10, 2 );
47
- add_action( 'wp_ajax_save_bulk_edit_sp_player', array( $this, 'bulk_save' ) );
48
-
49
- // Call SP_Admin_CPT constructor
50
- parent::__construct();
51
- }
52
 
53
- /**
54
- * Change title boxes in admin.
55
- * @param string $text
56
- * @param object $post
57
- * @return string
58
- */
59
- public function enter_title_here( $text, $post ) {
60
- if ( $post->post_type == 'sp_player' )
61
- return __( 'Name', 'sportspress' );
62
 
63
- return $text;
64
- }
65
 
66
- /**
67
- * Change the columns shown in admin.
68
- */
69
- public function edit_columns( $existing_columns ) {
70
- unset( $existing_columns['author'], $existing_columns['date'] );
71
- $columns = array_merge( array(
72
- 'cb' => '<input type="checkbox" />',
73
- 'sp_number' => '<span class="dashicons sp-icon-tshirt sp-tip" title="' . __( 'Squad Number', 'sportspress' ) . '"></span>',
74
- 'title' => null,
75
- 'sp_position' => __( 'Positions', 'sportspress' ),
76
- 'sp_team' => __( 'Teams', 'sportspress' ),
77
- 'sp_league' => __( 'Leagues', 'sportspress' ),
78
- 'sp_season' => __( 'Seasons', 'sportspress' ),
79
- ), $existing_columns, array(
80
- 'title' => __( 'Name', 'sportspress' )
81
- ) );
82
- return apply_filters( 'sportspress_player_admin_columns', $columns );
83
- }
84
 
85
- /**
86
- * Define our custom columns shown in admin.
87
- * @param string $column
88
- */
89
- public function custom_columns( $column, $post_id ) {
90
- switch ( $column ):
91
- case 'sp_number':
92
- echo get_post_meta ( $post_id, 'sp_number', true );
93
- break;
94
- case 'sp_position':
95
- echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '&mdash;';
96
- break;
97
- case 'sp_team':
98
- $current_teams = get_post_meta( $post_id, 'sp_current_team', false );
99
- $past_teams = get_post_meta( $post_id, 'sp_past_team', false );
100
- $current_teams = array_filter( $current_teams );
101
- $past_teams = array_filter( $past_teams );
102
- echo '<span class="hidden sp-player-teams" data-current-teams="' . implode( ',', $current_teams ) . '" data-past-teams="' . implode( ',', $past_teams ) . '"></span>';
103
- $teams = (array)get_post_meta( $post_id, 'sp_team', false );
104
- $teams = array_filter( $teams );
105
- $teams = array_unique( $teams );
106
- if ( empty( $teams ) ):
107
- echo '&mdash;';
108
- else:
109
- foreach( $teams as $team_id ):
110
- if ( ! $team_id ) continue;
111
- $team = get_post( $team_id );
112
- if ( $team ):
113
- echo $team->post_title;
114
- if ( in_array( $team_id, $current_teams ) ):
115
- echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
116
- endif;
117
- echo '<br>';
118
- endif;
119
- endforeach;
120
- endif;
121
- break;
122
- case 'sp_league':
123
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '&mdash;';
124
- break;
125
- case 'sp_season':
126
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '&mdash;';
127
- break;
128
- case 'sp_venue':
129
- echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '&mdash;';
130
- break;
131
- endswitch;
132
- }
133
 
134
- /**
135
- * Show a category filter box
136
- */
137
- public function filters() {
138
- global $typenow, $wp_query;
139
-
140
- if ( $typenow != 'sp_player' )
141
- return;
142
-
143
- if ( taxonomy_exists( 'sp_position' ) ):
144
- $selected = isset( $_REQUEST['sp_position'] ) ? $_REQUEST['sp_position'] : null;
145
- $args = array(
146
- 'show_option_all' => __( 'Show all positions', 'sportspress' ),
147
- 'taxonomy' => 'sp_position',
148
- 'name' => 'sp_position',
149
- 'selected' => $selected
150
- );
151
- sp_dropdown_taxonomies( $args );
152
- endif;
153
-
154
- $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
155
- $args = array(
156
- 'post_type' => 'sp_team',
157
- 'name' => 'team',
158
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
159
- 'selected' => $selected,
160
- 'values' => 'ID',
161
- );
162
- wp_dropdown_pages( $args );
163
-
164
- if ( taxonomy_exists( 'sp_league' ) ):
165
- $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
166
- $args = array(
167
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
168
- 'taxonomy' => 'sp_league',
169
- 'name' => 'sp_league',
170
- 'selected' => $selected
 
 
 
 
 
 
 
 
 
 
171
  );
172
- sp_dropdown_taxonomies( $args );
173
- endif;
174
-
175
- if ( taxonomy_exists( 'sp_season' ) ):
176
- $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
177
- $args = array(
178
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
179
- 'taxonomy' => 'sp_season',
180
- 'name' => 'sp_season',
181
- 'selected' => $selected
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  );
183
- sp_dropdown_taxonomies( $args );
184
- endif;
185
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
 
187
- /**
188
- * Filter in admin based on options
189
- *
190
- * @param mixed $query
191
- */
192
- public function filters_query( $query ) {
193
 
194
- if ( empty ( $query->query_vars['post_type'] ) || $query->query_vars['post_type'] !== 'sp_player' ) return $query;
 
 
195
 
196
- global $typenow, $wp_query;
197
 
198
- if ( $typenow == 'sp_player' ) {
199
 
200
- if ( ! empty( $_GET['team'] ) ) {
201
- $query->query_vars['meta_value'] = $_GET['team'];
202
- $query->query_vars['meta_key'] = 'sp_team';
 
203
  }
 
 
204
  }
205
 
206
- return $query;
207
- }
 
 
 
 
 
 
 
 
 
 
 
208
 
209
- /**
210
- * Quick edit squad number
211
- *
212
- * @param string $column_name
213
- * @param string $post_type
214
- */
215
- public function quick_edit_number( $column_name, $post_type ) {
216
- if ( $this->type !== $post_type ) return;
217
- if ( 'sp_number' !== $column_name ) return;
218
-
219
- static $print_nonce = true;
220
- if ( $print_nonce ) {
221
- $print_nonce = false;
222
- wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
223
- }
224
- ?>
225
  <fieldset class="inline-edit-col-right">
226
  <div class="inline-edit-col">
227
  <label>
228
- <span class="title"><?php _e( 'Squad Number', 'sportspress' ); ?></span>
229
  <span class="input-text-wrap"><input type="text" name="sp_number" class="inline-edit-menu-order-input"></span>
230
  </label>
231
  </div>
232
  </fieldset>
233
- <?php
234
- }
235
 
236
- /**
237
- * Quick edit teams
238
- *
239
- * @param string $column_name
240
- * @param string $post_type
241
- */
242
- public function quick_edit_teams( $column_name, $post_type ) {
243
- if ( $this->type !== $post_type ) return;
244
- if ( 'sp_team' !== $column_name ) return;
245
-
246
- $teams = get_posts( array(
247
- 'post_type' => 'sp_team',
248
- 'numberposts' => -1,
249
- 'post_status' => 'publish',
250
- ) );
251
-
252
- if ( ! $teams ) return;
253
- ?>
 
 
 
 
 
 
 
 
254
  <fieldset class="inline-edit-col-right">
255
  <div class="inline-edit-col">
256
- <span class="title inline-edit-categories-label"><?php _e( 'Current Teams', 'sportspress' ); ?></span>
257
  <input type="hidden" name="sp_current_team[]" value="0">
258
  <ul class="cat-checklist">
259
  <?php foreach ( $teams as $team ) { ?>
260
- <li><label class="selectit"><input value="<?php echo $team->ID; ?>" type="checkbox" name="sp_current_team[]"> <?php echo $team->post_title; ?></label></li>
261
  <?php } ?>
262
  </ul>
263
- <span class="title inline-edit-categories-label"><?php _e( 'Past Teams', 'sportspress' ); ?></span>
264
  <input type="hidden" name="sp_past_team[]" value="0">
265
  <ul class="cat-checklist">
266
  <?php foreach ( $teams as $team ) { ?>
267
- <li><label class="selectit"><input value="<?php echo $team->ID; ?>" type="checkbox" name="sp_past_team[]"> <?php echo $team->post_title; ?></label></li>
268
  <?php } ?>
269
  </ul>
270
  </div>
271
  </fieldset>
272
- <?php
273
- }
274
 
275
- /**
276
- * Save quick edit boxes
277
- *
278
- * @param int $post_id
279
- */
280
- public function quick_save( $post_id ) {
281
- if ( empty( $_POST ) ) return $post_id;
282
- if ( ! current_user_can( 'edit_post', $post_id ) ) return $post_id;;
 
 
 
 
283
 
284
- $_POST += array( "{$this->type}_edit_nonce" => '' );
285
- if ( ! wp_verify_nonce( $_POST["{$this->type}_edit_nonce"], plugin_basename( __FILE__ ) ) ) return $post_id;;
 
 
286
 
287
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id;
288
- if ( isset( $post->post_type ) && $post->post_type == 'revision' ) return $post_id;
 
 
 
 
 
 
 
 
289
 
290
- if ( isset( $_POST[ 'sp_number' ] ) ) {
291
- update_post_meta( $post_id, 'sp_number', $_POST[ 'sp_number' ] );
 
292
  }
293
 
294
- sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
295
- sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
296
- sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) );
297
- }
 
 
 
 
 
 
 
 
 
298
 
299
- /**
300
- * Bulk edit teams
301
- *
302
- * @param string $column_name
303
- * @param string $post_type
304
- */
305
- public function bulk_edit_teams( $column_name, $post_type ) {
306
- if ( $this->type !== $post_type ) return;
307
- if ( 'sp_team' !== $column_name ) return;
308
-
309
- static $print_nonce = true;
310
- if ( $print_nonce ) {
311
- $print_nonce = false;
312
- wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
313
- }
314
 
315
- $teams = get_posts( array(
316
- 'post_type' => 'sp_team',
317
- 'numberposts' => -1,
318
- 'post_status' => 'publish',
319
- ) );
320
-
321
- if ( ! $teams ) return;
322
- ?>
 
 
 
 
323
  <fieldset class="inline-edit-col-right">
324
  <div class="inline-edit-col">
325
- <span class="title inline-edit-categories-label"><?php _e( 'Current Teams', 'sportspress' ); ?></span>
326
  <input type="hidden" name="sp_current_team[]" value="0">
327
  <ul class="cat-checklist">
328
  <?php foreach ( $teams as $team ) { ?>
329
- <li><label class="selectit"><input value="<?php echo $team->ID; ?>" type="checkbox" name="sp_current_team[]"> <?php echo $team->post_title; ?></label></li>
330
  <?php } ?>
331
  </ul>
332
- <span class="title inline-edit-categories-label"><?php _e( 'Past Teams', 'sportspress' ); ?></span>
333
  <input type="hidden" name="sp_past_team[]" value="0">
334
  <ul class="cat-checklist">
335
  <?php foreach ( $teams as $team ) { ?>
336
- <li><label class="selectit"><input value="<?php echo $team->ID; ?>" type="checkbox" name="sp_past_team[]"> <?php echo $team->post_title; ?></label></li>
337
  <?php } ?>
338
  </ul>
339
  </div>
340
  </fieldset>
341
- <?php
342
- }
343
 
344
- /**
345
- * Save bulk edit boxes
346
- */
347
- public function bulk_save() {
348
- $_POST += array( "nonce" => '' );
349
- if ( ! wp_verify_nonce( $_POST["nonce"], plugin_basename( __FILE__ ) ) ) return;
 
 
350
 
351
- $post_ids = ( ! empty( $_POST[ 'post_ids' ] ) ) ? $_POST[ 'post_ids' ] : array();
352
 
353
- $current_teams = sp_array_value( $_POST, 'current_teams', array() );
354
- $past_teams = sp_array_value( $_POST, 'past_teams', array() );
355
- $teams = array_merge( $current_teams, $past_teams );
356
 
357
- if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
358
- foreach ( $post_ids as $post_id ) {
359
- if ( ! current_user_can( 'edit_post', $post_id ) ) continue;
 
 
360
 
361
- sp_add_post_meta_recursive( $post_id, 'sp_current_team', $current_teams );
362
- sp_add_post_meta_recursive( $post_id, 'sp_past_team', $past_teams );
363
- sp_add_post_meta_recursive( $post_id, 'sp_team', $teams );
 
364
  }
365
- }
366
 
367
- die();
 
368
  }
369
- }
370
 
371
  endif;
372
 
2
  /**
3
  * Admin functions for the players post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Player' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Player Class
23
  */
24
+ class SP_Admin_CPT_Player extends SP_Admin_CPT {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_player';
 
 
 
 
31
 
32
+ // Post title fields
33
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
34
 
35
+ // Admin columns
36
+ add_filter( 'manage_edit-sp_player_columns', array( $this, 'edit_columns' ) );
37
+ add_action( 'manage_sp_player_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
+ // Filtering
40
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
41
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
+ // Quick edit
44
+ add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_number' ), 10, 2 );
45
+ add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_teams' ), 10, 2 );
46
+ add_action( 'save_post', array( $this, 'quick_save' ) );
47
+
48
+ // Bulk edit
49
+ add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit_teams' ), 10, 2 );
50
+ add_action( 'wp_ajax_save_bulk_edit_sp_player', array( $this, 'bulk_save' ) );
51
+
52
+ // Call SP_Admin_CPT constructor
53
+ parent::__construct();
54
+ }
55
+
56
+ /**
57
+ * Change title boxes in admin.
58
+ *
59
+ * @param string $text
60
+ * @param object $post
61
+ * @return string
62
+ */
63
+ public function enter_title_here( $text, $post ) {
64
+ if ( $post->post_type == 'sp_player' ) {
65
+ return esc_attr__( 'Name', 'sportspress' );
66
+ }
67
+
68
+ return $text;
69
+ }
70
+
71
+ /**
72
+ * Change the columns shown in admin.
73
+ */
74
+ public function edit_columns( $existing_columns ) {
75
+ unset( $existing_columns['author'], $existing_columns['date'] );
76
+ $columns = array_merge(
77
+ array(
78
+ 'cb' => '<input type="checkbox" />',
79
+ 'sp_number' => '<span class="dashicons sp-icon-tshirt sp-tip" title="' . esc_attr__( 'Squad Number', 'sportspress' ) . '"></span>',
80
+ 'title' => null,
81
+ 'sp_position' => esc_attr__( 'Positions', 'sportspress' ),
82
+ 'sp_team' => esc_attr__( 'Teams', 'sportspress' ),
83
+ 'sp_league' => esc_attr__( 'Leagues', 'sportspress' ),
84
+ 'sp_season' => esc_attr__( 'Seasons', 'sportspress' ),
85
+ ),
86
+ $existing_columns,
87
+ array(
88
+ 'title' => esc_attr__( 'Name', 'sportspress' ),
89
+ )
90
  );
91
+ return apply_filters( 'sportspress_player_admin_columns', $columns );
92
+ }
93
+
94
+ /**
95
+ * Define our custom columns shown in admin.
96
+ *
97
+ * @param string $column
98
+ */
99
+ public function custom_columns( $column, $post_id ) {
100
+ switch ( $column ) :
101
+ case 'sp_number':
102
+ echo esc_html( get_post_meta( $post_id, 'sp_number', true ) );
103
+ break;
104
+ case 'sp_position':
105
+ echo get_the_terms( $post_id, 'sp_position' ) ? wp_kses_post( the_terms( $post_id, 'sp_position' ) ) : '&mdash;';
106
+ break;
107
+ case 'sp_team':
108
+ $current_teams = get_post_meta( $post_id, 'sp_current_team', false );
109
+ $past_teams = get_post_meta( $post_id, 'sp_past_team', false );
110
+ $current_teams = array_filter( $current_teams );
111
+ $past_teams = array_filter( $past_teams );
112
+ echo '<span class="hidden sp-player-teams" data-current-teams="' . implode( ',', array_map( 'esc_attr', $current_teams ) ) . '" data-past-teams="' . implode( ',', array_map( 'esc_attr', $past_teams ) ) . '"></span>';
113
+ $teams = (array) get_post_meta( $post_id, 'sp_team', false );
114
+ $teams = array_filter( $teams );
115
+ $teams = array_unique( $teams );
116
+ if ( empty( $teams ) ) :
117
+ echo '&mdash;';
118
+ else :
119
+ foreach ( $teams as $team_id ) :
120
+ if ( ! $team_id ) {
121
+ continue;
122
+ }
123
+ $team = get_post( $team_id );
124
+ if ( $team ) :
125
+ echo esc_html( $team->post_title );
126
+ if ( in_array( $team_id, $current_teams ) ) :
127
+ echo '<span class="dashicons dashicons-yes" title="' . esc_attr__( 'Current Team', 'sportspress' ) . '"></span>';
128
+ endif;
129
+ echo '<br>';
130
+ endif;
131
+ endforeach;
132
+ endif;
133
+ break;
134
+ case 'sp_league':
135
+ echo get_the_terms( $post_id, 'sp_league' ) ? wp_kses_post( the_terms( $post_id, 'sp_league' ) ) : '&mdash;';
136
+ break;
137
+ case 'sp_season':
138
+ echo get_the_terms( $post_id, 'sp_season' ) ? wp_kses_post( the_terms( $post_id, 'sp_season' ) ) : '&mdash;';
139
+ break;
140
+ case 'sp_venue':
141
+ echo get_the_terms( $post_id, 'sp_venue' ) ? wp_kses_post( the_terms( $post_id, 'sp_venue' ) ) : '&mdash;';
142
+ break;
143
+ endswitch;
144
+ }
145
+
146
+ /**
147
+ * Show a category filter box
148
+ */
149
+ public function filters() {
150
+ global $typenow, $wp_query;
151
+
152
+ if ( $typenow != 'sp_player' ) {
153
+ return;
154
+ }
155
+
156
+ if ( taxonomy_exists( 'sp_position' ) ) :
157
+ $selected = isset( $_REQUEST['sp_position'] ) ? sanitize_key( $_REQUEST['sp_position'] ) : null;
158
+ $args = array(
159
+ 'show_option_all' => esc_attr__( 'Show all positions', 'sportspress' ),
160
+ 'taxonomy' => 'sp_position',
161
+ 'name' => 'sp_position',
162
+ 'selected' => $selected,
163
+ );
164
+ sp_dropdown_taxonomies( $args );
165
+ endif;
166
+
167
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
168
+ $args = array(
169
+ 'post_type' => 'sp_team',
170
+ 'name' => 'team',
171
+ 'show_option_none' => esc_attr__( 'Show all teams', 'sportspress' ),
172
+ 'selected' => $selected,
173
+ 'values' => 'ID',
174
  );
175
+ wp_dropdown_pages( $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
176
+
177
+ if ( taxonomy_exists( 'sp_league' ) ) :
178
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
179
+ $args = array(
180
+ 'show_option_all' => esc_attr__( 'Show all leagues', 'sportspress' ),
181
+ 'taxonomy' => 'sp_league',
182
+ 'name' => 'sp_league',
183
+ 'selected' => $selected,
184
+ );
185
+ sp_dropdown_taxonomies( $args );
186
+ endif;
187
+
188
+ if ( taxonomy_exists( 'sp_season' ) ) :
189
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
190
+ $args = array(
191
+ 'show_option_all' => esc_attr__( 'Show all seasons', 'sportspress' ),
192
+ 'taxonomy' => 'sp_season',
193
+ 'name' => 'sp_season',
194
+ 'selected' => $selected,
195
+ );
196
+ sp_dropdown_taxonomies( $args );
197
+ endif;
198
+ }
199
 
200
+ /**
201
+ * Filter in admin based on options
202
+ *
203
+ * @param mixed $query
204
+ */
205
+ public function filters_query( $query ) {
206
 
207
+ if ( empty( $query->query_vars['post_type'] ) || $query->query_vars['post_type'] !== 'sp_player' ) {
208
+ return $query;
209
+ }
210
 
211
+ global $typenow, $wp_query;
212
 
213
+ if ( $typenow == 'sp_player' ) {
214
 
215
+ if ( ! empty( $_GET['team'] ) ) {
216
+ $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
217
+ $query->query_vars['meta_key'] = 'sp_team';
218
+ }
219
  }
220
+
221
+ return $query;
222
  }
223
 
224
+ /**
225
+ * Quick edit squad number
226
+ *
227
+ * @param string $column_name
228
+ * @param string $post_type
229
+ */
230
+ public function quick_edit_number( $column_name, $post_type ) {
231
+ if ( $this->type !== $post_type ) {
232
+ return;
233
+ }
234
+ if ( 'sp_number' !== $column_name ) {
235
+ return;
236
+ }
237
 
238
+ static $print_nonce = true;
239
+ if ( $print_nonce ) {
240
+ $print_nonce = false;
241
+ wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
242
+ }
243
+ ?>
 
 
 
 
 
 
 
 
 
 
244
  <fieldset class="inline-edit-col-right">
245
  <div class="inline-edit-col">
246
  <label>
247
+ <span class="title"><?php esc_html_e( 'Squad Number', 'sportspress' ); ?></span>
248
  <span class="input-text-wrap"><input type="text" name="sp_number" class="inline-edit-menu-order-input"></span>
249
  </label>
250
  </div>
251
  </fieldset>
252
+ <?php
253
+ }
254
 
255
+ /**
256
+ * Quick edit teams
257
+ *
258
+ * @param string $column_name
259
+ * @param string $post_type
260
+ */
261
+ public function quick_edit_teams( $column_name, $post_type ) {
262
+ if ( $this->type !== $post_type ) {
263
+ return;
264
+ }
265
+ if ( 'sp_team' !== $column_name ) {
266
+ return;
267
+ }
268
+
269
+ $teams = get_posts(
270
+ array(
271
+ 'post_type' => 'sp_team',
272
+ 'numberposts' => -1,
273
+ 'post_status' => 'publish',
274
+ )
275
+ );
276
+
277
+ if ( ! $teams ) {
278
+ return;
279
+ }
280
+ ?>
281
  <fieldset class="inline-edit-col-right">
282
  <div class="inline-edit-col">
283
+ <span class="title inline-edit-categories-label"><?php esc_html_e( 'Current Teams', 'sportspress' ); ?></span>
284
  <input type="hidden" name="sp_current_team[]" value="0">
285
  <ul class="cat-checklist">
286
  <?php foreach ( $teams as $team ) { ?>
287
+ <li><label class="selectit"><input value="<?php echo esc_attr( $team->ID ); ?>" type="checkbox" name="sp_current_team[]"> <?php echo esc_html( $team->post_title ); ?></label></li>
288
  <?php } ?>
289
  </ul>
290
+ <span class="title inline-edit-categories-label"><?php esc_html_e( 'Past Teams', 'sportspress' ); ?></span>
291
  <input type="hidden" name="sp_past_team[]" value="0">
292
  <ul class="cat-checklist">
293
  <?php foreach ( $teams as $team ) { ?>
294
+ <li><label class="selectit"><input value="<?php echo esc_attr( $team->ID ); ?>" type="checkbox" name="sp_past_team[]"> <?php echo esc_html( $team->post_title ); ?></label></li>
295
  <?php } ?>
296
  </ul>
297
  </div>
298
  </fieldset>
299
+ <?php
300
+ }
301
 
302
+ /**
303
+ * Save quick edit boxes
304
+ *
305
+ * @param int $post_id
306
+ */
307
+ public function quick_save( $post_id ) {
308
+ if ( empty( $_POST ) ) {
309
+ return $post_id;
310
+ }
311
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
312
+ return $post_id;
313
+ }
314
 
315
+ $_POST += array( "{$this->type}_edit_nonce" => '' );
316
+ if ( ! isset( $_POST[ "{$this->type}_edit_nonce" ] ) || ! wp_verify_nonce( sanitize_key( $_POST[ "{$this->type}_edit_nonce" ] ), plugin_basename( __FILE__ ) ) ) {
317
+ return $post_id;
318
+ }
319
 
320
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
321
+ return $post_id;
322
+ }
323
+ if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
324
+ return $post_id;
325
+ }
326
+
327
+ if ( isset( $_POST['sp_number'] ) ) {
328
+ update_post_meta( $post_id, 'sp_number', sanitize_text_field( wp_unslash( $_POST['sp_number'] ) ) );
329
+ }
330
 
331
+ sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
332
+ sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
333
+ sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) );
334
  }
335
 
336
+ /**
337
+ * Bulk edit teams
338
+ *
339
+ * @param string $column_name
340
+ * @param string $post_type
341
+ */
342
+ public function bulk_edit_teams( $column_name, $post_type ) {
343
+ if ( $this->type !== $post_type ) {
344
+ return;
345
+ }
346
+ if ( 'sp_team' !== $column_name ) {
347
+ return;
348
+ }
349
 
350
+ static $print_nonce = true;
351
+ if ( $print_nonce ) {
352
+ $print_nonce = false;
353
+ wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
354
+ }
 
 
 
 
 
 
 
 
 
 
355
 
356
+ $teams = get_posts(
357
+ array(
358
+ 'post_type' => 'sp_team',
359
+ 'numberposts' => -1,
360
+ 'post_status' => 'publish',
361
+ )
362
+ );
363
+
364
+ if ( ! $teams ) {
365
+ return;
366
+ }
367
+ ?>
368
  <fieldset class="inline-edit-col-right">
369
  <div class="inline-edit-col">
370
+ <span class="title inline-edit-categories-label"><?php esc_html_e( 'Current Teams', 'sportspress' ); ?></span>
371
  <input type="hidden" name="sp_current_team[]" value="0">
372
  <ul class="cat-checklist">
373
  <?php foreach ( $teams as $team ) { ?>
374
+ <li><label class="selectit"><input value="<?php echo esc_attr( $team->ID ); ?>" type="checkbox" name="sp_current_team[]"> <?php echo esc_attr( $team->post_title ); ?></label></li>
375
  <?php } ?>
376
  </ul>
377
+ <span class="title inline-edit-categories-label"><?php esc_html_e( 'Past Teams', 'sportspress' ); ?></span>
378
  <input type="hidden" name="sp_past_team[]" value="0">
379
  <ul class="cat-checklist">
380
  <?php foreach ( $teams as $team ) { ?>
381
+ <li><label class="selectit"><input value="<?php echo esc_attr( $team->ID ); ?>" type="checkbox" name="sp_past_team[]"> <?php echo esc_attr( $team->post_title ); ?></label></li>
382
  <?php } ?>
383
  </ul>
384
  </div>
385
  </fieldset>
386
+ <?php
387
+ }
388
 
389
+ /**
390
+ * Save bulk edit boxes
391
+ */
392
+ public function bulk_save() {
393
+ $_POST += array( 'nonce' => '' );
394
+ if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), plugin_basename( __FILE__ ) ) ) {
395
+ return;
396
+ }
397
 
398
+ $post_ids = ( ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
399
 
400
+ $current_teams = sp_array_value( $_POST, 'current_teams', array() );
401
+ $past_teams = sp_array_value( $_POST, 'past_teams', array() );
402
+ $teams = array_merge( $current_teams, $past_teams );
403
 
404
+ if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
405
+ foreach ( $post_ids as $post_id ) {
406
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
407
+ continue;
408
+ }
409
 
410
+ sp_add_post_meta_recursive( $post_id, 'sp_current_team', $current_teams );
411
+ sp_add_post_meta_recursive( $post_id, 'sp_past_team', $past_teams );
412
+ sp_add_post_meta_recursive( $post_id, 'sp_team', $teams );
413
+ }
414
  }
 
415
 
416
+ die();
417
+ }
418
  }
 
419
 
420
  endif;
421
 
includes/admin/post-types/class-sp-admin-cpt-result.php CHANGED
@@ -2,68 +2,72 @@
2
  /**
3
  * Admin functions for the results post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 0.9
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Result' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Result Class
20
- */
21
- class SP_Admin_CPT_Result extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_result';
28
 
29
- // Admin Columns
30
- add_filter( 'manage_edit-sp_result_columns', array( $this, 'edit_columns' ) );
31
- add_action( 'manage_sp_result_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
32
-
33
- // Call SP_Admin_CPT constructor
34
- parent::__construct();
35
- }
36
 
37
- /**
38
- * Change the columns shown in admin.
39
- */
40
- public function edit_columns( $existing_columns ) {
41
- $columns = array(
42
- 'cb' => '<input type="checkbox" />',
43
- 'title' => __( 'Label', 'sportspress' ),
44
- 'sp_key' => __( 'Variable', 'sportspress' ),
45
- 'sp_description' => __( 'Description', 'sportspress' ),
46
- );
47
- return apply_filters( 'sportspress_result_admin_columns', $columns );
48
- }
49
 
50
- /**
51
- * Define our custom columns shown in admin.
52
- * @param string $column
53
- */
54
- public function custom_columns( $column, $post_id ) {
55
- switch ( $column ):
56
- case 'sp_key':
57
- global $post;
58
- echo $post->post_name . 'for, ' . $post->post_name . 'against';
59
- break;
60
- case 'sp_description':
61
- global $post;
62
- echo '<span class="description">' . $post->post_excerpt . '</span>';
63
- break;
64
- endswitch;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
- }
67
 
68
  endif;
69
 
2
  /**
3
  * Admin functions for the results post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Result' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Result Class
23
  */
24
+ class SP_Admin_CPT_Result extends SP_Admin_CPT {
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_result';
 
 
31
 
32
+ // Admin Columns
33
+ add_filter( 'manage_edit-sp_result_columns', array( $this, 'edit_columns' ) );
34
+ add_action( 'manage_sp_result_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
35
 
36
+ // Call SP_Admin_CPT constructor
37
+ parent::__construct();
38
+ }
39
+
40
+ /**
41
+ * Change the columns shown in admin.
42
+ */
43
+ public function edit_columns( $existing_columns ) {
44
+ $columns = array(
45
+ 'cb' => '<input type="checkbox" />',
46
+ 'title' => esc_attr__( 'Label', 'sportspress' ),
47
+ 'sp_key' => esc_attr__( 'Variable', 'sportspress' ),
48
+ 'sp_description' => esc_attr__( 'Description', 'sportspress' ),
49
+ );
50
+ return apply_filters( 'sportspress_result_admin_columns', $columns );
51
+ }
52
+
53
+ /**
54
+ * Define our custom columns shown in admin.
55
+ *
56
+ * @param string $column
57
+ */
58
+ public function custom_columns( $column, $post_id ) {
59
+ switch ( $column ) :
60
+ case 'sp_key':
61
+ global $post;
62
+ echo esc_html( $post->post_name ) . 'for, ' . esc_html( $post->post_name ) . 'against';
63
+ break;
64
+ case 'sp_description':
65
+ global $post;
66
+ echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
67
+ break;
68
+ endswitch;
69
+ }
70
  }
 
71
 
72
  endif;
73
 
includes/admin/post-types/class-sp-admin-cpt-spec.php CHANGED
@@ -2,68 +2,72 @@
2
  /**
3
  * Admin functions for the columns post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 2.6
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Spec' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Spec Class
20
- */
21
- class SP_Admin_CPT_Spec extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_spec';
28
 
29
- // Admin Columns
30
- add_filter( 'manage_edit-sp_spec_columns', array( $this, 'edit_columns' ) );
31
- add_action( 'manage_sp_spec_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
32
-
33
- // Call SP_Admin_CPT constructor
34
- parent::__construct();
35
- }
36
 
37
- /**
38
- * Change the columns shown in admin.
39
- */
40
- public function edit_columns( $existing_columns ) {
41
- $columns = array(
42
- 'cb' => '<input type="checkbox" />',
43
- 'title' => __( 'Label', 'sportspress' ),
44
- 'sp_key' => __( 'Variable', 'sportspress' ),
45
- 'sp_description' => __( 'Description', 'sportspress' ),
46
- );
47
- return apply_filters( 'sportspress_spec_admin_columns', $columns );
48
- }
49
 
50
- /**
51
- * Define our custom columns shown in admin.
52
- * @param string $column
53
- */
54
- public function custom_columns( $column, $post_id ) {
55
- switch ( $column ):
56
- case 'sp_key':
57
- global $post;
58
- echo $post->post_name;
59
- break;
60
- case 'sp_description':
61
- global $post;
62
- echo '<span class="description">' . $post->post_excerpt . '</span>';
63
- break;
64
- endswitch;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
- }
67
 
68
  endif;
69
 
2
  /**
3
  * Admin functions for the columns post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Spec' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Spec Class
23
  */
24
+ class SP_Admin_CPT_Spec extends SP_Admin_CPT {
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_spec';
 
 
31
 
32
+ // Admin Columns
33
+ add_filter( 'manage_edit-sp_spec_columns', array( $this, 'edit_columns' ) );
34
+ add_action( 'manage_sp_spec_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
35
 
36
+ // Call SP_Admin_CPT constructor
37
+ parent::__construct();
38
+ }
39
+
40
+ /**
41
+ * Change the columns shown in admin.
42
+ */
43
+ public function edit_columns( $existing_columns ) {
44
+ $columns = array(
45
+ 'cb' => '<input type="checkbox" />',
46
+ 'title' => esc_attr__( 'Label', 'sportspress' ),
47
+ 'sp_key' => esc_attr__( 'Variable', 'sportspress' ),
48
+ 'sp_description' => esc_attr__( 'Description', 'sportspress' ),
49
+ );
50
+ return apply_filters( 'sportspress_spec_admin_columns', $columns );
51
+ }
52
+
53
+ /**
54
+ * Define our custom columns shown in admin.
55
+ *
56
+ * @param string $column
57
+ */
58
+ public function custom_columns( $column, $post_id ) {
59
+ switch ( $column ) :
60
+ case 'sp_key':
61
+ global $post;
62
+ echo esc_html( $post->post_name );
63
+ break;
64
+ case 'sp_description':
65
+ global $post;
66
+ echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
67
+ break;
68
+ endswitch;
69
+ }
70
  }
 
71
 
72
  endif;
73
 
includes/admin/post-types/class-sp-admin-cpt-staff.php CHANGED
@@ -2,169 +2,182 @@
2
  /**
3
  * Admin functions for the staff post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 2.5
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Staff' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Staff Class
20
- */
21
- class SP_Admin_CPT_Staff extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_staff';
28
-
29
- // Post title fields
30
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
31
-
32
- // Admin Columns
33
- add_filter( 'manage_edit-sp_staff_columns', array( $this, 'edit_columns' ) );
34
- add_action( 'manage_sp_staff_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
35
-
36
- // Filtering
37
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
38
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
39
-
40
- // Call SP_Admin_CPT constructor
41
- parent::__construct();
42
- }
43
 
44
- /**
45
- * Change title boxes in admin.
46
- * @param string $text
47
- * @param object $post
48
- * @return string
49
- */
50
- public function enter_title_here( $text, $post ) {
51
- if ( $post->post_type == 'sp_staff' )
52
- return __( 'Name', 'sportspress' );
53
 
54
- return $text;
55
- }
56
 
57
- /**
58
- * Change the columns shown in admin.
59
- */
60
- public function edit_columns( $existing_columns ) {
61
- unset( $existing_columns['author'], $existing_columns['date'] );
62
- $columns = array_merge( array(
63
- 'cb' => '<input type="checkbox" />',
64
- 'title' => null,
65
- 'sp_role' => __( 'Job', 'sportspress' ),
66
- 'sp_team' => __( 'Teams', 'sportspress' ),
67
- 'sp_league' => __( 'Leagues', 'sportspress' ),
68
- 'sp_season' => __( 'Seasons', 'sportspress' ),
69
- ), $existing_columns, array(
70
- 'title' => __( 'Name', 'sportspress' )
71
- ) );
72
- return apply_filters( 'sportspress_staff_admin_columns', $columns );
73
- }
74
 
75
- /**
76
- * Define our custom columns shown in admin.
77
- * @param string $column
78
- */
79
- public function custom_columns( $column, $post_id ) {
80
- switch ( $column ):
81
- case 'sp_role':
82
- echo get_the_terms( $post_id, 'sp_role' ) ? the_terms( $post_id, 'sp_role' ) : '&mdash;';
83
- break;
84
- case 'sp_team':
85
- $teams = (array)get_post_meta( $post_id, 'sp_team', false );
86
- $teams = array_filter( $teams );
87
- if ( empty( $teams ) ):
88
- echo '&mdash;';
89
- else:
90
- $current_teams = get_post_meta( $post_id, 'sp_current_team', false );
91
- foreach( $teams as $team_id ):
92
- if ( ! $team_id ) continue;
93
- $team = get_post( $team_id );
94
- if ( $team ):
95
- echo $team->post_title;
96
- if ( in_array( $team_id, $current_teams ) ):
97
- echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
98
- endif;
99
- echo '<br>';
100
- endif;
101
- endforeach;
102
- endif;
103
- break;
104
- case 'sp_league':
105
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '&mdash;';
106
- break;
107
- case 'sp_season':
108
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '&mdash;';
109
- break;
110
- endswitch;
111
- }
112
 
113
- /**
114
- * Show a category filter box
115
- */
116
- public function filters() {
117
- global $typenow, $wp_query;
118
-
119
- if ( $typenow != 'sp_staff' )
120
- return;
121
-
122
- $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
123
- $args = array(
124
- 'post_type' => 'sp_team',
125
- 'name' => 'team',
126
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
127
- 'selected' => $selected,
128
- 'values' => 'ID',
129
- );
130
- wp_dropdown_pages( $args );
131
-
132
- $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
133
- $args = array(
134
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
135
- 'taxonomy' => 'sp_league',
136
- 'name' => 'sp_league',
137
- 'selected' => $selected
138
- );
139
- sp_dropdown_taxonomies( $args );
140
-
141
- $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
142
- $args = array(
143
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
144
- 'taxonomy' => 'sp_season',
145
- 'name' => 'sp_season',
146
- 'selected' => $selected
147
- );
148
- sp_dropdown_taxonomies( $args );
149
- }
150
 
151
- /**
152
- * Filter in admin based on options
153
- *
154
- * @param mixed $query
155
- */
156
- public function filters_query( $query ) {
157
- global $typenow, $wp_query;
 
 
 
 
 
 
 
158
 
159
- if ( $typenow == 'sp_staff' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
- if ( ! empty( $_GET['team'] ) ) {
162
- $query->query_vars['meta_value'] = $_GET['team'];
163
- $query->query_vars['meta_key'] = 'sp_team';
164
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
  }
167
- }
168
 
169
  endif;
170
 
2
  /**
3
  * Admin functions for the staff post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Staff' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Staff Class
23
  */
24
+ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_staff';
 
 
 
 
31
 
32
+ // Post title fields
33
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
34
 
35
+ // Admin Columns
36
+ add_filter( 'manage_edit-sp_staff_columns', array( $this, 'edit_columns' ) );
37
+ add_action( 'manage_sp_staff_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
+ // Filtering
40
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
41
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
+ // Call SP_Admin_CPT constructor
44
+ parent::__construct();
45
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
+ /**
48
+ * Change title boxes in admin.
49
+ *
50
+ * @param string $text
51
+ * @param object $post
52
+ * @return string
53
+ */
54
+ public function enter_title_here( $text, $post ) {
55
+ if ( $post->post_type == 'sp_staff' ) {
56
+ return esc_attr__( 'Name', 'sportspress' );
57
+ }
58
+
59
+ return $text;
60
+ }
61
 
62
+ /**
63
+ * Change the columns shown in admin.
64
+ */
65
+ public function edit_columns( $existing_columns ) {
66
+ unset( $existing_columns['author'], $existing_columns['date'] );
67
+ $columns = array_merge(
68
+ array(
69
+ 'cb' => '<input type="checkbox" />',
70
+ 'title' => null,
71
+ 'sp_role' => esc_attr__( 'Job', 'sportspress' ),
72
+ 'sp_team' => esc_attr__( 'Teams', 'sportspress' ),
73
+ 'sp_league' => esc_attr__( 'Leagues', 'sportspress' ),
74
+ 'sp_season' => esc_attr__( 'Seasons', 'sportspress' ),
75
+ ),
76
+ $existing_columns,
77
+ array(
78
+ 'title' => esc_attr__( 'Name', 'sportspress' ),
79
+ )
80
+ );
81
+ return apply_filters( 'sportspress_staff_admin_columns', $columns );
82
+ }
83
+
84
+ /**
85
+ * Define our custom columns shown in admin.
86
+ *
87
+ * @param string $column
88
+ */
89
+ public function custom_columns( $column, $post_id ) {
90
+ switch ( $column ) :
91
+ case 'sp_role':
92
+ echo get_the_terms( $post_id, 'sp_role' ) ? wp_kses_post( the_terms( $post_id, 'sp_role' ) ) : '&mdash;';
93
+ break;
94
+ case 'sp_team':
95
+ $teams = (array) get_post_meta( $post_id, 'sp_team', false );
96
+ $teams = array_filter( $teams );
97
+ if ( empty( $teams ) ) :
98
+ echo '&mdash;';
99
+ else :
100
+ $current_teams = get_post_meta( $post_id, 'sp_current_team', false );
101
+ foreach ( $teams as $team_id ) :
102
+ if ( ! $team_id ) {
103
+ continue;
104
+ }
105
+ $team = get_post( $team_id );
106
+ if ( $team ) :
107
+ echo esc_html( $team->post_title );
108
+ if ( in_array( $team_id, $current_teams ) ) :
109
+ echo '<span class="dashicons dashicons-yes" title="' . esc_attr__( 'Current Team', 'sportspress' ) . '"></span>';
110
+ endif;
111
+ echo '<br>';
112
+ endif;
113
+ endforeach;
114
+ endif;
115
+ break;
116
+ case 'sp_league':
117
+ echo get_the_terms( $post_id, 'sp_league' ) ? wp_kses_post( the_terms( $post_id, 'sp_league' ) ) : '&mdash;';
118
+ break;
119
+ case 'sp_season':
120
+ echo get_the_terms( $post_id, 'sp_season' ) ? wp_kses_post( the_terms( $post_id, 'sp_season' ) ) : '&mdash;';
121
+ break;
122
+ endswitch;
123
+ }
124
 
125
+ /**
126
+ * Show a category filter box
127
+ */
128
+ public function filters() {
129
+ global $typenow, $wp_query;
130
+
131
+ if ( $typenow != 'sp_staff' ) {
132
+ return;
133
+ }
134
+
135
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
136
+ $args = array(
137
+ 'post_type' => 'sp_team',
138
+ 'name' => 'team',
139
+ 'show_option_none' => esc_attr__( 'Show all teams', 'sportspress' ),
140
+ 'selected' => $selected,
141
+ 'values' => 'ID',
142
+ );
143
+ wp_dropdown_pages( $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
144
+
145
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
146
+ $args = array(
147
+ 'show_option_all' => esc_attr__( 'Show all leagues', 'sportspress' ),
148
+ 'taxonomy' => 'sp_league',
149
+ 'name' => 'sp_league',
150
+ 'selected' => $selected,
151
+ );
152
+ sp_dropdown_taxonomies( $args );
153
+
154
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
155
+ $args = array(
156
+ 'show_option_all' => esc_attr__( 'Show all seasons', 'sportspress' ),
157
+ 'taxonomy' => 'sp_season',
158
+ 'name' => 'sp_season',
159
+ 'selected' => $selected,
160
+ );
161
+ sp_dropdown_taxonomies( $args );
162
+ }
163
+
164
+ /**
165
+ * Filter in admin based on options
166
+ *
167
+ * @param mixed $query
168
+ */
169
+ public function filters_query( $query ) {
170
+ global $typenow, $wp_query;
171
+
172
+ if ( $typenow == 'sp_staff' ) {
173
+
174
+ if ( ! empty( $_GET['team'] ) ) {
175
+ $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
176
+ $query->query_vars['meta_key'] = 'sp_team';
177
+ }
178
+ }
179
  }
180
  }
 
181
 
182
  endif;
183
 
includes/admin/post-types/class-sp-admin-cpt-statistic.php CHANGED
@@ -2,80 +2,84 @@
2
  /**
3
  * Admin functions for the statistics post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 2.6.8
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Statistic' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Statistic Class
20
- */
21
- class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_statistic';
28
 
29
- // Admin Columns
30
- add_filter( 'manage_edit-sp_statistic_columns', array( $this, 'edit_columns' ) );
31
- add_action( 'manage_sp_statistic_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
32
-
33
- // Call SP_Admin_CPT constructor
34
- parent::__construct();
35
- }
36
 
37
- /**
38
- * Change the columns shown in admin.
39
- */
40
- public function edit_columns( $existing_columns ) {
41
- $columns = array(
42
- 'cb' => '<input type="checkbox" />',
43
- 'sp_icon' => __( 'Icon', 'sportspress' ),
44
- 'title' => __( 'Label', 'sportspress' ),
45
- 'sp_key' => __( 'Key', 'sportspress' ),
46
- 'sp_equation' => __( 'Equation', 'sportspress' ),
47
- 'sp_precision' => __( 'Decimal Places', 'sportspress' ),
48
- 'sp_description' => __( 'Description', 'sportspress' ),
49
- );
50
- return apply_filters( 'sportspress_statistic_admin_columns', $columns );
51
- }
52
 
53
- /**
54
- * Define our custom columns shown in admin.
55
- * @param string $column
56
- */
57
- public function custom_columns( $column, $post_id ) {
58
- switch ( $column ):
59
- case 'sp_icon':
60
- echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
61
- break;
62
- case 'sp_key':
63
- global $post;
64
- echo $post->post_name;
65
- break;
66
- case 'sp_equation':
67
- echo sp_get_post_equation( $post_id );
68
- break;
69
- case 'sp_precision':
70
- echo sp_get_post_precision( $post_id );
71
- break;
72
- case 'sp_description':
73
- global $post;
74
- echo '<span class="description">' . $post->post_excerpt . '</span>';
75
- break;
76
- endswitch;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
- }
79
 
80
  endif;
81
 
2
  /**
3
  * Admin functions for the statistics post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Statistic' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Statistic Class
23
  */
24
+ class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_statistic';
 
 
31
 
32
+ // Admin Columns
33
+ add_filter( 'manage_edit-sp_statistic_columns', array( $this, 'edit_columns' ) );
34
+ add_action( 'manage_sp_statistic_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ // Call SP_Admin_CPT constructor
37
+ parent::__construct();
38
+ }
39
+
40
+ /**
41
+ * Change the columns shown in admin.
42
+ */
43
+ public function edit_columns( $existing_columns ) {
44
+ $columns = array(
45
+ 'cb' => '<input type="checkbox" />',
46
+ 'sp_icon' => esc_attr__( 'Icon', 'sportspress' ),
47
+ 'title' => esc_attr__( 'Label', 'sportspress' ),
48
+ 'sp_key' => esc_attr__( 'Key', 'sportspress' ),
49
+ 'sp_equation' => esc_attr__( 'Equation', 'sportspress' ),
50
+ 'sp_precision' => esc_attr__( 'Decimal Places', 'sportspress' ),
51
+ 'sp_description' => esc_attr__( 'Description', 'sportspress' ),
52
+ );
53
+ return apply_filters( 'sportspress_statistic_admin_columns', $columns );
54
+ }
55
+
56
+ /**
57
+ * Define our custom columns shown in admin.
58
+ *
59
+ * @param string $column
60
+ */
61
+ public function custom_columns( $column, $post_id ) {
62
+ switch ( $column ) :
63
+ case 'sp_icon':
64
+ echo has_post_thumbnail( $post_id ) ? wp_kses_post( edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) ) : '';
65
+ break;
66
+ case 'sp_key':
67
+ global $post;
68
+ echo esc_html( $post->post_name );
69
+ break;
70
+ case 'sp_equation':
71
+ echo esc_html( sp_get_post_equation( $post_id ) );
72
+ break;
73
+ case 'sp_precision':
74
+ echo esc_html( sp_get_post_precision( $post_id ) );
75
+ break;
76
+ case 'sp_description':
77
+ global $post;
78
+ echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
79
+ break;
80
+ endswitch;
81
+ }
82
  }
 
83
 
84
  endif;
85
 
includes/admin/post-types/class-sp-admin-cpt-table.php CHANGED
@@ -2,136 +2,144 @@
2
  /**
3
  * Admin functions for the league tables post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 2.5
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Table' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Table Class
20
- */
21
- class SP_Admin_CPT_Table extends SP_Admin_CPT {
22
-
23
  /**
24
- * Constructor
25
  */
26
- public function __construct() {
27
- $this->type = 'sp_table';
28
-
29
- // Admin Columns
30
- add_filter( 'manage_edit-sp_table_columns', array( $this, 'edit_columns' ) );
31
- add_action( 'manage_sp_table_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
32
-
33
- // Filtering
34
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
35
- add_filter( 'parse_query', array( $this, 'filters_query' ) );
36
-
37
- // Call SP_Admin_CPT constructor
38
- parent::__construct();
39
- }
40
 
41
- /**
42
- * Change the columns shown in admin.
43
- */
44
- public function edit_columns( $existing_columns ) {
45
- unset( $existing_columns['date'] );
46
- $columns = array_merge( array(
47
- 'cb' => '<input type="checkbox" />',
48
- 'title' => __( 'Title', 'sportspress' ),
49
- 'sp_league' => __( 'League', 'sportspress' ),
50
- 'sp_season' => __( 'Season', 'sportspress' ),
51
- 'sp_team' => __( 'Teams', 'sportspress' ),
52
- ), $existing_columns );
53
- return apply_filters( 'sportspress_table_admin_columns', $columns );
54
- }
55
 
56
- /**
57
- * Define our custom columns shown in admin.
58
- * @param string $column
59
- */
60
- public function custom_columns( $column, $post_id ) {
61
- switch ( $column ):
62
- case 'sp_league':
63
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '&mdash;';
64
- break;
65
- case 'sp_season':
66
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '&mdash;';
67
- break;
68
- case 'sp_team':
69
- $select = get_post_meta( $post_id, 'sp_select', true );
70
- if ( 'manual' == $select ):
71
- $teams = array_filter( get_post_meta( $post_id, 'sp_team' ) );
72
- echo sizeof( $teams );
73
- else:
74
- _e( 'Auto', 'sportspress' );
75
- endif;
76
- break;
77
- endswitch;
78
- }
79
 
80
- /**
81
- * Show a category filter box
82
- */
83
- public function filters() {
84
- global $typenow, $wp_query;
85
-
86
- if ( $typenow != 'sp_table' )
87
- return;
88
-
89
- $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
90
- $args = array(
91
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
92
- 'taxonomy' => 'sp_league',
93
- 'name' => 'sp_league',
94
- 'selected' => $selected
95
- );
96
- sp_dropdown_taxonomies( $args );
97
-
98
- $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
99
- $args = array(
100
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
101
- 'taxonomy' => 'sp_season',
102
- 'name' => 'sp_season',
103
- 'selected' => $selected
104
- );
105
- sp_dropdown_taxonomies( $args );
106
-
107
- $selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
108
- $args = array(
109
- 'post_type' => 'sp_team',
110
- 'name' => 'team',
111
- 'show_option_none' => __( 'Show all teams', 'sportspress' ),
112
- 'selected' => $selected,
113
- 'values' => 'ID',
114
- );
115
- wp_dropdown_pages( $args );
116
- }
117
 
118
- /**
119
- * Filter in admin based on options
120
- *
121
- * @param mixed $query
122
- */
123
- public function filters_query( $query ) {
124
- global $typenow, $wp_query;
125
 
126
- if ( $typenow == 'sp_table' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
- if ( ! empty( $_GET['team'] ) ) {
129
- $query->query_vars['meta_value'] = $_GET['team'];
130
- $query->query_vars['meta_key'] = 'sp_team';
131
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  }
133
  }
134
- }
135
 
136
  endif;
137
 
2
  /**
3
  * Admin functions for the league tables post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.5
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Table' ) ) :
20
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Table Class
23
  */
24
+ class SP_Admin_CPT_Table extends SP_Admin_CPT {
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_table';
 
 
 
 
 
 
 
 
 
31
 
32
+ // Admin Columns
33
+ add_filter( 'manage_edit-sp_table_columns', array( $this, 'edit_columns' ) );
34
+ add_action( 'manage_sp_table_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ // Filtering
37
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
38
+ add_filter( 'parse_query', array( $this, 'filters_query' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ // Call SP_Admin_CPT constructor
41
+ parent::__construct();
42
+ }
 
 
 
 
43
 
44
+ /**
45
+ * Change the columns shown in admin.
46
+ */
47
+ public function edit_columns( $existing_columns ) {
48
+ unset( $existing_columns['date'] );
49
+ $columns = array_merge(
50
+ array(
51
+ 'cb' => '<input type="checkbox" />',
52
+ 'title' => esc_attr__( 'Title', 'sportspress' ),
53
+ 'sp_league' => esc_attr__( 'League', 'sportspress' ),
54
+ 'sp_season' => esc_attr__( 'Season', 'sportspress' ),
55
+ 'sp_team' => esc_attr__( 'Teams', 'sportspress' ),
56
+ ),
57
+ $existing_columns
58
+ );
59
+ return apply_filters( 'sportspress_table_admin_columns', $columns );
60
+ }
61
+
62
+ /**
63
+ * Define our custom columns shown in admin.
64
+ *
65
+ * @param string $column
66
+ */
67
+ public function custom_columns( $column, $post_id ) {
68
+ switch ( $column ) :
69
+ case 'sp_league':
70
+ echo get_the_terms( $post_id, 'sp_league' ) ? wp_kses_post( the_terms( $post_id, 'sp_league' ) ) : '&mdash;';
71
+ break;
72
+ case 'sp_season':
73
+ echo get_the_terms( $post_id, 'sp_season' ) ? wp_kses_post( the_terms( $post_id, 'sp_season' ) ) : '&mdash;';
74
+ break;
75
+ case 'sp_team':
76
+ $select = get_post_meta( $post_id, 'sp_select', true );
77
+ if ( 'manual' == $select ) :
78
+ $teams = array_filter( get_post_meta( $post_id, 'sp_team' ) );
79
+ echo esc_html( sizeof( $teams ) );
80
+ else :
81
+ esc_html_e( 'Auto', 'sportspress' );
82
+ endif;
83
+ break;
84
+ endswitch;
85
+ }
86
 
87
+ /**
88
+ * Show a category filter box
89
+ */
90
+ public function filters() {
91
+ global $typenow, $wp_query;
92
+
93
+ if ( $typenow != 'sp_table' ) {
94
+ return;
95
+ }
96
+
97
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
98
+ $args = array(
99
+ 'show_option_all' => esc_attr__( 'Show all leagues', 'sportspress' ),
100
+ 'taxonomy' => 'sp_league',
101
+ 'name' => 'sp_league',
102
+ 'selected' => $selected,
103
+ );
104
+ sp_dropdown_taxonomies( $args );
105
+
106
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
107
+ $args = array(
108
+ 'show_option_all' => esc_attr__( 'Show all seasons', 'sportspress' ),
109
+ 'taxonomy' => 'sp_season',
110
+ 'name' => 'sp_season',
111
+ 'selected' => $selected,
112
+ );
113
+ sp_dropdown_taxonomies( $args );
114
+
115
+ $selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
116
+ $args = array(
117
+ 'post_type' => 'sp_team',
118
+ 'name' => 'team',
119
+ 'show_option_none' => esc_attr__( 'Show all teams', 'sportspress' ),
120
+ 'selected' => $selected,
121
+ 'values' => 'ID',
122
+ );
123
+ wp_dropdown_pages( $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
124
+ }
125
+
126
+ /**
127
+ * Filter in admin based on options
128
+ *
129
+ * @param mixed $query
130
+ */
131
+ public function filters_query( $query ) {
132
+ global $typenow, $wp_query;
133
+
134
+ if ( $typenow == 'sp_table' ) {
135
+
136
+ if ( ! empty( $_GET['team'] ) ) {
137
+ $query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
138
+ $query->query_vars['meta_key'] = 'sp_team';
139
+ }
140
+ }
141
  }
142
  }
 
143
 
144
  endif;
145
 
includes/admin/post-types/class-sp-admin-cpt-team.php CHANGED
@@ -2,131 +2,142 @@
2
  /**
3
  * Admin functions for the teams post type
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
- * @version 2.6
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
- if ( ! class_exists( 'SP_Admin_CPT' ) )
14
- include( 'class-sp-admin-cpt.php' );
 
15
 
16
  if ( ! class_exists( 'SP_Admin_CPT_Team' ) ) :
17
 
18
- /**
19
- * SP_Admin_CPT_Team Class
20
- */
21
- class SP_Admin_CPT_Team extends SP_Admin_CPT {
22
-
23
- /**
24
- * Constructor
25
- */
26
- public function __construct() {
27
- $this->type = 'sp_team';
28
-
29
- // Post title fields
30
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
31
-
32
- // Admin Columns
33
- add_filter( 'manage_edit-sp_team_columns', array( $this, 'edit_columns' ) );
34
- add_action( 'manage_sp_team_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
35
-
36
- // Filtering
37
- add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
38
-
39
- // Call SP_Admin_CPT constructor
40
- parent::__construct();
41
- }
42
-
43
- /**
44
- * Change title boxes in admin.
45
- * @param string $text
46
- * @param object $post
47
- * @return string
48
- */
49
- public function enter_title_here( $text, $post ) {
50
- if ( $post->post_type == 'sp_team' )
51
- return __( 'Name', 'sportspress' );
52
-
53
- return $text;
54
- }
55
-
56
  /**
57
- * Change the columns shown in admin.
58
  */
59
- public function edit_columns( $existing_columns ) {
60
- unset( $existing_columns['author'], $existing_columns['date'] );
61
- $columns = array_merge( array(
62
- 'cb' => '<input type="checkbox" />',
63
- 'sp_icon' => '<span class="dashicons sp-icon-shield sp-tip" title="' . __( 'Logo', 'sportspress' ) . '"></span>',
64
- 'title' => null,
65
- 'sp_short_name' => __( 'Short Name', 'sportspress' ),
66
- 'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
67
- 'sp_league' => __( 'Leagues', 'sportspress' ),
68
- 'sp_season' => __( 'Seasons', 'sportspress' ),
69
- ), $existing_columns, array(
70
- 'title' => __( 'Team', 'sportspress' ),
71
- ) );
72
- return apply_filters( 'sportspress_team_admin_columns', $columns );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
 
75
- /**
76
- * Define our custom columns shown in admin.
77
- * @param string $column
78
- */
79
- public function custom_columns( $column, $post_id ) {
80
- switch ( $column ):
81
- case 'sp_icon':
82
- echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
83
- break;
84
- case 'sp_short_name':
85
- $short_name = get_post_meta ( $post_id, 'sp_short_name', true );
86
- echo $short_name ? esc_html( $short_name ) : '&mdash;';
87
- break;
88
- case 'sp_abbreviation':
89
- $abbreviation = get_post_meta ( $post_id, 'sp_abbreviation', true );
90
- echo $abbreviation ? esc_html( $abbreviation ) : '&mdash;';
91
- break;
92
- case 'sp_league':
93
- echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '&mdash;';
94
- break;
95
- case 'sp_season':
96
- echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '&mdash;';
97
- break;
98
- endswitch;
99
- }
100
-
101
- /**
102
- * Show a category filter box
103
- */
104
- public function filters() {
105
- global $typenow, $wp_query;
106
-
107
- if ( $typenow != 'sp_team' )
108
- return;
109
-
110
- $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
111
- $args = array(
112
- 'show_option_all' => __( 'Show all leagues', 'sportspress' ),
113
- 'taxonomy' => 'sp_league',
114
- 'name' => 'sp_league',
115
- 'selected' => $selected
116
- );
117
- sp_dropdown_taxonomies( $args );
118
-
119
- $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
120
- $args = array(
121
- 'show_option_all' => __( 'Show all seasons', 'sportspress' ),
122
- 'taxonomy' => 'sp_season',
123
- 'name' => 'sp_season',
124
- 'selected' => $selected
125
- );
126
- sp_dropdown_taxonomies( $args );
127
- }
128
- }
129
-
130
  endif;
131
 
132
  return new SP_Admin_CPT_Team();
2
  /**
3
  * Admin functions for the teams post type
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
+ * @version 2.6
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
+ if ( ! class_exists( 'SP_Admin_CPT' ) ) {
16
+ require 'class-sp-admin-cpt.php';
17
+ }
18
 
19
  if ( ! class_exists( 'SP_Admin_CPT_Team' ) ) :
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  /**
22
+ * SP_Admin_CPT_Team Class
23
  */
24
+ class SP_Admin_CPT_Team extends SP_Admin_CPT {
25
+
26
+ /**
27
+ * Constructor
28
+ */
29
+ public function __construct() {
30
+ $this->type = 'sp_team';
31
+
32
+ // Post title fields
33
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
34
+
35
+ // Admin Columns
36
+ add_filter( 'manage_edit-sp_team_columns', array( $this, 'edit_columns' ) );
37
+ add_action( 'manage_sp_team_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
38
+
39
+ // Filtering
40
+ add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
41
+
42
+ // Call SP_Admin_CPT constructor
43
+ parent::__construct();
44
+ }
45
+
46
+ /**
47
+ * Change title boxes in admin.
48
+ *
49
+ * @param string $text
50
+ * @param object $post
51
+ * @return string
52
+ */
53
+ public function enter_title_here( $text, $post ) {
54
+ if ( $post->post_type == 'sp_team' ) {
55
+ return esc_attr__( 'Name', 'sportspress' );
56
+ }
57
+
58
+ return $text;
59
+ }
60
+
61
+ /**
62
+ * Change the columns shown in admin.
63
+ */
64
+ public function edit_columns( $existing_columns ) {
65
+ unset( $existing_columns['author'], $existing_columns['date'] );
66
+ $columns = array_merge(
67
+ array(
68
+ 'cb' => '<input type="checkbox" />',
69
+ 'sp_icon' => '<span class="dashicons sp-icon-shield sp-tip" title="' . esc_attr__( 'Logo', 'sportspress' ) . '"></span>',
70
+ 'title' => null,
71
+ 'sp_short_name' => esc_attr__( 'Short Name', 'sportspress' ),
72
+ 'sp_abbreviation' => esc_attr__( 'Abbreviation', 'sportspress' ),
73
+ 'sp_league' => esc_attr__( 'Leagues', 'sportspress' ),
74
+ 'sp_season' => esc_attr__( 'Seasons', 'sportspress' ),
75
+ ),
76
+ $existing_columns,
77
+ array(
78
+ 'title' => esc_attr__( 'Team', 'sportspress' ),
79
+ )
80
+ );
81
+ return apply_filters( 'sportspress_team_admin_columns', $columns );
82
+ }
83
+
84
+ /**
85
+ * Define our custom columns shown in admin.
86
+ *
87
+ * @param string $column
88
+ */
89
+ public function custom_columns( $column, $post_id ) {
90
+ switch ( $column ) :
91
+ case 'sp_icon':
92
+ echo has_post_thumbnail( $post_id ) ? wp_kses_post( edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) ) : '';
93
+ break;
94
+ case 'sp_short_name':
95
+ $short_name = get_post_meta( $post_id, 'sp_short_name', true );
96
+ echo $short_name ? esc_html( $short_name ) : '&mdash;';
97
+ break;
98
+ case 'sp_abbreviation':
99
+ $abbreviation = get_post_meta( $post_id, 'sp_abbreviation', true );
100
+ echo $abbreviation ? esc_html( $abbreviation ) : '&mdash;';
101
+ break;
102
+ case 'sp_league':
103
+ echo get_the_terms( $post_id, 'sp_league' ) ? wp_kses_post( the_terms( $post_id, 'sp_league' ) ) : '&mdash;';
104
+ break;
105
+ case 'sp_season':
106
+ echo get_the_terms( $post_id, 'sp_season' ) ? wp_kses_post( the_terms( $post_id, 'sp_season' ) ) : '&mdash;';
107
+ break;
108
+ endswitch;
109
+ }
110
+
111
+ /**
112
+ * Show a category filter box
113
+ */
114
+ public function filters() {
115
+ global $typenow, $wp_query;
116
+
117
+ if ( $typenow != 'sp_team' ) {
118
+ return;
119
+ }
120
+
121
+ $selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
122
+ $args = array(
123
+ 'show_option_all' => esc_attr__( 'Show all leagues', 'sportspress' ),
124
+ 'taxonomy' => 'sp_league',
125
+ 'name' => 'sp_league',
126
+ 'selected' => $selected,
127
+ );
128
+ sp_dropdown_taxonomies( $args );
129
+
130
+ $selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
131
+ $args = array(
132
+ 'show_option_all' => esc_attr__( 'Show all seasons', 'sportspress' ),
133
+ 'taxonomy' => 'sp_season',
134
+ 'name' => 'sp_season',
135
+ 'selected' => $selected,
136
+ );
137
+ sp_dropdown_taxonomies( $args );
138
+ }
139
  }
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  endif;
142
 
143
  return new SP_Admin_CPT_Team();
includes/admin/post-types/class-sp-admin-cpt.php CHANGED
@@ -2,66 +2,70 @@
2
  /**
3
  * Admin functions for post types
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Post_Types
8
  * @version 0.7
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  if ( ! class_exists( 'SP_Admin_CPT' ) ) :
14
 
15
- /**
16
- * SP_Admin_CPT Class
17
- */
18
- class SP_Admin_CPT {
19
-
20
- protected $type = '';
21
-
22
- /**
23
- * Constructor
24
- */
25
- public function __construct() {
26
- // Insert into X media browser
27
- add_filter( 'media_view_strings', array( $this, 'change_insert_into_post' ) );
28
- }
29
-
30
  /**
31
- * Change label for insert buttons.
32
- * @access public
33
- * @param array $strings
34
- * @return array
35
  */
36
- function change_insert_into_post( $strings ) {
37
- global $post_type;
38
 
39
- if ( $post_type == $this->type ) {
40
- $obj = get_post_type_object( $this->type );
41
 
42
- $strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'sportspress' ), $obj->labels->singular_name );
43
- $strings['uploadedToThisPost'] = sprintf( __( 'Uploaded to this %s', 'sportspress' ), $obj->labels->singular_name );
 
 
 
 
44
  }
45
 
46
- return $strings;
47
- }
 
 
 
 
 
 
 
48
 
49
- /**
50
- * Check if we're editing or adding an event
51
- * @return boolean
52
- */
53
- private function is_editing() {
54
- if ( ! empty( $_GET['post_type'] ) && $this->type == $_GET['post_type'] ) {
55
- return true;
56
- }
57
- if ( ! empty( $_GET['post'] ) && $this->type == get_post_type( $_GET['post'] ) ) {
58
- return true;
59
  }
60
- if ( ! empty( $_REQUEST['post_id'] ) && $this->type == get_post_type( $_REQUEST['post_id'] ) ) {
61
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
- return false;
64
  }
65
- }
66
 
67
- endif;
2
  /**
3
  * Admin functions for post types
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Post_Types
8
  * @version 0.7
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  if ( ! class_exists( 'SP_Admin_CPT' ) ) :
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  /**
18
+ * SP_Admin_CPT Class
 
 
 
19
  */
20
+ class SP_Admin_CPT {
 
21
 
22
+ protected $type = '';
 
23
 
24
+ /**
25
+ * Constructor
26
+ */
27
+ public function __construct() {
28
+ // Insert into X media browser
29
+ add_filter( 'media_view_strings', array( $this, 'change_insert_into_post' ) );
30
  }
31
 
32
+ /**
33
+ * Change label for insert buttons.
34
+ *
35
+ * @access public
36
+ * @param array $strings
37
+ * @return array
38
+ */
39
+ function change_insert_into_post( $strings ) {
40
+ global $post_type;
41
 
42
+ if ( $post_type == $this->type ) {
43
+ $obj = get_post_type_object( $this->type );
44
+
45
+ $strings['insertIntoPost'] = sprintf( esc_attr__( 'Insert into %s', 'sportspress' ), $obj->labels->singular_name );
46
+ $strings['uploadedToThisPost'] = sprintf( esc_attr__( 'Uploaded to this %s', 'sportspress' ), $obj->labels->singular_name );
47
+ }
48
+
49
+ return $strings;
 
 
50
  }
51
+
52
+ /**
53
+ * Check if we're editing or adding an event
54
+ *
55
+ * @return boolean
56
+ */
57
+ private function is_editing() {
58
+ if ( ! empty( $_GET['post_type'] ) && $this->type == $_GET['post_type'] ) {
59
+ return true;
60
+ }
61
+ if ( ! empty( $_GET['post'] ) && $this->type == get_post_type( sanitize_key( $_GET['post'] ) ) ) {
62
+ return true;
63
+ }
64
+ if ( ! empty( $_REQUEST['post_id'] ) && $this->type == get_post_type( sanitize_key( $_REQUEST['post_id'] ) ) ) {
65
+ return true;
66
+ }
67
+ return false;
68
  }
 
69
  }
 
70
 
71
+ endif;
includes/admin/post-types/class-sp-admin-meta-boxes.php CHANGED
@@ -4,13 +4,15 @@
4
  *
5
  * Sets up the write panels used by custom post types
6
  *
7
- * @author ThemeBoy
8
- * @category Admin
9
- * @package SportsPress/Admin/Meta_Boxes
10
- * @version 2.6.8
11
  */
12
 
13
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
14
 
15
  /**
16
  * SP_Admin_Meta_Boxes
@@ -27,202 +29,202 @@ class SP_Admin_Meta_Boxes {
27
  */
28
  public function __construct() {
29
  $meta_boxes = array(
30
- 'sp_outcome' => array(
31
  'details' => array(
32
- 'title' => __( 'Details', 'sportspress' ),
33
- 'save' => 'SP_Meta_Box_Outcome_Details::save',
34
- 'output' => 'SP_Meta_Box_Outcome_Details::output',
35
- 'context' => 'normal',
36
  'priority' => 'high',
37
  ),
38
  ),
39
- 'sp_result' => array(
40
- 'details' => array(
41
- 'title' => __( 'Details', 'sportspress' ),
42
- 'save' => 'SP_Meta_Box_Result_Details::save',
43
- 'output' => 'SP_Meta_Box_Result_Details::output',
44
- 'context' => 'side',
45
  'priority' => 'default',
46
  ),
47
  'equation' => array(
48
- 'title' => __( 'Equation', 'sportspress' ),
49
- 'save' => 'SP_Meta_Box_Result_Equation::save',
50
- 'output' => 'SP_Meta_Box_Result_Equation::output',
51
- 'context' => 'normal',
52
  'priority' => 'high',
53
  ),
54
  ),
55
  'sp_performance' => array(
56
- 'details' => array(
57
- 'title' => __( 'Details', 'sportspress' ),
58
- 'save' => 'SP_Meta_Box_Performance_Details::save',
59
- 'output' => 'SP_Meta_Box_Performance_Details::output',
60
- 'context' => 'normal',
61
  'priority' => 'high',
62
  ),
63
  'equation' => array(
64
- 'title' => __( 'Equation', 'sportspress' ),
65
- 'save' => 'SP_Meta_Box_Performance_Equation::save',
66
- 'output' => 'SP_Meta_Box_Performance_Equation::output',
67
- 'context' => 'normal',
68
  'priority' => 'high',
69
  ),
70
  ),
71
- 'sp_column' => array(
72
- 'details' => array(
73
- 'title' => __( 'Details', 'sportspress' ),
74
- 'save' => 'SP_Meta_Box_Column_Details::save',
75
- 'output' => 'SP_Meta_Box_Column_Details::output',
76
- 'context' => 'side',
77
  'priority' => 'default',
78
  ),
79
  'equation' => array(
80
- 'title' => __( 'Equation', 'sportspress' ),
81
- 'save' => 'SP_Meta_Box_Column_Equation::save',
82
- 'output' => 'SP_Meta_Box_Column_Equation::output',
83
- 'context' => 'normal',
84
  'priority' => 'high',
85
  ),
86
  ),
87
- 'sp_metric' => array(
88
  'details' => array(
89
- 'title' => __( 'Details', 'sportspress' ),
90
- 'save' => 'SP_Meta_Box_Metric_Details::save',
91
- 'output' => 'SP_Meta_Box_Metric_Details::output',
92
- 'context' => 'normal',
93
  'priority' => 'high',
94
  ),
95
  ),
96
- 'sp_statistic' => array(
97
- 'details' => array(
98
- 'title' => __( 'Details', 'sportspress' ),
99
- 'save' => 'SP_Meta_Box_Statistic_Details::save',
100
- 'output' => 'SP_Meta_Box_Statistic_Details::output',
101
- 'context' => 'side',
102
  'priority' => 'default',
103
  ),
104
  'equation' => array(
105
- 'title' => __( 'Equation', 'sportspress' ),
106
- 'save' => 'SP_Meta_Box_Statistic_Equation::save',
107
- 'output' => 'SP_Meta_Box_Statistic_Equation::output',
108
- 'context' => 'normal',
109
  'priority' => 'high',
110
  ),
111
  ),
112
- 'sp_event' => array(
113
- 'shortcode' => array(
114
- 'title' => __( 'Shortcodes', 'sportspress' ),
115
- 'output' => 'SP_Meta_Box_Event_Shortcode::output',
116
- 'context' => 'side',
117
  'priority' => 'default',
118
  ),
119
- 'format' => array(
120
- 'title' => __( 'Format', 'sportspress' ),
121
- 'save' => 'SP_Meta_Box_Event_Format::save',
122
- 'output' => 'SP_Meta_Box_Event_Format::output',
123
- 'context' => 'side',
124
  'priority' => 'default',
125
  ),
126
- 'mode' => array(
127
- 'title' => __( 'Mode', 'sportspress' ),
128
- 'save' => 'SP_Meta_Box_Event_Mode::save',
129
- 'output' => 'SP_Meta_Box_Event_Mode::output',
130
- 'context' => 'side',
131
  'priority' => 'default',
132
  ),
133
- 'details' => array(
134
- 'title' => __( 'Details', 'sportspress' ),
135
- 'save' => 'SP_Meta_Box_Event_Details::save',
136
- 'output' => 'SP_Meta_Box_Event_Details::output',
137
- 'context' => 'side',
138
  'priority' => 'default',
139
  ),
140
- 'team' => array(
141
- 'title' => __( 'Teams', 'sportspress' ),
142
- 'save' => 'SP_Meta_Box_Event_Teams::save',
143
- 'output' => 'SP_Meta_Box_Event_Teams::output',
144
- 'context' => 'side',
145
  'priority' => 'default',
146
  ),
147
- 'results' => array(
148
- 'title' => __( 'Results', 'sportspress' ),
149
- 'save' => 'SP_Meta_Box_Event_Results::save',
150
- 'output' => 'SP_Meta_Box_Event_Results::output',
151
- 'context' => 'normal',
152
  'priority' => 'high',
153
  ),
154
  'performance' => array(
155
- 'title' => __( 'Box Score', 'sportspress' ),
156
- 'save' => 'SP_Meta_Box_Event_Performance::save',
157
- 'output' => 'SP_Meta_Box_Event_Performance::output',
158
- 'context' => 'normal',
159
  'priority' => 'high',
160
  ),
161
  ),
162
- 'sp_team' => array(
163
  'details' => array(
164
- 'title' => __( 'Details', 'sportspress' ),
165
- 'save' => 'SP_Meta_Box_Team_Details::save',
166
- 'output' => 'SP_Meta_Box_Team_Details::output',
167
- 'context' => 'side',
168
  'priority' => 'default',
169
  ),
170
- 'staff' => array(
171
- 'title' => __( 'Staff', 'sportspress' ),
172
- 'save' => 'SP_Meta_Box_Team_Staff::save',
173
- 'output' => 'SP_Meta_Box_Team_Staff::output',
174
- 'context' => 'normal',
175
  'priority' => 'high',
176
  ),
177
  ),
178
- 'sp_player' => array(
179
- 'shortcode' => array(
180
- 'title' => __( 'Shortcodes', 'sportspress' ),
181
- 'output' => 'SP_Meta_Box_Player_Shortcode::output',
182
- 'context' => 'side',
183
  'priority' => 'default',
184
  ),
185
- 'columns' => array(
186
- 'title' => __( 'Columns', 'sportspress' ),
187
- 'save' => 'SP_Meta_Box_Player_Columns::save',
188
- 'output' => 'SP_Meta_Box_Player_Columns::output',
189
- 'context' => 'side',
190
  'priority' => 'default',
191
  ),
192
- 'details' => array(
193
- 'title' => __( 'Details', 'sportspress' ),
194
- 'save' => 'SP_Meta_Box_Player_Details::save',
195
- 'output' => 'SP_Meta_Box_Player_Details::output',
196
- 'context' => 'side',
197
  'priority' => 'default',
198
  ),
199
- 'metrics' => array(
200
- 'title' => __( 'Metrics', 'sportspress' ),
201
- 'save' => 'SP_Meta_Box_Player_Metrics::save',
202
- 'output' => 'SP_Meta_Box_Player_Metrics::output',
203
- 'context' => 'side',
204
  'priority' => 'default',
205
  ),
206
  'statistics' => array(
207
- 'title' => __( 'Statistics', 'sportspress' ),
208
- 'save' => 'SP_Meta_Box_Player_Statistics::save',
209
- 'output' => 'SP_Meta_Box_Player_Statistics::output',
210
- 'context' => 'normal',
211
  'priority' => 'high',
212
  ),
213
  ),
214
- 'sp_staff' => array(
215
  'shortcode' => array(
216
- 'title' => __( 'Shortcode', 'sportspress' ),
217
- 'output' => 'SP_Meta_Box_Staff_Shortcode::output',
218
- 'context' => 'side',
219
  'priority' => 'default',
220
  ),
221
- 'details' => array(
222
- 'title' => __( 'Details', 'sportspress' ),
223
- 'save' => 'SP_Meta_Box_Staff_Details::save',
224
- 'output' => 'SP_Meta_Box_Staff_Details::output',
225
- 'context' => 'side',
226
  'priority' => 'default',
227
  ),
228
  ),
@@ -290,38 +292,52 @@ class SP_Admin_Meta_Boxes {
290
  */
291
  public function rename_meta_boxes() {
292
  remove_meta_box( 'submitdiv', 'sp_event', 'side' );
293
- add_meta_box( 'submitdiv', __( 'Event', 'sportspress' ), 'post_submit_meta_box', 'sp_event', 'side', 'high' );
294
 
295
  remove_meta_box( 'postimagediv', 'sp_team', 'side' );
296
- add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'low' );
297
 
298
  remove_meta_box( 'postimagediv', 'sp_player', 'side' );
299
- add_meta_box( 'postimagediv', __( 'Photo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_player', 'side', 'low' );
300
 
301
  remove_meta_box( 'postimagediv', 'sp_staff', 'side' );
302
- add_meta_box( 'postimagediv', __( 'Photo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_staff', 'side', 'low' );
303
 
304
  remove_meta_box( 'postimagediv', 'sp_performance', 'side' );
305
- add_meta_box( 'postimagediv', __( 'Icon', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_performance', 'side', 'low' );
306
-
307
  remove_meta_box( 'postimagediv', 'sp_statistic', 'side' );
308
- add_meta_box( 'postimagediv', __( 'Icon', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_statistic', 'side', 'low' );
309
  }
310
 
311
  /**
312
  * Check if we're saving, then trigger an action based on the post type
313
  *
314
- * @param int $post_id
315
  * @param object $post
316
  */
317
  public function save_meta_boxes( $post_id, $post ) {
318
- if ( empty( $post_id ) || empty( $post ) ) return;
319
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
320
- if ( is_int( wp_is_post_revision( $post ) ) ) return;
321
- if ( is_int( wp_is_post_autosave( $post ) ) ) return;
322
- if ( empty( $_POST['sportspress_meta_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_meta_nonce'], 'sportspress_save_data' ) ) return;
323
- if ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) return;
324
- if ( ! is_sp_post_type( $post->post_type ) && ! is_sp_config_type( $post->post_type ) ) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
 
326
  do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
327
  }
4
  *
5
  * Sets up the write panels used by custom post types
6
  *
7
+ * @author ThemeBoy
8
+ * @category Admin
9
+ * @package SportsPress/Admin/Meta_Boxes
10
+ * @version 2.6.8
11
  */
12
 
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit; // Exit if accessed directly
15
+ }
16
 
17
  /**
18
  * SP_Admin_Meta_Boxes
29
  */
30
  public function __construct() {
31
  $meta_boxes = array(
32
+ 'sp_outcome' => array(
33
  'details' => array(
34
+ 'title' => esc_attr__( 'Details', 'sportspress' ),
35
+ 'save' => 'SP_Meta_Box_Outcome_Details::save',
36
+ 'output' => 'SP_Meta_Box_Outcome_Details::output',
37
+ 'context' => 'normal',
38
  'priority' => 'high',
39
  ),
40
  ),
41
+ 'sp_result' => array(
42
+ 'details' => array(
43
+ 'title' => esc_attr__( 'Details', 'sportspress' ),
44
+ 'save' => 'SP_Meta_Box_Result_Details::save',
45
+ 'output' => 'SP_Meta_Box_Result_Details::output',
46
+ 'context' => 'side',
47
  'priority' => 'default',
48
  ),
49
  'equation' => array(
50
+ 'title' => esc_attr__( 'Equation', 'sportspress' ),
51
+ 'save' => 'SP_Meta_Box_Result_Equation::save',
52
+ 'output' => 'SP_Meta_Box_Result_Equation::output',
53
+ 'context' => 'normal',
54
  'priority' => 'high',
55
  ),
56
  ),
57
  'sp_performance' => array(
58
+ 'details' => array(
59
+ 'title' => esc_attr__( 'Details', 'sportspress' ),
60
+ 'save' => 'SP_Meta_Box_Performance_Details::save',
61
+ 'output' => 'SP_Meta_Box_Performance_Details::output',
62
+ 'context' => 'normal',
63
  'priority' => 'high',
64
  ),
65
  'equation' => array(
66
+ 'title' => esc_attr__( 'Equation', 'sportspress' ),
67
+ 'save' => 'SP_Meta_Box_Performance_Equation::save',
68
+ 'output' => 'SP_Meta_Box_Performance_Equation::output',
69
+ 'context' => 'normal',
70
  'priority' => 'high',
71
  ),
72
  ),
73
+ 'sp_column' => array(
74
+ 'details' => array(
75
+ 'title' => esc_attr__( 'Details', 'sportspress' ),
76
+ 'save' => 'SP_Meta_Box_Column_Details::save',
77
+ 'output' => 'SP_Meta_Box_Column_Details::output',
78
+ 'context' => 'side',
79
  'priority' => 'default',
80
  ),
81
  'equation' => array(
82
+ 'title' => esc_attr__( 'Equation', 'sportspress' ),
83
+ 'save' => 'SP_Meta_Box_Column_Equation::save',
84
+ 'output' => 'SP_Meta_Box_Column_Equation::output',
85
+ 'context' => 'normal',
86
  'priority' => 'high',
87
  ),
88
  ),
89
+ 'sp_metric' => array(
90
  'details' => array(
91
+ 'title' => esc_attr__( 'Details', 'sportspress' ),
92
+ 'save' => 'SP_Meta_Box_Metric_Details::save',
93
+ 'output' => 'SP_Meta_Box_Metric_Details::output',
94
+ 'context' => 'normal',
95
  'priority' => 'high',
96
  ),
97
  ),
98
+ 'sp_statistic' => array(
99
+ 'details' => array(
100
+ 'title' => esc_attr__( 'Details', 'sportspress' ),
101
+ 'save' => 'SP_Meta_Box_Statistic_Details::save',
102
+ 'output' => 'SP_Meta_Box_Statistic_Details::output',
103
+ 'context' => 'side',
104
  'priority' => 'default',
105
  ),
106
  'equation' => array(
107
+ 'title' => esc_attr__( 'Equation', 'sportspress' ),
108
+ 'save' => 'SP_Meta_Box_Statistic_Equation::save',
109
+ 'output' => 'SP_Meta_Box_Statistic_Equation::output',
110
+ 'context' => 'normal',
111
  'priority' => 'high',
112
  ),
113
  ),
114
+ 'sp_event' => array(
115
+ 'shortcode' => array(
116
+ 'title' => esc_attr__( 'Shortcodes', 'sportspress' ),
117
+ 'output' => 'SP_Meta_Box_Event_Shortcode::output',
118
+ 'context' => 'side',
119
  'priority' => 'default',
120
  ),
121
+ 'format' => array(
122
+ 'title' => esc_attr__( 'Format', 'sportspress' ),
123
+ 'save' => 'SP_Meta_Box_Event_Format::save',
124
+ 'output' => 'SP_Meta_Box_Event_Format::output',
125
+ 'context' => 'side',
126
  'priority' => 'default',
127
  ),
128
+ 'mode' => array(
129
+ 'title' => esc_attr__( 'Mode', 'sportspress' ),
130
+ 'save' => 'SP_Meta_Box_Event_Mode::save',
131
+ 'output' => 'SP_Meta_Box_Event_Mode::output',
132
+ 'context' => 'side',
133
  'priority' => 'default',
134
  ),
135
+ 'details' => array(
136
+ 'title' => esc_attr__( 'Details', 'sportspress' ),
137
+ 'save' => 'SP_Meta_Box_Event_Details::save',
138
+ 'output' => 'SP_Meta_Box_Event_Details::output',
139
+ 'context' => 'side',
140
  'priority' => 'default',
141
  ),
142
+ 'team' => array(
143
+ 'title' => esc_attr__( 'Teams', 'sportspress' ),
144
+ 'save' => 'SP_Meta_Box_Event_Teams::save',
145
+ 'output' => 'SP_Meta_Box_Event_Teams::output',
146
+ 'context' => 'side',
147
  'priority' => 'default',
148
  ),
149
+ 'results' => array(
150
+ 'title' => esc_attr__( 'Results', 'sportspress' ),
151
+ 'save' => 'SP_Meta_Box_Event_Results::save',
152
+ 'output' => 'SP_Meta_Box_Event_Results::output',
153
+ 'context' => 'normal',
154
  'priority' => 'high',
155
  ),
156
  'performance' => array(
157
+ 'title' => esc_attr__( 'Box Score', 'sportspress' ),
158
+ 'save' => 'SP_Meta_Box_Event_Performance::save',
159
+ 'output' => 'SP_Meta_Box_Event_Performance::output',
160
+ 'context' => 'normal',
161
  'priority' => 'high',
162
  ),
163
  ),
164
+ 'sp_team' => array(
165
  'details' => array(
166
+ 'title' => esc_attr__( 'Details', 'sportspress' ),
167
+ 'save' => 'SP_Meta_Box_Team_Details::save',
168
+ 'output' => 'SP_Meta_Box_Team_Details::output',
169
+ 'context' => 'side',
170
  'priority' => 'default',
171
  ),
172
+ 'staff' => array(
173
+ 'title' => esc_attr__( 'Staff', 'sportspress' ),
174
+ 'save' => 'SP_Meta_Box_Team_Staff::save',
175
+ 'output' => 'SP_Meta_Box_Team_Staff::output',
176
+ 'context' => 'normal',
177
  'priority' => 'high',
178
  ),
179
  ),
180
+ 'sp_player' => array(
181
+ 'shortcode' => array(
182
+ 'title' => esc_attr__( 'Shortcodes', 'sportspress' ),
183
+ 'output' => 'SP_Meta_Box_Player_Shortcode::output',
184
+ 'context' => 'side',
185
  'priority' => 'default',
186
  ),
187
+ 'columns' => array(
188
+ 'title' => esc_attr__( 'Columns', 'sportspress' ),
189
+ 'save' => 'SP_Meta_Box_Player_Columns::save',
190
+ 'output' => 'SP_Meta_Box_Player_Columns::output',
191
+ 'context' => 'side',
192
  'priority' => 'default',
193
  ),
194
+ 'details' => array(
195
+ 'title' => esc_attr__( 'Details', 'sportspress' ),
196
+ 'save' => 'SP_Meta_Box_Player_Details::save',
197
+ 'output' => 'SP_Meta_Box_Player_Details::output',
198
+ 'context' => 'side',
199
  'priority' => 'default',
200
  ),
201
+ 'metrics' => array(
202
+ 'title' => esc_attr__( 'Metrics', 'sportspress' ),
203
+ 'save' => 'SP_Meta_Box_Player_Metrics::save',
204
+ 'output' => 'SP_Meta_Box_Player_Metrics::output',
205
+ 'context' => 'side',
206
  'priority' => 'default',
207
  ),
208
  'statistics' => array(
209
+ 'title' => esc_attr__( 'Statistics', 'sportspress' ),
210
+ 'save' => 'SP_Meta_Box_Player_Statistics::save',
211
+ 'output' => 'SP_Meta_Box_Player_Statistics::output',
212
+ 'context' => 'normal',
213
  'priority' => 'high',
214
  ),
215
  ),
216
+ 'sp_staff' => array(
217
  'shortcode' => array(
218
+ 'title' => esc_attr__( 'Shortcode', 'sportspress' ),
219
+ 'output' => 'SP_Meta_Box_Staff_Shortcode::output',
220
+ 'context' => 'side',
221
  'priority' => 'default',
222
  ),
223
+ 'details' => array(
224
+ 'title' => esc_attr__( 'Details', 'sportspress' ),
225
+ 'save' => 'SP_Meta_Box_Staff_Details::save',
226
+ 'output' => 'SP_Meta_Box_Staff_Details::output',
227
+ 'context' => 'side',
228
  'priority' => 'default',
229
  ),
230
  ),
292
  */
293
  public function rename_meta_boxes() {
294
  remove_meta_box( 'submitdiv', 'sp_event', 'side' );
295
+ add_meta_box( 'submitdiv', esc_attr__( 'Event', 'sportspress' ), 'post_submit_meta_box', 'sp_event', 'side', 'high' );
296
 
297
  remove_meta_box( 'postimagediv', 'sp_team', 'side' );
298
+ add_meta_box( 'postimagediv', esc_attr__( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'low' );
299
 
300
  remove_meta_box( 'postimagediv', 'sp_player', 'side' );
301
+ add_meta_box( 'postimagediv', esc_attr__( 'Photo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_player', 'side', 'low' );
302
 
303
  remove_meta_box( 'postimagediv', 'sp_staff', 'side' );
304
+ add_meta_box( 'postimagediv', esc_attr__( 'Photo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_staff', 'side', 'low' );
305
 
306
  remove_meta_box( 'postimagediv', 'sp_performance', 'side' );
307
+ add_meta_box( 'postimagediv', esc_attr__( 'Icon', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_performance', 'side', 'low' );
308
+
309
  remove_meta_box( 'postimagediv', 'sp_statistic', 'side' );
310
+ add_meta_box( 'postimagediv', esc_attr__( 'Icon', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_statistic', 'side', 'low' );
311
  }
312
 
313
  /**
314
  * Check if we're saving, then trigger an action based on the post type
315
  *
316
+ * @param int $post_id
317
  * @param object $post
318
  */
319
  public function save_meta_boxes( $post_id, $post ) {
320
+ if ( empty( $post_id ) || empty( $post ) ) {
321
+ return;
322
+ }
323
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
324
+ return;
325
+ }
326
+ if ( is_int( wp_is_post_revision( $post ) ) ) {
327
+ return;
328
+ }
329
+ if ( is_int( wp_is_post_autosave( $post ) ) ) {
330
+ return;
331
+ }
332
+ if ( empty( $_POST['sportspress_meta_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['sportspress_meta_nonce'] ), 'sportspress_save_data' ) ) {
333
+ return;
334
+ }
335
+ if ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) {
336
+ return;
337
+ }
338
+ if ( ! is_sp_post_type( $post->post_type ) && ! is_sp_config_type( $post->post_type ) ) {
339
+ return;
340
+ }
341
 
342
  do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
343
  }
includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-columns.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Calendar Columns
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Meta_Boxes
8
- * @version 2.6.12
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  /**
14
  * SP_Meta_Box_Calendar_Columns
@@ -19,9 +21,9 @@ class SP_Meta_Box_Calendar_Columns {
19
  * Output the metabox
20
  */
21
  public static function output( $post ) {
22
- $selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
23
  $title_format = get_option( 'sportspress_event_list_title_format', 'title' );
24
- $time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
25
 
26
  if ( is_array( $selected ) ) {
27
  $selected = array_filter( $selected );
@@ -30,44 +32,44 @@ class SP_Meta_Box_Calendar_Columns {
30
  $columns = array();
31
 
32
  if ( 'teams' === $title_format ) {
33
- $columns[ 'event' ] = __( 'Home', 'sportspress' ) . ' | ' . __( 'Away', 'sportspress' );
34
  } elseif ( 'homeaway' === $title_format ) {
35
- $columns[ 'event' ] = __( 'Teams', 'sportspress' );
36
  } else {
37
- $columns[ 'event' ] = __( 'Title', 'sportspress' );
38
  }
39
 
40
  if ( 'time' === $time_format || 'separate' === $time_format ) {
41
- $columns['time'] = __( 'Time', 'sportspress' );
42
  } elseif ( 'combined' === $time_format ) {
43
- $columns['time'] = __( 'Time/Results', 'sportspress' );
44
  }
45
 
46
  if ( 'results' === $time_format || 'separate' === $time_format ) {
47
- $columns['results'] = __( 'Results', 'sportspress' );
48
  }
49
 
50
- $columns['league'] = __( 'League', 'sportspress' );
51
- $columns['season'] = __( 'Season', 'sportspress' );
52
- $columns['venue'] = __( 'Venue', 'sportspress' );
53
- $columns['article'] = __( 'Article', 'sportspress' );
54
- $columns['day'] = __( 'Match Day', 'sportspress' );
55
 
56
  $columns = apply_filters( 'sportspress_calendar_columns', $columns );
57
  ?>
58
  <div class="sp-instance">
59
  <ul class="categorychecklist form-no-clear">
60
  <?php
61
- foreach ( $columns as $key => $label ) {
62
- ?>
63
  <li>
64
  <label>
65
- <input type="checkbox" name="sp_columns[]" value="<?php echo $key; ?>" id="sp_columns_<?php echo $key; ?>" <?php checked( ! is_array( $selected ) || in_array( $key, $selected ) ); ?>>
66
- <?php echo $label; ?>
67
  </label>
68
  </li>
69
  <?php
70
- }
71
  ?>
72
  </div>
73
  <?php
@@ -77,6 +79,6 @@ class SP_Meta_Box_Calendar_Columns {
77
  * Save meta box data
78
  */
79
  public static function save( $post_id, $post ) {
80
- update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
81
  }
82
- }
2
  /**
3
  * Calendar Columns
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Meta_Boxes
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  /**
16
  * SP_Meta_Box_Calendar_Columns
21
  * Output the metabox
22
  */
23
  public static function output( $post ) {
24
+ $selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
25
  $title_format = get_option( 'sportspress_event_list_title_format', 'title' );
26
+ $time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
27
 
28
  if ( is_array( $selected ) ) {
29
  $selected = array_filter( $selected );
32
  $columns = array();
33
 
34
  if ( 'teams' === $title_format ) {
35
+ $columns['event'] = esc_attr__( 'Home', 'sportspress' ) . ' | ' . esc_attr__( 'Away', 'sportspress' );
36
  } elseif ( 'homeaway' === $title_format ) {
37
+ $columns['event'] = esc_attr__( 'Teams', 'sportspress' );
38
  } else {
39
+ $columns['event'] = esc_attr__( 'Title', 'sportspress' );
40
  }
41
 
42
  if ( 'time' === $time_format || 'separate' === $time_format ) {
43
+ $columns['time'] = esc_attr__( 'Time', 'sportspress' );
44
  } elseif ( 'combined' === $time_format ) {
45
+ $columns['time'] = esc_attr__( 'Time/Results', 'sportspress' );
46
  }
47
 
48
  if ( 'results' === $time_format || 'separate' === $time_format ) {
49
+ $columns['results'] = esc_attr__( 'Results', 'sportspress' );
50
  }
51
 
52
+ $columns['league'] = esc_attr__( 'League', 'sportspress' );
53
+ $columns['season'] = esc_attr__( 'Season', 'sportspress' );
54
+ $columns['venue'] = esc_attr__( 'Venue', 'sportspress' );
55
+ $columns['article'] = esc_attr__( 'Article', 'sportspress' );
56
+ $columns['day'] = esc_attr__( 'Match Day', 'sportspress' );
57
 
58
  $columns = apply_filters( 'sportspress_calendar_columns', $columns );
59
  ?>
60
  <div class="sp-instance">
61
  <ul class="categorychecklist form-no-clear">
62
  <?php
63
+ foreach ( $columns as $key => $label ) {
64
+ ?>
65
  <li>
66
  <label>
67
+ <input type="checkbox" name="sp_columns[]" value="<?php echo esc_attr( $key ); ?>" id="sp_columns_<?php echo esc_attr( $key ); ?>" <?php checked( ! is_array( $selected ) || in_array( $key, $selected ) ); ?>>
68
+ <?php echo esc_html( $label ); ?>
69
  </label>
70
  </li>
71
  <?php
72
+ }
73
  ?>
74
  </div>
75
  <?php
79
  * Save meta box data
80
  */
81
  public static function save( $post_id, $post ) {
82
+ update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array(), 'text' ) );
83
  }
84
+ }
includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Calendar Events
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Meta_Boxes
8
- * @version 2.6.9
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  /**
14
  * SP_Meta_Box_Calendar_Data
@@ -19,8 +21,8 @@ class SP_Meta_Box_Calendar_Data {
19
  * Output the metabox
20
  */
21
  public static function output( $post ) {
22
- $calendar = new SP_Calendar( $post );
23
- $data = $calendar->data();
24
  $usecolumns = $calendar->columns;
25
  self::table( $data, $usecolumns );
26
  }
@@ -29,7 +31,7 @@ class SP_Meta_Box_Calendar_Data {
29
  * Save meta box data
30
  */
31
  public static function save( $post_id, $post ) {
32
- update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
33
  }
34
 
35
  /**
@@ -37,11 +39,11 @@ class SP_Meta_Box_Calendar_Data {
37
  */
38
  public static function table( $data = array(), $usecolumns = null ) {
39
  $title_format = get_option( 'sportspress_event_list_title_format', 'title' );
40
- $time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
41
 
42
  if ( is_array( $usecolumns ) ) {
43
  $usecolumns = array_filter( $usecolumns );
44
- }else{
45
  $usecolumns = array();
46
  }
47
  ?>
@@ -50,18 +52,22 @@ class SP_Meta_Box_Calendar_Data {
50
  <thead>
51
  <tr>
52
  <th class="column-date">
53
- <?php _e( 'Date', 'sportspress' ); ?>
54
  </th>
55
  <?php if ( is_array( $usecolumns ) && in_array( 'event', $usecolumns ) ) { ?>
56
  <th class="column-event">
57
  <label for="sp_columns_event">
58
  <?php
59
  if ( 'teams' == $title_format ) {
60
- _e( 'Home', 'sportspress' ); ?> | <?php _e( 'Away', 'sportspress' );
 
 
 
 
61
  } elseif ( 'homeaway' == $title_format ) {
62
- _e( 'Teams', 'sportspress' );
63
  } else {
64
- _e( 'Title', 'sportspress' );
65
  }
66
  ?>
67
  </label>
@@ -72,9 +78,9 @@ class SP_Meta_Box_Calendar_Data {
72
  <label for="sp_columns_time">
73
  <?php
74
  if ( 'time' == $time_format || 'separate' == $time_format ) {
75
- _e( 'Time', 'sportspress' );
76
  } else {
77
- _e( 'Time/Results', 'sportspress' );
78
  }
79
  ?>
80
  </label>
@@ -83,42 +89,42 @@ class SP_Meta_Box_Calendar_Data {
83
  <?php if ( ( is_array( $usecolumns ) && in_array( 'results', $usecolumns ) ) && in_array( $time_format, array( 'separate', 'results' ) ) ) { ?>
84
  <th class="column-results">
85
  <label for="sp_columns_results">
86
- <?php _e( 'Results', 'sportspress' ); ?>
87
  </label>
88
  </th>
89
  <?php } ?>
90
  <?php if ( is_array( $usecolumns ) && in_array( 'league', $usecolumns ) ) { ?>
91
  <th class="column-league">
92
  <label for="sp_columns_league">
93
- <?php _e( 'League', 'sportspress' ); ?>
94
  </label>
95
  </th>
96
  <?php } ?>
97
  <?php if ( is_array( $usecolumns ) && in_array( 'season', $usecolumns ) ) { ?>
98
  <th class="column-season">
99
  <label for="sp_columns_season">
100
- <?php _e( 'Season', 'sportspress' ); ?>
101
  </label>
102
  </th>
103
  <?php } ?>
104
  <?php if ( is_array( $usecolumns ) && in_array( 'venue', $usecolumns ) ) { ?>
105
  <th class="column-venue">
106
  <label for="sp_columns_venue">
107
- <?php _e( 'Venue', 'sportspress' ); ?>
108
  </label>
109
  </th>
110
  <?php } ?>
111
  <?php if ( is_array( $usecolumns ) && in_array( 'article', $usecolumns ) ) { ?>
112
  <th class="column-article">
113
  <label for="sp_columns_article">
114
- <?php _e( 'Article', 'sportspress' ); ?>
115
  </label>
116
  </th>
117
  <?php } ?>
118
  <?php if ( is_array( $usecolumns ) && in_array( 'day', $usecolumns ) ) { ?>
119
  <th class="column-day">
120
  <label for="sp_columns_day">
121
- <?php _e( 'Match Day', 'sportspress' ); ?>
122
  </label>
123
  </th>
124
  <?php } ?>
@@ -127,50 +133,64 @@ class SP_Meta_Box_Calendar_Data {
127
  </thead>
128
  <tbody>
129
  <?php
130
- if ( is_array( $data ) ):
131
- if ( sizeof( $data ) > 0 ):
132
  $main_result = get_option( 'sportspress_primary_result', null );
133
- $i = 0;
134
- foreach ( $data as $event ):
135
- $teams = get_post_meta( $event->ID, 'sp_team' );
136
- $results = get_post_meta( $event->ID, 'sp_results', true );
137
- $video = get_post_meta( $event->ID, 'sp_video', true );
138
  $main_results = array();
139
  ?>
140
- <tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
141
- <td><?php echo get_post_time( get_option( 'date_format' ), false, $event, true ); ?></td>
 
 
 
 
 
142
  <?php if ( is_array( $usecolumns ) && in_array( 'event', $usecolumns ) ) { ?>
143
  <td>
144
- <div class="sp-title-format sp-title-format-title<?php if ( $title_format && $title_format != 'title' ): ?> hidden<?php endif; ?>"><?php echo $event->post_title; ?></div>
145
- <div class="sp-title-format sp-title-format-teams sp-title-format-homeaway<?php if ( ! in_array( $title_format, array( 'teams', 'homeaway' ) ) ): ?> hidden<?php endif; ?>">
 
 
 
 
 
 
 
 
146
  <?php
147
- if ( $teams ): foreach ( $teams as $team ):
148
- $name = get_the_title( $team );
149
- if ( $name ):
150
- $team_results = sp_array_value( $results, $team, null );
 
151
 
152
- if ( $main_result ):
153
- $team_result = sp_array_value( $team_results, $main_result, null );
154
- else:
155
- if ( is_array( $team_results ) ):
156
- end( $team_results );
157
- $team_result = prev( $team_results );
158
- else:
159
- $team_result = null;
 
160
  endif;
161
- endif;
162
 
163
- if ( $team_result != null ):
164
- $team_result = apply_filters( 'sportspress_calendar_team_result_admin', $team_result, $event->ID, $team );
165
- $main_results[] = $team_result;
166
- unset( $team_results['outcome'] );
167
- $team_results = implode( ' | ', $team_results );
168
- echo '<a class="result sp-tip" title="' . $team_results . '" href="' . get_edit_post_link( $event->ID ) . '">' . $team_result . '</a> ';
169
- endif;
170
 
171
- echo $name . '<br>';
172
- endif;
173
- endforeach; else:
174
  echo '&mdash;';
175
  endif;
176
  ?>
@@ -180,29 +200,29 @@ class SP_Meta_Box_Calendar_Data {
180
  <?php if ( ( is_array( $usecolumns ) && in_array( 'time', $usecolumns ) ) && in_array( $time_format, array( 'combined', 'separate', 'time' ) ) ) { ?>
181
  <?php if ( 'time' == $time_format || 'separate' == $time_format ) { ?>
182
  <td>
183
- <?php echo apply_filters( 'sportspress_event_time_admin', get_post_time( get_option( 'time_format' ), false, $event, true ), $event->ID ); ?>
184
  </td>
185
  <?php } else { ?>
186
  <td>
187
  <?php
188
- if ( ! empty( $main_results ) ):
189
- echo implode( ' - ', $main_results );
190
- else:
191
- echo apply_filters( 'sportspress_event_time_admin', get_post_time( get_option( 'time_format' ), false, $event, true ), $event->ID );
192
  endif;
193
- ?>
194
  </td>
195
  <?php } ?>
196
  <?php } ?>
197
  <?php if ( ( is_array( $usecolumns ) && in_array( 'results', $usecolumns ) ) && in_array( $time_format, array( 'separate', 'results' ) ) ) { ?>
198
  <td>
199
  <?php
200
- if ( ! empty( $main_results ) ):
201
- echo implode( ' - ', $main_results );
202
- else:
203
  echo '-';
204
  endif;
205
- ?>
206
  </td>
207
  <?php } ?>
208
  <?php if ( is_array( $usecolumns ) && in_array( 'league', $usecolumns ) ) { ?>
@@ -216,19 +236,19 @@ class SP_Meta_Box_Calendar_Data {
216
  <?php } ?>
217
  <?php if ( is_array( $usecolumns ) && in_array( 'article', $usecolumns ) ) { ?>
218
  <td>
219
- <a href="<?php echo get_edit_post_link( $event->ID ); ?>#sp_articlediv">
220
- <?php if ( $video ): ?>
221
  <div class="dashicons dashicons-video-alt"></div>
222
- <?php elseif ( has_post_thumbnail( $event->ID ) ): ?>
223
  <div class="dashicons dashicons-camera"></div>
224
  <?php endif; ?>
225
  <?php
226
- if ( $event->post_content == null ):
227
- _e( 'None', 'sportspress' );
228
- elseif ( $event->post_status == 'publish' ):
229
- _e( 'Recap', 'sportspress' );
230
- else:
231
- _e( 'Preview', 'sportspress' );
232
  endif;
233
  ?>
234
  </a>
@@ -241,7 +261,7 @@ class SP_Meta_Box_Calendar_Data {
241
  if ( '' == $day ) {
242
  echo '&mdash;';
243
  } else {
244
- echo $day;
245
  }
246
  ?>
247
  </td>
@@ -251,23 +271,23 @@ class SP_Meta_Box_Calendar_Data {
251
  <?php
252
  $i++;
253
  endforeach;
254
- else:
255
  ?>
256
  <tr class="sp-row alternate">
257
- <td colspan="<?php echo sizeof( $usecolumns ); ?>">
258
- <?php _e( 'No results found.', 'sportspress' ); ?>
259
  </td>
260
  </tr>
261
  <?php
262
  endif;
263
- else:
264
- ?>
265
  <tr class="sp-row alternate">
266
- <td colspan="<?php echo sizeof( $usecolumns ); ?>">
267
- <?php printf( __( 'Select %s', 'sportspress' ), __( 'Details', 'sportspress' ) ); ?>
268
  </td>
269
  </tr>
270
- <?php
271
  endif;
272
  ?>
273
  </tbody>
2
  /**
3
  * Calendar Events
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Meta_Boxes
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  /**
16
  * SP_Meta_Box_Calendar_Data
21
  * Output the metabox
22
  */
23
  public static function output( $post ) {
24
+ $calendar = new SP_Calendar( $post );
25
+ $data = $calendar->data();
26
  $usecolumns = $calendar->columns;
27
  self::table( $data, $usecolumns );
28
  }
31
  * Save meta box data
32
  */
33
  public static function save( $post_id, $post ) {
34
+ update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array(), 'text' ) );
35
  }
36
 
37
  /**
39
  */
40
  public static function table( $data = array(), $usecolumns = null ) {
41
  $title_format = get_option( 'sportspress_event_list_title_format', 'title' );
42
+ $time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
43
 
44
  if ( is_array( $usecolumns ) ) {
45
  $usecolumns = array_filter( $usecolumns );
46
+ } else {
47
  $usecolumns = array();
48
  }
49
  ?>
52
  <thead>
53
  <tr>
54
  <th class="column-date">
55
+ <?php esc_attr_e( 'Date', 'sportspress' ); ?>
56
  </th>
57
  <?php if ( is_array( $usecolumns ) && in_array( 'event', $usecolumns ) ) { ?>
58
  <th class="column-event">
59
  <label for="sp_columns_event">
60
  <?php
61
  if ( 'teams' == $title_format ) {
62
+ esc_attr_e( 'Home', 'sportspress' );
63
+ ?>
64
+ |
65
+ <?php
66
+ esc_attr_e( 'Away', 'sportspress' );
67
  } elseif ( 'homeaway' == $title_format ) {
68
+ esc_attr_e( 'Teams', 'sportspress' );
69
  } else {
70
+ esc_attr_e( 'Title', 'sportspress' );
71
  }
72
  ?>
73
  </label>
78
  <label for="sp_columns_time">
79
  <?php
80
  if ( 'time' == $time_format || 'separate' == $time_format ) {
81
+ esc_attr_e( 'Time', 'sportspress' );
82
  } else {
83
+ esc_attr_e( 'Time/Results', 'sportspress' );
84
  }
85
  ?>
86
  </label>
89
  <?php if ( ( is_array( $usecolumns ) && in_array( 'results', $usecolumns ) ) && in_array( $time_format, array( 'separate', 'results' ) ) ) { ?>
90
  <th class="column-results">
91
  <label for="sp_columns_results">
92
+ <?php esc_attr_e( 'Results', 'sportspress' ); ?>
93
  </label>
94
  </th>
95
  <?php } ?>
96
  <?php if ( is_array( $usecolumns ) && in_array( 'league', $usecolumns ) ) { ?>
97
  <th class="column-league">
98
  <label for="sp_columns_league">
99
+ <?php esc_attr_e( 'League', 'sportspress' ); ?>
100
  </label>
101
  </th>
102
  <?php } ?>
103
  <?php if ( is_array( $usecolumns ) && in_array( 'season', $usecolumns ) ) { ?>
104
  <th class="column-season">
105
  <label for="sp_columns_season">
106
+ <?php esc_attr_e( 'Season', 'sportspress' ); ?>
107
  </label>
108
  </th>
109
  <?php } ?>
110
  <?php if ( is_array( $usecolumns ) && in_array( 'venue', $usecolumns ) ) { ?>
111
  <th class="column-venue">
112
  <label for="sp_columns_venue">
113
+ <?php esc_attr_e( 'Venue', 'sportspress' ); ?>
114
  </label>
115
  </th>
116
  <?php } ?>
117
  <?php if ( is_array( $usecolumns ) && in_array( 'article', $usecolumns ) ) { ?>
118
  <th class="column-article">
119
  <label for="sp_columns_article">
120
+ <?php esc_attr_e( 'Article', 'sportspress' ); ?>
121
  </label>
122
  </th>
123
  <?php } ?>
124
  <?php if ( is_array( $usecolumns ) && in_array( 'day', $usecolumns ) ) { ?>
125
  <th class="column-day">
126
  <label for="sp_columns_day">
127
+ <?php esc_attr_e( 'Match Day', 'sportspress' ); ?>
128
  </label>
129
  </th>
130
  <?php } ?>
133
  </thead>
134
  <tbody>
135
  <?php
136
+ if ( is_array( $data ) ) :
137
+ if ( sizeof( $data ) > 0 ) :
138
  $main_result = get_option( 'sportspress_primary_result', null );
139
+ $i = 0;
140
+ foreach ( $data as $event ) :
141
+ $teams = get_post_meta( $event->ID, 'sp_team' );
142
+ $results = get_post_meta( $event->ID, 'sp_results', true );
143
+ $video = get_post_meta( $event->ID, 'sp_video', true );
144
  $main_results = array();
145
  ?>
146
+ <tr class="sp-row sp-post
147
+ <?php
148
+ if ( $i % 2 == 0 ) {
149
+ echo ' alternate';}
150
+ ?>
151
+ ">
152
+ <td><?php echo esc_attr( get_post_time( get_option( 'date_format' ) ), false, $event, true ); ?></td>
153
  <?php if ( is_array( $usecolumns ) && in_array( 'event', $usecolumns ) ) { ?>
154
  <td>
155
+ <div class="sp-title-format sp-title-format-title
156
+ <?php
157
+ if ( $title_format && $title_format != 'title' ) :
158
+ ?>
159
+ hidden<?php endif; ?>"><?php echo esc_html( $event->post_title ); ?></div>
160
+ <div class="sp-title-format sp-title-format-teams sp-title-format-homeaway
161
+ <?php
162
+ if ( ! in_array( $title_format, array( 'teams', 'homeaway' ) ) ) :
163
+ ?>
164
+ hidden<?php endif; ?>">
165
  <?php
166
+ if ( $teams ) :
167
+ foreach ( $teams as $team ) :
168
+ $name = get_the_title( $team );
169
+ if ( $name ) :
170
+ $team_results = sp_array_value( $results, $team, null );
171
 
172
+ if ( $main_result ) :
173
+ $team_result = sp_array_value( $team_results, $main_result, null );
174
+ else :
175
+ if ( is_array( $team_results ) ) :
176
+ end( $team_results );
177
+ $team_result = prev( $team_results );
178
+ else :
179
+ $team_result = null;
180
+ endif;
181
  endif;
 
182
 
183
+ if ( $team_result != null ) :
184
+ $team_result = apply_filters( 'sportspress_calendar_team_result_admin', $team_result, $event->ID, $team );
185
+ $main_results[] = $team_result;
186
+ unset( $team_results['outcome'] );
187
+ $team_results = implode( ' | ', $team_results );
188
+ echo '<a class="result sp-tip" title="' . esc_attr( $team_results ) . '" href="' . esc_url( get_edit_post_link( $event->ID ) ) . '">' . esc_attr( $team_result ) . '</a> ';
189
+ endif;
190
 
191
+ echo esc_html( $name ) . '<br>';
192
+ endif;
193
+ endforeach; else :
194
  echo '&mdash;';
195
  endif;
196
  ?>
200
  <?php if ( ( is_array( $usecolumns ) && in_array( 'time', $usecolumns ) ) && in_array( $time_format, array( 'combined', 'separate', 'time' ) ) ) { ?>
201
  <?php if ( 'time' == $time_format || 'separate' == $time_format ) { ?>
202
  <td>
203
+ <?php echo wp_kses_post( apply_filters( 'sportspress_event_time_admin', get_post_time( get_option( 'time_format' ), false, $event, true ), $event->ID ) ); ?>
204
  </td>
205
  <?php } else { ?>
206
  <td>
207
  <?php
208
+ if ( ! empty( $main_results ) ) :
209
+ echo wp_kses_post( implode( ' - ', $main_results ) );
210
+ else :
211
+ echo wp_kses_post( apply_filters( 'sportspress_event_time_admin', get_post_time( get_option( 'time_format' ), false, $event, true ), $event->ID ) );
212
  endif;
213
+ ?>
214
  </td>
215
  <?php } ?>
216
  <?php } ?>
217
  <?php if ( ( is_array( $usecolumns ) && in_array( 'results', $usecolumns ) ) && in_array( $time_format, array( 'separate', 'results' ) ) ) { ?>
218
  <td>
219
  <?php
220
+ if ( ! empty( $main_results ) ) :
221
+ echo wp_kses_post( implode( ' - ', $main_results ) );
222
+ else :
223
  echo '-';
224
  endif;
225
+ ?>
226
  </td>
227
  <?php } ?>
228
  <?php if ( is_array( $usecolumns ) && in_array( 'league', $usecolumns ) ) { ?>
236
  <?php } ?>
237
  <?php if ( is_array( $usecolumns ) && in_array( 'article', $usecolumns ) ) { ?>
238
  <td>
239
+ <a href="<?php echo esc_url( get_edit_post_link( $event->ID ) ); ?>#sp_articlediv">
240
+ <?php if ( $video ) : ?>
241
  <div class="dashicons dashicons-video-alt"></div>
242
+ <?php elseif ( has_post_thumbnail( $event->ID ) ) : ?>
243
  <div class="dashicons dashicons-camera"></div>
244
  <?php endif; ?>
245
  <?php
246
+ if ( $event->post_content == null ) :
247
+ esc_attr_e( 'None', 'sportspress' );
248
+ elseif ( $event->post_status == 'publish' ) :
249
+ esc_attr_e( 'Recap', 'sportspress' );
250
+ else :
251
+ esc_attr_e( 'Preview', 'sportspress' );
252
  endif;
253
  ?>
254
  </a>
261
  if ( '' == $day ) {
262
  echo '&mdash;';
263
  } else {
264
+ echo esc_html( $day );
265
  }
266
  ?>
267
  </td>
271
  <?php
272
  $i++;
273
  endforeach;
274
+ else :
275
  ?>
276
  <tr class="sp-row alternate">
277
+ <td colspan="<?php echo esc_attr( sizeof( $usecolumns ) ); ?>">
278
+ <?php esc_attr_e( 'No results found.', 'sportspress' ); ?>
279
  </td>
280
  </tr>
281
  <?php
282
  endif;
283
+ else :
284
+ ?>
285
  <tr class="sp-row alternate">
286
+ <td colspan="<?php echo esc_attr( sizeof( $usecolumns ) ); ?>">
287
+ <?php printf( esc_attr__( 'Select %s', 'sportspress' ), esc_attr__( 'Details', 'sportspress' ) ); ?>
288
  </td>
289
  </tr>
290
+ <?php
291
  endif;
292
  ?>
293
  </tbody>
includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-details.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Calendar Details
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin/Meta_Boxes
8
- * @version 2.6.19
9
  */
10
 
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
 
 
12
 
13
  /**
14
  * SP_Meta_Box_Calendar_Details
@@ -19,54 +21,54 @@ class SP_Meta_Box_Calendar_Details {
19
  * Output the metabox
20
  */
21
  public static function output( $post ) {
22
- $taxonomies = get_object_taxonomies( 'sp_calendar' );
23
- $caption = get_post_meta( $post->ID, 'sp_caption', true );
24
- $status = get_post_meta( $post->ID, 'sp_status', true );
25
- $date = get_post_meta( $post->ID, 'sp_date', true );
26
- $date_from = get_post_meta( $post->ID, 'sp_date_from', true );
27
- $date_to = get_post_meta( $post->ID, 'sp_date_to', true );
28
- $date_past = get_post_meta( $post->ID, 'sp_date_past', true );
29
- $date_future = get_post_meta( $post->ID, 'sp_date_future', true );
30
  $date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
31
- $event_format = get_post_meta( $post->ID, 'sp_event_format', true );
32
- $day = get_post_meta( $post->ID, 'sp_day', true );
33
- $teams = get_post_meta( $post->ID, 'sp_team', false );
34
- $players = get_post_meta( $post->ID, 'sp_player', false );
35
- $table_id = get_post_meta( $post->ID, 'sp_table', true );
36
- $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
37
- $order = get_post_meta( $post->ID, 'sp_order', true );
38
  ?>
39
  <div>
40
- <p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
41
  <p><input type="text" id="sp_caption" name="sp_caption" value="<?php echo esc_attr( $caption ); ?>" placeholder="<?php echo esc_attr( get_the_title() ); ?>"></p>
42
 
43
- <p><strong><?php _e( 'Status', 'sportspress' ); ?></strong></p>
44
  <p>
45
  <?php
46
  $args = array(
47
- 'name' => 'sp_status',
48
- 'id' => 'sp_status',
49
  'selected' => $status,
50
  );
51
  sp_dropdown_statuses( $args );
52
  ?>
53
  </p>
54
- <p><strong><?php _e( 'Event Format', 'sportspress' ); ?></strong></p>
55
  <p>
56
  <select name="sp_event_format" class="postform">
57
  <option value="all">All</option>
58
- <?php foreach ( SP()->formats->event as $key => $format ): ?>
59
- <option value="<?php echo $key; ?>" <?php selected( $event_format, $key ); ?>><?php echo $format; ?></option>
60
  <?php endforeach; ?>
61
  </select>
62
  </p>
63
  <div class="sp-date-selector">
64
- <p><strong><?php _e( 'Date', 'sportspress' ); ?></strong></p>
65
  <p>
66
  <?php
67
  $args = array(
68
- 'name' => 'sp_date',
69
- 'id' => 'sp_date',
70
  'selected' => $date,
71
  );
72
  sp_dropdown_dates( $args );
@@ -74,33 +76,33 @@ class SP_Meta_Box_Calendar_Details {
74
  </p>
75
  <div class="sp-date-range">
76
  <p class="sp-date-range-absolute">
77
- <input type="text" class="sp-datepicker-from" name="sp_date_from" value="<?php echo $date_from ? $date_from : date_i18n( 'Y-m-d' ); ?>" size="10">
78
  :
79
- <input type="text" class="sp-datepicker-to" name="sp_date_to" value="<?php echo $date_to ? $date_to : date_i18n( 'Y-m-d' ); ?>" size="10">
80
  </p>
81
 
82
  <p class="sp-date-range-relative">
83
- <?php _e( 'Past', 'sportspress' ); ?>
84
- <input type="number" min="0" step="1" class="tiny-text" name="sp_date_past" value="<?php echo '' !== $date_past ? $date_past : 7; ?>">
85
- <?php _e( 'days', 'sportspress' ); ?>
86
  &rarr;
87
- <?php _e( 'Next', 'sportspress' ); ?>
88
- <input type="number" min="0" step="1" class="tiny-text" name="sp_date_future" value="<?php echo '' !== $date_future ? $date_future : 7; ?>">
89
- <?php _e( 'days', 'sportspress' ); ?>
90
  </p>
91
 
92
  <p class="sp-date-relative">
93
  <label>
94
  <input type="checkbox" name="sp_date_relative" value="1" id="sp_date_relative" <?php checked( $date_relative ); ?>>
95
- <?php _e( 'Relative', 'sportspress' ); ?>
96
  </label>
97
  </p>
98
  </div>
99
  </div>
100
  <div class="sp-event-day-field">
101
- <p><strong><?php _e( 'Match Day', 'sportspress' ); ?></strong></p>
102
  <p>
103
- <input name="sp_day" type="text" class="medium-text" placeholder="<?php _e( 'All', 'sportspress' ); ?>" value="<?php echo esc_attr( $day ); ?>">
104
  </p>
105
  </div>
106
  <?php
@@ -108,54 +110,54 @@ class SP_Meta_Box_Calendar_Details {
108
  sp_taxonomy_field( $taxonomy, $post, true );
109
  }
110
  ?>
111
- <p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
112
  <p>
113
  <?php
114
  $args = array(
115
- 'post_type' => 'sp_team',
116
- 'name' => 'sp_team[]',
117
- 'selected' => $teams,
118
- 'values' => 'ID',
119
- 'class' => 'widefat',
120
- 'property' => 'multiple',
121
- 'chosen' => true,
122
- 'placeholder' => __( 'All', 'sportspress' ),
123
  );
124
- if ( ! sp_dropdown_pages( $args ) ):
125
- sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
126
  endif;
127
  ?>
128
  </p>
129
- <p><strong><?php _e( 'Player', 'sportspress' ); ?></strong></p>
130
  <p>
131
  <?php
132
  $args = array(
133
- 'post_type' => 'sp_player',
134
- 'name' => 'sp_player[]',
135
- 'selected' => $players,
136
- 'values' => 'ID',
137
- 'class' => 'widefat',
138
- 'property' => 'multiple',
139
- 'chosen' => true,
140
- 'placeholder' => __( 'All', 'sportspress' ),
141
  );
142
- if ( ! sp_dropdown_pages( $args ) ):
143
- sp_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
144
  endif;
145
  ?>
146
  </p>
147
- <p><strong><?php _e( 'Sort by', 'sportspress' ); ?></strong></p>
148
  <p>
149
  <select name="sp_orderby">
150
- <option value="date" <?php selected( 'date', $orderby ); ?>><?php _e( 'Date', 'sportspress' ); ?></option>
151
- <option value="day" <?php selected( 'day', $orderby ); ?>><?php _e( 'Match Day', 'sportspress' ); ?></option>
152
  </select>
153
  </p>
154
- <p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
155
  <p>
156
  <select name="sp_order">
157
- <option value="ASC" <?php selected( 'ASC', $order ); ?>><?php _e( 'Ascending', 'sportspress' ); ?></option>
158
- <option value="DESC" <?php selected( 'DESC', $order ); ?>><?php _e( 'Descending', 'sportspress' ); ?></option>
159
  </select>
160
  </p>
161
  </div>
@@ -166,22 +168,22 @@ class SP_Meta_Box_Calendar_Details {
166
  * Save meta box data
167
  */
168
  public static function save( $post_id, $post ) {
169
- update_post_meta( $post_id, 'sp_caption', esc_attr( sp_array_value( $_POST, 'sp_caption', 0 ) ) );
170
- update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0 ) );
171
- update_post_meta( $post_id, 'sp_event_format', sp_array_value( $_POST, 'sp_event_format', 0 ) );
172
- update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
173
- update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );
174
- update_post_meta( $post_id, 'sp_date_to', sp_array_value( $_POST, 'sp_date_to', null ) );
175
- update_post_meta( $post_id, 'sp_date_past', sp_array_value( $_POST, 'sp_date_past', 0 ) );
176
- update_post_meta( $post_id, 'sp_date_future', sp_array_value( $_POST, 'sp_date_future', 0 ) );
177
- update_post_meta( $post_id, 'sp_date_relative', sp_array_value( $_POST, 'sp_date_relative', 0 ) );
178
- update_post_meta( $post_id, 'sp_day', sp_array_value( $_POST, 'sp_day', null ) );
2
  /**
3
  * Calendar Details
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin/Meta_Boxes
8
+ * @version 2.7.9
9
  */
10
 
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
 
15
  /**
16
  * SP_Meta_Box_Calendar_Details
21
  * Output the metabox
22
  */
23
  public static function output( $post ) {
24
+ $taxonomies = get_object_taxonomies( 'sp_calendar' );
25
+ $caption = get_post_meta( $post->ID, 'sp_caption', true );
26
+ $status = get_post_meta( $post->ID, 'sp_status', true );
27
+ $date = get_post_meta( $post->ID, 'sp_date', true );
28
+ $date_from = get_post_meta( $post->ID, 'sp_date_from', true );
29
+ $date_to = get_post_meta( $post->ID, 'sp_date_to', true );
30
+ $date_past = get_post_meta( $post->ID, 'sp_date_past', true );
31
+ $date_future = get_post_meta( $post->ID, 'sp_date_future', true );
32
  $date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
33
+ $event_format = get_post_meta( $post->ID, 'sp_event_format', true );
34
+ $day = get_post_meta( $post->ID, 'sp_day', true );
35
+ $teams = get_post_meta( $post->ID, 'sp_team', false );
36
+ $players = get_post_meta( $post->ID, 'sp_player', false );
37
+ $table_id = get_post_meta( $post->ID, 'sp_table', true );
38
+ $orderby = get_post_meta( $post->ID, 'sp_orderby', true );
39
+ $order = get_post_meta( $post->ID, 'sp_order', true );
40
  ?>
41
  <div>
42
+ <p><strong><?php esc_attr_e( 'Heading', 'sportspress' ); ?></strong></p>
43
  <p><input type="text" id="sp_caption" name="sp_caption" value="<?php echo esc_attr( $caption ); ?>" placeholder="<?php echo esc_attr( get_the_title() ); ?>"></p>
44
 
45
+ <p><strong><?php esc_attr_e( 'Status', 'sportspress' ); ?></strong></p>
46
  <p>
47
  <?php
48
  $args = array(
49
+ 'name' => 'sp_status',
50
+ 'id' => 'sp_status',
51
  'selected' => $status,
52
  );
53
  sp_dropdown_statuses( $args );
54
  ?>
55
  </p>
56
+ <p><strong><?php esc_attr_e( 'Event Format', 'sportspress' ); ?></strong></p>
57
  <p>
58
  <select name="sp_event_format" class="postform">
59
  <option value="all">All</option>
60
+ <?php foreach ( SP()->formats->event as $key => $format ) : ?>
61
+ <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $event_format, $key ); ?>><?php echo esc_html( $format ); ?></option>
62
  <?php endforeach; ?>
63
  </select>
64
  </p>
65
  <div class="sp-date-selector">
66
+ <p><strong><?php esc_attr_e( 'Date', 'sportspress' ); ?></strong></p>
67
  <p>
68
  <?php
69
  $args = array(
70
+ 'name' => 'sp_date',
71
+ 'id' => 'sp_date',
72
  'selected' => $date,
73
  );
74
  sp_dropdown_dates( $args );
76
  </p>
77
  <div class="sp-date-range">
78
  <p class="sp-date-range-absolute">
79
+ <input type="text" class="sp-datepicker-from" name="sp_date_from" value="<?php echo $date_from ? esc_attr( $date_from ) : esc_attr( date_i18n( 'Y-m-d' ) ); ?>" size="10">
80
  :
81
+ <input type="text" class="sp-datepicker-to" name="sp_date_to" value="<?php echo $date_to ? esc_attr( $date_to ) : esc_attr( date_i18n( 'Y-m-d' ) ); ?>" size="10">
82
  </p>
83
 
84
  <p class="sp-date-range-relative">
85
+ <?php esc_attr_e( 'Past', 'sportspress' ); ?>
86
+ <input type="number" min="0" step="1" class="tiny-text" name="sp_date_past" value="<?php echo '' !== $date_past ? esc_attr( $date_past ) : 7; ?>">
87
+ <?php esc_attr_e( 'days', 'sportspress' ); ?>
88
  &rarr;
89
+ <?php esc_attr_e( 'Next', 'sportspress' ); ?>
90
+ <input type="number" min="0" step="1" class="tiny-text" name="sp_date_future" value="<?php echo '' !== $date_future ? esc_attr( $date_future ) : 7; ?>">
91
+ <?php esc_attr_e( 'days', 'sportspress' ); ?>
92
  </p>
93
 
94
  <p class="sp-date-relative">
95
  <label>
96
  <input type="checkbox" name="sp_date_relative" value="1" id="sp_date_relative" <?php checked( $date_relative ); ?>>
97
+ <?php esc_attr_e( 'Relative', 'sportspress' ); ?>
98
  </label>
99
  </p>
100
  </div>
101
  </div>
102
  <div class="sp-event-day-field">
103
+ <p><strong><?php esc_attr_e( 'Match Day', 'sportspress' ); ?></strong></p>
104
  <p>
105
+ <input name="sp_day" type="text" class="medium-text" placeholder="<?php esc_attr_e( 'All', 'sportspress' ); ?>" value="<?php echo esc_attr( $day ); ?>">
106
  </p>
107
  </div>
108
  <?php
110
  sp_taxonomy_field( $taxonomy, $post, true );
111
  }
112
  ?>
113
+ <p><strong><?php esc_attr_e( 'Team', 'sportspress' ); ?></strong></p>
114
  <p>
115
  <?php
116
  $args = array(
117
+ 'post_type' => 'sp_team',
118
+ 'name' => 'sp_team[]',
119
+ 'selected' => $teams,
120
+ 'values' => 'ID',
121
+ 'class' => 'widefat',
122
+ 'property' => 'multiple',
123
+ 'chosen' => true,
124
+ 'placeholder' => esc_attr__( 'All', 'sportspress' ),
125
  );
126
+ if ( ! sp_dropdown_pages( $args ) ) :
127
+ sp_post_adder( 'sp_team', esc_attr__( 'Add New', 'sportspress' ) );
128
  endif;
129
  ?>
130
  </p>
131
+ <p><strong><?php esc_attr_e( 'Player', 'sportspress' ); ?></strong></p>
132
  <p>
133
  <?php
134
  $args = array(
135
+ 'post_type' => 'sp_player',
136
+ 'name' => 'sp_player[]',
137
+ 'selected' => $players,
138
+ 'values' => 'ID',
139
+ 'class' => 'widefat',
140
+ 'property' => 'multiple',
141
+ 'chosen' => true,
142
+ 'placeholder' => esc_attr__( 'All', 'sportspress' ),
143
  );
144
+ if ( ! sp_dropdown_pages( $args ) ) :
145
+ sp_post_adder( 'sp_player', esc_attr__( 'Add New', 'sportspress' ) );
146
  endif;
147
  ?>
148
  </p>
149
+ <p><strong><?php esc_attr_e( 'Sort by', 'sportspress' ); ?></strong></p>
150
  <p>
151
  <select name="sp_orderby">
152
+ <option value="date" <?php selected( 'date', $orderby ); ?>><?php esc_attr_e( 'Date', 'sportspress' ); ?></option>
153
+ <option value="day" <?php selected( 'day', $orderby ); ?>><?php esc_attr_e( 'Match Day', 'sportspress' ); ?></option>
154
  </select>
155
  </p>
156
+ <p><strong><?php esc_attr_e( 'Sort Order', 'sportspress' ); ?></strong></p>
157
  <p>
158
  <select name="sp_order">
159
+ <option value="ASC" <?php selected( 'ASC', $order ); ?>><?php esc_attr_e( 'Ascending', 'sportspress' ); ?></option>
160
+ <option value="DESC" <?php selected( 'DESC', $order ); ?>><?php esc_attr_e( 'Descending', 'sportspress' ); ?></option>
161
  </select>
162
  </p>
163
  </div>
168
  * Save meta box data
169
  */
170
  public static function save( $post_id, $post ) {
171
+ update_post_meta( $post_id, 'sp_caption', sp_array_value( $_POST, 'sp_caption', 0, 'text' ) );
172
+ update_post_meta( $post_id, 'sp_status', sp_array_value( $_POST, 'sp_status', 0, 'text' ) );
173
+ update_post_meta( $post_id, 'sp_event_format', sp_array_value( $_POST, 'sp_event_format', 0, 'key' ) );
174
+ update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0, 'text' ) );
175
+ update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null, 'text' ) );
176
+ update_post_meta( $post_id, 'sp_date_to', sp_array_value( $_POST, 'sp_date_to', null, 'text' ) );
177
+ update_post_meta( $post_id, 'sp_date_past', sp_array_value( $_POST, 'sp_date_past', 0, 'text' ) );
178
+ update_post_meta( $post_id, 'sp_date_future', sp_array_value( $_POST, 'sp_date_future', 0, 'text' ) );
179
+ update_post_meta( $post_id, 'sp_date_relative', sp_array_value( $_POST, 'sp_date_relative',