Clean up spaces, tabs, indentation, and bracket formatting
This commit is contained in:
@@ -60,18 +60,18 @@ p.sportspress-actions a.button-primary:focus {
|
||||
|
||||
.sportspress-steps:before,
|
||||
.sportspress-steps:after {
|
||||
content: " ";
|
||||
display: table;
|
||||
content: " ";
|
||||
display: table;
|
||||
}
|
||||
|
||||
.sportspress-steps:after {
|
||||
clear: both;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.sportspress-steps {
|
||||
*zoom: 1;
|
||||
*zoom: 1;
|
||||
}
|
||||
|
||||
.sportspress-steps .welcome-icon i:before {
|
||||
color: #888;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,8 +318,8 @@ table.widefat.sp-data-table input[type="text"],
|
||||
table.widefat.sp-data-table input[type="number"] {
|
||||
min-width: 1.25em;
|
||||
width: 100%;
|
||||
margin: 1px;
|
||||
padding: 3px 5px;
|
||||
margin: 1px;
|
||||
padding: 3px 5px;
|
||||
}
|
||||
|
||||
table.widefat.sp-data-table input[type="text"]::placeholder,
|
||||
@@ -681,28 +681,28 @@ table.widefat.sp-sortable-table tbody tr .icon {
|
||||
|
||||
.sp-toggle-switch + label:before,
|
||||
.sp-toggle-switch + label:after {
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
content: "";
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
content: "";
|
||||
}
|
||||
|
||||
.sp-toggle-switch + label:before {
|
||||
right: 1px;
|
||||
background-color: #e4e4e4;
|
||||
border-radius: 16px;
|
||||
transition: background 0.4s;
|
||||
right: 1px;
|
||||
background-color: #e4e4e4;
|
||||
border-radius: 16px;
|
||||
transition: background 0.4s;
|
||||
}
|
||||
|
||||
.sp-toggle-switch + label:after {
|
||||
width: 16px;
|
||||
background-color: #fff;
|
||||
border-radius: 100%;
|
||||
-webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
transition: margin 0.4s;
|
||||
width: 16px;
|
||||
background-color: #fff;
|
||||
border-radius: 100%;
|
||||
-webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
transition: margin 0.4s;
|
||||
}
|
||||
|
||||
.sp-toggle-switch:checked + label:before {
|
||||
@@ -735,7 +735,7 @@ table.widefat.sp-sortable-table tbody tr .icon {
|
||||
clear: both;
|
||||
max-width: 382px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.sp-sortable-list .sp-item-float + .sp-item-float {
|
||||
@@ -743,49 +743,49 @@ table.widefat.sp-sortable-table tbody tr .icon {
|
||||
}
|
||||
|
||||
.sp-item-bar {
|
||||
clear: both;
|
||||
line-height: 1.5em;
|
||||
position: relative;
|
||||
margin: 9px 0 0;
|
||||
clear: both;
|
||||
line-height: 1.5em;
|
||||
position: relative;
|
||||
margin: 9px 0 0;
|
||||
}
|
||||
|
||||
.sp-item-bar .sp-item-handle {
|
||||
background: #fafafa;
|
||||
color: #23282d;
|
||||
border: 1px solid #dfdfdf;
|
||||
position: relative;
|
||||
padding: 10px 15px;
|
||||
height: auto;
|
||||
min-height: 20px;
|
||||
line-height: 30px;
|
||||
overflow: hidden;
|
||||
word-wrap: break-word;
|
||||
border: 1px solid #dfdfdf;
|
||||
position: relative;
|
||||
padding: 10px 15px;
|
||||
height: auto;
|
||||
min-height: 20px;
|
||||
line-height: 30px;
|
||||
overflow: hidden;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.sp-item-bar .sp-item-handle:hover {
|
||||
border-color: #999;
|
||||
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.1);
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,.1);
|
||||
border-color: #999;
|
||||
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.1);
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,.1);
|
||||
}
|
||||
|
||||
.sp-item-bar .sp-item-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 20px;
|
||||
display: block;
|
||||
margin-right: 13em;
|
||||
font-weight: 600;
|
||||
line-height: 20px;
|
||||
display: block;
|
||||
margin-right: 13em;
|
||||
}
|
||||
|
||||
.sp-item-settings {
|
||||
display: block;
|
||||
padding: 10px 0 10px 15px;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
background: #fff;
|
||||
border: 1px solid #e5e5e5;
|
||||
border-top: none;
|
||||
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
display: block;
|
||||
padding: 10px 0 10px 15px;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
background: #fff;
|
||||
border: 1px solid #e5e5e5;
|
||||
border-top: none;
|
||||
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
}
|
||||
|
||||
.js .sp-item-handle {
|
||||
@@ -793,9 +793,9 @@ table.widefat.sp-sortable-table tbody tr .icon {
|
||||
}
|
||||
|
||||
.sp-sortable-list .sp-item-placeholder {
|
||||
border: 1px dashed #b4b9be;
|
||||
margin: 9px auto 6px;
|
||||
height: 42px;
|
||||
border: 1px dashed #b4b9be;
|
||||
margin: 9px auto 6px;
|
||||
height: 42px;
|
||||
}
|
||||
|
||||
/* Logo */
|
||||
@@ -1225,7 +1225,7 @@ table.sp-status-table td mark.yes {
|
||||
float: none;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
|
||||
.wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-sp_format,
|
||||
.wp-list-table tr:not(.inline-edit-row):not(.no-items) td.column-sp_icon,
|
||||
.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 {
|
||||
margin-right: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
|
||||
.about-sportspress-wrap .sp-badge {
|
||||
float: none;
|
||||
margin: 20px auto 10px;
|
||||
|
||||
@@ -427,9 +427,9 @@ This file is generated by `grunt build`, do not edit it by hand.
|
||||
.chosen-container-multi .chosen-choices .search-choice .search-choice-close,
|
||||
.chosen-container .chosen-results-scroll-down span,
|
||||
.chosen-container .chosen-results-scroll-up span {
|
||||
background-image: url('../images/chosen/chosen-sprite@2x.png') !important;
|
||||
background-size: 52px 37px !important;
|
||||
background-repeat: no-repeat !important;
|
||||
background-image: url('../images/chosen/chosen-sprite@2x.png') !important;
|
||||
background-size: 52px 37px !important;
|
||||
background-repeat: no-repeat !important;
|
||||
}
|
||||
}
|
||||
/* @end */
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
}
|
||||
#available-widgets [class*=sp_countdown] .widget-title:before {
|
||||
content: "\f469";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +73,4 @@
|
||||
|
||||
.sp-equation-formula .button .remove:hover {
|
||||
color: #d00;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
.leaflet-marker-shadow {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
/* Prevents IE11 from highlighting tiles in blue */
|
||||
@@ -86,7 +86,7 @@
|
||||
width: 0;
|
||||
height: 0;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
z-index: 800;
|
||||
}
|
||||
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
|
||||
@@ -173,15 +173,15 @@
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
-moz-transition: opacity 0.2s linear;
|
||||
transition: opacity 0.2s linear;
|
||||
transition: opacity 0.2s linear;
|
||||
}
|
||||
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||
opacity: 1;
|
||||
}
|
||||
.leaflet-zoom-animated {
|
||||
-webkit-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
will-change: transform;
|
||||
@@ -189,13 +189,13 @@
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-tile,
|
||||
.leaflet-pan-anim .leaflet-tile {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
transition: none;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-hide {
|
||||
@@ -435,7 +435,7 @@ svg.leaflet-image-layer.leaflet-interactive path {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
|
||||
background: #fff;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
@@ -498,8 +498,8 @@ svg.leaflet-image-layer.leaflet-interactive path {
|
||||
|
||||
-webkit-transform: rotate(45deg);
|
||||
-moz-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
.leaflet-popup-content-wrapper,
|
||||
.leaflet-popup-tip {
|
||||
|
||||
@@ -371,4 +371,4 @@ i.mce-i-sp_shortcodes_button:before, span.mce_sp_shortcodes_button:before {
|
||||
text-align: center;
|
||||
content: "\f111";
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,421 +1,421 @@
|
||||
.sp-setup-content p,
|
||||
.sp-setup-content table {
|
||||
font-size: 1em;
|
||||
line-height: 1.75em;
|
||||
color: #666;
|
||||
font-size: 1em;
|
||||
line-height: 1.75em;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 100px auto 24px;
|
||||
box-shadow: none;
|
||||
background: #f1f1f1;
|
||||
padding: 0;
|
||||
margin: 100px auto 24px;
|
||||
box-shadow: none;
|
||||
background: #f1f1f1;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#sp-logo {
|
||||
border: 0;
|
||||
margin: 24px 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
border: 0;
|
||||
margin: 24px 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#sp-logo img {
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
max-height: 50px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
max-height: 50px;
|
||||
}
|
||||
|
||||
.sp-setup-content {
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, .13);
|
||||
padding: 24px 24px 0;
|
||||
background: #fff;
|
||||
zoom: 1;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, .13);
|
||||
padding: 24px 24px 0;
|
||||
background: #fff;
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
.sp-setup-content:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.sp-setup-content h1,
|
||||
.sp-setup-content h2,
|
||||
.sp-setup-content h3,
|
||||
.sp-setup-content table {
|
||||
margin: 0 0 24px;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
color: #666;
|
||||
clear: none;
|
||||
margin: 0 0 24px;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
color: #666;
|
||||
clear: none;
|
||||
}
|
||||
|
||||
.sp-setup-content p {
|
||||
margin: 0 0 24px;
|
||||
margin: 0 0 24px;
|
||||
}
|
||||
|
||||
.sp-setup-content a {
|
||||
color: #00a69c;
|
||||
color: #00a69c;
|
||||
}
|
||||
|
||||
.sp-setup-content a:focus,
|
||||
.sp-setup-content a:hover {
|
||||
color: #111;
|
||||
color: #111;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table {
|
||||
width: 100%;
|
||||
border-top: 1px solid #eee;
|
||||
width: 100%;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table th {
|
||||
width: 30%;
|
||||
vertical-align: top;
|
||||
font-weight: 700;
|
||||
width: 30%;
|
||||
vertical-align: top;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td {
|
||||
vertical-align: top;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td input,
|
||||
.sp-setup-content .form-table td select {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td input[size] {
|
||||
width: auto;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td ol,
|
||||
.sp-setup-content .form-table td ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td ul {
|
||||
list-style: none;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td li {
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td li:last-child {
|
||||
margin-bottom: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td .description {
|
||||
line-height: 1.5em;
|
||||
display: block;
|
||||
margin: .25em 0 0;
|
||||
color: #999;
|
||||
font-style: italic;
|
||||
line-height: 1.5em;
|
||||
display: block;
|
||||
margin: .25em 0 0;
|
||||
color: #999;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td .input-checkbox,
|
||||
.sp-setup-content .form-table td .input-radio {
|
||||
width: auto;
|
||||
box-sizing: inherit;
|
||||
padding: inherit;
|
||||
margin: 0 .5em 0 0;
|
||||
box-shadow: none;
|
||||
width: auto;
|
||||
box-sizing: inherit;
|
||||
padding: inherit;
|
||||
margin: 0 .5em 0 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table .section_title td {
|
||||
padding: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table .section_title td h2,
|
||||
.sp-setup-content .form-table .section_title td p {
|
||||
margin: 12px 0 0;
|
||||
margin: 12px 0 0;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td,
|
||||
.sp-setup-content .form-table th {
|
||||
padding: 14px 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding: 14px 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td:first-child,
|
||||
.sp-setup-content .form-table th:first-child {
|
||||
padding-right: 9px;
|
||||
padding-right: 9px;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table th .sp-desc-tip {
|
||||
line-height: 1.4;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table .sp-chosen-container {
|
||||
display: block;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table .sp-location-picker {
|
||||
width: 100%;
|
||||
height: 320px;
|
||||
margin: 0.5em 0 0;
|
||||
width: 100%;
|
||||
height: 320px;
|
||||
margin: 0.5em 0 0;
|
||||
}
|
||||
|
||||
.sp-setup-content .twitter-share-button {
|
||||
float: right;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-banner {
|
||||
margin: 0 -24px 24px;
|
||||
margin: 0 -24px 24px;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-banner img {
|
||||
display: block;
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
display: block;
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps {
|
||||
overflow: hidden;
|
||||
margin: 0 0 24px;
|
||||
overflow: hidden;
|
||||
margin: 0 0 24px;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps h2 {
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps .sp-setup-next-steps-first {
|
||||
float: left;
|
||||
width: 50%;
|
||||
box-sizing: border-box;
|
||||
float: left;
|
||||
width: 50%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps .sp-setup-next-steps-last {
|
||||
float: right;
|
||||
width: 50%;
|
||||
box-sizing: border-box;
|
||||
float: right;
|
||||
width: 50%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps ul {
|
||||
padding: 0 2em 0 0;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0 2em 0 0;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps ul li .button {
|
||||
display: block;
|
||||
padding: 0 0 .75em;
|
||||
display: block;
|
||||
padding: 0 0 .75em;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps ul li .button-first-event {
|
||||
background-color: #3bbab3;
|
||||
border-color: #15a29a;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
text-shadow: 0 -1px 1px #15a29a, 1px 0 1px #15a29a, 0 1px 1px #15a29a, -1px 0 1px #15a29a;
|
||||
font-size: 1em;
|
||||
height: auto;
|
||||
line-height: 1.75em;
|
||||
margin: 0 0 .75em;
|
||||
opacity: 1;
|
||||
padding: 1em;
|
||||
text-align: center;
|
||||
background-color: #3bbab3;
|
||||
border-color: #15a29a;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
text-shadow: 0 -1px 1px #15a29a, 1px 0 1px #15a29a, 0 1px 1px #15a29a, -1px 0 1px #15a29a;
|
||||
font-size: 1em;
|
||||
height: auto;
|
||||
line-height: 1.75em;
|
||||
margin: 0 0 .75em;
|
||||
opacity: 1;
|
||||
padding: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps ul li .button-first-event:active,
|
||||
.sp-setup-content .sp-setup-next-steps ul li .button-first-event:focus,
|
||||
.sp-setup-content .sp-setup-next-steps ul li .button-first-event:hover {
|
||||
background: #15a29a;
|
||||
border-color: #15a29a;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
background: #15a29a;
|
||||
border-color: #15a29a;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps ul li a:before {
|
||||
color: #82878c;
|
||||
font: 400 20px/1 dashicons;
|
||||
speak: none;
|
||||
display: inline-block;
|
||||
padding: 0 10px 0 0;
|
||||
top: 1px;
|
||||
position: relative;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
text-decoration: none!important;
|
||||
vertical-align: top;
|
||||
color: #82878c;
|
||||
font: 400 20px/1 dashicons;
|
||||
speak: none;
|
||||
display: inline-block;
|
||||
padding: 0 10px 0 0;
|
||||
top: 1px;
|
||||
position: relative;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
text-decoration: none!important;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps ul .learn-more a:before {
|
||||
content: "\f105";
|
||||
content: "\f105";
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps ul .video-walkthrough a:before {
|
||||
content: "\f126";
|
||||
content: "\f126";
|
||||
}
|
||||
|
||||
.sp-setup-content .sp-setup-next-steps ul .newsletter a:before {
|
||||
content: "\f465";
|
||||
content: "\f465";
|
||||
}
|
||||
|
||||
.sp-setup-content .updated {
|
||||
padding: 24px 24px 0;
|
||||
margin: 0 0 24px;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
padding: 24px 24px 0;
|
||||
margin: 0 0 24px;
|
||||
overflow: hidden;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.sp-setup-content .updated p {
|
||||
padding: 0;
|
||||
margin: 0 0 12px;
|
||||
padding: 0;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.sp-setup-content .updated p:last-child {
|
||||
margin: 0 0 24px;
|
||||
margin: 0 0 24px;
|
||||
}
|
||||
|
||||
.sp-setup-steps {
|
||||
padding: 0 0 24px;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
overflow: hidden;
|
||||
color: #ccc;
|
||||
width: 100%;
|
||||
display: -webkit-inline-flex;
|
||||
display: -ms-inline-flexbox;
|
||||
display: inline-flex;
|
||||
padding: 0 0 24px;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
overflow: hidden;
|
||||
color: #ccc;
|
||||
width: 100%;
|
||||
display: -webkit-inline-flex;
|
||||
display: -ms-inline-flexbox;
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.sp-setup-steps li {
|
||||
width: 20%;
|
||||
float: left;
|
||||
padding: 0 0 .8em;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
border-bottom: 4px solid #ccc;
|
||||
line-height: 1.4em;
|
||||
width: 20%;
|
||||
float: left;
|
||||
padding: 0 0 .8em;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
border-bottom: 4px solid #ccc;
|
||||
line-height: 1.4em;
|
||||
}
|
||||
|
||||
.sp-setup-steps li:before {
|
||||
content: "";
|
||||
border: 4px solid #ccc;
|
||||
border-radius: 100%;
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
margin-left: -6px;
|
||||
margin-bottom: -8px;
|
||||
background: #fff;
|
||||
content: "";
|
||||
border: 4px solid #ccc;
|
||||
border-radius: 100%;
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
margin-left: -6px;
|
||||
margin-bottom: -8px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.sp-setup-steps li.active {
|
||||
border-color: #00a69c;
|
||||
color: #00a69c;
|
||||
border-color: #00a69c;
|
||||
color: #00a69c;
|
||||
}
|
||||
|
||||
.sp-setup-steps li.active:before {
|
||||
border-color: #00a69c;
|
||||
border-color: #00a69c;
|
||||
}
|
||||
|
||||
.sp-setup-steps li.done {
|
||||
border-color: #00a69c;
|
||||
color: #00a69c;
|
||||
border-color: #00a69c;
|
||||
color: #00a69c;
|
||||
}
|
||||
|
||||
.sp-setup-steps li.done:before {
|
||||
border-color: #00a69c;
|
||||
background: #00a69c;
|
||||
border-color: #00a69c;
|
||||
background: #00a69c;
|
||||
}
|
||||
|
||||
.sp-setup .sp-setup-actions:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.sp-setup .sp-setup-actions .button {
|
||||
float: right;
|
||||
font-size: 1.25em;
|
||||
padding: .5em 1em;
|
||||
line-height: 1em;
|
||||
margin-right: .5em;
|
||||
margin-bottom: 2px;
|
||||
height: auto;
|
||||
border-radius: 4px;
|
||||
float: right;
|
||||
font-size: 1.25em;
|
||||
padding: .5em 1em;
|
||||
line-height: 1em;
|
||||
margin-right: .5em;
|
||||
margin-bottom: 2px;
|
||||
height: auto;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.sp-setup .sp-setup-actions .button-primary {
|
||||
background-color: #3bbab3;
|
||||
border-color: #15a29a;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
text-shadow: 0 -1px 1px #15a29a, 1px 0 1px #15a29a, 0 1px 1px #15a29a, -1px 0 1px #15a29a;
|
||||
float: right;
|
||||
margin: 0 0 0 1em;
|
||||
opacity: 1;
|
||||
background-color: #3bbab3;
|
||||
border-color: #15a29a;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
text-shadow: 0 -1px 1px #15a29a, 1px 0 1px #15a29a, 0 1px 1px #15a29a, -1px 0 1px #15a29a;
|
||||
float: right;
|
||||
margin: 0 0 0 1em;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.sp-setup .sp-setup-actions .button-primary:active,
|
||||
.sp-setup .sp-setup-actions .button-primary:focus,
|
||||
.sp-setup .sp-setup-actions .button-primary:hover {
|
||||
background: #15a29a;
|
||||
border-color: #15a29a;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
background: #15a29a;
|
||||
border-color: #15a29a;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 0 #15a29a;
|
||||
}
|
||||
|
||||
.sp-setup .sp-setup-actions .button-muted {
|
||||
border: none;
|
||||
background: transparent;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
padding: 0;
|
||||
margin: .55em 0.05em 0.65em;
|
||||
color: #ccc;
|
||||
border: none;
|
||||
background: transparent;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
padding: 0;
|
||||
margin: .55em 0.05em 0.65em;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.sp-setup .sp-setup-actions .button-muted:hover {
|
||||
color: #999;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.sp-return-to-dashboard {
|
||||
font-size: .85em;
|
||||
margin: 1.18em 0;
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: .85em;
|
||||
margin: 1.18em 0;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sp-return-to-dashboard a {
|
||||
color: #b5b5b5;
|
||||
color: #b5b5b5;
|
||||
}
|
||||
|
||||
.sp-return-to-dashboard a:hover {
|
||||
color: #888;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
/* Media Queries */
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
.sp-setup-content .form-table tbody th {
|
||||
width: auto
|
||||
};
|
||||
.sp-setup-content .form-table tbody th {
|
||||
width: auto
|
||||
};
|
||||
}
|
||||
|
||||
@media screen and (min-width: 783px) {
|
||||
.sp-setup-content .form-table td li input {
|
||||
width: 40%;
|
||||
}
|
||||
.sp-setup-content .form-table td li input {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td .player input {
|
||||
width: 40%;
|
||||
}
|
||||
.sp-setup-content .form-table td .player input {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td .player .player-number {
|
||||
width: 11%;
|
||||
}
|
||||
.sp-setup-content .form-table td .player .player-number {
|
||||
width: 11%;
|
||||
}
|
||||
|
||||
.sp-setup-content .form-table td .staff .staff-name {
|
||||
width: 52%;
|
||||
}
|
||||
}
|
||||
.sp-setup-content .form-table td .staff .staff-name {
|
||||
width: 52%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,4 +240,4 @@ table, .sp-sitemap caption, .sp-sitemap tbody, .sp-sitemap tfoot, .sp-sitemap th
|
||||
.sp-sitemap .sp-utility {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,28 +6,28 @@
|
||||
*/
|
||||
|
||||
.sp-tournament-bracket .sp-team .sp-team-name:before {
|
||||
border-left-color: #e5e5e5 !important;
|
||||
border-right-color: #e5e5e5 !important;
|
||||
left: -10px !important;
|
||||
border-left-color: #e5e5e5 !important;
|
||||
border-right-color: #e5e5e5 !important;
|
||||
left: -10px !important;
|
||||
}
|
||||
|
||||
.sp-tournament-bracket .sp-team-flip .sp-team-name:before {
|
||||
left: auto !important;
|
||||
right: -10px !important;
|
||||
left: auto !important;
|
||||
right: -10px !important;
|
||||
}
|
||||
|
||||
.sp-tournament-bracket .sp-team.sp-first-round .sp-team-name {
|
||||
margin-left: -1px !important;
|
||||
margin-left: -1px !important;
|
||||
}
|
||||
|
||||
.sp-tournament-bracket .sp-team.sp-last-round .sp-team-name {
|
||||
margin-right: -1px !important;
|
||||
margin-right: -1px !important;
|
||||
}
|
||||
|
||||
.sp-template-event-performance-icons .sp-performance-icons {
|
||||
text-align: right !important;
|
||||
text-align: right !important;
|
||||
}
|
||||
|
||||
.sp-data-table .data-name {
|
||||
text-align: left !important;
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
@@ -6,28 +6,28 @@
|
||||
*/
|
||||
|
||||
.sp-tournament-bracket .sp-team .sp-team-name:before {
|
||||
border-right-color: #e5e5e5 !important;
|
||||
border-left-color: #e5e5e5 !important;
|
||||
right: -10px !important;
|
||||
border-right-color: #e5e5e5 !important;
|
||||
border-left-color: #e5e5e5 !important;
|
||||
right: -10px !important;
|
||||
}
|
||||
|
||||
.sp-tournament-bracket .sp-team-flip .sp-team-name:before {
|
||||
right: auto !important;
|
||||
left: -10px !important;
|
||||
right: auto !important;
|
||||
left: -10px !important;
|
||||
}
|
||||
|
||||
.sp-tournament-bracket .sp-team.sp-first-round .sp-team-name {
|
||||
margin-right: -1px !important;
|
||||
margin-right: -1px !important;
|
||||
}
|
||||
|
||||
.sp-tournament-bracket .sp-team.sp-last-round .sp-team-name {
|
||||
margin-left: -1px !important;
|
||||
margin-left: -1px !important;
|
||||
}
|
||||
|
||||
.sp-template-event-performance-icons .sp-performance-icons {
|
||||
text-align: left !important;
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
.sp-data-table .data-name {
|
||||
text-align: right !important;
|
||||
text-align: right !important;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -61,10 +61,10 @@
|
||||
margin: 0 10px;
|
||||
color: inherit;
|
||||
opacity: 0.5;
|
||||
transition: all .3s;
|
||||
transition: all .3s;
|
||||
}
|
||||
.sp-tab-menu-item a:focus {
|
||||
outline: none;
|
||||
outline: none;
|
||||
}
|
||||
.sp-tab-menu-item-active a,
|
||||
.sp-tab-menu-item a:hover {
|
||||
@@ -90,7 +90,7 @@
|
||||
.sp-data-table {
|
||||
width: 100%;
|
||||
table-layout: auto;
|
||||
border-spacing: 0;
|
||||
border-spacing: 0;
|
||||
}
|
||||
.sp-paginated-table {
|
||||
margin-bottom: 0;
|
||||
@@ -310,12 +310,12 @@
|
||||
color: #f4d014;
|
||||
}
|
||||
.sp-event-performance .sp-event-star-number {
|
||||
margin-left: -20px;
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
font-size: smaller;
|
||||
line-height: 20px;
|
||||
margin-left: -20px;
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
font-size: smaller;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
/* Event Performance (Icons) */
|
||||
@@ -335,12 +335,12 @@
|
||||
}
|
||||
|
||||
.sp-template-event-performance-icons .sp-player-position {
|
||||
display: block;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Event Calendar */
|
||||
.sp-event-calendar {
|
||||
border-spacing: 0;
|
||||
border-spacing: 0;
|
||||
}
|
||||
.sp-event-calendar a {
|
||||
text-decoration: none;
|
||||
@@ -635,11 +635,11 @@ span.sp_event_spec_label {
|
||||
display: inline-block;
|
||||
margin: 0 0.25em;
|
||||
}
|
||||
|
||||
|
||||
.sp-template-logo + .sp-post-content {
|
||||
clear: left;
|
||||
}
|
||||
|
||||
|
||||
.sp-template-photo + .sp-post-content {
|
||||
clear: none;
|
||||
}
|
||||
@@ -664,15 +664,15 @@ span.sp_event_spec_label {
|
||||
text-align: right;
|
||||
float: right;
|
||||
}
|
||||
|
||||
|
||||
.sp-template-event-logos-block .logo-odd img {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
|
||||
.sp-template-event-logos-block .logo-even img {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
|
||||
.sp-template-event-logos-block .sp-team-name {
|
||||
display: inline;
|
||||
clear: none;
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
|
||||
.sportspress-page .entry-content h4:first-child {
|
||||
margin-top: 36px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
jQuery(document).ready(function($){
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
|
||||
// Color picker
|
||||
$('.colorpick').iris( {
|
||||
change: function(event, ui){
|
||||
$(this).css( { backgroundColor: ui.color.toString() } );
|
||||
},
|
||||
hide: true,
|
||||
border: true
|
||||
} ).each( function() {
|
||||
$(this).css( { backgroundColor: $(this).val() } );
|
||||
})
|
||||
.click(function(){
|
||||
$('.iris-picker').hide();
|
||||
$(this).closest('.sp-color-box, td').find('.iris-picker').show();
|
||||
});
|
||||
// Color picker
|
||||
$( '.colorpick' ).iris(
|
||||
{
|
||||
change: function(event, ui){
|
||||
$( this ).css( { backgroundColor: ui.color.toString() } );
|
||||
},
|
||||
hide: true,
|
||||
border: true
|
||||
}
|
||||
).each(
|
||||
function() {
|
||||
$( this ).css( { backgroundColor: $( this ).val() } );
|
||||
}
|
||||
)
|
||||
.click(
|
||||
function(){
|
||||
$( '.iris-picker' ).hide();
|
||||
$( this ).closest( '.sp-color-box, td' ).find( '.iris-picker' ).show();
|
||||
}
|
||||
);
|
||||
|
||||
$('body').click(function() {
|
||||
$('.iris-picker').hide();
|
||||
});
|
||||
$( 'body' ).click(
|
||||
function() {
|
||||
$( '.iris-picker' ).hide();
|
||||
}
|
||||
);
|
||||
|
||||
$('.sp-color-box, .colorpick').click(function(event){
|
||||
event.stopPropagation();
|
||||
});
|
||||
$( '.sp-color-box, .colorpick' ).click(
|
||||
function(event){
|
||||
event.stopPropagation();
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
jQuery(document).ready(function($){
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
|
||||
// Dashboard countdown
|
||||
$("#sportspress_dashboard_status .sp_status_list li.countdown").each(function() {
|
||||
var $this = $(this), finalDate = $(this).data('countdown');
|
||||
$this.countdown(finalDate, function(event) {
|
||||
$this.find('strong').html(event.strftime("%D "+localized_strings.days+" %H:%M:%S"));
|
||||
});
|
||||
});
|
||||
// Dashboard countdown
|
||||
$( "#sportspress_dashboard_status .sp_status_list li.countdown" ).each(
|
||||
function() {
|
||||
var $this = $( this ), finalDate = $( this ).data( 'countdown' );
|
||||
$this.countdown(
|
||||
finalDate,
|
||||
function(event) {
|
||||
$this.find( 'strong' ).html( event.strftime( "%D " + localized_strings.days + " %H:%M:%S" ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -3,51 +3,63 @@
|
||||
$shortcodes = '';
|
||||
|
||||
$options = array(
|
||||
'event' => array(
|
||||
'details', 'results', 'performance', 'venue', 'officials', 'teams', 'full',
|
||||
),
|
||||
'team' => array(),
|
||||
'player' => array(
|
||||
'details', 'statistics'
|
||||
),
|
||||
'event' => array(
|
||||
'details',
|
||||
'results',
|
||||
'performance',
|
||||
'venue',
|
||||
'officials',
|
||||
'teams',
|
||||
'full',
|
||||
),
|
||||
'team' => array(),
|
||||
'player' => array(
|
||||
'details',
|
||||
'statistics',
|
||||
),
|
||||
);
|
||||
|
||||
$options = apply_filters( 'sportspress_shortcodes', $options );
|
||||
|
||||
foreach ( $options as $name => $group ) {
|
||||
if ( empty( $group ) ) continue;
|
||||
$shortcodes .= $name . '[' . implode( '|', $group ) . ']';
|
||||
if ( empty( $group ) ) {
|
||||
continue;
|
||||
}
|
||||
$shortcodes .= $name . '[' . implode( '|', $group ) . ']';
|
||||
}
|
||||
|
||||
$raw = apply_filters( 'sportspress_tinymce_strings', array(
|
||||
'shortcodes' => $shortcodes,
|
||||
'insert' => __( 'SportsPress Shortcodes', 'sportspress' ),
|
||||
'auto' => __( 'Auto', 'sportspress' ),
|
||||
'manual' => __( 'Manual', 'sportspress' ),
|
||||
'select' => __( 'Select...', 'sportspress' ),
|
||||
'event' => __( 'Event', 'sportspress' ),
|
||||
'details' => __( 'Details', 'sportspress' ),
|
||||
'results' => __( 'Results', 'sportspress' ),
|
||||
'countdown' => __( 'Countdown', 'sportspress' ),
|
||||
'performance' => __( 'Box Score', 'sportspress' ),
|
||||
'venue' => __( 'Venue', 'sportspress' ),
|
||||
'officials' => __( 'Officials', 'sportspress' ),
|
||||
'teams' => __( 'Teams', 'sportspress' ),
|
||||
'full' => __( 'Full Info', 'sportspress' ),
|
||||
'calendar' => __( 'Calendar', 'sportspress' ),
|
||||
'statistics' => __( 'Statistics', 'sportspress' ),
|
||||
'team' => __( 'Team', 'sportspress' ),
|
||||
'standings' => __( 'League Table', 'sportspress' ),
|
||||
'player' => __( 'Player', 'sportspress' ),
|
||||
'list' => __( 'List', 'sportspress' ),
|
||||
'blocks' => __( 'Blocks', 'sportspress' ),
|
||||
'gallery' => __( 'Gallery', 'sportspress' ),
|
||||
));
|
||||
$raw = apply_filters(
|
||||
'sportspress_tinymce_strings',
|
||||
array(
|
||||
'shortcodes' => $shortcodes,
|
||||
'insert' => __( 'SportsPress Shortcodes', 'sportspress' ),
|
||||
'auto' => __( 'Auto', 'sportspress' ),
|
||||
'manual' => __( 'Manual', 'sportspress' ),
|
||||
'select' => __( 'Select...', 'sportspress' ),
|
||||
'event' => __( 'Event', 'sportspress' ),
|
||||
'details' => __( 'Details', 'sportspress' ),
|
||||
'results' => __( 'Results', 'sportspress' ),
|
||||
'countdown' => __( 'Countdown', 'sportspress' ),
|
||||
'performance' => __( 'Box Score', 'sportspress' ),
|
||||
'venue' => __( 'Venue', 'sportspress' ),
|
||||
'officials' => __( 'Officials', 'sportspress' ),
|
||||
'teams' => __( 'Teams', 'sportspress' ),
|
||||
'full' => __( 'Full Info', 'sportspress' ),
|
||||
'calendar' => __( 'Calendar', 'sportspress' ),
|
||||
'statistics' => __( 'Statistics', 'sportspress' ),
|
||||
'team' => __( 'Team', 'sportspress' ),
|
||||
'standings' => __( 'League Table', 'sportspress' ),
|
||||
'player' => __( 'Player', 'sportspress' ),
|
||||
'list' => __( 'List', 'sportspress' ),
|
||||
'blocks' => __( 'Blocks', 'sportspress' ),
|
||||
'gallery' => __( 'Gallery', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
|
||||
$formatted = array();
|
||||
|
||||
foreach ( $raw as $key => $value ) {
|
||||
$formatted[] = $key . ': "' . esc_js( $value ) . '"';
|
||||
$formatted[] = $key . ': "' . esc_js( $value ) . '"';
|
||||
}
|
||||
|
||||
$strings = 'tinyMCE.addI18n({' . _WP_Editors::$mce_locale . ':{
|
||||
|
||||
@@ -1,42 +1,58 @@
|
||||
/* global tinymce */
|
||||
( function () {
|
||||
tinymce.PluginManager.add( 'sp_shortcodes_button', function( editor, url ) {
|
||||
var ed = tinymce.activeEditor;
|
||||
tinymce.PluginManager.add(
|
||||
'sp_shortcodes_button',
|
||||
function( editor, url ) {
|
||||
var ed = tinymce.activeEditor;
|
||||
|
||||
var groups = ed.getLang( 'sportspress.shortcodes' ).split("]");
|
||||
var menu = new Array();
|
||||
var groups = ed.getLang( 'sportspress.shortcodes' ).split( "]" );
|
||||
var menu = new Array();
|
||||
|
||||
groups.forEach(function(g) {
|
||||
if ( "" == g ) return;
|
||||
var p = g.split("[");
|
||||
var label = p.shift();
|
||||
var variations = p.shift();
|
||||
var shortcodes = typeof variations!== 'undefined' ? variations.split("|") : [];
|
||||
var submenu = new Array();
|
||||
shortcodes.forEach(function(s) {
|
||||
submenu.push({
|
||||
text: ed.getLang( 'sportspress.' + s ),
|
||||
onclick: function() {
|
||||
// triggers the thickbox
|
||||
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
|
||||
W = W - 80;
|
||||
H = H - 84;
|
||||
tb_show( ed.getLang( 'sportspress.' + label ) + ' - ' + ed.getLang( 'sportspress.' + s ), 'admin-ajax.php?action=sportspress_' + label + '_' + s + '_shortcode&width=' + W + '&height=' + H );
|
||||
groups.forEach(
|
||||
function(g) {
|
||||
if ( "" == g ) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
menu.push({
|
||||
text: ed.getLang( 'sportspress.' + label ),
|
||||
menu: submenu
|
||||
});
|
||||
});
|
||||
var p = g.split( "[" );
|
||||
var label = p.shift();
|
||||
var variations = p.shift();
|
||||
var shortcodes = typeof variations !== 'undefined' ? variations.split( "|" ) : [];
|
||||
var submenu = new Array();
|
||||
shortcodes.forEach(
|
||||
function(s) {
|
||||
submenu.push(
|
||||
{
|
||||
text: ed.getLang( 'sportspress.' + s ),
|
||||
onclick: function() {
|
||||
// triggers the thickbox
|
||||
var width = jQuery( window ).width(), H = jQuery( window ).height(), W = ( 720 < width ) ? 720 : width;
|
||||
W = W - 80;
|
||||
H = H - 84;
|
||||
tb_show( ed.getLang( 'sportspress.' + label ) + ' - ' + ed.getLang( 'sportspress.' + s ), 'admin-ajax.php?action=sportspress_' + label + '_' + s + '_shortcode&width=' + W + '&height=' + H );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
menu.push(
|
||||
{
|
||||
text: ed.getLang( 'sportspress.' + label ),
|
||||
menu: submenu
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
editor.addButton( 'sp_shortcodes_button', {
|
||||
title: ed.getLang('sportspress.insert'),
|
||||
text: false,
|
||||
icon: false,
|
||||
type: 'menubutton',
|
||||
menu: menu
|
||||
});
|
||||
});
|
||||
editor.addButton(
|
||||
'sp_shortcodes_button',
|
||||
{
|
||||
title: ed.getLang( 'sportspress.insert' ),
|
||||
text: false,
|
||||
icon: false,
|
||||
type: 'menubutton',
|
||||
menu: menu
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
})();
|
||||
|
||||
@@ -1,37 +1,55 @@
|
||||
jQuery(document).ready(function($){
|
||||
$("#title").keyup(function() {
|
||||
val = $(this).val();
|
||||
if ( val == '' ) val = 'f(x)';
|
||||
$(".sp-equation-variable").text( val + ' =' );
|
||||
});
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
$( "#title" ).keyup(
|
||||
function() {
|
||||
val = $( this ).val();
|
||||
if ( val == '' ) {
|
||||
val = 'f(x)';
|
||||
}
|
||||
$( ".sp-equation-variable" ).text( val + ' =' );
|
||||
}
|
||||
);
|
||||
|
||||
$(".sp-equation-parts .button").draggable({
|
||||
appendTo: "body",
|
||||
helper: "clone",
|
||||
cursor: "move",
|
||||
distance: 10,
|
||||
containment: "#sp_equationdiv",
|
||||
}).click(function() {
|
||||
$("<label class='button'></label>").text( $(this).text() ).append("<span class='remove'>×</span><input name='sp_equation[]' type='hidden' value='" + $(this).data("variable") + "'>").appendTo( $(".sp-equation-formula") );
|
||||
});
|
||||
$( ".sp-equation-parts .button" ).draggable(
|
||||
{
|
||||
appendTo: "body",
|
||||
helper: "clone",
|
||||
cursor: "move",
|
||||
distance: 10,
|
||||
containment: "#sp_equationdiv",
|
||||
}
|
||||
).click(
|
||||
function() {
|
||||
$( "<label class='button'></label>" ).text( $( this ).text() ).append( "<span class='remove'>×</span><input name='sp_equation[]' type='hidden' value='" + $( this ).data( "variable" ) + "'>" ).appendTo( $( ".sp-equation-formula" ) );
|
||||
}
|
||||
);
|
||||
|
||||
$(".sp-equation").droppable({
|
||||
activeClass: "ui-state-active",
|
||||
hoverClass: "ui-state-hover",
|
||||
accept: ".button:not(.ui-sortable-helper)",
|
||||
drop: function( event, ui ) {
|
||||
$("<label class='button'></label>").text( ui.draggable.text() ).append("<span class='remove'>×</span><input name='sp_equation[]' type='hidden' value='" + ui.draggable.data("variable") + "'>").appendTo( $(".sp-equation-formula") );
|
||||
}
|
||||
}).sortable({
|
||||
items: ".button",
|
||||
tolerance: "pointer",
|
||||
containment: "#sp_equationdiv",
|
||||
sort: function() {
|
||||
$( this ).removeClass( "ui-state-active" );
|
||||
}
|
||||
});
|
||||
$( ".sp-equation" ).droppable(
|
||||
{
|
||||
activeClass: "ui-state-active",
|
||||
hoverClass: "ui-state-hover",
|
||||
accept: ".button:not(.ui-sortable-helper)",
|
||||
drop: function( event, ui ) {
|
||||
$( "<label class='button'></label>" ).text( ui.draggable.text() ).append( "<span class='remove'>×</span><input name='sp_equation[]' type='hidden' value='" + ui.draggable.data( "variable" ) + "'>" ).appendTo( $( ".sp-equation-formula" ) );
|
||||
}
|
||||
}
|
||||
).sortable(
|
||||
{
|
||||
items: ".button",
|
||||
tolerance: "pointer",
|
||||
containment: "#sp_equationdiv",
|
||||
sort: function() {
|
||||
$( this ).removeClass( "ui-state-active" );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$(".sp-equation-formula").on("click", ".button .remove", function() {
|
||||
$(this).closest(".button").remove();
|
||||
});
|
||||
});
|
||||
$( ".sp-equation-formula" ).on(
|
||||
"click",
|
||||
".button .remove",
|
||||
function() {
|
||||
$( this ).closest( ".button" ).remove();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,37 +1,52 @@
|
||||
jQuery(document).ready(function($){
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
|
||||
// Icon picker
|
||||
$('.sp-icons input').on('change', function() {
|
||||
if ('' == $(this).val()) {
|
||||
$('.sp-custom-colors').hide();
|
||||
$('.sp-custom-thumbnail').show();
|
||||
} else {
|
||||
$('.sp-custom-thumbnail').hide();
|
||||
$('.sp-custom-colors').show();
|
||||
}
|
||||
});
|
||||
// Icon picker
|
||||
$( '.sp-icons input' ).on(
|
||||
'change',
|
||||
function() {
|
||||
if ('' == $( this ).val()) {
|
||||
$( '.sp-custom-colors' ).hide();
|
||||
$( '.sp-custom-thumbnail' ).show();
|
||||
} else {
|
||||
$( '.sp-custom-thumbnail' ).hide();
|
||||
$( '.sp-custom-colors' ).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Color picker
|
||||
$('.colorpick').iris( {
|
||||
change: function(event, ui){
|
||||
$(this).css( { backgroundColor: ui.color.toString() } );
|
||||
},
|
||||
hide: true,
|
||||
border: true
|
||||
} ).each( function() {
|
||||
$(this).css( { backgroundColor: $(this).val() } );
|
||||
})
|
||||
.click(function(){
|
||||
$('.iris-picker').hide();
|
||||
$(this).closest('.sp-color-box-for-icon, td').find('.iris-picker').show();
|
||||
});
|
||||
// Color picker
|
||||
$( '.colorpick' ).iris(
|
||||
{
|
||||
change: function(event, ui){
|
||||
$( this ).css( { backgroundColor: ui.color.toString() } );
|
||||
},
|
||||
hide: true,
|
||||
border: true
|
||||
}
|
||||
).each(
|
||||
function() {
|
||||
$( this ).css( { backgroundColor: $( this ).val() } );
|
||||
}
|
||||
)
|
||||
.click(
|
||||
function(){
|
||||
$( '.iris-picker' ).hide();
|
||||
$( this ).closest( '.sp-color-box-for-icon, td' ).find( '.iris-picker' ).show();
|
||||
}
|
||||
);
|
||||
|
||||
$('body').click(function() {
|
||||
$('.iris-picker').hide();
|
||||
});
|
||||
$( 'body' ).click(
|
||||
function() {
|
||||
$( '.iris-picker' ).hide();
|
||||
}
|
||||
);
|
||||
|
||||
$('.sp-color-box-for-icon, .colorpick').click(function(event){
|
||||
event.stopPropagation();
|
||||
});
|
||||
$( '.sp-color-box-for-icon, .colorpick' ).click(
|
||||
function(event){
|
||||
event.stopPropagation();
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -24,56 +24,72 @@
|
||||
var $post_row = $( '#post-' + $post_id );
|
||||
|
||||
// get the data
|
||||
var $number = $( '.column-sp_number', $post_row ).text();
|
||||
var $current_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'current-teams' ) ).split(',');
|
||||
var $past_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'past-teams' ) ).split(',');
|
||||
var $number = $( '.column-sp_number', $post_row ).text();
|
||||
var $current_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'current-teams' ) ).split( ',' );
|
||||
var $past_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'past-teams' ) ).split( ',' );
|
||||
|
||||
// populate the data
|
||||
$( ':input[name="sp_number"]', $edit_row ).val( $number );
|
||||
$( ':input[name="sp_current_team[]"]', $edit_row ).each(function() {
|
||||
$(this).prop("checked", ($.inArray($(this).val(), $current_teams ) != -1));
|
||||
});
|
||||
$( ':input[name="sp_past_team[]"]', $edit_row ).each(function() {
|
||||
$(this).prop("checked", ($.inArray($(this).val(), $past_teams ) != -1));
|
||||
});
|
||||
$( ':input[name="sp_current_team[]"]', $edit_row ).each(
|
||||
function() {
|
||||
$( this ).prop( "checked", ($.inArray( $( this ).val(), $current_teams ) != -1) );
|
||||
}
|
||||
);
|
||||
$( ':input[name="sp_past_team[]"]', $edit_row ).each(
|
||||
function() {
|
||||
$( this ).prop( "checked", ($.inArray( $( this ).val(), $past_teams ) != -1) );
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
$( document ).on( 'click', '#bulk_edit', function() {
|
||||
// define the bulk edit row
|
||||
var $bulk_row = $( '#bulk-edit' );
|
||||
$( document ).on(
|
||||
'click',
|
||||
'#bulk_edit',
|
||||
function() {
|
||||
// define the bulk edit row
|
||||
var $bulk_row = $( '#bulk-edit' );
|
||||
|
||||
// get the selected post ids that are being edited
|
||||
var $post_ids = new Array();
|
||||
$bulk_row.find( '#bulk-titles' ).children().each( function() {
|
||||
$post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
|
||||
});
|
||||
// get the selected post ids that are being edited
|
||||
var $post_ids = new Array();
|
||||
$bulk_row.find( '#bulk-titles' ).children().each(
|
||||
function() {
|
||||
$post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
|
||||
}
|
||||
);
|
||||
|
||||
// get the data
|
||||
var $current_teams = [];
|
||||
$bulk_row.find( 'input[name="sp_current_team[]"]:checked' ).each(function() {
|
||||
$current_teams.push( $(this).val() );
|
||||
});
|
||||
// get the data
|
||||
var $current_teams = [];
|
||||
$bulk_row.find( 'input[name="sp_current_team[]"]:checked' ).each(
|
||||
function() {
|
||||
$current_teams.push( $( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
var $past_teams = [];
|
||||
$bulk_row.find( 'input[name="sp_past_team[]"]:checked' ).each(function() {
|
||||
$past_teams.push( $(this).val() );
|
||||
});
|
||||
var $past_teams = [];
|
||||
$bulk_row.find( 'input[name="sp_past_team[]"]:checked' ).each(
|
||||
function() {
|
||||
$past_teams.push( $( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
// save the data
|
||||
$.ajax({
|
||||
url: ajaxurl, // this is a variable that WordPress has already defined for us
|
||||
type: 'POST',
|
||||
async: false,
|
||||
cache: false,
|
||||
data: {
|
||||
action: 'save_bulk_edit_sp_player',
|
||||
post_ids: $post_ids,
|
||||
current_teams: $current_teams,
|
||||
past_teams: $past_teams,
|
||||
nonce: $("#sp_player_edit_nonce").val()
|
||||
}
|
||||
});
|
||||
});
|
||||
// save the data
|
||||
$.ajax(
|
||||
{
|
||||
url: ajaxurl, // this is a variable that WordPress has already defined for us
|
||||
type: 'POST',
|
||||
async: false,
|
||||
cache: false,
|
||||
data: {
|
||||
action: 'save_bulk_edit_sp_player',
|
||||
post_ids: $post_ids,
|
||||
current_teams: $current_teams,
|
||||
past_teams: $past_teams,
|
||||
nonce: $( "#sp_player_edit_nonce" ).val()
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
})(jQuery);
|
||||
})( jQuery );
|
||||
|
||||
@@ -1,64 +1,92 @@
|
||||
jQuery(document).ready(function($){
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
|
||||
// Display custom sport name field as needed
|
||||
$("body.toplevel_page_sportspress #sportspress_sport").change(function() {
|
||||
$target = $("#sportspress_custom_sport_name");
|
||||
if ( $(this).val() == "custom" )
|
||||
$target.show();
|
||||
else
|
||||
$target.hide();
|
||||
});
|
||||
// Display custom sport name field as needed
|
||||
$( "body.toplevel_page_sportspress #sportspress_sport" ).change(
|
||||
function() {
|
||||
$target = $( "#sportspress_custom_sport_name" );
|
||||
if ( $( this ).val() == "custom" ) {
|
||||
$target.show();
|
||||
} else {
|
||||
$target.hide();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Color picker
|
||||
$('.colorpick').iris( {
|
||||
change: function(event, ui){
|
||||
$(this).css( { backgroundColor: ui.color.toString() } );
|
||||
},
|
||||
hide: true,
|
||||
border: true
|
||||
} ).each( function() {
|
||||
$(this).css( { backgroundColor: $(this).val() } );
|
||||
})
|
||||
.click(function(){
|
||||
$('.iris-picker').hide();
|
||||
$(this).closest('.sp-color-box, td').find('.iris-picker').show();
|
||||
});
|
||||
// Color picker
|
||||
$( '.colorpick' ).iris(
|
||||
{
|
||||
change: function(event, ui){
|
||||
$( this ).css( { backgroundColor: ui.color.toString() } );
|
||||
},
|
||||
hide: true,
|
||||
border: true
|
||||
}
|
||||
).each(
|
||||
function() {
|
||||
$( this ).css( { backgroundColor: $( this ).val() } );
|
||||
}
|
||||
)
|
||||
.click(
|
||||
function(){
|
||||
$( '.iris-picker' ).hide();
|
||||
$( this ).closest( '.sp-color-box, td' ).find( '.iris-picker' ).show();
|
||||
}
|
||||
);
|
||||
|
||||
$('body').click(function() {
|
||||
$('.iris-picker').hide();
|
||||
});
|
||||
$( 'body' ).click(
|
||||
function() {
|
||||
$( '.iris-picker' ).hide();
|
||||
}
|
||||
);
|
||||
|
||||
$('.sp-color-box, .colorpick').click(function(event){
|
||||
event.stopPropagation();
|
||||
});
|
||||
$( '.sp-color-box, .colorpick' ).click(
|
||||
function(event){
|
||||
event.stopPropagation();
|
||||
}
|
||||
);
|
||||
|
||||
// Chosen select
|
||||
$(".chosen-select").chosen({
|
||||
allow_single_deselect: true,
|
||||
single_backstroke_delete: false,
|
||||
placeholder_text_multiple: localized_strings.none
|
||||
});
|
||||
// Chosen select
|
||||
$( ".chosen-select" ).chosen(
|
||||
{
|
||||
allow_single_deselect: true,
|
||||
single_backstroke_delete: false,
|
||||
placeholder_text_multiple: localized_strings.none
|
||||
}
|
||||
);
|
||||
|
||||
// Preset field modifier
|
||||
$(".sp-custom-input-wrapper .preset").click(function() {
|
||||
val = $(this).val();
|
||||
if(val == "\\c\\u\\s\\t\\o\\m") return true;
|
||||
example = $(this).attr("data-example");
|
||||
$(this).closest(".sp-custom-input-wrapper").find(".value").val(val).siblings(".example").html(example);
|
||||
});
|
||||
// Preset field modifier
|
||||
$( ".sp-custom-input-wrapper .preset" ).click(
|
||||
function() {
|
||||
val = $( this ).val();
|
||||
if (val == "\\c\\u\\s\\t\\o\\m") {
|
||||
return true;
|
||||
}
|
||||
example = $( this ).attr( "data-example" );
|
||||
$( this ).closest( ".sp-custom-input-wrapper" ).find( ".value" ).val( val ).siblings( ".example" ).html( example );
|
||||
}
|
||||
);
|
||||
|
||||
// Select custom preset when field is brought to focus
|
||||
$(".sp-custom-input-wrapper .value").focus(function() {
|
||||
$(this).siblings("label").find(".preset").prop("checked", true);
|
||||
});
|
||||
// Select custom preset when field is brought to focus
|
||||
$( ".sp-custom-input-wrapper .value" ).focus(
|
||||
function() {
|
||||
$( this ).siblings( "label" ).find( ".preset" ).prop( "checked", true );
|
||||
}
|
||||
);
|
||||
|
||||
// Adjust example field when custom preset is entered
|
||||
$(".sp-custom-input-wrapper .value").on("keyup", function() {
|
||||
val = $(this).val();
|
||||
if ( val === undefined ) return true;
|
||||
format = $(this).attr("data-example-format");
|
||||
example = format.replace(/__val__/g, val);
|
||||
$(this).siblings(".example").html(example);
|
||||
});
|
||||
// Adjust example field when custom preset is entered
|
||||
$( ".sp-custom-input-wrapper .value" ).on(
|
||||
"keyup",
|
||||
function() {
|
||||
val = $( this ).val();
|
||||
if ( val === undefined ) {
|
||||
return true;
|
||||
}
|
||||
format = $( this ).attr( "data-example-format" );
|
||||
example = format.replace( /__val__/g, val );
|
||||
$( this ).siblings( ".example" ).html( example );
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,54 +1,76 @@
|
||||
//Get variables form input values
|
||||
latitude = document.getElementById('term_meta[sp_latitude]').value;
|
||||
longitude = document.getElementById('term_meta[sp_longitude]').value;
|
||||
|
||||
//Initialize the map and add the Search control box
|
||||
var map = L.map('sp-location-picker').setView([latitude, longitude], 15),
|
||||
// Get variables form input values
|
||||
latitude = document.getElementById( 'term_meta[sp_latitude]' ).value;
|
||||
longitude = document.getElementById( 'term_meta[sp_longitude]' ).value;
|
||||
|
||||
// Initialize the map and add the Search control box
|
||||
var map = L.map( 'sp-location-picker' ).setView( [latitude, longitude], 15 ),
|
||||
geocoder = L.Control.Geocoder.nominatim(),
|
||||
control = L.Control.geocoder({
|
||||
geocoder: geocoder,
|
||||
collapsed: false,
|
||||
defaultMarkGeocode: false
|
||||
}).addTo(map),
|
||||
//Add a marker to use from the begining
|
||||
marker = L.marker([latitude, longitude],{draggable: true, autoPan: true}).addTo(map);
|
||||
|
||||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
//Pass the values to the fields after dragging
|
||||
marker.on('dragend', function (e) {
|
||||
document.getElementById('term_meta[sp_latitude]').value = marker.getLatLng().lat;
|
||||
document.getElementById('term_meta[sp_longitude]').value = marker.getLatLng().lng;
|
||||
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
|
||||
var r = results[0];
|
||||
if (r) {
|
||||
document.getElementById('term_meta[sp_address]').value = r.name;
|
||||
control = L.Control.geocoder(
|
||||
{
|
||||
geocoder: geocoder,
|
||||
collapsed: false,
|
||||
defaultMarkGeocode: false
|
||||
}
|
||||
})
|
||||
});
|
||||
).addTo( map ),
|
||||
// Add a marker to use from the begining
|
||||
marker = L.marker( [latitude, longitude],{draggable: true, autoPan: true} ).addTo( map );
|
||||
|
||||
//After searching
|
||||
control.on('markgeocode', function(e) {
|
||||
var center = e.geocode.center;
|
||||
var address = e.geocode.name;
|
||||
map.setView([center.lat, center.lng], 15); //Center map to the new place
|
||||
map.removeLayer(marker); //Remove previous marker
|
||||
marker = L.marker([center.lat, center.lng],{draggable: true, autoPan: true}).addTo(map); //Add new marker to use
|
||||
//Pass the values to the fields after searching
|
||||
document.getElementById('term_meta[sp_latitude]').value = center.lat;
|
||||
document.getElementById('term_meta[sp_longitude]').value = center.lng;
|
||||
document.getElementById('term_meta[sp_address]').value = address;
|
||||
//Pass the values to the fields after dragging
|
||||
marker.on('dragend', function (e) {
|
||||
document.getElementById('term_meta[sp_latitude]').value = marker.getLatLng().lat;
|
||||
document.getElementById('term_meta[sp_longitude]').value = marker.getLatLng().lng;
|
||||
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
|
||||
var r = results[0];
|
||||
if (r) {
|
||||
document.getElementById('term_meta[sp_address]').value = r.name;
|
||||
L.tileLayer(
|
||||
'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
|
||||
{
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}
|
||||
).addTo( map );
|
||||
|
||||
// Pass the values to the fields after dragging
|
||||
marker.on(
|
||||
'dragend',
|
||||
function (e) {
|
||||
document.getElementById( 'term_meta[sp_latitude]' ).value = marker.getLatLng().lat;
|
||||
document.getElementById( 'term_meta[sp_longitude]' ).value = marker.getLatLng().lng;
|
||||
geocoder.reverse(
|
||||
marker.getLatLng(),
|
||||
map.options.crs.scale( map.getZoom() ),
|
||||
function(results) {
|
||||
var r = results[0];
|
||||
if (r) {
|
||||
document.getElementById( 'term_meta[sp_address]' ).value = r.name;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}).addTo(map);
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
// After searching
|
||||
control.on(
|
||||
'markgeocode',
|
||||
function(e) {
|
||||
var center = e.geocode.center;
|
||||
var address = e.geocode.name;
|
||||
map.setView( [center.lat, center.lng], 15 ); // Center map to the new place
|
||||
map.removeLayer( marker ); // Remove previous marker
|
||||
marker = L.marker( [center.lat, center.lng],{draggable: true, autoPan: true} ).addTo( map ); // Add new marker to use
|
||||
// Pass the values to the fields after searching
|
||||
document.getElementById( 'term_meta[sp_latitude]' ).value = center.lat;
|
||||
document.getElementById( 'term_meta[sp_longitude]' ).value = center.lng;
|
||||
document.getElementById( 'term_meta[sp_address]' ).value = address;
|
||||
// Pass the values to the fields after dragging
|
||||
marker.on(
|
||||
'dragend',
|
||||
function (e) {
|
||||
document.getElementById( 'term_meta[sp_latitude]' ).value = marker.getLatLng().lat;
|
||||
document.getElementById( 'term_meta[sp_longitude]' ).value = marker.getLatLng().lng;
|
||||
geocoder.reverse(
|
||||
marker.getLatLng(),
|
||||
map.options.crs.scale( map.getZoom() ),
|
||||
function(results) {
|
||||
var r = results[0];
|
||||
if (r) {
|
||||
document.getElementById( 'term_meta[sp_address]' ).value = r.name;
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
).addTo( map );
|
||||
|
||||
@@ -1,54 +1,76 @@
|
||||
//Get variables form input values
|
||||
latitude = document.getElementById('sp_latitude').value;
|
||||
longitude = document.getElementById('sp_longitude').value;
|
||||
|
||||
//Initialize the map and add the Search control box
|
||||
var map = L.map('sp-location-picker').setView([latitude, longitude], 15),
|
||||
// Get variables form input values
|
||||
latitude = document.getElementById( 'sp_latitude' ).value;
|
||||
longitude = document.getElementById( 'sp_longitude' ).value;
|
||||
|
||||
// Initialize the map and add the Search control box
|
||||
var map = L.map( 'sp-location-picker' ).setView( [latitude, longitude], 15 ),
|
||||
geocoder = L.Control.Geocoder.nominatim(),
|
||||
control = L.Control.geocoder({
|
||||
geocoder: geocoder,
|
||||
collapsed: false,
|
||||
defaultMarkGeocode: false
|
||||
}).addTo(map),
|
||||
//Add a marker to use from the begining
|
||||
marker = L.marker([latitude, longitude],{draggable: true, autoPan: true}).addTo(map);
|
||||
|
||||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
//Pass the values to the fields after dragging
|
||||
marker.on('dragend', function (e) {
|
||||
document.getElementById('sp_latitude').value = marker.getLatLng().lat;
|
||||
document.getElementById('sp_longitude').value = marker.getLatLng().lng;
|
||||
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
|
||||
var r = results[0];
|
||||
if (r) {
|
||||
document.getElementById('sp_address').value = r.name;
|
||||
control = L.Control.geocoder(
|
||||
{
|
||||
geocoder: geocoder,
|
||||
collapsed: false,
|
||||
defaultMarkGeocode: false
|
||||
}
|
||||
})
|
||||
});
|
||||
).addTo( map ),
|
||||
// Add a marker to use from the begining
|
||||
marker = L.marker( [latitude, longitude],{draggable: true, autoPan: true} ).addTo( map );
|
||||
|
||||
//After searching
|
||||
control.on('markgeocode', function(e) {
|
||||
var center = e.geocode.center;
|
||||
var address = e.geocode.name;
|
||||
map.setView([center.lat, center.lng], 15); //Center map to the new place
|
||||
map.removeLayer(marker); //Remove previous marker
|
||||
marker = L.marker([center.lat, center.lng],{draggable: true, autoPan: true}).addTo(map); //Add new marker to use
|
||||
//Pass the values to the fields after searching
|
||||
document.getElementById('sp_latitude').value = center.lat;
|
||||
document.getElementById('sp_longitude').value = center.lng;
|
||||
document.getElementById('sp_address').value = address;
|
||||
//Pass the values to the fields after dragging
|
||||
marker.on('dragend', function (e) {
|
||||
document.getElementById('sp_latitude').value = marker.getLatLng().lat;
|
||||
document.getElementById('sp_longitude').value = marker.getLatLng().lng;
|
||||
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
|
||||
var r = results[0];
|
||||
if (r) {
|
||||
document.getElementById('sp_address').value = r.name;
|
||||
L.tileLayer(
|
||||
'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
|
||||
{
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}
|
||||
).addTo( map );
|
||||
|
||||
// Pass the values to the fields after dragging
|
||||
marker.on(
|
||||
'dragend',
|
||||
function (e) {
|
||||
document.getElementById( 'sp_latitude' ).value = marker.getLatLng().lat;
|
||||
document.getElementById( 'sp_longitude' ).value = marker.getLatLng().lng;
|
||||
geocoder.reverse(
|
||||
marker.getLatLng(),
|
||||
map.options.crs.scale( map.getZoom() ),
|
||||
function(results) {
|
||||
var r = results[0];
|
||||
if (r) {
|
||||
document.getElementById( 'sp_address' ).value = r.name;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}).addTo(map);
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
// After searching
|
||||
control.on(
|
||||
'markgeocode',
|
||||
function(e) {
|
||||
var center = e.geocode.center;
|
||||
var address = e.geocode.name;
|
||||
map.setView( [center.lat, center.lng], 15 ); // Center map to the new place
|
||||
map.removeLayer( marker ); // Remove previous marker
|
||||
marker = L.marker( [center.lat, center.lng],{draggable: true, autoPan: true} ).addTo( map ); // Add new marker to use
|
||||
// Pass the values to the fields after searching
|
||||
document.getElementById( 'sp_latitude' ).value = center.lat;
|
||||
document.getElementById( 'sp_longitude' ).value = center.lng;
|
||||
document.getElementById( 'sp_address' ).value = address;
|
||||
// Pass the values to the fields after dragging
|
||||
marker.on(
|
||||
'dragend',
|
||||
function (e) {
|
||||
document.getElementById( 'sp_latitude' ).value = marker.getLatLng().lat;
|
||||
document.getElementById( 'sp_longitude' ).value = marker.getLatLng().lng;
|
||||
geocoder.reverse(
|
||||
marker.getLatLng(),
|
||||
map.options.crs.scale( map.getZoom() ),
|
||||
function(results) {
|
||||
var r = results[0];
|
||||
if (r) {
|
||||
document.getElementById( 'sp_address' ).value = r.name;
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
).addTo( map );
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,32 @@
|
||||
jQuery(document).ready(function($){
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
|
||||
// Tiptip
|
||||
$(".sp-tip").tipTip({
|
||||
delay: 200,
|
||||
fadeIn: 100,
|
||||
fadeOut: 100
|
||||
});
|
||||
$(".sp-desc-tip").tipTip({
|
||||
delay: 200,
|
||||
fadeIn: 100,
|
||||
fadeOut: 100,
|
||||
defaultPosition: 'right'
|
||||
});
|
||||
// Tiptip
|
||||
$( ".sp-tip" ).tipTip(
|
||||
{
|
||||
delay: 200,
|
||||
fadeIn: 100,
|
||||
fadeOut: 100
|
||||
}
|
||||
);
|
||||
$( ".sp-desc-tip" ).tipTip(
|
||||
{
|
||||
delay: 200,
|
||||
fadeIn: 100,
|
||||
fadeOut: 100,
|
||||
defaultPosition: 'right'
|
||||
}
|
||||
);
|
||||
|
||||
// Chosen select
|
||||
$(".chosen-select, #poststuff #post_author_override").chosen({
|
||||
allow_single_deselect: true,
|
||||
search_contains: true,
|
||||
single_backstroke_delete: false,
|
||||
disable_search_threshold: 10,
|
||||
placeholder_text_multiple: localized_strings.none
|
||||
});
|
||||
});
|
||||
// Chosen select
|
||||
$( ".chosen-select, #poststuff #post_author_override" ).chosen(
|
||||
{
|
||||
allow_single_deselect: true,
|
||||
search_contains: true,
|
||||
single_backstroke_delete: false,
|
||||
disable_search_threshold: 10,
|
||||
placeholder_text_multiple: localized_strings.none
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,41 +1,60 @@
|
||||
jQuery(document).ready(function($){
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
|
||||
// Orderby affects order select in widget options
|
||||
$("body").on("change", ".sp-select-orderby", function() {
|
||||
$(this).closest(".widget-content").find(".sp-select-order").prop("disabled", $(this).val() == "default");
|
||||
});
|
||||
// Orderby affects order select in widget options
|
||||
$( "body" ).on(
|
||||
"change",
|
||||
".sp-select-orderby",
|
||||
function() {
|
||||
$( this ).closest( ".widget-content" ).find( ".sp-select-order" ).prop( "disabled", $( this ).val() == "default" );
|
||||
}
|
||||
);
|
||||
|
||||
// Calendar affects view all link checkbox in widget options
|
||||
$("body").on("change", ".sp-event-calendar-select", function() {
|
||||
$el = $(this).closest(".widget-content").find(".sp-event-calendar-show-all-toggle");
|
||||
if($(this).val() == 0)
|
||||
$el.hide();
|
||||
else
|
||||
$el.show();
|
||||
});
|
||||
// Calendar affects view all link checkbox in widget options
|
||||
$( "body" ).on(
|
||||
"change",
|
||||
".sp-event-calendar-select",
|
||||
function() {
|
||||
$el = $( this ).closest( ".widget-content" ).find( ".sp-event-calendar-show-all-toggle" );
|
||||
if ($( this ).val() == 0) {
|
||||
$el.hide();
|
||||
} else {
|
||||
$el.show();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Show or hide datepicker
|
||||
$("body").on("change", ".sp-date-selector select", function() {
|
||||
if ( $(this).val() == "range" ) {
|
||||
$(this).closest(".sp-date-selector").find(".sp-date-range").show();
|
||||
} else {
|
||||
$(this).closest(".sp-date-selector").find(".sp-date-range").hide();
|
||||
}
|
||||
});
|
||||
$(".sp-date-selector select").trigger("change");
|
||||
// Show or hide datepicker
|
||||
$( "body" ).on(
|
||||
"change",
|
||||
".sp-date-selector select",
|
||||
function() {
|
||||
if ( $( this ).val() == "range" ) {
|
||||
$( this ).closest( ".sp-date-selector" ).find( ".sp-date-range" ).show();
|
||||
} else {
|
||||
$( this ).closest( ".sp-date-selector" ).find( ".sp-date-range" ).hide();
|
||||
}
|
||||
}
|
||||
);
|
||||
$( ".sp-date-selector select" ).trigger( "change" );
|
||||
|
||||
// Toggle date range selectors
|
||||
$("body").on("change", ".sp-date-relative input", function() {
|
||||
$relative = $(this).closest(".sp-date-relative").siblings(".sp-date-range-relative").toggle(0, $(this).attr("checked"));
|
||||
$absolute = $(this).closest(".sp-date-relative").siblings(".sp-date-range-absolute").toggle(0, $(this).attr("checked"));
|
||||
// Toggle date range selectors
|
||||
$( "body" ).on(
|
||||
"change",
|
||||
".sp-date-relative input",
|
||||
function() {
|
||||
$relative = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-relative" ).toggle( 0, $( this ).attr( "checked" ) );
|
||||
$absolute = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-absolute" ).toggle( 0, $( this ).attr( "checked" ) );
|
||||
|
||||
if ($(this).attr("checked")) {
|
||||
$relative.show();
|
||||
$absolute.hide();
|
||||
} else {
|
||||
$absolute.show();
|
||||
$relative.hide();
|
||||
}
|
||||
});
|
||||
$(".sp-date-selector input").trigger("change");
|
||||
});
|
||||
if ($( this ).attr( "checked" )) {
|
||||
$relative.show();
|
||||
$absolute.hide();
|
||||
} else {
|
||||
$absolute.show();
|
||||
$relative.hide();
|
||||
}
|
||||
}
|
||||
);
|
||||
$( ".sp-date-selector input" ).trigger( "change" );
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,81 +1,88 @@
|
||||
import apiFetch from '@wordpress/api-fetch';
|
||||
console.log(wp.api.collections.Posts());
|
||||
console.log( wp.api.collections.Posts() );
|
||||
|
||||
wp.blocks.registerBlockType('sportspress/event-calendar', {
|
||||
title: strings.event_calendar,
|
||||
icon: 'calendar',
|
||||
category: 'sportspress',
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string'
|
||||
},
|
||||
id: {
|
||||
type: 'number'
|
||||
},
|
||||
status: {
|
||||
type: 'string'
|
||||
},
|
||||
date: {
|
||||
type: 'string'
|
||||
},
|
||||
date_from: {
|
||||
type: 'string'
|
||||
},
|
||||
date_to: {
|
||||
type: 'string'
|
||||
},
|
||||
date_past: {
|
||||
type: 'number'
|
||||
},
|
||||
date_future: {
|
||||
type: 'number'
|
||||
},
|
||||
date_relative: {
|
||||
type: 'number'
|
||||
},
|
||||
day: {
|
||||
type: 'string'
|
||||
},
|
||||
show_all_events_link: {
|
||||
type: 'number'
|
||||
},
|
||||
wp.blocks.registerBlockType(
|
||||
'sportspress/event-calendar',
|
||||
{
|
||||
title: strings.event_calendar,
|
||||
icon: 'calendar',
|
||||
category: 'sportspress',
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string'
|
||||
},
|
||||
id: {
|
||||
type: 'number'
|
||||
},
|
||||
status: {
|
||||
type: 'string'
|
||||
},
|
||||
date: {
|
||||
type: 'string'
|
||||
},
|
||||
date_from: {
|
||||
type: 'string'
|
||||
},
|
||||
date_to: {
|
||||
type: 'string'
|
||||
},
|
||||
date_past: {
|
||||
type: 'number'
|
||||
},
|
||||
date_future: {
|
||||
type: 'number'
|
||||
},
|
||||
date_relative: {
|
||||
type: 'number'
|
||||
},
|
||||
day: {
|
||||
type: 'string'
|
||||
},
|
||||
show_all_events_link: {
|
||||
type: 'number'
|
||||
},
|
||||
|
||||
content: {type: 'string'},
|
||||
color: {type: 'string'}
|
||||
},
|
||||
|
||||
edit: function(props) {
|
||||
function updateContent(event) {
|
||||
props.setAttributes({content: event.target.value})
|
||||
}
|
||||
function updateColor(value) {
|
||||
props.setAttributes({color: value.hex})
|
||||
}
|
||||
return React.createElement(
|
||||
wp.components.Panel,
|
||||
{header: strings.event_calendar},
|
||||
React.createElement(
|
||||
wp.components.PanelBody,
|
||||
{title: strings.properties},
|
||||
React.createElement(
|
||||
wp.components.TextControl,
|
||||
{label: strings.title, type: "text", value: props.attributes.title}
|
||||
),
|
||||
React.createElement(
|
||||
wp.components.SelectControl,
|
||||
{label: strings.select_calendar, options: [{label: strings.all, value: 0}].concat(posts.events.map(post => {
|
||||
return {label: post.post_title, value: post.ID}
|
||||
}))}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
content: {type: 'string'},
|
||||
color: {type: 'string'}
|
||||
},
|
||||
|
||||
save: function(props) {
|
||||
return wp.element.createElement(
|
||||
"h3",
|
||||
{ style: { border: "3px solid " + props.attributes.color } },
|
||||
props.attributes.content
|
||||
);
|
||||
}
|
||||
})
|
||||
edit: function(props) {
|
||||
function updateContent(event) {
|
||||
props.setAttributes( {content: event.target.value} )
|
||||
}
|
||||
function updateColor(value) {
|
||||
props.setAttributes( {color: value.hex} )
|
||||
}
|
||||
return React.createElement(
|
||||
wp.components.Panel,
|
||||
{header: strings.event_calendar},
|
||||
React.createElement(
|
||||
wp.components.PanelBody,
|
||||
{title: strings.properties},
|
||||
React.createElement(
|
||||
wp.components.TextControl,
|
||||
{label: strings.title, type: "text", value: props.attributes.title}
|
||||
),
|
||||
React.createElement(
|
||||
wp.components.SelectControl,
|
||||
{label: strings.select_calendar, options: [{label: strings.all, value: 0}].concat(
|
||||
posts.events.map(
|
||||
post => {
|
||||
return {label: post.post_title, value: post.ID}
|
||||
}
|
||||
)
|
||||
)}
|
||||
)
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
save: function(props) {
|
||||
return wp.element.createElement(
|
||||
"h3",
|
||||
{ style: { border: "3px solid " + props.attributes.color } },
|
||||
props.attributes.content
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -11,73 +11,77 @@
|
||||
|
||||
(function( $ ){
|
||||
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
$.fn.fitVids = function( options ) {
|
||||
var settings = {
|
||||
customSelector: null,
|
||||
ignore: null
|
||||
};
|
||||
$.fn.fitVids = function( options ) {
|
||||
var settings = {
|
||||
customSelector: null,
|
||||
ignore: null
|
||||
};
|
||||
|
||||
if(!document.getElementById('fit-vids-style')) {
|
||||
// appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
|
||||
var head = document.head || document.getElementsByTagName('head')[0];
|
||||
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%;}';
|
||||
var div = document.createElement("div");
|
||||
div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
|
||||
head.appendChild(div.childNodes[1]);
|
||||
}
|
||||
if ( ! document.getElementById( 'fit-vids-style' )) {
|
||||
// appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
|
||||
var head = document.head || document.getElementsByTagName( 'head' )[0];
|
||||
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%;}';
|
||||
var div = document.createElement( "div" );
|
||||
div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
|
||||
head.appendChild( div.childNodes[1] );
|
||||
}
|
||||
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
|
||||
return this.each(function(){
|
||||
var selectors = [
|
||||
'iframe[src*="player.vimeo.com"]',
|
||||
'iframe[src*="youtube.com"]',
|
||||
'iframe[src*="youtube-nocookie.com"]',
|
||||
'iframe[src*="kickstarter.com"][src*="video.html"]',
|
||||
'object',
|
||||
'embed'
|
||||
];
|
||||
return this.each(
|
||||
function(){
|
||||
var selectors = [
|
||||
'iframe[src*="player.vimeo.com"]',
|
||||
'iframe[src*="youtube.com"]',
|
||||
'iframe[src*="youtube-nocookie.com"]',
|
||||
'iframe[src*="kickstarter.com"][src*="video.html"]',
|
||||
'object',
|
||||
'embed'
|
||||
];
|
||||
|
||||
if (settings.customSelector) {
|
||||
selectors.push(settings.customSelector);
|
||||
}
|
||||
if (settings.customSelector) {
|
||||
selectors.push( settings.customSelector );
|
||||
}
|
||||
|
||||
var ignoreList = '.fitvidsignore';
|
||||
var ignoreList = '.fitvidsignore';
|
||||
|
||||
if(settings.ignore) {
|
||||
ignoreList = ignoreList + ', ' + settings.ignore;
|
||||
}
|
||||
if (settings.ignore) {
|
||||
ignoreList = ignoreList + ', ' + settings.ignore;
|
||||
}
|
||||
|
||||
var $allVideos = $(this).find(selectors.join(','));
|
||||
$allVideos = $allVideos.not('object object'); // SwfObj conflict patch
|
||||
$allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video.
|
||||
var $allVideos = $( this ).find( selectors.join( ',' ) );
|
||||
$allVideos = $allVideos.not( 'object object' ); // SwfObj conflict patch
|
||||
$allVideos = $allVideos.not( ignoreList ); // Disable FitVids on this video.
|
||||
|
||||
$allVideos.each(function(){
|
||||
var $this = $(this);
|
||||
if($this.parents(ignoreList).length > 0) {
|
||||
return; // Disable FitVids on this video.
|
||||
}
|
||||
if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
|
||||
if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
|
||||
{
|
||||
$this.attr('height', 9);
|
||||
$this.attr('width', 16);
|
||||
}
|
||||
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
|
||||
width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
|
||||
aspectRatio = height / width;
|
||||
if(!$this.attr('id')){
|
||||
var videoID = 'fitvid' + Math.floor(Math.random()*999999);
|
||||
$this.attr('id', videoID);
|
||||
}
|
||||
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
|
||||
$this.removeAttr('height').removeAttr('width');
|
||||
});
|
||||
});
|
||||
};
|
||||
// Works with either jQuery or Zepto
|
||||
$allVideos.each(
|
||||
function(){
|
||||
var $this = $( this );
|
||||
if ($this.parents( ignoreList ).length > 0) {
|
||||
return; // Disable FitVids on this video.
|
||||
}
|
||||
if (this.tagName.toLowerCase() === 'embed' && $this.parent( 'object' ).length || $this.parent( '.fluid-width-video-wrapper' ).length) {
|
||||
return; }
|
||||
if (( ! $this.css( 'height' ) && ! $this.css( 'width' )) && (isNaN( $this.attr( 'height' ) ) || isNaN( $this.attr( 'width' ) ))) {
|
||||
$this.attr( 'height', 9 );
|
||||
$this.attr( 'width', 16 );
|
||||
}
|
||||
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr( 'height' ) && ! isNaN( parseInt( $this.attr( 'height' ), 10 ) )) ) ? parseInt( $this.attr( 'height' ), 10 ) : $this.height(),
|
||||
width = ! isNaN( parseInt( $this.attr( 'width' ), 10 ) ) ? parseInt( $this.attr( 'width' ), 10 ) : $this.width(),
|
||||
aspectRatio = height / width;
|
||||
if ( ! $this.attr( 'id' )) {
|
||||
var videoID = 'fitvid' + Math.floor( Math.random() * 999999 );
|
||||
$this.attr( 'id', videoID );
|
||||
}
|
||||
$this.wrap( '<div class="fluid-width-video-wrapper"></div>' ).parent( '.fluid-width-video-wrapper' ).css( 'padding-top', (aspectRatio * 100) + '%' );
|
||||
$this.removeAttr( 'height' ).removeAttr( 'width' );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
// Works with either jQuery or Zepto
|
||||
})( window.jQuery || window.Zepto );
|
||||
|
||||
@@ -1,119 +1,138 @@
|
||||
function sp_viewport() {
|
||||
var e = window, a = 'inner';
|
||||
if (!('innerWidth' in window )) {
|
||||
a = 'client';
|
||||
e = document.documentElement || document.body;
|
||||
}
|
||||
return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
|
||||
var e = window, a = 'inner';
|
||||
if ( ! ('innerWidth' in window )) {
|
||||
a = 'client';
|
||||
e = document.documentElement || document.body;
|
||||
}
|
||||
return { width : e[ a + 'Width' ] , height : e[ a + 'Height' ] };
|
||||
}
|
||||
|
||||
(function($) {
|
||||
|
||||
/* Header */
|
||||
if ( ! $('.sp-header').length ) {
|
||||
$('body').prepend( '<div class="sp-header sp-header-loaded"></div>' );
|
||||
if ( ! $( '.sp-header' ).length ) {
|
||||
$( 'body' ).prepend( '<div class="sp-header sp-header-loaded"></div>' );
|
||||
}
|
||||
|
||||
/* Countdown */
|
||||
$("[data-countdown]").each(function() {
|
||||
var $this = $(this);
|
||||
// Get countdown time
|
||||
var countDownDate = new Date($(this).data('countdown')).getTime();
|
||||
// Iterate every second
|
||||
var x = setInterval(function() {
|
||||
|
||||
// Get todays date and time
|
||||
var now = new Date();
|
||||
|
||||
// Convert curent date and time to UTC
|
||||
var tzDifference = now.getTimezoneOffset();
|
||||
var nowutc = new Date(now.getTime() + tzDifference * 60 * 1000);
|
||||
|
||||
// Find the distance between now and the count down date
|
||||
var distance = countDownDate - nowutc;
|
||||
if ( distance < 0 ) {
|
||||
distance = 0;
|
||||
}
|
||||
|
||||
// Time calculations for days, hours, minutes and seconds
|
||||
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
||||
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
||||
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
||||
|
||||
// Output the result
|
||||
$this.html("<span>"+(days < 10 ? '0' + days : days)+" <small>" + localized_strings.days + "</small></span> "
|
||||
+ "<span>"+('0' + hours).slice(-2)+" <small>" + localized_strings.hrs + "</small></span> "
|
||||
+ "<span>"+('0' + minutes).slice(-2)+" <small>" + localized_strings.mins + "</small></span> "
|
||||
+ "<span>"+('0' + seconds).slice(-2)+" <small>" + localized_strings.secs + "</small></span>" );
|
||||
}, 1000);
|
||||
});
|
||||
$( "[data-countdown]" ).each(
|
||||
function() {
|
||||
var $this = $( this );
|
||||
// Get countdown time
|
||||
var countDownDate = new Date( $( this ).data( 'countdown' ) ).getTime();
|
||||
// Iterate every second
|
||||
var x = setInterval(
|
||||
function() {
|
||||
|
||||
// Get todays date and time
|
||||
var now = new Date();
|
||||
|
||||
// Convert curent date and time to UTC
|
||||
var tzDifference = now.getTimezoneOffset();
|
||||
var nowutc = new Date( now.getTime() + tzDifference * 60 * 1000 );
|
||||
|
||||
// Find the distance between now and the count down date
|
||||
var distance = countDownDate - nowutc;
|
||||
if ( distance < 0 ) {
|
||||
distance = 0;
|
||||
}
|
||||
|
||||
// Time calculations for days, hours, minutes and seconds
|
||||
var days = Math.floor( distance / (1000 * 60 * 60 * 24) );
|
||||
var hours = Math.floor( (distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) );
|
||||
var minutes = Math.floor( (distance % (1000 * 60 * 60)) / (1000 * 60) );
|
||||
var seconds = Math.floor( (distance % (1000 * 60)) / 1000 );
|
||||
|
||||
// Output the result
|
||||
$this.html(
|
||||
"<span>" + (days < 10 ? '0' + days : days) + " <small>" + localized_strings.days + "</small></span> "
|
||||
+ "<span>" + ('0' + hours).slice( -2 ) + " <small>" + localized_strings.hrs + "</small></span> "
|
||||
+ "<span>" + ('0' + minutes).slice( -2 ) + " <small>" + localized_strings.mins + "</small></span> "
|
||||
+ "<span>" + ('0' + seconds).slice( -2 ) + " <small>" + localized_strings.secs + "</small></span>"
|
||||
);
|
||||
},
|
||||
1000
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
/* Scrollable Tables */
|
||||
$(".sp-scrollable-table").wrap("<div class=\"sp-scrollable-table-wrapper\"></div>");
|
||||
|
||||
$( ".sp-scrollable-table" ).wrap( "<div class=\"sp-scrollable-table-wrapper\"></div>" );
|
||||
|
||||
/* Selector Redirect */
|
||||
$(".sp-selector-redirect").change(function() {
|
||||
window.location = $(this).val();
|
||||
});
|
||||
$( ".sp-selector-redirect" ).change(
|
||||
function() {
|
||||
window.location = $( this ).val();
|
||||
}
|
||||
);
|
||||
|
||||
/* Template Tabs */
|
||||
$(".sp-tab-menu-item a").click(function() {
|
||||
$template = $(this).data("sp-tab");
|
||||
$(this).closest(".sp-tab-menu-item").addClass("sp-tab-menu-item-active").siblings(".sp-tab-menu-item").removeClass("sp-tab-menu-item-active");
|
||||
$(this).closest(".sp-tab-group").find(".sp-tab-content-"+$template).show().siblings(".sp-tab-content").hide();
|
||||
return false;
|
||||
});
|
||||
$( ".sp-tab-menu-item a" ).click(
|
||||
function() {
|
||||
$template = $( this ).data( "sp-tab" );
|
||||
$( this ).closest( ".sp-tab-menu-item" ).addClass( "sp-tab-menu-item-active" ).siblings( ".sp-tab-menu-item" ).removeClass( "sp-tab-menu-item-active" );
|
||||
$( this ).closest( ".sp-tab-group" ).find( ".sp-tab-content-" + $template ).show().siblings( ".sp-tab-content" ).hide();
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
/* API method to get paging information */
|
||||
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
|
||||
{
|
||||
return {
|
||||
"iStart": oSettings._iDisplayStart,
|
||||
"iEnd": oSettings.fnDisplayEnd(),
|
||||
"iLength": oSettings._iDisplayLength,
|
||||
"iTotal": oSettings.fnRecordsTotal(),
|
||||
"iFilteredTotal": oSettings.fnRecordsDisplay(),
|
||||
"iPage": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
|
||||
"iTotalPages": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
|
||||
};
|
||||
return {
|
||||
"iStart": oSettings._iDisplayStart,
|
||||
"iEnd": oSettings.fnDisplayEnd(),
|
||||
"iLength": oSettings._iDisplayLength,
|
||||
"iTotal": oSettings.fnRecordsTotal(),
|
||||
"iFilteredTotal": oSettings.fnRecordsDisplay(),
|
||||
"iPage": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
|
||||
"iTotalPages": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
|
||||
};
|
||||
}
|
||||
|
||||
/* Data Tables */
|
||||
$(".sp-data-table").each(function() {
|
||||
sortable = $(this).hasClass("sp-sortable-table");
|
||||
paginated = $(this).hasClass("sp-paginated-table");
|
||||
display_length = parseInt($(this).attr("data-sp-rows"));
|
||||
if ( display_length == undefined || isNaN( display_length ) ) display_length = 10;
|
||||
if ( $(this).find("tbody tr").length <= display_length ) paginated = false;
|
||||
if ( sortable || paginated ) {
|
||||
$(this).dataTable({
|
||||
"order": [],
|
||||
"autoWidth": false,
|
||||
"searching": false,
|
||||
"info": false,
|
||||
"paging": paginated,
|
||||
"lengthChange": false,
|
||||
"pagingType": "simple_numbers",
|
||||
"pageLength": display_length,
|
||||
"ordering": sortable,
|
||||
"language": {
|
||||
"aria": {
|
||||
"sortAscending": "",
|
||||
"sortDescending": ""
|
||||
},
|
||||
"paginate": {
|
||||
"previous": localized_strings.previous,
|
||||
"next": localized_strings.next,
|
||||
}
|
||||
},
|
||||
"columnDefs": [
|
||||
{ "type": "num-fmt", "targets": [ ".data-number", ".data-rank" ] },
|
||||
]
|
||||
});
|
||||
$( ".sp-data-table" ).each(
|
||||
function() {
|
||||
sortable = $( this ).hasClass( "sp-sortable-table" );
|
||||
paginated = $( this ).hasClass( "sp-paginated-table" );
|
||||
display_length = parseInt( $( this ).attr( "data-sp-rows" ) );
|
||||
if ( display_length == undefined || isNaN( display_length ) ) {
|
||||
display_length = 10;
|
||||
}
|
||||
if ( $( this ).find( "tbody tr" ).length <= display_length ) {
|
||||
paginated = false;
|
||||
}
|
||||
if ( sortable || paginated ) {
|
||||
$( this ).dataTable(
|
||||
{
|
||||
"order": [],
|
||||
"autoWidth": false,
|
||||
"searching": false,
|
||||
"info": false,
|
||||
"paging": paginated,
|
||||
"lengthChange": false,
|
||||
"pagingType": "simple_numbers",
|
||||
"pageLength": display_length,
|
||||
"ordering": sortable,
|
||||
"language": {
|
||||
"aria": {
|
||||
"sortAscending": "",
|
||||
"sortDescending": ""
|
||||
},
|
||||
"paginate": {
|
||||
"previous": localized_strings.previous,
|
||||
"next": localized_strings.next,
|
||||
}
|
||||
},
|
||||
"columnDefs": [
|
||||
{ "type": "num-fmt", "targets": [ ".data-number", ".data-rank" ] },
|
||||
]
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
})(jQuery);
|
||||
})( jQuery );
|
||||
|
||||
106
feeds/ical.php
106
feeds/ical.php
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* iCal Feed
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Feeds
|
||||
* @package SportsPress/Feeds
|
||||
* @author ThemeBoy
|
||||
* @category Feeds
|
||||
* @package SportsPress/Feeds
|
||||
* @version 2.7.5
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( 'sp_calendar' !== get_post_type( $post ) ) {
|
||||
wp_die( __( 'ERROR: This is not a valid feed template.', 'sportspress' ), '', array( 'response' => 404 ) );
|
||||
@@ -16,7 +18,7 @@ if ( 'sp_calendar' !== get_post_type( $post ) ) {
|
||||
|
||||
// Get events in calendar
|
||||
$calendar = new SP_Calendar( $post );
|
||||
$events = $calendar->data();
|
||||
$events = $calendar->data();
|
||||
|
||||
// Get blog locale
|
||||
$locale = substr( get_locale(), 0, 2 );
|
||||
@@ -29,41 +31,43 @@ $timezone = sanitize_option( 'timezone_string', get_option( 'timezone_string' )
|
||||
|
||||
// Get the URL
|
||||
$url = add_query_arg( 'feed', 'sp-ical', get_post_permalink( $post ) );
|
||||
$url = wordwrap( $url , 60, "\r\n\t", true );
|
||||
$url = wordwrap( $url, 60, "\r\n\t", true );
|
||||
|
||||
$output =
|
||||
"BEGIN:VCALENDAR\r\n" .
|
||||
"VERSION:2.0\r\n" .
|
||||
"PRODID:-//ThemeBoy//SportsPress//" . strtoupper( $locale ) . "\r\n" .
|
||||
'PRODID:-//ThemeBoy//SportsPress//' . strtoupper( $locale ) . "\r\n" .
|
||||
"CALSCALE:GREGORIAN\r\n" .
|
||||
"METHOD:PUBLISH\r\n" .
|
||||
"URL:" . $url . "\r\n" .
|
||||
"X-FROM-URL:" . $url . "\r\n" .
|
||||
"NAME:" . $post->post_title . "\r\n" .
|
||||
"X-WR-CALNAME:" . $post->post_title . "\r\n" .
|
||||
"DESCRIPTION:" . $post->post_title . "\r\n" .
|
||||
"X-WR-CALDESC:" . $post->post_title . "\r\n" .
|
||||
'URL:' . $url . "\r\n" .
|
||||
'X-FROM-URL:' . $url . "\r\n" .
|
||||
'NAME:' . $post->post_title . "\r\n" .
|
||||
'X-WR-CALNAME:' . $post->post_title . "\r\n" .
|
||||
'DESCRIPTION:' . $post->post_title . "\r\n" .
|
||||
'X-WR-CALDESC:' . $post->post_title . "\r\n" .
|
||||
"REFRESH-INTERVAL;VALUE=DURATION:PT2M\r\n" .
|
||||
"X-PUBLISHED-TTL:PT2M\r\n" .
|
||||
"TZID:" . $timezone . "\r\n" .
|
||||
"X-WR-TIMEZONE:" . $timezone . "\r\n";
|
||||
'TZID:' . $timezone . "\r\n" .
|
||||
'X-WR-TIMEZONE:' . $timezone . "\r\n";
|
||||
|
||||
// Loop through each event
|
||||
foreach ( $events as $event):
|
||||
foreach ( $events as $event ) :
|
||||
|
||||
// Define date format
|
||||
$date_format = 'Ymd\THis';
|
||||
|
||||
// Get description
|
||||
$description = preg_replace( '/([\,;])/','\\\$1', $event->post_content );
|
||||
$description = wordwrap( $description , 60, "\n\t" );
|
||||
$description = preg_replace( '/([\,;])/', '\\\$1', $event->post_content );
|
||||
$description = wordwrap( $description, 60, "\n\t" );
|
||||
|
||||
// Initialize end time
|
||||
// Initialize end time
|
||||
$end = new DateTime( $event->post_date );
|
||||
|
||||
// Get full time minutes
|
||||
$minutes = get_post_meta( $event->ID, 'sp_minutes', true );
|
||||
if ( '' === $minutes ) $minutes = get_option( 'sportspress_event_minutes', 90 );
|
||||
if ( '' === $minutes ) {
|
||||
$minutes = get_option( 'sportspress_event_minutes', 90 );
|
||||
}
|
||||
|
||||
// Add full time minutes to end time
|
||||
$end->add( new DateInterval( 'PT' . $minutes . 'M' ) );
|
||||
@@ -74,7 +78,7 @@ foreach ( $events as $event):
|
||||
// Get venue information
|
||||
$venues = get_the_terms( $event->ID, 'sp_venue' );
|
||||
if ( $venues ) {
|
||||
$venue = reset( $venues );
|
||||
$venue = reset( $venues );
|
||||
$location .= $venue->name;
|
||||
|
||||
// Get venue term meta
|
||||
@@ -84,11 +88,11 @@ foreach ( $events as $event):
|
||||
// Add details to location
|
||||
$address = sp_array_value( $meta, 'sp_address', false );
|
||||
if ( false !== $address ) {
|
||||
$location = $venue->name . '\, ' . preg_replace('/([\,;])/','\\\$1', $address);
|
||||
$location = $venue->name . '\, ' . preg_replace( '/([\,;])/', '\\\$1', $address );
|
||||
}
|
||||
|
||||
// Generate geo tag
|
||||
$latitude = sp_array_value( $meta, 'sp_latitude', false );
|
||||
$latitude = sp_array_value( $meta, 'sp_latitude', false );
|
||||
$longitude = sp_array_value( $meta, 'sp_longitude', false );
|
||||
if ( false !== $latitude && false !== $longitude ) {
|
||||
$geo = $latitude . ';' . $longitude;
|
||||
@@ -96,17 +100,19 @@ foreach ( $events as $event):
|
||||
$geo = false;
|
||||
}
|
||||
}
|
||||
$location = wordwrap( $location , 60, "\r\n\t" );
|
||||
$location = wordwrap( $location, 60, "\r\n\t" );
|
||||
|
||||
// Get title or write summary based on scores
|
||||
$results = array();
|
||||
$teams = (array)get_post_meta( $event->ID, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
$teams = array_unique( $teams );
|
||||
$teams = (array) get_post_meta( $event->ID, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
$teams = array_unique( $teams );
|
||||
if ( ! empty( $teams ) ) {
|
||||
$event_results = get_post_meta( $event->ID, 'sp_results', true );
|
||||
foreach( $teams as $team_id ) {
|
||||
if ( ! $team_id ) continue;
|
||||
foreach ( $teams as $team_id ) {
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
|
||||
if ( $team ) {
|
||||
@@ -134,51 +140,57 @@ foreach ( $events as $event):
|
||||
} else {
|
||||
$summary = $event->post_title;
|
||||
}
|
||||
|
||||
//Convert &#[0-9]+ entities to UTF-8
|
||||
$summary = preg_replace_callback("/(&#[0-9]+;)/", function($m) { return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $summary);
|
||||
|
||||
|
||||
// Convert &#[0-9]+ entities to UTF-8
|
||||
$summary = preg_replace_callback(
|
||||
'/(&#[0-9]+;)/',
|
||||
function( $m ) {
|
||||
return mb_convert_encoding( $m[1], 'UTF-8', 'HTML-ENTITIES' );
|
||||
},
|
||||
$summary
|
||||
);
|
||||
|
||||
$summary = apply_filters( 'sportspress_ical_feed_summary', $summary, $event );
|
||||
|
||||
|
||||
// Append to output string
|
||||
$output .=
|
||||
"BEGIN:VEVENT\r\n" .
|
||||
"SUMMARY:" . preg_replace( '/([\,;])/','\\\$1', $summary ) . "\r\n" .
|
||||
'SUMMARY:' . preg_replace( '/([\,;])/', '\\\$1', $summary ) . "\r\n" .
|
||||
"UID:$event->ID\r\n" .
|
||||
"STATUS:CONFIRMED\r\n" .
|
||||
"DTSTAMP:19700101T000000\r\n".
|
||||
"DTSTART:" . mysql2date( $date_format, $event->post_date ) . "\r\n" .
|
||||
"DTEND:" . $end->format( $date_format ) . "\r\n" .
|
||||
"LAST-MODIFIED:" . mysql2date( $date_format, $event->post_modified_gmt ) . "\r\n";
|
||||
"DTSTAMP:19700101T000000\r\n" .
|
||||
'DTSTART:' . mysql2date( $date_format, $event->post_date ) . "\r\n" .
|
||||
'DTEND:' . $end->format( $date_format ) . "\r\n" .
|
||||
'LAST-MODIFIED:' . mysql2date( $date_format, $event->post_modified_gmt ) . "\r\n";
|
||||
|
||||
if ( $description ) {
|
||||
$output .= "DESCRIPTION:" . $description . "\r\n";
|
||||
$output .= 'DESCRIPTION:' . $description . "\r\n";
|
||||
}
|
||||
|
||||
if ( $location ) {
|
||||
$output .= "LOCATION:" . $location . "\r\n";
|
||||
$output .= 'LOCATION:' . $location . "\r\n";
|
||||
}
|
||||
|
||||
if ( $geo ) {
|
||||
$output .= "GEO:" . $geo . "\r\n";
|
||||
$output .= 'GEO:' . $geo . "\r\n";
|
||||
}
|
||||
|
||||
$output .= "END:VEVENT\r\n";
|
||||
endforeach;
|
||||
|
||||
// End output
|
||||
$output .= "END:VCALENDAR";
|
||||
$output .= 'END:VCALENDAR';
|
||||
|
||||
// Print headers
|
||||
header('Content-type: text/calendar; charset=utf-8');
|
||||
header( 'Content-type: text/calendar; charset=utf-8' );
|
||||
|
||||
// The E-Tag is not being changed when the output file is generated – Some Webdav clients do not like this and
|
||||
// do not then 'see' that the file has changed – updates to the calendars are then not displayed to the user.
|
||||
// Props @garygomm https://wordpress.org/support/topic/calendar-feed-issue-not-updating-after-change/
|
||||
$etag = md5($output);
|
||||
header('Etag:' . '"'.$etag.'"');
|
||||
$etag = md5( $output );
|
||||
header( 'Etag:' . '"' . $etag . '"' );
|
||||
|
||||
header('Content-Disposition: inline; filename=' . $post->post_name . '.ics');
|
||||
header( 'Content-Disposition: inline; filename=' . $post->post_name . '.ics' );
|
||||
|
||||
// Print content
|
||||
echo wp_kses_post( $output );
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*
|
||||
* The SportsPress custom post class handles individual post data.
|
||||
*
|
||||
* @class SP_Custom_Post
|
||||
* @version 2.6.5
|
||||
* @package SportsPress/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author ThemeBoy
|
||||
* @class SP_Custom_Post
|
||||
* @version 2.6.5
|
||||
* @package SportsPress/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
abstract class SP_Custom_Post {
|
||||
|
||||
@@ -25,11 +25,11 @@ abstract class SP_Custom_Post {
|
||||
* @param mixed $post
|
||||
*/
|
||||
public function __construct( $post ) {
|
||||
if ( $post instanceof WP_Post || $post instanceof SP_Custom_Post ):
|
||||
if ( $post instanceof WP_Post || $post instanceof SP_Custom_Post ) :
|
||||
$this->ID = absint( $post->ID );
|
||||
$this->post = $post;
|
||||
else:
|
||||
$this->ID = absint( $post );
|
||||
else :
|
||||
$this->ID = absint( $post );
|
||||
$this->post = get_post( $this->ID );
|
||||
endif;
|
||||
}
|
||||
@@ -53,9 +53,9 @@ abstract class SP_Custom_Post {
|
||||
* @return bool
|
||||
*/
|
||||
public function __get( $key ) {
|
||||
if ( ! isset( $key ) ):
|
||||
if ( ! isset( $key ) ) :
|
||||
return $this->post;
|
||||
else:
|
||||
else :
|
||||
$value = get_post_meta( $this->ID, 'sp_' . $key, true );
|
||||
endif;
|
||||
|
||||
@@ -77,7 +77,7 @@ abstract class SP_Custom_Post {
|
||||
*
|
||||
* @access public
|
||||
* @param string $taxonomy The taxonomy.
|
||||
* @return array|false|WP_Error See `get_the_terms()`
|
||||
* @return array|false|WP_Error See `get_the_terms()`
|
||||
*/
|
||||
public function get_terms_sorted_by_sp_order( $taxonomy ) {
|
||||
$terms = get_the_terms( $this->ID, $taxonomy );
|
||||
|
||||
@@ -4,70 +4,70 @@
|
||||
*
|
||||
* The SportsPress secondary post class extends custom posts with handling of secondary post types.
|
||||
*
|
||||
* @class SP_Secondary_Post
|
||||
* @class SP_Secondary_Post
|
||||
* @version 2.5.3
|
||||
* @package SportsPress/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author ThemeBoy
|
||||
* @package SportsPress/Abstracts
|
||||
* @category Abstract Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
abstract class SP_Secondary_Post extends SP_Custom_Post {
|
||||
|
||||
/** @var string The date filter for events. */
|
||||
public $date = 0;
|
||||
/** @var string The date filter for events. */
|
||||
public $date = 0;
|
||||
|
||||
/** @var string The date to range from. */
|
||||
public $from = 'now';
|
||||
/** @var string The date to range from. */
|
||||
public $from = 'now';
|
||||
|
||||
/** @var string The date to range to. */
|
||||
public $to = 'now';
|
||||
/** @var string The date to range to. */
|
||||
public $to = 'now';
|
||||
|
||||
/** @var string The number of days to query in the past. */
|
||||
public $past = 0;
|
||||
/** @var string The number of days to query in the past. */
|
||||
public $past = 0;
|
||||
|
||||
/** @var string The number of days to query in the future. */
|
||||
public $future = 0;
|
||||
/** @var string The number of days to query in the future. */
|
||||
public $future = 0;
|
||||
|
||||
/** @var boolean Determines whether the date range is relative. */
|
||||
public $relative = false;
|
||||
/** @var boolean Determines whether the date range is relative. */
|
||||
public $relative = false;
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $post
|
||||
*/
|
||||
public function __construct( $post ) {
|
||||
if ( $post instanceof WP_Post || $post instanceof SP_Secondary_Post ):
|
||||
$this->ID = absint( $post->ID );
|
||||
$this->post = $post;
|
||||
else:
|
||||
$this->ID = absint( $post );
|
||||
$this->post = get_post( $this->ID );
|
||||
endif;
|
||||
}
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $post
|
||||
*/
|
||||
public function __construct( $post ) {
|
||||
if ( $post instanceof WP_Post || $post instanceof SP_Secondary_Post ) :
|
||||
$this->ID = absint( $post->ID );
|
||||
$this->post = $post;
|
||||
else :
|
||||
$this->ID = absint( $post );
|
||||
$this->post = get_post( $this->ID );
|
||||
endif;
|
||||
}
|
||||
|
||||
public function range( $where = '', $format = 'Y-m-d' ) {
|
||||
$from = new DateTime( $this->from );
|
||||
$to = new DateTime( $this->to );
|
||||
public function range( $where = '', $format = 'Y-m-d' ) {
|
||||
$from = new DateTime( $this->from );
|
||||
$to = new DateTime( $this->to );
|
||||
|
||||
$to->modify( '+1 day' );
|
||||
$to->modify( '+1 day' );
|
||||
|
||||
$where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
|
||||
$where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
|
||||
|
||||
return $where;
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function relative( $where = '', $format = 'Y-m-d' ) {
|
||||
$from = new DateTime( 'now' );
|
||||
$to = new DateTime( 'now' );
|
||||
public function relative( $where = '', $format = 'Y-m-d' ) {
|
||||
$from = new DateTime( 'now' );
|
||||
$to = new DateTime( 'now' );
|
||||
|
||||
$from->modify( '-' . abs( (int) $this->past ) . ' day' );
|
||||
$to->modify( '+' . abs( (int) $this->future ) . ' day' );
|
||||
$from->modify( '-' . abs( (int) $this->past ) . ' day' );
|
||||
$to->modify( '+' . abs( (int) $this->future ) . ' day' );
|
||||
|
||||
$to->modify( '+1 day' );
|
||||
$to->modify( '+1 day' );
|
||||
|
||||
$where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
|
||||
$where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'";
|
||||
|
||||
return $where;
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
/**
|
||||
* SportsPress Admin.
|
||||
*
|
||||
* @class SP_Admin_AJAX
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @class SP_Admin_AJAX
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 1.7
|
||||
*/
|
||||
class SP_Admin_AJAX {
|
||||
@@ -59,10 +59,10 @@ class SP_Admin_AJAX {
|
||||
function save_inline_results() {
|
||||
check_ajax_referer( 'sp-save-inline-results', 'nonce' );
|
||||
|
||||
$id = sp_array_value( $_POST, 'post_id' );
|
||||
$id = sp_array_value( $_POST, 'post_id' );
|
||||
$results = sp_array_value( $_POST, 'results' );
|
||||
|
||||
if ( sp_update_main_results ( $id, $results ) ) {
|
||||
if ( sp_update_main_results( $id, $results ) ) {
|
||||
wp_send_json_success();
|
||||
} else {
|
||||
wp_send_json_error();
|
||||
|
||||
@@ -2,144 +2,149 @@
|
||||
/**
|
||||
* Load assets.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.6.15
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_Assets' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_Assets Class
|
||||
*/
|
||||
class SP_Admin_Assets {
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
* SP_Admin_Assets Class
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
}
|
||||
class SP_Admin_Assets {
|
||||
|
||||
/**
|
||||
* Enqueue styles
|
||||
*/
|
||||
public function admin_styles( $hook ) {
|
||||
// Sitewide menu CSS
|
||||
wp_enqueue_style( 'sportspress-admin-menu-styles', SP()->plugin_url() . '/assets/css/menu.css', array(), SP_VERSION );
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
||||
// Admin styles for SP pages only
|
||||
wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
|
||||
} elseif ( strpos( $screen->id, 'sportspress-config' ) !== false ) {
|
||||
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
}
|
||||
|
||||
if ( strpos( $screen->id, 'sportspress-overview' ) !== false ) {
|
||||
wp_enqueue_style( 'sportspress-admin-slickmap', SP()->plugin_url() . '/assets/css/slickmap.css', array(), '1.1.0' );
|
||||
/**
|
||||
* Enqueue styles
|
||||
*/
|
||||
public function admin_styles( $hook ) {
|
||||
// Sitewide menu CSS
|
||||
wp_enqueue_style( 'sportspress-admin-menu-styles', SP()->plugin_url() . '/assets/css/menu.css', array(), SP_VERSION );
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
|
||||
// Admin styles for SP pages only
|
||||
wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
|
||||
} elseif ( strpos( $screen->id, 'sportspress-config' ) !== false ) {
|
||||
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
|
||||
}
|
||||
|
||||
if ( strpos( $screen->id, 'sportspress-overview' ) !== false ) {
|
||||
wp_enqueue_style( 'sportspress-admin-slickmap', SP()->plugin_url() . '/assets/css/slickmap.css', array(), '1.1.0' );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, array( 'dashboard' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-admin-dashboard-styles', SP()->plugin_url() . '/assets/css/dashboard.css', array(), SP_VERSION );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, array( 'customize' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-admin-customize-styles', SP()->plugin_url() . '/assets/css/customize.css', array(), SP_VERSION );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, array( 'sp_result', 'sp_performance', 'sp_column', 'sp_statistic' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-admin-equation-styles', SP()->plugin_url() . '/assets/css/equation.css', array(), SP_VERSION );
|
||||
}
|
||||
|
||||
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' ) ) ) {
|
||||
wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css' );
|
||||
wp_enqueue_style( 'sportspress-admin-datepicker-styles', SP()->plugin_url() . '/assets/css/datepicker.css', array( 'jquery-ui-style' ), SP_VERSION );
|
||||
}
|
||||
|
||||
do_action( 'sportspress_admin_css', $screen );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, array( 'dashboard' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-admin-dashboard-styles', SP()->plugin_url() . '/assets/css/dashboard.css', array(), SP_VERSION );
|
||||
}
|
||||
/**
|
||||
* Enqueue scripts
|
||||
*/
|
||||
public function admin_scripts( $hook ) {
|
||||
global $wp_query, $post;
|
||||
|
||||
if ( in_array( $screen->id, array( 'customize' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-admin-customize-styles', SP()->plugin_url() . '/assets/css/customize.css', array(), SP_VERSION );
|
||||
}
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( in_array( $screen->id, array( 'sp_result', 'sp_performance', 'sp_column', 'sp_statistic' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-admin-equation-styles', SP()->plugin_url() . '/assets/css/equation.css', array(), SP_VERSION );
|
||||
}
|
||||
// Register scripts
|
||||
wp_register_script( 'chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
|
||||
|
||||
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') ) ) {
|
||||
wp_enqueue_style( 'jquery-ui-style' , '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css' );
|
||||
wp_enqueue_style( 'sportspress-admin-datepicker-styles', SP()->plugin_url() . '/assets/css/datepicker.css', array( 'jquery-ui-style' ), SP_VERSION );
|
||||
}
|
||||
wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
|
||||
|
||||
do_action( 'sportspress_admin_css', $screen );
|
||||
}
|
||||
wp_register_script( 'jquery-caret', SP()->plugin_url() . '/assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
|
||||
|
||||
/**
|
||||
* Enqueue scripts
|
||||
*/
|
||||
public function admin_scripts($hook) {
|
||||
global $wp_query, $post;
|
||||
wp_register_script( 'jquery-fitvids', SP()->plugin_url() . '/assets/js/jquery.fitvids.js', array( 'jquery' ), '1.1', true );
|
||||
|
||||
$screen = get_current_screen();
|
||||
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 );
|
||||
|
||||
// Register scripts
|
||||
wp_register_script( 'chosen', SP()->plugin_url() . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), '1.1.0', true );
|
||||
wp_register_script( 'sportspress-admin-colorpicker', SP()->plugin_url() . '/assets/js/admin/colorpicker.js', array( 'jquery', 'wp-color-picker', 'iris' ), SP_VERSION, true );
|
||||
|
||||
wp_register_script( 'jquery-tiptip', SP()->plugin_url() . '/assets/js/jquery.tipTip.min.js', array( 'jquery' ), '1.3', true );
|
||||
wp_register_script( 'sportspress-admin-widgets', SP()->plugin_url() . '/assets/js/admin/widgets.js', array( 'jquery' ), SP_VERSION, true );
|
||||
|
||||
wp_register_script( 'jquery-caret', SP()->plugin_url() . '/assets/js/jquery.caret.min.js', array( 'jquery' ), '1.02', true );
|
||||
wp_register_script( 'sportspress-admin-quickeditor', SP()->plugin_url() . '/assets/js/admin/quickeditor.js', array( 'jquery' ), SP_VERSION, true );
|
||||
|
||||
wp_register_script( 'jquery-fitvids', SP()->plugin_url() . '/assets/js/jquery.fitvids.js', array( 'jquery' ), '1.1', true );
|
||||
// SportsPress admin pages
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) || strpos( $screen->id, 'sportspress-config' ) || in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
|
||||
|
||||
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 );
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'chosen' );
|
||||
wp_enqueue_script( 'jquery-ui-core' );
|
||||
wp_enqueue_script( 'jquery-ui-draggable' );
|
||||
wp_enqueue_script( 'jquery-ui-droppable' );
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
wp_enqueue_script( 'jquery-tiptip' );
|
||||
wp_enqueue_script( 'jquery-caret' );
|
||||
wp_enqueue_script( 'jquery-fitvids' );
|
||||
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 );
|
||||
|
||||
wp_register_script( 'sportspress-admin-colorpicker', SP()->plugin_url() . '/assets/js/admin/colorpicker.js', array( 'jquery', 'wp-color-picker', 'iris' ), SP_VERSION, true );
|
||||
$strings = apply_filters(
|
||||
'sportspress_localized_strings',
|
||||
array(
|
||||
'none' => __( 'None', 'sportspress' ),
|
||||
'remove_text' => __( '— Remove —', 'sportspress' ),
|
||||
'days' => __( 'days', 'sportspress' ),
|
||||
'hrs' => __( 'hrs', 'sportspress' ),
|
||||
'mins' => __( 'mins', 'sportspress' ),
|
||||
'secs' => __( 'secs', 'sportspress' ),
|
||||
'displaying_posts' => html_entity_decode( __( 'Displaying %1$s–%2$s of %3$s', 'sportspress' ) ),
|
||||
)
|
||||
);
|
||||
|
||||
wp_register_script( 'sportspress-admin-widgets', SP()->plugin_url() . '/assets/js/admin/widgets.js', array( 'jquery' ), SP_VERSION, true );
|
||||
// Localize scripts
|
||||
wp_localize_script( 'sportspress-admin', 'localized_strings', $strings );
|
||||
}
|
||||
|
||||
wp_register_script( 'sportspress-admin-quickeditor', SP()->plugin_url() . '/assets/js/admin/quickeditor.js', array( 'jquery' ), SP_VERSION, true );
|
||||
if ( in_array( $screen->id, array( 'widgets' ) ) ) {
|
||||
wp_enqueue_script( 'sportspress-admin-widgets' );
|
||||
}
|
||||
|
||||
// SportsPress admin pages
|
||||
if ( in_array( $screen->id, sp_get_screen_ids() ) || strpos( $screen->id, 'sportspress-config' ) || in_array($hook, array('post.php', 'post-new.php') ) ) {
|
||||
// Edit color
|
||||
if ( in_array( $screen->id, array( 'sp_outcome' ) ) ) {
|
||||
wp_enqueue_script( 'sportspress-admin-colorpicker' );
|
||||
}
|
||||
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'chosen' );
|
||||
wp_enqueue_script( 'jquery-ui-core' );
|
||||
wp_enqueue_script( 'jquery-ui-draggable' );
|
||||
wp_enqueue_script( 'jquery-ui-droppable' );
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
wp_enqueue_script( 'jquery-tiptip' );
|
||||
wp_enqueue_script( 'jquery-caret' );
|
||||
wp_enqueue_script( 'jquery-fitvids' );
|
||||
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 );
|
||||
|
||||
$strings = apply_filters( 'sportspress_localized_strings', array(
|
||||
'none' => __( 'None', 'sportspress' ),
|
||||
'remove_text' => __( '— Remove —', 'sportspress' ),
|
||||
'days' => __( 'days', 'sportspress' ),
|
||||
'hrs' => __( 'hrs', 'sportspress' ),
|
||||
'mins' => __( 'mins', 'sportspress' ),
|
||||
'secs' => __( 'secs', 'sportspress' ),
|
||||
'displaying_posts' => html_entity_decode( __( 'Displaying %s–%s of %s', 'sportspress' ) ),
|
||||
) );
|
||||
// Edit equation
|
||||
if ( in_array( $screen->id, array( 'sp_result', 'sp_performance', 'sp_column', 'sp_statistic' ) ) ) {
|
||||
wp_enqueue_script( 'sportspress-admin-equationbuilder' );
|
||||
}
|
||||
|
||||
// Localize scripts
|
||||
wp_localize_script( 'sportspress-admin', 'localized_strings', $strings );
|
||||
}
|
||||
|
||||
if ( in_array( $screen->id, array( 'widgets' ) ) ) {
|
||||
wp_enqueue_script( 'sportspress-admin-widgets' );
|
||||
}
|
||||
|
||||
// Edit color
|
||||
if ( in_array( $screen->id, array( 'sp_outcome' ) ) ) {
|
||||
wp_enqueue_script( 'sportspress-admin-colorpicker' );
|
||||
}
|
||||
|
||||
// Edit equation
|
||||
if ( in_array( $screen->id, array( 'sp_result', 'sp_performance', 'sp_column', 'sp_statistic' ) ) ) {
|
||||
wp_enqueue_script( 'sportspress-admin-equationbuilder' );
|
||||
}
|
||||
|
||||
// Quick edit
|
||||
if ( in_array( $screen->id, array( 'edit-sp_player' ) ) ) {
|
||||
wp_enqueue_script( 'sportspress-admin-quickeditor' );
|
||||
// Quick edit
|
||||
if ( in_array( $screen->id, array( 'edit-sp_player' ) ) ) {
|
||||
wp_enqueue_script( 'sportspress-admin-quickeditor' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,126 +2,130 @@
|
||||
/**
|
||||
* Admin Dashboard
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_Dashboard' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_Dashboard Class
|
||||
*/
|
||||
class SP_Admin_Dashboard {
|
||||
/**
|
||||
* SP_Admin_Dashboard Class
|
||||
*/
|
||||
class SP_Admin_Dashboard {
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
// Only hook in admin parts if the user has admin access
|
||||
if ( current_user_can( 'view_sportspress_reports' ) || current_user_can( 'manage_sportspress' ) || current_user_can( 'publish_sp_events' ) ) {
|
||||
add_action( 'wp_dashboard_setup', array( $this, 'init' ) );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
// Only hook in admin parts if the user has admin access
|
||||
if ( current_user_can( 'view_sportspress_reports' ) || current_user_can( 'manage_sportspress' ) || current_user_can( 'publish_sp_events' ) ) {
|
||||
add_action( 'wp_dashboard_setup', array( $this, 'init' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Init dashboard widgets
|
||||
*/
|
||||
public function init() {
|
||||
//wp_add_dashboard_widget( 'sportspress_dashboard_news', __( 'Sports News', 'sportspress' ), array( $this, 'news_widget' ), null, null, 'side' );
|
||||
wp_add_dashboard_widget( 'sportspress_dashboard_status', __( 'SportsPress', 'sportspress' ), array( $this, 'status_widget' ) );
|
||||
add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 );
|
||||
}
|
||||
/**
|
||||
* Init dashboard widgets
|
||||
*/
|
||||
public function init() {
|
||||
// wp_add_dashboard_widget( 'sportspress_dashboard_news', __( 'Sports News', 'sportspress' ), array( $this, 'news_widget' ), null, null, 'side' );
|
||||
wp_add_dashboard_widget( 'sportspress_dashboard_status', __( 'SportsPress', 'sportspress' ), array( $this, 'status_widget' ) );
|
||||
add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add links to At a Glance
|
||||
*/
|
||||
function glance_items( $items = array() ) {
|
||||
$post_types = apply_filters( 'sportspress_glance_items', array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) );
|
||||
foreach ( $post_types as $type ):
|
||||
if ( ! post_type_exists( $type ) ) continue;
|
||||
$num_posts = wp_count_posts( $type );
|
||||
if ( $num_posts ):
|
||||
$published = intval( $num_posts->publish );
|
||||
$post_type = get_post_type_object( $type );
|
||||
$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'sportspress' );
|
||||
$text = sprintf( $text, number_format_i18n( $published ) );
|
||||
if ( current_user_can( $post_type->cap->edit_posts ) ):
|
||||
$output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $text . '</a>';
|
||||
else:
|
||||
$output = '<span>' . $text . '</span>';
|
||||
endif;
|
||||
echo '<li class="post-count ' . eac_attr( $post_type->name ) . '-count">' . esc_html( $output ) . '</li>';
|
||||
endif;
|
||||
endforeach;
|
||||
return $items;
|
||||
}
|
||||
/**
|
||||
* Add links to At a Glance
|
||||
*/
|
||||
function glance_items( $items = array() ) {
|
||||
$post_types = apply_filters( 'sportspress_glance_items', array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) );
|
||||
foreach ( $post_types as $type ) :
|
||||
if ( ! post_type_exists( $type ) ) {
|
||||
continue;
|
||||
}
|
||||
$num_posts = wp_count_posts( $type );
|
||||
if ( $num_posts ) :
|
||||
$published = intval( $num_posts->publish );
|
||||
$post_type = get_post_type_object( $type );
|
||||
$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'sportspress' );
|
||||
$text = sprintf( $text, number_format_i18n( $published ) );
|
||||
if ( current_user_can( $post_type->cap->edit_posts ) ) :
|
||||
$output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $text . '</a>';
|
||||
else :
|
||||
$output = '<span>' . $text . '</span>';
|
||||
endif;
|
||||
echo '<li class="post-count ' . eac_attr( $post_type->name ) . '-count">' . esc_html( $output ) . '</li>';
|
||||
endif;
|
||||
endforeach;
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show status widget
|
||||
*/
|
||||
public function status_widget() {
|
||||
?>
|
||||
<ul class="sp_status_list">
|
||||
<?php
|
||||
$count = wp_count_posts( 'sp_event' );
|
||||
$scheduled_count = isset( $count->future ) ? $count->future : 0;
|
||||
$published_count = isset( $count->publish ) ? $count->publish : 0;
|
||||
$next_event = sp_get_next_event();
|
||||
if ( $next_event ):
|
||||
$now = new DateTime( current_time( 'mysql', 0 ) );
|
||||
$date = new DateTime( $next_event->post_date );
|
||||
$interval = date_diff( $now, $date );
|
||||
?>
|
||||
<li class="countdown" data-countdown="<?php echo str_replace( '-', '/', get_gmt_from_date( $next_event->post_date ) ); ?>">
|
||||
<a href="<?php echo get_edit_post_link( $next_event->ID ); ?>">
|
||||
<?php printf( __( '<strong>%s</strong> until next event', 'sportspress' ), $interval->days . ' ' . __( 'days', 'sportspress' ) . ' ' . sprintf( '%02s:%02s:%02s', $interval->h, $interval->i, $interval->s ) ); ?>
|
||||
(<?php echo esc_html( $next_event->post_title ); ?>)
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<li class="events-scheduled">
|
||||
<a href="<?php echo admin_url( 'edit.php?post_type=sp_event&post_status=future' ); ?>">
|
||||
<?php printf( _n( '<strong>%s event</strong> scheduled', '<strong>%s events</strong> scheduled', $scheduled_count, 'sportspress' ), $scheduled_count ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="events-published">
|
||||
<a href="<?php echo admin_url( 'edit.php?post_type=sp_event&post_status=publish' ); ?>">
|
||||
<?php printf( _n( '<strong>%s event</strong> published', '<strong>%s events</strong> published', $published_count, 'sportspress' ), $published_count ); ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* Show status widget
|
||||
*/
|
||||
public function status_widget() {
|
||||
?>
|
||||
<ul class="sp_status_list">
|
||||
<?php
|
||||
$count = wp_count_posts( 'sp_event' );
|
||||
$scheduled_count = isset( $count->future ) ? $count->future : 0;
|
||||
$published_count = isset( $count->publish ) ? $count->publish : 0;
|
||||
$next_event = sp_get_next_event();
|
||||
if ( $next_event ) :
|
||||
$now = new DateTime( current_time( 'mysql', 0 ) );
|
||||
$date = new DateTime( $next_event->post_date );
|
||||
$interval = date_diff( $now, $date );
|
||||
?>
|
||||
<li class="countdown" data-countdown="<?php echo str_replace( '-', '/', get_gmt_from_date( $next_event->post_date ) ); ?>">
|
||||
<a href="<?php echo get_edit_post_link( $next_event->ID ); ?>">
|
||||
<?php printf( __( '<strong>%s</strong> until next event', 'sportspress' ), $interval->days . ' ' . __( 'days', 'sportspress' ) . ' ' . sprintf( '%02s:%02s:%02s', $interval->h, $interval->i, $interval->s ) ); ?>
|
||||
(<?php echo esc_html( $next_event->post_title ); ?>)
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<li class="events-scheduled">
|
||||
<a href="<?php echo admin_url( 'edit.php?post_type=sp_event&post_status=future' ); ?>">
|
||||
<?php printf( _n( '<strong>%s event</strong> scheduled', '<strong>%s events</strong> scheduled', $scheduled_count, 'sportspress' ), $scheduled_count ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="events-published">
|
||||
<a href="<?php echo admin_url( 'edit.php?post_type=sp_event&post_status=publish' ); ?>">
|
||||
<?php printf( _n( '<strong>%s event</strong> published', '<strong>%s events</strong> published', $published_count, 'sportspress' ), $published_count ); ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Show news widget
|
||||
*/
|
||||
public function news_widget() {
|
||||
$rss = fetch_feed("https://tboy.co/sportsnews/");
|
||||
if (!is_wp_error($rss)) { // Checks that the object is created correctly
|
||||
// Figure out how many total items there are, but limit it to 2.
|
||||
$maxitems = $rss->get_item_quantity(5);
|
||||
// Build an array of all the items, starting with element 0 (first element).
|
||||
$rss_items = $rss->get_items(0, $maxitems);
|
||||
}
|
||||
if (!empty($maxitems)) {
|
||||
?>
|
||||
<div class="rss-widget">
|
||||
<ul>
|
||||
<?php foreach ($rss_items as $item) { ?>
|
||||
<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>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Show news widget
|
||||
*/
|
||||
public function news_widget() {
|
||||
$rss = fetch_feed( 'https://tboy.co/sportsnews/' );
|
||||
if ( ! is_wp_error( $rss ) ) { // Checks that the object is created correctly
|
||||
// Figure out how many total items there are, but limit it to 2.
|
||||
$maxitems = $rss->get_item_quantity( 5 );
|
||||
// Build an array of all the items, starting with element 0 (first element).
|
||||
$rss_items = $rss->get_items( 0, $maxitems );
|
||||
}
|
||||
if ( ! empty( $maxitems ) ) {
|
||||
?>
|
||||
<div class="rss-widget">
|
||||
<ul>
|
||||
<?php foreach ( $rss_items as $item ) { ?>
|
||||
<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>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_Dashboard();
|
||||
return new SP_Admin_Dashboard();
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*
|
||||
* Methods which tweak the WP Editor.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.4
|
||||
*/
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
@@ -51,8 +51,8 @@ class SP_Admin_Editor {
|
||||
* @return array
|
||||
*/
|
||||
public function add_tinymce_lang( $arr ) {
|
||||
$arr['sp_shortcodes_button'] = SP()->plugin_path() . '/assets/js/admin/editor-lang.php';
|
||||
return $arr;
|
||||
$arr['sp_shortcodes_button'] = SP()->plugin_path() . '/assets/js/admin/editor-lang.php';
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,166 +2,172 @@
|
||||
/**
|
||||
* Setup importers for SP data.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.5.1
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.5.1
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_Importers' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_Importers Class
|
||||
*/
|
||||
class SP_Admin_Importers {
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
* SP_Admin_Importers Class
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_init', array( $this, 'register_importers' ) );
|
||||
}
|
||||
class SP_Admin_Importers {
|
||||
|
||||
/**
|
||||
* Add menu items
|
||||
*/
|
||||
public function register_importers() {
|
||||
global $pagenow;
|
||||
$importers = apply_filters( 'sportspress_importers', array(
|
||||
'sp_event_csv' => array(
|
||||
'name' => __( 'SportsPress Events (CSV)', 'sportspress' ),
|
||||
'description' => __( 'Import <strong>events</strong> from a csv file.', 'sportspress'),
|
||||
'callback' => array( $this, 'events_importer' ),
|
||||
),
|
||||
'sp_fixture_csv' => array(
|
||||
'name' => __( 'SportsPress Fixtures (CSV)', 'sportspress' ),
|
||||
'description' => __( 'Import <strong>upcoming events</strong> from a csv file.', 'sportspress'),
|
||||
'callback' => array( $this, 'fixtures_importer' ),
|
||||
),
|
||||
'sp_team_csv' => array(
|
||||
'name' => __( 'SportsPress Teams (CSV)', 'sportspress' ),
|
||||
'description' => __( 'Import <strong>teams</strong> from a csv file.', 'sportspress'),
|
||||
'callback' => array( $this, 'teams_importer' ),
|
||||
),
|
||||
'sp_player_csv' => array(
|
||||
'name' => __( 'SportsPress Players (CSV)', 'sportspress' ),
|
||||
'description' => __( 'Import <strong>players</strong> from a csv file.', 'sportspress'),
|
||||
'callback' => array( $this, 'players_importer' ),
|
||||
),
|
||||
'sp_staff_csv' => array(
|
||||
'name' => __( 'SportsPress Staff (CSV)', 'sportspress' ),
|
||||
'description' => __( 'Import <strong>staff</strong> from a csv file.', 'sportspress'),
|
||||
'callback' => array( $this, 'staff_importer' ),
|
||||
),
|
||||
) );
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_init', array( $this, 'register_importers' ) );
|
||||
}
|
||||
|
||||
if ( 'import.php' !== $pagenow ) {
|
||||
$importers['sp_event_performance_csv'] = array(
|
||||
'name' => __( 'SportsPress Box Score (CSV)', 'sportspress' ),
|
||||
'description' => '<a href="' . admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ) . '">' . sprintf( __( 'Select %s', 'sportspress' ), __( 'Event', 'sportspress' ) ) . '</a>',
|
||||
'callback' => array( $this, 'event_performance_importer' ),
|
||||
/**
|
||||
* Add menu items
|
||||
*/
|
||||
public function register_importers() {
|
||||
global $pagenow;
|
||||
$importers = apply_filters(
|
||||
'sportspress_importers',
|
||||
array(
|
||||
'sp_event_csv' => array(
|
||||
'name' => __( 'SportsPress Events (CSV)', 'sportspress' ),
|
||||
'description' => __( 'Import <strong>events</strong> from a csv file.', 'sportspress' ),
|
||||
'callback' => array( $this, 'events_importer' ),
|
||||
),
|
||||
'sp_fixture_csv' => array(
|
||||
'name' => __( 'SportsPress Fixtures (CSV)', 'sportspress' ),
|
||||
'description' => __( 'Import <strong>upcoming events</strong> from a csv file.', 'sportspress' ),
|
||||
'callback' => array( $this, 'fixtures_importer' ),
|
||||
),
|
||||
'sp_team_csv' => array(
|
||||
'name' => __( 'SportsPress Teams (CSV)', 'sportspress' ),
|
||||
'description' => __( 'Import <strong>teams</strong> from a csv file.', 'sportspress' ),
|
||||
'callback' => array( $this, 'teams_importer' ),
|
||||
),
|
||||
'sp_player_csv' => array(
|
||||
'name' => __( 'SportsPress Players (CSV)', 'sportspress' ),
|
||||
'description' => __( 'Import <strong>players</strong> from a csv file.', 'sportspress' ),
|
||||
'callback' => array( $this, 'players_importer' ),
|
||||
),
|
||||
'sp_staff_csv' => array(
|
||||
'name' => __( 'SportsPress Staff (CSV)', 'sportspress' ),
|
||||
'description' => __( 'Import <strong>staff</strong> from a csv file.', 'sportspress' ),
|
||||
'callback' => array( $this, 'staff_importer' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ( 'import.php' !== $pagenow ) {
|
||||
$importers['sp_event_performance_csv'] = array(
|
||||
'name' => __( 'SportsPress Box Score (CSV)', 'sportspress' ),
|
||||
'description' => '<a href="' . admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ) . '">' . sprintf( __( 'Select %s', 'sportspress' ), __( 'Event', 'sportspress' ) ) . '</a>',
|
||||
'callback' => array( $this, 'event_performance_importer' ),
|
||||
);
|
||||
}
|
||||
|
||||
foreach ( $importers as $id => $importer ) {
|
||||
register_importer( $id, $importer['name'], $importer['description'], $importer['callback'] );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $importers as $id => $importer ) {
|
||||
register_importer( $id, $importer['name'], $importer['description'], $importer['callback'] );
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function events_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-event-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Event_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function event_performance_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-event-performance-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Event_Performance_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function fixtures_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-fixture-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Fixture_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function teams_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-team-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Team_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function players_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-player-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Player_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function staff_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-staff-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Staff_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
public static function includes() {
|
||||
// Load Importer API
|
||||
require_once ABSPATH . 'wp-admin/includes/import.php';
|
||||
|
||||
if ( ! class_exists( 'WP_Importer' ) ) {
|
||||
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
|
||||
if ( file_exists( $class_wp_importer ) ) {
|
||||
require $class_wp_importer;
|
||||
}
|
||||
}
|
||||
|
||||
require 'importers/class-sp-importer.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function events_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-event-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Event_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function event_performance_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-event-performance-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Event_Performance_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function fixtures_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-fixture-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Fixture_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function teams_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-team-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Team_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function players_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-player-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Player_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function staff_importer() {
|
||||
$this->includes();
|
||||
|
||||
require 'importers/class-sp-staff-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new SP_Staff_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
||||
public static function includes() {
|
||||
// Load Importer API
|
||||
require_once ABSPATH . 'wp-admin/includes/import.php';
|
||||
|
||||
if ( ! class_exists( 'WP_Importer' ) ) {
|
||||
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
|
||||
if ( file_exists( $class_wp_importer ) )
|
||||
require $class_wp_importer;
|
||||
}
|
||||
|
||||
require 'importers/class-sp-importer.php';
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_Importers();
|
||||
return new SP_Admin_Importers();
|
||||
|
||||
@@ -2,283 +2,293 @@
|
||||
/**
|
||||
* Setup menus in WP admin.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_Menus' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_Menus Class
|
||||
*/
|
||||
class SP_Admin_Menus {
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
* SP_Admin_Menus Class
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter( 'admin_menu', array( $this, 'menu_clean' ), 5 );
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ), 6 );
|
||||
add_action( 'admin_menu', array( $this, 'config_menu' ), 7 );
|
||||
add_action( 'admin_menu', array( $this, 'leagues_menu' ), 20 );
|
||||
add_action( 'admin_menu', array( $this, 'seasons_menu' ), 21 );
|
||||
class SP_Admin_Menus {
|
||||
|
||||
add_action( 'admin_head', array( $this, 'menu_highlight' ) );
|
||||
add_action( 'admin_head', array( $this, 'menu_rename' ) );
|
||||
add_action( 'parent_file', array( $this, 'parent_file' ) );
|
||||
add_filter( 'menu_order', array( $this, 'menu_order' ) );
|
||||
add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
|
||||
add_filter( 'sportspress_sitemap_taxonomy_post_types', array( $this, 'sitemap_taxonomy_post_types' ), 10, 2 );
|
||||
}
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter( 'admin_menu', array( $this, 'menu_clean' ), 5 );
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ), 6 );
|
||||
add_action( 'admin_menu', array( $this, 'config_menu' ), 7 );
|
||||
add_action( 'admin_menu', array( $this, 'leagues_menu' ), 20 );
|
||||
add_action( 'admin_menu', array( $this, 'seasons_menu' ), 21 );
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function admin_menu() {
|
||||
global $menu;
|
||||
|
||||
if ( current_user_can( 'manage_sportspress' ) )
|
||||
$menu[] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
|
||||
|
||||
$main_page = add_menu_page( __( 'SportsPress', 'sportspress' ), __( 'SportsPress', 'sportspress' ), 'manage_sportspress', 'sportspress', array( $this, 'settings_page' ), apply_filters( 'sportspress_menu_icon', null ), '51.5' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function config_menu() {
|
||||
add_submenu_page( 'sportspress', __( 'Configure', 'sportspress' ), __( 'Configure', 'sportspress' ), 'manage_sportspress', 'sportspress-config', array( $this, 'config_page' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function leagues_menu() {
|
||||
add_submenu_page( 'sportspress', __( 'Leagues', 'sportspress' ), __( 'Leagues', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_league');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function seasons_menu() {
|
||||
add_submenu_page( 'sportspress', __( 'Seasons', 'sportspress' ), __( 'Seasons', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_season');
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlights the correct top level admin menu item for post type add screens.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function menu_highlight() {
|
||||
global $typenow;
|
||||
$screen = get_current_screen();
|
||||
if ( ! is_object( $screen ) ) return;
|
||||
if ( $screen->id == 'sp_role' ) {
|
||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit-tags.php?taxonomy=sp_role&post_type=sp_staff' );
|
||||
} elseif ( is_sp_config_type( $typenow ) ) {
|
||||
$this->highlight_admin_menu( 'sportspress', 'sportspress-config' );
|
||||
} elseif ( $typenow == 'sp_calendar' ) {
|
||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' );
|
||||
} elseif ( $typenow == 'sp_table' ) {
|
||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );
|
||||
} elseif ( $typenow == 'sp_list' ) {
|
||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' );
|
||||
add_action( 'admin_head', array( $this, 'menu_highlight' ) );
|
||||
add_action( 'admin_head', array( $this, 'menu_rename' ) );
|
||||
add_action( 'parent_file', array( $this, 'parent_file' ) );
|
||||
add_filter( 'menu_order', array( $this, 'menu_order' ) );
|
||||
add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
|
||||
add_filter( 'sportspress_sitemap_taxonomy_post_types', array( $this, 'sitemap_taxonomy_post_types' ), 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames admin menu items.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function menu_rename() {
|
||||
global $menu, $submenu;
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function admin_menu() {
|
||||
global $menu;
|
||||
|
||||
if ( isset( $submenu['sportspress'] ) && isset( $submenu['sportspress'][0] ) && isset( $submenu['sportspress'][0][0] ) )
|
||||
$submenu['sportspress'][0][0] = __( 'Settings', 'sportspress' );
|
||||
}
|
||||
if ( current_user_can( 'manage_sportspress' ) ) {
|
||||
$menu[] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
|
||||
}
|
||||
|
||||
public function parent_file( $parent_file ) {
|
||||
global $current_screen;
|
||||
$taxonomy = $current_screen->taxonomy;
|
||||
if ( in_array( $taxonomy, array( 'sp_league', 'sp_season' ) ) )
|
||||
$parent_file = 'sportspress';
|
||||
return $parent_file;
|
||||
}
|
||||
$main_page = add_menu_page( __( 'SportsPress', 'sportspress' ), __( 'SportsPress', 'sportspress' ), 'manage_sportspress', 'sportspress', array( $this, 'settings_page' ), apply_filters( 'sportspress_menu_icon', null ), '51.5' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorder the SP menu items in admin.
|
||||
*
|
||||
* @param mixed $menu_order
|
||||
* @return array
|
||||
*/
|
||||
public function menu_order( $menu_order ) {
|
||||
// Initialize our custom order array
|
||||
$sportspress_menu_order = array();
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function config_menu() {
|
||||
add_submenu_page( 'sportspress', __( 'Configure', 'sportspress' ), __( 'Configure', 'sportspress' ), 'manage_sportspress', 'sportspress-config', array( $this, 'config_page' ) );
|
||||
}
|
||||
|
||||
// Get the index of our custom separator
|
||||
$sportspress_separator = array_search( 'separator-sportspress', $menu_order );
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function leagues_menu() {
|
||||
add_submenu_page( 'sportspress', __( 'Leagues', 'sportspress' ), __( 'Leagues', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_league' );
|
||||
}
|
||||
|
||||
// Get index of menu items
|
||||
$sportspress_event = array_search( 'edit.php?post_type=sp_event', $menu_order );
|
||||
$sportspress_team = array_search( 'edit.php?post_type=sp_team', $menu_order );
|
||||
$sportspress_player = array_search( 'edit.php?post_type=sp_player', $menu_order );
|
||||
$sportspress_staff = array_search( 'edit.php?post_type=sp_staff', $menu_order );
|
||||
/**
|
||||
* Add menu item
|
||||
*/
|
||||
public function seasons_menu() {
|
||||
add_submenu_page( 'sportspress', __( 'Seasons', 'sportspress' ), __( 'Seasons', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_season' );
|
||||
}
|
||||
|
||||
// Loop through menu order and do some rearranging
|
||||
foreach ( $menu_order as $index => $item ):
|
||||
/**
|
||||
* Highlights the correct top level admin menu item for post type add screens.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function menu_highlight() {
|
||||
global $typenow;
|
||||
$screen = get_current_screen();
|
||||
if ( ! is_object( $screen ) ) {
|
||||
return;
|
||||
}
|
||||
if ( $screen->id == 'sp_role' ) {
|
||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit-tags.php?taxonomy=sp_role&post_type=sp_staff' );
|
||||
} elseif ( is_sp_config_type( $typenow ) ) {
|
||||
$this->highlight_admin_menu( 'sportspress', 'sportspress-config' );
|
||||
} elseif ( $typenow == 'sp_calendar' ) {
|
||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' );
|
||||
} elseif ( $typenow == 'sp_table' ) {
|
||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );
|
||||
} elseif ( $typenow == 'sp_list' ) {
|
||||
$this->highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( ( 'sportspress' ) == $item ) ):
|
||||
$sportspress_menu_order[] = 'separator-sportspress';
|
||||
$sportspress_menu_order[] = $item;
|
||||
$sportspress_menu_order[] = 'edit.php?post_type=sp_event';
|
||||
$sportspress_menu_order[] = 'edit.php?post_type=sp_team';
|
||||
$sportspress_menu_order[] = 'edit.php?post_type=sp_player';
|
||||
$sportspress_menu_order[] = 'edit.php?post_type=sp_staff';
|
||||
unset( $menu_order[ $sportspress_separator ] );
|
||||
unset( $menu_order[ $sportspress_event ] );
|
||||
unset( $menu_order[ $sportspress_team ] );
|
||||
unset( $menu_order[ $sportspress_player ] );
|
||||
unset( $menu_order[ $sportspress_staff ] );
|
||||
/**
|
||||
* Renames admin menu items.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function menu_rename() {
|
||||
global $menu, $submenu;
|
||||
|
||||
// Apply to added menu items
|
||||
$menu_items = apply_filters( 'sportspress_menu_items', array() );
|
||||
foreach ( $menu_items as $menu_item ):
|
||||
$sportspress_menu_order[] = $menu_item;
|
||||
$index = array_search( $menu_item, $menu_order );
|
||||
unset( $menu_order[ $index ] );
|
||||
endforeach;
|
||||
if ( isset( $submenu['sportspress'] ) && isset( $submenu['sportspress'][0] ) && isset( $submenu['sportspress'][0][0] ) ) {
|
||||
$submenu['sportspress'][0][0] = __( 'Settings', 'sportspress' );
|
||||
}
|
||||
}
|
||||
|
||||
elseif ( !in_array( $item, array( 'separator-sportspress' ) ) ) :
|
||||
$sportspress_menu_order[] = $item;
|
||||
public function parent_file( $parent_file ) {
|
||||
global $current_screen;
|
||||
$taxonomy = $current_screen->taxonomy;
|
||||
if ( in_array( $taxonomy, array( 'sp_league', 'sp_season' ) ) ) {
|
||||
$parent_file = 'sportspress';
|
||||
}
|
||||
return $parent_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorder the SP menu items in admin.
|
||||
*
|
||||
* @param mixed $menu_order
|
||||
* @return array
|
||||
*/
|
||||
public function menu_order( $menu_order ) {
|
||||
// Initialize our custom order array
|
||||
$sportspress_menu_order = array();
|
||||
|
||||
// Get the index of our custom separator
|
||||
$sportspress_separator = array_search( 'separator-sportspress', $menu_order );
|
||||
|
||||
// Get index of menu items
|
||||
$sportspress_event = array_search( 'edit.php?post_type=sp_event', $menu_order );
|
||||
$sportspress_team = array_search( 'edit.php?post_type=sp_team', $menu_order );
|
||||
$sportspress_player = array_search( 'edit.php?post_type=sp_player', $menu_order );
|
||||
$sportspress_staff = array_search( 'edit.php?post_type=sp_staff', $menu_order );
|
||||
|
||||
// Loop through menu order and do some rearranging
|
||||
foreach ( $menu_order as $index => $item ) :
|
||||
|
||||
if ( ( ( 'sportspress' ) == $item ) ) :
|
||||
$sportspress_menu_order[] = 'separator-sportspress';
|
||||
$sportspress_menu_order[] = $item;
|
||||
$sportspress_menu_order[] = 'edit.php?post_type=sp_event';
|
||||
$sportspress_menu_order[] = 'edit.php?post_type=sp_team';
|
||||
$sportspress_menu_order[] = 'edit.php?post_type=sp_player';
|
||||
$sportspress_menu_order[] = 'edit.php?post_type=sp_staff';
|
||||
unset( $menu_order[ $sportspress_separator ] );
|
||||
unset( $menu_order[ $sportspress_event ] );
|
||||
unset( $menu_order[ $sportspress_team ] );
|
||||
unset( $menu_order[ $sportspress_player ] );
|
||||
unset( $menu_order[ $sportspress_staff ] );
|
||||
|
||||
// Apply to added menu items
|
||||
$menu_items = apply_filters( 'sportspress_menu_items', array() );
|
||||
foreach ( $menu_items as $menu_item ) :
|
||||
$sportspress_menu_order[] = $menu_item;
|
||||
$index = array_search( $menu_item, $menu_order );
|
||||
unset( $menu_order[ $index ] );
|
||||
endforeach;
|
||||
|
||||
elseif ( ! in_array( $item, array( 'separator-sportspress' ) ) ) :
|
||||
$sportspress_menu_order[] = $item;
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
// Return order
|
||||
return $sportspress_menu_order;
|
||||
}
|
||||
|
||||
/**
|
||||
* custom_menu_order
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function custom_menu_order() {
|
||||
if ( ! current_user_can( 'manage_sportspress' ) ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean the SP menu items in admin.
|
||||
*/
|
||||
public function menu_clean() {
|
||||
global $menu, $submenu, $current_user;
|
||||
|
||||
// Find where our separator is in the menu
|
||||
foreach ( $menu as $key => $data ) :
|
||||
if ( is_array( $data ) && array_key_exists( 2, $data ) && $data[2] == 'edit.php?post_type=sp_separator' ) {
|
||||
$separator_position = $key;
|
||||
}
|
||||
endforeach;
|
||||
|
||||
// Swap our separator post type with a menu separator
|
||||
if ( isset( $separator_position ) ) :
|
||||
$menu[ $separator_position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
// Remove "Leagues" and "Seasons" links from Events submenu
|
||||
if ( isset( $submenu['edit.php?post_type=sp_event'] ) ) :
|
||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_leagues' ) );
|
||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_seasons' ) );
|
||||
endif;
|
||||
|
||||
// Return order
|
||||
return $sportspress_menu_order;
|
||||
// Remove "Venues", "Leagues" and "Seasons" links from Teams submenu
|
||||
if ( isset( $submenu['edit.php?post_type=sp_team'] ) ) :
|
||||
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_venues' ) );
|
||||
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_leagues' ) );
|
||||
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_seasons' ) );
|
||||
endif;
|
||||
|
||||
// Remove "Leagues" and "Seasons" links from Players submenu
|
||||
if ( isset( $submenu['edit.php?post_type=sp_player'] ) ) :
|
||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_leagues' ) );
|
||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_seasons' ) );
|
||||
endif;
|
||||
|
||||
// Remove "Leagues" and "Seasons" links from Staff submenu
|
||||
if ( isset( $submenu['edit.php?post_type=sp_staff'] ) ) :
|
||||
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_leagues' ) );
|
||||
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_seasons' ) );
|
||||
endif;
|
||||
|
||||
$user_roles = $current_user->roles;
|
||||
$user_role = array_shift( $user_roles );
|
||||
|
||||
if ( in_array( $user_role, array( 'sp_player', 'sp_staff', 'sp_event_manager', 'sp_team_manager' ) ) ) :
|
||||
remove_menu_page( 'upload.php' );
|
||||
remove_menu_page( 'edit-comments.php' );
|
||||
remove_menu_page( 'tools.php' );
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the config page
|
||||
*/
|
||||
public function config_page() {
|
||||
include 'views/html-admin-config.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the settings page
|
||||
*/
|
||||
public function settings_page() {
|
||||
include_once 'class-sp-admin-settings.php';
|
||||
SP_Admin_Settings::output();
|
||||
}
|
||||
|
||||
public function remove_add_new( $arr = array() ) {
|
||||
return $arr[0] != __( 'Add New', 'sportspress' );
|
||||
}
|
||||
|
||||
public function remove_leagues( $arr = array() ) {
|
||||
return $arr[0] != __( 'Leagues', 'sportspress' );
|
||||
}
|
||||
|
||||
public function remove_positions( $arr = array() ) {
|
||||
return $arr[0] != __( 'Positions', 'sportspress' );
|
||||
}
|
||||
|
||||
public function remove_seasons( $arr = array() ) {
|
||||
return $arr[0] != __( 'Seasons', 'sportspress' );
|
||||
}
|
||||
|
||||
public function remove_venues( $arr = array() ) {
|
||||
return $arr[0] != __( 'Venues', 'sportspress' );
|
||||
}
|
||||
|
||||
public static function highlight_admin_menu( $p = 'sportspress', $s = 'sportspress' ) {
|
||||
global $parent_file, $submenu_file;
|
||||
$parent_file = $p;
|
||||
$submenu_file = $s;
|
||||
}
|
||||
|
||||
public static function sitemap_taxonomy_post_types( $post_types = array(), $taxonomy = 'sp_venue' ) {
|
||||
$post_types = array_intersect( $post_types, sp_primary_post_types() );
|
||||
// Remove teams from venues taxonomy post type array
|
||||
if ( $taxonomy === 'sp_venue' && ( $key = array_search( 'sp_team', $post_types ) ) !== false ) :
|
||||
unset( $post_types[ $key ] );
|
||||
endif;
|
||||
|
||||
return $post_types;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* custom_menu_order
|
||||
* @return bool
|
||||
*/
|
||||
public function custom_menu_order() {
|
||||
if ( ! current_user_can( 'manage_sportspress' ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean the SP menu items in admin.
|
||||
*/
|
||||
public function menu_clean() {
|
||||
global $menu, $submenu, $current_user;
|
||||
|
||||
// Find where our separator is in the menu
|
||||
foreach( $menu as $key => $data ):
|
||||
if ( is_array( $data ) && array_key_exists( 2, $data ) && $data[2] == 'edit.php?post_type=sp_separator' )
|
||||
$separator_position = $key;
|
||||
endforeach;
|
||||
|
||||
// Swap our separator post type with a menu separator
|
||||
if ( isset( $separator_position ) ):
|
||||
$menu[ $separator_position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
|
||||
endif;
|
||||
|
||||
// Remove "Leagues" and "Seasons" links from Events submenu
|
||||
if ( isset( $submenu['edit.php?post_type=sp_event'] ) ):
|
||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_leagues' ) );
|
||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_seasons' ) );
|
||||
endif;
|
||||
|
||||
// Remove "Venues", "Leagues" and "Seasons" links from Teams submenu
|
||||
if ( isset( $submenu['edit.php?post_type=sp_team'] ) ):
|
||||
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_venues' ) );
|
||||
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_leagues' ) );
|
||||
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_seasons' ) );
|
||||
endif;
|
||||
|
||||
// Remove "Leagues" and "Seasons" links from Players submenu
|
||||
if ( isset( $submenu['edit.php?post_type=sp_player'] ) ):
|
||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_leagues' ) );
|
||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_seasons' ) );
|
||||
endif;
|
||||
|
||||
// Remove "Leagues" and "Seasons" links from Staff submenu
|
||||
if ( isset( $submenu['edit.php?post_type=sp_staff'] ) ):
|
||||
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_leagues' ) );
|
||||
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_seasons' ) );
|
||||
endif;
|
||||
|
||||
$user_roles = $current_user->roles;
|
||||
$user_role = array_shift($user_roles);
|
||||
|
||||
if ( in_array( $user_role, array( 'sp_player', 'sp_staff', 'sp_event_manager', 'sp_team_manager' ) ) ):
|
||||
remove_menu_page( 'upload.php' );
|
||||
remove_menu_page( 'edit-comments.php' );
|
||||
remove_menu_page( 'tools.php' );
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the config page
|
||||
*/
|
||||
public function config_page() {
|
||||
include( 'views/html-admin-config.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the settings page
|
||||
*/
|
||||
public function settings_page() {
|
||||
include_once( 'class-sp-admin-settings.php' );
|
||||
SP_Admin_Settings::output();
|
||||
}
|
||||
|
||||
public function remove_add_new( $arr = array() ) {
|
||||
return $arr[0] != __( 'Add New', 'sportspress' );
|
||||
}
|
||||
|
||||
public function remove_leagues( $arr = array() ) {
|
||||
return $arr[0] != __( 'Leagues', 'sportspress' );
|
||||
}
|
||||
|
||||
public function remove_positions( $arr = array() ) {
|
||||
return $arr[0] != __( 'Positions', 'sportspress' );
|
||||
}
|
||||
|
||||
public function remove_seasons( $arr = array() ) {
|
||||
return $arr[0] != __( 'Seasons', 'sportspress' );
|
||||
}
|
||||
|
||||
public function remove_venues( $arr = array() ) {
|
||||
return $arr[0] != __( 'Venues', 'sportspress' );
|
||||
}
|
||||
|
||||
public static function highlight_admin_menu( $p = 'sportspress', $s = 'sportspress' ) {
|
||||
global $parent_file, $submenu_file;
|
||||
$parent_file = $p;
|
||||
$submenu_file = $s;
|
||||
}
|
||||
|
||||
public static function sitemap_taxonomy_post_types( $post_types = array(), $taxonomy = 'sp_venue' ) {
|
||||
$post_types = array_intersect( $post_types, sp_primary_post_types() );
|
||||
// Remove teams from venues taxonomy post type array
|
||||
if ( $taxonomy === 'sp_venue' && ( $key = array_search( 'sp_team', $post_types ) ) !== false ):
|
||||
unset( $post_types[ $key ] );
|
||||
endif;
|
||||
|
||||
return $post_types;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_Menus();
|
||||
|
||||
@@ -2,145 +2,149 @@
|
||||
/**
|
||||
* Display notices in admin.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.3
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_Notices' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_Notices Class
|
||||
*/
|
||||
class SP_Admin_Notices {
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
* SP_Admin_Notices Class
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'switch_theme', array( $this, 'reset_admin_notices' ) );
|
||||
add_action( 'sportspress_updated', array( $this, 'reset_admin_notices' ) );
|
||||
add_action( 'admin_print_styles', array( $this, 'add_notices' ) );
|
||||
}
|
||||
class SP_Admin_Notices {
|
||||
|
||||
/**
|
||||
* Reset notices for themes when switched or a new version of SP is installed
|
||||
*/
|
||||
public function reset_admin_notices() {
|
||||
update_option( 'sportspress_admin_notices', array( 'template_files', 'theme_support' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add notices + styles if needed.
|
||||
*/
|
||||
public function add_notices() {
|
||||
$screen = get_current_screen();
|
||||
$notices = get_option( 'sportspress_admin_notices', array() );
|
||||
|
||||
if ( ! is_object( $screen ) ) return;
|
||||
|
||||
if ( ! get_option( 'sportspress_completed_setup' ) && ! in_array( $screen->id, array( 'dashboard_page_sp-about', 'dashboard_page_sp-credits', 'dashboard_page_sp-translators' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
|
||||
add_action( 'admin_notices', array( $this, 'setup_notice' ) );
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'switch_theme', array( $this, 'reset_admin_notices' ) );
|
||||
add_action( 'sportspress_updated', array( $this, 'reset_admin_notices' ) );
|
||||
add_action( 'admin_print_styles', array( $this, 'add_notices' ) );
|
||||
}
|
||||
|
||||
if ( 'post' == $screen->base ) {
|
||||
$post_id = get_the_ID();
|
||||
if ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) {
|
||||
add_action( 'admin_notices', array( $this, 'no_access_notice' ) );
|
||||
}
|
||||
/**
|
||||
* Reset notices for themes when switched or a new version of SP is installed
|
||||
*/
|
||||
public function reset_admin_notices() {
|
||||
update_option( 'sportspress_admin_notices', array( 'template_files', 'theme_support' ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['hide_theme_support_notice'] ) ) {
|
||||
$notices = array_diff( $notices, array( 'theme_support' ) );
|
||||
update_option( 'sportspress_admin_notices', $notices );
|
||||
}
|
||||
/**
|
||||
* Add notices + styles if needed.
|
||||
*/
|
||||
public function add_notices() {
|
||||
$screen = get_current_screen();
|
||||
$notices = get_option( 'sportspress_admin_notices', array() );
|
||||
|
||||
if ( ! empty( $_GET['hide_template_files_notice'] ) ) {
|
||||
$notices = array_diff( $notices, array( 'template_files' ) );
|
||||
update_option( 'sportspress_admin_notices', $notices );
|
||||
}
|
||||
|
||||
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' ) ) ) {
|
||||
$template = get_option( 'template' );
|
||||
|
||||
if ( ! in_array( $template, array( 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
|
||||
add_action( 'admin_notices', array( $this, 'theme_check_notice' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( 'template_files', $notices ) ) {
|
||||
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
|
||||
add_action( 'admin_notices', array( $this, 'template_file_check_notice' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the setup notices
|
||||
*/
|
||||
public function setup_notice() {
|
||||
include( 'views/html-notice-install.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a notice when the user doesn't have access to edit a post type
|
||||
*/
|
||||
public function no_access_notice() {
|
||||
include( 'views/html-notice-no-access.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Theme Check notice
|
||||
*/
|
||||
public function theme_check_notice() {
|
||||
include( 'views/html-notice-theme-support.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a notice highlighting bad template files
|
||||
*/
|
||||
public function template_file_check_notice() {
|
||||
if ( isset( $_GET['page'] ) && 'sportspress' == $_GET['page'] && isset( $_GET['tab'] ) && 'status' == $_GET['tab'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$status = include( 'class-sp-admin-status.php' );
|
||||
$core_templates = $status->scan_template_files( SP()->plugin_path() . '/templates' );
|
||||
$outdated = false;
|
||||
|
||||
foreach ( $core_templates as $file ) {
|
||||
$theme_file = false;
|
||||
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
|
||||
$theme_file = get_stylesheet_directory() . '/' . $file;
|
||||
} elseif ( file_exists( get_stylesheet_directory() . '/sportspress/' . $file ) ) {
|
||||
$theme_file = get_stylesheet_directory() . '/sportspress/' . $file;
|
||||
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
|
||||
$theme_file = get_template_directory() . '/' . $file;
|
||||
} elseif( file_exists( get_template_directory() . '/sportspress/' . $file ) ) {
|
||||
$theme_file = get_template_directory() . '/sportspress/' . $file;
|
||||
if ( ! is_object( $screen ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $theme_file ) {
|
||||
$core_version = $status->get_file_version( SP()->plugin_path() . '/templates/' . $file );
|
||||
$theme_version = $status->get_file_version( $theme_file );
|
||||
if ( ! get_option( 'sportspress_completed_setup' ) && ! in_array( $screen->id, array( 'dashboard_page_sp-about', 'dashboard_page_sp-credits', 'dashboard_page_sp-translators' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
|
||||
add_action( 'admin_notices', array( $this, 'setup_notice' ) );
|
||||
}
|
||||
|
||||
if ( $core_version && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) {
|
||||
$outdated = true;
|
||||
break;
|
||||
if ( 'post' == $screen->base ) {
|
||||
$post_id = get_the_ID();
|
||||
if ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) {
|
||||
add_action( 'admin_notices', array( $this, 'no_access_notice' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['hide_theme_support_notice'] ) ) {
|
||||
$notices = array_diff( $notices, array( 'theme_support' ) );
|
||||
update_option( 'sportspress_admin_notices', $notices );
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['hide_template_files_notice'] ) ) {
|
||||
$notices = array_diff( $notices, array( 'template_files' ) );
|
||||
update_option( 'sportspress_admin_notices', $notices );
|
||||
}
|
||||
|
||||
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' ) ) ) {
|
||||
$template = get_option( 'template' );
|
||||
|
||||
if ( ! in_array( $template, array( 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) {
|
||||
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
|
||||
add_action( 'admin_notices', array( $this, 'theme_check_notice' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( 'template_files', $notices ) ) {
|
||||
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
|
||||
add_action( 'admin_notices', array( $this, 'template_file_check_notice' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $outdated ) {
|
||||
include( 'views/html-notice-template-check.php' );
|
||||
/**
|
||||
* Show the setup notices
|
||||
*/
|
||||
public function setup_notice() {
|
||||
include 'views/html-notice-install.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a notice when the user doesn't have access to edit a post type
|
||||
*/
|
||||
public function no_access_notice() {
|
||||
include 'views/html-notice-no-access.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Theme Check notice
|
||||
*/
|
||||
public function theme_check_notice() {
|
||||
include 'views/html-notice-theme-support.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a notice highlighting bad template files
|
||||
*/
|
||||
public function template_file_check_notice() {
|
||||
if ( isset( $_GET['page'] ) && 'sportspress' == $_GET['page'] && isset( $_GET['tab'] ) && 'status' == $_GET['tab'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$status = include 'class-sp-admin-status.php';
|
||||
$core_templates = $status->scan_template_files( SP()->plugin_path() . '/templates' );
|
||||
$outdated = false;
|
||||
|
||||
foreach ( $core_templates as $file ) {
|
||||
$theme_file = false;
|
||||
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
|
||||
$theme_file = get_stylesheet_directory() . '/' . $file;
|
||||
} elseif ( file_exists( get_stylesheet_directory() . '/sportspress/' . $file ) ) {
|
||||
$theme_file = get_stylesheet_directory() . '/sportspress/' . $file;
|
||||
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
|
||||
$theme_file = get_template_directory() . '/' . $file;
|
||||
} elseif ( file_exists( get_template_directory() . '/sportspress/' . $file ) ) {
|
||||
$theme_file = get_template_directory() . '/sportspress/' . $file;
|
||||
}
|
||||
|
||||
if ( $theme_file ) {
|
||||
$core_version = $status->get_file_version( SP()->plugin_path() . '/templates/' . $file );
|
||||
$theme_version = $status->get_file_version( $theme_file );
|
||||
|
||||
if ( $core_version && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) {
|
||||
$outdated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $outdated ) {
|
||||
include 'views/html-notice-template-check.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_Notices();
|
||||
return new SP_Admin_Notices();
|
||||
|
||||
@@ -2,102 +2,111 @@
|
||||
/**
|
||||
* Adds settings to the permalinks admin settings page.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_Permalink_Settings' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_Permalink_Settings Class
|
||||
*/
|
||||
class SP_Admin_Permalink_Settings {
|
||||
|
||||
/**
|
||||
* Hook in tabs.
|
||||
* SP_Admin_Permalink_Settings Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->slugs = apply_filters( 'sportspress_permalink_slugs', array(
|
||||
array( 'event', __( 'Events', 'sportspress' ) ),
|
||||
array( 'venue', __( 'Venues', 'sportspress' ) ),
|
||||
array( 'calendar', __( 'Calendars', 'sportspress' ) ),
|
||||
array( 'team', __( 'Teams', 'sportspress' ) ),
|
||||
array( 'league', __( 'Leagues', 'sportspress' ) ),
|
||||
array( 'season', __( 'Seasons', 'sportspress' ) ),
|
||||
array( 'table', __( 'League Tables', 'sportspress' ) ),
|
||||
array( 'player', __( 'Players', 'sportspress' ) ),
|
||||
array( 'position', __( 'Positions', 'sportspress' ) ),
|
||||
array( 'list', __( 'Player Lists', 'sportspress' ) ),
|
||||
array( 'staff', __( 'Staff', 'sportspress' ) ),
|
||||
) );
|
||||
class SP_Admin_Permalink_Settings {
|
||||
|
||||
add_action( 'admin_init', array( $this, 'settings_init' ) );
|
||||
add_action( 'admin_init', array( $this, 'settings_save' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init our settings
|
||||
*/
|
||||
public function settings_init() {
|
||||
// Add a section to the permalinks page
|
||||
add_settings_section( 'sportspress-permalink', __( 'SportsPress', 'sportspress' ), array( $this, 'settings' ), 'permalink' );
|
||||
|
||||
// Add our settings
|
||||
foreach ( $this->slugs as $slug ):
|
||||
add_settings_field(
|
||||
$slug[0], // id
|
||||
$slug[1], // setting title
|
||||
array( $this, 'slug_input' ), // display callback
|
||||
'permalink', // settings page
|
||||
'sportspress-permalink' // settings section
|
||||
/**
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->slugs = apply_filters(
|
||||
'sportspress_permalink_slugs',
|
||||
array(
|
||||
array( 'event', __( 'Events', 'sportspress' ) ),
|
||||
array( 'venue', __( 'Venues', 'sportspress' ) ),
|
||||
array( 'calendar', __( 'Calendars', 'sportspress' ) ),
|
||||
array( 'team', __( 'Teams', 'sportspress' ) ),
|
||||
array( 'league', __( 'Leagues', 'sportspress' ) ),
|
||||
array( 'season', __( 'Seasons', 'sportspress' ) ),
|
||||
array( 'table', __( 'League Tables', 'sportspress' ) ),
|
||||
array( 'player', __( 'Players', 'sportspress' ) ),
|
||||
array( 'position', __( 'Positions', 'sportspress' ) ),
|
||||
array( 'list', __( 'Player Lists', 'sportspress' ) ),
|
||||
array( 'staff', __( 'Staff', 'sportspress' ) ),
|
||||
)
|
||||
);
|
||||
endforeach;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a slug input box.
|
||||
*/
|
||||
public function slug_input() {
|
||||
$slug = array_shift( $this->slugs );
|
||||
$key = $slug[0];
|
||||
$text = get_option( 'sportspress_' . $key . '_slug', null );
|
||||
?><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><?php
|
||||
}
|
||||
add_action( 'admin_init', array( $this, 'settings_init' ) );
|
||||
add_action( 'admin_init', array( $this, 'settings_save' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the settings
|
||||
*/
|
||||
public function settings() {
|
||||
echo wpautop( __( 'These settings control the permalinks used for SportsPress. These settings only apply when <strong>not using "default" permalinks above</strong>.', 'sportspress' ) );
|
||||
}
|
||||
/**
|
||||
* Init our settings
|
||||
*/
|
||||
public function settings_init() {
|
||||
// Add a section to the permalinks page
|
||||
add_settings_section( 'sportspress-permalink', __( 'SportsPress', 'sportspress' ), array( $this, 'settings' ), 'permalink' );
|
||||
|
||||
/**
|
||||
* Save the settings
|
||||
*/
|
||||
public function settings_save() {
|
||||
if ( ! is_admin() )
|
||||
return;
|
||||
|
||||
if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['sportspress_event_slug'] ) ):
|
||||
foreach ( $this->slugs as $slug ):
|
||||
$key = 'sportspress_' . $slug[0] . '_slug';
|
||||
$value = null;
|
||||
if ( isset( $_POST[ $key ] ) )
|
||||
$value = sanitize_text_field( $_POST[ $key ] );
|
||||
if ( empty( $value ) )
|
||||
delete_option( $key );
|
||||
else
|
||||
update_option( $key, $value );
|
||||
// Add our settings
|
||||
foreach ( $this->slugs as $slug ) :
|
||||
add_settings_field(
|
||||
$slug[0], // id
|
||||
$slug[1], // setting title
|
||||
array( $this, 'slug_input' ), // display callback
|
||||
'permalink', // settings page
|
||||
'sportspress-permalink' // settings section
|
||||
);
|
||||
endforeach;
|
||||
sp_flush_rewrite_rules();
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a slug input box.
|
||||
*/
|
||||
public function slug_input() {
|
||||
$slug = array_shift( $this->slugs );
|
||||
$key = $slug[0];
|
||||
$text = get_option( 'sportspress_' . $key . '_slug', null );
|
||||
?><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>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the settings
|
||||
*/
|
||||
public function settings() {
|
||||
echo wpautop( __( 'These settings control the permalinks used for SportsPress. These settings only apply when <strong>not using "default" permalinks above</strong>.', 'sportspress' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the settings
|
||||
*/
|
||||
public function settings_save() {
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['sportspress_event_slug'] ) ) :
|
||||
foreach ( $this->slugs as $slug ) :
|
||||
$key = 'sportspress_' . $slug[0] . '_slug';
|
||||
$value = null;
|
||||
if ( isset( $_POST[ $key ] ) ) {
|
||||
$value = sanitize_text_field( $_POST[ $key ] );
|
||||
}
|
||||
if ( empty( $value ) ) {
|
||||
delete_option( $key );
|
||||
} else {
|
||||
update_option( $key, $value );
|
||||
}
|
||||
endforeach;
|
||||
sp_flush_rewrite_rules();
|
||||
endif;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_Permalink_Settings();
|
||||
return new SP_Admin_Permalink_Settings();
|
||||
|
||||
@@ -2,122 +2,126 @@
|
||||
/**
|
||||
* Post Types Admin
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_Post_Types' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_Post_Types Class
|
||||
*/
|
||||
class SP_Admin_Post_Types {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_Post_Types Class
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_init', array( $this, 'include_post_type_handlers' ) );
|
||||
add_action( 'save_post', array( $this, 'unflag_post' ) );
|
||||
add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'meta_boxes' ) );
|
||||
}
|
||||
class SP_Admin_Post_Types {
|
||||
|
||||
/**
|
||||
* Conditonally load classes and functions only needed when viewing a post type.
|
||||
*/
|
||||
public function include_post_type_handlers() {
|
||||
include_once( 'post-types/class-sp-admin-meta-boxes.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-result.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-outcome.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-performance.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-column.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-metric.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-statistic.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-event.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-team.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-player.php' );
|
||||
include_once( 'post-types/class-sp-admin-cpt-staff.php' );
|
||||
do_action( 'sportspress_include_post_type_handlers' );
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_init', array( $this, 'include_post_type_handlers' ) );
|
||||
add_action( 'save_post', array( $this, 'unflag_post' ) );
|
||||
add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
|
||||
add_filter( 'sportspress_meta_boxes', array( $this, 'meta_boxes' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unflag preset and sample posts.
|
||||
*/
|
||||
public function unflag_post( $post_id ) {
|
||||
$post_types = sp_post_types();
|
||||
$config_types = sp_config_types();
|
||||
$post_type = get_post_type( $post_id );
|
||||
if ( in_array( $post_type, $post_types ) ):
|
||||
delete_post_meta( $post_id, '_sp_sample' );
|
||||
elseif ( in_array( $post_type, $config_types ) ):
|
||||
delete_post_meta( $post_id, '_sp_preset' );
|
||||
endif;
|
||||
}
|
||||
/**
|
||||
* Conditonally load classes and functions only needed when viewing a post type.
|
||||
*/
|
||||
public function include_post_type_handlers() {
|
||||
include_once 'post-types/class-sp-admin-meta-boxes.php';
|
||||
include_once 'post-types/class-sp-admin-cpt-result.php';
|
||||
include_once 'post-types/class-sp-admin-cpt-outcome.php';
|
||||
include_once 'post-types/class-sp-admin-cpt-performance.php';
|
||||
include_once 'post-types/class-sp-admin-cpt-column.php';
|
||||
include_once 'post-types/class-sp-admin-cpt-metric.php';
|
||||
include_once 'post-types/class-sp-admin-cpt-statistic.php';
|
||||
include_once 'post-types/class-sp-admin-cpt-event.php';
|
||||
include_once 'post-types/class-sp-admin-cpt-team.php';
|
||||
include_once 'post-types/class-sp-admin-cpt-player.php';
|
||||
include_once 'post-types/class-sp-admin-cpt-staff.php';
|
||||
do_action( 'sportspress_include_post_type_handlers' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Change messages when a post type is updated.
|
||||
*
|
||||
* @param array $messages
|
||||
* @return array
|
||||
*/
|
||||
public function post_updated_messages( $messages ) {
|
||||
global $typenow, $post;
|
||||
/**
|
||||
* Unflag preset and sample posts.
|
||||
*/
|
||||
public function unflag_post( $post_id ) {
|
||||
$post_types = sp_post_types();
|
||||
$config_types = sp_config_types();
|
||||
$post_type = get_post_type( $post_id );
|
||||
if ( in_array( $post_type, $post_types ) ) :
|
||||
delete_post_meta( $post_id, '_sp_sample' );
|
||||
elseif ( in_array( $post_type, $config_types ) ) :
|
||||
delete_post_meta( $post_id, '_sp_preset' );
|
||||
endif;
|
||||
}
|
||||
|
||||
if ( is_sp_config_type( $typenow ) ):
|
||||
$obj = get_post_type_object( $typenow );
|
||||
/**
|
||||
* Change messages when a post type is updated.
|
||||
*
|
||||
* @param array $messages
|
||||
* @return array
|
||||
*/
|
||||
public function post_updated_messages( $messages ) {
|
||||
global $typenow, $post;
|
||||
|
||||
for ( $i = 0; $i <= 10; $i++ ):
|
||||
$messages['post'][ $i ] = __( 'Settings saved.', 'sportspress' ) .
|
||||
if ( is_sp_config_type( $typenow ) ) :
|
||||
$obj = get_post_type_object( $typenow );
|
||||
|
||||
for ( $i = 0; $i <= 10; $i++ ) :
|
||||
$messages['post'][ $i ] = __( 'Settings saved.', 'sportspress' ) .
|
||||
' <a href="' . esc_url( admin_url( 'edit.php?post_type=' . $typenow ) ) . '">' .
|
||||
__( 'View All', 'sportspress' ) . '</a>';
|
||||
endfor;
|
||||
elseif ( is_sp_post_type( $typenow ) ):
|
||||
$obj = get_post_type_object( $typenow );
|
||||
endfor;
|
||||
elseif ( is_sp_post_type( $typenow ) ) :
|
||||
$obj = get_post_type_object( $typenow );
|
||||
|
||||
$messages['post'][1] = __( 'Changes saved.', 'sportspress' ) .
|
||||
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
|
||||
$messages['post'][1] = __( 'Changes saved.', 'sportspress' ) .
|
||||
' <a href="' . esc_url( get_permalink( $post->ID ) ) . '">' . $obj->labels->view_item . '</a>';
|
||||
|
||||
$messages['post'][4] = __( 'Changes saved.', 'sportspress' );
|
||||
$messages['post'][4] = __( 'Changes saved.', 'sportspress' );
|
||||
|
||||
$messages['post'][6] = __( 'Success!', 'sportspress' ) .
|
||||
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
|
||||
$messages['post'][6] = __( 'Success!', 'sportspress' ) .
|
||||
' <a href="' . esc_url( get_permalink( $post->ID ) ) . '">' . $obj->labels->view_item . '</a>';
|
||||
|
||||
$messages['post'][7] = __( 'Changes saved.', 'sportspress' );
|
||||
$messages['post'][7] = __( 'Changes saved.', 'sportspress' );
|
||||
|
||||
$messages['post'][8] = __( 'Success!', 'sportspress' ) .
|
||||
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
|
||||
$messages['post'][8] = __( 'Success!', 'sportspress' ) .
|
||||
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '">' .
|
||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||
|
||||
$messages['post'][9] = sprintf(
|
||||
__( 'Scheduled for: <b>%1$s</b>.', 'sportspress' ),
|
||||
date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post->ID) ) ) .
|
||||
' <a target="_blank" href="' . esc_url( get_permalink($post->ID) ) . '">' .
|
||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||
$messages['post'][9] = sprintf(
|
||||
__( 'Scheduled for: <b>%1$s</b>.', 'sportspress' ),
|
||||
date_i18n( __( 'M j, Y @ G:i', 'sportspress' ), strtotime( $post->post_date ) ),
|
||||
esc_url( get_permalink( $post->ID ) )
|
||||
) .
|
||||
' <a target="_blank" href="' . esc_url( get_permalink( $post->ID ) ) . '">' .
|
||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||
|
||||
$messages['post'][10] = __( 'Success!', 'sportspress' ) .
|
||||
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
|
||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||
endif;
|
||||
$messages['post'][10] = __( 'Success!', 'sportspress' ) .
|
||||
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '">' .
|
||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||
endif;
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove meta boxes as needed
|
||||
*/
|
||||
public static function meta_boxes( $meta_boxes ) {
|
||||
if ( 'manual' != get_option( 'sportspress_player_columns', 'auto' ) ) {
|
||||
unset( $meta_boxes['sp_player']['columns'] );
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove meta boxes as needed
|
||||
*/
|
||||
public static function meta_boxes( $meta_boxes ) {
|
||||
if ( 'manual' != get_option( 'sportspress_player_columns', 'auto' ) ) {
|
||||
unset( $meta_boxes['sp_player']['columns'] );
|
||||
}
|
||||
return $meta_boxes;
|
||||
}
|
||||
return $meta_boxes;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_Post_Types();
|
||||
return new SP_Admin_Post_Types();
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*
|
||||
* The SportsPress admin sample data class stores demo content.
|
||||
*
|
||||
* @class SP_Admin_Sample_Data
|
||||
* @version 2.5
|
||||
* @package SportsPress/Admin
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
* @class SP_Admin_Sample_Data
|
||||
* @version 2.5
|
||||
* @package SportsPress/Admin
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
class SP_Admin_Sample_Data {
|
||||
|
||||
@@ -23,18 +23,18 @@ class SP_Admin_Sample_Data {
|
||||
|
||||
// Initialize inserted ids array
|
||||
$inserted_ids = array(
|
||||
'sp_league' => array(),
|
||||
'sp_season' => array(),
|
||||
'sp_venue' => array(),
|
||||
'sp_league' => array(),
|
||||
'sp_season' => array(),
|
||||
'sp_venue' => array(),
|
||||
'sp_position' => array(),
|
||||
'sp_role' => array(),
|
||||
'sp_event' => array(),
|
||||
'sp_role' => array(),
|
||||
'sp_event' => array(),
|
||||
'sp_calendar' => array(),
|
||||
'sp_team' => array(),
|
||||
'sp_table' => array(),
|
||||
'sp_player' => array(),
|
||||
'sp_list' => array(),
|
||||
'sp_staff' => array(),
|
||||
'sp_team' => array(),
|
||||
'sp_table' => array(),
|
||||
'sp_player' => array(),
|
||||
'sp_list' => array(),
|
||||
'sp_staff' => array(),
|
||||
);
|
||||
|
||||
// Terms to insert
|
||||
@@ -44,33 +44,33 @@ class SP_Admin_Sample_Data {
|
||||
$taxonomies['sp_league'] = array( _x( 'Primary League', 'example', 'sportspress' ), _x( 'Secondary League', 'example', 'sportspress' ) );
|
||||
|
||||
// Seasons
|
||||
$current_year = date( 'Y' );
|
||||
$current_year = intval( $current_year );
|
||||
$current_year = date( 'Y' );
|
||||
$current_year = intval( $current_year );
|
||||
$taxonomies['sp_season'] = array( $current_year - 1, $current_year, $current_year + 1 );
|
||||
|
||||
// Venues
|
||||
$taxonomies['sp_venue'] = array(
|
||||
$taxonomies['sp_venue'] = array(
|
||||
array(
|
||||
'name' => 'Bentleigh',
|
||||
'meta' => array(
|
||||
'sp_address' => '12A Bolinda Street, Bentleigh VIC 3204, Australia',
|
||||
'sp_latitude' => -37.920537,
|
||||
'sp_address' => '12A Bolinda Street, Bentleigh VIC 3204, Australia',
|
||||
'sp_latitude' => -37.920537,
|
||||
'sp_longitude' => 145.043199,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'name' => 'Essendon',
|
||||
'meta' => array(
|
||||
'sp_address' => '74 Napier Street, Essendon VIC 3040, Australia',
|
||||
'sp_latitude' => -37.751940,
|
||||
'sp_address' => '74 Napier Street, Essendon VIC 3040, Australia',
|
||||
'sp_latitude' => -37.751940,
|
||||
'sp_longitude' => 144.919549,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'name' => 'Kensington',
|
||||
'meta' => array(
|
||||
'sp_address' => '50 Altona Street, Kensington, Victoria, Australia',
|
||||
'sp_latitude' => -37.797789,
|
||||
'sp_address' => '50 Altona Street, Kensington, Victoria, Australia',
|
||||
'sp_latitude' => -37.797789,
|
||||
'sp_longitude' => 144.924709,
|
||||
),
|
||||
),
|
||||
@@ -92,14 +92,21 @@ class SP_Admin_Sample_Data {
|
||||
}
|
||||
|
||||
// Insert term
|
||||
$inserted = wp_insert_term( $name, $taxonomy, array( 'description' => $name, 'slug' => sanitize_title( $name ) ) );
|
||||
$inserted = wp_insert_term(
|
||||
$name,
|
||||
$taxonomy,
|
||||
array(
|
||||
'description' => $name,
|
||||
'slug' => sanitize_title( $name ),
|
||||
)
|
||||
);
|
||||
|
||||
// Add meta to term if is array
|
||||
if ( ! is_wp_error( $inserted ) && is_array( $term ) && array_key_exists( 'meta', $term ) ) {
|
||||
$t_id = sp_array_value( $inserted, 'term_id', 1 );
|
||||
$meta = sp_array_value( $term, 'meta' );
|
||||
update_option( "taxonomy_$t_id", $meta );
|
||||
|
||||
|
||||
// Add to inserted ids array
|
||||
$inserted_ids[ $taxonomy ][] = $t_id;
|
||||
}
|
||||
@@ -113,15 +120,15 @@ class SP_Admin_Sample_Data {
|
||||
$teams = array(
|
||||
array(
|
||||
'name' => 'Bluebirds',
|
||||
'url' => 'http://tboy.co/bluebirds',
|
||||
'url' => 'http://tboy.co/bluebirds',
|
||||
),
|
||||
array(
|
||||
'name' => 'Eagles',
|
||||
'url' => 'http://tboy.co/eagles',
|
||||
'url' => 'http://tboy.co/eagles',
|
||||
),
|
||||
array(
|
||||
'name' => 'Kangaroos',
|
||||
'url' => 'http://tboy.co/kangaroos',
|
||||
'url' => 'http://tboy.co/kangaroos',
|
||||
),
|
||||
);
|
||||
|
||||
@@ -160,19 +167,35 @@ class SP_Admin_Sample_Data {
|
||||
* Insert teams
|
||||
*/
|
||||
foreach ( $teams as $index => $team ) {
|
||||
$post['post_title'] = $team['name'];
|
||||
$post['post_type'] = 'sp_team';
|
||||
$post['post_status'] = 'publish';
|
||||
$post['post_title'] = $team['name'];
|
||||
$post['post_type'] = 'sp_team';
|
||||
$post['post_status'] = 'publish';
|
||||
$post['post_content'] = sprintf( $sample_content, __( 'Team', 'sportspress' ), __( 'Teams', 'sportspress' ), add_query_arg( 'post_type', 'sp_team', admin_url( 'edit.php' ) ) );
|
||||
|
||||
// Terms
|
||||
$post['tax_input'] = array();
|
||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) );
|
||||
};
|
||||
$post['tax_input'][ $taxonomy ] = get_terms(
|
||||
$taxonomy,
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$post['tax_input']['sp_venue'] = get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $index ) );
|
||||
$post['tax_input']['sp_venue'] = get_terms(
|
||||
'sp_venue',
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
'orderby' => 'id',
|
||||
'order' => 'ASC',
|
||||
'number' => 1,
|
||||
'offset' => $index,
|
||||
)
|
||||
);
|
||||
|
||||
// Insert post
|
||||
$id = wp_insert_post( $post );
|
||||
@@ -189,13 +212,13 @@ class SP_Admin_Sample_Data {
|
||||
|
||||
// Get columns
|
||||
$columns = array( 'team' );
|
||||
$args = array(
|
||||
'post_type' => array( 'sp_performance', 'sp_statistic' ),
|
||||
$args = array(
|
||||
'post_type' => array( 'sp_performance', 'sp_statistic' ),
|
||||
'posts_per_page' => 2,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
$vars = get_posts( $args );
|
||||
$vars = get_posts( $args );
|
||||
foreach ( $vars as $var ) {
|
||||
$columns[] = $var->post_name;
|
||||
}
|
||||
@@ -204,24 +227,39 @@ class SP_Admin_Sample_Data {
|
||||
* Insert players
|
||||
*/
|
||||
foreach ( $players as $index => $name ) {
|
||||
$post['post_title'] = $name;
|
||||
$post['post_type'] = 'sp_player';
|
||||
$post['post_status'] = 'publish';
|
||||
$post['post_title'] = $name;
|
||||
$post['post_type'] = 'sp_player';
|
||||
$post['post_status'] = 'publish';
|
||||
$post['post_content'] = sprintf( $sample_content, __( 'Player', 'sportspress' ), __( 'Players', 'sportspress' ), add_query_arg( 'post_type', 'sp_player', admin_url( 'edit.php' ) ) );
|
||||
|
||||
// Terms
|
||||
$post['tax_input'] = array();
|
||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) );
|
||||
};
|
||||
$post['tax_input'][ $taxonomy ] = get_terms(
|
||||
$taxonomy,
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
)
|
||||
);
|
||||
}
|
||||
$taxonomies = array( 'sp_position' );
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$terms = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'slug', 'number' => 1, 'offset' => $index % 4 ) );
|
||||
$terms = get_terms(
|
||||
$taxonomy,
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
'orderby' => 'slug',
|
||||
'number' => 1,
|
||||
'offset' => $index % 4,
|
||||
)
|
||||
);
|
||||
if ( $terms && ! is_wp_error( $terms ) ) {
|
||||
$post['tax_input'][ $taxonomy ] = $terms;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Insert post
|
||||
$id = wp_insert_post( $post );
|
||||
@@ -233,13 +271,13 @@ class SP_Admin_Sample_Data {
|
||||
update_post_meta( $id, '_sp_sample', 1 );
|
||||
|
||||
// Calculate meta
|
||||
$nationality = array_rand( $countries->countries );
|
||||
$team_index = floor( $index / 4 );
|
||||
$nationality = array_rand( $countries->countries );
|
||||
$team_index = floor( $index / 4 );
|
||||
$past_team_index = ( $team_index + 1 ) % 3;
|
||||
$current_team = sp_array_value( $inserted_ids['sp_team'], $team_index, 0 );
|
||||
$past_team = sp_array_value( $inserted_ids['sp_team'], $past_team_index, 0 );
|
||||
$primary_league = reset( $post['tax_input']['sp_league'] );
|
||||
$season_teams = $season_stats = array();
|
||||
$current_team = sp_array_value( $inserted_ids['sp_team'], $team_index, 0 );
|
||||
$past_team = sp_array_value( $inserted_ids['sp_team'], $past_team_index, 0 );
|
||||
$primary_league = reset( $post['tax_input']['sp_league'] );
|
||||
$season_teams = $season_stats = array();
|
||||
foreach ( $post['tax_input']['sp_season'] as $season_index => $season_id ) {
|
||||
$season_stats[ $season_id ] = array();
|
||||
if ( $season_index == 0 ) {
|
||||
@@ -253,7 +291,7 @@ class SP_Admin_Sample_Data {
|
||||
}
|
||||
}
|
||||
}
|
||||
$player_stats = array( $primary_league => $season_stats );
|
||||
$player_stats = array( $primary_league => $season_stats );
|
||||
$player_leagues = array( $primary_league => $season_teams );
|
||||
|
||||
// Update meta
|
||||
@@ -268,30 +306,32 @@ class SP_Admin_Sample_Data {
|
||||
}
|
||||
|
||||
// Get columns
|
||||
$columns = array();
|
||||
$args = array(
|
||||
'post_type' => 'sp_performance',
|
||||
$columns = array();
|
||||
$args = array(
|
||||
'post_type' => 'sp_performance',
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
$performance_posts = get_posts( $args );
|
||||
foreach ( $performance_posts as $performance_post ) {
|
||||
if ( sizeof( $columns ) >= 5 ) continue;
|
||||
if ( sizeof( $columns ) >= 5 ) {
|
||||
continue;
|
||||
}
|
||||
$columns[] = $performance_post->post_name;
|
||||
}
|
||||
$args = array(
|
||||
'post_type' => 'sp_result',
|
||||
$args = array(
|
||||
'post_type' => 'sp_result',
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
$result_posts = get_posts( $args );
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
$result_posts = get_posts( $args );
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
$outcome_posts = get_posts( $args );
|
||||
|
||||
@@ -299,22 +339,37 @@ class SP_Admin_Sample_Data {
|
||||
* Insert staff
|
||||
*/
|
||||
foreach ( $staff as $index => $name ) {
|
||||
$post['post_title'] = $name;
|
||||
$post['post_type'] = 'sp_staff';
|
||||
$post['post_status'] = 'publish';
|
||||
$post['post_title'] = $name;
|
||||
$post['post_type'] = 'sp_staff';
|
||||
$post['post_status'] = 'publish';
|
||||
$post['post_content'] = sprintf( $sample_content, __( 'Staff', 'sportspress' ), __( 'Staff', 'sportspress' ), add_query_arg( 'post_type', 'sp_staff', admin_url( 'edit.php' ) ) );
|
||||
|
||||
// Terms
|
||||
$post['tax_input'] = array();
|
||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids' ) );
|
||||
};
|
||||
$post['tax_input'][ $taxonomy ] = get_terms(
|
||||
$taxonomy,
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
)
|
||||
);
|
||||
}
|
||||
$taxonomies = array( 'sp_role' );
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$terms = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'slug', 'number' => 1, 'offset' => $index % 4 ) );
|
||||
$terms = get_terms(
|
||||
$taxonomy,
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
'orderby' => 'slug',
|
||||
'number' => 1,
|
||||
'offset' => $index % 4,
|
||||
)
|
||||
);
|
||||
$post['tax_input'][ $taxonomy ] = $terms;
|
||||
};
|
||||
}
|
||||
|
||||
// Insert post
|
||||
$id = wp_insert_post( $post );
|
||||
@@ -326,8 +381,8 @@ class SP_Admin_Sample_Data {
|
||||
update_post_meta( $id, '_sp_sample', 1 );
|
||||
|
||||
// Calculate meta
|
||||
$team_index = floor( $index / 4 );
|
||||
$past_teams = $inserted_ids['sp_team'];
|
||||
$team_index = floor( $index / 4 );
|
||||
$past_teams = $inserted_ids['sp_team'];
|
||||
$current_team = sp_array_value( $past_teams, $team_index, 0 );
|
||||
unset( $past_teams[ $team_index ] );
|
||||
|
||||
@@ -347,27 +402,67 @@ class SP_Admin_Sample_Data {
|
||||
// Determine team index and post status
|
||||
$i = $index % 3;
|
||||
if ( $index < 3 ) {
|
||||
$post_status = 'publish';
|
||||
$post_year = $current_year - 1;
|
||||
$event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
||||
$post_status = 'publish';
|
||||
$post_year = $current_year - 1;
|
||||
$event_season = get_terms(
|
||||
'sp_season',
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
'orderby' => 'id',
|
||||
'order' => 'ASC',
|
||||
'number' => 1,
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$post_status = 'future';
|
||||
$post_year = $current_year + 1;
|
||||
$event_season = get_terms( 'sp_season', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'DESC', 'number' => 1 ) );
|
||||
$post_status = 'future';
|
||||
$post_year = $current_year + 1;
|
||||
$event_season = get_terms(
|
||||
'sp_season',
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
'orderby' => 'id',
|
||||
'order' => 'DESC',
|
||||
'number' => 1,
|
||||
)
|
||||
);
|
||||
}
|
||||
// The away team should be the next inserted team, or the first if this is the last event
|
||||
if ( $i == 2 ) $away_index = 0;
|
||||
else $away_index = $i + 1;
|
||||
if ( $i == 2 ) {
|
||||
$away_index = 0;
|
||||
} else {
|
||||
$away_index = $i + 1;
|
||||
}
|
||||
$post = array(
|
||||
'post_title' => $teams[ $i ]['name'] . ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ' . $teams[ $away_index ]['name'],
|
||||
'post_type' => 'sp_event',
|
||||
'post_status' => $post_status,
|
||||
'post_title' => $teams[ $i ]['name'] . ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ' . $teams[ $away_index ]['name'],
|
||||
'post_type' => 'sp_event',
|
||||
'post_status' => $post_status,
|
||||
'post_content' => sprintf( $sample_content, __( 'Event', 'sportspress' ), __( 'Events', 'sportspress' ), add_query_arg( 'post_type', 'sp_event', admin_url( 'edit.php' ) ) ),
|
||||
'post_date' => $post_year . '-' . sprintf( '%02d', 3 + $i * 3 ) . '-' . sprintf( '%02d', 5 + $i * 10 ) . ' ' . ( 18 + $i ) . ':00:00',
|
||||
'tax_input' => array(
|
||||
'sp_league' => get_terms( 'sp_league', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) ),
|
||||
'post_date' => $post_year . '-' . sprintf( '%02d', 3 + $i * 3 ) . '-' . sprintf( '%02d', 5 + $i * 10 ) . ' ' . ( 18 + $i ) . ':00:00',
|
||||
'tax_input' => array(
|
||||
'sp_league' => get_terms(
|
||||
'sp_league',
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
'orderby' => 'id',
|
||||
'order' => 'ASC',
|
||||
'number' => 1,
|
||||
)
|
||||
),
|
||||
'sp_season' => $event_season,
|
||||
'sp_venue' => get_terms( 'sp_venue', array( 'hide_empty' => 0, 'fields' => 'ids', 'orderby' => 'id', 'order' => 'ASC', 'number' => 1, 'offset' => $i ) ),
|
||||
'sp_venue' => get_terms(
|
||||
'sp_venue',
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
'orderby' => 'id',
|
||||
'order' => 'ASC',
|
||||
'number' => 1,
|
||||
'offset' => $i,
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -383,23 +478,23 @@ class SP_Admin_Sample_Data {
|
||||
// Calculate home and away team ids
|
||||
$home_team_index = ( $i ) % 3;
|
||||
$away_team_index = ( $i + 1 ) % 3;
|
||||
$home_team_id = sp_array_value( $inserted_ids['sp_team'], $home_team_index, 0 );
|
||||
$away_team_id = sp_array_value( $inserted_ids['sp_team'], $away_team_index, 0 );
|
||||
$event_teams = array(
|
||||
$home_team_id = sp_array_value( $inserted_ids['sp_team'], $home_team_index, 0 );
|
||||
$away_team_id = sp_array_value( $inserted_ids['sp_team'], $away_team_index, 0 );
|
||||
$event_teams = array(
|
||||
$home_team_id,
|
||||
$away_team_id,
|
||||
);
|
||||
|
||||
// Initialize meta
|
||||
$event_players = array( 0 );
|
||||
$performance = $results = array();
|
||||
$performance = $results = array();
|
||||
|
||||
if ( $home_team_id ) {
|
||||
// Add home team player performance
|
||||
$performance[ $home_team_id ] = array();
|
||||
for ( $j = 0; $j < 4; $j ++ ) {
|
||||
$player_id = sp_array_value( $inserted_ids['sp_player'], $home_team_index * 4 + $j );
|
||||
$event_players[] = $player_id;
|
||||
$player_id = sp_array_value( $inserted_ids['sp_player'], $home_team_index * 4 + $j );
|
||||
$event_players[] = $player_id;
|
||||
$player_performance = array();
|
||||
foreach ( $performance_posts as $performance_post ) {
|
||||
$player_performance[ $performance_post->post_name ] = rand( 0, 1 );
|
||||
@@ -413,7 +508,9 @@ class SP_Admin_Sample_Data {
|
||||
$results[ $home_team_id ][ $result_post->post_name ] = 1 + $result_post_index;
|
||||
}
|
||||
$outcome = reset( $outcome_posts );
|
||||
if ( is_object( $outcome ) ) $results[ $home_team_id ]['outcome'] = array( $outcome->post_name );
|
||||
if ( is_object( $outcome ) ) {
|
||||
$results[ $home_team_id ]['outcome'] = array( $outcome->post_name );
|
||||
}
|
||||
}
|
||||
|
||||
// Separate teams with zero
|
||||
@@ -422,8 +519,8 @@ class SP_Admin_Sample_Data {
|
||||
if ( $away_team_id ) {
|
||||
$performance[ $away_team_id ] = array();
|
||||
for ( $j = 0; $j < 4; $j ++ ) {
|
||||
$player_id = sp_array_value( $inserted_ids['sp_player'], $away_team_index * 4 + $j );
|
||||
$event_players[] = $player_id;
|
||||
$player_id = sp_array_value( $inserted_ids['sp_player'], $away_team_index * 4 + $j );
|
||||
$event_players[] = $player_id;
|
||||
$player_performance = array();
|
||||
foreach ( $performance_posts as $performance_post ) {
|
||||
$player_performance[ $performance_post->post_name ] = rand( 0, 1 );
|
||||
@@ -437,15 +534,17 @@ class SP_Admin_Sample_Data {
|
||||
$results[ $away_team_id ][ $result_post->post_name ] = '0';
|
||||
}
|
||||
$outcome = next( $outcome_posts );
|
||||
if ( is_object( $outcome ) ) $results[ $away_team_id ]['outcome'] = array( $outcome->post_name );
|
||||
if ( is_object( $outcome ) ) {
|
||||
$results[ $away_team_id ]['outcome'] = array( $outcome->post_name );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'publish' === $post_status ) {
|
||||
// Swap results for last event only
|
||||
if ( $i == 2 ) {
|
||||
$k = array_keys( $results );
|
||||
$v = array_values( $results );
|
||||
$rv = array_reverse( $v );
|
||||
$k = array_keys( $results );
|
||||
$v = array_values( $results );
|
||||
$rv = array_reverse( $v );
|
||||
$results = array_combine( $k, $rv );
|
||||
}
|
||||
|
||||
@@ -466,10 +565,10 @@ class SP_Admin_Sample_Data {
|
||||
* Insert calendar
|
||||
*/
|
||||
$post = array(
|
||||
'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ),
|
||||
'post_type' => 'sp_calendar',
|
||||
'post_status' => 'publish',
|
||||
'post_content' => sprintf( $sample_content, __( 'Calendar', 'sportspress' ), __( 'Calendars', 'sportspress' ), add_query_arg( 'post_type', 'sp_calendar', admin_url( 'edit.php' ) ) )
|
||||
'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ),
|
||||
'post_type' => 'sp_calendar',
|
||||
'post_status' => 'publish',
|
||||
'post_content' => sprintf( $sample_content, __( 'Calendar', 'sportspress' ), __( 'Calendars', 'sportspress' ), add_query_arg( 'post_type', 'sp_calendar', admin_url( 'edit.php' ) ) ),
|
||||
);
|
||||
|
||||
// Insert post
|
||||
@@ -495,16 +594,32 @@ class SP_Admin_Sample_Data {
|
||||
/*
|
||||
* Insert league table
|
||||
*/
|
||||
$leagues = get_terms( 'sp_league', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
||||
$league = reset( $leagues );
|
||||
$seasons = get_terms( 'sp_season', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
||||
$season = reset( $seasons );
|
||||
$post = array(
|
||||
'post_title' => $league->name . ' ' . $season->name,
|
||||
'post_type' => 'sp_table',
|
||||
'post_status' => 'publish',
|
||||
$leagues = get_terms(
|
||||
'sp_league',
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'orderby' => 'id',
|
||||
'order' => 'ASC',
|
||||
'number' => 1,
|
||||
)
|
||||
);
|
||||
$league = reset( $leagues );
|
||||
$seasons = get_terms(
|
||||
'sp_season',
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'orderby' => 'id',
|
||||
'order' => 'ASC',
|
||||
'number' => 1,
|
||||
)
|
||||
);
|
||||
$season = reset( $seasons );
|
||||
$post = array(
|
||||
'post_title' => $league->name . ' ' . $season->name,
|
||||
'post_type' => 'sp_table',
|
||||
'post_status' => 'publish',
|
||||
'post_content' => sprintf( $sample_content, __( 'League Table', 'sportspress' ), __( 'League Tables', 'sportspress' ), add_query_arg( 'post_type', 'sp_table', admin_url( 'edit.php' ) ) ),
|
||||
'tax_input' => array(
|
||||
'tax_input' => array(
|
||||
'sp_league' => $league->term_id,
|
||||
'sp_season' => $season->term_id,
|
||||
),
|
||||
@@ -520,12 +635,12 @@ class SP_Admin_Sample_Data {
|
||||
update_post_meta( $id, '_sp_sample', 1 );
|
||||
|
||||
// Get columns
|
||||
$columns = array();
|
||||
$args = array(
|
||||
'post_type' => 'sp_column',
|
||||
$columns = array();
|
||||
$args = array(
|
||||
'post_type' => 'sp_column',
|
||||
'posts_per_page' => 8,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
$column_posts = get_posts( $args );
|
||||
foreach ( $column_posts as $column_post ) {
|
||||
@@ -542,9 +657,9 @@ class SP_Admin_Sample_Data {
|
||||
*/
|
||||
foreach ( $inserted_ids['sp_team'] as $index => $team_id ) {
|
||||
$post = array(
|
||||
'post_title' => get_the_title( $team_id ) . ' ' . _x( 'Roster', 'example', 'sportspress' ),
|
||||
'post_type' => 'sp_list',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => get_the_title( $team_id ) . ' ' . _x( 'Roster', 'example', 'sportspress' ),
|
||||
'post_type' => 'sp_list',
|
||||
'post_status' => 'publish',
|
||||
'post_content' => sprintf( $sample_content, __( 'Player List', 'sportspress' ), __( 'Player Lists', 'sportspress' ), add_query_arg( 'post_type', 'sp_list', admin_url( 'edit.php' ) ) ),
|
||||
);
|
||||
|
||||
@@ -561,12 +676,12 @@ class SP_Admin_Sample_Data {
|
||||
$list_players = array_slice( $inserted_ids['sp_player'], $index * 4, 4 );
|
||||
|
||||
// Get columns
|
||||
$columns = array();
|
||||
$args = array(
|
||||
'post_type' => array( 'sp_metric' ),
|
||||
$columns = array();
|
||||
$args = array(
|
||||
'post_type' => array( 'sp_metric' ),
|
||||
'posts_per_page' => 2,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
$column_posts = get_posts( $args );
|
||||
foreach ( $column_posts as $column_post ) {
|
||||
@@ -587,9 +702,9 @@ class SP_Admin_Sample_Data {
|
||||
* Insert player list for player ranking
|
||||
*/
|
||||
$post = array(
|
||||
'post_title' => _x( 'Player Ranking', 'example', 'sportspress' ),
|
||||
'post_type' => 'sp_list',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => _x( 'Player Ranking', 'example', 'sportspress' ),
|
||||
'post_type' => 'sp_list',
|
||||
'post_status' => 'publish',
|
||||
'post_content' => sprintf( $sample_content, __( 'Player List', 'sportspress' ), __( 'Player Lists', 'sportspress' ), add_query_arg( 'post_type', 'sp_list', admin_url( 'edit.php' ) ) ),
|
||||
);
|
||||
|
||||
@@ -603,9 +718,11 @@ class SP_Admin_Sample_Data {
|
||||
update_post_meta( $id, '_sp_sample', 1 );
|
||||
|
||||
// Get columns
|
||||
$columns = array( 'team' );
|
||||
$columns = array( 'team' );
|
||||
$performance_post = reset( $performance_posts );
|
||||
if ( is_object( $performance_post ) ) $columns[] = $performance_post->post_name;
|
||||
if ( is_object( $performance_post ) ) {
|
||||
$columns[] = $performance_post->post_name;
|
||||
}
|
||||
|
||||
// Update meta
|
||||
update_post_meta( $id, 'sp_format', 'list' );
|
||||
@@ -613,7 +730,9 @@ class SP_Admin_Sample_Data {
|
||||
update_post_meta( $id, 'sp_columns', $columns );
|
||||
update_post_meta( $id, 'sp_grouping', '0' );
|
||||
update_post_meta( $id, 'sp_order', 'DESC' );
|
||||
if ( is_object( $performance_post ) ) update_post_meta( $id, 'sp_orderby', $performance_post->post_name );
|
||||
if ( is_object( $performance_post ) ) {
|
||||
update_post_meta( $id, 'sp_orderby', $performance_post->post_name );
|
||||
}
|
||||
|
||||
/*
|
||||
* Update player list and league table per team
|
||||
@@ -631,21 +750,21 @@ class SP_Admin_Sample_Data {
|
||||
*/
|
||||
public static function delete_posts() {
|
||||
$post_types = sp_post_types();
|
||||
$args = array(
|
||||
'post_type' => $post_types,
|
||||
$args = array(
|
||||
'post_type' => $post_types,
|
||||
'posts_per_page' => -1,
|
||||
'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
|
||||
'meta_query' => array(
|
||||
'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_sp_sample',
|
||||
'value' => 1
|
||||
)
|
||||
'key' => '_sp_sample',
|
||||
'value' => 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Delete posts
|
||||
$old_posts = get_posts( $args );
|
||||
foreach( $old_posts as $post ):
|
||||
foreach ( $old_posts as $post ) :
|
||||
wp_delete_post( $post->ID, true );
|
||||
endforeach;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,11 +4,11 @@
|
||||
*
|
||||
* The SportsPress admin sports class stores preset sport data.
|
||||
*
|
||||
* @class SP_Admin_Sports
|
||||
* @version 2.6
|
||||
* @package SportsPress/Admin
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
* @class SP_Admin_Sports
|
||||
* @version 2.6
|
||||
* @package SportsPress/Admin
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
class SP_Admin_Sports {
|
||||
|
||||
@@ -20,18 +20,18 @@ class SP_Admin_Sports {
|
||||
*/
|
||||
public static function get_presets() {
|
||||
if ( empty( self::$presets ) ) {
|
||||
$presets = array();
|
||||
$presets = array();
|
||||
self::$options = array(
|
||||
'team-sports' => array(),
|
||||
'team-sports' => array(),
|
||||
'racket-sports' => array(),
|
||||
'water-sports' => array(),
|
||||
'water-sports' => array(),
|
||||
'target-sports' => array(),
|
||||
'esports' => array(),
|
||||
'other' => array(),
|
||||
'esports' => array(),
|
||||
'other' => array(),
|
||||
);
|
||||
|
||||
foreach ( self::$options as $slug => $options ) {
|
||||
$dir = scandir( SP()->plugin_path() . '/presets/' . $slug );
|
||||
$dir = scandir( SP()->plugin_path() . '/presets/' . $slug );
|
||||
$files = array();
|
||||
if ( $dir ) {
|
||||
foreach ( $dir as $key => $value ) {
|
||||
@@ -40,13 +40,15 @@ class SP_Admin_Sports {
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach( $files as $file ) {
|
||||
foreach ( $files as $file ) {
|
||||
$json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $slug . '/' . $file );
|
||||
$data = json_decode( $json_data, true );
|
||||
if ( ! is_array( $data ) ) continue;
|
||||
$id = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file );
|
||||
$data = json_decode( $json_data, true );
|
||||
if ( ! is_array( $data ) ) {
|
||||
continue;
|
||||
}
|
||||
$id = preg_replace( '/\\.[^.\\s]{3,4}$/', '', $file );
|
||||
$presets[ $id ] = $data;
|
||||
$name = array_key_exists( 'name', $data ) ? __( $data['name'], 'sportspress' ) : $id;
|
||||
$name = array_key_exists( 'name', $data ) ? __( $data['name'], 'sportspress' ) : $id;
|
||||
|
||||
// Conditionally append filename in parentheses for clarity
|
||||
if ( false === strpos( str_replace( ' ', '', strtolower( $data['name'] ) ), str_replace( '-', '', $id ) ) ) {
|
||||
@@ -69,15 +71,19 @@ class SP_Admin_Sports {
|
||||
|
||||
public static function get_preset( $id ) {
|
||||
$json_data = @file_get_contents( SP()->plugin_path() . '/presets/' . $id . '.json', true );
|
||||
|
||||
if ( $json_data ) return json_decode( $json_data, true );
|
||||
|
||||
|
||||
if ( $json_data ) {
|
||||
return json_decode( $json_data, true );
|
||||
}
|
||||
|
||||
$dir = scandir( SP()->plugin_path() . '/presets' );
|
||||
if ( $dir ) {
|
||||
foreach ( $dir as $key => $value ) {
|
||||
if ( substr( $value, 0, 1 ) !== '.' && strpos( $value, '.' ) === false ) {
|
||||
$json_data = @file_get_contents( SP()->plugin_path() . '/presets/' . $value . '/' . $id . '.json', true );
|
||||
if ( $json_data ) return json_decode( $json_data, true );
|
||||
if ( $json_data ) {
|
||||
return json_decode( $json_data, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,19 +105,21 @@ class SP_Admin_Sports {
|
||||
|
||||
// Positions
|
||||
$positions = sp_array_value( $preset, 'positions', array() );
|
||||
$i = 0;
|
||||
$i = 0;
|
||||
foreach ( $positions as $position ) {
|
||||
if ( is_string( $position ) ) {
|
||||
$name = $position;
|
||||
$name = $position;
|
||||
$sections = array( 0, 1 );
|
||||
} else {
|
||||
$name = sp_array_value( $position, 'name', __( 'Position', 'sportspress' ) );
|
||||
$name = sp_array_value( $position, 'name', __( 'Position', 'sportspress' ) );
|
||||
$sections = sp_array_value( $position, 'sections', array( 0, 1 ) );
|
||||
}
|
||||
$term = wp_insert_term( $name, 'sp_position' );
|
||||
if ( is_wp_error( $term ) ) continue;
|
||||
$t_id = $term['term_id'];
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
if ( is_wp_error( $term ) ) {
|
||||
continue;
|
||||
}
|
||||
$t_id = $term['term_id'];
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$term_meta['sp_sections'] = $sections;
|
||||
update_option( "taxonomy_$t_id", $term_meta );
|
||||
update_term_meta( $t_id, 'sp_order', $i + 1 );
|
||||
@@ -120,11 +128,13 @@ class SP_Admin_Sports {
|
||||
|
||||
// Outcomes
|
||||
$post_type = 'sp_outcome';
|
||||
$outcomes = sp_array_value( $preset, 'outcomes', array() );
|
||||
$outcomes = sp_array_value( $preset, 'outcomes', array() );
|
||||
self::delete_preset_posts( $post_type );
|
||||
foreach ( $outcomes as $index => $outcome ) {
|
||||
$post = self::get_post_array( $outcome, $post_type );
|
||||
if ( empty( $post ) ) continue;
|
||||
if ( empty( $post ) ) {
|
||||
continue;
|
||||
}
|
||||
$id = self::insert_preset_post( $post, $index );
|
||||
update_post_meta( $id, 'sp_abbreviation', sp_array_value( $outcome, 'abbreviation', null ) );
|
||||
update_post_meta( $id, 'sp_condition', sp_array_value( $outcome, 'condition', null ) );
|
||||
@@ -132,14 +142,18 @@ class SP_Admin_Sports {
|
||||
|
||||
// Results
|
||||
$post_type = 'sp_result';
|
||||
$results = sp_array_value( $preset, 'results', array() );
|
||||
$results = sp_array_value( $preset, 'results', array() );
|
||||
self::delete_preset_posts( $post_type );
|
||||
$primary_result = 0;
|
||||
foreach ( $results as $index => $result ) {
|
||||
$post = self::get_post_array( $result, $post_type );
|
||||
if ( empty( $post ) ) continue;
|
||||
if ( empty( $post ) ) {
|
||||
continue;
|
||||
}
|
||||
$id = self::insert_preset_post( $post, $index );
|
||||
if ( is_array( $result ) && array_key_exists( 'primary', $result ) ) $primary_result = $post['post_name'];
|
||||
if ( is_array( $result ) && array_key_exists( 'primary', $result ) ) {
|
||||
$primary_result = $post['post_name'];
|
||||
}
|
||||
update_post_meta( $id, 'sp_equation', sp_array_value( $result, 'equation', null ) );
|
||||
}
|
||||
|
||||
@@ -147,12 +161,14 @@ class SP_Admin_Sports {
|
||||
$i = 0;
|
||||
|
||||
// Performance
|
||||
$post_type = 'sp_performance';
|
||||
$post_type = 'sp_performance';
|
||||
$performances = sp_array_value( $preset, 'performance', array() );
|
||||
self::delete_preset_posts( $post_type );
|
||||
foreach ( $performances as $index => $performance ) {
|
||||
$post = self::get_post_array( $performance, $post_type );
|
||||
if ( empty( $post ) ) continue;
|
||||
if ( empty( $post ) ) {
|
||||
continue;
|
||||
}
|
||||
$id = self::insert_preset_post( $post, $index );
|
||||
if ( isset( $performance['position'] ) ) {
|
||||
wp_set_object_terms( $id, $performance['position'], 'sp_position', false );
|
||||
@@ -170,11 +186,13 @@ class SP_Admin_Sports {
|
||||
|
||||
// Columns
|
||||
$post_type = 'sp_column';
|
||||
$columns = sp_array_value( $preset, 'columns', array() );
|
||||
$columns = sp_array_value( $preset, 'columns', array() );
|
||||
self::delete_preset_posts( $post_type );
|
||||
foreach ( $columns as $index => $column ) {
|
||||
$post = self::get_post_array( $column, $post_type );
|
||||
if ( empty( $post ) ) continue;
|
||||
if ( empty( $post ) ) {
|
||||
continue;
|
||||
}
|
||||
$id = self::insert_preset_post( $post, $index );
|
||||
update_post_meta( $id, 'sp_equation', sp_array_value( $column, 'equation', null ) );
|
||||
update_post_meta( $id, 'sp_precision', sp_array_value( $column, 'precision', 0 ) );
|
||||
@@ -184,40 +202,45 @@ class SP_Admin_Sports {
|
||||
|
||||
// Metrics
|
||||
$post_type = 'sp_metric';
|
||||
$metrics = sp_array_value( $preset, 'metrics', array() );
|
||||
$metrics = sp_array_value( $preset, 'metrics', array() );
|
||||
self::delete_preset_posts( $post_type );
|
||||
foreach ( $metrics as $index => $metric ) {
|
||||
$post = self::get_post_array( $metric, $post_type );
|
||||
if ( empty( $post ) ) continue;
|
||||
if ( empty( $post ) ) {
|
||||
continue;
|
||||
}
|
||||
$id = self::insert_preset_post( $post, $i + $index );
|
||||
$i ++;
|
||||
}
|
||||
|
||||
|
||||
// Event Specs
|
||||
$post_type = 'sp_spec';
|
||||
$specs = sp_array_value( $preset, 'specs', array() );
|
||||
$specs = sp_array_value( $preset, 'specs', array() );
|
||||
self::delete_preset_posts( $post_type );
|
||||
foreach ( $specs as $index => $spec ) {
|
||||
$post = self::get_post_array( $spec, $post_type );
|
||||
if ( empty( $post ) ) continue;
|
||||
if ( empty( $post ) ) {
|
||||
continue;
|
||||
}
|
||||
$id = self::insert_preset_post( $post, $i + $index );
|
||||
$i ++;
|
||||
}
|
||||
|
||||
// Statistics
|
||||
$post_type = 'sp_statistic';
|
||||
$post_type = 'sp_statistic';
|
||||
$statistics = sp_array_value( $preset, 'statistics', array() );
|
||||
self::delete_preset_posts( $post_type );
|
||||
foreach ( $statistics as $index => $statistic ) {
|
||||
$post = self::get_post_array( $statistic, $post_type );
|
||||
if ( empty( $post ) ) continue;
|
||||
if ( empty( $post ) ) {
|
||||
continue;
|
||||
}
|
||||
$id = self::insert_preset_post( $post, $i + $index );
|
||||
update_post_meta( $id, 'sp_equation', sp_array_value( $statistic, 'equation', null ) );
|
||||
update_post_meta( $id, 'sp_precision', sp_array_value( $statistic, 'precision', 0 ) );
|
||||
update_post_meta( $id, 'sp_type', sp_array_value( $statistic, 'type', 'total' ) );
|
||||
}
|
||||
|
||||
|
||||
// Options
|
||||
$options = sp_array_value( $preset, 'options', array() );
|
||||
foreach ( $options as $option => $value ) {
|
||||
@@ -230,20 +253,20 @@ class SP_Admin_Sports {
|
||||
|
||||
public static function delete_preset_posts( $post_type = null ) {
|
||||
$args = array(
|
||||
'post_type' => $post_type,
|
||||
'post_type' => $post_type,
|
||||
'posts_per_page' => -1,
|
||||
'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
|
||||
'meta_query' => array(
|
||||
'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ),
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_sp_preset',
|
||||
'value' => 1
|
||||
)
|
||||
)
|
||||
'key' => '_sp_preset',
|
||||
'value' => 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Delete posts
|
||||
$old_posts = get_posts( $args );
|
||||
foreach( $old_posts as $post ):
|
||||
foreach ( $old_posts as $post ) :
|
||||
wp_delete_post( $post->ID, true );
|
||||
endforeach;
|
||||
}
|
||||
@@ -252,15 +275,19 @@ class SP_Admin_Sports {
|
||||
$post_array = array();
|
||||
if ( is_string( $post ) ) {
|
||||
$post_array['post_title'] = $post;
|
||||
$post_array['post_name'] = sp_get_eos_safe_slug( $post_array['post_title'] );
|
||||
$post_array['post_name'] = sp_get_eos_safe_slug( $post_array['post_title'] );
|
||||
} elseif ( is_array( $post ) ) {
|
||||
if ( ! array_key_exists( 'name', $post ) ) $post_array = array();
|
||||
if ( ! array_key_exists( 'name', $post ) ) {
|
||||
$post_array = array();
|
||||
}
|
||||
$post_array['post_title'] = $post['name'];
|
||||
$post_array['post_name'] = sp_array_value( $post, 'id', sp_get_eos_safe_slug( $post_array['post_title'] ) );
|
||||
$post_array['post_name'] = sp_array_value( $post, 'id', sp_get_eos_safe_slug( $post_array['post_title'] ) );
|
||||
}
|
||||
|
||||
// Return empty array if post with same slug already exists
|
||||
if ( get_page_by_path( $post_array['post_name'], OBJECT, $post_type ) ) return array();
|
||||
if ( get_page_by_path( $post_array['post_name'], OBJECT, $post_type ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Set post type
|
||||
$post_array['post_type'] = $post_type;
|
||||
@@ -275,9 +302,9 @@ class SP_Admin_Sports {
|
||||
|
||||
public static function insert_preset_post( $post, $index = 0 ) {
|
||||
// Increment menu order by 10 and publish post
|
||||
$post['menu_order'] = $index * 10 + 10;
|
||||
$post['menu_order'] = $index * 10 + 10;
|
||||
$post['post_status'] = 'publish';
|
||||
$id = wp_insert_post( $post );
|
||||
$id = wp_insert_post( $post );
|
||||
|
||||
// Flag as preset
|
||||
update_post_meta( $id, '_sp_preset', 1 );
|
||||
@@ -287,21 +314,26 @@ class SP_Admin_Sports {
|
||||
|
||||
/**
|
||||
* Sport category names
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function sport_category_names() {
|
||||
return apply_filters( 'sportspress_sport_categories', array(
|
||||
'team-sports' => __( 'Team Sports', 'sportspress' ),
|
||||
'racket-sports' => __( 'Racket Sports', 'sportspress' ),
|
||||
'water-sports' => __( 'Water Sports', 'sportspress' ),
|
||||
'target-sports' => __( 'Target Sports', 'sportspress' ),
|
||||
'esports' => __( 'Esports', 'sportspress' ),
|
||||
'other' => __( 'Other', 'sportspress' ),
|
||||
) );
|
||||
return apply_filters(
|
||||
'sportspress_sport_categories',
|
||||
array(
|
||||
'team-sports' => __( 'Team Sports', 'sportspress' ),
|
||||
'racket-sports' => __( 'Racket Sports', 'sportspress' ),
|
||||
'water-sports' => __( 'Water Sports', 'sportspress' ),
|
||||
'target-sports' => __( 'Target Sports', 'sportspress' ),
|
||||
'esports' => __( 'Esports', 'sportspress' ),
|
||||
'other' => __( 'Other', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sport preset names for localization
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function sport_preset_names() {
|
||||
|
||||
@@ -2,75 +2,78 @@
|
||||
/**
|
||||
* Debug/Status page
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 1.4
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_Status' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_Status Class
|
||||
*/
|
||||
class SP_Admin_Status {
|
||||
|
||||
/**
|
||||
* Retrieve metadata from a file. Based on WP Core's get_file_data function
|
||||
*
|
||||
* @since 0.8
|
||||
* @param string $file Path to the file
|
||||
* @param array $all_headers List of headers, in the format array('HeaderKey' => 'Header Name')
|
||||
* SP_Admin_Status Class
|
||||
*/
|
||||
public function get_file_version( $file ) {
|
||||
// We don't need to write to the file, so just open for reading.
|
||||
$fp = fopen( $file, 'r' );
|
||||
class SP_Admin_Status {
|
||||
|
||||
// Pull only the first 8kiB of the file in.
|
||||
$file_data = fread( $fp, 8192 );
|
||||
/**
|
||||
* Retrieve metadata from a file. Based on WP Core's get_file_data function
|
||||
*
|
||||
* @since 0.8
|
||||
* @param string $file Path to the file
|
||||
* @param array $all_headers List of headers, in the format array('HeaderKey' => 'Header Name')
|
||||
*/
|
||||
public function get_file_version( $file ) {
|
||||
// We don't need to write to the file, so just open for reading.
|
||||
$fp = fopen( $file, 'r' );
|
||||
|
||||
// PHP will close file handle, but we are good citizens.
|
||||
fclose( $fp );
|
||||
// Pull only the first 8kiB of the file in.
|
||||
$file_data = fread( $fp, 8192 );
|
||||
|
||||
// Make sure we catch CR-only line endings.
|
||||
$file_data = str_replace( "\r", "\n", $file_data );
|
||||
$version = '';
|
||||
// PHP will close file handle, but we are good citizens.
|
||||
fclose( $fp );
|
||||
|
||||
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] )
|
||||
$version = _cleanup_header_comment( $match[1] );
|
||||
// Make sure we catch CR-only line endings.
|
||||
$file_data = str_replace( "\r", "\n", $file_data );
|
||||
$version = '';
|
||||
|
||||
return $version ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan the template files
|
||||
*
|
||||
* @access public
|
||||
* @param string $template_path
|
||||
* @return array
|
||||
*/
|
||||
public function scan_template_files( $template_path ) {
|
||||
$files = scandir( $template_path );
|
||||
$result = array();
|
||||
if ( $files ) {
|
||||
foreach ( $files as $key => $value ) {
|
||||
if ( ! in_array( $value, array( ".",".." ) ) ) {
|
||||
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
|
||||
$sub_files = $this->scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
|
||||
foreach ( $sub_files as $sub_file ) {
|
||||
$result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
|
||||
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
|
||||
$version = _cleanup_header_comment( $match[1] );
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan the template files
|
||||
*
|
||||
* @access public
|
||||
* @param string $template_path
|
||||
* @return array
|
||||
*/
|
||||
public function scan_template_files( $template_path ) {
|
||||
$files = scandir( $template_path );
|
||||
$result = array();
|
||||
if ( $files ) {
|
||||
foreach ( $files as $key => $value ) {
|
||||
if ( ! in_array( $value, array( '.', '..' ) ) ) {
|
||||
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
|
||||
$sub_files = $this->scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
|
||||
foreach ( $sub_files as $sub_file ) {
|
||||
$result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
|
||||
}
|
||||
} else {
|
||||
$result[] = $value;
|
||||
}
|
||||
} else {
|
||||
$result[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
/**
|
||||
* Handles taxonomies in admin
|
||||
*
|
||||
* @class SP_Admin_Taxonomies
|
||||
* @version 2.7.9
|
||||
* @package SportsPress/Admin
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
* @class SP_Admin_Taxonomies
|
||||
* @version 2.7.9
|
||||
* @package SportsPress/Admin
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
class SP_Admin_Taxonomies {
|
||||
|
||||
@@ -71,7 +71,7 @@ class SP_Admin_Taxonomies {
|
||||
* @param mixed $term Term (category) being edited
|
||||
*/
|
||||
public function edit_taxonomy_fields( $term ) {
|
||||
$t_id = $term->term_id;
|
||||
$t_id = $term->term_id;
|
||||
?>
|
||||
<?php if ( function_exists( 'get_term_meta' ) ) { ?>
|
||||
<?php $order = get_term_meta( $t_id, 'sp_order', true ); ?>
|
||||
@@ -80,7 +80,7 @@ class SP_Admin_Taxonomies {
|
||||
<td><input name="sp_order" class="sp-number-input" type="text" step="1" size="4" id="sp_order" value="<?php echo (int) $order; ?>"></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,25 +91,25 @@ class SP_Admin_Taxonomies {
|
||||
*/
|
||||
public function add_venue_fields() {
|
||||
$args = array(
|
||||
'orderby' => 'id',
|
||||
'order' => 'DESC',
|
||||
'orderby' => 'id',
|
||||
'order' => 'DESC',
|
||||
'hide_empty' => false,
|
||||
'number' => 1,
|
||||
'number' => 1,
|
||||
);
|
||||
|
||||
// Get latitude and longitude from the last added venue
|
||||
$terms = get_terms( 'sp_venue', $args );
|
||||
if ( $terms && array_key_exists( 0, $terms) && is_object( reset( $terms ) ) ):
|
||||
$term = reset( $terms );
|
||||
$t_id = $term->term_id;
|
||||
if ( $terms && array_key_exists( 0, $terms ) && is_object( reset( $terms ) ) ) :
|
||||
$term = reset( $terms );
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$latitude = sp_array_value( $term_meta, 'sp_latitude', '-37.8165647' );
|
||||
$latitude = sp_array_value( $term_meta, 'sp_latitude', '-37.8165647' );
|
||||
$longitude = sp_array_value( $term_meta, 'sp_longitude', '144.9475055' );
|
||||
$address = sp_array_value( $term_meta, 'sp_address', '' );
|
||||
$address = sp_array_value( $term_meta, 'sp_address', '' );
|
||||
endif;
|
||||
// Sanitize latitude and longitude, fallback to default.
|
||||
if( ! is_numeric( $latitude) || ! is_numeric( $longitude) ):
|
||||
$latitude = '-37.8165647';
|
||||
if ( ! is_numeric( $latitude ) || ! is_numeric( $longitude ) ) :
|
||||
$latitude = '-37.8165647';
|
||||
$longitude = '144.9475055';
|
||||
endif;
|
||||
?>
|
||||
@@ -129,7 +129,7 @@ class SP_Admin_Taxonomies {
|
||||
<label for="term_meta[sp_longitude]"><?php _e( 'Longitude', 'sportspress' ); ?></label>
|
||||
<input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo esc_attr( $longitude ); ?>">
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
do_action( 'sp_admin_geocoder_scripts' );
|
||||
}
|
||||
|
||||
@@ -140,11 +140,11 @@ class SP_Admin_Taxonomies {
|
||||
* @param mixed $term Term (category) being edited
|
||||
*/
|
||||
public function edit_venue_fields( $term ) {
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$latitude = is_numeric( $term_meta['sp_latitude'] ) ? $term_meta['sp_latitude'] : '';
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$latitude = is_numeric( $term_meta['sp_latitude'] ) ? $term_meta['sp_latitude'] : '';
|
||||
$longitude = is_numeric( $term_meta['sp_longitude'] ) ? $term_meta['sp_longitude'] : '';
|
||||
$address = $term_meta['sp_address'] ? $term_meta['sp_address'] : '';
|
||||
$address = $term_meta['sp_address'] ? $term_meta['sp_address'] : '';
|
||||
?>
|
||||
<tr class="form-field">
|
||||
<td colspan="2">
|
||||
@@ -170,7 +170,7 @@ class SP_Admin_Taxonomies {
|
||||
<input type="text" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo esc_attr( $longitude ); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
do_action( 'sp_admin_geocoder_scripts' );
|
||||
}
|
||||
|
||||
@@ -184,16 +184,29 @@ class SP_Admin_Taxonomies {
|
||||
?>
|
||||
<div class="form-field">
|
||||
<label><?php _e( 'Statistics', 'sportspress' ); ?></label>
|
||||
<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">
|
||||
<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">
|
||||
<?php
|
||||
$options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
||||
foreach ( $options as $key => $value ):
|
||||
$options = apply_filters(
|
||||
'sportspress_performance_sections',
|
||||
array(
|
||||
0 => __( 'Offense', 'sportspress' ),
|
||||
1 => __(
|
||||
'Defense',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true ), $value );
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,17 +216,30 @@ class SP_Admin_Taxonomies {
|
||||
* @param mixed $term Term (category) being edited
|
||||
*/
|
||||
public function edit_position_fields( $term ) {
|
||||
$t_id = $term->term_id;
|
||||
$t_id = $term->term_id;
|
||||
$sections = sp_get_term_sections( $t_id );
|
||||
?>
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="term_meta[sp_sections]"><?php _e( 'Statistics', 'sportspress' ); ?></label></th>
|
||||
<input type="hidden" name="term_meta[sp_sections]" value="">
|
||||
<td>
|
||||
<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">
|
||||
<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">
|
||||
<?php
|
||||
$options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
||||
foreach ( $options as $key => $value ):
|
||||
$options = apply_filters(
|
||||
'sportspress_performance_sections',
|
||||
array(
|
||||
0 => __( 'Offense', 'sportspress' ),
|
||||
1 => __(
|
||||
'Defense',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( in_array( $key, $sections ), true, false ), $value );
|
||||
endforeach;
|
||||
?>
|
||||
@@ -227,7 +253,7 @@ class SP_Admin_Taxonomies {
|
||||
<td><input name="sp_order" class="sp-number-input" type="text" step="1" size="4" id="sp_order" value="<?php echo (int) $order; ?>"></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,12 +265,12 @@ class SP_Admin_Taxonomies {
|
||||
*/
|
||||
public function save_fields( $term_id ) {
|
||||
if ( isset( $_POST['term_meta'] ) ) {
|
||||
$t_id = $term_id;
|
||||
$t_id = $term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$cat_keys = array_keys( $_POST['term_meta'] );
|
||||
$cat_keys = array_keys( $_POST['term_meta'] );
|
||||
foreach ( $cat_keys as $key ) {
|
||||
if ( isset ( $_POST['term_meta'][ $key ] ) ) {
|
||||
$term_meta[$key] = sanitize_text_field( $_POST['term_meta'][ $key ] );
|
||||
if ( isset( $_POST['term_meta'][ $key ] ) ) {
|
||||
$term_meta[ $key ] = sanitize_text_field( $_POST['term_meta'][ $key ] );
|
||||
}
|
||||
}
|
||||
update_option( "taxonomy_$t_id", $term_meta );
|
||||
@@ -263,13 +289,15 @@ class SP_Admin_Taxonomies {
|
||||
*/
|
||||
public function taxonomy_columns( $columns ) {
|
||||
$new_columns = array();
|
||||
|
||||
if ( function_exists( 'get_term_meta' ) ) $new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
|
||||
if ( array_key_exists('posts', $columns) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
if ( function_exists( 'get_term_meta' ) ) {
|
||||
$new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
}
|
||||
|
||||
unset( $columns['posts'] );
|
||||
if ( array_key_exists( 'posts', $columns ) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
|
||||
unset( $columns['posts'] );
|
||||
}
|
||||
|
||||
return array_merge( $columns, $new_columns );
|
||||
@@ -283,12 +311,12 @@ class SP_Admin_Taxonomies {
|
||||
* @return array
|
||||
*/
|
||||
public function venue_columns( $columns ) {
|
||||
$new_columns = array();
|
||||
$new_columns = array();
|
||||
$new_columns['sp_address'] = __( 'Address', 'sportspress' );
|
||||
|
||||
if ( array_key_exists('posts', $columns) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
unset( $columns['posts'] );
|
||||
|
||||
if ( array_key_exists( 'posts', $columns ) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
unset( $columns['posts'] );
|
||||
}
|
||||
|
||||
unset( $columns['description'] );
|
||||
@@ -305,14 +333,16 @@ class SP_Admin_Taxonomies {
|
||||
* @return array
|
||||
*/
|
||||
public function position_columns( $columns ) {
|
||||
$new_columns = array();
|
||||
$new_columns = array();
|
||||
$new_columns['sp_sections'] = __( 'Statistics', 'sportspress' );
|
||||
|
||||
if ( function_exists( 'get_term_meta' ) ) $new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
|
||||
if ( array_key_exists('posts', $columns) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
unset( $columns['posts'] );
|
||||
if ( function_exists( 'get_term_meta' ) ) {
|
||||
$new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'posts', $columns ) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
unset( $columns['posts'] );
|
||||
}
|
||||
|
||||
unset( $columns['description'] );
|
||||
@@ -341,13 +371,22 @@ class SP_Admin_Taxonomies {
|
||||
$columns .= $address;
|
||||
|
||||
} elseif ( $column == 'sp_sections' ) {
|
||||
|
||||
$options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
||||
|
||||
$options = apply_filters(
|
||||
'sportspress_performance_sections',
|
||||
array(
|
||||
0 => __( 'Offense', 'sportspress' ),
|
||||
1 => __(
|
||||
'Defense',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$sections = sp_get_term_sections( $id );
|
||||
|
||||
|
||||
$section_names = array();
|
||||
|
||||
|
||||
if ( is_array( $sections ) ) {
|
||||
foreach ( $sections as $section ) {
|
||||
if ( array_key_exists( $section, $options ) ) {
|
||||
@@ -355,7 +394,7 @@ class SP_Admin_Taxonomies {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$columns .= implode( ', ', $section_names );
|
||||
|
||||
} elseif ( $column == 'sp_order' ) {
|
||||
|
||||
@@ -10,404 +10,447 @@
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.7.9
|
||||
*/
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Admin_Welcome class.
|
||||
*/
|
||||
class SP_Admin_Welcome {
|
||||
|
||||
private $plugin;
|
||||
private $plugin;
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->plugin = 'sportspress/sportspress.php';
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->plugin = 'sportspress/sportspress.php';
|
||||
|
||||
add_action( 'admin_menu', array( $this, 'admin_menus') );
|
||||
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
||||
add_action( 'admin_init', array( $this, 'welcome' ) );
|
||||
}
|
||||
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
|
||||
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
||||
add_action( 'admin_init', array( $this, 'welcome' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add admin menus/screens
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function admin_menus() {
|
||||
if ( empty( $_GET['page'] ) ) {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Add admin menus/screens
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function admin_menus() {
|
||||
if ( empty( $_GET['page'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$welcome_page_name = __( 'About SportsPress', 'sportspress' );
|
||||
$welcome_page_title = __( 'Welcome to SportsPress', 'sportspress' );
|
||||
$welcome_page_name = __( 'About SportsPress', 'sportspress' );
|
||||
$welcome_page_title = __( 'Welcome to SportsPress', 'sportspress' );
|
||||
|
||||
switch ( $_GET['page'] ) {
|
||||
case 'sp-about' :
|
||||
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-about', array( $this, 'about_screen' ) );
|
||||
add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
|
||||
break;
|
||||
case 'sp-credits' :
|
||||
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-credits', array( $this, 'credits_screen' ) );
|
||||
add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
|
||||
break;
|
||||
case 'sp-translators' :
|
||||
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-translators', array( $this, 'translators_screen' ) );
|
||||
add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch ( $_GET['page'] ) {
|
||||
case 'sp-about':
|
||||
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-about', array( $this, 'about_screen' ) );
|
||||
add_action( 'admin_print_styles-' . $page, array( $this, 'admin_css' ) );
|
||||
break;
|
||||
case 'sp-credits':
|
||||
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-credits', array( $this, 'credits_screen' ) );
|
||||
add_action( 'admin_print_styles-' . $page, array( $this, 'admin_css' ) );
|
||||
break;
|
||||
case 'sp-translators':
|
||||
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-translators', array( $this, 'translators_screen' ) );
|
||||
add_action( 'admin_print_styles-' . $page, array( $this, 'admin_css' ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* admin_css function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function admin_css() {
|
||||
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ), array(), SP_VERSION );
|
||||
}
|
||||
/**
|
||||
* admin_css function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function admin_css() {
|
||||
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ), array(), SP_VERSION );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add styles just for this page, and remove dashboard page links.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function admin_head() {
|
||||
remove_submenu_page( 'index.php', 'sp-about' );
|
||||
remove_submenu_page( 'index.php', 'sp-credits' );
|
||||
remove_submenu_page( 'index.php', 'sp-translators' );
|
||||
}
|
||||
/**
|
||||
* Add styles just for this page, and remove dashboard page links.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function admin_head() {
|
||||
remove_submenu_page( 'index.php', 'sp-about' );
|
||||
remove_submenu_page( 'index.php', 'sp-credits' );
|
||||
remove_submenu_page( 'index.php', 'sp-translators' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Into text/links shown on all about pages.
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function intro() {
|
||||
/**
|
||||
* Into text/links shown on all about pages.
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function intro() {
|
||||
|
||||
// Flush after upgrades
|
||||
if ( ! empty( $_GET['sp-updated'] ) || ! empty( $_GET['sp-installed'] ) )
|
||||
flush_rewrite_rules();
|
||||
// Flush after upgrades
|
||||
if ( ! empty( $_GET['sp-updated'] ) || ! empty( $_GET['sp-installed'] ) ) {
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
|
||||
// Get major version number
|
||||
$version = explode( '.', SP()->version, 3 );
|
||||
unset( $version[2] );
|
||||
$display_version = implode( '.', $version );
|
||||
?>
|
||||
<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>
|
||||
// Get major version number
|
||||
$version = explode( '.', SP()->version, 3 );
|
||||
unset( $version[2] );
|
||||
$display_version = implode( '.', $version );
|
||||
?>
|
||||
<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>
|
||||
|
||||
<div class="sp-badge"><?php printf( __( 'Version %s', 'sportspress' ), SP()->version ); ?></div>
|
||||
<div class="sp-badge"><?php printf( __( 'Version %s', 'sportspress' ), SP()->version ); ?></div>
|
||||
|
||||
<div class="about-text sp-about-text">
|
||||
<?php
|
||||
if ( ! empty( $_GET['sp-installed'] ) )
|
||||
$message = __( 'Thanks, all done!', 'sportspress' );
|
||||
elseif ( ! empty( $_GET['sp-updated'] ) )
|
||||
$message = __( 'Thank you for updating to the latest version!', 'sportspress' );
|
||||
else
|
||||
$message = __( 'Thanks for installing!', 'sportspress' );
|
||||
<div class="about-text sp-about-text">
|
||||
<?php
|
||||
if ( ! empty( $_GET['sp-installed'] ) ) {
|
||||
$message = __( 'Thanks, all done!', 'sportspress' );
|
||||
} elseif ( ! empty( $_GET['sp-updated'] ) ) {
|
||||
$message = __( 'Thank you for updating to the latest version!', 'sportspress' );
|
||||
} else {
|
||||
$message = __( 'Thanks for installing!', 'sportspress' );
|
||||
}
|
||||
|
||||
printf( __( '%s SportsPress %s has lots of refinements we think you’ll love.', 'sportspress' ), $message, $display_version );
|
||||
?>
|
||||
</div>
|
||||
printf( __( '%1$s SportsPress %2$s has lots of refinements we think you’ll love.', 'sportspress' ), $message, $display_version );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<p class="sportspress-actions">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</p>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</p>
|
||||
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<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' ) ) ); ?>">
|
||||
<?php _e( 'Welcome', 'sportspress' ); ?>
|
||||
</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' ) ) ); ?>">
|
||||
<?php _e( 'Credits', 'sportspress' ); ?>
|
||||
</a>
|
||||
</h2>
|
||||
<?php
|
||||
}
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<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' ) ) ); ?>">
|
||||
<?php _e( 'Welcome', 'sportspress' ); ?>
|
||||
</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' ) ) ); ?>">
|
||||
<?php _e( 'Credits', 'sportspress' ); ?>
|
||||
</a>
|
||||
</h2>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the about screen.
|
||||
*/
|
||||
public function about_screen() {
|
||||
include_once( 'class-sp-admin-settings.php' );
|
||||
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
|
||||
?>
|
||||
<div class="wrap about-wrap about-sportspress-wrap">
|
||||
/**
|
||||
* Output the about screen.
|
||||
*/
|
||||
public function about_screen() {
|
||||
include_once 'class-sp-admin-settings.php';
|
||||
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
|
||||
?>
|
||||
<div class="wrap about-wrap about-sportspress-wrap">
|
||||
|
||||
<?php $this->intro(); ?>
|
||||
<?php $this->intro(); ?>
|
||||
|
||||
<?php
|
||||
// Save settings
|
||||
if ( isset( $_POST['timezone_string'] ) ):
|
||||
update_option( 'timezone_string', sanitize_text_field( $_POST['timezone_string'] ) );
|
||||
update_option( 'sportspress_basic_setup', 1 );
|
||||
endif;
|
||||
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) ):
|
||||
$sport = sanitize_text_field( $_POST['sportspress_sport'] );
|
||||
SP_Admin_Sports::apply_preset( $sport );
|
||||
update_option( 'sportspress_sport', $sport );
|
||||
delete_option( '_sp_needs_welcome' );
|
||||
update_option( 'sportspress_installed', 1 );
|
||||
?>
|
||||
<div id="message" class="updated sportspress-message">
|
||||
<p><strong><?php _e( 'Your settings have been saved.', 'sportspress' ); ?></strong></p>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
if ( isset( $_POST['add_sample_data'] ) ):
|
||||
SP_Admin_Sample_Data::delete_posts();
|
||||
SP_Admin_Sample_Data::insert_posts();
|
||||
endif;
|
||||
<?php
|
||||
// Save settings
|
||||
if ( isset( $_POST['timezone_string'] ) ) :
|
||||
update_option( 'timezone_string', sanitize_text_field( $_POST['timezone_string'] ) );
|
||||
update_option( 'sportspress_basic_setup', 1 );
|
||||
endif;
|
||||
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) ) :
|
||||
$sport = sanitize_text_field( $_POST['sportspress_sport'] );
|
||||
SP_Admin_Sports::apply_preset( $sport );
|
||||
update_option( 'sportspress_sport', $sport );
|
||||
delete_option( '_sp_needs_welcome' );
|
||||
update_option( 'sportspress_installed', 1 );
|
||||
?>
|
||||
<div id="message" class="updated sportspress-message">
|
||||
<p><strong><?php _e( 'Your settings have been saved.', 'sportspress' ); ?></strong></p>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
if ( isset( $_POST['add_sample_data'] ) ) :
|
||||
SP_Admin_Sample_Data::delete_posts();
|
||||
SP_Admin_Sample_Data::insert_posts();
|
||||
endif;
|
||||
|
||||
do_action( 'sportspress_before_welcome_features' );
|
||||
?>
|
||||
<div class="feature-section one-col">
|
||||
<div class="col">
|
||||
<h2>New Features 🌟</h2>
|
||||
</div>
|
||||
</div>
|
||||
do_action( 'sportspress_before_welcome_features' );
|
||||
?>
|
||||
<div class="feature-section one-col">
|
||||
<div class="col">
|
||||
<h2>New Features 🌟</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="feature-section three-col">
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-conditional-equations.png" alt="Screenshot">
|
||||
<h3>Conditional Equations</h3>
|
||||
<p>Use the newly introduced conditional operators <strong>></strong>, <strong><</strong>, <strong>≡</strong>, <strong>≠</strong>, <strong>≥</strong>, and <strong>≤</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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-event-specs.png" alt="Screenshot">
|
||||
<h3>Event Specs</h3>
|
||||
<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.
|
||||
</div>
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-next-team.png" alt="Screenshot">
|
||||
<h3>Next Team Column</h3>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="feature-section three-col">
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-conditional-equations.png" alt="Screenshot">
|
||||
<h3>Conditional Equations</h3>
|
||||
<p>Use the newly introduced conditional operators <strong>></strong>, <strong><</strong>, <strong>≡</strong>, <strong>≠</strong>, <strong>≥</strong>, and <strong>≤</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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-event-specs.png" alt="Screenshot">
|
||||
<h3>Event Specs</h3>
|
||||
<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.
|
||||
</div>
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-next-team.png" alt="Screenshot">
|
||||
<h3>Next Team Column</h3>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( ! class_exists( 'SportsPress_Pro' ) ) { ?>
|
||||
<hr>
|
||||
<?php if ( ! class_exists( 'SportsPress_Pro' ) ) { ?>
|
||||
<hr>
|
||||
|
||||
<div class="feature-section one-col">
|
||||
<div class="col">
|
||||
<h2>SportsPress Pro Updates 🏆</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="feature-section one-col">
|
||||
<div class="col">
|
||||
<h2>SportsPress Pro Updates 🏆</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="feature-section three-col">
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-results-matrix.png" alt="Results Matrix">
|
||||
<h3>Results Matrix</h3>
|
||||
<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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-midseason-transfers.png" alt="Midseason Transfers">
|
||||
<h3>Midseason Transfers</h3>
|
||||
<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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-vertical-timelines.png" alt="Vertical Timelines">
|
||||
<h3>Vertical Timelines</h3>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="feature-section three-col">
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-results-matrix.png" alt="Results Matrix">
|
||||
<h3>Results Matrix</h3>
|
||||
<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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-midseason-transfers.png" alt="Midseason Transfers">
|
||||
<h3>Midseason Transfers</h3>
|
||||
<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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<img src="<?php echo plugin_dir_url( SP_PLUGIN_FILE ); ?>assets/images/welcome/screenshot-vertical-timelines.png" alt="Vertical Timelines">
|
||||
<h3>Vertical Timelines</h3>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<?php } ?>
|
||||
<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>
|
||||
<?php } ?>
|
||||
|
||||
<hr>
|
||||
<hr>
|
||||
|
||||
<div class="feature-section one-col">
|
||||
<div class="col">
|
||||
<h2>Player Data Improvements</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="feature-section one-col">
|
||||
<div class="col">
|
||||
<h2>Player Data Improvements</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="feature-section three-col">
|
||||
<div class="col">
|
||||
<h3>Player Assignments</h3>
|
||||
<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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h3>Current Team Column</h3>
|
||||
<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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h3>Squad Number Zero</h3>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="feature-section three-col">
|
||||
<div class="col">
|
||||
<h3>Player Assignments</h3>
|
||||
<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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h3>Current Team Column</h3>
|
||||
<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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h3>Squad Number Zero</h3>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<hr>
|
||||
|
||||
<div class="feature-section one-col">
|
||||
<div class="col">
|
||||
<h2>Other Notes</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="feature-section one-col">
|
||||
<div class="col">
|
||||
<h2>Other Notes</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="feature-section three-col">
|
||||
<div class="col">
|
||||
<h3>Countdown Images</h3>
|
||||
<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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h3>Relative Date in Shortcodes</h3>
|
||||
<p>You'll now be able to select a relative date range when inserting calendar-related shortcodes from the visual editor.</p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h3>Short Names</h3>
|
||||
<p>Teams have been given a <strong>Short Name</strong> setting in addition to the existing <strong>Abbreviation</strong> for added customizability.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="feature-section three-col">
|
||||
<div class="col">
|
||||
<h3>Countdown Images</h3>
|
||||
<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>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h3>Relative Date in Shortcodes</h3>
|
||||
<p>You'll now be able to select a relative date range when inserting calendar-related shortcodes from the visual editor.</p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h3>Short Names</h3>
|
||||
<p>Teams have been given a <strong>Short Name</strong> setting in addition to the existing <strong>Abbreviation</strong> for added customizability.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'sportspress_after_welcome_features' ); ?>
|
||||
<?php do_action( 'sportspress_after_welcome_features' ); ?>
|
||||
<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>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
<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>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* Output the credits.
|
||||
*/
|
||||
public function credits_screen() {
|
||||
?>
|
||||
<div class="wrap about-wrap about-sportspress-wrap">
|
||||
<?php $this->intro(); ?>
|
||||
|
||||
<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>
|
||||
|
||||
/**
|
||||
* Output the credits.
|
||||
*/
|
||||
public function credits_screen() {
|
||||
?>
|
||||
<div class="wrap about-wrap about-sportspress-wrap">
|
||||
<?php $this->intro(); ?>
|
||||
|
||||
<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>
|
||||
<div class="sp-feature feature-section col one-col">
|
||||
<?php echo wp_kses_post( $this->contributors() ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
<div class="sp-feature feature-section col one-col">
|
||||
<?php echo wp_kses_post( $this->contributors() ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* Output the translators screen
|
||||
*/
|
||||
public function translators_screen() {
|
||||
?>
|
||||
<div class="wrap about-wrap about-sportspress-wrap">
|
||||
|
||||
/**
|
||||
* Output the translators screen
|
||||
*/
|
||||
public function translators_screen() {
|
||||
?>
|
||||
<div class="wrap about-wrap about-sportspress-wrap">
|
||||
<?php $this->intro(); ?>
|
||||
|
||||
<?php $this->intro(); ?>
|
||||
<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>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
<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>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* Render Contributors List
|
||||
*
|
||||
* @access public
|
||||
* @return string $contributor_list HTML formatted list of contributors.
|
||||
*/
|
||||
public function contributors() {
|
||||
$contributors = $this->get_contributors();
|
||||
|
||||
/**
|
||||
* Render Contributors List
|
||||
*
|
||||
* @access public
|
||||
* @return string $contributor_list HTML formatted list of contributors.
|
||||
*/
|
||||
public function contributors() {
|
||||
$contributors = $this->get_contributors();
|
||||
if ( empty( $contributors ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( empty( $contributors ) ) {
|
||||
return '';
|
||||
}
|
||||
$contributor_list = '<ul class="wp-people-group">';
|
||||
|
||||
$contributor_list = '<ul class="wp-people-group">';
|
||||
foreach ( $contributors as $contributor ) {
|
||||
$contributor_list .= '<li class="wp-person">';
|
||||
$contributor_list .= sprintf(
|
||||
'<a href="%s" title="%s">',
|
||||
esc_url( 'https://github.com/' . $contributor->login ),
|
||||
esc_html( sprintf( __( 'View %s', 'sportspress' ), $contributor->login ) )
|
||||
);
|
||||
$contributor_list .= sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) );
|
||||
$contributor_list .= '</a>';
|
||||
$contributor_list .= sprintf( '<a class="web" href="%s">%s</a>', esc_url( 'https://github.com/' . $contributor->login ), esc_html( $contributor->login ) );
|
||||
$contributor_list .= '</a>';
|
||||
$contributor_list .= '</li>';
|
||||
}
|
||||
|
||||
foreach ( $contributors as $contributor ) {
|
||||
$contributor_list .= '<li class="wp-person">';
|
||||
$contributor_list .= sprintf( '<a href="%s" title="%s">',
|
||||
esc_url( 'https://github.com/' . $contributor->login ),
|
||||
esc_html( sprintf( __( 'View %s', 'sportspress' ), $contributor->login ) )
|
||||
);
|
||||
$contributor_list .= sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) );
|
||||
$contributor_list .= '</a>';
|
||||
$contributor_list .= sprintf( '<a class="web" href="%s">%s</a>', esc_url( 'https://github.com/' . $contributor->login ), esc_html( $contributor->login ) );
|
||||
$contributor_list .= '</a>';
|
||||
$contributor_list .= '</li>';
|
||||
}
|
||||
$contributor_list .= '</ul>';
|
||||
|
||||
$contributor_list .= '</ul>';
|
||||
return $contributor_list;
|
||||
}
|
||||
|
||||
return $contributor_list;
|
||||
}
|
||||
/**
|
||||
* Retrieve list of contributors from GitHub.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_contributors() {
|
||||
$contributors = get_transient( 'sportspress_contributors' );
|
||||
|
||||
/**
|
||||
* Retrieve list of contributors from GitHub.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_contributors() {
|
||||
$contributors = get_transient( 'sportspress_contributors' );
|
||||
if ( false !== $contributors ) {
|
||||
return $contributors;
|
||||
}
|
||||
|
||||
if ( false !== $contributors ) {
|
||||
return $contributors;
|
||||
}
|
||||
$response = wp_remote_get( 'https://api.github.com/repos/ThemeBoy/SportsPress/contributors', array( 'sslverify' => false ) );
|
||||
|
||||
$response = wp_remote_get( 'https://api.github.com/repos/ThemeBoy/SportsPress/contributors', array( 'sslverify' => false ) );
|
||||
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
|
||||
return array();
|
||||
}
|
||||
$contributors = json_decode( wp_remote_retrieve_body( $response ) );
|
||||
|
||||
$contributors = json_decode( wp_remote_retrieve_body( $response ) );
|
||||
if ( ! is_array( $contributors ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ( ! is_array( $contributors ) ) {
|
||||
return array();
|
||||
}
|
||||
set_transient( 'sportspress_contributors', $contributors, HOUR_IN_SECONDS );
|
||||
|
||||
set_transient( 'sportspress_contributors', $contributors, HOUR_IN_SECONDS );
|
||||
return $contributors;
|
||||
}
|
||||
|
||||
return $contributors;
|
||||
}
|
||||
/**
|
||||
* Sends user to the welcome page on first activation
|
||||
*/
|
||||
public function welcome() {
|
||||
|
||||
/**
|
||||
* Sends user to the welcome page on first activation
|
||||
*/
|
||||
public function welcome() {
|
||||
// Bail if no activation redirect transient is set
|
||||
if ( ! get_transient( '_sp_activation_redirect' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bail if no activation redirect transient is set
|
||||
if ( ! get_transient( '_sp_activation_redirect' ) )
|
||||
return;
|
||||
// Delete the redirect transient
|
||||
delete_transient( '_sp_activation_redirect' );
|
||||
|
||||
// Delete the redirect transient
|
||||
delete_transient( '_sp_activation_redirect' );
|
||||
// Bail if we are waiting to install or update via the interface update/install links
|
||||
if ( get_option( '_sp_needs_update' ) == 1 || get_option( '_sp_needs_pages' ) == 1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bail if we are waiting to install or update via the interface update/install links
|
||||
if ( get_option( '_sp_needs_update' ) == 1 || get_option( '_sp_needs_pages' ) == 1 )
|
||||
return;
|
||||
// Bail if activating from network, or bulk, or within an iFrame
|
||||
if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bail if activating from network, or bulk, or within an iFrame
|
||||
if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) )
|
||||
return;
|
||||
if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] ) && ( isset( $_GET['plugin'] ) && strstr( $_GET['plugin'], 'sportspress.php' ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] ) && ( isset( $_GET['plugin'] ) && strstr( $_GET['plugin'], 'sportspress.php' ) ) )
|
||||
return;
|
||||
if ( ! get_option( 'sportspress_completed_setup' ) ) {
|
||||
wp_redirect( admin_url( 'admin.php?page=sp-setup' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! get_option( 'sportspress_completed_setup' ) ) {
|
||||
wp_redirect( admin_url( 'admin.php?page=sp-setup' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
wp_redirect( admin_url( 'index.php?page=sp-about' ) );
|
||||
exit;
|
||||
}
|
||||
wp_redirect( admin_url( 'index.php?page=sp-about' ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
new SP_Admin_Welcome();
|
||||
|
||||
@@ -6,11 +6,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
/**
|
||||
* SportsPress Admin.
|
||||
*
|
||||
* @class SP_Admin
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.5.1
|
||||
* @class SP_Admin
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 2.5.1
|
||||
*/
|
||||
class SP_Admin {
|
||||
|
||||
@@ -36,32 +36,32 @@ class SP_Admin {
|
||||
*/
|
||||
public function includes() {
|
||||
// Functions
|
||||
include_once( 'sp-admin-functions.php' );
|
||||
include_once 'sp-admin-functions.php';
|
||||
|
||||
// Classes
|
||||
include_once( 'class-sp-admin-post-types.php' );
|
||||
include_once( 'class-sp-admin-taxonomies.php' );
|
||||
include_once( 'class-sp-admin-ajax.php' );
|
||||
include_once 'class-sp-admin-post-types.php';
|
||||
include_once 'class-sp-admin-taxonomies.php';
|
||||
include_once 'class-sp-admin-ajax.php';
|
||||
|
||||
// Classes we only need if the ajax is not-ajax
|
||||
if ( ! is_ajax() ) {
|
||||
include( 'class-sp-admin-menus.php' );
|
||||
include( 'class-sp-admin-welcome.php' );
|
||||
include( 'class-sp-admin-notices.php' );
|
||||
include( 'class-sp-admin-assets.php' );
|
||||
include( 'class-sp-admin-permalink-settings.php' );
|
||||
include 'class-sp-admin-menus.php';
|
||||
include 'class-sp-admin-welcome.php';
|
||||
include 'class-sp-admin-notices.php';
|
||||
include 'class-sp-admin-assets.php';
|
||||
include 'class-sp-admin-permalink-settings.php';
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_rich_editing', 'yes' ) ):
|
||||
include( 'class-sp-admin-editor.php' );
|
||||
if ( 'yes' == get_option( 'sportspress_rich_editing', 'yes' ) ) :
|
||||
include 'class-sp-admin-editor.php';
|
||||
endif;
|
||||
}
|
||||
|
||||
// Setup/welcome
|
||||
if ( ! empty( $_GET['page'] ) ) {
|
||||
switch ( $_GET['page'] ) {
|
||||
case 'sp-setup' :
|
||||
include_once( 'class-sp-admin-setup-wizard.php' );
|
||||
break;
|
||||
case 'sp-setup':
|
||||
include_once 'class-sp-admin-setup-wizard.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,8 +73,8 @@ class SP_Admin {
|
||||
$screen = get_current_screen();
|
||||
|
||||
switch ( $screen->id ) {
|
||||
case 'dashboard' :
|
||||
include( 'class-sp-admin-dashboard.php' );
|
||||
case 'dashboard':
|
||||
include 'class-sp-admin-dashboard.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class SP_Admin {
|
||||
public function prevent_admin_access() {
|
||||
$prevent_access = false;
|
||||
|
||||
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' ) {
|
||||
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' ) {
|
||||
$prevent_access = true;
|
||||
}
|
||||
|
||||
@@ -134,4 +134,4 @@ class SP_Admin {
|
||||
}
|
||||
}
|
||||
|
||||
return new SP_Admin();
|
||||
return new SP_Admin();
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Event importer - import events into SportsPress.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Importer' ) ) {
|
||||
class SP_Event_Importer extends SP_Importer {
|
||||
@@ -20,20 +22,21 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->import_page = 'sp_event_csv';
|
||||
$this->import_page = 'sp_event_csv';
|
||||
$this->import_label = __( 'Import Events', 'sportspress' );
|
||||
$this->columns = array(
|
||||
'post_date' => __( 'Date', 'sportspress' ),
|
||||
'post_time' => __( 'Time', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
$this->columns = array(
|
||||
'post_date' => __( 'Date', 'sportspress' ),
|
||||
'post_time' => __( 'Time', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_results' => __( 'Results', 'sportspress' ),
|
||||
'sp_outcome' => __( 'Outcome', 'sportspress' ),
|
||||
'sp_player' => __( 'Players', 'sportspress' ),
|
||||
'sp_player' => __( 'Players', 'sportspress' ),
|
||||
);
|
||||
$performance_labels = sp_get_var_labels( 'sp_performance' );
|
||||
if ( $performance_labels && is_array( $performance_labels ) && sizeof( $performance_labels ) )
|
||||
if ( $performance_labels && is_array( $performance_labels ) && sizeof( $performance_labels ) ) {
|
||||
$this->columns = array_merge( $this->columns, $performance_labels );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +50,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||
$this->imported = $this->skipped = 0;
|
||||
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||
$this->footer();
|
||||
die();
|
||||
endif;
|
||||
@@ -56,29 +59,31 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Get event format, league, and season from post vars
|
||||
$event_format = ( empty( $_POST['sp_format'] ) ? false : sanitize_text_field( $_POST['sp_format'] ) );
|
||||
$league = ( sp_array_value( $_POST, 'sp_league', '-1' ) == '-1' ? false : sanitize_text_field( $_POST['sp_league'] ) );
|
||||
$season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : sanitize_text_field( $_POST['sp_season'] ) );
|
||||
$date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : sanitize_text_field( $_POST['sp_date_format'] ) );
|
||||
$league = ( sp_array_value( $_POST, 'sp_league', '-1' ) == '-1' ? false : sanitize_text_field( $_POST['sp_league'] ) );
|
||||
$season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : sanitize_text_field( $_POST['sp_season'] ) );
|
||||
$date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : sanitize_text_field( $_POST['sp_date_format'] ) );
|
||||
|
||||
// Get labels from result and performance post types
|
||||
$result_labels = sp_get_var_labels( 'sp_result' );
|
||||
$result_labels = sp_get_var_labels( 'sp_result' );
|
||||
$performance_labels = sp_get_var_labels( 'sp_performance' );
|
||||
|
||||
foreach ( $rows as $row ):
|
||||
foreach ( $rows as $row ) :
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
foreach ( $columns as $index => $key ):
|
||||
foreach ( $columns as $index => $key ) :
|
||||
$meta[ $key ] = sp_array_value( $row, $index );
|
||||
endforeach;
|
||||
|
||||
// Slice array into event, team, and player
|
||||
$event = array_slice( $row, 0, 3 );
|
||||
$team = array_slice( $row, 3, 3 );
|
||||
$event = array_slice( $row, 0, 3 );
|
||||
$team = array_slice( $row, 3, 3 );
|
||||
$player = array_slice( $row, 6 );
|
||||
|
||||
// Get event details
|
||||
@@ -105,16 +110,16 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$player = array(
|
||||
sp_array_value( $meta, 'sp_player' ),
|
||||
);
|
||||
unset( $meta['sp_player' ] );
|
||||
foreach ( $performance_labels as $key => $label ):
|
||||
unset( $meta['sp_player'] );
|
||||
foreach ( $performance_labels as $key => $label ) :
|
||||
$player[] = sp_array_value( $meta, $key, '' );
|
||||
endforeach;
|
||||
|
||||
// Add new event if date is given
|
||||
if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ):
|
||||
if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ) :
|
||||
|
||||
// Add player performance to last event if available
|
||||
if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ):
|
||||
if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ) :
|
||||
update_post_meta( $id, 'sp_players', $players );
|
||||
endif;
|
||||
|
||||
@@ -122,9 +127,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
list( $date, $time, $venue ) = $event;
|
||||
|
||||
// Format date
|
||||
$date = str_replace( '/', '-', trim( $date ) );
|
||||
$date = str_replace( '/', '-', trim( $date ) );
|
||||
$date_array = explode( '-', $date );
|
||||
switch ( $date_format ):
|
||||
switch ( $date_format ) :
|
||||
case 'dd/mm/yyyy':
|
||||
$date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
|
||||
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' ) ) {
|
||||
endswitch;
|
||||
|
||||
// Add time to date if given
|
||||
if ( ! empty( $time ) ):
|
||||
if ( ! empty( $time ) ) :
|
||||
$date .= ' ' . trim( $time );
|
||||
endif;
|
||||
|
||||
// Define post type args
|
||||
$args = array( 'post_type' => 'sp_event', 'post_status' => 'publish', 'post_date' => $date, 'post_title' => __( 'Event', 'sportspress' ) );
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'post_status' => 'publish',
|
||||
'post_date' => $date,
|
||||
'post_title' => __( 'Event', 'sportspress' ),
|
||||
);
|
||||
|
||||
// Insert event
|
||||
$id = wp_insert_post( $args );
|
||||
@@ -159,17 +169,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
update_post_meta( $id, '_sp_import', 1 );
|
||||
|
||||
// Update event format
|
||||
if ( $event_format ):
|
||||
if ( $event_format ) :
|
||||
update_post_meta( $id, 'sp_format', $event_format );
|
||||
endif;
|
||||
|
||||
// Update league
|
||||
if ( $league ):
|
||||
if ( $league ) :
|
||||
wp_set_object_terms( $id, $league, 'sp_league', false );
|
||||
endif;
|
||||
|
||||
// Update season
|
||||
if ( $season ):
|
||||
if ( $season ) :
|
||||
wp_set_object_terms( $id, $season, 'sp_season', false );
|
||||
endif;
|
||||
|
||||
@@ -182,7 +192,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
endif;
|
||||
|
||||
// Add new team if team name is given
|
||||
if ( sizeof( $team ) > 0 && ! empty( $team[0] ) ):
|
||||
if ( sizeof( $team ) > 0 && ! empty( $team[0] ) ) :
|
||||
|
||||
// List team columns
|
||||
list( $team_name, $result, $outcome ) = $team;
|
||||
@@ -191,20 +201,31 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$team_object = get_page_by_title( stripslashes( $team_name ), OBJECT, 'sp_team' );
|
||||
|
||||
// Get or insert team
|
||||
if ( $team_object ):
|
||||
if ( $team_object ) :
|
||||
|
||||
// Make sure team is published
|
||||
if ( $team_object->post_status != 'publish' ):
|
||||
wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
|
||||
if ( $team_object->post_status != 'publish' ) :
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $team_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
|
||||
// Get team ID
|
||||
$team_id = $team_object->ID;
|
||||
|
||||
else:
|
||||
else :
|
||||
|
||||
// Insert team
|
||||
$team_id = wp_insert_post( array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $team_name ) ) );
|
||||
$team_id = wp_insert_post(
|
||||
array(
|
||||
'post_type' => 'sp_team',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $team_name ),
|
||||
)
|
||||
);
|
||||
|
||||
// Flag as import
|
||||
update_post_meta( $team_id, '_sp_import', 1 );
|
||||
@@ -212,17 +233,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
endif;
|
||||
|
||||
// Update league
|
||||
if ( $league ):
|
||||
if ( $league ) :
|
||||
wp_set_object_terms( $team_id, $league, 'sp_league', true );
|
||||
endif;
|
||||
|
||||
// Update season
|
||||
if ( $season ):
|
||||
if ( $season ) :
|
||||
wp_set_object_terms( $team_id, $season, 'sp_season', true );
|
||||
endif;
|
||||
|
||||
// Add to event if exists
|
||||
if ( isset( $id ) ):
|
||||
if ( isset( $id ) ) :
|
||||
|
||||
// Add team to event
|
||||
add_post_meta( $id, 'sp_team', $team_id );
|
||||
@@ -235,21 +256,21 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Create team results array from result keys
|
||||
$team_results = array();
|
||||
if ( sizeof( $result_labels ) > 0 ):
|
||||
foreach( $result_labels as $key => $label ):
|
||||
if ( sizeof( $result_labels ) > 0 ) :
|
||||
foreach ( $result_labels as $key => $label ) :
|
||||
$team_results[ $key ] = trim( array_shift( $results ) );
|
||||
endforeach;
|
||||
$team_results[ 'outcome' ] = array();
|
||||
$team_results['outcome'] = array();
|
||||
endif;
|
||||
|
||||
// Explode outcomes into array
|
||||
$outcomes = explode( '|', $outcome );
|
||||
|
||||
// Add outcome slugs to team outcomes array
|
||||
foreach ( $outcomes as $outcome ):
|
||||
foreach ( $outcomes as $outcome ) :
|
||||
|
||||
// Continue if outcome doesn't exist
|
||||
if ( $outcome == null ):
|
||||
if ( $outcome == null ) :
|
||||
continue;
|
||||
endif;
|
||||
|
||||
@@ -259,24 +280,35 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
// Get or insert outcome
|
||||
$outcome_object = get_page_by_title( stripslashes( $outcome ), OBJECT, 'sp_outcome' );
|
||||
|
||||
if ( $outcome_object ):
|
||||
if ( $outcome_object ) :
|
||||
|
||||
// Make sure outcome is published
|
||||
if ( $outcome_object->post_status != 'publish' ):
|
||||
wp_update_post( array( 'ID' => $outcome_object->ID, 'post_status' => 'publish' ) );
|
||||
if ( $outcome_object->post_status != 'publish' ) :
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $outcome_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
|
||||
// Get outcome slug
|
||||
$outcome_slug = $outcome_object->post_name;
|
||||
|
||||
else:
|
||||
else :
|
||||
|
||||
// Insert outcome
|
||||
$outcome_id = wp_insert_post( array( 'post_type' => 'sp_outcome', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $outcome ) ) );
|
||||
$outcome_id = wp_insert_post(
|
||||
array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $outcome ),
|
||||
)
|
||||
);
|
||||
|
||||
// Get outcome slug
|
||||
$post_data = get_post( $outcome_id, ARRAY_A );
|
||||
$outcome_slug = $post_data['post_name'];
|
||||
$post_data = get_post( $outcome_id, ARRAY_A );
|
||||
$outcome_slug = $post_data['post_name'];
|
||||
|
||||
// Flag as import
|
||||
update_post_meta( $outcome_id, '_sp_import', 1 );
|
||||
@@ -284,7 +316,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
endif;
|
||||
|
||||
// Add to team results array
|
||||
$team_results[ 'outcome' ][] = $outcome_slug;
|
||||
$team_results['outcome'][] = $outcome_slug;
|
||||
|
||||
endforeach;
|
||||
|
||||
@@ -292,7 +324,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$event_results = get_post_meta( $id, 'sp_results', true );
|
||||
|
||||
// Create new array if results not exists
|
||||
if ( ! $event_results ):
|
||||
if ( ! $event_results ) :
|
||||
$event_results = array();
|
||||
endif;
|
||||
|
||||
@@ -317,9 +349,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Update event with new name
|
||||
$post = array(
|
||||
'ID' => $id,
|
||||
'ID' => $id,
|
||||
'post_title' => $title,
|
||||
'post_name' => $id,
|
||||
'post_name' => $id,
|
||||
);
|
||||
wp_update_post( $post );
|
||||
|
||||
@@ -328,7 +360,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
endif;
|
||||
|
||||
// Add new player if player name is given
|
||||
if ( sizeof( $player ) > 0 && ! empty( $player[0] ) ):
|
||||
if ( sizeof( $player ) > 0 && ! empty( $player[0] ) ) :
|
||||
|
||||
// Get and unset player name leaving us with the performance
|
||||
$player_name = $player[0];
|
||||
@@ -338,11 +370,16 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
|
||||
|
||||
// Get or insert player
|
||||
if ( $player_object ):
|
||||
if ( $player_object ) :
|
||||
|
||||
// Make sure player is published
|
||||
if ( $player_object->post_status != 'publish' ):
|
||||
wp_update_post( array( 'ID' => $player_object->ID, 'post_status' => 'publish' ) );
|
||||
if ( $player_object->post_status != 'publish' ) :
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $player_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
|
||||
// Get player ID
|
||||
@@ -351,10 +388,16 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
// Get player number
|
||||
$player_number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
else:
|
||||
else :
|
||||
|
||||
// Insert player
|
||||
$player_id = wp_insert_post( array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $player_name ) ) );
|
||||
$player_id = wp_insert_post(
|
||||
array(
|
||||
'post_type' => 'sp_player',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $player_name ),
|
||||
)
|
||||
);
|
||||
|
||||
// Flag as import
|
||||
update_post_meta( $player_id, '_sp_import', 1 );
|
||||
@@ -368,29 +411,29 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
endif;
|
||||
|
||||
// Update league
|
||||
if ( $league ):
|
||||
if ( $league ) :
|
||||
wp_set_object_terms( $player_id, $league, 'sp_league', true );
|
||||
endif;
|
||||
|
||||
// Update season
|
||||
if ( $season ):
|
||||
if ( $season ) :
|
||||
wp_set_object_terms( $player_id, $season, 'sp_season', true );
|
||||
endif;
|
||||
|
||||
// Add to event if exists
|
||||
if ( isset( $id ) ):
|
||||
if ( isset( $id ) ) :
|
||||
|
||||
// Add player to event
|
||||
add_post_meta( $id, 'sp_player', $player_id );
|
||||
|
||||
// Add player performance to array if team is available
|
||||
if ( isset( $team_id ) ):
|
||||
if ( isset( $team_id ) ) :
|
||||
|
||||
// Initialize performance array
|
||||
$performance = array( 'number' => $player_number );
|
||||
|
||||
// Map keys to player performance
|
||||
foreach ( $performance_labels as $key => $label ):
|
||||
foreach ( $performance_labels as $key => $label ) :
|
||||
$performance[ $key ] = array_shift( $player );
|
||||
endforeach;
|
||||
$players[ $team_id ][ $player_id ] = $performance;
|
||||
@@ -398,17 +441,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
// Get player teams
|
||||
$player_teams = get_post_meta( $player_id, 'sp_team', false );
|
||||
$current_team = get_post_meta( $player_id, 'sp_current_team', true );
|
||||
$past_teams = get_post_meta( $player_id, 'sp_past_team', false );
|
||||
$past_teams = get_post_meta( $player_id, 'sp_past_team', false );
|
||||
|
||||
// Add team if not exists in player
|
||||
if ( ! in_array( $team_id, $player_teams ) ):
|
||||
if ( ! in_array( $team_id, $player_teams ) ) :
|
||||
add_post_meta( $player_id, 'sp_team', $team_id );
|
||||
endif;
|
||||
|
||||
// Add as past team or set current team if not set
|
||||
if ( ! $current_team ):
|
||||
if ( ! $current_team ) :
|
||||
update_post_meta( $player_id, 'sp_current_team', $team_id );
|
||||
elseif ( $current_team != $team_id && ! in_array( $team_id, $past_teams ) ):
|
||||
elseif ( $current_team != $team_id && ! in_array( $team_id, $past_teams ) ) :
|
||||
add_post_meta( $player_id, 'sp_past_team', $team_id );
|
||||
endif;
|
||||
|
||||
@@ -421,13 +464,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
endforeach;
|
||||
|
||||
// Add player performance to last event if available
|
||||
if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ):
|
||||
if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ) :
|
||||
update_post_meta( $id, 'sp_players', $players );
|
||||
endif;
|
||||
|
||||
// Show Result
|
||||
echo '<div class="updated settings-error below-h2"><p>
|
||||
'.sprintf( __( 'Import complete - imported <strong>%s</strong> events and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
|
||||
' . sprintf( __( 'Import complete - imported <strong>%1$s</strong> events and skipped <strong>%2$s</strong>.', 'sportspress' ), $this->imported, $this->skipped ) . '
|
||||
</p></div>';
|
||||
|
||||
$this->import_end();
|
||||
@@ -437,7 +480,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* Performs post-import cleanup of files and the cache
|
||||
*/
|
||||
function import_end() {
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_event') . '">' . __( 'View Events', 'sportspress' ) . '</a>' . '</p>';
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_event' ) . '">' . __( 'View Events', 'sportspress' ) . '</a>' . '</p>';
|
||||
|
||||
do_action( 'import_end' );
|
||||
}
|
||||
@@ -450,7 +493,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
*/
|
||||
function greet() {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||
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>';
|
||||
echo '<p>' . sprintf( __( 'Supports CSV files generated by <a href="%s">LeagueLobster</a>.', 'sportspress' ), 'http://tboy.co/leaguelobster' ) . '</p>';
|
||||
wp_import_upload_form( 'admin.php?import=sp_event_csv&step=1' );
|
||||
@@ -473,11 +516,11 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
<fieldset id="post-formats-select">
|
||||
<ul>
|
||||
<?php
|
||||
foreach( (new SP_Formats)->event as $name => $title ) {
|
||||
?>
|
||||
foreach ( ( new SP_Formats() )->event as $name => $title ) {
|
||||
?>
|
||||
<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>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</fieldset>
|
||||
@@ -485,56 +528,60 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php _e( 'League', 'sportspress' ); ?></label><br/></th>
|
||||
<td><?php
|
||||
<td>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'values' => 'slug',
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'values' => 'slug',
|
||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||
);
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ) :
|
||||
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
||||
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
?></td>
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php _e( 'Season', 'sportspress' ); ?></label><br/></th>
|
||||
<td><?php
|
||||
<td>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'values' => 'slug',
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'values' => 'slug',
|
||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||
);
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ) :
|
||||
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
||||
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
?></td>
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" class="titledesc">
|
||||
<?php _e( 'Date Format', 'sportspress' ); ?>
|
||||
</th>
|
||||
<td class="forminp forminp-radio">
|
||||
<fieldset>
|
||||
<ul>
|
||||
<td class="forminp forminp-radio">
|
||||
<fieldset>
|
||||
<ul>
|
||||
<li>
|
||||
<label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
|
||||
</li>
|
||||
<label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
|
||||
</li>
|
||||
<label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
|
||||
</li>
|
||||
<label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Event Performance importer - import box scores into SportsPress.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Importer' ) ) {
|
||||
class SP_Event_Performance_Importer extends SP_Importer {
|
||||
@@ -20,14 +22,15 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->import_page = 'sp_event_performance_csv';
|
||||
$this->import_page = 'sp_event_performance_csv';
|
||||
$this->import_label = __( 'Import Box Score', 'sportspress' );
|
||||
$this->columns = array(
|
||||
$this->columns = array(
|
||||
'sp_player' => __( 'Player', 'sportspress' ),
|
||||
);
|
||||
$performance_labels = sp_get_var_labels( 'sp_performance' );
|
||||
if ( $performance_labels && is_array( $performance_labels ) && sizeof( $performance_labels ) )
|
||||
if ( $performance_labels && is_array( $performance_labels ) && sizeof( $performance_labels ) ) {
|
||||
$this->columns = array_merge( $this->columns, $performance_labels );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +44,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
function import( $array = array(), $columns = array( 'sp_player' ) ) {
|
||||
$this->imported = $this->skipped = 0;
|
||||
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||
$this->footer();
|
||||
die();
|
||||
endif;
|
||||
@@ -52,36 +55,44 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$event = ( empty( $_POST['sp_event'] ) ? false : sanitize_text_field( $_POST['sp_event'] ) );
|
||||
$teams = ( empty( $_POST['sp_teams'] ) ? false : sanitize_text_field( $_POST['sp_teams'] ) );
|
||||
$index = ( empty( $_POST['sp_index'] ) ? false : sanitize_text_field( $_POST['sp_index'] ) );
|
||||
$team = ( empty( $_POST['sp_team'] ) ? false : sanitize_text_field( $_POST['sp_team'] ) );
|
||||
$team = ( empty( $_POST['sp_team'] ) ? false : sanitize_text_field( $_POST['sp_team'] ) );
|
||||
|
||||
$team_players = array( 0 );
|
||||
$team_players = array( 0 );
|
||||
$team_performance = array();
|
||||
$name_index = (int) array_search( 'sp_player', $columns );
|
||||
$name_index = (int) array_search( 'sp_player', $columns );
|
||||
|
||||
foreach ( $rows as $row ):
|
||||
foreach ( $rows as $row ) :
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$player_name = sp_array_value( $row, $name_index );
|
||||
|
||||
if ( ! $player_name ):
|
||||
|
||||
if ( ! $player_name ) :
|
||||
$this->skipped ++;
|
||||
continue;
|
||||
endif;
|
||||
|
||||
$player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
|
||||
|
||||
if ( $player_object ):
|
||||
if ( $player_object ) :
|
||||
|
||||
// Get player ID
|
||||
$player_id = $player_object->ID;
|
||||
|
||||
else:
|
||||
else :
|
||||
|
||||
// Insert player
|
||||
$player_id = wp_insert_post( array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $player_name ) ) );
|
||||
$player_id = wp_insert_post(
|
||||
array(
|
||||
'post_type' => 'sp_player',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $player_name ),
|
||||
)
|
||||
);
|
||||
|
||||
// Flag as import
|
||||
update_post_meta( $player_id, '_sp_import', 1 );
|
||||
@@ -89,10 +100,12 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
endif;
|
||||
|
||||
$team_players[] = $player_id;
|
||||
$player = array();
|
||||
$player = array();
|
||||
|
||||
foreach ( $columns as $i => $key ):
|
||||
if ( 'sp_player' === $key ) continue;
|
||||
foreach ( $columns as $i => $key ) :
|
||||
if ( 'sp_player' === $key ) {
|
||||
continue;
|
||||
}
|
||||
$player[ $key ] = sp_array_value( $row, $i, '' );
|
||||
endforeach;
|
||||
|
||||
@@ -100,13 +113,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
endforeach;
|
||||
|
||||
if ( $event && $team ):
|
||||
if ( $event && $team ) :
|
||||
$the_players = get_post_meta( $event, 'sp_player', false );
|
||||
$players = array();
|
||||
for ( $i = 0; $i < $teams; $i++ ):
|
||||
if ( $index == $i ):
|
||||
$players = array();
|
||||
for ( $i = 0; $i < $teams; $i++ ) :
|
||||
if ( $index == $i ) :
|
||||
array_push( $players, $team_players );
|
||||
else:
|
||||
else :
|
||||
array_push( $players, sp_array_between( $the_players, 0, $i ) );
|
||||
endif;
|
||||
endfor;
|
||||
@@ -114,15 +127,15 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
$this->imported = sizeof( $team_players ) - 1;
|
||||
|
||||
$performance = (array) get_post_meta( $event, 'sp_players', true );
|
||||
$performance = array_filter( $performance );
|
||||
$performance = (array) get_post_meta( $event, 'sp_players', true );
|
||||
$performance = array_filter( $performance );
|
||||
$performance[ $team ] = $team_performance;
|
||||
update_post_meta( $event, 'sp_players', $performance );
|
||||
endif;
|
||||
|
||||
// Show Result
|
||||
echo '<div class="updated settings-error below-h2"><p>
|
||||
'.sprintf( __( 'Import complete - imported <strong>%s</strong> rows and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
|
||||
' . sprintf( __( 'Import complete - imported <strong>%1$s</strong> rows and skipped <strong>%2$s</strong>.', 'sportspress' ), $this->imported, $this->skipped ) . '
|
||||
</p></div>';
|
||||
|
||||
$this->import_end( $event );
|
||||
@@ -132,7 +145,15 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* Performs post-import cleanup of files and the cache
|
||||
*/
|
||||
function import_end( $event = 0 ) {
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( add_query_arg( array( 'post' => $event, 'action' => 'edit' ), 'post.php' ) ) . '">' . __( 'View Event', 'sportspress' ) . '</a>' . '</p>';
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'post' => $event,
|
||||
'action' => 'edit',
|
||||
),
|
||||
'post.php'
|
||||
)
|
||||
) . '">' . __( 'View Event', 'sportspress' ) . '</a>' . '</p>';
|
||||
|
||||
do_action( 'import_end' );
|
||||
}
|
||||
@@ -149,8 +170,14 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
echo '<div class="narrow">';
|
||||
|
||||
if ( $event ) {
|
||||
$args = array_merge( $_REQUEST, array( 'import' => 'sp_event_performance_csv', 'step' => '1' ) );
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||
$args = array_merge(
|
||||
$_REQUEST,
|
||||
array(
|
||||
'import' => 'sp_event_performance_csv',
|
||||
'step' => '1',
|
||||
)
|
||||
);
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||
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>';
|
||||
wp_import_upload_form( add_query_arg( $args, 'admin.php' ) );
|
||||
} else {
|
||||
@@ -167,10 +194,10 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* @return void
|
||||
*/
|
||||
function options() {
|
||||
$event = sp_array_value( $_REQUEST, 'event', 0, 'key' );
|
||||
$teams = sp_array_value( $_REQUEST, 'teams', 0, 'key' );
|
||||
$index = sp_array_value( $_REQUEST, 'index', 0, 'key' );
|
||||
$team = sp_array_value( $_REQUEST, 'team', 0, 'key' );
|
||||
$event = sp_array_value( $_REQUEST, 'event', 0, 'key' );
|
||||
$teams = sp_array_value( $_REQUEST, 'teams', 0, 'key' );
|
||||
$index = sp_array_value( $_REQUEST, 'index', 0, 'key' );
|
||||
$team = sp_array_value( $_REQUEST, 'team', 0, 'key' );
|
||||
$include = get_post_meta( $event, 'sp_team', false );
|
||||
?>
|
||||
<table class="form-table">
|
||||
@@ -192,10 +219,10 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_team',
|
||||
'values' => 'ID',
|
||||
'selected' => $team,
|
||||
'include' => $include,
|
||||
'name' => 'sp_team',
|
||||
'values' => 'ID',
|
||||
'selected' => $team,
|
||||
'include' => $include,
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Fixture importer - import fixtures into SportsPress.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.7
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.7
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Importer' ) ) {
|
||||
class SP_Fixture_Importer extends SP_Importer {
|
||||
@@ -20,17 +22,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->import_page = 'sp_fixture_csv';
|
||||
$this->import_page = 'sp_fixture_csv';
|
||||
$this->import_label = __( 'Import Fixtures', 'sportspress' );
|
||||
$this->columns = array(
|
||||
$this->columns = array(
|
||||
'post_date' => __( 'Date', 'sportspress' ),
|
||||
'post_time' => __( 'Time', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_home' => __( 'Home', 'sportspress' ),
|
||||
'sp_away' => __( 'Away', 'sportspress' ),
|
||||
'sp_day' => __( 'Match Day', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_home' => __( 'Home', 'sportspress' ),
|
||||
'sp_away' => __( 'Away', 'sportspress' ),
|
||||
'sp_day' => __( 'Match Day', 'sportspress' ),
|
||||
);
|
||||
$this->optionals = array( 'sp_day' );
|
||||
$this->optionals = array( 'sp_day' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,7 +46,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||
$this->imported = $this->skipped = 0;
|
||||
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||
$this->footer();
|
||||
die();
|
||||
endif;
|
||||
@@ -53,19 +55,21 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Get event format, league, and season from post vars
|
||||
$event_format = ( empty( $_POST['sp_format'] ) ? false : $_POST['sp_format'] );
|
||||
$league = ( sp_array_value( $_POST, 'sp_league', '-1' ) == '-1' ? false : $_POST['sp_league'] );
|
||||
$season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : $_POST['sp_season'] );
|
||||
$date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : $_POST['sp_date_format'] );
|
||||
$league = ( sp_array_value( $_POST, 'sp_league', '-1' ) == '-1' ? false : $_POST['sp_league'] );
|
||||
$season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : $_POST['sp_season'] );
|
||||
$date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : $_POST['sp_date_format'] );
|
||||
|
||||
foreach ( $rows as $row ):
|
||||
foreach ( $rows as $row ) :
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
foreach ( $columns as $index => $key ):
|
||||
foreach ( $columns as $index => $key ) :
|
||||
$meta[ $key ] = sp_array_value( $row, $index );
|
||||
endforeach;
|
||||
|
||||
@@ -83,15 +87,15 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
);
|
||||
|
||||
// Add new event if date is given
|
||||
if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ):
|
||||
if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ) :
|
||||
|
||||
// List event columns
|
||||
list( $date, $time, $venue, $day ) = $event;
|
||||
|
||||
// Format date
|
||||
$date = str_replace( '/', '-', trim( $date ) );
|
||||
$date = str_replace( '/', '-', trim( $date ) );
|
||||
$date_array = explode( '-', $date );
|
||||
switch ( $date_format ):
|
||||
switch ( $date_format ) :
|
||||
case 'dd/mm/yyyy':
|
||||
$date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
|
||||
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' ) ) {
|
||||
endswitch;
|
||||
|
||||
// Add time to date if given
|
||||
if ( ! empty( $time ) ):
|
||||
if ( ! empty( $time ) ) :
|
||||
$date .= ' ' . trim( $time );
|
||||
endif;
|
||||
|
||||
// Define post type args
|
||||
$args = array( 'post_type' => 'sp_event', 'post_status' => 'publish', 'post_date' => $date, 'post_title' => __( 'Event', 'sportspress' ) );
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'post_status' => 'publish',
|
||||
'post_date' => $date,
|
||||
'post_title' => __( 'Event', 'sportspress' ),
|
||||
);
|
||||
|
||||
// Insert event
|
||||
$id = wp_insert_post( $args );
|
||||
@@ -123,25 +132,25 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
update_post_meta( $id, '_sp_import', 1 );
|
||||
|
||||
// Update event format
|
||||
if ( $event_format ):
|
||||
if ( $event_format ) :
|
||||
update_post_meta( $id, 'sp_format', $event_format );
|
||||
endif;
|
||||
|
||||
// Update league
|
||||
if ( $league ):
|
||||
if ( $league ) :
|
||||
wp_set_object_terms( $id, $league, 'sp_league', false );
|
||||
endif;
|
||||
|
||||
// Update season
|
||||
if ( $season ):
|
||||
if ( $season ) :
|
||||
wp_set_object_terms( $id, $season, 'sp_season', false );
|
||||
endif;
|
||||
|
||||
// Update venue
|
||||
if ( $venue == '' ) {
|
||||
$team = reset( $teams );
|
||||
$team = reset( $teams );
|
||||
$team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
|
||||
$venue = sp_get_the_term_id( $team_object->ID, 'sp_venue' );
|
||||
$venue = sp_get_the_term_id( $team_object->ID, 'sp_venue' );
|
||||
}
|
||||
wp_set_object_terms( $id, $venue, 'sp_venue', false );
|
||||
|
||||
@@ -156,30 +165,41 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
endif;
|
||||
|
||||
// Add teams to event
|
||||
if ( sizeof( $teams ) > 0 ):
|
||||
if ( sizeof( $teams ) > 0 ) :
|
||||
|
||||
foreach ( $teams as $team_name ):
|
||||
foreach ( $teams as $team_name ) :
|
||||
|
||||
if ( '' !== $team_name ):
|
||||
if ( '' !== $team_name ) :
|
||||
|
||||
// Find out if team exists
|
||||
$team_object = get_page_by_title( stripslashes( $team_name ), OBJECT, 'sp_team' );
|
||||
|
||||
// Get or insert team
|
||||
if ( $team_object ):
|
||||
if ( $team_object ) :
|
||||
|
||||
// Make sure team is published
|
||||
if ( $team_object->post_status != 'publish' ):
|
||||
wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
|
||||
if ( $team_object->post_status != 'publish' ) :
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $team_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
|
||||
// Get team ID
|
||||
$team_id = $team_object->ID;
|
||||
|
||||
else:
|
||||
else :
|
||||
|
||||
// Insert team
|
||||
$team_id = wp_insert_post( array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $team_name ) ) );
|
||||
$team_id = wp_insert_post(
|
||||
array(
|
||||
'post_type' => 'sp_team',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $team_name ),
|
||||
)
|
||||
);
|
||||
|
||||
// Flag as import
|
||||
update_post_meta( $team_id, '_sp_import', 1 );
|
||||
@@ -187,17 +207,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
endif;
|
||||
|
||||
// Update league
|
||||
if ( $league ):
|
||||
if ( $league ) :
|
||||
wp_set_object_terms( $team_id, $league, 'sp_league', true );
|
||||
endif;
|
||||
|
||||
// Update season
|
||||
if ( $season ):
|
||||
if ( $season ) :
|
||||
wp_set_object_terms( $team_id, $season, 'sp_season', true );
|
||||
endif;
|
||||
|
||||
// Add to event if exists
|
||||
if ( isset( $id ) ):
|
||||
if ( isset( $id ) ) :
|
||||
|
||||
// Add team to event
|
||||
add_post_meta( $id, 'sp_team', $team_id );
|
||||
@@ -217,19 +237,19 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Update event with new name
|
||||
$post = array(
|
||||
'ID' => $id,
|
||||
'ID' => $id,
|
||||
'post_title' => $title,
|
||||
'post_name' => $id,
|
||||
'post_name' => $id,
|
||||
);
|
||||
wp_update_post( $post );
|
||||
|
||||
endif;
|
||||
|
||||
else:
|
||||
else :
|
||||
|
||||
// Add empty team to event
|
||||
add_post_meta( $id, 'sp_team', -1 );
|
||||
|
||||
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
@@ -240,7 +260,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Show Result
|
||||
echo '<div class="updated settings-error below-h2"><p>
|
||||
'.sprintf( __( 'Import complete - imported <strong>%s</strong> events and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
|
||||
' . sprintf( __( 'Import complete - imported <strong>%1$s</strong> events and skipped <strong>%2$s</strong>.', 'sportspress' ), $this->imported, $this->skipped ) . '
|
||||
</p></div>';
|
||||
|
||||
$this->import_end();
|
||||
@@ -250,7 +270,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* Performs post-import cleanup of files and the cache
|
||||
*/
|
||||
function import_end() {
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_event') . '">' . __( 'View Fixtures', 'sportspress' ) . '</a>' . '</p>';
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_event' ) . '">' . __( 'View Fixtures', 'sportspress' ) . '</a>' . '</p>';
|
||||
|
||||
do_action( 'import_end' );
|
||||
}
|
||||
@@ -263,7 +283,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
*/
|
||||
function greet() {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||
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>';
|
||||
echo '<p>' . sprintf( __( 'Supports CSV files generated by <a href="%s">LeagueLobster</a>.', 'sportspress' ), 'http://tboy.co/leaguelobster' ) . '</p>';
|
||||
wp_import_upload_form( 'admin.php?import=sp_fixture_csv&step=1' );
|
||||
@@ -293,56 +313,60 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php _e( 'League', 'sportspress' ); ?></label><br/></th>
|
||||
<td><?php
|
||||
<td>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'values' => 'slug',
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'values' => 'slug',
|
||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||
);
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ) :
|
||||
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
||||
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
?></td>
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php _e( 'Season', 'sportspress' ); ?></label><br/></th>
|
||||
<td><?php
|
||||
<td>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'values' => 'slug',
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'values' => 'slug',
|
||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||
);
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ) :
|
||||
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
||||
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
?></td>
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" class="titledesc">
|
||||
<?php _e( 'Date Format', 'sportspress' ); ?>
|
||||
</th>
|
||||
<td class="forminp forminp-radio">
|
||||
<fieldset>
|
||||
<ul>
|
||||
<td class="forminp forminp-radio">
|
||||
<fieldset>
|
||||
<ul>
|
||||
<li>
|
||||
<label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
|
||||
</li>
|
||||
<label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
|
||||
</li>
|
||||
<label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
|
||||
</li>
|
||||
<label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* SportsPress Importer
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Importer' ) ) {
|
||||
class SP_Importer extends WP_Importer {
|
||||
@@ -21,7 +23,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
var $imported;
|
||||
var $skipped;
|
||||
var $import_label;
|
||||
var $columns = array();
|
||||
var $columns = array();
|
||||
var $optionals = array();
|
||||
|
||||
/**
|
||||
@@ -35,7 +37,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* Enqueue scripts
|
||||
*/
|
||||
public function admin_scripts() {
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,32 +48,36 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
function dispatch() {
|
||||
$this->header();
|
||||
|
||||
if ( ! empty( $_POST['delimiter'] ) )
|
||||
if ( ! empty( $_POST['delimiter'] ) ) {
|
||||
$this->delimiter = stripslashes( trim( sanitize_text_field( $_POST['delimiter'] ) ) );
|
||||
}
|
||||
|
||||
if ( ! $this->delimiter )
|
||||
if ( ! $this->delimiter ) {
|
||||
$this->delimiter = ',';
|
||||
}
|
||||
|
||||
$step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
|
||||
switch ( $step ):
|
||||
switch ( $step ) :
|
||||
case 0:
|
||||
$this->greet();
|
||||
break;
|
||||
case 1:
|
||||
check_admin_referer( 'import-upload' );
|
||||
if ( $this->handle_upload() ):
|
||||
if ( $this->handle_upload() ) :
|
||||
|
||||
if ( $this->id )
|
||||
if ( $this->id ) {
|
||||
$file = get_attached_file( $this->id );
|
||||
else
|
||||
} else {
|
||||
$file = ABSPATH . $this->file_url;
|
||||
}
|
||||
|
||||
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
|
||||
|
||||
if ( function_exists( 'gc_enable' ) )
|
||||
if ( function_exists( 'gc_enable' ) ) {
|
||||
gc_enable();
|
||||
}
|
||||
|
||||
@set_time_limit(0);
|
||||
@set_time_limit( 0 );
|
||||
@ob_flush();
|
||||
@flush();
|
||||
|
||||
@@ -80,7 +86,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
break;
|
||||
case 2:
|
||||
check_admin_referer( 'import-upload' );
|
||||
if ( isset( $_POST['sp_import'] ) ):
|
||||
if ( isset( $_POST['sp_import'] ) ) :
|
||||
$columns = array_filter( sp_array_value( $_POST, 'sp_columns', array( 'post_title' ) ) );
|
||||
$this->import( $_POST['sp_import'], array_values( $columns ) );
|
||||
endif;
|
||||
@@ -100,7 +106,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
?>
|
||||
<select name="sp_columns[]" data-index="<?php echo array_search( $selected, array_keys( $this->columns ) ); ?>">
|
||||
<option value="0">— <?php _e( 'Disable', 'sportspress' ); ?> —</option>
|
||||
<?php foreach ( $this->columns as $key => $label ): ?>
|
||||
<?php foreach ( $this->columns as $key => $label ) : ?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $selected, $key ); ?>><?php echo esc_html( $label ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
@@ -119,26 +125,26 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
$this->imported = $this->skipped = 0;
|
||||
|
||||
if ( ! is_file($file) ):
|
||||
if ( ! is_file( $file ) ) :
|
||||
$this->footer();
|
||||
die();
|
||||
endif;
|
||||
|
||||
ini_set( 'auto_detect_line_endings', '1' );
|
||||
|
||||
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ):
|
||||
if ( ( $handle = fopen( $file, 'r' ) ) !== false ) :
|
||||
|
||||
$header = fgetcsv( $handle, 0, $this->delimiter );
|
||||
|
||||
if ( sizeof( $header ) >= 1 ):
|
||||
if ( sizeof( $header ) >= 1 ) :
|
||||
$action = 'admin.php?import=' . $this->import_page . '&step=2';
|
||||
?>
|
||||
<form enctype="multipart/form-data" id="import-upload-form" class="sportspress" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
|
||||
<form enctype="multipart/form-data" id="import-upload-form" class="sportspress" method="post" action="<?php echo esc_attr( wp_nonce_url( $action, 'import-upload' ) ); ?>">
|
||||
<?php $this->options(); ?>
|
||||
<table class="wp-list-table sp-data-table sp-import-table widefat fixed pages">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ( $this->columns as $key => $label ): ?>
|
||||
<?php foreach ( $this->columns as $key => $label ) : ?>
|
||||
<th scope="col" class="manage-column">
|
||||
<?php $this->dropdown( $key ); ?>
|
||||
</th>
|
||||
@@ -149,21 +155,35 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ): ?>
|
||||
<?php while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== false ) : ?>
|
||||
<tr>
|
||||
<?php $index = 0; foreach ( $this->columns as $key => $label ): $value = sp_array_value( $row, $index ); ?>
|
||||
<?php
|
||||
$index = 0;
|
||||
foreach ( $this->columns as $key => $label ) :
|
||||
$value = sp_array_value( $row, $index );
|
||||
?>
|
||||
<td>
|
||||
<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 } ?>>
|
||||
<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 } ?>>
|
||||
</td>
|
||||
<?php $index ++; endforeach; ?>
|
||||
<?php
|
||||
$index ++;
|
||||
endforeach;
|
||||
?>
|
||||
<td class="sp-actions-column">
|
||||
<a href="#" title="<?php _e( 'Delete row', 'sportspress' ); ?>" class="dashicons dashicons-dismiss sp-delete-row"></a>
|
||||
<a href="#" title="<?php _e( 'Insert row after', 'sportspress' ); ?>" class="dashicons dashicons-plus-alt sp-add-row"></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $this->imported++; endwhile; ?>
|
||||
<?php
|
||||
$this->imported++;
|
||||
endwhile;
|
||||
?>
|
||||
<tr>
|
||||
<?php foreach ( $this->columns as $key => $label ): ?>
|
||||
<?php foreach ( $this->columns as $key => $label ) : ?>
|
||||
<td>
|
||||
<input type="text" class="widefat" name="sp_import[]">
|
||||
</td>
|
||||
@@ -172,17 +192,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
<a href="#" title="<?php _e( 'Insert row after', 'sportspress' ); ?>" class="dashicons dashicons-plus-alt sp-add-row"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="sp-post-count alignright">
|
||||
<?php printf( __( 'Displaying %s–%s of %s', 'sportspress' ), 1, $this->imported+1, $this->imported+1 ); ?>
|
||||
<?php printf( __( 'Displaying %1$s–%2$s of %3$s', 'sportspress' ), 1, $this->imported + 1, $this->imported + 1 ); ?>
|
||||
</p>
|
||||
<p class="submit">
|
||||
<input type="submit" class="button button-primary button-hero" value="<?php echo esc_attr( $this->import_label ); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
else:
|
||||
else :
|
||||
|
||||
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'sportspress' ) . '</strong><br />';
|
||||
_e( 'The CSV is invalid.', 'sportspress' ) . '</p>';
|
||||
@@ -191,7 +211,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
endif;
|
||||
|
||||
fclose( $handle );
|
||||
fclose( $handle );
|
||||
endif;
|
||||
}
|
||||
|
||||
@@ -199,7 +219,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* format_data_from_csv function.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $data
|
||||
* @param mixed $data
|
||||
* @param string $enc
|
||||
* @return string
|
||||
*/
|
||||
@@ -239,7 +259,6 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -276,6 +295,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
/**
|
||||
* Added to http_request_timeout filter to force timeout at 60 seconds during import
|
||||
*
|
||||
* @param int $val
|
||||
* @return int 60
|
||||
*/
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Official importer - import officials into SportsPress.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.5.1
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.5.1
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Importer' ) ) {
|
||||
class SP_Official_Importer extends SP_Importer {
|
||||
@@ -20,9 +22,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->import_page = 'sp_official_csv';
|
||||
$this->import_page = 'sp_official_csv';
|
||||
$this->import_label = __( 'Import Officials', 'sportspress' );
|
||||
$this->columns = array(
|
||||
$this->columns = array(
|
||||
'post_title' => __( 'Name', 'sportspress' ),
|
||||
);
|
||||
parent::__construct();
|
||||
@@ -39,33 +41,39 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||
$this->imported = $this->skipped = 0;
|
||||
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||
$this->footer();
|
||||
die();
|
||||
endif;
|
||||
|
||||
$rows = array_chunk( $array, sizeof( $columns ) );
|
||||
|
||||
foreach ( $rows as $row ):
|
||||
foreach ( $rows as $row ) :
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
foreach ( $columns as $index => $key ):
|
||||
foreach ( $columns as $index => $key ) :
|
||||
$meta[ $key ] = sp_array_value( $row, $index );
|
||||
endforeach;
|
||||
|
||||
$name = sp_array_value( $meta, 'post_title' );
|
||||
|
||||
if ( ! $name ):
|
||||
if ( ! $name ) :
|
||||
$this->skipped++;
|
||||
continue;
|
||||
endif;
|
||||
|
||||
$args = array( 'post_type' => 'sp_official', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
|
||||
$args = array(
|
||||
'post_type' => 'sp_official',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $name ),
|
||||
);
|
||||
|
||||
$id = wp_insert_post( $args );
|
||||
|
||||
@@ -75,7 +83,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Show Result
|
||||
echo '<div class="updated settings-error below-h2"><p>
|
||||
'.sprintf( __( 'Import complete - imported <strong>%s</strong> officials and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
|
||||
' . sprintf( __( 'Import complete - imported <strong>%1$s</strong> officials and skipped <strong>%2$s</strong>.', 'sportspress' ), $this->imported, $this->skipped ) . '
|
||||
</p></div>';
|
||||
|
||||
$this->import_end();
|
||||
@@ -85,7 +93,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* Performs post-import cleanup of files and the cache
|
||||
*/
|
||||
function import_end() {
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_official') . '">' . __( 'View Officials', 'sportspress' ) . '</a>' . '</p>';
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_official' ) . '">' . __( 'View Officials', 'sportspress' ) . '</a>' . '</p>';
|
||||
|
||||
do_action( 'import_end' );
|
||||
}
|
||||
@@ -108,7 +116,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
*/
|
||||
function greet() {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||
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>';
|
||||
wp_import_upload_form( 'admin.php?import=sp_official_csv&step=1' );
|
||||
echo '</div>';
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Player importer - import players into SportsPress.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.7
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Importer' ) ) {
|
||||
class SP_Player_Importer extends SP_Importer {
|
||||
@@ -20,17 +22,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->import_page = 'sp_player_csv';
|
||||
$this->import_page = 'sp_player_csv';
|
||||
$this->import_label = __( 'Import Players', 'sportspress' );
|
||||
$this->columns = array(
|
||||
'sp_number' => __( 'Squad Number', 'sportspress' ),
|
||||
'post_title' => __( 'Name', 'sportspress' ),
|
||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
$this->columns = array(
|
||||
'sp_number' => __( 'Squad Number', 'sportspress' ),
|
||||
'post_title' => __( 'Name', 'sportspress' ),
|
||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
'sp_nationality' => __( 'Nationality', 'sportspress' ),
|
||||
'post_date' => __( 'Date of Birth', 'sportspress' ),
|
||||
'post_date' => __( 'Date of Birth', 'sportspress' ),
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -46,21 +48,23 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||
$this->imported = $this->skipped = 0;
|
||||
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||
$this->footer();
|
||||
die();
|
||||
endif;
|
||||
|
||||
$rows = array_chunk( $array, sizeof( $columns ) );
|
||||
|
||||
|
||||
// Get Date of Birth format from post vars
|
||||
$date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : sanitize_text_field( $_POST['sp_date_format'] ) );
|
||||
|
||||
foreach ( $rows as $row ):
|
||||
foreach ( $rows as $row ) :
|
||||
|
||||
$row = array_filter( $row, 'strlen' );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
@@ -76,17 +80,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$meta[ $p ] = '';
|
||||
}
|
||||
|
||||
foreach ( $columns as $index => $key ):
|
||||
foreach ( $columns as $index => $key ) :
|
||||
$meta[ $key ] = sp_array_value( $row, $index );
|
||||
endforeach;
|
||||
|
||||
$name = sp_array_value( $meta, 'post_title' );
|
||||
$date = sp_array_value( $meta, 'post_date' );
|
||||
|
||||
|
||||
// Format date of birth
|
||||
$date = str_replace( '/', '-', trim( $date ) );
|
||||
$date = str_replace( '/', '-', trim( $date ) );
|
||||
$date_array = explode( '-', $date );
|
||||
switch ( $date_format ):
|
||||
switch ( $date_format ) :
|
||||
case 'dd/mm/yyyy':
|
||||
$date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
|
||||
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' ) ) {
|
||||
substr( str_pad( sp_array_value( $date_array, 2, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 );
|
||||
endswitch;
|
||||
|
||||
if ( ! $name ):
|
||||
if ( ! $name ) :
|
||||
$this->skipped++;
|
||||
continue;
|
||||
endif;
|
||||
|
||||
// Get or insert player
|
||||
$player_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_player' ) : false;
|
||||
if ( $player_object ):
|
||||
if ( $player_object->post_status != 'publish' ):
|
||||
wp_update_post( array( 'ID' => $player_object->ID, 'post_status' => 'publish' ) );
|
||||
if ( $player_object ) :
|
||||
if ( $player_object->post_status != 'publish' ) :
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $player_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
$id = $player_object->ID;
|
||||
// Handle preservable data.
|
||||
foreach ( $preservable_metas_keys as $p ) {
|
||||
$terms = wp_get_object_terms( $id, $p, array( 'fields' => 'names' ) );
|
||||
$terms = wp_get_object_terms( $id, $p, array( 'fields' => 'names' ) );
|
||||
$meta[ $p ] .= '|' . implode( '|', $terms );
|
||||
}
|
||||
else:
|
||||
$args = array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
|
||||
else :
|
||||
$args = array(
|
||||
'post_type' => 'sp_player',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $name ),
|
||||
);
|
||||
// Check if a DoB was set
|
||||
if( '0000-00-00' !== $date ){
|
||||
$args['post_date'] = $date;
|
||||
if ( '0000-00-00' !== $date ) {
|
||||
$args['post_date'] = $date;
|
||||
}
|
||||
$id = wp_insert_post( $args );
|
||||
|
||||
@@ -148,18 +161,29 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
wp_set_object_terms( $id, $seasons, 'sp_season', false );
|
||||
|
||||
// Update teams
|
||||
$teams = (array)explode( '|', sp_array_value( $meta, 'sp_team' ) );
|
||||
$i = 0;
|
||||
foreach ( $teams as $team ):
|
||||
$teams = (array) explode( '|', sp_array_value( $meta, 'sp_team' ) );
|
||||
$i = 0;
|
||||
foreach ( $teams as $team ) :
|
||||
// Get or insert team
|
||||
$team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
|
||||
if ( $team_object ):
|
||||
if ( $team_object->post_status != 'publish' ):
|
||||
wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
|
||||
if ( $team_object ) :
|
||||
if ( $team_object->post_status != 'publish' ) :
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $team_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
$team_id = $team_object->ID;
|
||||
else:
|
||||
$team_id = wp_insert_post( array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $team ) ) );
|
||||
else :
|
||||
$team_id = wp_insert_post(
|
||||
array(
|
||||
'post_type' => 'sp_team',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $team ),
|
||||
)
|
||||
);
|
||||
// Flag as import
|
||||
update_post_meta( $team_id, '_sp_import', 1 );
|
||||
wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
|
||||
@@ -170,7 +194,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
add_post_meta( $id, 'sp_team', $team_id );
|
||||
|
||||
// Update current team if first in array, otherwise use as past team
|
||||
if ( $i == 0 ):
|
||||
if ( $i == 0 ) :
|
||||
update_post_meta( $id, 'sp_current_team', $team_id );
|
||||
else :
|
||||
add_post_meta( $id, 'sp_past_team', $team_id );
|
||||
@@ -181,7 +205,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Update nationality
|
||||
$nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
|
||||
if ( $nationality == '*' ) $nationality = '';
|
||||
if ( $nationality == '*' ) {
|
||||
$nationality = '';
|
||||
}
|
||||
update_post_meta( $id, 'sp_nationality', $nationality );
|
||||
|
||||
$this->imported++;
|
||||
@@ -190,7 +216,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Show Result
|
||||
echo '<div class="updated settings-error below-h2"><p>
|
||||
'.sprintf( __( 'Import complete - imported <strong>%s</strong> players and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
|
||||
' . sprintf( __( 'Import complete - imported <strong>%1$s</strong> players and skipped <strong>%2$s</strong>.', 'sportspress' ), $this->imported, $this->skipped ) . '
|
||||
</p></div>';
|
||||
|
||||
$this->import_end();
|
||||
@@ -200,7 +226,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* Performs post-import cleanup of files and the cache
|
||||
*/
|
||||
function import_end() {
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_player') . '">' . __( 'View Players', 'sportspress' ) . '</a>' . '</p>';
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_player' ) . '">' . __( 'View Players', 'sportspress' ) . '</a>' . '</p>';
|
||||
|
||||
do_action( 'import_end' );
|
||||
}
|
||||
@@ -223,7 +249,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
*/
|
||||
function greet() {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||
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>';
|
||||
wp_import_upload_form( 'admin.php?import=sp_player_csv&step=1' );
|
||||
echo '</div>';
|
||||
@@ -243,22 +269,22 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
<th scope="row" class="titledesc">
|
||||
<?php _e( 'Date of Birth Format', 'sportspress' ); ?>
|
||||
</th>
|
||||
<td class="forminp forminp-radio">
|
||||
<fieldset>
|
||||
<ul>
|
||||
<td class="forminp forminp-radio">
|
||||
<fieldset>
|
||||
<ul>
|
||||
<li>
|
||||
<label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
|
||||
</li>
|
||||
<label><input name="sp_date_format" value="yyyy/mm/dd" type="radio" checked> yyyy/mm/dd</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
|
||||
</li>
|
||||
<label><input name="sp_date_format" value="dd/mm/yyyy" type="radio"> dd/mm/yyyy</label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
|
||||
</li>
|
||||
<label><input name="sp_date_format" value="mm/dd/yyyy" type="radio"> mm/dd/yyyy</label>
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Staff importer - import staff into SportsPress.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.5.5
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.5.5
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Importer' ) ) {
|
||||
class SP_Staff_Importer extends SP_Importer {
|
||||
@@ -20,14 +22,14 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->import_page = 'sp_staff_csv';
|
||||
$this->import_page = 'sp_staff_csv';
|
||||
$this->import_label = __( 'Import Staff', 'sportspress' );
|
||||
$this->columns = array(
|
||||
'post_title' => __( 'Name', 'sportspress' ),
|
||||
'sp_role' => __( 'Jobs', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
$this->columns = array(
|
||||
'post_title' => __( 'Name', 'sportspress' ),
|
||||
'sp_role' => __( 'Jobs', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
'sp_nationality' => __( 'Nationality', 'sportspress' ),
|
||||
);
|
||||
parent::__construct();
|
||||
@@ -44,42 +46,53 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||
$this->imported = $this->skipped = 0;
|
||||
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||
$this->footer();
|
||||
die();
|
||||
endif;
|
||||
|
||||
$rows = array_chunk( $array, sizeof( $columns ) );
|
||||
|
||||
foreach ( $rows as $row ):
|
||||
foreach ( $rows as $row ) :
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
foreach ( $columns as $index => $key ):
|
||||
foreach ( $columns as $index => $key ) :
|
||||
$meta[ $key ] = sp_array_value( $row, $index );
|
||||
endforeach;
|
||||
|
||||
$name = sp_array_value( $meta, 'post_title' );
|
||||
|
||||
if ( ! $name ):
|
||||
if ( ! $name ) :
|
||||
$this->skipped++;
|
||||
continue;
|
||||
endif;
|
||||
|
||||
// Get or insert staff
|
||||
$staff_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_staff' ) : false;
|
||||
if ( $staff_object ):
|
||||
if ( $staff_object->post_status != 'publish' ):
|
||||
wp_update_post( array( 'ID' => $staff_object->ID, 'post_status' => 'publish' ) );
|
||||
if ( $staff_object ) :
|
||||
if ( $staff_object->post_status != 'publish' ) :
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $staff_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
$id = $staff_object->ID;
|
||||
else:
|
||||
$args = array( 'post_type' => 'sp_staff', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
|
||||
$id = wp_insert_post( $args );
|
||||
else :
|
||||
$args = array(
|
||||
'post_type' => 'sp_staff',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $name ),
|
||||
);
|
||||
$id = wp_insert_post( $args );
|
||||
|
||||
// Flag as import
|
||||
update_post_meta( $id, '_sp_import', 1 );
|
||||
@@ -98,18 +111,29 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
wp_set_object_terms( $id, $seasons, 'sp_season', false );
|
||||
|
||||
// Update teams
|
||||
$teams = (array)explode( '|', sp_array_value( $meta, 'sp_team' ) );
|
||||
$i = 0;
|
||||
foreach ( $teams as $team ):
|
||||
$teams = (array) explode( '|', sp_array_value( $meta, 'sp_team' ) );
|
||||
$i = 0;
|
||||
foreach ( $teams as $team ) :
|
||||
// Get or insert team
|
||||
$team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
|
||||
if ( $team_object ):
|
||||
if ( $team_object->post_status != 'publish' ):
|
||||
wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
|
||||
if ( $team_object ) :
|
||||
if ( $team_object->post_status != 'publish' ) :
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $team_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
$team_id = $team_object->ID;
|
||||
else:
|
||||
$team_id = wp_insert_post( array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $team ) ) );
|
||||
else :
|
||||
$team_id = wp_insert_post(
|
||||
array(
|
||||
'post_type' => 'sp_team',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $team ),
|
||||
)
|
||||
);
|
||||
// Flag as import
|
||||
update_post_meta( $team_id, '_sp_import', 1 );
|
||||
wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
|
||||
@@ -120,7 +144,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
add_post_meta( $id, 'sp_team', $team_id );
|
||||
|
||||
// Update current team if first in array
|
||||
if ( $i == 0 ):
|
||||
if ( $i == 0 ) :
|
||||
update_post_meta( $id, 'sp_current_team', $team_id );
|
||||
endif;
|
||||
|
||||
@@ -129,7 +153,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Update nationality
|
||||
$nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
|
||||
if ( $nationality == '*' ) $nationality = '';
|
||||
if ( $nationality == '*' ) {
|
||||
$nationality = '';
|
||||
}
|
||||
update_post_meta( $id, 'sp_nationality', $nationality );
|
||||
|
||||
$this->imported++;
|
||||
@@ -138,7 +164,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Show Result
|
||||
echo '<div class="updated settings-error below-h2"><p>
|
||||
'.sprintf( __( 'Import complete - imported <strong>%s</strong> staff and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
|
||||
' . sprintf( __( 'Import complete - imported <strong>%1$s</strong> staff and skipped <strong>%2$s</strong>.', 'sportspress' ), $this->imported, $this->skipped ) . '
|
||||
</p></div>';
|
||||
|
||||
$this->import_end();
|
||||
@@ -148,7 +174,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* Performs post-import cleanup of files and the cache
|
||||
*/
|
||||
function import_end() {
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_staff') . '">' . __( 'View Staff', 'sportspress' ) . '</a>' . '</p>';
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_staff' ) . '">' . __( 'View Staff', 'sportspress' ) . '</a>' . '</p>';
|
||||
|
||||
do_action( 'import_end' );
|
||||
}
|
||||
@@ -171,7 +197,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
*/
|
||||
function greet() {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||
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>';
|
||||
wp_import_upload_form( 'admin.php?import=sp_staff_csv&step=1' );
|
||||
echo '</div>';
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Team importer - import teams into SportsPress.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.5.5
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Importers
|
||||
* @version 2.5.5
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Importer' ) ) {
|
||||
class SP_Team_Importer extends SP_Importer {
|
||||
@@ -20,15 +22,15 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->import_page = 'sp_team_csv';
|
||||
$this->import_page = 'sp_team_csv';
|
||||
$this->import_label = __( 'Import Teams', 'sportspress' );
|
||||
$this->columns = array(
|
||||
'post_title' => __( 'Name', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
'sp_url' => __( 'Site URL', 'sportspress' ),
|
||||
$this->columns = array(
|
||||
'post_title' => __( 'Name', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
'sp_url' => __( 'Site URL', 'sportspress' ),
|
||||
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
|
||||
'sp_venue' => __( 'Home', 'sportspress' ),
|
||||
'sp_venue' => __( 'Home', 'sportspress' ),
|
||||
);
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -44,42 +46,53 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||
$this->imported = $this->skipped = 0;
|
||||
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
||||
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||
$this->footer();
|
||||
die();
|
||||
endif;
|
||||
|
||||
$rows = array_chunk( $array, sizeof( $columns ) );
|
||||
|
||||
foreach ( $rows as $row ):
|
||||
foreach ( $rows as $row ) :
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
foreach ( $columns as $index => $key ):
|
||||
foreach ( $columns as $index => $key ) :
|
||||
$meta[ $key ] = sp_array_value( $row, $index );
|
||||
endforeach;
|
||||
|
||||
$name = sp_array_value( $meta, 'post_title' );
|
||||
|
||||
if ( ! $name ):
|
||||
if ( ! $name ) :
|
||||
$this->skipped++;
|
||||
continue;
|
||||
endif;
|
||||
|
||||
// Get or insert team
|
||||
$team_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_team' ) : false;
|
||||
if ( $team_object ):
|
||||
if ( $team_object->post_status != 'publish' ):
|
||||
wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
|
||||
if ( $team_object ) :
|
||||
if ( $team_object->post_status != 'publish' ) :
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $team_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
$id = $team_object->ID;
|
||||
else:
|
||||
$args = array( 'post_type' => 'sp_team', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
|
||||
$id = wp_insert_post( $args );
|
||||
else :
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $name ),
|
||||
);
|
||||
$id = wp_insert_post( $args );
|
||||
|
||||
// Flag as import
|
||||
update_post_meta( $id, '_sp_import', 1 );
|
||||
@@ -107,7 +120,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Show Result
|
||||
echo '<div class="updated settings-error below-h2"><p>
|
||||
'.sprintf( __( 'Import complete - imported <strong>%s</strong> teams and skipped <strong>%s</strong>.', 'sportspress' ), $this->imported, $this->skipped ).'
|
||||
' . sprintf( __( 'Import complete - imported <strong>%1$s</strong> teams and skipped <strong>%2$s</strong>.', 'sportspress' ), $this->imported, $this->skipped ) . '
|
||||
</p></div>';
|
||||
|
||||
$this->import_end();
|
||||
@@ -117,7 +130,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
* Performs post-import cleanup of files and the cache
|
||||
*/
|
||||
function import_end() {
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_team') . '">' . __( 'View Teams', 'sportspress' ) . '</a>' . '</p>';
|
||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_team' ) . '">' . __( 'View Teams', 'sportspress' ) . '</a>' . '</p>';
|
||||
|
||||
do_action( 'import_end' );
|
||||
}
|
||||
@@ -130,7 +143,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
*/
|
||||
function greet() {
|
||||
echo '<div class="narrow">';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||
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>';
|
||||
wp_import_upload_form( 'admin.php?import=sp_team_csv&step=1' );
|
||||
echo '</div>';
|
||||
|
||||
@@ -2,160 +2,170 @@
|
||||
/**
|
||||
* Admin functions for the calendars post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Calendar' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Calendar Class
|
||||
*/
|
||||
class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Calendar Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_calendar';
|
||||
class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_calendar_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_calendar_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_calendar';
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_calendar_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_calendar_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
'sp_events' => __( 'Events', 'sportspress' ),
|
||||
'sp_layout' => __( 'Layout', 'sportspress' ),
|
||||
), $existing_columns );
|
||||
return apply_filters( 'sportspress_calendar_admin_columns', $columns );
|
||||
}
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_league':
|
||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
|
||||
break;
|
||||
case 'sp_venue':
|
||||
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : __( 'All', 'sportspress' );
|
||||
break;
|
||||
case 'sp_team':
|
||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
if ( empty( $teams ) ):
|
||||
echo __( 'All', 'sportspress' );
|
||||
else:
|
||||
$current_team = get_post_meta( $post_id, 'sp_current_team', true );
|
||||
foreach( $teams as $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ):
|
||||
echo esc_html( $team->post_title );
|
||||
if ( $team_id == $current_team ):
|
||||
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
'sp_events' => __( 'Events', 'sportspress' ),
|
||||
'sp_layout' => __( 'Layout', 'sportspress' ),
|
||||
),
|
||||
$existing_columns
|
||||
);
|
||||
return apply_filters( 'sportspress_calendar_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_league':
|
||||
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
|
||||
break;
|
||||
case 'sp_venue':
|
||||
echo get_the_terms( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : __( 'All', 'sportspress' );
|
||||
break;
|
||||
case 'sp_team':
|
||||
$teams = (array) get_post_meta( $post_id, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
if ( empty( $teams ) ) :
|
||||
echo __( 'All', 'sportspress' );
|
||||
else :
|
||||
$current_team = get_post_meta( $post_id, 'sp_current_team', true );
|
||||
foreach ( $teams as $team_id ) :
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ) :
|
||||
echo esc_html( $team->post_title );
|
||||
if ( $team_id == $current_team ) :
|
||||
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
||||
endif;
|
||||
echo '<br>';
|
||||
endif;
|
||||
echo '<br>';
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
case 'sp_events':
|
||||
$calendar = new SP_Calendar( $post_id );
|
||||
echo sizeof( $calendar->data() );
|
||||
break;
|
||||
case 'sp_layout':
|
||||
echo esc_html( sp_array_value( SP()->formats->calendar, get_post_meta( $post_id, 'sp_format', true ), '—' ) );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
case 'sp_events':
|
||||
$calendar = new SP_Calendar( $post_id );
|
||||
echo sizeof( $calendar->data() );
|
||||
break;
|
||||
case 'sp_layout':
|
||||
echo esc_html( sp_array_value( SP()->formats->calendar, get_post_meta( $post_id, 'sp_format', true ), '—' ) );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_calendar' )
|
||||
return;
|
||||
if ( $typenow != 'sp_calendar' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
}
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
global $typenow, $wp_query;
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow == 'sp_calendar' ) {
|
||||
if ( $typenow == 'sp_calendar' ) {
|
||||
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
}
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,80 +2,84 @@
|
||||
/**
|
||||
* Admin functions for the columns post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Column' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Column Class
|
||||
*/
|
||||
class SP_Admin_CPT_Column extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Column Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_column';
|
||||
class SP_Admin_CPT_Column extends SP_Admin_CPT {
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_column_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_column_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_column';
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Key', 'sportspress' ),
|
||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||
'sp_precision' => __( 'Decimal Places', 'sportspress' ),
|
||||
'sp_order' => __( 'Sort Order', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_column_admin_columns', $columns );
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_column_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_column_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_equation':
|
||||
echo wp_kses_post( sp_get_post_equation( $post_id ) );
|
||||
break;
|
||||
case 'sp_precision':
|
||||
echo esc_html( sp_get_post_precision( $post_id ) );
|
||||
break;
|
||||
case 'sp_order':
|
||||
echo esc_html( sp_get_post_order( $post_id ) );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Key', 'sportspress' ),
|
||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||
'sp_precision' => __( 'Decimal Places', 'sportspress' ),
|
||||
'sp_order' => __( 'Sort Order', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_column_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_equation':
|
||||
echo wp_kses_post( sp_get_post_equation( $post_id ) );
|
||||
break;
|
||||
case 'sp_precision':
|
||||
echo esc_html( sp_get_post_precision( $post_id ) );
|
||||
break;
|
||||
case 'sp_order':
|
||||
echo esc_html( sp_get_post_order( $post_id ) );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,217 +2,235 @@
|
||||
/**
|
||||
* Admin functions for the events post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Event' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Event Class
|
||||
*/
|
||||
class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Event Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_event';
|
||||
class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
|
||||
// Post title fields
|
||||
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_event';
|
||||
|
||||
// Empty data filter
|
||||
add_filter( 'wp_insert_post_empty_content', array( $this, 'wp_insert_post_empty_content' ), 99, 2 );
|
||||
// Post title fields
|
||||
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
|
||||
|
||||
// Before data updates
|
||||
add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 99, 2 );
|
||||
// Empty data filter
|
||||
add_filter( 'wp_insert_post_empty_content', array( $this, 'wp_insert_post_empty_content' ), 99, 2 );
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_event_columns', array( $this, 'edit_columns' ) );
|
||||
add_filter( 'manage_edit-sp_event_sortable_columns', array( $this, 'sortable_columns' ) );
|
||||
add_action( 'pre_get_posts', array( $this, 'orderby_columns' ) );
|
||||
add_action( 'manage_sp_event_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
// Before data updates
|
||||
add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 99, 2 );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_event_columns', array( $this, 'edit_columns' ) );
|
||||
add_filter( 'manage_edit-sp_event_sortable_columns', array( $this, 'sortable_columns' ) );
|
||||
add_action( 'pre_get_posts', array( $this, 'orderby_columns' ) );
|
||||
add_action( 'manage_sp_event_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
// Post states
|
||||
add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
* @param string $text
|
||||
* @param object $post
|
||||
* @return string
|
||||
*/
|
||||
public function enter_title_here( $text, $post ) {
|
||||
if ( $post->post_type == 'sp_event' )
|
||||
return __( '(Auto)', 'sportspress' );
|
||||
// Post states
|
||||
add_filter( 'display_post_states', array( $this, 'post_states' ), 10, 2 );
|
||||
|
||||
return $text;
|
||||
}
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark as not empty when saving event if teams are selected for auto title.
|
||||
*
|
||||
* @param array $maybe_empty
|
||||
* @param array $postarr
|
||||
* @return bool
|
||||
*/
|
||||
public function wp_insert_post_empty_content( $maybe_empty, $postarr ) {
|
||||
if ( $maybe_empty && 'sp_event' === sp_array_value( $postarr, 'post_type' ) ):
|
||||
$teams = sp_array_value( $postarr, 'sp_team', array() );
|
||||
$teams = array_filter( $teams );
|
||||
if ( sizeof( $teams ) ) return false;
|
||||
endif;
|
||||
|
||||
return $maybe_empty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-generate an event title based on the team playing if left blank.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $postarr
|
||||
* @return array
|
||||
*/
|
||||
public function wp_insert_post_data( $data, $postarr ) {
|
||||
if ( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ):
|
||||
|
||||
$teams = sp_array_value( $postarr, 'sp_team', array() );
|
||||
$teams = array_filter( $teams );
|
||||
|
||||
$team_names = array();
|
||||
foreach ( $teams as $team ):
|
||||
while ( is_array( $team ) ) {
|
||||
$team = array_shift( array_filter( $team ) );
|
||||
}
|
||||
if ( $team > 0 ) $team_names[] = sp_team_short_name( $team );
|
||||
endforeach;
|
||||
|
||||
$team_names = array_unique( $team_names );
|
||||
|
||||
$reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
|
||||
if ( $reverse_teams ) {
|
||||
$team_names = array_reverse( $team_names );
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
*
|
||||
* @param string $text
|
||||
* @param object $post
|
||||
* @return string
|
||||
*/
|
||||
public function enter_title_here( $text, $post ) {
|
||||
if ( $post->post_type == 'sp_event' ) {
|
||||
return __( '(Auto)', 'sportspress' );
|
||||
}
|
||||
|
||||
$data['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
|
||||
|
||||
endif;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['comments'] );
|
||||
$columns = array_merge( array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_format' => '<span class="dashicons sp-icon-calendar sp-tip" title="' . __( 'Format', 'sportspress' ) . '"></span>',
|
||||
'title' => null,
|
||||
'date' => __( 'Date', 'sportspress' ),
|
||||
'sp_time' => __( 'Time', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_day' => __( 'Match Day', 'sportspress' ),
|
||||
), $existing_columns, array(
|
||||
'title' => __( 'Event', 'sportspress' ),
|
||||
) );
|
||||
return apply_filters( 'sportspress_event_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the sortable columns in admin.
|
||||
*/
|
||||
public function sortable_columns( $columns ) {
|
||||
$columns['sp_day'] = 'sp_day';
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the sortable columns in admin.
|
||||
*/
|
||||
public function orderby_columns( $query ) {
|
||||
if ( ! is_admin() ) return;
|
||||
|
||||
$orderby = $query->get( 'orderby');
|
||||
|
||||
if ( 'sp_day' == $orderby ) {
|
||||
$query->set( 'meta_key','sp_day' );
|
||||
$query->set( 'orderby','meta_value_num' );
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_format':
|
||||
$format = get_post_meta( $post_id, 'sp_format', true );
|
||||
$formats = new SP_Formats();
|
||||
$event_formats = $formats->event;
|
||||
if ( array_key_exists( $format, $event_formats ) ):
|
||||
echo '<span class="dashicons sp-icon-' . $format . ' sp-tip" title="' . $event_formats[ $format ] . '"></span>';
|
||||
endif;
|
||||
break;
|
||||
case 'sp_time':
|
||||
echo apply_filters( 'sportspress_event_time_admin', get_post_time( 'H:i', false, $post_id, true ) );
|
||||
break;
|
||||
case 'sp_team':
|
||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
||||
/**
|
||||
* Mark as not empty when saving event if teams are selected for auto title.
|
||||
*
|
||||
* @param array $maybe_empty
|
||||
* @param array $postarr
|
||||
* @return bool
|
||||
*/
|
||||
public function wp_insert_post_empty_content( $maybe_empty, $postarr ) {
|
||||
if ( $maybe_empty && 'sp_event' === sp_array_value( $postarr, 'post_type' ) ) :
|
||||
$teams = sp_array_value( $postarr, 'sp_team', array() );
|
||||
$teams = array_filter( $teams );
|
||||
$teams = array_unique( $teams );
|
||||
if ( sizeof( $teams ) ) {
|
||||
return false;
|
||||
}
|
||||
endif;
|
||||
|
||||
return $maybe_empty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-generate an event title based on the team playing if left blank.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $postarr
|
||||
* @return array
|
||||
*/
|
||||
public function wp_insert_post_data( $data, $postarr ) {
|
||||
if ( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ) :
|
||||
|
||||
$teams = sp_array_value( $postarr, 'sp_team', array() );
|
||||
$teams = array_filter( $teams );
|
||||
|
||||
$team_names = array();
|
||||
foreach ( $teams as $team ) :
|
||||
while ( is_array( $team ) ) {
|
||||
$team = array_shift( array_filter( $team ) );
|
||||
}
|
||||
if ( $team > 0 ) {
|
||||
$team_names[] = sp_team_short_name( $team );
|
||||
}
|
||||
endforeach;
|
||||
|
||||
$team_names = array_unique( $team_names );
|
||||
|
||||
$reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
|
||||
if ( $reverse_teams ) {
|
||||
$teams = array_reverse( $teams , true );
|
||||
$team_names = array_reverse( $team_names );
|
||||
}
|
||||
if ( empty( $teams ) ):
|
||||
echo '—';
|
||||
else:
|
||||
$results = get_post_meta( $post_id, 'sp_results', true );
|
||||
$main_result = get_option( 'sportspress_primary_result', null );
|
||||
echo '<input type="hidden" name="sp_post_id" value="' . $post_id . '">';
|
||||
echo '<div class="sp-results">';
|
||||
foreach( $teams as $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
|
||||
$data['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
|
||||
|
||||
endif;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['comments'] );
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_format' => '<span class="dashicons sp-icon-calendar sp-tip" title="' . __( 'Format', 'sportspress' ) . '"></span>',
|
||||
'title' => null,
|
||||
'date' => __( 'Date', 'sportspress' ),
|
||||
'sp_time' => __( 'Time', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_day' => __( 'Match Day', 'sportspress' ),
|
||||
),
|
||||
$existing_columns,
|
||||
array(
|
||||
'title' => __( 'Event', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
return apply_filters( 'sportspress_event_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the sortable columns in admin.
|
||||
*/
|
||||
public function sortable_columns( $columns ) {
|
||||
$columns['sp_day'] = 'sp_day';
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the sortable columns in admin.
|
||||
*/
|
||||
public function orderby_columns( $query ) {
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$orderby = $query->get( 'orderby' );
|
||||
|
||||
if ( 'sp_day' == $orderby ) {
|
||||
$query->set( 'meta_key', 'sp_day' );
|
||||
$query->set( 'orderby', 'meta_value_num' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_format':
|
||||
$format = get_post_meta( $post_id, 'sp_format', true );
|
||||
$formats = new SP_Formats();
|
||||
$event_formats = $formats->event;
|
||||
if ( array_key_exists( $format, $event_formats ) ) :
|
||||
echo '<span class="dashicons sp-icon-' . $format . ' sp-tip" title="' . $event_formats[ $format ] . '"></span>';
|
||||
endif;
|
||||
break;
|
||||
case 'sp_time':
|
||||
echo apply_filters( 'sportspress_event_time_admin', get_post_time( 'H:i', false, $post_id, true ) );
|
||||
break;
|
||||
case 'sp_team':
|
||||
$teams = (array) get_post_meta( $post_id, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
$teams = array_unique( $teams );
|
||||
$reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
|
||||
if ( $reverse_teams ) {
|
||||
$teams = array_reverse( $teams, true );
|
||||
}
|
||||
if ( empty( $teams ) ) :
|
||||
echo '—';
|
||||
else :
|
||||
$results = get_post_meta( $post_id, 'sp_results', true );
|
||||
$main_result = get_option( 'sportspress_primary_result', null );
|
||||
echo '<input type="hidden" name="sp_post_id" value="' . $post_id . '">';
|
||||
echo '<div class="sp-results">';
|
||||
foreach ( $teams as $team_id ) :
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
|
||||
if ( $team ):
|
||||
if ( $team ) :
|
||||
$team_results = sportspress_array_value( $results, $team_id, null );
|
||||
|
||||
if ( $main_result ):
|
||||
if ( $main_result ) :
|
||||
$team_result = sportspress_array_value( $team_results, $main_result, null );
|
||||
else:
|
||||
if ( is_array( $team_results ) ):
|
||||
else :
|
||||
if ( is_array( $team_results ) ) :
|
||||
end( $team_results );
|
||||
$team_result = prev( $team_results );
|
||||
$main_result = key( $team_results );
|
||||
else:
|
||||
else :
|
||||
$team_result = null;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( is_array( $team_results ) ):
|
||||
if ( is_array( $team_results ) ) :
|
||||
unset( $team_results['outcome'] );
|
||||
$team_results = array_filter( $team_results, 'sp_filter_non_empty' );
|
||||
$team_results = implode( ' | ', $team_results );
|
||||
@@ -223,129 +241,134 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
echo esc_html( $team->post_title );
|
||||
echo '<br>';
|
||||
endif;
|
||||
endforeach;
|
||||
echo '</div>';
|
||||
if ( current_user_can( 'edit_others_sp_events' ) ) {
|
||||
?>
|
||||
endforeach;
|
||||
echo '</div>';
|
||||
if ( current_user_can( 'edit_others_sp_events' ) ) {
|
||||
?>
|
||||
<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>
|
||||
<p class="inline-edit-save sp-inline-edit-save hidden">
|
||||
<a href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
|
||||
<a href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
|
||||
</p>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
case 'sp_venue':
|
||||
echo get_the_terms( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
||||
break;
|
||||
case 'sp_day':
|
||||
$day = get_post_meta( $post_id, 'sp_day', true );
|
||||
if ( '' === $day ) {
|
||||
$day = __( 'Default', 'sportspress' );
|
||||
}
|
||||
endif;
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
case 'sp_venue':
|
||||
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
||||
break;
|
||||
case 'sp_day':
|
||||
$day = get_post_meta ( $post_id, 'sp_day', true );
|
||||
if ( '' === $day ) $day = __( 'Default', 'sportspress' );
|
||||
echo esc_html( $day );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_event' )
|
||||
return;
|
||||
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['match_day'] ) ? sanitize_text_field( $_REQUEST['match_day'] ) : null;
|
||||
echo '<input name="match_day" type="text" class="sp-tablenav-input" placeholder="' . __( 'Match Day', 'sportspress' ) . '" value="' . $selected . '">';
|
||||
|
||||
if ( current_user_can( 'edit_others_sp_events' ) )
|
||||
wp_nonce_field( 'sp-save-inline-results', 'sp-inline-nonce', false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow == 'sp_event' ) {
|
||||
//Avoid overriding relation operator if already set
|
||||
if ( !isset( $query->query_vars['meta_query']['relation'] ) )
|
||||
$query->query_vars['meta_query']['relation'] = 'AND';
|
||||
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_query'][] = array(
|
||||
'key' => 'sp_team',
|
||||
'value' => $_GET['team'],
|
||||
);
|
||||
echo esc_html( $day );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['match_day'] ) ) {
|
||||
$query->query_vars['meta_query'][] = array(
|
||||
'key' => 'sp_day',
|
||||
'value' => $_GET['match_day'],
|
||||
);
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_event' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['match_day'] ) ? sanitize_text_field( $_REQUEST['match_day'] ) : null;
|
||||
echo '<input name="match_day" type="text" class="sp-tablenav-input" placeholder="' . __( 'Match Day', 'sportspress' ) . '" value="' . $selected . '">';
|
||||
|
||||
if ( current_user_can( 'edit_others_sp_events' ) ) {
|
||||
wp_nonce_field( 'sp-save-inline-results', 'sp-inline-nonce', false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace displayed post state for events
|
||||
*
|
||||
* @param array $post_states
|
||||
* @param object $post
|
||||
*/
|
||||
public function post_states( $post_states, $post ) {
|
||||
$status = get_post_meta( $post->ID, 'sp_status', true );
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( 'postponed' == $status ) {
|
||||
$post_states = array( __( 'Postponed', 'sportspress' ) );
|
||||
} elseif ( 'cancelled' == $status ) {
|
||||
$post_states = array( __( 'Canceled', 'sportspress' ) );
|
||||
} elseif ( 'tbd' == $status ) {
|
||||
$post_states = array( __( 'TBD', 'sportspress' ) );
|
||||
}
|
||||
if ( $typenow == 'sp_event' ) {
|
||||
// Avoid overriding relation operator if already set
|
||||
if ( ! isset( $query->query_vars['meta_query']['relation'] ) ) {
|
||||
$query->query_vars['meta_query']['relation'] = 'AND';
|
||||
}
|
||||
|
||||
return $post_states;
|
||||
}
|
||||
}
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_query'][] = array(
|
||||
'key' => 'sp_team',
|
||||
'value' => $_GET['team'],
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['match_day'] ) ) {
|
||||
$query->query_vars['meta_query'][] = array(
|
||||
'key' => 'sp_day',
|
||||
'value' => $_GET['match_day'],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace displayed post state for events
|
||||
*
|
||||
* @param array $post_states
|
||||
* @param object $post
|
||||
*/
|
||||
public function post_states( $post_states, $post ) {
|
||||
$status = get_post_meta( $post->ID, 'sp_status', true );
|
||||
|
||||
if ( 'postponed' == $status ) {
|
||||
$post_states = array( __( 'Postponed', 'sportspress' ) );
|
||||
} elseif ( 'cancelled' == $status ) {
|
||||
$post_states = array( __( 'Canceled', 'sportspress' ) );
|
||||
} elseif ( 'tbd' == $status ) {
|
||||
$post_states = array( __( 'TBD', 'sportspress' ) );
|
||||
}
|
||||
|
||||
return $post_states;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,154 +2,166 @@
|
||||
/**
|
||||
* Admin functions for the player lists post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_List' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_List Class
|
||||
*/
|
||||
class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_List Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_list';
|
||||
class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_list_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_list_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_list';
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_list_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_list_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
'sp_player' => __( 'Players', 'sportspress' ),
|
||||
'sp_layout' => __( 'Layout', 'sportspress' ),
|
||||
), $existing_columns );
|
||||
return apply_filters( 'sportspress_list_admin_columns', $columns );
|
||||
}
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_player':
|
||||
$select = get_post_meta( $post_id, 'sp_select', true );
|
||||
if ( 'manual' == $select ):
|
||||
$players = array_filter( get_post_meta( $post_id, 'sp_player' ) );
|
||||
echo sizeof( $players );
|
||||
else:
|
||||
_e( 'Auto', 'sportspress' );
|
||||
endif;
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
|
||||
break;
|
||||
case 'sp_team':
|
||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
if ( empty( $teams ) ):
|
||||
echo __( 'All', 'sportspress' );
|
||||
else:
|
||||
foreach( $teams as $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ) echo esc_html( $team->post_title ) . '<br>';
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
case 'sp_layout':
|
||||
echo esc_html( sp_array_value( SP()->formats->list, get_post_meta( $post_id, 'sp_format', true ), '—' ) );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
'sp_player' => __( 'Players', 'sportspress' ),
|
||||
'sp_layout' => __( 'Layout', 'sportspress' ),
|
||||
),
|
||||
$existing_columns
|
||||
);
|
||||
return apply_filters( 'sportspress_list_admin_columns', $columns );
|
||||
}
|
||||
|
||||
if ( $typenow != 'sp_list' )
|
||||
return;
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_player':
|
||||
$select = get_post_meta( $post_id, 'sp_select', true );
|
||||
if ( 'manual' == $select ) :
|
||||
$players = array_filter( get_post_meta( $post_id, 'sp_player' ) );
|
||||
echo sizeof( $players );
|
||||
else :
|
||||
_e( 'Auto', 'sportspress' );
|
||||
endif;
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
|
||||
break;
|
||||
case 'sp_team':
|
||||
$teams = (array) get_post_meta( $post_id, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
if ( empty( $teams ) ) :
|
||||
echo __( 'All', 'sportspress' );
|
||||
else :
|
||||
foreach ( $teams as $team_id ) :
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ) {
|
||||
echo esc_html( $team->post_title ) . '<br>';
|
||||
}
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
case 'sp_layout':
|
||||
echo esc_html( sp_array_value( SP()->formats->list, get_post_meta( $post_id, 'sp_format', true ), '—' ) );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
if ( $typenow != 'sp_list' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
}
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
global $typenow, $wp_query;
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
if ( $typenow == 'sp_list' ) {
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
}
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow == 'sp_list' ) {
|
||||
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,68 +2,72 @@
|
||||
/**
|
||||
* Admin functions for the columns post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Metric' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Metric Class
|
||||
*/
|
||||
class SP_Admin_CPT_Metric extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Metric Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_metric';
|
||||
class SP_Admin_CPT_Metric extends SP_Admin_CPT {
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_metric_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_metric_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_metric';
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_metric_admin_columns', $columns );
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_metric_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_metric_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_metric_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,51 +2,56 @@
|
||||
/**
|
||||
* Admin functions for the officials post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.5.1
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.5.1
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Official' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Official Class
|
||||
*/
|
||||
class SP_Admin_CPT_Official extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Official Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_official';
|
||||
class SP_Admin_CPT_Official extends SP_Admin_CPT {
|
||||
|
||||
// Post title fields
|
||||
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_official';
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
// Post title fields
|
||||
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
*
|
||||
* @param string $text
|
||||
* @param object $post
|
||||
* @return string
|
||||
*/
|
||||
public function enter_title_here( $text, $post ) {
|
||||
if ( $post->post_type == 'sp_official' ) {
|
||||
return __( 'Name', 'sportspress' );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
* @param string $text
|
||||
* @param object $post
|
||||
* @return string
|
||||
*/
|
||||
public function enter_title_here( $text, $post ) {
|
||||
if ( $post->post_type == 'sp_official' )
|
||||
return __( 'Name', 'sportspress' );
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_CPT_Official();
|
||||
|
||||
@@ -2,73 +2,77 @@
|
||||
/**
|
||||
* Admin functions for the outcomes post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Outcome' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Outcome Class
|
||||
*/
|
||||
class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Outcome Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_outcome';
|
||||
class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_outcome_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_outcome_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_outcome';
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_outcome_admin_columns', $columns );
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_outcome_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_outcome_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_abbreviation':
|
||||
global $post;
|
||||
echo esc_html( sp_get_post_abbreviation( $post->ID ) );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_outcome_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_abbreviation':
|
||||
global $post;
|
||||
echo esc_html( sp_get_post_abbreviation( $post->ID ) );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,82 +2,86 @@
|
||||
/**
|
||||
* Admin functions for the performance post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Performance' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Performance Class
|
||||
*/
|
||||
class SP_Admin_CPT_Performance extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Performance Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_performance';
|
||||
class SP_Admin_CPT_Performance extends SP_Admin_CPT {
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_performance_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_performance_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_performance';
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_icon' => __( 'Icon', 'sportspress' ),
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_section' => __( 'Category', 'sportspress' ),
|
||||
'sp_config_format' => __( 'Format', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_performance_admin_columns', $columns );
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_performance_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_performance_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_icon':
|
||||
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
||||
break;
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_section':
|
||||
global $post;
|
||||
echo esc_html( sp_get_post_section( $post->ID ) );
|
||||
break;
|
||||
case 'sp_config_format':
|
||||
global $post;
|
||||
echo esc_html( sp_get_post_format( $post->ID ) );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_icon' => __( 'Icon', 'sportspress' ),
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_section' => __( 'Category', 'sportspress' ),
|
||||
'sp_config_format' => __( 'Format', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_performance_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_icon':
|
||||
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
||||
break;
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_section':
|
||||
global $post;
|
||||
echo esc_html( sp_get_post_section( $post->ID ) );
|
||||
break;
|
||||
case 'sp_config_format':
|
||||
global $post;
|
||||
echo esc_html( sp_get_post_format( $post->ID ) );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,226 +2,245 @@
|
||||
/**
|
||||
* Admin functions for the players post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Player' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Player Class
|
||||
*/
|
||||
class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Player Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_player';
|
||||
class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
|
||||
// Post title fields
|
||||
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_player';
|
||||
|
||||
// Admin columns
|
||||
add_filter( 'manage_edit-sp_player_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_player_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
// Post title fields
|
||||
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
// Admin columns
|
||||
add_filter( 'manage_edit-sp_player_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_player_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
// Quick edit
|
||||
add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_number' ), 10, 2 );
|
||||
add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_teams' ), 10, 2 );
|
||||
add_action( 'save_post', array( $this, 'quick_save' ) );
|
||||
|
||||
// Bulk edit
|
||||
add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit_teams' ), 10, 2 );
|
||||
add_action( 'wp_ajax_save_bulk_edit_sp_player', array( $this, 'bulk_save' ) );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
* @param string $text
|
||||
* @param object $post
|
||||
* @return string
|
||||
*/
|
||||
public function enter_title_here( $text, $post ) {
|
||||
if ( $post->post_type == 'sp_player' )
|
||||
return __( 'Name', 'sportspress' );
|
||||
// Quick edit
|
||||
add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_number' ), 10, 2 );
|
||||
add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_teams' ), 10, 2 );
|
||||
add_action( 'save_post', array( $this, 'quick_save' ) );
|
||||
|
||||
return $text;
|
||||
}
|
||||
// Bulk edit
|
||||
add_action( 'bulk_edit_custom_box', array( $this, 'bulk_edit_teams' ), 10, 2 );
|
||||
add_action( 'wp_ajax_save_bulk_edit_sp_player', array( $this, 'bulk_save' ) );
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_number' => '<span class="dashicons sp-icon-tshirt sp-tip" title="' . __( 'Squad Number', 'sportspress' ) . '"></span>',
|
||||
'title' => null,
|
||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
), $existing_columns, array(
|
||||
'title' => __( 'Name', 'sportspress' )
|
||||
) );
|
||||
return apply_filters( 'sportspress_player_admin_columns', $columns );
|
||||
}
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_number':
|
||||
echo esc_html( get_post_meta ( $post_id, 'sp_number', true ) );
|
||||
break;
|
||||
case 'sp_position':
|
||||
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
$current_teams = get_post_meta( $post_id, 'sp_current_team', false );
|
||||
$past_teams = get_post_meta( $post_id, 'sp_past_team', false );
|
||||
$current_teams = array_filter( $current_teams );
|
||||
$past_teams = array_filter( $past_teams );
|
||||
echo '<span class="hidden sp-player-teams" data-current-teams="' . implode( ',', $current_teams ) . '" data-past-teams="' . implode( ',', $past_teams ) . '"></span>';
|
||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
$teams = array_unique( $teams );
|
||||
if ( empty( $teams ) ):
|
||||
echo '—';
|
||||
else:
|
||||
foreach( $teams as $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ):
|
||||
echo esc_html( $team->post_title );
|
||||
if ( in_array( $team_id, $current_teams ) ):
|
||||
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
||||
endif;
|
||||
echo '<br>';
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
case 'sp_venue':
|
||||
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_player' )
|
||||
return;
|
||||
|
||||
if ( taxonomy_exists( 'sp_position' ) ):
|
||||
$selected = isset( $_REQUEST['sp_position'] ) ? sanitize_key( $_REQUEST['sp_position'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all positions', 'sportspress' ),
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'sp_position',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
|
||||
if ( taxonomy_exists( 'sp_league' ) ):
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
|
||||
if ( taxonomy_exists( 'sp_season' ) ):
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
|
||||
if ( empty ( $query->query_vars['post_type'] ) || $query->query_vars['post_type'] !== 'sp_player' ) return $query;
|
||||
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow == 'sp_player' ) {
|
||||
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
*
|
||||
* @param string $text
|
||||
* @param object $post
|
||||
* @return string
|
||||
*/
|
||||
public function enter_title_here( $text, $post ) {
|
||||
if ( $post->post_type == 'sp_player' ) {
|
||||
return __( 'Name', 'sportspress' );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick edit squad number
|
||||
*
|
||||
* @param string $column_name
|
||||
* @param string $post_type
|
||||
*/
|
||||
public function quick_edit_number( $column_name, $post_type ) {
|
||||
if ( $this->type !== $post_type ) return;
|
||||
if ( 'sp_number' !== $column_name ) return;
|
||||
|
||||
static $print_nonce = true;
|
||||
if ( $print_nonce ) {
|
||||
$print_nonce = false;
|
||||
wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_number' => '<span class="dashicons sp-icon-tshirt sp-tip" title="' . __( 'Squad Number', 'sportspress' ) . '"></span>',
|
||||
'title' => null,
|
||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
),
|
||||
$existing_columns,
|
||||
array(
|
||||
'title' => __( 'Name', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
return apply_filters( 'sportspress_player_admin_columns', $columns );
|
||||
}
|
||||
?>
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_number':
|
||||
echo esc_html( get_post_meta( $post_id, 'sp_number', true ) );
|
||||
break;
|
||||
case 'sp_position':
|
||||
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
$current_teams = get_post_meta( $post_id, 'sp_current_team', false );
|
||||
$past_teams = get_post_meta( $post_id, 'sp_past_team', false );
|
||||
$current_teams = array_filter( $current_teams );
|
||||
$past_teams = array_filter( $past_teams );
|
||||
echo '<span class="hidden sp-player-teams" data-current-teams="' . implode( ',', $current_teams ) . '" data-past-teams="' . implode( ',', $past_teams ) . '"></span>';
|
||||
$teams = (array) get_post_meta( $post_id, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
$teams = array_unique( $teams );
|
||||
if ( empty( $teams ) ) :
|
||||
echo '—';
|
||||
else :
|
||||
foreach ( $teams as $team_id ) :
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ) :
|
||||
echo esc_html( $team->post_title );
|
||||
if ( in_array( $team_id, $current_teams ) ) :
|
||||
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
||||
endif;
|
||||
echo '<br>';
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
case 'sp_venue':
|
||||
echo get_the_terms( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_player' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( taxonomy_exists( 'sp_position' ) ) :
|
||||
$selected = isset( $_REQUEST['sp_position'] ) ? sanitize_key( $_REQUEST['sp_position'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all positions', 'sportspress' ),
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'sp_position',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
|
||||
if ( taxonomy_exists( 'sp_league' ) ) :
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
|
||||
if ( taxonomy_exists( 'sp_season' ) ) :
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
|
||||
if ( empty( $query->query_vars['post_type'] ) || $query->query_vars['post_type'] !== 'sp_player' ) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow == 'sp_player' ) {
|
||||
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick edit squad number
|
||||
*
|
||||
* @param string $column_name
|
||||
* @param string $post_type
|
||||
*/
|
||||
public function quick_edit_number( $column_name, $post_type ) {
|
||||
if ( $this->type !== $post_type ) {
|
||||
return;
|
||||
}
|
||||
if ( 'sp_number' !== $column_name ) {
|
||||
return;
|
||||
}
|
||||
|
||||
static $print_nonce = true;
|
||||
if ( $print_nonce ) {
|
||||
$print_nonce = false;
|
||||
wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
|
||||
}
|
||||
?>
|
||||
<fieldset class="inline-edit-col-right">
|
||||
<div class="inline-edit-col">
|
||||
<label>
|
||||
@@ -230,27 +249,35 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick edit teams
|
||||
*
|
||||
* @param string $column_name
|
||||
* @param string $post_type
|
||||
*/
|
||||
public function quick_edit_teams( $column_name, $post_type ) {
|
||||
if ( $this->type !== $post_type ) return;
|
||||
if ( 'sp_team' !== $column_name ) return;
|
||||
/**
|
||||
* Quick edit teams
|
||||
*
|
||||
* @param string $column_name
|
||||
* @param string $post_type
|
||||
*/
|
||||
public function quick_edit_teams( $column_name, $post_type ) {
|
||||
if ( $this->type !== $post_type ) {
|
||||
return;
|
||||
}
|
||||
if ( 'sp_team' !== $column_name ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$teams = get_posts( array(
|
||||
'post_type' => 'sp_team',
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
) );
|
||||
|
||||
if ( ! $teams ) return;
|
||||
?>
|
||||
$teams = get_posts(
|
||||
array(
|
||||
'post_type' => 'sp_team',
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! $teams ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<fieldset class="inline-edit-col-right">
|
||||
<div class="inline-edit-col">
|
||||
<span class="title inline-edit-categories-label"><?php _e( 'Current Teams', 'sportspress' ); ?></span>
|
||||
@@ -269,57 +296,75 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
</ul>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save quick edit boxes
|
||||
*
|
||||
* @param int $post_id
|
||||
*/
|
||||
public function quick_save( $post_id ) {
|
||||
if ( empty( $_POST ) ) return $post_id;
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) return $post_id;;
|
||||
|
||||
$_POST += array( "{$this->type}_edit_nonce" => '' );
|
||||
if ( ! wp_verify_nonce( $_POST["{$this->type}_edit_nonce"], plugin_basename( __FILE__ ) ) ) return $post_id;;
|
||||
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id;
|
||||
if ( isset( $post->post_type ) && $post->post_type == 'revision' ) return $post_id;
|
||||
|
||||
if ( isset( $_POST[ 'sp_number' ] ) ) {
|
||||
update_post_meta( $post_id, 'sp_number', $_POST[ 'sp_number' ] );
|
||||
<?php
|
||||
}
|
||||
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
|
||||
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() ) ) );
|
||||
}
|
||||
/**
|
||||
* Save quick edit boxes
|
||||
*
|
||||
* @param int $post_id
|
||||
*/
|
||||
public function quick_save( $post_id ) {
|
||||
if ( empty( $_POST ) ) {
|
||||
return $post_id;
|
||||
}
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk edit teams
|
||||
*
|
||||
* @param string $column_name
|
||||
* @param string $post_type
|
||||
*/
|
||||
public function bulk_edit_teams( $column_name, $post_type ) {
|
||||
if ( $this->type !== $post_type ) return;
|
||||
if ( 'sp_team' !== $column_name ) return;
|
||||
$_POST += array( "{$this->type}_edit_nonce" => '' );
|
||||
if ( ! wp_verify_nonce( $_POST[ "{$this->type}_edit_nonce" ], plugin_basename( __FILE__ ) ) ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
static $print_nonce = true;
|
||||
if ( $print_nonce ) {
|
||||
$print_nonce = false;
|
||||
wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
return $post_id;
|
||||
}
|
||||
if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
if ( isset( $_POST['sp_number'] ) ) {
|
||||
update_post_meta( $post_id, 'sp_number', $_POST['sp_number'] );
|
||||
}
|
||||
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
|
||||
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() ) ) );
|
||||
}
|
||||
|
||||
$teams = get_posts( array(
|
||||
'post_type' => 'sp_team',
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
) );
|
||||
|
||||
if ( ! $teams ) return;
|
||||
?>
|
||||
/**
|
||||
* Bulk edit teams
|
||||
*
|
||||
* @param string $column_name
|
||||
* @param string $post_type
|
||||
*/
|
||||
public function bulk_edit_teams( $column_name, $post_type ) {
|
||||
if ( $this->type !== $post_type ) {
|
||||
return;
|
||||
}
|
||||
if ( 'sp_team' !== $column_name ) {
|
||||
return;
|
||||
}
|
||||
|
||||
static $print_nonce = true;
|
||||
if ( $print_nonce ) {
|
||||
$print_nonce = false;
|
||||
wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
|
||||
}
|
||||
|
||||
$teams = get_posts(
|
||||
array(
|
||||
'post_type' => 'sp_team',
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! $teams ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<fieldset class="inline-edit-col-right">
|
||||
<div class="inline-edit-col">
|
||||
<span class="title inline-edit-categories-label"><?php _e( 'Current Teams', 'sportspress' ); ?></span>
|
||||
@@ -338,35 +383,39 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
</ul>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save bulk edit boxes
|
||||
*/
|
||||
public function bulk_save() {
|
||||
$_POST += array( "nonce" => '' );
|
||||
if ( ! wp_verify_nonce( $_POST["nonce"], plugin_basename( __FILE__ ) ) ) return;
|
||||
|
||||
$post_ids = ( ! empty( $_POST[ 'post_ids' ] ) ) ? $_POST[ 'post_ids' ] : array();
|
||||
|
||||
$current_teams = sp_array_value( $_POST, 'current_teams', array() );
|
||||
$past_teams = sp_array_value( $_POST, 'past_teams', array() );
|
||||
$teams = array_merge( $current_teams, $past_teams );
|
||||
|
||||
if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) continue;
|
||||
|
||||
sp_add_post_meta_recursive( $post_id, 'sp_current_team', $current_teams );
|
||||
sp_add_post_meta_recursive( $post_id, 'sp_past_team', $past_teams );
|
||||
sp_add_post_meta_recursive( $post_id, 'sp_team', $teams );
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
die();
|
||||
/**
|
||||
* Save bulk edit boxes
|
||||
*/
|
||||
public function bulk_save() {
|
||||
$_POST += array( 'nonce' => '' );
|
||||
if ( ! wp_verify_nonce( $_POST['nonce'], plugin_basename( __FILE__ ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_ids = ( ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
|
||||
|
||||
$current_teams = sp_array_value( $_POST, 'current_teams', array() );
|
||||
$past_teams = sp_array_value( $_POST, 'past_teams', array() );
|
||||
$teams = array_merge( $current_teams, $past_teams );
|
||||
|
||||
if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sp_add_post_meta_recursive( $post_id, 'sp_current_team', $current_teams );
|
||||
sp_add_post_meta_recursive( $post_id, 'sp_past_team', $past_teams );
|
||||
sp_add_post_meta_recursive( $post_id, 'sp_team', $teams );
|
||||
}
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,68 +2,72 @@
|
||||
/**
|
||||
* Admin functions for the results post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Result' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Result Class
|
||||
*/
|
||||
class SP_Admin_CPT_Result extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Result Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_result';
|
||||
class SP_Admin_CPT_Result extends SP_Admin_CPT {
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_result_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_result_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_result';
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_result_admin_columns', $columns );
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_result_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_result_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name ) . 'for, ' . esc_html( $post->post_name ) . 'against';
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_result_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name ) . 'for, ' . esc_html( $post->post_name ) . 'against';
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,68 +2,72 @@
|
||||
/**
|
||||
* Admin functions for the columns post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Spec' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Spec Class
|
||||
*/
|
||||
class SP_Admin_CPT_Spec extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Spec Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_spec';
|
||||
class SP_Admin_CPT_Spec extends SP_Admin_CPT {
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_spec_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_spec_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_spec';
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_spec_admin_columns', $columns );
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_spec_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_spec_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_spec_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,169 +2,182 @@
|
||||
/**
|
||||
* Admin functions for the staff post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Staff' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Staff Class
|
||||
*/
|
||||
class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Staff Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_staff';
|
||||
class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
|
||||
// Post title fields
|
||||
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_staff';
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_staff_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_staff_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
// Post title fields
|
||||
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_staff_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_staff_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
* @param string $text
|
||||
* @param object $post
|
||||
* @return string
|
||||
*/
|
||||
public function enter_title_here( $text, $post ) {
|
||||
if ( $post->post_type == 'sp_staff' )
|
||||
return __( 'Name', 'sportspress' );
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
|
||||
return $text;
|
||||
}
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => null,
|
||||
'sp_role' => __( 'Job', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
), $existing_columns, array(
|
||||
'title' => __( 'Name', 'sportspress' )
|
||||
) );
|
||||
return apply_filters( 'sportspress_staff_admin_columns', $columns );
|
||||
}
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
*
|
||||
* @param string $text
|
||||
* @param object $post
|
||||
* @return string
|
||||
*/
|
||||
public function enter_title_here( $text, $post ) {
|
||||
if ( $post->post_type == 'sp_staff' ) {
|
||||
return __( 'Name', 'sportspress' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_role':
|
||||
echo get_the_terms( $post_id, 'sp_role' ) ? the_terms( $post_id, 'sp_role' ) : '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
if ( empty( $teams ) ):
|
||||
echo '—';
|
||||
else:
|
||||
$current_teams = get_post_meta( $post_id, 'sp_current_team', false );
|
||||
foreach( $teams as $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ):
|
||||
echo esc_html( $team->post_title );
|
||||
if ( in_array( $team_id, $current_teams ) ):
|
||||
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => null,
|
||||
'sp_role' => __( 'Job', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
),
|
||||
$existing_columns,
|
||||
array(
|
||||
'title' => __( 'Name', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
return apply_filters( 'sportspress_staff_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_role':
|
||||
echo get_the_terms( $post_id, 'sp_role' ) ? the_terms( $post_id, 'sp_role' ) : '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
$teams = (array) get_post_meta( $post_id, 'sp_team', false );
|
||||
$teams = array_filter( $teams );
|
||||
if ( empty( $teams ) ) :
|
||||
echo '—';
|
||||
else :
|
||||
$current_teams = get_post_meta( $post_id, 'sp_current_team', false );
|
||||
foreach ( $teams as $team_id ) :
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ) :
|
||||
echo esc_html( $team->post_title );
|
||||
if ( in_array( $team_id, $current_teams ) ) :
|
||||
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
||||
endif;
|
||||
echo '<br>';
|
||||
endif;
|
||||
echo '<br>';
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_staff' )
|
||||
return;
|
||||
if ( $typenow != 'sp_staff' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
}
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
global $typenow, $wp_query;
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow == 'sp_staff' ) {
|
||||
if ( $typenow == 'sp_staff' ) {
|
||||
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
}
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,80 +2,84 @@
|
||||
/**
|
||||
* Admin functions for the statistics post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Statistic' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Statistic Class
|
||||
*/
|
||||
class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Statistic Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_statistic';
|
||||
class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_statistic_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_statistic_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_statistic';
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_icon' => __( 'Icon', 'sportspress' ),
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Key', 'sportspress' ),
|
||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||
'sp_precision' => __( 'Decimal Places', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_statistic_admin_columns', $columns );
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_statistic_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_statistic_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_icon':
|
||||
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
||||
break;
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_equation':
|
||||
echo esc_html( sp_get_post_equation( $post_id ) );
|
||||
break;
|
||||
case 'sp_precision':
|
||||
echo esc_html( sp_get_post_precision( $post_id ) );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_icon' => __( 'Icon', 'sportspress' ),
|
||||
'title' => __( 'Label', 'sportspress' ),
|
||||
'sp_key' => __( 'Key', 'sportspress' ),
|
||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||
'sp_precision' => __( 'Decimal Places', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_statistic_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_icon':
|
||||
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
||||
break;
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo esc_html( $post->post_name );
|
||||
break;
|
||||
case 'sp_equation':
|
||||
echo esc_html( sp_get_post_equation( $post_id ) );
|
||||
break;
|
||||
case 'sp_precision':
|
||||
echo esc_html( sp_get_post_precision( $post_id ) );
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . wp_kses_post( $post->post_excerpt ) . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,136 +2,144 @@
|
||||
/**
|
||||
* Admin functions for the league tables post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.5
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.5
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Table' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Table Class
|
||||
*/
|
||||
class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Table Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_table';
|
||||
class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_table_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_table_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_table';
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_table_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_table_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
), $existing_columns );
|
||||
return apply_filters( 'sportspress_table_admin_columns', $columns );
|
||||
}
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
add_filter( 'parse_query', array( $this, 'filters_query' ) );
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_league':
|
||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
$select = get_post_meta( $post_id, 'sp_select', true );
|
||||
if ( 'manual' == $select ):
|
||||
$teams = array_filter( get_post_meta( $post_id, 'sp_team' ) );
|
||||
echo sizeof( $teams );
|
||||
else:
|
||||
_e( 'Auto', 'sportspress' );
|
||||
endif;
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['date'] );
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
),
|
||||
$existing_columns
|
||||
);
|
||||
return apply_filters( 'sportspress_table_admin_columns', $columns );
|
||||
}
|
||||
|
||||
if ( $typenow != 'sp_table' )
|
||||
return;
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_league':
|
||||
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
case 'sp_team':
|
||||
$select = get_post_meta( $post_id, 'sp_select', true );
|
||||
if ( 'manual' == $select ) :
|
||||
$teams = array_filter( get_post_meta( $post_id, 'sp_team' ) );
|
||||
echo sizeof( $teams );
|
||||
else :
|
||||
_e( 'Auto', 'sportspress' );
|
||||
endif;
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
if ( $typenow != 'sp_table' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
}
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
global $typenow, $wp_query;
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
if ( $typenow == 'sp_table' ) {
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_none' => __( 'Show all teams', 'sportspress' ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
}
|
||||
/**
|
||||
* Filter in admin based on options
|
||||
*
|
||||
* @param mixed $query
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow == 'sp_table' ) {
|
||||
|
||||
if ( ! empty( $_GET['team'] ) ) {
|
||||
$query->query_vars['meta_value'] = sanitize_key( $_GET['team'] );
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
@@ -2,131 +2,142 @@
|
||||
/**
|
||||
* Admin functions for the teams post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.6
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 2.6
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) )
|
||||
include( 'class-sp-admin-cpt.php' );
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||
require 'class-sp-admin-cpt.php';
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT_Team' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Team Class
|
||||
*/
|
||||
class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT_Team Class
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_team';
|
||||
class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
|
||||
// Post title fields
|
||||
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_team';
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_team_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_team_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
// Post title fields
|
||||
add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 1, 2 );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_team_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_team_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
|
||||
|
||||
// Filtering
|
||||
add_action( 'restrict_manage_posts', array( $this, 'filters' ) );
|
||||
|
||||
// Call SP_Admin_CPT constructor
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
*
|
||||
* @param string $text
|
||||
* @param object $post
|
||||
* @return string
|
||||
*/
|
||||
public function enter_title_here( $text, $post ) {
|
||||
if ( $post->post_type == 'sp_team' ) {
|
||||
return __( 'Name', 'sportspress' );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_icon' => '<span class="dashicons sp-icon-shield sp-tip" title="' . __( 'Logo', 'sportspress' ) . '"></span>',
|
||||
'title' => null,
|
||||
'sp_short_name' => __( 'Short Name', 'sportspress' ),
|
||||
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
),
|
||||
$existing_columns,
|
||||
array(
|
||||
'title' => __( 'Team', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
return apply_filters( 'sportspress_team_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) :
|
||||
case 'sp_icon':
|
||||
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
||||
break;
|
||||
case 'sp_short_name':
|
||||
$short_name = get_post_meta( $post_id, 'sp_short_name', true );
|
||||
echo $short_name ? esc_html( $short_name ) : '—';
|
||||
break;
|
||||
case 'sp_abbreviation':
|
||||
$abbreviation = get_post_meta( $post_id, 'sp_abbreviation', true );
|
||||
echo $abbreviation ? esc_html( $abbreviation ) : '—';
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_team' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
* @param string $text
|
||||
* @param object $post
|
||||
* @return string
|
||||
*/
|
||||
public function enter_title_here( $text, $post ) {
|
||||
if ( $post->post_type == 'sp_team' )
|
||||
return __( 'Name', 'sportspress' );
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_icon' => '<span class="dashicons sp-icon-shield sp-tip" title="' . __( 'Logo', 'sportspress' ) . '"></span>',
|
||||
'title' => null,
|
||||
'sp_short_name' => __( 'Short Name', 'sportspress' ),
|
||||
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
), $existing_columns, array(
|
||||
'title' => __( 'Team', 'sportspress' ),
|
||||
) );
|
||||
return apply_filters( 'sportspress_team_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_icon':
|
||||
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
||||
break;
|
||||
case 'sp_short_name':
|
||||
$short_name = get_post_meta ( $post_id, 'sp_short_name', true );
|
||||
echo $short_name ? esc_html( $short_name ) : '—';
|
||||
break;
|
||||
case 'sp_abbreviation':
|
||||
$abbreviation = get_post_meta ( $post_id, 'sp_abbreviation', true );
|
||||
echo $abbreviation ? esc_html( $abbreviation ) : '—';
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a category filter box
|
||||
*/
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_team' )
|
||||
return;
|
||||
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||
$args = array(
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_CPT_Team();
|
||||
|
||||
@@ -2,66 +2,70 @@
|
||||
/**
|
||||
* Admin functions for post types
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Admin_CPT' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT Class
|
||||
*/
|
||||
class SP_Admin_CPT {
|
||||
|
||||
protected $type = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* SP_Admin_CPT Class
|
||||
*/
|
||||
public function __construct() {
|
||||
// Insert into X media browser
|
||||
add_filter( 'media_view_strings', array( $this, 'change_insert_into_post' ) );
|
||||
class SP_Admin_CPT {
|
||||
|
||||
protected $type = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Insert into X media browser
|
||||
add_filter( 'media_view_strings', array( $this, 'change_insert_into_post' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Change label for insert buttons.
|
||||
*
|
||||
* @access public
|
||||
* @param array $strings
|
||||
* @return array
|
||||
*/
|
||||
function change_insert_into_post( $strings ) {
|
||||
global $post_type;
|
||||
|
||||
if ( $post_type == $this->type ) {
|
||||
$obj = get_post_type_object( $this->type );
|
||||
|
||||
$strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'sportspress' ), $obj->labels->singular_name );
|
||||
$strings['uploadedToThisPost'] = sprintf( __( 'Uploaded to this %s', 'sportspress' ), $obj->labels->singular_name );
|
||||
}
|
||||
|
||||
return $strings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding an event
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
if ( ! empty( $_GET['post_type'] ) && $this->type == $_GET['post_type'] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_GET['post'] ) && $this->type == get_post_type( $_GET['post'] ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && $this->type == get_post_type( $_REQUEST['post_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change label for insert buttons.
|
||||
* @access public
|
||||
* @param array $strings
|
||||
* @return array
|
||||
*/
|
||||
function change_insert_into_post( $strings ) {
|
||||
global $post_type;
|
||||
|
||||
if ( $post_type == $this->type ) {
|
||||
$obj = get_post_type_object( $this->type );
|
||||
|
||||
$strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'sportspress' ), $obj->labels->singular_name );
|
||||
$strings['uploadedToThisPost'] = sprintf( __( 'Uploaded to this %s', 'sportspress' ), $obj->labels->singular_name );
|
||||
}
|
||||
|
||||
return $strings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding an event
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
if ( ! empty( $_GET['post_type'] ) && $this->type == $_GET['post_type'] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_GET['post'] ) && $this->type == get_post_type( $_GET['post'] ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && $this->type == get_post_type( $_REQUEST['post_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
endif;
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
*
|
||||
* Sets up the write panels used by custom post types
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.6.8
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.6.8
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Admin_Meta_Boxes
|
||||
@@ -27,202 +29,202 @@ class SP_Admin_Meta_Boxes {
|
||||
*/
|
||||
public function __construct() {
|
||||
$meta_boxes = array(
|
||||
'sp_outcome' => array(
|
||||
'sp_outcome' => array(
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Outcome_Details::save',
|
||||
'output' => 'SP_Meta_Box_Outcome_Details::output',
|
||||
'context' => 'normal',
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Outcome_Details::save',
|
||||
'output' => 'SP_Meta_Box_Outcome_Details::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
),
|
||||
'sp_result' => array(
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Result_Details::save',
|
||||
'output' => 'SP_Meta_Box_Result_Details::output',
|
||||
'context' => 'side',
|
||||
'sp_result' => array(
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Result_Details::save',
|
||||
'output' => 'SP_Meta_Box_Result_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'equation' => array(
|
||||
'title' => __( 'Equation', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Result_Equation::save',
|
||||
'output' => 'SP_Meta_Box_Result_Equation::output',
|
||||
'context' => 'normal',
|
||||
'title' => __( 'Equation', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Result_Equation::save',
|
||||
'output' => 'SP_Meta_Box_Result_Equation::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
),
|
||||
'sp_performance' => array(
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Performance_Details::save',
|
||||
'output' => 'SP_Meta_Box_Performance_Details::output',
|
||||
'context' => 'normal',
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Performance_Details::save',
|
||||
'output' => 'SP_Meta_Box_Performance_Details::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
'equation' => array(
|
||||
'title' => __( 'Equation', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Performance_Equation::save',
|
||||
'output' => 'SP_Meta_Box_Performance_Equation::output',
|
||||
'context' => 'normal',
|
||||
'title' => __( 'Equation', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Performance_Equation::save',
|
||||
'output' => 'SP_Meta_Box_Performance_Equation::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
),
|
||||
'sp_column' => array(
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Column_Details::save',
|
||||
'output' => 'SP_Meta_Box_Column_Details::output',
|
||||
'context' => 'side',
|
||||
'sp_column' => array(
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Column_Details::save',
|
||||
'output' => 'SP_Meta_Box_Column_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'equation' => array(
|
||||
'title' => __( 'Equation', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Column_Equation::save',
|
||||
'output' => 'SP_Meta_Box_Column_Equation::output',
|
||||
'context' => 'normal',
|
||||
'title' => __( 'Equation', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Column_Equation::save',
|
||||
'output' => 'SP_Meta_Box_Column_Equation::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
),
|
||||
'sp_metric' => array(
|
||||
'sp_metric' => array(
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Metric_Details::save',
|
||||
'output' => 'SP_Meta_Box_Metric_Details::output',
|
||||
'context' => 'normal',
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Metric_Details::save',
|
||||
'output' => 'SP_Meta_Box_Metric_Details::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
),
|
||||
'sp_statistic' => array(
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Statistic_Details::save',
|
||||
'output' => 'SP_Meta_Box_Statistic_Details::output',
|
||||
'context' => 'side',
|
||||
'sp_statistic' => array(
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Statistic_Details::save',
|
||||
'output' => 'SP_Meta_Box_Statistic_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'equation' => array(
|
||||
'title' => __( 'Equation', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Statistic_Equation::save',
|
||||
'output' => 'SP_Meta_Box_Statistic_Equation::output',
|
||||
'context' => 'normal',
|
||||
'title' => __( 'Equation', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Statistic_Equation::save',
|
||||
'output' => 'SP_Meta_Box_Statistic_Equation::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
),
|
||||
'sp_event' => array(
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcodes', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Event_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'sp_event' => array(
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcodes', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Event_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'format' => array(
|
||||
'title' => __( 'Format', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Format::save',
|
||||
'output' => 'SP_Meta_Box_Event_Format::output',
|
||||
'context' => 'side',
|
||||
'format' => array(
|
||||
'title' => __( 'Format', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Format::save',
|
||||
'output' => 'SP_Meta_Box_Event_Format::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'mode' => array(
|
||||
'title' => __( 'Mode', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Mode::save',
|
||||
'output' => 'SP_Meta_Box_Event_Mode::output',
|
||||
'context' => 'side',
|
||||
'mode' => array(
|
||||
'title' => __( 'Mode', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Mode::save',
|
||||
'output' => 'SP_Meta_Box_Event_Mode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Details::save',
|
||||
'output' => 'SP_Meta_Box_Event_Details::output',
|
||||
'context' => 'side',
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Details::save',
|
||||
'output' => 'SP_Meta_Box_Event_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'team' => array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Teams::save',
|
||||
'output' => 'SP_Meta_Box_Event_Teams::output',
|
||||
'context' => 'side',
|
||||
'team' => array(
|
||||
'title' => __( 'Teams', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Teams::save',
|
||||
'output' => 'SP_Meta_Box_Event_Teams::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'results' => array(
|
||||
'title' => __( 'Results', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Results::save',
|
||||
'output' => 'SP_Meta_Box_Event_Results::output',
|
||||
'context' => 'normal',
|
||||
'results' => array(
|
||||
'title' => __( 'Results', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Results::save',
|
||||
'output' => 'SP_Meta_Box_Event_Results::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
'performance' => array(
|
||||
'title' => __( 'Box Score', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Performance::save',
|
||||
'output' => 'SP_Meta_Box_Event_Performance::output',
|
||||
'context' => 'normal',
|
||||
'title' => __( 'Box Score', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Event_Performance::save',
|
||||
'output' => 'SP_Meta_Box_Event_Performance::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
),
|
||||
'sp_team' => array(
|
||||
'sp_team' => array(
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Team_Details::save',
|
||||
'output' => 'SP_Meta_Box_Team_Details::output',
|
||||
'context' => 'side',
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Team_Details::save',
|
||||
'output' => 'SP_Meta_Box_Team_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'staff' => array(
|
||||
'title' => __( 'Staff', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Team_Staff::save',
|
||||
'output' => 'SP_Meta_Box_Team_Staff::output',
|
||||
'context' => 'normal',
|
||||
'staff' => array(
|
||||
'title' => __( 'Staff', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Team_Staff::save',
|
||||
'output' => 'SP_Meta_Box_Team_Staff::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
),
|
||||
'sp_player' => array(
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcodes', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Player_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'sp_player' => array(
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcodes', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Player_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'columns' => array(
|
||||
'title' => __( 'Columns', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Player_Columns::save',
|
||||
'output' => 'SP_Meta_Box_Player_Columns::output',
|
||||
'context' => 'side',
|
||||
'columns' => array(
|
||||
'title' => __( 'Columns', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Player_Columns::save',
|
||||
'output' => 'SP_Meta_Box_Player_Columns::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Player_Details::save',
|
||||
'output' => 'SP_Meta_Box_Player_Details::output',
|
||||
'context' => 'side',
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Player_Details::save',
|
||||
'output' => 'SP_Meta_Box_Player_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'metrics' => array(
|
||||
'title' => __( 'Metrics', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Player_Metrics::save',
|
||||
'output' => 'SP_Meta_Box_Player_Metrics::output',
|
||||
'context' => 'side',
|
||||
'metrics' => array(
|
||||
'title' => __( 'Metrics', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Player_Metrics::save',
|
||||
'output' => 'SP_Meta_Box_Player_Metrics::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'statistics' => array(
|
||||
'title' => __( 'Statistics', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Player_Statistics::save',
|
||||
'output' => 'SP_Meta_Box_Player_Statistics::output',
|
||||
'context' => 'normal',
|
||||
'title' => __( 'Statistics', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Player_Statistics::save',
|
||||
'output' => 'SP_Meta_Box_Player_Statistics::output',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high',
|
||||
),
|
||||
),
|
||||
'sp_staff' => array(
|
||||
'sp_staff' => array(
|
||||
'shortcode' => array(
|
||||
'title' => __( 'Shortcode', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Staff_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'title' => __( 'Shortcode', 'sportspress' ),
|
||||
'output' => 'SP_Meta_Box_Staff_Shortcode::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Staff_Details::save',
|
||||
'output' => 'SP_Meta_Box_Staff_Details::output',
|
||||
'context' => 'side',
|
||||
'details' => array(
|
||||
'title' => __( 'Details', 'sportspress' ),
|
||||
'save' => 'SP_Meta_Box_Staff_Details::save',
|
||||
'output' => 'SP_Meta_Box_Staff_Details::output',
|
||||
'context' => 'side',
|
||||
'priority' => 'default',
|
||||
),
|
||||
),
|
||||
@@ -303,7 +305,7 @@ class SP_Admin_Meta_Boxes {
|
||||
|
||||
remove_meta_box( 'postimagediv', 'sp_performance', 'side' );
|
||||
add_meta_box( 'postimagediv', __( 'Icon', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_performance', 'side', 'low' );
|
||||
|
||||
|
||||
remove_meta_box( 'postimagediv', 'sp_statistic', 'side' );
|
||||
add_meta_box( 'postimagediv', __( 'Icon', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_statistic', 'side', 'low' );
|
||||
}
|
||||
@@ -311,17 +313,31 @@ class SP_Admin_Meta_Boxes {
|
||||
/**
|
||||
* Check if we're saving, then trigger an action based on the post type
|
||||
*
|
||||
* @param int $post_id
|
||||
* @param int $post_id
|
||||
* @param object $post
|
||||
*/
|
||||
public function save_meta_boxes( $post_id, $post ) {
|
||||
if ( empty( $post_id ) || empty( $post ) ) return;
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
|
||||
if ( is_int( wp_is_post_revision( $post ) ) ) return;
|
||||
if ( is_int( wp_is_post_autosave( $post ) ) ) return;
|
||||
if ( empty( $_POST['sportspress_meta_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_meta_nonce'], 'sportspress_save_data' ) ) return;
|
||||
if ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) return;
|
||||
if ( ! is_sp_post_type( $post->post_type ) && ! is_sp_config_type( $post->post_type ) ) return;
|
||||
if ( empty( $post_id ) || empty( $post ) ) {
|
||||
return;
|
||||
}
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
return;
|
||||
}
|
||||
if ( is_int( wp_is_post_revision( $post ) ) ) {
|
||||
return;
|
||||
}
|
||||
if ( is_int( wp_is_post_autosave( $post ) ) ) {
|
||||
return;
|
||||
}
|
||||
if ( empty( $_POST['sportspress_meta_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_meta_nonce'], 'sportspress_save_data' ) ) {
|
||||
return;
|
||||
}
|
||||
if ( ! apply_filters( 'sportspress_user_can', current_user_can( 'edit_post', $post_id ), $post_id ) ) {
|
||||
return;
|
||||
}
|
||||
if ( ! is_sp_post_type( $post->post_type ) && ! is_sp_config_type( $post->post_type ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Calendar Columns
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Calendar_Columns
|
||||
@@ -19,9 +21,9 @@ class SP_Meta_Box_Calendar_Columns {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
|
||||
$selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
|
||||
$title_format = get_option( 'sportspress_event_list_title_format', 'title' );
|
||||
$time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
|
||||
$time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
|
||||
|
||||
if ( is_array( $selected ) ) {
|
||||
$selected = array_filter( $selected );
|
||||
@@ -30,11 +32,11 @@ class SP_Meta_Box_Calendar_Columns {
|
||||
$columns = array();
|
||||
|
||||
if ( 'teams' === $title_format ) {
|
||||
$columns[ 'event' ] = __( 'Home', 'sportspress' ) . ' | ' . __( 'Away', 'sportspress' );
|
||||
$columns['event'] = __( 'Home', 'sportspress' ) . ' | ' . __( 'Away', 'sportspress' );
|
||||
} elseif ( 'homeaway' === $title_format ) {
|
||||
$columns[ 'event' ] = __( 'Teams', 'sportspress' );
|
||||
$columns['event'] = __( 'Teams', 'sportspress' );
|
||||
} else {
|
||||
$columns[ 'event' ] = __( 'Title', 'sportspress' );
|
||||
$columns['event'] = __( 'Title', 'sportspress' );
|
||||
}
|
||||
|
||||
if ( 'time' === $time_format || 'separate' === $time_format ) {
|
||||
@@ -47,27 +49,27 @@ class SP_Meta_Box_Calendar_Columns {
|
||||
$columns['results'] = __( 'Results', 'sportspress' );
|
||||
}
|
||||
|
||||
$columns['league'] = __( 'League', 'sportspress' );
|
||||
$columns['season'] = __( 'Season', 'sportspress' );
|
||||
$columns['venue'] = __( 'Venue', 'sportspress' );
|
||||
$columns['league'] = __( 'League', 'sportspress' );
|
||||
$columns['season'] = __( 'Season', 'sportspress' );
|
||||
$columns['venue'] = __( 'Venue', 'sportspress' );
|
||||
$columns['article'] = __( 'Article', 'sportspress' );
|
||||
$columns['day'] = __( 'Match Day', 'sportspress' );
|
||||
$columns['day'] = __( 'Match Day', 'sportspress' );
|
||||
|
||||
$columns = apply_filters( 'sportspress_calendar_columns', $columns );
|
||||
?>
|
||||
<div class="sp-instance">
|
||||
<ul class="categorychecklist form-no-clear">
|
||||
<?php
|
||||
foreach ( $columns as $key => $label ) {
|
||||
?>
|
||||
foreach ( $columns as $key => $label ) {
|
||||
?>
|
||||
<li>
|
||||
<label>
|
||||
<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 ) ); ?>>
|
||||
<?php echo esc_html( $label ); ?>
|
||||
<?php echo esc_html( $label ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
@@ -79,4 +81,4 @@ class SP_Meta_Box_Calendar_Columns {
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array(), 'text' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Calendar Events
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Calendar_Data
|
||||
@@ -19,8 +21,8 @@ class SP_Meta_Box_Calendar_Data {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$calendar = new SP_Calendar( $post );
|
||||
$data = $calendar->data();
|
||||
$calendar = new SP_Calendar( $post );
|
||||
$data = $calendar->data();
|
||||
$usecolumns = $calendar->columns;
|
||||
self::table( $data, $usecolumns );
|
||||
}
|
||||
@@ -37,11 +39,11 @@ class SP_Meta_Box_Calendar_Data {
|
||||
*/
|
||||
public static function table( $data = array(), $usecolumns = null ) {
|
||||
$title_format = get_option( 'sportspress_event_list_title_format', 'title' );
|
||||
$time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
|
||||
$time_format = get_option( 'sportspress_event_list_time_format', 'combined' );
|
||||
|
||||
if ( is_array( $usecolumns ) ) {
|
||||
$usecolumns = array_filter( $usecolumns );
|
||||
}else{
|
||||
} else {
|
||||
$usecolumns = array();
|
||||
}
|
||||
?>
|
||||
@@ -57,7 +59,11 @@ class SP_Meta_Box_Calendar_Data {
|
||||
<label for="sp_columns_event">
|
||||
<?php
|
||||
if ( 'teams' == $title_format ) {
|
||||
_e( 'Home', 'sportspress' ); ?> | <?php _e( 'Away', 'sportspress' );
|
||||
_e( 'Home', 'sportspress' );
|
||||
?>
|
||||
|
|
||||
<?php
|
||||
_e( 'Away', 'sportspress' );
|
||||
} elseif ( 'homeaway' == $title_format ) {
|
||||
_e( 'Teams', 'sportspress' );
|
||||
} else {
|
||||
@@ -127,50 +133,64 @@ class SP_Meta_Box_Calendar_Data {
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( is_array( $data ) ):
|
||||
if ( sizeof( $data ) > 0 ):
|
||||
if ( is_array( $data ) ) :
|
||||
if ( sizeof( $data ) > 0 ) :
|
||||
$main_result = get_option( 'sportspress_primary_result', null );
|
||||
$i = 0;
|
||||
foreach ( $data as $event ):
|
||||
$teams = get_post_meta( $event->ID, 'sp_team' );
|
||||
$results = get_post_meta( $event->ID, 'sp_results', true );
|
||||
$video = get_post_meta( $event->ID, 'sp_video', true );
|
||||
$i = 0;
|
||||
foreach ( $data as $event ) :
|
||||
$teams = get_post_meta( $event->ID, 'sp_team' );
|
||||
$results = get_post_meta( $event->ID, 'sp_results', true );
|
||||
$video = get_post_meta( $event->ID, 'sp_video', true );
|
||||
$main_results = array();
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<tr class="sp-row sp-post
|
||||
<?php
|
||||
if ( $i % 2 == 0 ) {
|
||||
echo ' alternate';}
|
||||
?>
|
||||
">
|
||||
<td><?php echo get_post_time( get_option( 'date_format' ), false, $event, true ); ?></td>
|
||||
<?php if ( is_array( $usecolumns ) && in_array( 'event', $usecolumns ) ) { ?>
|
||||
<td>
|
||||
<div class="sp-title-format sp-title-format-title<?php if ( $title_format && $title_format != 'title' ): ?> hidden<?php endif; ?>"><?php echo esc_html( $event->post_title ); ?></div>
|
||||
<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; ?>">
|
||||
<div class="sp-title-format sp-title-format-title
|
||||
<?php
|
||||
if ( $title_format && $title_format != 'title' ) :
|
||||
?>
|
||||
hidden<?php endif; ?>"><?php echo esc_html( $event->post_title ); ?></div>
|
||||
<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; ?>">
|
||||
<?php
|
||||
if ( $teams ): foreach ( $teams as $team ):
|
||||
$name = get_the_title( $team );
|
||||
if ( $name ):
|
||||
$team_results = sp_array_value( $results, $team, null );
|
||||
if ( $teams ) :
|
||||
foreach ( $teams as $team ) :
|
||||
$name = get_the_title( $team );
|
||||
if ( $name ) :
|
||||
$team_results = sp_array_value( $results, $team, null );
|
||||
|
||||
if ( $main_result ):
|
||||
$team_result = sp_array_value( $team_results, $main_result, null );
|
||||
else:
|
||||
if ( is_array( $team_results ) ):
|
||||
end( $team_results );
|
||||
$team_result = prev( $team_results );
|
||||
else:
|
||||
$team_result = null;
|
||||
if ( $main_result ) :
|
||||
$team_result = sp_array_value( $team_results, $main_result, null );
|
||||
else :
|
||||
if ( is_array( $team_results ) ) :
|
||||
end( $team_results );
|
||||
$team_result = prev( $team_results );
|
||||
else :
|
||||
$team_result = null;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
if ( $team_result != null ):
|
||||
$team_result = apply_filters( 'sportspress_calendar_team_result_admin', $team_result, $event->ID, $team );
|
||||
$main_results[] = $team_result;
|
||||
unset( $team_results['outcome'] );
|
||||
$team_results = implode( ' | ', $team_results );
|
||||
echo '<a class="result sp-tip" title="' . $team_results . '" href="' . get_edit_post_link( $event->ID ) . '">' . $team_result . '</a> ';
|
||||
endif;
|
||||
if ( $team_result != null ) :
|
||||
$team_result = apply_filters( 'sportspress_calendar_team_result_admin', $team_result, $event->ID, $team );
|
||||
$main_results[] = $team_result;
|
||||
unset( $team_results['outcome'] );
|
||||
$team_results = implode( ' | ', $team_results );
|
||||
echo '<a class="result sp-tip" title="' . $team_results . '" href="' . get_edit_post_link( $event->ID ) . '">' . $team_result . '</a> ';
|
||||
endif;
|
||||
|
||||
echo esc_html( $name ) . '<br>';
|
||||
endif;
|
||||
endforeach; else:
|
||||
echo esc_html( $name ) . '<br>';
|
||||
endif;
|
||||
endforeach; else :
|
||||
echo '—';
|
||||
endif;
|
||||
?>
|
||||
@@ -185,24 +205,24 @@ class SP_Meta_Box_Calendar_Data {
|
||||
<?php } else { ?>
|
||||
<td>
|
||||
<?php
|
||||
if ( ! empty( $main_results ) ):
|
||||
echo implode( ' - ', $main_results );
|
||||
else:
|
||||
if ( ! empty( $main_results ) ) :
|
||||
echo implode( ' - ', $main_results );
|
||||
else :
|
||||
echo apply_filters( 'sportspress_event_time_admin', get_post_time( get_option( 'time_format' ), false, $event, true ), $event->ID );
|
||||
endif;
|
||||
?>
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php if ( ( is_array( $usecolumns ) && in_array( 'results', $usecolumns ) ) && in_array( $time_format, array( 'separate', 'results' ) ) ) { ?>
|
||||
<td>
|
||||
<?php
|
||||
if ( ! empty( $main_results ) ):
|
||||
echo implode( ' - ', $main_results );
|
||||
else:
|
||||
if ( ! empty( $main_results ) ) :
|
||||
echo implode( ' - ', $main_results );
|
||||
else :
|
||||
echo '-';
|
||||
endif;
|
||||
?>
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php if ( is_array( $usecolumns ) && in_array( 'league', $usecolumns ) ) { ?>
|
||||
@@ -217,17 +237,17 @@ class SP_Meta_Box_Calendar_Data {
|
||||
<?php if ( is_array( $usecolumns ) && in_array( 'article', $usecolumns ) ) { ?>
|
||||
<td>
|
||||
<a href="<?php echo get_edit_post_link( $event->ID ); ?>#sp_articlediv">
|
||||
<?php if ( $video ): ?>
|
||||
<?php if ( $video ) : ?>
|
||||
<div class="dashicons dashicons-video-alt"></div>
|
||||
<?php elseif ( has_post_thumbnail( $event->ID ) ): ?>
|
||||
<?php elseif ( has_post_thumbnail( $event->ID ) ) : ?>
|
||||
<div class="dashicons dashicons-camera"></div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if ( $event->post_content == null ):
|
||||
if ( $event->post_content == null ) :
|
||||
_e( 'None', 'sportspress' );
|
||||
elseif ( $event->post_status == 'publish' ):
|
||||
elseif ( $event->post_status == 'publish' ) :
|
||||
_e( 'Recap', 'sportspress' );
|
||||
else:
|
||||
else :
|
||||
_e( 'Preview', 'sportspress' );
|
||||
endif;
|
||||
?>
|
||||
@@ -251,7 +271,7 @@ class SP_Meta_Box_Calendar_Data {
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
else:
|
||||
else :
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="<?php echo sizeof( $usecolumns ); ?>">
|
||||
@@ -260,14 +280,14 @@ class SP_Meta_Box_Calendar_Data {
|
||||
</tr>
|
||||
<?php
|
||||
endif;
|
||||
else:
|
||||
?>
|
||||
else :
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="<?php echo sizeof( $usecolumns ); ?>">
|
||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Details', 'sportspress' ) ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</tbody>
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Calendar Details
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Calendar_Details
|
||||
@@ -19,22 +21,22 @@ class SP_Meta_Box_Calendar_Details {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$taxonomies = get_object_taxonomies( 'sp_calendar' );
|
||||
$caption = get_post_meta( $post->ID, 'sp_caption', true );
|
||||
$status = get_post_meta( $post->ID, 'sp_status', true );
|
||||
$date = get_post_meta( $post->ID, 'sp_date', true );
|
||||
$date_from = get_post_meta( $post->ID, 'sp_date_from', true );
|
||||
$date_to = get_post_meta( $post->ID, 'sp_date_to', true );
|
||||
$date_past = get_post_meta( $post->ID, 'sp_date_past', true );
|
||||
$date_future = get_post_meta( $post->ID, 'sp_date_future', true );
|
||||
$taxonomies = get_object_taxonomies( 'sp_calendar' );
|
||||
$caption = get_post_meta( $post->ID, 'sp_caption', true );
|
||||
$status = get_post_meta( $post->ID, 'sp_status', true );
|
||||
$date = get_post_meta( $post->ID, 'sp_date', true );
|
||||
$date_from = get_post_meta( $post->ID, 'sp_date_from', true );
|
||||
$date_to = get_post_meta( $post->ID, 'sp_date_to', true );
|
||||
$date_past = get_post_meta( $post->ID, 'sp_date_past', true );
|
||||
$date_future = get_post_meta( $post->ID, 'sp_date_future', true );
|
||||
$date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
|
||||
$event_format = get_post_meta( $post->ID, 'sp_event_format', true );
|
||||
$day = get_post_meta( $post->ID, 'sp_day', true );
|
||||
$teams = get_post_meta( $post->ID, 'sp_team', false );
|
||||
$players = get_post_meta( $post->ID, 'sp_player', false );
|
||||
$table_id = get_post_meta( $post->ID, 'sp_table', true );
|
||||
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
||||
$event_format = get_post_meta( $post->ID, 'sp_event_format', true );
|
||||
$day = get_post_meta( $post->ID, 'sp_day', true );
|
||||
$teams = get_post_meta( $post->ID, 'sp_team', false );
|
||||
$players = get_post_meta( $post->ID, 'sp_player', false );
|
||||
$table_id = get_post_meta( $post->ID, 'sp_table', true );
|
||||
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
|
||||
@@ -44,8 +46,8 @@ class SP_Meta_Box_Calendar_Details {
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'name' => 'sp_status',
|
||||
'id' => 'sp_status',
|
||||
'name' => 'sp_status',
|
||||
'id' => 'sp_status',
|
||||
'selected' => $status,
|
||||
);
|
||||
sp_dropdown_statuses( $args );
|
||||
@@ -55,7 +57,7 @@ class SP_Meta_Box_Calendar_Details {
|
||||
<p>
|
||||
<select name="sp_event_format" class="postform">
|
||||
<option value="all">All</option>
|
||||
<?php foreach ( SP()->formats->event as $key => $format ): ?>
|
||||
<?php foreach ( SP()->formats->event as $key => $format ) : ?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $event_format, $key ); ?>><?php echo esc_html( $format ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
@@ -65,8 +67,8 @@ class SP_Meta_Box_Calendar_Details {
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'name' => 'sp_date',
|
||||
'id' => 'sp_date',
|
||||
'name' => 'sp_date',
|
||||
'id' => 'sp_date',
|
||||
'selected' => $date,
|
||||
);
|
||||
sp_dropdown_dates( $args );
|
||||
@@ -112,17 +114,17 @@ class SP_Meta_Box_Calendar_Details {
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_team[]',
|
||||
'selected' => $teams,
|
||||
'values' => 'ID',
|
||||
'class' => 'widefat',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_team[]',
|
||||
'selected' => $teams,
|
||||
'values' => 'ID',
|
||||
'class' => 'widefat',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
'placeholder' => __( 'All', 'sportspress' ),
|
||||
);
|
||||
if ( ! sp_dropdown_pages( $args ) ):
|
||||
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||
if ( ! sp_dropdown_pages( $args ) ) :
|
||||
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
@@ -130,17 +132,17 @@ class SP_Meta_Box_Calendar_Details {
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_player',
|
||||
'name' => 'sp_player[]',
|
||||
'selected' => $players,
|
||||
'values' => 'ID',
|
||||
'class' => 'widefat',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
'post_type' => 'sp_player',
|
||||
'name' => 'sp_player[]',
|
||||
'selected' => $players,
|
||||
'values' => 'ID',
|
||||
'class' => 'widefat',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
'placeholder' => __( 'All', 'sportspress' ),
|
||||
);
|
||||
if ( ! sp_dropdown_pages( $args ) ):
|
||||
sp_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
|
||||
if ( ! sp_dropdown_pages( $args ) ) :
|
||||
sp_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
@@ -184,4 +186,4 @@ class SP_Meta_Box_Calendar_Details {
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array(), 'int' ) );
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array(), 'int' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
*
|
||||
* Based on a tutorial by Steve Thomas.
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Calendar_Feeds
|
||||
@@ -21,7 +23,7 @@ class SP_Meta_Box_Calendar_Feeds {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$feeds = new SP_Feeds();
|
||||
$feeds = new SP_Feeds();
|
||||
$calendar_feeds = $feeds->calendar;
|
||||
?>
|
||||
<div>
|
||||
@@ -52,4 +54,4 @@ class SP_Meta_Box_Calendar_Feeds {
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Calendar Format
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Calendar_Format
|
||||
@@ -23,7 +25,7 @@ class SP_Meta_Box_Calendar_Format {
|
||||
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
||||
?>
|
||||
<div id="post-formats-select">
|
||||
<?php foreach ( SP()->formats->calendar as $key => $format ): ?>
|
||||
<?php foreach ( SP()->formats->calendar as $key => $format ) : ?>
|
||||
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( true, ( $key == 'calendar' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $format ); ?></label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
@@ -36,4 +38,4 @@ class SP_Meta_Box_Calendar_Format {
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'calendar', 'text' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Calendar Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 1.6.1
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Calendar_Shortcode
|
||||
@@ -20,7 +22,9 @@ class SP_Meta_Box_Calendar_Shortcode {
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
||||
if ( ! $the_format ) $the_format = 'calendar';
|
||||
if ( ! $the_format ) {
|
||||
$the_format = 'calendar';
|
||||
}
|
||||
?>
|
||||
<p class="howto">
|
||||
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
|
||||
@@ -28,4 +32,4 @@ class SP_Meta_Box_Calendar_Shortcode {
|
||||
<p><input type="text" value="<?php sp_shortcode_template( 'event_' . $the_format, $post->ID ); ?>" readonly="readonly" class="code widefat"></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,19 @@
|
||||
/**
|
||||
* Column Details
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Meta_Box_Config' ) )
|
||||
include( 'class-sp-meta-box-config.php' );
|
||||
if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
|
||||
require 'class-sp-meta-box-config.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Column_Details
|
||||
@@ -23,13 +26,15 @@ class SP_Meta_Box_Column_Details extends SP_Meta_Box_Config {
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
||||
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
||||
$priority = get_post_meta( $post->ID, 'sp_priority', true );
|
||||
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
|
||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
||||
$priority = get_post_meta( $post->ID, 'sp_priority', true );
|
||||
$precision = get_post_meta( $post->ID, 'sp_precision', true );
|
||||
|
||||
// Defaults
|
||||
if ( $precision == '' ) $precision = 0;
|
||||
if ( $precision == '' ) {
|
||||
$precision = 0;
|
||||
}
|
||||
?>
|
||||
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
@@ -45,19 +50,22 @@ class SP_Meta_Box_Column_Details extends SP_Meta_Box_Config {
|
||||
<select name="sp_priority">
|
||||
<?php
|
||||
$options = array( '0' => __( 'Disable', 'sportspress' ) );
|
||||
$count = wp_count_posts( 'sp_column' );
|
||||
for( $i = 1; $i <= $count->publish; $i++ ):
|
||||
$count = wp_count_posts( 'sp_column' );
|
||||
for ( $i = 1; $i <= $count->publish; $i++ ) :
|
||||
$options[ $i ] = $i;
|
||||
endfor;
|
||||
foreach ( $options as $key => $value ):
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
<select name="sp_order">
|
||||
<?php
|
||||
$options = array( 'DESC' => __( 'Descending', 'sportspress' ), 'ASC' => __( 'Ascending', 'sportspress' ) );
|
||||
foreach ( $options as $key => $value ):
|
||||
$options = array(
|
||||
'DESC' => __( 'Descending', 'sportspress' ),
|
||||
'ASC' => __( 'Ascending', 'sportspress' ),
|
||||
);
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $order, false ), $value );
|
||||
endforeach;
|
||||
?>
|
||||
@@ -75,4 +83,4 @@ class SP_Meta_Box_Column_Details extends SP_Meta_Box_Config {
|
||||
update_post_meta( $post_id, 'sp_priority', sp_array_value( $_POST, 'sp_priority', '0', 'int' ) );
|
||||
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', 'DESC', 'text' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,19 @@
|
||||
/**
|
||||
* Column Equation
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 1.9.4
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'SP_Meta_Box_Equation' ) )
|
||||
include( 'class-sp-meta-box-equation.php' );
|
||||
if ( ! class_exists( 'SP_Meta_Box_Equation' ) ) {
|
||||
require 'class-sp-meta-box-equation.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Column_Equation
|
||||
@@ -25,4 +28,4 @@ class SP_Meta_Box_Column_Equation extends SP_Meta_Box_Equation {
|
||||
$equation = get_post_meta( $post->ID, 'sp_equation', true );
|
||||
self::builder( $post->post_title, $equation, array( 'team_event', 'outcome', 'result', 'subset', 'preset' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Config type meta box functions
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Config
|
||||
@@ -26,14 +28,16 @@ class SP_Meta_Box_Config {
|
||||
global $wpdb;
|
||||
|
||||
$key = isset( $post['sp_key'] ) ? $post['sp_key'] : null;
|
||||
if ( ! $key ) $key = $post['post_title'];
|
||||
$id = sp_array_value( $post, 'post_ID', 'var' );
|
||||
if ( ! $key ) {
|
||||
$key = $post['post_title'];
|
||||
}
|
||||
$id = sp_array_value( $post, 'post_ID', 'var' );
|
||||
$title = sp_get_eos_safe_slug( $key, $id );
|
||||
|
||||
$check_sql = "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
|
||||
$check_sql = "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
|
||||
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $title, $post['post_type'], $id ) );
|
||||
|
||||
if ( $post_name_check ):
|
||||
if ( $post_name_check ) :
|
||||
wp_delete_post( $post_name_check, true );
|
||||
$post['post_status'] = 'draft';
|
||||
endif;
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Equation meta box functions
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Equation
|
||||
@@ -23,88 +25,146 @@ class SP_Meta_Box_Equation {
|
||||
}
|
||||
|
||||
public static function builder( $title = 'f(x)', $equation = '', $groups = array() ) {
|
||||
if ( $title == '' ) $title = 'f(x)';
|
||||
if ( $title == '' ) {
|
||||
$title = 'f(x)';
|
||||
}
|
||||
$options = array(); // Multidimensional equation part options
|
||||
$parts = array(); // Flattened equation part options
|
||||
$parts = array(); // Flattened equation part options
|
||||
|
||||
// Add groups to options
|
||||
foreach ( $groups as $group ):
|
||||
switch ( $group ):
|
||||
foreach ( $groups as $group ) :
|
||||
switch ( $group ) :
|
||||
case 'player_event':
|
||||
$options[ 'Events' ] = array( '$eventsattended' => __( 'Attended', 'sportspress' ), '$eventsplayed' => __( 'Played', 'sportspress' ), '$eventsstarted' => __( 'Started', 'sportspress' ), '$eventssubbed' => __( 'Substituted', 'sportspress' ), '$eventminutes' => __( 'Minutes', 'sportspress' ) );
|
||||
$options['Events'] = array(
|
||||
'$eventsattended' => __( 'Attended', 'sportspress' ),
|
||||
'$eventsplayed' => __( 'Played', 'sportspress' ),
|
||||
'$eventsstarted' => __( 'Started', 'sportspress' ),
|
||||
'$eventssubbed' => __( 'Substituted', 'sportspress' ),
|
||||
'$eventminutes' => __( 'Minutes', 'sportspress' ),
|
||||
);
|
||||
break;
|
||||
case 'team_event':
|
||||
$options[ 'Events' ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ), '$eventminutes' => __( 'Minutes', 'sportspress' ) );
|
||||
$options['Events'] = array(
|
||||
'$eventsplayed' => __( 'Played', 'sportspress' ),
|
||||
'$eventminutes' => __( 'Minutes', 'sportspress' ),
|
||||
);
|
||||
break;
|
||||
case 'result':
|
||||
$options[ 'Results' ] = self::optgroup( 'sp_result', array( 'for' => '(' . __( 'for', 'sportspress' ) . ')', 'against' => '(' . __( 'against', 'sportspress' ) . ')' ), null, false );
|
||||
$options['Results'] = self::optgroup(
|
||||
'sp_result',
|
||||
array(
|
||||
'for' => '(' . __( 'for', 'sportspress' ) . ')',
|
||||
'against' => '(' . __(
|
||||
'against',
|
||||
'sportspress'
|
||||
) . ')',
|
||||
),
|
||||
null,
|
||||
false
|
||||
);
|
||||
break;
|
||||
case 'outcome':
|
||||
$options[ 'Outcomes' ] = self::optgroup( 'sp_outcome' );
|
||||
$options['Outcomes'] = self::optgroup( 'sp_outcome' );
|
||||
break;
|
||||
case 'preset':
|
||||
$options[ 'Presets' ] = array( '$gamesback' => __( 'Games Back', 'sportspress' ), '$homerecord' => __( 'Home Record', 'sportspress' ), '$awayrecord' => __( 'Away Record', 'sportspress' ), '$streak' => __( 'Streak', 'sportspress' ), '$form' => __( 'Form', 'sportspress' ), '$last5' => __( 'Last 5', 'sportspress' ), '$last10' => __( 'Last 10', 'sportspress' ) );
|
||||
$options['Presets'] = array(
|
||||
'$gamesback' => __( 'Games Back', 'sportspress' ),
|
||||
'$homerecord' => __( 'Home Record', 'sportspress' ),
|
||||
'$awayrecord' => __( 'Away Record', 'sportspress' ),
|
||||
'$streak' => __( 'Streak', 'sportspress' ),
|
||||
'$form' => __( 'Form', 'sportspress' ),
|
||||
'$last5' => __( 'Last 5', 'sportspress' ),
|
||||
'$last10' => __( 'Last 10', 'sportspress' ),
|
||||
);
|
||||
break;
|
||||
case 'subset':
|
||||
$options[ 'Subsets' ] = array( '_home' => '@' . __( 'Home', 'sportspress' ), '_away' => '@' . __( 'Away', 'sportspress' ), '_venue' => '@' . __( 'Venue', 'sportspress' ) );
|
||||
$options['Subsets'] = array(
|
||||
'_home' => '@' . __( 'Home', 'sportspress' ),
|
||||
'_away' => '@' . __( 'Away', 'sportspress' ),
|
||||
'_venue' => '@' . __( 'Venue', 'sportspress' ),
|
||||
);
|
||||
break;
|
||||
case 'performance':
|
||||
$options[ 'Performance' ] = self::optgroup( 'sp_performance' );
|
||||
$options['Performance'] = self::optgroup( 'sp_performance' );
|
||||
break;
|
||||
case 'metric':
|
||||
$options[ 'Metrics' ] = self::optgroup( 'sp_metric' );
|
||||
$options['Metrics'] = self::optgroup( 'sp_metric' );
|
||||
break;
|
||||
endswitch;
|
||||
endforeach;
|
||||
|
||||
// Add operators to options
|
||||
$options[ 'Operators' ] = array( '+' => '+', '-' => '−', '*' => '×', '/' => '÷', '(' => '(', ')' => ')' );
|
||||
$options['Operators'] = array(
|
||||
'+' => '+',
|
||||
'-' => '−',
|
||||
'*' => '×',
|
||||
'/' => '÷',
|
||||
'(' => '(',
|
||||
')' => ')',
|
||||
);
|
||||
|
||||
// Create array of constants
|
||||
$max = 10;
|
||||
$max = 10;
|
||||
$constants = array();
|
||||
for ( $i = 0; $i <= $max; $i ++ ):
|
||||
$constants[$i] = $i;
|
||||
for ( $i = 0; $i <= $max; $i ++ ) :
|
||||
$constants[ $i ] = $i;
|
||||
endfor;
|
||||
|
||||
// Add 100 to constants
|
||||
$constants[100] = 100;
|
||||
|
||||
// Add constants to options
|
||||
$options[ 'Constants' ] = (array) $constants;
|
||||
$options['Constants'] = (array) $constants;
|
||||
|
||||
$options = apply_filters( 'sportspress_equation_options', $options );
|
||||
?>
|
||||
<div class="sp-equation-builder">
|
||||
<div class="sp-data-table-container sp-equation-parts">
|
||||
<table class="widefat sp-data-table">
|
||||
<?php $i = 0; foreach ( $options as $label => $option ): ?>
|
||||
<tr<?php if ( $i % 2 == 0 ): ?> class="alternate"<?php endif; ?>>
|
||||
<?php $i = 0; foreach ( $options as $label => $option ) : ?>
|
||||
<tr
|
||||
<?php
|
||||
if ( $i % 2 == 0 ) :
|
||||
?>
|
||||
class="alternate"<?php endif; ?>>
|
||||
<th><?php _e( $label, 'sportspress' ); ?></th>
|
||||
<td>
|
||||
<?php foreach ( $option as $key => $value ): $parts[ $key ] = $value;
|
||||
?><span class="button" data-variable="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value ); ?></span><?php
|
||||
endforeach; ?>
|
||||
<?php
|
||||
foreach ( $option as $key => $value ) :
|
||||
$parts[ $key ] = $value;
|
||||
?>
|
||||
<span class="button" data-variable="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value ); ?></span>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
<div class="sp-equation">
|
||||
<span class="sp-equation-variable"><?php echo esc_html( $title ); ?> = </span>
|
||||
<span class="sp-equation-formula"><?php
|
||||
<span class="sp-equation-formula">
|
||||
<?php
|
||||
$equation = trim( $equation );
|
||||
if ( $equation !== '' ):
|
||||
$equation = explode( ' ', $equation );
|
||||
foreach ( $equation as $part ):
|
||||
if ( array_key_exists( $part, $parts ) ) {
|
||||
$name = $parts[ $part ];
|
||||
} else {
|
||||
$name = $part;
|
||||
} ?><span class="button"><?php echo esc_html( $name ); ?><span class="remove">×</span><input type="hidden" name="sp_equation[]" value="<?php echo esc_attr( $part ); ?>"></span><?php
|
||||
endforeach;
|
||||
if ( $equation !== '' ) :
|
||||
$equation = explode( ' ', $equation );
|
||||
foreach ( $equation as $part ) :
|
||||
if ( array_key_exists( $part, $parts ) ) {
|
||||
$name = $parts[ $part ];
|
||||
} else {
|
||||
$name = $part;
|
||||
}
|
||||
?>
|
||||
<span class="button"><?php echo esc_html( $name ); ?><span class="remove">×</span><input type="hidden" name="sp_equation[]" value="<?php echo esc_attr( $part ); ?>"></span>
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
?></span>
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
@@ -115,21 +175,21 @@ class SP_Meta_Box_Equation {
|
||||
|
||||
// Get posts
|
||||
$args = array(
|
||||
'post_type' => $type,
|
||||
'numberposts' => -1,
|
||||
'post_type' => $type,
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_format',
|
||||
'value' => 'number',
|
||||
'key' => 'sp_format',
|
||||
'value' => 'number',
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_format',
|
||||
'value' => array( 'equation', 'text' ),
|
||||
'key' => 'sp_format',
|
||||
'value' => array( 'equation', 'text' ),
|
||||
'compare' => 'NOT IN',
|
||||
),
|
||||
),
|
||||
@@ -137,22 +197,24 @@ class SP_Meta_Box_Equation {
|
||||
$vars = get_posts( $args );
|
||||
|
||||
// Add extra vars to the array
|
||||
if ( isset( $defaults ) && is_array( $defaults ) ):
|
||||
foreach ( $defaults as $key => $value ):
|
||||
if ( isset( $defaults ) && is_array( $defaults ) ) :
|
||||
foreach ( $defaults as $key => $value ) :
|
||||
$arr[ $key ] = $value;
|
||||
endforeach;
|
||||
endif;
|
||||
|
||||
// Add vars to the array
|
||||
if ( isset( $variations ) && is_array( $variations ) ):
|
||||
foreach ( $vars as $var ):
|
||||
if ( $totals ) $arr[ '$' . $var->post_name ] = $var->post_title;
|
||||
foreach ( $variations as $key => $value ):
|
||||
if ( isset( $variations ) && is_array( $variations ) ) :
|
||||
foreach ( $vars as $var ) :
|
||||
if ( $totals ) {
|
||||
$arr[ '$' . $var->post_name ] = $var->post_title;
|
||||
}
|
||||
foreach ( $variations as $key => $value ) :
|
||||
$arr[ '$' . $var->post_name . $key ] = $var->post_title . ' ' . $value;
|
||||
endforeach;
|
||||
endforeach;
|
||||
else:
|
||||
foreach ( $vars as $var ):
|
||||
else :
|
||||
foreach ( $vars as $var ) :
|
||||
$arr[ '$' . $var->post_name ] = $var->post_title;
|
||||
endforeach;
|
||||
endif;
|
||||
@@ -162,6 +224,7 @@ class SP_Meta_Box_Equation {
|
||||
|
||||
/**
|
||||
* Equation part labels for localization
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function equation_part_labels() {
|
||||
@@ -170,4 +233,4 @@ class SP_Meta_Box_Equation {
|
||||
__( 'Subsets', 'sportspress' );
|
||||
__( 'Constants', 'sportspress' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Event Details
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Details
|
||||
@@ -19,9 +21,9 @@ class SP_Meta_Box_Event_Details {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$day = get_post_meta( $post->ID, 'sp_day', true );
|
||||
$day = get_post_meta( $post->ID, 'sp_day', true );
|
||||
$taxonomies = get_object_taxonomies( 'sp_event' );
|
||||
$minutes = get_post_meta( $post->ID, 'sp_minutes', true );
|
||||
$minutes = get_post_meta( $post->ID, 'sp_minutes', true );
|
||||
?>
|
||||
<?php do_action( 'sportspress_event_details_meta_box', $post ); ?>
|
||||
<div class="sp-event-day-field">
|
||||
@@ -39,7 +41,9 @@ class SP_Meta_Box_Event_Details {
|
||||
</div>
|
||||
<?php
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
if ( 'sp_venue' == $taxonomy ) continue;
|
||||
if ( 'sp_venue' == $taxonomy ) {
|
||||
continue;
|
||||
}
|
||||
sp_taxonomy_field( $taxonomy, $post, true, true, __( 'None', 'sportspress' ) );
|
||||
}
|
||||
?>
|
||||
@@ -48,14 +52,14 @@ class SP_Meta_Box_Event_Details {
|
||||
<p>
|
||||
<?php
|
||||
$terms = get_the_terms( $post->ID, 'sp_venue' );
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_venue',
|
||||
'name' => 'tax_input[sp_venue][]',
|
||||
'class' => 'sp-has-dummy',
|
||||
'selected' => sp_get_the_term_id_or_meta( $post->ID, 'sp_venue' ),
|
||||
'values' => 'term_id',
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_venue',
|
||||
'name' => 'tax_input[sp_venue][]',
|
||||
'class' => 'sp-has-dummy',
|
||||
'selected' => sp_get_the_term_id_or_meta( $post->ID, 'sp_venue' ),
|
||||
'values' => 'term_id',
|
||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||
'chosen' => true,
|
||||
'chosen' => true,
|
||||
);
|
||||
if ( in_array( 'sp_venue', apply_filters( 'sportspress_event_auto_taxonomies', array( 'sp_venue' ) ) ) ) {
|
||||
$args['show_option_all'] = __( '(Auto)', 'sportspress' );
|
||||
@@ -75,10 +79,10 @@ class SP_Meta_Box_Event_Details {
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_day', sp_array_value( $_POST, 'sp_day', null, 'text' ) );
|
||||
update_post_meta( $post_id, 'sp_minutes', sp_array_value( $_POST, 'sp_minutes', get_option( 'sportspress_event_minutes', 90 ), 'int' ) );
|
||||
$venues = array_filter( sp_array_value( sp_array_value( $_POST, 'tax_input', array() ), 'sp_venue', array() ) );
|
||||
$venues = array_filter( sp_array_value( sp_array_value( $_POST, 'tax_input', array() ), 'sp_venue', array() ) );
|
||||
if ( empty( $venues ) ) {
|
||||
$teams = sp_array_value( $_POST, 'sp_team', array(), 'int' );
|
||||
$team = reset( $teams );
|
||||
$team = reset( $teams );
|
||||
$venue = sp_get_the_term_id( $team, 'sp_venue' );
|
||||
wp_set_post_terms( $post_id, $venue, 'sp_venue' );
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Event Format
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Format
|
||||
@@ -23,7 +25,7 @@ class SP_Meta_Box_Event_Format {
|
||||
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
||||
?>
|
||||
<div id="post-formats-select">
|
||||
<?php foreach ( SP()->formats->event as $key => $format ): ?>
|
||||
<?php foreach ( SP()->formats->event as $key => $format ) : ?>
|
||||
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( true, ( $key == 'league' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $format ); ?></label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
@@ -36,4 +38,4 @@ class SP_Meta_Box_Event_Format {
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'league', 'text' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,34 +5,41 @@
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Mode
|
||||
*/
|
||||
class SP_Meta_Box_Event_Mode {
|
||||
|
||||
/**
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$the_mode = sp_get_post_mode( $post->ID );
|
||||
?>
|
||||
<div id="post-formats-select">
|
||||
<?php foreach ( array( 'team' => __( 'Team vs team', 'sportspress' ), 'player' => __( 'Player vs player', 'sportspress' ) ) as $key => $mode ): ?>
|
||||
<input type="radio" name="sp_mode" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( $the_mode, $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $mode ); ?></label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
/**
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$the_mode = sp_get_post_mode( $post->ID );
|
||||
?>
|
||||
<div id="post-formats-select">
|
||||
<?php
|
||||
foreach ( array(
|
||||
'team' => __( 'Team vs team', 'sportspress' ),
|
||||
'player' => __( 'Player vs player', 'sportspress' ),
|
||||
) as $key => $mode ) :
|
||||
?>
|
||||
<input type="radio" name="sp_mode" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( $the_mode, $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $mode ); ?></label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_mode', sp_array_value( $_POST, 'sp_mode', 'team', 'text' ) );
|
||||
}
|
||||
/**
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_mode', sp_array_value( $_POST, 'sp_mode', 'team', 'text' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,70 +6,76 @@
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Officials
|
||||
*/
|
||||
class SP_Meta_Box_Event_Officials {
|
||||
|
||||
/**
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$duties = get_terms( array(
|
||||
'taxonomy' => 'sp_duty',
|
||||
'hide_empty' => false,
|
||||
'orderby' => 'meta_value_num',
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'NOT EXISTS'
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'EXISTS'
|
||||
),
|
||||
),
|
||||
) );
|
||||
/**
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$duties = get_terms(
|
||||
array(
|
||||
'taxonomy' => 'sp_duty',
|
||||
'hide_empty' => false,
|
||||
'orderby' => 'meta_value_num',
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$officials = (array) get_post_meta( $post->ID, 'sp_officials', true );
|
||||
$officials = (array) get_post_meta( $post->ID, 'sp_officials', true );
|
||||
|
||||
if ( is_array( $duties ) && sizeof( $duties ) ) {
|
||||
foreach ( $duties as $duty ) {
|
||||
?>
|
||||
<p><strong><?php echo esc_html( $duty->name ); ?></strong></p>
|
||||
<p><?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_official',
|
||||
'name' => 'sp_officials[' . $duty->term_id . '][]',
|
||||
'selected' => sp_array_value( $officials, $duty->term_id, array() ),
|
||||
'values' => 'ID',
|
||||
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Officials', 'sportspress' ) ),
|
||||
'class' => 'widefat',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
);
|
||||
if ( is_array( $duties ) && sizeof( $duties ) ) {
|
||||
foreach ( $duties as $duty ) {
|
||||
?>
|
||||
<p><strong><?php echo esc_html( $duty->name ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_official',
|
||||
'name' => 'sp_officials[' . $duty->term_id . '][]',
|
||||
'selected' => sp_array_value( $officials, $duty->term_id, array() ),
|
||||
'values' => 'ID',
|
||||
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Officials', 'sportspress' ) ),
|
||||
'class' => 'widefat',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
);
|
||||
|
||||
if ( ! sp_dropdown_pages( $args ) ) {
|
||||
sp_post_adder( 'sp_official', __( 'Add New', 'sportspress' ) );
|
||||
}
|
||||
?></p>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
sp_taxonomy_adder( 'sp_duty', 'sp_official', __( 'Duty', 'sportspress' ) );
|
||||
}
|
||||
}
|
||||
if ( ! sp_dropdown_pages( $args ) ) {
|
||||
sp_post_adder( 'sp_official', __( 'Add New', 'sportspress' ) );
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
sp_taxonomy_adder( 'sp_duty', 'sp_official', __( 'Duty', 'sportspress' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_officials', sp_array_value( $_POST, 'sp_officials', array(), 'int' ) );
|
||||
}
|
||||
/**
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_officials', sp_array_value( $_POST, 'sp_officials', array(), 'int' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Event Performance
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Performance
|
||||
@@ -22,32 +24,35 @@ class SP_Meta_Box_Event_Performance {
|
||||
$event = new SP_Event( $post );
|
||||
list( $labels, $columns, $stats, $teams, $formats, $order, $timed, $stars ) = $event->performance( true );
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_event_performance_show_minutes', 'no' ) )
|
||||
if ( 'yes' == get_option( 'sportspress_event_performance_show_minutes', 'no' ) ) {
|
||||
$timeline = $event->timeline( true );
|
||||
else
|
||||
} else {
|
||||
$timeline = false;
|
||||
}
|
||||
|
||||
// Determine if columns are auto or manual
|
||||
if ( 'manual' == get_option( 'sportspress_event_performance_columns', 'auto' ) )
|
||||
if ( 'manual' == get_option( 'sportspress_event_performance_columns', 'auto' ) ) {
|
||||
$manual = true;
|
||||
else
|
||||
} else {
|
||||
$manual = false;
|
||||
}
|
||||
|
||||
// Determine if we need checkboxes
|
||||
if ( $manual )
|
||||
if ( $manual ) {
|
||||
$has_checkboxes = true;
|
||||
else
|
||||
} else {
|
||||
$has_checkboxes = false;
|
||||
|
||||
}
|
||||
|
||||
// Get player number option
|
||||
$numbers = 'yes' == get_option( 'sportspress_event_show_player_numbers', 'yes' ) ? true : false;
|
||||
|
||||
// Get positions
|
||||
$positions = array();
|
||||
if ( 'yes' == get_option( 'sportspress_event_show_position', 'yes' ) && taxonomy_exists( 'sp_position' ) ):
|
||||
$args = array(
|
||||
'hide_empty' => false,
|
||||
'parent' => 0,
|
||||
if ( 'yes' == get_option( 'sportspress_event_show_position', 'yes' ) && taxonomy_exists( 'sp_position' ) ) :
|
||||
$args = array(
|
||||
'hide_empty' => false,
|
||||
'parent' => 0,
|
||||
'include_children' => true,
|
||||
);
|
||||
$positions = get_terms( 'sp_position', $args );
|
||||
@@ -55,7 +60,7 @@ class SP_Meta_Box_Event_Performance {
|
||||
|
||||
// Apply filters to labels
|
||||
$labels = apply_filters( 'sportspress_event_performance_labels_admin', $labels );
|
||||
|
||||
|
||||
// Check if individual mode
|
||||
$is_individual = 'player' === sp_get_post_mode( $post->ID );
|
||||
|
||||
@@ -95,27 +100,29 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?php self::footer( sp_array_value( $stats, -1 ), $labels, 0, $positions, $status, false, $numbers, -1, $formats ); ?>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ( $teams as $key => $team_id ):
|
||||
if ( -1 == $team_id ) continue;
|
||||
foreach ( $teams as $key => $team_id ) :
|
||||
if ( -1 == $team_id ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get results for players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||
$players = sp_array_between( (array) get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||
$players[] = -1;
|
||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
// Get team timeline
|
||||
if ( is_array( $timeline ) ):
|
||||
if ( is_array( $timeline ) ) :
|
||||
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
|
||||
else:
|
||||
else :
|
||||
$team_timeline = false;
|
||||
endif;
|
||||
|
||||
foreach ( $data as $player_id => $player_performance ):
|
||||
foreach ( $data as $player_id => $player_performance ) :
|
||||
|
||||
// Get player timeline
|
||||
if ( is_array( $team_timeline ) ):
|
||||
if ( is_array( $team_timeline ) ) :
|
||||
$player_timeline = (array) sp_array_value( $team_timeline, $player_id, array() );
|
||||
else:
|
||||
else :
|
||||
$player_timeline = false;
|
||||
endif;
|
||||
|
||||
@@ -129,27 +136,46 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?php
|
||||
} else {
|
||||
$i = 0;
|
||||
|
||||
foreach ( $teams as $key => $team_id ):
|
||||
if ( -1 == $team_id ) continue;
|
||||
|
||||
|
||||
foreach ( $teams as $key => $team_id ) :
|
||||
if ( -1 == $team_id ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( -1 == $sections ) {
|
||||
// Get results for players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||
$players = sp_array_between( (array) get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||
$players[] = -1;
|
||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
// Get team timeline
|
||||
if ( is_array( $timeline ) ):
|
||||
if ( is_array( $timeline ) ) :
|
||||
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
|
||||
else:
|
||||
else :
|
||||
$team_timeline = false;
|
||||
endif;
|
||||
?>
|
||||
<div>
|
||||
<p>
|
||||
<strong><?php echo get_the_title( $team_id ); ?></strong>
|
||||
<a class="add-new-h2 sp-add-new-h2" href="<?php echo esc_url( admin_url( add_query_arg( array( 'import' => 'sp_event_performance_csv', 'event' => $post_id, 'team' => $team_id, 'teams' => sizeof( $teams ), 'index' => $key ), 'admin.php' ) ) ); ?>"><?php _e( 'Import', 'sportspress' ); ?></a>
|
||||
<a class="add-new-h2 sp-add-new-h2" href="
|
||||
<?php
|
||||
echo esc_url(
|
||||
admin_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'import' => 'sp_event_performance_csv',
|
||||
'event' => $post_id,
|
||||
'team' => $team_id,
|
||||
'teams' => sizeof( $teams ),
|
||||
'index' => $key,
|
||||
),
|
||||
'admin.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
?>
|
||||
"><?php _e( 'Import', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes && $i === 0, $positions, $status, -1, $formats, $order, $numbers, $team_timeline, $timed, $stars ); ?>
|
||||
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels, $columns, $data, $team_id ); ?>
|
||||
@@ -158,21 +184,21 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?php
|
||||
// Get labels by section
|
||||
$args = array(
|
||||
'post_type' => 'sp_performance',
|
||||
'numberposts' => 100,
|
||||
'post_type' => 'sp_performance',
|
||||
'numberposts' => 100,
|
||||
'posts_per_page' => 100,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_format',
|
||||
'value' => 'number',
|
||||
'key' => 'sp_format',
|
||||
'value' => 'number',
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_format',
|
||||
'value' => 'equation',
|
||||
'key' => 'sp_format',
|
||||
'value' => 'equation',
|
||||
'compare' => '!=',
|
||||
),
|
||||
),
|
||||
@@ -181,12 +207,12 @@ class SP_Meta_Box_Event_Performance {
|
||||
$performances = get_posts( $args );
|
||||
|
||||
$labels = array( array(), array() );
|
||||
foreach ( $performances as $performance ):
|
||||
foreach ( $performances as $performance ) :
|
||||
$section = get_post_meta( $performance->ID, 'sp_section', true );
|
||||
if ( '' === $section ) {
|
||||
$section = -1;
|
||||
}
|
||||
switch ( $section ):
|
||||
switch ( $section ) :
|
||||
case 1:
|
||||
$labels[1][ $performance->post_name ] = $performance->post_title;
|
||||
break;
|
||||
@@ -194,47 +220,65 @@ class SP_Meta_Box_Event_Performance {
|
||||
$labels[0][ $performance->post_name ] = $performance->post_title;
|
||||
endswitch;
|
||||
endforeach;
|
||||
|
||||
$offense = (array)get_post_meta( $post_id, 'sp_offense', false );
|
||||
$defense = (array)get_post_meta( $post_id, 'sp_defense', false );
|
||||
$data = array();
|
||||
|
||||
$offense = (array) get_post_meta( $post_id, 'sp_offense', false );
|
||||
$defense = (array) get_post_meta( $post_id, 'sp_defense', false );
|
||||
$data = array();
|
||||
if ( sizeof( $offense ) || sizeof( $defense ) ) {
|
||||
// Get results for offensive players in the team
|
||||
$offense = sp_array_between( $offense, 0, $key );
|
||||
$offense = sp_array_between( $offense, 0, $key );
|
||||
$offense[] = -1;
|
||||
$data[0] = sp_array_combine( $offense, sp_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
$data[0] = sp_array_combine( $offense, sp_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
// Get results for defensive players in the team
|
||||
$defense = sp_array_between( $defense, 0, $key );
|
||||
$defense = sp_array_between( $defense, 0, $key );
|
||||
$defense[] = -1;
|
||||
$data[1] = sp_array_combine( $defense, sp_array_value( $stats, $team_id, array() ) );
|
||||
$data[1] = sp_array_combine( $defense, sp_array_value( $stats, $team_id, array() ) );
|
||||
} else {
|
||||
// Get results for all players in the team
|
||||
$players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||
$players = sp_array_between( (array) get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||
$players[] = -1;
|
||||
$data[0] = $data[1] = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
$data[0] = $data[1] = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||
}
|
||||
|
||||
// Get team timeline
|
||||
if ( is_array( $timeline ) ):
|
||||
if ( is_array( $timeline ) ) :
|
||||
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
|
||||
else:
|
||||
else :
|
||||
$team_timeline = false;
|
||||
endif;
|
||||
|
||||
|
||||
// Determine order of sections
|
||||
if ( 1 == $sections ) {
|
||||
$section_order = array( 1 => __( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
|
||||
$section_order = array(
|
||||
1 => __( 'Defense', 'sportspress' ),
|
||||
0 => __( 'Offense', 'sportspress' ),
|
||||
);
|
||||
} else {
|
||||
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
||||
}
|
||||
|
||||
|
||||
foreach ( $section_order as $section_id => $section_label ) {
|
||||
?>
|
||||
<div>
|
||||
<p>
|
||||
<strong><?php echo get_the_title( $team_id ); ?> — <?php echo esc_html( $section_label ); ?></strong>
|
||||
<a class="add-new-h2 sp-add-new-h2" href="<?php echo esc_url( admin_url( add_query_arg( array( 'import' => 'sp_event_performance_csv', 'event' => $post_id, 'team' => $team_id ), 'admin.php' ) ) ); ?>"><?php _e( 'Import', 'sportspress' ); ?></a>
|
||||
<a class="add-new-h2 sp-add-new-h2" href="
|
||||
<?php
|
||||
echo esc_url(
|
||||
admin_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'import' => 'sp_event_performance_csv',
|
||||
'event' => $post_id,
|
||||
'team' => $team_id,
|
||||
),
|
||||
'admin.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
?>
|
||||
"><?php _e( 'Import', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
<?php self::table( $labels[ $section_id ], $columns, $data[ $section_id ], $team_id, ( $has_checkboxes && 0 === $i ), $positions, $status, $section_id, $formats, $order, $numbers, $team_timeline, $timed, $stars ); ?>
|
||||
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels[ $section_id ], $columns, $data[ $section_id ], $team_id ); ?>
|
||||
@@ -259,11 +303,11 @@ class SP_Meta_Box_Event_Performance {
|
||||
<tbody>
|
||||
<?php
|
||||
if ( 1 == $section && is_array( $order ) && sizeof( $order ) ) {
|
||||
$players = array();
|
||||
$players = array();
|
||||
$player_order = sp_array_value( $order, $team_id, array() );
|
||||
if ( is_array( $player_order ) && sizeof( $player_order ) ) {
|
||||
foreach ( $player_order as $key ) {
|
||||
if ( array_key_exists( $key, $data ) ):
|
||||
if ( array_key_exists( $key, $data ) ) :
|
||||
$players[ $key ] = $data[ $key ];
|
||||
endif;
|
||||
}
|
||||
@@ -276,12 +320,12 @@ class SP_Meta_Box_Event_Performance {
|
||||
$data = $players;
|
||||
}
|
||||
|
||||
foreach ( $data as $player_id => $player_performance ):
|
||||
foreach ( $data as $player_id => $player_performance ) :
|
||||
|
||||
// Get player timeline
|
||||
if ( is_array( $team_timeline ) ):
|
||||
if ( is_array( $team_timeline ) ) :
|
||||
$player_timeline = (array) sp_array_value( $team_timeline, $player_id, array() );
|
||||
else:
|
||||
else :
|
||||
$player_timeline = false;
|
||||
endif;
|
||||
|
||||
@@ -315,22 +359,28 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?php _e( 'Position', 'sportspress' ); ?>
|
||||
</th>
|
||||
<?php } ?>
|
||||
<?php $i = 0; foreach ( $labels as $key => $label ): ?>
|
||||
<?php if ( 'equation' === sp_array_value( $formats, $key, 'number' ) ) continue; ?>
|
||||
<?php $i = 0; foreach ( $labels as $key => $label ) : ?>
|
||||
<?php
|
||||
if ( 'equation' === sp_array_value( $formats, $key, 'number' ) ) {
|
||||
continue;}
|
||||
?>
|
||||
<th>
|
||||
<?php if ( $has_checkboxes ): ?>
|
||||
<?php if ( 0 == $i ): ?>
|
||||
<?php if ( $has_checkboxes ) : ?>
|
||||
<?php if ( 0 == $i ) : ?>
|
||||
<input type="hidden" name="sp_columns[]" value="">
|
||||
<?php endif; ?>
|
||||
<label for="sp_columns_<?php echo esc_attr( $key ); ?>">
|
||||
<input type="checkbox" name="sp_columns[]" value="<?php echo esc_attr( $key ); ?>" id="sp_columns_<?php echo esc_attr( $key ); ?>" <?php checked( ! is_array( $columns ) || in_array( $key, $columns ) ); ?>>
|
||||
<?php echo esc_html( $label ); ?>
|
||||
</label>
|
||||
<?php else: ?>
|
||||
<?php else : ?>
|
||||
<?php echo esc_html( $label ); ?>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
?>
|
||||
<?php if ( apply_filters( 'sportspress_event_performance_show_status', $status, $section ) ) { ?>
|
||||
<th>
|
||||
<?php _e( 'Status', 'sportspress' ); ?>
|
||||
@@ -363,13 +413,16 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?php if ( ! empty( $positions ) ) { ?>
|
||||
<td> </td>
|
||||
<?php } ?>
|
||||
<?php foreach( $labels as $column => $label ):
|
||||
if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) continue;
|
||||
$player_id = 0;
|
||||
<?php
|
||||
foreach ( $labels as $column => $label ) :
|
||||
if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) {
|
||||
continue;
|
||||
}
|
||||
$player_id = 0;
|
||||
$player_performance = sp_array_value( $data, $player_id, array() );
|
||||
$value = sp_array_value( $player_performance, $column, '' );
|
||||
$format = sp_array_value( $formats, $column, 'number' );
|
||||
$placeholder = sp_get_format_placeholder( $format );
|
||||
$value = sp_array_value( $player_performance, $column, '' );
|
||||
$format = sp_array_value( $formats, $column, 'number' );
|
||||
$placeholder = sp_get_format_placeholder( $format );
|
||||
?>
|
||||
<td><input type="text" name="sp_players[<?php echo esc_attr( $team_id ); ?>][<?php echo esc_attr( $player_id ); ?>][<?php echo esc_attr( $column ); ?>]" placeholder="<?php echo trim( $placeholder ); ?>" value="<?php echo esc_attr( $value ); ?>" data-sp-format="<?php echo esc_attr( $format ); ?>" /></td>
|
||||
<?php endforeach; ?>
|
||||
@@ -389,10 +442,12 @@ class SP_Meta_Box_Event_Performance {
|
||||
* Admin edit table row
|
||||
*/
|
||||
public static function row( $labels = array(), $player_id = 0, $player_performance = array(), $team_id = 0, $data = array(), $positions = true, $status = true, $sortable = true, $numbers = true, $section = -1, $formats = array(), $player_timeline = array(), $timed = array(), $stars = array() ) {
|
||||
if ( $player_id <= 0 ) return;
|
||||
if ( $player_id <= 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$stars_type = get_option( 'sportspress_event_performance_stars_type', 0 );
|
||||
$value = sp_array_value( $player_performance, 'number', '' );
|
||||
$value = sp_array_value( $player_performance, 'number', '' );
|
||||
?>
|
||||
<tr class="sp-row sp-post" data-player="<?php echo esc_attr( $player_id ); ?>">
|
||||
<?php if ( $sortable ) { ?>
|
||||
@@ -413,51 +468,55 @@ class SP_Meta_Box_Event_Performance {
|
||||
<td>
|
||||
<?php
|
||||
$selected = (array) sp_array_value( $player_performance, 'position', null );
|
||||
if ( $selected == null ):
|
||||
if ( $selected == null ) :
|
||||
$selected = (array) sp_get_the_term_id( $player_id, 'sp_position', 0 );
|
||||
endif;
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position][]',
|
||||
'values' => 'term_id',
|
||||
'orderby' => 'meta_value_num',
|
||||
'meta_query' => array(
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'sp_players[' . $team_id . '][' . $player_id . '][position][]',
|
||||
'values' => 'term_id',
|
||||
'orderby' => 'meta_value_num',
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'NOT EXISTS'
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'EXISTS'
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
),
|
||||
'selected' => $selected,
|
||||
'class' => 'sp-position',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
'selected' => $selected,
|
||||
'class' => 'sp-position',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
'include_children' => ( 'no' == get_option( 'sportspress_event_hide_child_positions', 'no' ) ),
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php foreach( $labels as $column => $label ):
|
||||
if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) continue;
|
||||
$value = sp_array_value( $player_performance, $column, '' );
|
||||
$intval = intval( $value );
|
||||
<?php
|
||||
foreach ( $labels as $column => $label ) :
|
||||
if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) {
|
||||
continue;
|
||||
}
|
||||
$value = sp_array_value( $player_performance, $column, '' );
|
||||
$intval = intval( $value );
|
||||
$placeholder = sp_get_format_placeholder( sp_array_value( $formats, $column, 'number' ) );
|
||||
?>
|
||||
<td>
|
||||
<?php $format = sp_array_value( $formats, $column, 'number' ); ?>
|
||||
<?php if ( 'time' === $format ) { ?>
|
||||
<?php
|
||||
$intval = intval( $value );
|
||||
$intval = intval( $value );
|
||||
$timeval = gmdate( 'i:s', $intval );
|
||||
$hours = floor( $intval / 3600 );
|
||||
$hours = floor( $intval / 3600 );
|
||||
|
||||
if ( '00' != $hours )
|
||||
$timeval = $hours . ':' . $timeval;
|
||||
if ( '00' != $hours ) {
|
||||
$timeval = $hours . ':' . $timeval;
|
||||
}
|
||||
|
||||
$timeval = preg_replace( '/^0/', '', $timeval );
|
||||
?>
|
||||
@@ -479,11 +538,14 @@ class SP_Meta_Box_Event_Performance {
|
||||
} else {
|
||||
$times = false;
|
||||
}
|
||||
|
||||
|
||||
if ( is_array( $times ) ) {
|
||||
?>
|
||||
<hr>
|
||||
<?php for ( $i = 0; $i < $intval; $i++ ) { ?><input class="sp-sync-input small-text" type="text" name="sp_timeline[<?php echo esc_attr( $team_id ); ?>][<?php echo esc_attr( $player_id ); ?>][<?php echo esc_attr( $column ); ?>][<?php echo $i; ?>]" value="<?php echo esc_attr( sp_array_value( $times, $i, '' ) ); ?>" placeholder="-" /><?php } ?>
|
||||
<?php
|
||||
for ( $i = 0; $i < $intval; $i++ ) {
|
||||
?>
|
||||
<input class="sp-sync-input small-text" type="text" name="sp_timeline[<?php echo esc_attr( $team_id ); ?>][<?php echo esc_attr( $player_id ); ?>][<?php echo esc_attr( $column ); ?>][<?php echo $i; ?>]" value="<?php echo esc_attr( sp_array_value( $times, $i, '' ) ); ?>" placeholder="-" /><?php } ?>
|
||||
<span class="description"><?php _e( 'mins', 'sportspress' ); ?></span>
|
||||
<?php
|
||||
}
|
||||
@@ -531,17 +593,21 @@ class SP_Meta_Box_Event_Performance {
|
||||
*/
|
||||
public static function status_select( $team_id, $player_id, $value = null ) {
|
||||
|
||||
if ( ! $team_id || ! $player_id )
|
||||
if ( ! $team_id || ! $player_id ) {
|
||||
return '—';
|
||||
}
|
||||
|
||||
$options = apply_filters( 'sportspress_event_performance_status_options', array(
|
||||
'lineup' => __( 'Starting Lineup', 'sportspress' ),
|
||||
'sub' => __( 'Substitute', 'sportspress' ),
|
||||
) );
|
||||
$options = apply_filters(
|
||||
'sportspress_event_performance_status_options',
|
||||
array(
|
||||
'lineup' => __( 'Starting Lineup', 'sportspress' ),
|
||||
'sub' => __( 'Substitute', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
|
||||
$output = '<select class="sp-sync-select" name="sp_players[' . $team_id . '][' . $player_id . '][status]">';
|
||||
|
||||
foreach( $options as $key => $name ):
|
||||
foreach ( $options as $key => $name ) :
|
||||
$output .= '<option value="' . $key . '"' . ( $key == $value ? ' selected' : '' ) . '>' . $name . '</option>';
|
||||
endforeach;
|
||||
|
||||
@@ -556,17 +622,20 @@ class SP_Meta_Box_Event_Performance {
|
||||
*/
|
||||
public static function sub_select( $team_id, $player_id, $value, $data = array() ) {
|
||||
|
||||
if ( ! $team_id || ! $player_id )
|
||||
if ( ! $team_id || ! $player_id ) {
|
||||
return '—';
|
||||
}
|
||||
|
||||
$output = '<select class="sp-sync-select" name="sp_players[' . $team_id . '][' . $player_id . '][sub]" style="display: none;">';
|
||||
|
||||
$output .= '<option value="0">' . __( 'None', 'sportspress' ) . '</option>';
|
||||
|
||||
// Add players as selectable options
|
||||
foreach( $data as $id => $performance ):
|
||||
if ( ! $id || $id == $player_id ) continue;
|
||||
$number = get_post_meta( $id, 'sp_number', true );
|
||||
foreach ( $data as $id => $performance ) :
|
||||
if ( ! $id || $id == $player_id ) {
|
||||
continue;
|
||||
}
|
||||
$number = get_post_meta( $id, 'sp_number', true );
|
||||
$output .= '<option value="' . $id . '"' . ( $id == $value ? ' selected' : '' ) . '>' . ( $number ? $number . '. ' : '' ) . get_the_title( $id ) . '</option>';
|
||||
endforeach;
|
||||
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Event Results
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Results
|
||||
@@ -20,12 +22,13 @@ class SP_Meta_Box_Event_Results {
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
// Determine if we need checkboxes
|
||||
if ( 'manual' == get_option( 'sportspress_event_result_columns', 'auto' ) )
|
||||
if ( 'manual' == get_option( 'sportspress_event_result_columns', 'auto' ) ) {
|
||||
$has_checkboxes = true;
|
||||
else
|
||||
} else {
|
||||
$has_checkboxes = false;
|
||||
}
|
||||
|
||||
$event = new SP_Event( $post );
|
||||
$event = new SP_Event( $post );
|
||||
list( $columns, $usecolumns, $data ) = $event->results( true );
|
||||
self::table( $columns, $usecolumns, $data, $has_checkboxes );
|
||||
}
|
||||
@@ -34,7 +37,7 @@ class SP_Meta_Box_Event_Results {
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
$results = (array)sp_array_value( $_POST, 'sp_results', array(), 'text' );
|
||||
$results = (array) sp_array_value( $_POST, 'sp_results', array(), 'text' );
|
||||
$main_result = get_option( 'sportspress_primary_result', null );
|
||||
|
||||
// Get player performance
|
||||
@@ -57,15 +60,25 @@ class SP_Meta_Box_Event_Results {
|
||||
if ( ! $finished ) {
|
||||
foreach ( $performance as $team => $players ) {
|
||||
foreach ( $players as $player => $pp ) {
|
||||
if ( 0 >= $player ) continue;
|
||||
if ( 0 >= $player ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $pp as $pk => $pv ) {
|
||||
if ( in_array( $pk, apply_filters( 'sportspress_event_auto_result_bypass_keys', array( 'number', 'status', 'sub' ) ) ) ) continue;
|
||||
if ( in_array( $pk, apply_filters( 'sportspress_event_auto_result_bypass_keys', array( 'number', 'status', 'sub' ) ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_array( $pv ) ) continue;
|
||||
if ( is_array( $pv ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$pv = trim( $pv );
|
||||
if ( '' == $pv ) continue;
|
||||
if ( ! ctype_digit( $pv ) ) continue;
|
||||
if ( '' == $pv ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! ctype_digit( $pv ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$finished = true;
|
||||
break;
|
||||
@@ -73,16 +86,16 @@ class SP_Meta_Box_Event_Results {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( $finished ) {
|
||||
// Get results with equations
|
||||
$args = array(
|
||||
'post_type' => 'sp_result',
|
||||
'numberposts' => -1,
|
||||
$args = array(
|
||||
'post_type' => 'sp_result',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'meta_query' => array(
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'sp_equation',
|
||||
'key' => 'sp_equation',
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
),
|
||||
@@ -96,25 +109,26 @@ class SP_Meta_Box_Event_Results {
|
||||
$precision[ $result->post_name ] = (int) get_post_meta( $result->ID, 'sp_precision', true );
|
||||
}
|
||||
|
||||
|
||||
// Apply equations to empty results
|
||||
foreach ( $equations as $key => $equation ) {
|
||||
if ( '' == $equation ) continue;
|
||||
if ( '' == $equation ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $results as $team => $team_results ) {
|
||||
if ( '' === sp_array_value( $team_results, $key, '' ) ) {
|
||||
$totals = array();
|
||||
if ( '' === sp_array_value( $team_results, $key, '' ) ) {
|
||||
$totals = array();
|
||||
$players = sp_array_value( $performance, $team, array() );
|
||||
foreach ( $players as $player => $pp ) {
|
||||
foreach ( $pp as $pk => $pv ) {
|
||||
$value = sp_array_value( $totals, $pk, 0 );
|
||||
$value += floatval( $pv );
|
||||
$value = sp_array_value( $totals, $pk, 0 );
|
||||
$value += floatval( $pv );
|
||||
$totals[ $pk ] = $value;
|
||||
}
|
||||
}
|
||||
$totals[ 'eventsplayed' ] = 1;
|
||||
$totals = apply_filters( 'sportspress_event_result_equation_vars', $totals, $performance, $team );
|
||||
$results[ $team ][ $key ] = sp_solve( $equation, $totals, sp_array_value( $precision, $key, 0 ), '' );
|
||||
}
|
||||
$totals['eventsplayed'] = 1;
|
||||
$totals = apply_filters( 'sportspress_event_result_equation_vars', $totals, $performance, $team );
|
||||
$results[ $team ][ $key ] = sp_solve( $equation, $totals, sp_array_value( $precision, $key, 0 ), '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,55 +152,61 @@ class SP_Meta_Box_Event_Results {
|
||||
|
||||
if ( count( $primary_results ) && ! in_array( null, $primary_results ) ) {
|
||||
if ( count( array_unique( $primary_results ) ) === 1 ) {
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'numberposts' => -1,
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'meta_key' => 'sp_condition',
|
||||
'meta_value' => '=',
|
||||
'meta_key' => 'sp_condition',
|
||||
'meta_value' => '=',
|
||||
);
|
||||
$outcomes = get_posts( $args );
|
||||
foreach ( $results as $team => $team_results ) {
|
||||
if ( array_key_exists( 'outcome', $team_results ) ) continue;
|
||||
if ( array_key_exists( 'outcome', $team_results ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( $outcomes ) {
|
||||
$results[ $team ][ 'outcome' ] = array();
|
||||
$results[ $team ]['outcome'] = array();
|
||||
foreach ( $outcomes as $outcome ) {
|
||||
$results[ $team ][ 'outcome' ][] = $outcome->post_name;
|
||||
$results[ $team ]['outcome'][] = $outcome->post_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Get default outcomes
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'numberposts' => -1,
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'meta_key' => 'sp_condition',
|
||||
'meta_value' => 'else',
|
||||
'meta_key' => 'sp_condition',
|
||||
'meta_value' => 'else',
|
||||
);
|
||||
$default_outcomes = get_posts( $args );
|
||||
|
||||
// Get greater than outcomes
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'numberposts' => -1,
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'meta_key' => 'sp_condition',
|
||||
'meta_value' => '>',
|
||||
'meta_key' => 'sp_condition',
|
||||
'meta_value' => '>',
|
||||
);
|
||||
$gt_outcomes = get_posts( $args );
|
||||
if ( empty ( $gt_outcomes ) ) $gt_outcomes = $default_outcomes;
|
||||
if ( empty( $gt_outcomes ) ) {
|
||||
$gt_outcomes = $default_outcomes;
|
||||
}
|
||||
|
||||
// Get less than outcomes
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'numberposts' => -1,
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'meta_key' => 'sp_condition',
|
||||
'meta_value' => '<',
|
||||
'meta_key' => 'sp_condition',
|
||||
'meta_value' => '<',
|
||||
);
|
||||
$lt_outcomes = get_posts( $args );
|
||||
if ( empty ( $lt_outcomes ) ) $lt_outcomes = $default_outcomes;
|
||||
if ( empty( $lt_outcomes ) ) {
|
||||
$lt_outcomes = $default_outcomes;
|
||||
}
|
||||
|
||||
// Get min and max values
|
||||
$min = min( $primary_results );
|
||||
@@ -201,9 +221,9 @@ class SP_Meta_Box_Event_Results {
|
||||
} else {
|
||||
$outcomes = $default_outcomes;
|
||||
}
|
||||
$results[ $key ][ 'outcome' ] = array();
|
||||
$results[ $key ]['outcome'] = array();
|
||||
foreach ( $outcomes as $outcome ) {
|
||||
$results[ $key ][ 'outcome' ][] = $outcome->post_name;
|
||||
$results[ $key ]['outcome'][] = $outcome->post_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,20 +240,20 @@ class SP_Meta_Box_Event_Results {
|
||||
*/
|
||||
public static function table( $columns = array(), $usecolumns = array(), $data = array(), $has_checkboxes = false ) {
|
||||
// Get results with equations
|
||||
$args = array(
|
||||
'post_type' => 'sp_result',
|
||||
'numberposts' => -1,
|
||||
$args = array(
|
||||
'post_type' => 'sp_result',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'meta_query' => array(
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'sp_equation',
|
||||
'key' => 'sp_equation',
|
||||
'compare' => 'NOT IN',
|
||||
'value' => null
|
||||
'value' => null,
|
||||
),
|
||||
),
|
||||
);
|
||||
$dynamic_results = get_posts( $args );
|
||||
$auto_columns = wp_list_pluck( $dynamic_results, 'post_name' );
|
||||
$auto_columns = wp_list_pluck( $dynamic_results, 'post_name' );
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table sp-results-table">
|
||||
@@ -242,14 +262,14 @@ class SP_Meta_Box_Event_Results {
|
||||
<th class="column-team">
|
||||
<?php _e( 'Team', 'sportspress' ); ?>
|
||||
</th>
|
||||
<?php foreach ( $columns as $key => $label ): ?>
|
||||
<?php foreach ( $columns as $key => $label ) : ?>
|
||||
<th class="column-<?php echo esc_attr( $key ); ?>">
|
||||
<?php if ( $has_checkboxes ): ?>
|
||||
<?php if ( $has_checkboxes ) : ?>
|
||||
<label for="sp_result_columns_<?php echo esc_attr( $key ); ?>">
|
||||
<input type="checkbox" name="sp_result_columns[]" value="<?php echo esc_attr( $key ); ?>" id="sp_result_columns_<?php echo esc_attr( $key ); ?>" <?php checked( ! is_array( $usecolumns ) || in_array( $key, $usecolumns ) ); ?>>
|
||||
<?php echo esc_html( $label ); ?>
|
||||
</label>
|
||||
<?php else: ?>
|
||||
<?php else : ?>
|
||||
<?php echo esc_html( $label ); ?>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
@@ -262,35 +282,48 @@ class SP_Meta_Box_Event_Results {
|
||||
<tbody>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ( $data as $team_id => $team_results ):
|
||||
if ( ! $team_id || -1 == $team_id ) continue;
|
||||
foreach ( $data as $team_id => $team_results ) :
|
||||
if ( ! $team_id || -1 == $team_id ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>" data-team="<?php echo esc_attr( $team_id ); ?>">
|
||||
<tr class="sp-row sp-post
|
||||
<?php
|
||||
if ( $i % 2 == 0 ) {
|
||||
echo ' alternate';}
|
||||
?>
|
||||
" data-team="<?php echo esc_attr( $team_id ); ?>">
|
||||
<td>
|
||||
<?php echo get_the_title( $team_id ); ?>
|
||||
</td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
<?php
|
||||
foreach ( $columns as $column => $label ) :
|
||||
$value = sp_array_value( $team_results, $column, '' );
|
||||
?>
|
||||
<td><input class="sp-team-<?php echo esc_attr( $column ); ?>-input" type="text" name="sp_results[<?php echo esc_attr( $team_id ); ?>][<?php echo esc_attr( $column ); ?>]" value="<?php echo esc_attr( $value ); ?>"<?php if ( in_array( $column, $auto_columns ) ) { ?> placeholder="<?php _e( '(Auto)', 'sportspress' ); ?>"<?php } ?> /></td>
|
||||
<td><input class="sp-team-<?php echo esc_attr( $column ); ?>-input" type="text" name="sp_results[<?php echo esc_attr( $team_id ); ?>][<?php echo esc_attr( $column ); ?>]" value="<?php echo esc_attr( $value ); ?>"
|
||||
<?php
|
||||
if ( in_array( $column, $auto_columns ) ) {
|
||||
?>
|
||||
placeholder="<?php _e( '(Auto)', 'sportspress' ); ?>"<?php } ?> /></td>
|
||||
<?php endforeach; ?>
|
||||
<td>
|
||||
<?php
|
||||
$values = sp_array_value( $team_results, 'outcome', '' );
|
||||
if ( ! is_array( $values ) )
|
||||
if ( ! is_array( $values ) ) {
|
||||
$values = array( $values );
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'sp_outcome',
|
||||
'name' => 'sp_results[' . $team_id . '][outcome][]',
|
||||
'post_type' => 'sp_outcome',
|
||||
'name' => 'sp_results[' . $team_id . '][outcome][]',
|
||||
'option_none_value' => '',
|
||||
'sort_order' => 'ASC',
|
||||
'sort_column' => 'menu_order',
|
||||
'selected' => $values,
|
||||
'class' => 'sp-outcome',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
'placeholder' => __( '(Auto)', 'sportspress' ),
|
||||
'sort_order' => 'ASC',
|
||||
'sort_column' => 'menu_order',
|
||||
'selected' => $values,
|
||||
'class' => 'sp-outcome',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
'placeholder' => __( '(Auto)', 'sportspress' ),
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
@@ -305,4 +338,4 @@ class SP_Meta_Box_Event_Results {
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Event Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Shortcode
|
||||
@@ -19,27 +21,30 @@ class SP_Meta_Box_Event_Shortcode {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$shortcodes = apply_filters( 'sportspress_event_shortcodes', array(
|
||||
'event_results' => __( 'Results', 'sportspress' ),
|
||||
'event_details' => __( 'Details', 'sportspress' ),
|
||||
'event_performance' => __( 'Box Score', 'sportspress' ),
|
||||
'event_venue' => __( 'Venue', 'sportspress' ),
|
||||
'event_officials' => __( 'Officials', 'sportspress' ),
|
||||
'event_teams' => __( 'Teams', 'sportspress' ),
|
||||
'event_full' => __( 'Full Info', 'sportspress' ),
|
||||
) );
|
||||
$shortcodes = apply_filters(
|
||||
'sportspress_event_shortcodes',
|
||||
array(
|
||||
'event_results' => __( 'Results', 'sportspress' ),
|
||||
'event_details' => __( 'Details', 'sportspress' ),
|
||||
'event_performance' => __( 'Box Score', 'sportspress' ),
|
||||
'event_venue' => __( 'Venue', 'sportspress' ),
|
||||
'event_officials' => __( 'Officials', 'sportspress' ),
|
||||
'event_teams' => __( 'Teams', 'sportspress' ),
|
||||
'event_full' => __( 'Full Info', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
if ( $shortcodes ) {
|
||||
?>
|
||||
?>
|
||||
<p class="howto">
|
||||
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
|
||||
</p>
|
||||
<?php foreach ( $shortcodes as $id => $label ) { ?>
|
||||
<?php foreach ( $shortcodes as $id => $label ) { ?>
|
||||
<p>
|
||||
<strong><?php echo esc_html( $label ); ?></strong>
|
||||
</p>
|
||||
<p><input type="text" value="<?php sp_shortcode_template( $id, $post->ID ); ?>" readonly="readonly" class="code widefat"></p>
|
||||
<?php } ?>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Event Specs
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Specs
|
||||
@@ -23,23 +25,23 @@ class SP_Meta_Box_Event_Specs {
|
||||
$metrics = get_post_meta( $post->ID, 'sp_specs', true );
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'sp_spec',
|
||||
'numberposts' => -1,
|
||||
'post_type' => 'sp_spec',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
$vars = get_posts( $args );
|
||||
|
||||
if ( $vars ):
|
||||
foreach ( $vars as $var ):
|
||||
?>
|
||||
if ( $vars ) :
|
||||
foreach ( $vars as $var ) :
|
||||
?>
|
||||
<p><strong><?php echo esc_html( $var->post_title ); ?></strong></p>
|
||||
<p><input type="text" name="sp_specs[<?php echo esc_attr( $var->post_name ); ?>]" value="<?php echo esc_attr( sp_array_value( $metrics, $var->post_name, '' ) ); ?>" /></p>
|
||||
<?php
|
||||
<?php
|
||||
endforeach;
|
||||
else:
|
||||
else :
|
||||
sp_post_adder( 'sp_spec', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
}
|
||||
@@ -50,4 +52,4 @@ class SP_Meta_Box_Event_Specs {
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_specs', sp_array_value( $_POST, 'sp_specs', array(), 'text' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Event Teams
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Teams
|
||||
@@ -19,32 +21,32 @@ class SP_Meta_Box_Event_Teams {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$limit = get_option( 'sportspress_event_teams', 2 );
|
||||
$teams = (array) get_post_meta( $post->ID, 'sp_team', false );
|
||||
$limit = get_option( 'sportspress_event_teams', 2 );
|
||||
$teams = (array) get_post_meta( $post->ID, 'sp_team', false );
|
||||
$post_type = sp_get_post_mode_type( $post->ID );
|
||||
if ( $limit && 'sp_player' !== $post_type ) {
|
||||
for ( $i = 0; $i < $limit; $i ++ ):
|
||||
for ( $i = 0; $i < $limit; $i ++ ) :
|
||||
$team = array_shift( $teams );
|
||||
?>
|
||||
<div class="sp-instance">
|
||||
<p class="sp-tab-select sp-title-generator">
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => $post_type,
|
||||
'name' => 'sp_team[]',
|
||||
'class' => 'sportspress-pages',
|
||||
'post_type' => $post_type,
|
||||
'name' => 'sp_team[]',
|
||||
'class' => 'sportspress-pages',
|
||||
'show_option_none' => __( '— None —', 'sportspress' ),
|
||||
'values' => 'ID',
|
||||
'selected' => $team,
|
||||
'chosen' => true,
|
||||
'tax_query' => array(),
|
||||
'values' => 'ID',
|
||||
'selected' => $team,
|
||||
'chosen' => true,
|
||||
'tax_query' => array(),
|
||||
);
|
||||
if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_league', 'no' ) ) {
|
||||
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
|
||||
if ( $league_id ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'terms' => $league_id,
|
||||
'terms' => $league_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -53,7 +55,7 @@ class SP_Meta_Box_Event_Teams {
|
||||
if ( $season_id ) {
|
||||
$args['tax_query'][] = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'terms' => $season_id,
|
||||
'terms' => $season_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -64,34 +66,34 @@ class SP_Meta_Box_Event_Teams {
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
$tabs = array();
|
||||
$tabs = array();
|
||||
$sections = get_option( 'sportspress_event_performance_sections', -1 );
|
||||
if ( 0 == $sections ) {
|
||||
$tabs['sp_offense'] = array(
|
||||
'label' => __( 'Offense', 'sportspress' ),
|
||||
'label' => __( 'Offense', 'sportspress' ),
|
||||
'post_type' => 'sp_player',
|
||||
);
|
||||
$tabs['sp_defense'] = array(
|
||||
'label' => __( 'Defense', 'sportspress' ),
|
||||
'label' => __( 'Defense', 'sportspress' ),
|
||||
'post_type' => 'sp_player',
|
||||
);
|
||||
} elseif ( 1 == $sections ) {
|
||||
$tabs['sp_defense'] = array(
|
||||
'label' => __( 'Defense', 'sportspress' ),
|
||||
'label' => __( 'Defense', 'sportspress' ),
|
||||
'post_type' => 'sp_player',
|
||||
);
|
||||
$tabs['sp_offense'] = array(
|
||||
'label' => __( 'Offense', 'sportspress' ),
|
||||
'label' => __( 'Offense', 'sportspress' ),
|
||||
'post_type' => 'sp_player',
|
||||
);
|
||||
} else {
|
||||
$tabs['sp_player'] = array(
|
||||
'label' => __( 'Players', 'sportspress' ),
|
||||
'label' => __( 'Players', 'sportspress' ),
|
||||
'post_type' => 'sp_player',
|
||||
);
|
||||
}
|
||||
$tabs['sp_staff'] = array(
|
||||
'label' => __( 'Staff', 'sportspress' ),
|
||||
'label' => __( 'Staff', 'sportspress' ),
|
||||
'post_type' => 'sp_staff',
|
||||
);
|
||||
?>
|
||||
@@ -99,21 +101,25 @@ class SP_Meta_Box_Event_Teams {
|
||||
<ul id="sp_team-tabs" class="sp-tab-bar category-tabs">
|
||||
<?php
|
||||
$j = 0;
|
||||
foreach ( $tabs as $slug => $tab ) {
|
||||
?>
|
||||
<li class="<?php if ( 0 == $j ) { ?>tabs<?php } ?>"><a href="#<?php echo esc_attr( $slug ); ?>-all"><?php echo esc_html( $tab['label'] ); ?></a></li>
|
||||
foreach ( $tabs as $slug => $tab ) {
|
||||
?>
|
||||
<li class="
|
||||
<?php
|
||||
if ( 0 == $j ) {
|
||||
?>
|
||||
tabs<?php } ?>"><a href="#<?php echo esc_attr( $slug ); ?>-all"><?php echo esc_html( $tab['label'] ); ?></a></li>
|
||||
<?php
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
<?php
|
||||
$j = 0;
|
||||
foreach ( $tabs as $slug => $tab ) {
|
||||
do_action( 'sportspress_event_teams_meta_box_checklist', $post->ID, $tab['post_type'], ( 0 == $j ? 'block' : 'none' ), $team, $i, $slug );
|
||||
$j++;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
@@ -123,17 +129,17 @@ class SP_Meta_Box_Event_Teams {
|
||||
<p><strong><?php printf( __( 'Select %s:', 'sportspress' ), sp_get_post_mode_label( $post->ID ) ); ?></strong></p>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => $post_type,
|
||||
'name' => 'sp_team[]',
|
||||
'selected' => $teams,
|
||||
'values' => 'ID',
|
||||
'class' => 'widefat',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
'post_type' => $post_type,
|
||||
'name' => 'sp_team[]',
|
||||
'selected' => $teams,
|
||||
'values' => 'ID',
|
||||
'class' => 'widefat',
|
||||
'property' => 'multiple',
|
||||
'chosen' => true,
|
||||
'placeholder' => __( 'None', 'sportspress' ),
|
||||
);
|
||||
if ( ! sp_dropdown_pages( $args ) ):
|
||||
sp_post_adder( $post_type, __( 'Add New', 'sportspress' ) );
|
||||
if ( ! sp_dropdown_pages( $args ) ) :
|
||||
sp_post_adder( $post_type, __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
}
|
||||
wp_nonce_field( 'sp-get-players', 'sp-get-players-nonce', false );
|
||||
@@ -156,7 +162,7 @@ class SP_Meta_Box_Event_Teams {
|
||||
}
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_player', $players );
|
||||
} else {
|
||||
$tabs = array();
|
||||
$tabs = array();
|
||||
$sections = get_option( 'sportspress_event_performance_sections', -1 );
|
||||
if ( -1 == $sections ) {
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array(), 'int' ) );
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* Event Video
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Video
|
||||
@@ -20,8 +22,8 @@ class SP_Meta_Box_Event_Video {
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$video = get_post_meta( $post->ID, 'sp_video', true );
|
||||
if ( $video ):
|
||||
?>
|
||||
if ( $video ) :
|
||||
?>
|
||||
<fieldset class="sp-video-embed">
|
||||
<?php echo apply_filters( 'the_content', '[embed width="254"]' . $video . '[/embed]' ); ?>
|
||||
<p><a href="#" class="sp-remove-video"><?php _e( 'Remove video', 'sportspress' ); ?></a></p>
|
||||
@@ -32,7 +34,11 @@ class SP_Meta_Box_Event_Video {
|
||||
<p><input class="widefat" type="text" name="sp_video" id="sp_video" value="<?php echo esc_url( $video ); ?>"></p>
|
||||
<p><a href="#" class="sp-remove-video"><?php _e( 'Cancel', 'sportspress' ); ?></a></p>
|
||||
</fieldset>
|
||||
<fieldset class="sp-video-adder<?php if ( $video ): ?> hidden<?php endif; ?>">
|
||||
<fieldset class="sp-video-adder
|
||||
<?php
|
||||
if ( $video ) :
|
||||
?>
|
||||
hidden<?php endif; ?>">
|
||||
<p><a href="#" class="sp-add-video"><?php _e( 'Add video', 'sportspress' ); ?></a></p>
|
||||
</fieldset>
|
||||
<?php
|
||||
@@ -44,4 +50,4 @@ class SP_Meta_Box_Event_Video {
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_video', sp_array_value( $_POST, 'sp_video', null, 'text' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* List Columns
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_List_Columns
|
||||
@@ -19,8 +21,8 @@ class SP_Meta_Box_List_Columns {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$selected = (array)get_post_meta( $post->ID, 'sp_columns', true );
|
||||
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
||||
$selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
|
||||
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
||||
?>
|
||||
<p><strong><?php _e( 'General', 'sportspress' ); ?></strong></p>
|
||||
<ul class="categorychecklist form-no-clear">
|
||||
@@ -33,7 +35,8 @@ class SP_Meta_Box_List_Columns {
|
||||
} else {
|
||||
_e( 'Rank', 'sportspress' );
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
@@ -72,4 +75,4 @@ class SP_Meta_Box_List_Columns {
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array(), 'key' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* List Data
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_List_Data
|
||||
@@ -21,8 +23,8 @@ class SP_Meta_Box_List_Data {
|
||||
public static function output( $post ) {
|
||||
global $pagenow;
|
||||
if ( is_admin() && in_array( $pagenow, array( 'post-new.php' ) ) && 'sp_list' == get_post_type() ) {
|
||||
self::table( );
|
||||
}else{
|
||||
self::table();
|
||||
} else {
|
||||
$list = new SP_Player_List( $post );
|
||||
list( $columns, $data, $placeholders, $merged, $orderby ) = $list->data( true );
|
||||
$adjustments = $list->adjustments;
|
||||
@@ -62,8 +64,11 @@ class SP_Meta_Box_List_Data {
|
||||
<?php if ( array_key_exists( 'position', $columns ) ) { ?>
|
||||
<th><?php _e( 'Position', 'sportspress' ); ?></th>
|
||||
<?php } ?>
|
||||
<?php foreach ( $columns as $key => $label ): ?>
|
||||
<?php if ( in_array( $key, array( 'number', 'team', 'position' ) ) ) continue; ?>
|
||||
<?php foreach ( $columns as $key => $label ) : ?>
|
||||
<?php
|
||||
if ( in_array( $key, array( 'number', 'team', 'position' ) ) ) {
|
||||
continue;}
|
||||
?>
|
||||
<th><label for="sp_columns_<?php echo esc_attr( $key ); ?>">
|
||||
<?php echo esc_html( $label ); ?>
|
||||
</label></th>
|
||||
@@ -72,19 +77,27 @@ class SP_Meta_Box_List_Data {
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( is_array( $data ) && sizeof( $data ) > 0 ):
|
||||
if ( is_array( $data ) && sizeof( $data ) > 0 ) :
|
||||
$i = 0;
|
||||
foreach ( $data as $player_id => $player_stats ):
|
||||
if ( !$player_id ) continue;
|
||||
$teams = get_post_meta( $player_id, 'sp_team', false );
|
||||
$div = get_term( $player_id, 'sp_season' );
|
||||
foreach ( $data as $player_id => $player_stats ) :
|
||||
if ( ! $player_id ) {
|
||||
continue;
|
||||
}
|
||||
$teams = get_post_meta( $player_id, 'sp_team', false );
|
||||
$div = get_term( $player_id, 'sp_season' );
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
$default_name = sp_array_value( $player_stats, 'name', '' );
|
||||
if ( $default_name == null )
|
||||
if ( $default_name == null ) {
|
||||
$default_name = get_the_title( $player_id );
|
||||
}
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<tr class="sp-row sp-post
|
||||
<?php
|
||||
if ( $i % 2 == 0 ) {
|
||||
echo ' alternate';}
|
||||
?>
|
||||
">
|
||||
<?php if ( array_key_exists( 'number', $columns ) ) { ?>
|
||||
<td>
|
||||
<?php
|
||||
@@ -97,7 +110,10 @@ class SP_Meta_Box_List_Data {
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td>
|
||||
<?php if ( $show_player_photo ) echo get_the_post_thumbnail( $player_id, 'sportspress-fit-mini' ); ?>
|
||||
<?php
|
||||
if ( $show_player_photo ) {
|
||||
echo get_the_post_thumbnail( $player_id, 'sportspress-fit-mini' );}
|
||||
?>
|
||||
<span class="sp-default-value">
|
||||
<span class="sp-default-value-input"><?php echo esc_html( $default_name ); ?></span>
|
||||
<a class="dashicons dashicons-edit sp-edit" title="<?php _e( 'Edit', 'sportspress' ); ?>"></a>
|
||||
@@ -112,14 +128,16 @@ class SP_Meta_Box_List_Data {
|
||||
<td>
|
||||
<?php
|
||||
$selected = sp_array_value( $player_stats, 'team', get_post_meta( get_the_ID(), 'sp_team', true ) );
|
||||
if ( ! $selected ) $selected = get_post_meta( $player_id, 'sp_team', true );
|
||||
if ( ! $selected ) {
|
||||
$selected = get_post_meta( $player_id, 'sp_team', true );
|
||||
}
|
||||
$include = get_post_meta( $player_id, 'sp_team' );
|
||||
$args = array(
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_players[' . $player_id . '][team]',
|
||||
'include' => $include,
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
'name' => 'sp_players[' . $player_id . '][team]',
|
||||
'include' => $include,
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
?>
|
||||
@@ -129,33 +147,36 @@ class SP_Meta_Box_List_Data {
|
||||
<td>
|
||||
<?php
|
||||
$selected = sp_array_value( $player_stats, 'position', null );
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'sp_players[' . $player_id . '][position]',
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'sp_players[' . $player_id . '][position]',
|
||||
'show_option_blank' => __( '(Auto)', 'sportspress' ),
|
||||
'values' => 'term_id',
|
||||
'orderby' => 'meta_value_num',
|
||||
'values' => 'term_id',
|
||||
'orderby' => 'meta_value_num',
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'NOT EXISTS'
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'EXISTS'
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
),
|
||||
'selected' => $selected,
|
||||
'selected' => $selected,
|
||||
'include_children' => ( 'no' == get_option( 'sportspress_event_hide_child_positions', 'no' ) ),
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) continue;
|
||||
$value = sp_array_value( $player_stats, $column, '' );
|
||||
<?php
|
||||
foreach ( $columns as $column => $label ) :
|
||||
if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) {
|
||||
continue;
|
||||
}
|
||||
$value = sp_array_value( $player_stats, $column, '' );
|
||||
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
|
||||
?>
|
||||
<td><input type="text" name="sp_players[<?php echo esc_attr( $player_id ); ?>][<?php echo esc_attr( $column ); ?>]" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" data-placeholder="<?php echo esc_attr( $placeholder ); ?>" data-matrix="<?php echo esc_attr( $player_id ); ?>_<?php echo esc_attr( $column ); ?>" data-adjustment="<?php echo esc_attr( sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $column, 0 ) ); ?>" /></td>
|
||||
@@ -164,14 +185,19 @@ class SP_Meta_Box_List_Data {
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
else:
|
||||
?>
|
||||
else :
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="<?php $colspan = sizeof( $columns ) + ( apply_filters( 'sportspress_has_teams', true ) ? 3 : 2 ); echo esc_attr( $colspan ); ?>">
|
||||
<td colspan="
|
||||
<?php
|
||||
$colspan = sizeof( $columns ) + ( apply_filters( 'sportspress_has_teams', true ) ? 3 : 2 );
|
||||
echo esc_attr( $colspan );
|
||||
?>
|
||||
">
|
||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Data', 'sportspress' ) ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</tbody>
|
||||
@@ -183,27 +209,41 @@ class SP_Meta_Box_List_Data {
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<?php foreach ( $columns as $key => $label ): if ( in_array( $key, array( 'number', 'team', 'position' ) ) ) continue; ?>
|
||||
<?php
|
||||
foreach ( $columns as $key => $label ) :
|
||||
if ( in_array( $key, array( 'number', 'team', 'position' ) ) ) {
|
||||
continue;}
|
||||
?>
|
||||
<th><?php echo esc_html( $label ); ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( is_array( $data ) && sizeof( $data ) > 0 ):
|
||||
if ( is_array( $data ) && sizeof( $data ) > 0 ) :
|
||||
$i = 0;
|
||||
foreach ( $data as $player_id => $player_stats ):
|
||||
if ( !$player_id ) continue;
|
||||
$div = get_term( $player_id, 'sp_season' );
|
||||
foreach ( $data as $player_id => $player_stats ) :
|
||||
if ( ! $player_id ) {
|
||||
continue;
|
||||
}
|
||||
$div = get_term( $player_id, 'sp_season' );
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<tr class="sp-row sp-post
|
||||
<?php
|
||||
if ( $i % 2 == 0 ) {
|
||||
echo ' alternate';}
|
||||
?>
|
||||
">
|
||||
<td><?php echo ( $number ? $number : ' ' ); ?></td>
|
||||
<td>
|
||||
<?php echo get_the_title( $player_id ); ?>
|
||||
</td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) continue;
|
||||
<?php
|
||||
foreach ( $columns as $column => $label ) :
|
||||
if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) {
|
||||
continue;
|
||||
}
|
||||
$value = sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $column, '' );
|
||||
?>
|
||||
<td><input type="text" name="sp_adjustments[<?php echo esc_attr( $player_id ); ?>][<?php echo esc_attr( $column ); ?>]" value="<?php echo esc_attr( $value ); ?>" placeholder="0" data-matrix="<?php echo esc_attr( $player_id ); ?>_<?php echo esc_attr( $column ); ?>" /></td>
|
||||
@@ -212,14 +252,19 @@ class SP_Meta_Box_List_Data {
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
else:
|
||||
?>
|
||||
else :
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="<?php $colspan = sizeof( $columns ) + 3; echo esc_attr( $colspan ); ?>">
|
||||
<td colspan="
|
||||
<?php
|
||||
$colspan = sizeof( $columns ) + 3;
|
||||
echo esc_attr( $colspan );
|
||||
?>
|
||||
">
|
||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Details', 'sportspress' ) ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</tbody>
|
||||
@@ -227,4 +272,4 @@ class SP_Meta_Box_List_Data {
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* List Details
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_List_Details
|
||||
@@ -19,24 +21,24 @@ class SP_Meta_Box_List_Details {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$taxonomies = get_object_taxonomies( 'sp_list' );
|
||||
$caption = get_post_meta( $post->ID, 'sp_caption', true );
|
||||
$team_id = get_post_meta( $post->ID, 'sp_team', true );
|
||||
$era = get_post_meta( $post->ID, 'sp_era', true );
|
||||
$grouping = get_post_meta( $post->ID, 'sp_grouping', true );
|
||||
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
||||
$select = get_post_meta( $post->ID, 'sp_select', true );
|
||||
$number = get_post_meta( $post->ID, 'sp_number', true );
|
||||
$crop = get_post_meta( $post->ID, 'sp_crop', true );
|
||||
$date = get_post_meta( $post->ID, 'sp_date', true );
|
||||
$date_from = get_post_meta( $post->ID, 'sp_date_from', true );
|
||||
$date_to = get_post_meta( $post->ID, 'sp_date_to', true );
|
||||
$date_past = get_post_meta( $post->ID, 'sp_date_past', true );
|
||||
$date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
|
||||
$continents = SP()->countries->continents;
|
||||
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
|
||||
$default_nationality = get_option( 'sportspress_default_nationality' , false );
|
||||
$taxonomies = get_object_taxonomies( 'sp_list' );
|
||||
$caption = get_post_meta( $post->ID, 'sp_caption', true );
|
||||
$team_id = get_post_meta( $post->ID, 'sp_team', true );
|
||||
$era = get_post_meta( $post->ID, 'sp_era', true );
|
||||
$grouping = get_post_meta( $post->ID, 'sp_grouping', true );
|
||||
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
||||
$order = get_post_meta( $post->ID, 'sp_order', true );
|
||||
$select = get_post_meta( $post->ID, 'sp_select', true );
|
||||
$number = get_post_meta( $post->ID, 'sp_number', true );
|
||||
$crop = get_post_meta( $post->ID, 'sp_crop', true );
|
||||
$date = get_post_meta( $post->ID, 'sp_date', true );
|
||||
$date_from = get_post_meta( $post->ID, 'sp_date_from', true );
|
||||
$date_to = get_post_meta( $post->ID, 'sp_date_to', true );
|
||||
$date_past = get_post_meta( $post->ID, 'sp_date_past', true );
|
||||
$date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
|
||||
$continents = SP()->countries->continents;
|
||||
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
|
||||
$default_nationality = get_option( 'sportspress_default_nationality', false );
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
|
||||
@@ -47,8 +49,8 @@ class SP_Meta_Box_List_Details {
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'name' => 'sp_date',
|
||||
'id' => 'sp_date',
|
||||
'name' => 'sp_date',
|
||||
'id' => 'sp_date',
|
||||
'selected' => $date,
|
||||
);
|
||||
sp_dropdown_dates( $args );
|
||||
@@ -85,13 +87,13 @@ class SP_Meta_Box_List_Details {
|
||||
<p class="sp-tab-select sp-team-era-selector">
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_team',
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_team',
|
||||
'show_option_all' => __( 'All', 'sportspress' ),
|
||||
'selected' => $team_id,
|
||||
'values' => 'ID',
|
||||
'selected' => $team_id,
|
||||
'values' => 'ID',
|
||||
);
|
||||
if ( ! sp_dropdown_pages( $args ) ):
|
||||
if ( ! sp_dropdown_pages( $args ) ) :
|
||||
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
?>
|
||||
@@ -103,12 +105,16 @@ class SP_Meta_Box_List_Details {
|
||||
</p>
|
||||
<p><strong><?php _e( 'Nationality', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<select id="sp_nationality" name="sp_nationality[]" data-placeholder="<?php printf( __( 'Select %s', 'sportspress' ), __( 'Nationality', 'sportspress' ) ); ?>" class="widefat chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>" multiple="multiple">
|
||||
<select id="sp_nationality" name="sp_nationality[]" data-placeholder="<?php printf( __( 'Select %s', 'sportspress' ), __( 'Nationality', 'sportspress' ) ); ?>" class="widefat chosen-select
|
||||
<?php
|
||||
if ( is_rtl() ) :
|
||||
?>
|
||||
chosen-rtl<?php endif; ?>" multiple="multiple">
|
||||
<option value=""></option>
|
||||
<?php foreach ( $continents as $continent => $countries ): ?>
|
||||
<?php foreach ( $continents as $continent => $countries ) : ?>
|
||||
<optgroup label="<?php echo esc_attr( $continent ); ?>">
|
||||
<?php foreach ( $countries as $code => $country ): ?>
|
||||
<option value="<?php echo esc_attr( $code ); ?>" <?php selected ( in_array( $code, $nationalities ) ); ?>><?php echo esc_html( $country ); ?></option>
|
||||
<?php foreach ( $countries as $code => $country ) : ?>
|
||||
<option value="<?php echo esc_attr( $code ); ?>" <?php selected( in_array( $code, $nationalities ) ); ?>><?php echo esc_html( $country ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
@@ -127,12 +133,12 @@ class SP_Meta_Box_List_Details {
|
||||
$args = array(
|
||||
'prepend_options' => array(
|
||||
'number' => __( 'Squad Number', 'sportspress' ),
|
||||
'name' => __( 'Name', 'sportspress' ),
|
||||
'name' => __( 'Name', 'sportspress' ),
|
||||
),
|
||||
'post_type' => array( 'sp_performance', 'sp_metric', 'sp_statistic' ),
|
||||
'name' => 'sp_orderby',
|
||||
'selected' => $orderby,
|
||||
'values' => 'slug',
|
||||
'post_type' => array( 'sp_performance', 'sp_metric', 'sp_statistic' ),
|
||||
'name' => 'sp_orderby',
|
||||
'selected' => $orderby,
|
||||
'values' => 'slug',
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?>
|
||||
@@ -160,11 +166,11 @@ class SP_Meta_Box_List_Details {
|
||||
<?php
|
||||
if ( 'manual' == $select ) {
|
||||
$player_filters = array( 'sp_league', 'sp_season' );
|
||||
if ( $team_id ) {
|
||||
if ( in_array( $era, [ 'all', 'past' ] ) ) {
|
||||
if ( $team_id ) {
|
||||
if ( in_array( $era, array( 'all', 'past' ) ) ) {
|
||||
$player_filters[] = 'sp_past_team';
|
||||
}
|
||||
if ( in_array( $era, [ 'all', 'current' ] ) ) {
|
||||
if ( in_array( $era, array( 'all', 'current' ) ) ) {
|
||||
$player_filters[] = 'sp_current_team';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* List Format
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_List_Format
|
||||
@@ -23,7 +25,7 @@ class SP_Meta_Box_List_Format {
|
||||
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
||||
?>
|
||||
<div id="post-formats-select">
|
||||
<?php foreach ( SP()->formats->list as $key => $format ): ?>
|
||||
<?php foreach ( SP()->formats->list as $key => $format ) : ?>
|
||||
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( true, ( $key == 'list' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $format ); ?></label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
@@ -36,4 +38,4 @@ class SP_Meta_Box_List_Format {
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'list', 'key' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
/**
|
||||
* List Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 1.6.1
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_List_Shortcode
|
||||
@@ -20,7 +22,9 @@ class SP_Meta_Box_List_Shortcode {
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
||||
if ( ! $the_format ) $the_format = 'list';
|
||||
if ( ! $the_format ) {
|
||||
$the_format = 'list';
|
||||
}
|
||||
?>
|
||||
<p class="howto">
|
||||
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
|
||||
@@ -28,4 +32,4 @@ class SP_Meta_Box_List_Shortcode {
|
||||
<p><input type="text" value="<?php sp_shortcode_template( 'player_' . $the_format, $post->ID ); ?>" readonly="readonly" class="code widefat"></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user