Clean up spaces, tabs, indentation, and bracket formatting
This commit is contained in:
@@ -1,26 +1,38 @@
|
||||
jQuery(document).ready(function($){
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
|
||||
// Color picker
|
||||
$('.colorpick').iris( {
|
||||
$( '.colorpick' ).iris(
|
||||
{
|
||||
change: function(event, ui){
|
||||
$( this ).css( { backgroundColor: ui.color.toString() } );
|
||||
},
|
||||
hide: true,
|
||||
border: true
|
||||
} ).each( function() {
|
||||
}
|
||||
).each(
|
||||
function() {
|
||||
$( this ).css( { backgroundColor: $( this ).val() } );
|
||||
})
|
||||
.click(function(){
|
||||
}
|
||||
)
|
||||
.click(
|
||||
function(){
|
||||
$( '.iris-picker' ).hide();
|
||||
$( this ).closest( '.sp-color-box, td' ).find( '.iris-picker' ).show();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$('body').click(function() {
|
||||
$( 'body' ).click(
|
||||
function() {
|
||||
$( '.iris-picker' ).hide();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$('.sp-color-box, .colorpick').click(function(event){
|
||||
$( '.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() {
|
||||
$( "#sportspress_dashboard_status .sp_status_list li.countdown" ).each(
|
||||
function() {
|
||||
var $this = $( this ), finalDate = $( this ).data( 'countdown' );
|
||||
$this.countdown(finalDate, function(event) {
|
||||
$this.countdown(
|
||||
finalDate,
|
||||
function(event) {
|
||||
$this.find( 'strong' ).html( event.strftime( "%D " + localized_strings.days + " %H:%M:%S" ) );
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -4,22 +4,33 @@ $shortcodes = '';
|
||||
|
||||
$options = array(
|
||||
'event' => array(
|
||||
'details', 'results', 'performance', 'venue', 'officials', 'teams', 'full',
|
||||
'details',
|
||||
'results',
|
||||
'performance',
|
||||
'venue',
|
||||
'officials',
|
||||
'teams',
|
||||
'full',
|
||||
),
|
||||
'team' => array(),
|
||||
'player' => array(
|
||||
'details', 'statistics'
|
||||
'details',
|
||||
'statistics',
|
||||
),
|
||||
);
|
||||
|
||||
$options = apply_filters( 'sportspress_shortcodes', $options );
|
||||
|
||||
foreach ( $options as $name => $group ) {
|
||||
if ( empty( $group ) ) continue;
|
||||
if ( empty( $group ) ) {
|
||||
continue;
|
||||
}
|
||||
$shortcodes .= $name . '[' . implode( '|', $group ) . ']';
|
||||
}
|
||||
|
||||
$raw = apply_filters( 'sportspress_tinymce_strings', array(
|
||||
$raw = apply_filters(
|
||||
'sportspress_tinymce_strings',
|
||||
array(
|
||||
'shortcodes' => $shortcodes,
|
||||
'insert' => __( 'SportsPress Shortcodes', 'sportspress' ),
|
||||
'auto' => __( 'Auto', 'sportspress' ),
|
||||
@@ -42,7 +53,8 @@ $raw = apply_filters( 'sportspress_tinymce_strings', array(
|
||||
'list' => __( 'List', 'sportspress' ),
|
||||
'blocks' => __( 'Blocks', 'sportspress' ),
|
||||
'gallery' => __( 'Gallery', 'sportspress' ),
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$formatted = array();
|
||||
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
/* global tinymce */
|
||||
( function () {
|
||||
tinymce.PluginManager.add( 'sp_shortcodes_button', function( editor, url ) {
|
||||
tinymce.PluginManager.add(
|
||||
'sp_shortcodes_button',
|
||||
function( editor, url ) {
|
||||
var ed = tinymce.activeEditor;
|
||||
|
||||
var groups = ed.getLang( 'sportspress.shortcodes' ).split( "]" );
|
||||
var menu = new Array();
|
||||
|
||||
groups.forEach(function(g) {
|
||||
if ( "" == g ) return;
|
||||
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({
|
||||
shortcodes.forEach(
|
||||
function(s) {
|
||||
submenu.push(
|
||||
{
|
||||
text: ed.getLang( 'sportspress.' + s ),
|
||||
onclick: function() {
|
||||
// triggers the thickbox
|
||||
@@ -23,20 +30,29 @@
|
||||
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({
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
menu.push(
|
||||
{
|
||||
text: ed.getLang( 'sportspress.' + label ),
|
||||
menu: submenu
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
editor.addButton( 'sp_shortcodes_button', {
|
||||
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() {
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
$( "#title" ).keyup(
|
||||
function() {
|
||||
val = $( this ).val();
|
||||
if ( val == '' ) val = 'f(x)';
|
||||
if ( val == '' ) {
|
||||
val = 'f(x)';
|
||||
}
|
||||
$( ".sp-equation-variable" ).text( val + ' =' );
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$(".sp-equation-parts .button").draggable({
|
||||
$( ".sp-equation-parts .button" ).draggable(
|
||||
{
|
||||
appendTo: "body",
|
||||
helper: "clone",
|
||||
cursor: "move",
|
||||
distance: 10,
|
||||
containment: "#sp_equationdiv",
|
||||
}).click(function() {
|
||||
}
|
||||
).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({
|
||||
$( ".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({
|
||||
}
|
||||
).sortable(
|
||||
{
|
||||
items: ".button",
|
||||
tolerance: "pointer",
|
||||
containment: "#sp_equationdiv",
|
||||
sort: function() {
|
||||
$( this ).removeClass( "ui-state-active" );
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$(".sp-equation-formula").on("click", ".button .remove", function() {
|
||||
$( ".sp-equation-formula" ).on(
|
||||
"click",
|
||||
".button .remove",
|
||||
function() {
|
||||
$( this ).closest( ".button" ).remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
jQuery(document).ready(function($){
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
|
||||
// Icon picker
|
||||
$('.sp-icons input').on('change', function() {
|
||||
$( '.sp-icons input' ).on(
|
||||
'change',
|
||||
function() {
|
||||
if ('' == $( this ).val()) {
|
||||
$( '.sp-custom-colors' ).hide();
|
||||
$( '.sp-custom-thumbnail' ).show();
|
||||
@@ -9,29 +12,41 @@ jQuery(document).ready(function($){
|
||||
$( '.sp-custom-thumbnail' ).hide();
|
||||
$( '.sp-custom-colors' ).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Color picker
|
||||
$('.colorpick').iris( {
|
||||
$( '.colorpick' ).iris(
|
||||
{
|
||||
change: function(event, ui){
|
||||
$( this ).css( { backgroundColor: ui.color.toString() } );
|
||||
},
|
||||
hide: true,
|
||||
border: true
|
||||
} ).each( function() {
|
||||
}
|
||||
).each(
|
||||
function() {
|
||||
$( this ).css( { backgroundColor: $( this ).val() } );
|
||||
})
|
||||
.click(function(){
|
||||
}
|
||||
)
|
||||
.click(
|
||||
function(){
|
||||
$( '.iris-picker' ).hide();
|
||||
$( this ).closest( '.sp-color-box-for-icon, td' ).find( '.iris-picker' ).show();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$('body').click(function() {
|
||||
$( 'body' ).click(
|
||||
function() {
|
||||
$( '.iris-picker' ).hide();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$('.sp-color-box-for-icon, .colorpick').click(function(event){
|
||||
$( '.sp-color-box-for-icon, .colorpick' ).click(
|
||||
function(event){
|
||||
event.stopPropagation();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -30,38 +30,52 @@
|
||||
|
||||
// populate the data
|
||||
$( ':input[name="sp_number"]', $edit_row ).val( $number );
|
||||
$( ':input[name="sp_current_team[]"]', $edit_row ).each(function() {
|
||||
$( ':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() {
|
||||
}
|
||||
);
|
||||
$( ':input[name="sp_past_team[]"]', $edit_row ).each(
|
||||
function() {
|
||||
$( this ).prop( "checked", ($.inArray( $( this ).val(), $past_teams ) != -1) );
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
$( document ).on( 'click', '#bulk_edit', function() {
|
||||
$( 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() {
|
||||
$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() {
|
||||
$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() {
|
||||
$bulk_row.find( 'input[name="sp_past_team[]"]:checked' ).each(
|
||||
function() {
|
||||
$past_teams.push( $( this ).val() );
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// save the data
|
||||
$.ajax({
|
||||
$.ajax(
|
||||
{
|
||||
url: ajaxurl, // this is a variable that WordPress has already defined for us
|
||||
type: 'POST',
|
||||
async: false,
|
||||
@@ -73,7 +87,9 @@
|
||||
past_teams: $past_teams,
|
||||
nonce: $( "#sp_player_edit_nonce" ).val()
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
})( 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() {
|
||||
$( "body.toplevel_page_sportspress #sportspress_sport" ).change(
|
||||
function() {
|
||||
$target = $( "#sportspress_custom_sport_name" );
|
||||
if ( $(this).val() == "custom" )
|
||||
if ( $( this ).val() == "custom" ) {
|
||||
$target.show();
|
||||
else
|
||||
} else {
|
||||
$target.hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Color picker
|
||||
$('.colorpick').iris( {
|
||||
$( '.colorpick' ).iris(
|
||||
{
|
||||
change: function(event, ui){
|
||||
$( this ).css( { backgroundColor: ui.color.toString() } );
|
||||
},
|
||||
hide: true,
|
||||
border: true
|
||||
} ).each( function() {
|
||||
}
|
||||
).each(
|
||||
function() {
|
||||
$( this ).css( { backgroundColor: $( this ).val() } );
|
||||
})
|
||||
.click(function(){
|
||||
}
|
||||
)
|
||||
.click(
|
||||
function(){
|
||||
$( '.iris-picker' ).hide();
|
||||
$( this ).closest( '.sp-color-box, td' ).find( '.iris-picker' ).show();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$('body').click(function() {
|
||||
$( 'body' ).click(
|
||||
function() {
|
||||
$( '.iris-picker' ).hide();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$('.sp-color-box, .colorpick').click(function(event){
|
||||
$( '.sp-color-box, .colorpick' ).click(
|
||||
function(event){
|
||||
event.stopPropagation();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Chosen select
|
||||
$(".chosen-select").chosen({
|
||||
$( ".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() {
|
||||
$( ".sp-custom-input-wrapper .preset" ).click(
|
||||
function() {
|
||||
val = $( this ).val();
|
||||
if(val == "\\c\\u\\s\\t\\o\\m") return true;
|
||||
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() {
|
||||
$( ".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() {
|
||||
$( ".sp-custom-input-wrapper .value" ).on(
|
||||
"keyup",
|
||||
function() {
|
||||
val = $( this ).val();
|
||||
if ( val === undefined ) return true;
|
||||
if ( val === undefined ) {
|
||||
return true;
|
||||
}
|
||||
format = $( this ).attr( "data-example-format" );
|
||||
example = format.replace( /__val__/g, val );
|
||||
$( this ).siblings( ".example" ).html( example );
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -5,32 +5,46 @@ 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({
|
||||
control = L.Control.geocoder(
|
||||
{
|
||||
geocoder: geocoder,
|
||||
collapsed: false,
|
||||
defaultMarkGeocode: false
|
||||
}).addTo(map),
|
||||
}
|
||||
).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', {
|
||||
L.tileLayer(
|
||||
'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
|
||||
{
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
}
|
||||
).addTo( map );
|
||||
|
||||
// Pass the values to the fields after dragging
|
||||
marker.on('dragend', function (e) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
// After searching
|
||||
control.on('markgeocode', function(e) {
|
||||
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
|
||||
@@ -41,14 +55,22 @@ control.on('markgeocode', function(e) {
|
||||
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) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
).addTo( map );
|
||||
|
||||
@@ -5,32 +5,46 @@ 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({
|
||||
control = L.Control.geocoder(
|
||||
{
|
||||
geocoder: geocoder,
|
||||
collapsed: false,
|
||||
defaultMarkGeocode: false
|
||||
}).addTo(map),
|
||||
}
|
||||
).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', {
|
||||
L.tileLayer(
|
||||
'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
|
||||
{
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
}
|
||||
).addTo( map );
|
||||
|
||||
// Pass the values to the fields after dragging
|
||||
marker.on('dragend', function (e) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
// After searching
|
||||
control.on('markgeocode', function(e) {
|
||||
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
|
||||
@@ -41,14 +55,22 @@ control.on('markgeocode', function(e) {
|
||||
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) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
).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({
|
||||
$( ".sp-tip" ).tipTip(
|
||||
{
|
||||
delay: 200,
|
||||
fadeIn: 100,
|
||||
fadeOut: 100
|
||||
});
|
||||
$(".sp-desc-tip").tipTip({
|
||||
}
|
||||
);
|
||||
$( ".sp-desc-tip" ).tipTip(
|
||||
{
|
||||
delay: 200,
|
||||
fadeIn: 100,
|
||||
fadeOut: 100,
|
||||
defaultPosition: 'right'
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Chosen select
|
||||
$(".chosen-select, #poststuff #post_author_override").chosen({
|
||||
$( ".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,31 +1,48 @@
|
||||
jQuery(document).ready(function($){
|
||||
jQuery( document ).ready(
|
||||
function($){
|
||||
|
||||
// Orderby affects order select in widget options
|
||||
$("body").on("change", ".sp-select-orderby", function() {
|
||||
$( "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() {
|
||||
$( "body" ).on(
|
||||
"change",
|
||||
".sp-event-calendar-select",
|
||||
function() {
|
||||
$el = $( this ).closest( ".widget-content" ).find( ".sp-event-calendar-show-all-toggle" );
|
||||
if($(this).val() == 0)
|
||||
if ($( this ).val() == 0) {
|
||||
$el.hide();
|
||||
else
|
||||
} else {
|
||||
$el.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Show or hide datepicker
|
||||
$("body").on("change", ".sp-date-selector select", function() {
|
||||
$( "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() {
|
||||
$( "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" ) );
|
||||
|
||||
@@ -36,6 +53,8 @@ jQuery(document).ready(function($){
|
||||
$absolute.show();
|
||||
$relative.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
$( ".sp-date-selector input" ).trigger( "change" );
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import apiFetch from '@wordpress/api-fetch';
|
||||
console.log( wp.api.collections.Posts() );
|
||||
|
||||
wp.blocks.registerBlockType('sportspress/event-calendar', {
|
||||
wp.blocks.registerBlockType(
|
||||
'sportspress/event-calendar',
|
||||
{
|
||||
title: strings.event_calendar,
|
||||
icon: 'calendar',
|
||||
category: 'sportspress',
|
||||
@@ -63,9 +65,13 @@ wp.blocks.registerBlockType('sportspress/event-calendar', {
|
||||
),
|
||||
React.createElement(
|
||||
wp.components.SelectControl,
|
||||
{label: strings.select_calendar, options: [{label: strings.all, value: 0}].concat(posts.events.map(post => {
|
||||
{label: strings.select_calendar, options: [{label: strings.all, value: 0}].concat(
|
||||
posts.events.map(
|
||||
post => {
|
||||
return {label: post.post_title, value: post.ID}
|
||||
}))}
|
||||
}
|
||||
)
|
||||
)}
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -78,4 +84,5 @@ wp.blocks.registerBlockType('sportspress/event-calendar', {
|
||||
props.attributes.content
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
$.extend( settings, options );
|
||||
}
|
||||
|
||||
return this.each(function(){
|
||||
return this.each(
|
||||
function(){
|
||||
var selectors = [
|
||||
'iframe[src*="player.vimeo.com"]',
|
||||
'iframe[src*="youtube.com"]',
|
||||
@@ -56,14 +57,15 @@
|
||||
$allVideos = $allVideos.not( 'object object' ); // SwfObj conflict patch
|
||||
$allVideos = $allVideos.not( ignoreList ); // Disable FitVids on this video.
|
||||
|
||||
$allVideos.each(function(){
|
||||
$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'))))
|
||||
{
|
||||
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 );
|
||||
}
|
||||
@@ -76,8 +78,10 @@
|
||||
}
|
||||
$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 );
|
||||
|
||||
@@ -15,12 +15,14 @@ function sp_viewport() {
|
||||
}
|
||||
|
||||
/* Countdown */
|
||||
$("[data-countdown]").each(function() {
|
||||
$( "[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() {
|
||||
var x = setInterval(
|
||||
function() {
|
||||
|
||||
// Get todays date and time
|
||||
var now = new Date();
|
||||
@@ -42,28 +44,37 @@ function sp_viewport() {
|
||||
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> "
|
||||
$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);
|
||||
});
|
||||
+ "<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>" );
|
||||
|
||||
/* Selector Redirect */
|
||||
$(".sp-selector-redirect").change(function() {
|
||||
$( ".sp-selector-redirect" ).change(
|
||||
function() {
|
||||
window.location = $( this ).val();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
/* Template Tabs */
|
||||
$(".sp-tab-menu-item a").click(function() {
|
||||
$( ".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 )
|
||||
@@ -82,14 +93,20 @@ function sp_viewport() {
|
||||
}
|
||||
|
||||
/* Data Tables */
|
||||
$(".sp-data-table").each(function() {
|
||||
$( ".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 ( display_length == undefined || isNaN( display_length ) ) {
|
||||
display_length = 10;
|
||||
}
|
||||
if ( $( this ).find( "tbody tr" ).length <= display_length ) {
|
||||
paginated = false;
|
||||
}
|
||||
if ( sortable || paginated ) {
|
||||
$(this).dataTable({
|
||||
$( this ).dataTable(
|
||||
{
|
||||
"order": [],
|
||||
"autoWidth": false,
|
||||
"searching": false,
|
||||
@@ -112,8 +129,10 @@ function sp_viewport() {
|
||||
"columnDefs": [
|
||||
{ "type": "num-fmt", "targets": [ ".data-number", ".data-rank" ] },
|
||||
]
|
||||
});
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
})( jQuery );
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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 ) );
|
||||
@@ -34,19 +36,19 @@ $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 ) :
|
||||
@@ -63,7 +65,9 @@ foreach ( $events as $event):
|
||||
|
||||
// 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' ) );
|
||||
@@ -106,7 +110,9 @@ foreach ( $events as $event):
|
||||
if ( ! empty( $teams ) ) {
|
||||
$event_results = get_post_meta( $event->ID, 'sp_results', true );
|
||||
foreach ( $teams as $team_id ) {
|
||||
if ( ! $team_id ) continue;
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
|
||||
if ( $team ) {
|
||||
@@ -136,38 +142,44 @@ foreach ( $events as $event):
|
||||
}
|
||||
|
||||
// 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 = 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";
|
||||
'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' );
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -106,15 +108,18 @@ class SP_Admin_Assets {
|
||||
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(
|
||||
$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' ) ),
|
||||
) );
|
||||
'displaying_posts' => html_entity_decode( __( 'Displaying %1$s–%2$s of %3$s', 'sportspress' ) ),
|
||||
)
|
||||
);
|
||||
|
||||
// Localize scripts
|
||||
wp_localize_script( 'sportspress-admin', 'localized_strings', $strings );
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -42,7 +44,9 @@ class SP_Admin_Dashboard {
|
||||
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;
|
||||
if ( ! post_type_exists( $type ) ) {
|
||||
continue;
|
||||
}
|
||||
$num_posts = wp_count_posts( $type );
|
||||
if ( $num_posts ) :
|
||||
$published = intval( $num_posts->publish );
|
||||
@@ -101,7 +105,7 @@ class SP_Admin_Dashboard {
|
||||
* Show news widget
|
||||
*/
|
||||
public function news_widget() {
|
||||
$rss = fetch_feed("https://tboy.co/sportsnews/");
|
||||
$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 );
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -29,7 +31,9 @@ class SP_Admin_Importers {
|
||||
*/
|
||||
public function register_importers() {
|
||||
global $pagenow;
|
||||
$importers = apply_filters( 'sportspress_importers', array(
|
||||
$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' ),
|
||||
@@ -55,7 +59,8 @@ class SP_Admin_Importers {
|
||||
'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(
|
||||
@@ -154,9 +159,10 @@ class SP_Admin_Importers {
|
||||
|
||||
if ( ! class_exists( 'WP_Importer' ) ) {
|
||||
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
|
||||
if ( file_exists( $class_wp_importer ) )
|
||||
if ( file_exists( $class_wp_importer ) ) {
|
||||
require $class_wp_importer;
|
||||
}
|
||||
}
|
||||
|
||||
require 'importers/class-sp-importer.php';
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -41,8 +43,9 @@ class SP_Admin_Menus {
|
||||
public function admin_menu() {
|
||||
global $menu;
|
||||
|
||||
if ( current_user_can( 'manage_sportspress' ) )
|
||||
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' );
|
||||
}
|
||||
@@ -77,7 +80,9 @@ class SP_Admin_Menus {
|
||||
public function menu_highlight() {
|
||||
global $typenow;
|
||||
$screen = get_current_screen();
|
||||
if ( ! is_object( $screen ) ) return;
|
||||
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 ) ) {
|
||||
@@ -100,15 +105,17 @@ class SP_Admin_Menus {
|
||||
public function menu_rename() {
|
||||
global $menu, $submenu;
|
||||
|
||||
if ( isset( $submenu['sportspress'] ) && isset( $submenu['sportspress'][0] ) && isset( $submenu['sportspress'][0][0] ) )
|
||||
if ( isset( $submenu['sportspress'] ) && isset( $submenu['sportspress'][0] ) && isset( $submenu['sportspress'][0][0] ) ) {
|
||||
$submenu['sportspress'][0][0] = __( 'Settings', 'sportspress' );
|
||||
}
|
||||
}
|
||||
|
||||
public function parent_file( $parent_file ) {
|
||||
global $current_screen;
|
||||
$taxonomy = $current_screen->taxonomy;
|
||||
if ( in_array( $taxonomy, array( 'sp_league', 'sp_season' ) ) )
|
||||
if ( in_array( $taxonomy, array( 'sp_league', 'sp_season' ) ) ) {
|
||||
$parent_file = 'sportspress';
|
||||
}
|
||||
return $parent_file;
|
||||
}
|
||||
|
||||
@@ -167,11 +174,13 @@ class SP_Admin_Menus {
|
||||
|
||||
/**
|
||||
* custom_menu_order
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function custom_menu_order() {
|
||||
if ( ! current_user_can( 'manage_sportspress' ) )
|
||||
if ( ! current_user_can( 'manage_sportspress' ) ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -183,8 +192,9 @@ class SP_Admin_Menus {
|
||||
|
||||
// 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' )
|
||||
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
|
||||
@@ -231,14 +241,14 @@ class SP_Admin_Menus {
|
||||
* Init the config page
|
||||
*/
|
||||
public function config_page() {
|
||||
include( 'views/html-admin-config.php' );
|
||||
include 'views/html-admin-config.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the settings page
|
||||
*/
|
||||
public function settings_page() {
|
||||
include_once( 'class-sp-admin-settings.php' );
|
||||
include_once 'class-sp-admin-settings.php';
|
||||
SP_Admin_Settings::output();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -40,7 +42,9 @@ class SP_Admin_Notices {
|
||||
$screen = get_current_screen();
|
||||
$notices = get_option( 'sportspress_admin_notices', array() );
|
||||
|
||||
if ( ! is_object( $screen ) ) return;
|
||||
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 ) );
|
||||
@@ -83,21 +87,21 @@ class SP_Admin_Notices {
|
||||
* Show the setup notices
|
||||
*/
|
||||
public function setup_notice() {
|
||||
include( 'views/html-notice-install.php' );
|
||||
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' );
|
||||
include 'views/html-notice-no-access.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Theme Check notice
|
||||
*/
|
||||
public function theme_check_notice() {
|
||||
include( 'views/html-notice-theme-support.php' );
|
||||
include 'views/html-notice-theme-support.php';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +112,7 @@ class SP_Admin_Notices {
|
||||
return;
|
||||
}
|
||||
|
||||
$status = include( 'class-sp-admin-status.php' );
|
||||
$status = include 'class-sp-admin-status.php';
|
||||
$core_templates = $status->scan_template_files( SP()->plugin_path() . '/templates' );
|
||||
$outdated = false;
|
||||
|
||||
@@ -136,7 +140,7 @@ class SP_Admin_Notices {
|
||||
}
|
||||
|
||||
if ( $outdated ) {
|
||||
include( 'views/html-notice-template-check.php' );
|
||||
include 'views/html-notice-template-check.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -21,7 +23,9 @@ class SP_Admin_Permalink_Settings {
|
||||
* Hook in tabs.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->slugs = apply_filters( 'sportspress_permalink_slugs', array(
|
||||
$this->slugs = apply_filters(
|
||||
'sportspress_permalink_slugs',
|
||||
array(
|
||||
array( 'event', __( 'Events', 'sportspress' ) ),
|
||||
array( 'venue', __( 'Venues', 'sportspress' ) ),
|
||||
array( 'calendar', __( 'Calendars', 'sportspress' ) ),
|
||||
@@ -33,7 +37,8 @@ class SP_Admin_Permalink_Settings {
|
||||
array( 'position', __( 'Positions', 'sportspress' ) ),
|
||||
array( 'list', __( 'Player Lists', 'sportspress' ) ),
|
||||
array( 'staff', __( 'Staff', 'sportspress' ) ),
|
||||
) );
|
||||
)
|
||||
);
|
||||
|
||||
add_action( 'admin_init', array( $this, 'settings_init' ) );
|
||||
add_action( 'admin_init', array( $this, 'settings_save' ) );
|
||||
@@ -65,7 +70,8 @@ class SP_Admin_Permalink_Settings {
|
||||
$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
|
||||
?><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
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,19 +85,22 @@ class SP_Admin_Permalink_Settings {
|
||||
* Save the settings
|
||||
*/
|
||||
public function settings_save() {
|
||||
if ( ! is_admin() )
|
||||
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 ] ) )
|
||||
if ( isset( $_POST[ $key ] ) ) {
|
||||
$value = sanitize_text_field( $_POST[ $key ] );
|
||||
if ( empty( $value ) )
|
||||
}
|
||||
if ( empty( $value ) ) {
|
||||
delete_option( $key );
|
||||
else
|
||||
} else {
|
||||
update_option( $key, $value );
|
||||
}
|
||||
endforeach;
|
||||
sp_flush_rewrite_rules();
|
||||
endif;
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -31,17 +33,17 @@ 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' );
|
||||
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' );
|
||||
}
|
||||
|
||||
@@ -95,7 +97,9 @@ class SP_Admin_Post_Types {
|
||||
|
||||
$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) ) ) .
|
||||
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>';
|
||||
|
||||
|
||||
@@ -92,7 +92,14 @@ 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 ) ) {
|
||||
@@ -169,10 +176,26 @@ class SP_Admin_Sample_Data {
|
||||
$post['tax_input'] = array();
|
||||
$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 );
|
||||
@@ -213,15 +236,30 @@ class SP_Admin_Sample_Data {
|
||||
$post['tax_input'] = array();
|
||||
$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 );
|
||||
@@ -277,7 +315,9 @@ class SP_Admin_Sample_Data {
|
||||
);
|
||||
$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(
|
||||
@@ -308,13 +348,28 @@ class SP_Admin_Sample_Data {
|
||||
$post['tax_input'] = array();
|
||||
$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 );
|
||||
@@ -349,15 +404,36 @@ class SP_Admin_Sample_Data {
|
||||
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 ) );
|
||||
$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 ) );
|
||||
$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',
|
||||
@@ -365,9 +441,28 @@ class SP_Admin_Sample_Data {
|
||||
'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 ) ),
|
||||
'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,
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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
|
||||
@@ -437,7 +534,9 @@ 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 ) {
|
||||
@@ -469,7 +568,7 @@ class SP_Admin_Sample_Data {
|
||||
'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_content' => sprintf( $sample_content, __( 'Calendar', 'sportspress' ), __( 'Calendars', 'sportspress' ), add_query_arg( 'post_type', 'sp_calendar', admin_url( 'edit.php' ) ) ),
|
||||
);
|
||||
|
||||
// Insert post
|
||||
@@ -495,9 +594,25 @@ class SP_Admin_Sample_Data {
|
||||
/*
|
||||
* Insert league table
|
||||
*/
|
||||
$leagues = get_terms( 'sp_league', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
||||
$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 ) );
|
||||
$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,
|
||||
@@ -605,7 +720,9 @@ class SP_Admin_Sample_Data {
|
||||
// Get columns
|
||||
$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
|
||||
@@ -638,8 +757,8 @@ class SP_Admin_Sample_Data {
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_sp_sample',
|
||||
'value' => 1
|
||||
)
|
||||
'value' => 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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_Settings' ) ) :
|
||||
|
||||
@@ -29,28 +31,28 @@ class SP_Admin_Settings {
|
||||
if ( empty( self::$settings ) ) {
|
||||
$settings = array();
|
||||
|
||||
include_once( 'class-sp-admin-sports.php' );
|
||||
include_once( 'settings/class-sp-settings-page.php' );
|
||||
include_once 'class-sp-admin-sports.php';
|
||||
include_once 'settings/class-sp-settings-page.php';
|
||||
|
||||
$settings[] = include( 'settings/class-sp-settings-modules.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-general.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-events.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-teams.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-players.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-staff.php' );
|
||||
$settings[] = include 'settings/class-sp-settings-modules.php';
|
||||
$settings[] = include 'settings/class-sp-settings-general.php';
|
||||
$settings[] = include 'settings/class-sp-settings-events.php';
|
||||
$settings[] = include 'settings/class-sp-settings-teams.php';
|
||||
$settings[] = include 'settings/class-sp-settings-players.php';
|
||||
$settings[] = include 'settings/class-sp-settings-staff.php';
|
||||
|
||||
$settings = apply_filters( 'sportspress_get_settings_pages', $settings );
|
||||
|
||||
$settings[] = include( 'settings/class-sp-settings-text.php' );
|
||||
$settings[] = include 'settings/class-sp-settings-text.php';
|
||||
|
||||
if (
|
||||
( ! is_multisite() && current_user_can( 'manage_options' ) ) ||
|
||||
( is_multisite() && current_user_can( 'manage_network_options' ) )
|
||||
) {
|
||||
$settings[] = include( 'settings/class-sp-settings-licenses.php' );
|
||||
$settings[] = include 'settings/class-sp-settings-licenses.php';
|
||||
}
|
||||
|
||||
$settings[] = include( 'settings/class-sp-settings-status.php' );
|
||||
$settings[] = include 'settings/class-sp-settings-status.php';
|
||||
|
||||
self::$settings = apply_filters( 'sportspress_get_settings_config_pages', $settings );
|
||||
}
|
||||
@@ -63,8 +65,9 @@ class SP_Admin_Settings {
|
||||
public static function save() {
|
||||
global $current_section, $current_tab;
|
||||
|
||||
if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'sportspress-settings' ) )
|
||||
if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'sportspress-settings' ) ) {
|
||||
die( __( 'Action failed. Please refresh the page and retry.', 'sportspress' ) );
|
||||
}
|
||||
|
||||
// Trigger actions
|
||||
do_action( 'sportspress_settings_save_' . $current_tab );
|
||||
@@ -78,6 +81,7 @@ class SP_Admin_Settings {
|
||||
|
||||
/**
|
||||
* Add a message
|
||||
*
|
||||
* @param string $text
|
||||
*/
|
||||
public static function add_message( $text ) {
|
||||
@@ -86,6 +90,7 @@ class SP_Admin_Settings {
|
||||
|
||||
/**
|
||||
* Add an override
|
||||
*
|
||||
* @param string $text
|
||||
*/
|
||||
public static function add_override( $text ) {
|
||||
@@ -94,6 +99,7 @@ class SP_Admin_Settings {
|
||||
|
||||
/**
|
||||
* Add an error
|
||||
*
|
||||
* @param string $text
|
||||
*/
|
||||
public static function add_error( $text ) {
|
||||
@@ -105,16 +111,19 @@ class SP_Admin_Settings {
|
||||
*/
|
||||
public static function show_messages() {
|
||||
if ( sizeof( self::$errors ) > 0 ) {
|
||||
foreach ( self::$errors as $error )
|
||||
foreach ( self::$errors as $error ) {
|
||||
echo '<div id="message" class="error fade"><p><strong>' . esc_html( $error ) . '</strong></p></div>';
|
||||
}
|
||||
} elseif ( sizeof( self::$overrides ) > 0 ) {
|
||||
foreach ( self::$overrides as $override )
|
||||
foreach ( self::$overrides as $override ) {
|
||||
echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $override ) . '</strong></p></div>';
|
||||
}
|
||||
} elseif ( sizeof( self::$messages ) > 0 ) {
|
||||
foreach ( self::$messages as $message )
|
||||
foreach ( self::$messages as $message ) {
|
||||
echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $message ) . '</strong></p></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings page.
|
||||
@@ -131,9 +140,13 @@ class SP_Admin_Settings {
|
||||
|
||||
wp_enqueue_script( 'sportspress_settings', SP()->plugin_url() . '/assets/js/admin/settings.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'iris', 'chosen' ), SP()->version, true );
|
||||
|
||||
wp_localize_script( 'sportspress_settings', 'localized_strings', array(
|
||||
'none' => __( 'None', 'sportspress' )
|
||||
) );
|
||||
wp_localize_script(
|
||||
'sportspress_settings',
|
||||
'localized_strings',
|
||||
array(
|
||||
'none' => __( 'None', 'sportspress' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Include settings pages
|
||||
self::get_settings_pages();
|
||||
@@ -143,15 +156,18 @@ class SP_Admin_Settings {
|
||||
$current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( $_REQUEST['section'] );
|
||||
|
||||
// Save settings if data has been posted
|
||||
if ( ! empty( $_POST ) )
|
||||
if ( ! empty( $_POST ) ) {
|
||||
self::save();
|
||||
}
|
||||
|
||||
// Add any posted messages
|
||||
if ( ! empty( $_GET['sp_error'] ) )
|
||||
if ( ! empty( $_GET['sp_error'] ) ) {
|
||||
self::add_error( stripslashes( $_GET['sp_error'] ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $_GET['sp_message'] ) )
|
||||
if ( ! empty( $_GET['sp_message'] ) ) {
|
||||
self::add_message( stripslashes( $_GET['sp_message'] ) );
|
||||
}
|
||||
|
||||
self::show_messages();
|
||||
|
||||
@@ -181,20 +197,22 @@ class SP_Admin_Settings {
|
||||
|
||||
$key = key( $option_array[ $option_name ] );
|
||||
|
||||
if ( isset( $option_values[ $key ] ) )
|
||||
if ( isset( $option_values[ $key ] ) ) {
|
||||
$option_value = $option_values[ $key ];
|
||||
else
|
||||
} else {
|
||||
$option_value = null;
|
||||
}
|
||||
|
||||
// Single value
|
||||
} else {
|
||||
$option_value = get_option( $option_name, null );
|
||||
}
|
||||
|
||||
if ( is_array( $option_value ) )
|
||||
if ( is_array( $option_value ) ) {
|
||||
$option_value = array_map( 'stripslashes', $option_value );
|
||||
elseif ( ! is_null( $option_value ) )
|
||||
} elseif ( ! is_null( $option_value ) ) {
|
||||
$option_value = stripslashes( $option_value );
|
||||
}
|
||||
|
||||
return $option_value === null ? $default : $option_value;
|
||||
}
|
||||
@@ -209,22 +227,42 @@ class SP_Admin_Settings {
|
||||
*/
|
||||
public static function output_fields( $options ) {
|
||||
foreach ( $options as $value ) {
|
||||
if ( ! isset( $value['type'] ) ) continue;
|
||||
if ( ! isset( $value['id'] ) ) $value['id'] = '';
|
||||
if ( ! isset( $value['title'] ) ) $value['title'] = isset( $value['name'] ) ? $value['name'] : '';
|
||||
if ( ! isset( $value['class'] ) ) $value['class'] = '';
|
||||
if ( ! isset( $value['css'] ) ) $value['css'] = '';
|
||||
if ( ! isset( $value['default'] ) ) $value['default'] = '';
|
||||
if ( ! isset( $value['desc'] ) ) $value['desc'] = '';
|
||||
if ( ! isset( $value['desc_tip'] ) ) $value['desc_tip'] = false;
|
||||
if ( ! isset( $value['placeholder'] ) ) $value['placeholder'] = '';
|
||||
if ( ! isset( $value['type'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! isset( $value['id'] ) ) {
|
||||
$value['id'] = '';
|
||||
}
|
||||
if ( ! isset( $value['title'] ) ) {
|
||||
$value['title'] = isset( $value['name'] ) ? $value['name'] : '';
|
||||
}
|
||||
if ( ! isset( $value['class'] ) ) {
|
||||
$value['class'] = '';
|
||||
}
|
||||
if ( ! isset( $value['css'] ) ) {
|
||||
$value['css'] = '';
|
||||
}
|
||||
if ( ! isset( $value['default'] ) ) {
|
||||
$value['default'] = '';
|
||||
}
|
||||
if ( ! isset( $value['desc'] ) ) {
|
||||
$value['desc'] = '';
|
||||
}
|
||||
if ( ! isset( $value['desc_tip'] ) ) {
|
||||
$value['desc_tip'] = false;
|
||||
}
|
||||
if ( ! isset( $value['placeholder'] ) ) {
|
||||
$value['placeholder'] = '';
|
||||
}
|
||||
|
||||
// Custom attribute handling
|
||||
$custom_attributes = array();
|
||||
|
||||
if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) )
|
||||
foreach ( $value['custom_attributes'] as $attribute => $attribute_value )
|
||||
if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) {
|
||||
foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) {
|
||||
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
// Description handling
|
||||
if ( $value['desc_tip'] === true ) {
|
||||
@@ -297,7 +335,6 @@ class SP_Admin_Settings {
|
||||
case 'number':
|
||||
case 'color':
|
||||
case 'password':
|
||||
|
||||
$type = $value['type'];
|
||||
$class = '';
|
||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||
@@ -313,7 +350,7 @@ class SP_Admin_Settings {
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo esc_html( $tip ); ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||
<input
|
||||
name="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
@@ -325,20 +362,21 @@ class SP_Admin_Settings {
|
||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||
/> <?php echo wp_kses_post( $description ); ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
// Textarea
|
||||
case 'textarea':
|
||||
|
||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||
|
||||
?><tr valign="top">
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo esc_html( $tip ); ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||
<?php echo wp_kses_post( $description ); ?>
|
||||
|
||||
<textarea
|
||||
@@ -349,66 +387,95 @@ class SP_Admin_Settings {
|
||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||
><?php echo esc_textarea( $option_value ); ?></textarea>
|
||||
</td>
|
||||
</tr><?php
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
// Select boxes
|
||||
case 'select':
|
||||
case 'multiselect':
|
||||
|
||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||
|
||||
?><tr valign="top">
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo esc_html( $tip ); ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||
<select
|
||||
name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>"
|
||||
name="<?php echo esc_attr( $value['id'] ); ?>
|
||||
<?php
|
||||
if ( $value['type'] == 'multiselect' ) {
|
||||
echo '[]';}
|
||||
?>
|
||||
"
|
||||
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
style="<?php echo esc_attr( $value['css'] ); ?>"
|
||||
class="chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
|
||||
class="chosen-select
|
||||
<?php
|
||||
if ( is_rtl() ) :
|
||||
?>
|
||||
chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
|
||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||
<?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
|
||||
<?php
|
||||
if ( $value['type'] == 'multiselect' ) {
|
||||
echo 'multiple="multiple"';}
|
||||
?>
|
||||
>
|
||||
<?php
|
||||
foreach ( $value['options'] as $key => $val ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php
|
||||
<option value="<?php echo esc_attr( $key ); ?>"
|
||||
<?php
|
||||
|
||||
if ( is_array( $option_value ) )
|
||||
if ( is_array( $option_value ) ) {
|
||||
selected( in_array( $key, $option_value ), true );
|
||||
else
|
||||
} else {
|
||||
selected( $option_value, $key );
|
||||
}
|
||||
|
||||
?>><?php echo esc_attr( $val ); ?></option>
|
||||
?>
|
||||
><?php echo esc_attr( $val ); ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select> <?php echo wp_kses_post( $description ); ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
// Select boxes with optgroup
|
||||
case 'groupselect':
|
||||
|
||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||
|
||||
?><tr valign="top">
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo esc_html( $tip ); ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||
<select
|
||||
name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>"
|
||||
name="<?php echo esc_attr( $value['id'] ); ?>
|
||||
<?php
|
||||
if ( $value['type'] == 'multiselect' ) {
|
||||
echo '[]';}
|
||||
?>
|
||||
"
|
||||
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
style="<?php echo esc_attr( $value['css'] ); ?>"
|
||||
class="chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
|
||||
class="chosen-select
|
||||
<?php
|
||||
if ( is_rtl() ) :
|
||||
?>
|
||||
chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
|
||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||
<?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
|
||||
<?php
|
||||
if ( $value['type'] == 'multiselect' ) {
|
||||
echo 'multiple="multiple"';}
|
||||
?>
|
||||
>
|
||||
<?php
|
||||
foreach ( $value['options'] as $group => $options ) {
|
||||
@@ -417,14 +484,17 @@ class SP_Admin_Settings {
|
||||
<?php
|
||||
foreach ( $options as $key => $val ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php
|
||||
<option value="<?php echo esc_attr( $key ); ?>"
|
||||
<?php
|
||||
|
||||
if ( is_array( $option_value ) )
|
||||
if ( is_array( $option_value ) ) {
|
||||
selected( in_array( $key, $option_value ), true );
|
||||
else
|
||||
} else {
|
||||
selected( $option_value, $key );
|
||||
}
|
||||
|
||||
?>><?php echo esc_attr( $val ); ?></option>
|
||||
?>
|
||||
><?php echo esc_attr( $val ); ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
@@ -434,31 +504,46 @@ class SP_Admin_Settings {
|
||||
?>
|
||||
</select> <?php echo wp_kses_post( $description ); ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
// Select sport
|
||||
case 'sport':
|
||||
|
||||
$default = apply_filters( 'sportspress_default_sport', 'soccer' );
|
||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||
if ( 'none' === $option_value ) $option_value = $default;
|
||||
if ( 'none' === $option_value ) {
|
||||
$option_value = $default;
|
||||
}
|
||||
|
||||
$categories = SP_Admin_Sports::sport_category_names();
|
||||
|
||||
?><tr valign="top">
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo esc_html( $tip ); ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||
<select
|
||||
name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) echo '[]'; ?>"
|
||||
name="<?php echo esc_attr( $value['id'] ); ?>
|
||||
<?php
|
||||
if ( $value['type'] == 'multiselect' ) {
|
||||
echo '[]';}
|
||||
?>
|
||||
"
|
||||
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||
style="<?php echo esc_attr( $value['css'] ); ?>"
|
||||
class="sp-select-sport chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
|
||||
class="sp-select-sport chosen-select
|
||||
<?php
|
||||
if ( is_rtl() ) :
|
||||
?>
|
||||
chosen-rtl<?php endif; ?> <?php echo esc_attr( $value['class'] ); ?>"
|
||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||
<?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
|
||||
<?php
|
||||
if ( $value['type'] == 'multiselect' ) {
|
||||
echo 'multiple="multiple"';}
|
||||
?>
|
||||
>
|
||||
<?php
|
||||
foreach ( $value['options'] as $group => $options ) {
|
||||
@@ -467,14 +552,17 @@ class SP_Admin_Settings {
|
||||
<?php
|
||||
foreach ( $options as $key => $val ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php
|
||||
<option value="<?php echo esc_attr( $key ); ?>"
|
||||
<?php
|
||||
|
||||
if ( is_array( $option_value ) )
|
||||
if ( is_array( $option_value ) ) {
|
||||
selected( in_array( $key, $option_value ), true );
|
||||
else
|
||||
} else {
|
||||
selected( $option_value, $key );
|
||||
}
|
||||
|
||||
?>><?php echo esc_attr( $val ); ?></option>
|
||||
?>
|
||||
><?php echo esc_attr( $val ); ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
@@ -490,20 +578,21 @@ class SP_Admin_Settings {
|
||||
</label>
|
||||
</p>
|
||||
</td>
|
||||
</tr><?php
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
// Radio inputs
|
||||
case 'radio':
|
||||
|
||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||
|
||||
?><tr valign="top">
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc">
|
||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||
<?php echo wp_kses_post( $tip ); ?>
|
||||
</th>
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||
<fieldset>
|
||||
<?php echo wp_kses_post( $description ); ?>
|
||||
<ul>
|
||||
@@ -527,12 +616,12 @@ class SP_Admin_Settings {
|
||||
</ul>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr><?php
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
// Checkbox input
|
||||
case 'checkbox':
|
||||
|
||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||
$visbility_class = array();
|
||||
|
||||
@@ -555,7 +644,7 @@ class SP_Admin_Settings {
|
||||
if ( ! isset( $value['checkboxgroup'] ) || 'start' == $value['checkboxgroup'] ) {
|
||||
?>
|
||||
<tr valign="top" class="<?php echo esc_attr( implode( ' ', $visbility_class ) ); ?>">
|
||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?></th>
|
||||
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?></th>
|
||||
<td class="forminp forminp-checkbox">
|
||||
<fieldset>
|
||||
<?php
|
||||
@@ -567,7 +656,7 @@ class SP_Admin_Settings {
|
||||
|
||||
if ( ! empty( $value['title'] ) ) {
|
||||
?>
|
||||
<legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ) ?></span></legend>
|
||||
<legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ); ?></span></legend>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -615,8 +704,9 @@ class SP_Admin_Settings {
|
||||
* @return bool
|
||||
*/
|
||||
public static function save_fields( $options ) {
|
||||
if ( empty( $_POST ) )
|
||||
if ( empty( $_POST ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Options to update will be stored here
|
||||
$update_options = array();
|
||||
@@ -624,8 +714,9 @@ class SP_Admin_Settings {
|
||||
// Loop options and get values to save
|
||||
foreach ( $options as $value ) {
|
||||
|
||||
if ( ! isset( $value['id'] ) )
|
||||
if ( ! isset( $value['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = isset( $value['type'] ) ? esc_attr( $value['type'] ) : '';
|
||||
|
||||
@@ -636,7 +727,6 @@ class SP_Admin_Settings {
|
||||
|
||||
// Standard types
|
||||
case 'checkbox':
|
||||
|
||||
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||
$option_value = 'yes';
|
||||
} else {
|
||||
@@ -646,7 +736,6 @@ class SP_Admin_Settings {
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
|
||||
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||
$option_value = wp_kses_post( trim( stripslashes( $_POST[ $value['id'] ] ) ) );
|
||||
} else {
|
||||
@@ -664,7 +753,6 @@ class SP_Admin_Settings {
|
||||
case 'color':
|
||||
case 'password':
|
||||
case 'radio':
|
||||
|
||||
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||
$option_value = sanitize_text_field( stripslashes( $_POST[ $value['id'] ] ) );
|
||||
} else {
|
||||
@@ -674,14 +762,14 @@ class SP_Admin_Settings {
|
||||
break;
|
||||
|
||||
// Special types
|
||||
case "multiselect" :
|
||||
case "multi_select_countries" :
|
||||
|
||||
case 'multiselect':
|
||||
case 'multi_select_countries':
|
||||
// Get countries array
|
||||
if ( isset( $_POST[ $value['id'] ] ) )
|
||||
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||
$selected_countries = array_map( 'sanitize_text_field', array_map( 'stripslashes', (array) $_POST[ $value['id'] ] ) );
|
||||
else
|
||||
} else {
|
||||
$selected_countries = array();
|
||||
}
|
||||
|
||||
$option_value = $selected_countries;
|
||||
|
||||
@@ -689,7 +777,6 @@ class SP_Admin_Settings {
|
||||
|
||||
// Custom handling
|
||||
default:
|
||||
|
||||
do_action( 'sportspress_update_option_' . $type, $value );
|
||||
|
||||
break;
|
||||
@@ -706,11 +793,13 @@ class SP_Admin_Settings {
|
||||
$option_name = current( array_keys( $option_array ) );
|
||||
|
||||
// Get old option value
|
||||
if ( ! isset( $update_options[ $option_name ] ) )
|
||||
if ( ! isset( $update_options[ $option_name ] ) ) {
|
||||
$update_options[ $option_name ] = get_option( $option_name, array() );
|
||||
}
|
||||
|
||||
if ( ! is_array( $update_options[ $option_name ] ) )
|
||||
if ( ! is_array( $update_options[ $option_name ] ) ) {
|
||||
$update_options[ $option_name ] = array();
|
||||
}
|
||||
|
||||
// Set keys and value
|
||||
$key = key( $option_array[ $option_name ] );
|
||||
@@ -728,8 +817,9 @@ class SP_Admin_Settings {
|
||||
}
|
||||
|
||||
// Now save the options
|
||||
foreach( $update_options as $name => $value )
|
||||
foreach ( $update_options as $name => $value ) {
|
||||
update_option( $name, $value );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class SP_Admin_Setup_Wizard {
|
||||
|
||||
/** @var array Tweets user can optionally send after install */
|
||||
private $tweets = array(
|
||||
"Someone give me a high five, I just set up a new sports data website with #SportsPress and #WordPress!"
|
||||
'Someone give me a high five, I just set up a new sports data website with #SportsPress and #WordPress!',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -59,17 +59,17 @@ class SP_Admin_Setup_Wizard {
|
||||
'introduction' => array(
|
||||
'name' => __( 'Introduction', 'sportspress' ),
|
||||
'view' => array( $this, 'sp_setup_introduction' ),
|
||||
'handler' => ''
|
||||
'handler' => '',
|
||||
),
|
||||
'basics' => array(
|
||||
'name' => __( 'Basic Setup', 'sportspress' ),
|
||||
'view' => array( $this, 'sp_setup_basics' ),
|
||||
'handler' => array( $this, 'sp_setup_basics_save' )
|
||||
'handler' => array( $this, 'sp_setup_basics_save' ),
|
||||
),
|
||||
'teams' => array(
|
||||
'name' => __( 'Teams', 'sportspress' ),
|
||||
'view' => array( $this, 'sp_setup_teams' ),
|
||||
'handler' => array( $this, 'sp_setup_teams_save' )
|
||||
'handler' => array( $this, 'sp_setup_teams_save' ),
|
||||
),
|
||||
'players_staff' => array(
|
||||
'name' => __( 'Players', 'sportspress' ) . ' & ' . __( 'Staff', 'sportspress' ),
|
||||
@@ -84,13 +84,13 @@ class SP_Admin_Setup_Wizard {
|
||||
'pages' => array(
|
||||
'name' => __( 'Pages', 'sportspress' ),
|
||||
'view' => array( $this, 'sp_setup_pages' ),
|
||||
'handler' => array( $this, 'sp_setup_pages_save' )
|
||||
'handler' => array( $this, 'sp_setup_pages_save' ),
|
||||
),
|
||||
'next_steps' => array(
|
||||
'name' => __( 'Ready!', 'sportspress' ),
|
||||
'view' => array( $this, 'sp_setup_ready' ),
|
||||
'handler' => ''
|
||||
)
|
||||
'handler' => '',
|
||||
),
|
||||
);
|
||||
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
@@ -105,10 +105,13 @@ class SP_Admin_Setup_Wizard {
|
||||
|
||||
do_action( 'sp_setup_geocoder_scripts' );
|
||||
|
||||
$strings = apply_filters( 'sportspress_localized_strings', array(
|
||||
$strings = apply_filters(
|
||||
'sportspress_localized_strings',
|
||||
array(
|
||||
'none' => __( 'None', 'sportspress' ),
|
||||
'remove_text' => __( '— Remove —', 'sportspress' ),
|
||||
) );
|
||||
)
|
||||
);
|
||||
|
||||
// Localize scripts
|
||||
wp_localize_script( 'sportspress-setup', 'localized_strings', $strings );
|
||||
@@ -172,13 +175,15 @@ class SP_Admin_Setup_Wizard {
|
||||
?>
|
||||
<ol class="sp-setup-steps">
|
||||
<?php foreach ( $ouput_steps as $step_key => $step ) : ?>
|
||||
<li class="<?php
|
||||
<li class="
|
||||
<?php
|
||||
if ( $step_key === $this->step ) {
|
||||
echo 'active';
|
||||
} elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
|
||||
echo 'done';
|
||||
}
|
||||
?>"><?php echo esc_html( $step['name'] ); ?></li>
|
||||
?>
|
||||
"><?php echo esc_html( $step['name'] ); ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php
|
||||
@@ -229,18 +234,20 @@ class SP_Admin_Setup_Wizard {
|
||||
$check_zone_info = true;
|
||||
|
||||
// Remove old Etc mappings. Fallback to gmt_offset.
|
||||
if ( false !== strpos($tzstring,'Etc/GMT') )
|
||||
if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
|
||||
$tzstring = '';
|
||||
}
|
||||
|
||||
if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
|
||||
$check_zone_info = false;
|
||||
if ( 0 == $current_offset )
|
||||
if ( 0 == $current_offset ) {
|
||||
$tzstring = 'UTC+0';
|
||||
elseif ($current_offset < 0)
|
||||
} elseif ( $current_offset < 0 ) {
|
||||
$tzstring = 'UTC' . $current_offset;
|
||||
else
|
||||
} else {
|
||||
$tzstring = 'UTC+' . $current_offset;
|
||||
}
|
||||
}
|
||||
echo wp_timezone_choice( $tzstring );
|
||||
?>
|
||||
</select>
|
||||
@@ -253,7 +260,9 @@ class SP_Admin_Setup_Wizard {
|
||||
$options = SP_Admin_Sports::get_preset_options();
|
||||
$default = apply_filters( 'sportspress_default_sport', 'soccer' );
|
||||
$sport = get_option( 'sportspress_sport', $default );
|
||||
if ( 'none' === $sport ) $sport = $default;
|
||||
if ( 'none' === $sport ) {
|
||||
$sport = $default;
|
||||
}
|
||||
$categories = SP_Admin_Sports::sport_category_names();
|
||||
?>
|
||||
<select name="sport" id="sport" class="sp-select-sport <?php echo esc_attr( $class ); ?>">
|
||||
@@ -312,11 +321,13 @@ class SP_Admin_Setup_Wizard {
|
||||
$timezone_string = '';
|
||||
}
|
||||
|
||||
if ( isset( $timezone_string ) )
|
||||
if ( isset( $timezone_string ) ) {
|
||||
update_option( 'timezone_string', $timezone_string );
|
||||
}
|
||||
|
||||
if ( isset( $gmt_offset ) )
|
||||
if ( isset( $gmt_offset ) ) {
|
||||
update_option( 'gmt_offset', $gmt_offset );
|
||||
}
|
||||
|
||||
// Update sport
|
||||
$sport = sanitize_text_field( $_POST['sport'] );
|
||||
@@ -369,7 +380,7 @@ class SP_Admin_Setup_Wizard {
|
||||
<th scope="row"><?php _e( 'Rival Team', 'sportspress' ); ?></th>
|
||||
<td>
|
||||
<input name="away_team" type="text" class="widefat" placeholder="<?php _e( 'Who are you playing against next?', 'sportspress' ); ?>">
|
||||
<p class="description"><?php _e( "You can add more teams later.", 'sportspress' ); ?></p>
|
||||
<p class="description"><?php _e( 'You can add more teams later.', 'sportspress' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -396,8 +407,14 @@ class SP_Admin_Setup_Wizard {
|
||||
$post['tax_input'] = array();
|
||||
$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',
|
||||
)
|
||||
);
|
||||
}
|
||||
wp_insert_post( $post );
|
||||
|
||||
// Add home team
|
||||
@@ -412,7 +429,14 @@ class SP_Admin_Setup_Wizard {
|
||||
* Players & Staff Setup.
|
||||
*/
|
||||
public function sp_setup_players_staff() {
|
||||
$positions = (array) get_terms( 'sp_position', array( 'hide_empty' => 0, 'orderby' => 'slug', 'fields' => 'names' ) )
|
||||
$positions = (array) get_terms(
|
||||
'sp_position',
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'orderby' => 'slug',
|
||||
'fields' => 'names',
|
||||
)
|
||||
)
|
||||
?>
|
||||
<h1><?php esc_html_e( 'Player & Staff Setup', 'sportspress' ); ?></h1>
|
||||
<form method="post">
|
||||
@@ -423,10 +447,14 @@ class SP_Admin_Setup_Wizard {
|
||||
<td>
|
||||
<ul>
|
||||
<?php for ( $i = 0; $i < 3; $i++ ) { ?>
|
||||
<li class="player"><input name="players[<?php echo $i; ?>][number]" type="text" class="player-number" placeholder="#" value="<?php echo $i + 1; ?>"> <input name="players[<?php echo $i; ?>][name]" type="text" placeholder="<?php _e( 'Name', 'sportspress' ); ?>"> <input name="players[<?php echo $i; ?>][position]" type="text" placeholder="<?php _e( 'Position', 'sportspress' ); ?>" <?php if ( sizeof( $positions ) ) { ?> value="<?php echo esc_attr( $positions[ $i % sizeof( $positions ) ] ); ?>"<?php } ?>></li>
|
||||
<li class="player"><input name="players[<?php echo $i; ?>][number]" type="text" class="player-number" placeholder="#" value="<?php echo $i + 1; ?>"> <input name="players[<?php echo $i; ?>][name]" type="text" placeholder="<?php _e( 'Name', 'sportspress' ); ?>"> <input name="players[<?php echo $i; ?>][position]" type="text" placeholder="<?php _e( 'Position', 'sportspress' ); ?>"
|
||||
<?php
|
||||
if ( sizeof( $positions ) ) {
|
||||
?>
|
||||
value="<?php echo esc_attr( $positions[ $i % sizeof( $positions ) ] ); ?>"<?php } ?>></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<p class="description"><?php _e( "You can add more players later.", 'sportspress' ); ?></p>
|
||||
<p class="description"><?php _e( 'You can add more players later.', 'sportspress' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -455,7 +483,13 @@ class SP_Admin_Setup_Wizard {
|
||||
check_admin_referer( 'sp-setup' );
|
||||
|
||||
// Get home team
|
||||
$teams = (array) get_posts( array( 'posts_per_page' => 1, 'post_type' => 'sp_team', 'fields' => 'ids' ) );
|
||||
$teams = (array) get_posts(
|
||||
array(
|
||||
'posts_per_page' => 1,
|
||||
'post_type' => 'sp_team',
|
||||
'fields' => 'ids',
|
||||
)
|
||||
);
|
||||
$team = reset( $teams );
|
||||
|
||||
// Add players
|
||||
@@ -464,11 +498,19 @@ class SP_Admin_Setup_Wizard {
|
||||
$post['tax_input'] = array();
|
||||
$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',
|
||||
)
|
||||
);
|
||||
}
|
||||
if ( is_array( $_POST['players'] ) ) {
|
||||
foreach ( $_POST['players'] as $i => $player ) {
|
||||
if ( empty( $player['name'] ) ) continue;
|
||||
if ( empty( $player['name'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$post['post_title'] = $player['name'];
|
||||
$id = wp_insert_post( $post );
|
||||
@@ -517,7 +559,7 @@ class SP_Admin_Setup_Wizard {
|
||||
?>
|
||||
<h1><?php _e( 'Venue Setup', 'sportspress' ); ?></h1>
|
||||
<form method="post">
|
||||
<p><?php _e( "Enter the details of your home venue.", 'sportspress' ); ?></p>
|
||||
<p><?php _e( 'Enter the details of your home venue.', 'sportspress' ); ?></p>
|
||||
<table class="form-table" cellspacing="0">
|
||||
<tr>
|
||||
<th scope="row"><?php _e( 'Name', 'sportspress' ); ?></th>
|
||||
@@ -554,7 +596,13 @@ class SP_Admin_Setup_Wizard {
|
||||
check_admin_referer( 'sp-setup' );
|
||||
|
||||
// Get home team
|
||||
$teams = (array) get_posts( array( 'posts_per_page' => 1, 'post_type' => 'sp_team', 'fields' => 'ids' ) );
|
||||
$teams = (array) get_posts(
|
||||
array(
|
||||
'posts_per_page' => 1,
|
||||
'post_type' => 'sp_team',
|
||||
'fields' => 'ids',
|
||||
)
|
||||
);
|
||||
$team = reset( $teams );
|
||||
|
||||
// Insert venue
|
||||
@@ -588,11 +636,14 @@ class SP_Admin_Setup_Wizard {
|
||||
* Pages Step.
|
||||
*/
|
||||
public function sp_setup_pages() {
|
||||
$pages = apply_filters( 'sportspress_setup_pages', array(
|
||||
$pages = apply_filters(
|
||||
'sportspress_setup_pages',
|
||||
array(
|
||||
'sp_calendar' => __( 'Organize and publish calendars using different layouts.', 'sportspress' ),
|
||||
'sp_table' => __( 'Create automated league tables to keep track of team standings.', 'sportspress' ),
|
||||
'sp_list' => __( 'Create team rosters, player galleries, and ranking charts.', 'sportspress' ),
|
||||
) );
|
||||
)
|
||||
);
|
||||
?>
|
||||
<h1><?php _e( 'Pages', 'sportspress' ); ?></h1>
|
||||
<form method="post">
|
||||
@@ -601,7 +652,9 @@ class SP_Admin_Setup_Wizard {
|
||||
<?php foreach ( $pages as $post_type => $description ) { ?>
|
||||
<?php
|
||||
$obj = get_post_type_object( $post_type );
|
||||
if ( ! is_object( $obj ) ) continue;
|
||||
if ( ! is_object( $obj ) ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row"><?php echo esc_html( $obj->labels->singular_name ); ?></th>
|
||||
@@ -627,11 +680,14 @@ class SP_Admin_Setup_Wizard {
|
||||
public function sp_setup_pages_save() {
|
||||
check_admin_referer( 'sp-setup' );
|
||||
|
||||
$pages = apply_filters( 'sportspress_setup_pages', array(
|
||||
$pages = apply_filters(
|
||||
'sportspress_setup_pages',
|
||||
array(
|
||||
'sp_calendar' => __( 'Organize and publish calendars using different layouts.', 'sportspress' ),
|
||||
'sp_table' => __( 'Create automated league tables to keep track of team standings.', 'sportspress' ),
|
||||
'sp_list' => __( 'Create team rosters, player galleries, and ranking charts.', 'sportspress' ),
|
||||
) );
|
||||
)
|
||||
);
|
||||
|
||||
// Initialize post
|
||||
$post = array( 'post_status' => 'publish' );
|
||||
@@ -640,11 +696,20 @@ class SP_Admin_Setup_Wizard {
|
||||
// Insert posts
|
||||
foreach ( $pages as $post_type => $description ) {
|
||||
$obj = get_post_type_object( $post_type );
|
||||
if ( ! is_object( $obj ) ) continue;
|
||||
if ( ! is_object( $obj ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip if post exists
|
||||
$posts = get_posts( array( 'posts_per_page' => 1, 'post_type' => $post_type ) );
|
||||
if ( $posts ) continue;
|
||||
$posts = get_posts(
|
||||
array(
|
||||
'posts_per_page' => 1,
|
||||
'post_type' => $post_type,
|
||||
)
|
||||
);
|
||||
if ( $posts ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add post args
|
||||
$post['post_title'] = $obj->labels->singular_name;
|
||||
@@ -680,9 +745,9 @@ class SP_Admin_Setup_Wizard {
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_sp_first',
|
||||
'value' => 1
|
||||
)
|
||||
)
|
||||
'value' => 1,
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -696,13 +761,30 @@ class SP_Admin_Setup_Wizard {
|
||||
if ( 'player' === get_option( 'sportspress_mode', 'team' ) ) {
|
||||
$team_post_type = 'sp_player';
|
||||
}
|
||||
$teams = get_posts( array( 'posts_per_page' => 2, 'post_type' => $team_post_type ) );
|
||||
$teams = get_posts(
|
||||
array(
|
||||
'posts_per_page' => 2,
|
||||
'post_type' => $team_post_type,
|
||||
)
|
||||
);
|
||||
|
||||
// Get players
|
||||
$players = (array) get_posts( array( 'posts_per_page' => 3, 'post_type' => 'sp_player', 'fields' => 'ids' ) );
|
||||
$players = (array) get_posts(
|
||||
array(
|
||||
'posts_per_page' => 3,
|
||||
'post_type' => 'sp_player',
|
||||
'fields' => 'ids',
|
||||
)
|
||||
);
|
||||
|
||||
// Get staff
|
||||
$staff = (array) get_posts( array( 'posts_per_page' => 1, 'post_type' => 'sp_staff', 'fields' => 'ids' ) );
|
||||
$staff = (array) get_posts(
|
||||
array(
|
||||
'posts_per_page' => 1,
|
||||
'post_type' => 'sp_staff',
|
||||
'fields' => 'ids',
|
||||
)
|
||||
);
|
||||
|
||||
// Initialize post
|
||||
$post['post_type'] = 'sp_event';
|
||||
@@ -712,14 +794,23 @@ class SP_Admin_Setup_Wizard {
|
||||
// Add taxonomies
|
||||
$taxonomies = array( 'sp_league', 'sp_season', 'sp_venue' );
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$post['tax_input'][ $taxonomy ] = get_terms( $taxonomy, array( 'hide_empty' => 0, 'fields' => 'ids', 'number' => 1 ) );
|
||||
};
|
||||
$post['tax_input'][ $taxonomy ] = get_terms(
|
||||
$taxonomy,
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'fields' => 'ids',
|
||||
'number' => 1,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Add post title
|
||||
if ( is_array( $teams ) && sizeof( $teams ) ) {
|
||||
$team_names = array();
|
||||
foreach ( $teams as $team ) {
|
||||
if ( ! $team ) continue;
|
||||
if ( ! $team ) {
|
||||
continue;
|
||||
}
|
||||
$team_names[] = $team->post_title;
|
||||
}
|
||||
$post['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
|
||||
@@ -733,7 +824,9 @@ class SP_Admin_Setup_Wizard {
|
||||
// Add teams
|
||||
if ( is_array( $teams ) && sizeof( $teams ) ) {
|
||||
foreach ( $teams as $team ) {
|
||||
if ( ! $team ) continue;
|
||||
if ( ! $team ) {
|
||||
continue;
|
||||
}
|
||||
add_post_meta( $id, 'sp_team', $team->ID );
|
||||
}
|
||||
}
|
||||
@@ -741,7 +834,9 @@ class SP_Admin_Setup_Wizard {
|
||||
// Add players
|
||||
add_post_meta( $id, 'sp_player', 0 );
|
||||
foreach ( $players as $player ) {
|
||||
if ( ! $player ) continue;
|
||||
if ( ! $player ) {
|
||||
continue;
|
||||
}
|
||||
add_post_meta( $id, 'sp_player', $player );
|
||||
}
|
||||
add_post_meta( $id, 'sp_player', 0 );
|
||||
@@ -758,7 +853,9 @@ class SP_Admin_Setup_Wizard {
|
||||
$id = $this->sp_setup_ready_actions();
|
||||
shuffle( $this->tweets );
|
||||
|
||||
$steps = apply_filters( 'sportspress_setup_wizard_next_steps', array(
|
||||
$steps = apply_filters(
|
||||
'sportspress_setup_wizard_next_steps',
|
||||
array(
|
||||
'first' => array(
|
||||
'label' => __( 'Next Steps', 'sportspress' ),
|
||||
'content' => '<a class="button button-primary button-large button-first-event" href="' . esc_url( admin_url( 'post.php?post=' . $id . '&action=edit' ) ) . '">' . __( 'Schedule your first event!', 'sportspress' ) . '</a>',
|
||||
@@ -767,7 +864,8 @@ class SP_Admin_Setup_Wizard {
|
||||
'label' => __( 'Upgrade to Pro', 'sportspress' ),
|
||||
'content' => __( 'Get SportsPress Pro to get access to all modules. You can upgrade any time without losing any of your data.', 'sportspress' ) . ' <a href="' . apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ) . '" target="_blank">' . __( 'Learn more', 'sportspress' ) . '</a>',
|
||||
),
|
||||
) );
|
||||
)
|
||||
);
|
||||
?>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://tboy.co/sp" data-text="<?php echo esc_attr( $this->tweets[0] ); ?>" data-via="ThemeBoy" data-size="large">Tweet</a>
|
||||
<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>
|
||||
|
||||
@@ -43,7 +43,9 @@ class SP_Admin_Sports {
|
||||
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;
|
||||
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;
|
||||
@@ -70,14 +72,18 @@ 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +115,9 @@ class SP_Admin_Sports {
|
||||
$sections = sp_array_value( $position, 'sections', array( 0, 1 ) );
|
||||
}
|
||||
$term = wp_insert_term( $name, 'sp_position' );
|
||||
if ( is_wp_error( $term ) ) continue;
|
||||
if ( is_wp_error( $term ) ) {
|
||||
continue;
|
||||
}
|
||||
$t_id = $term['term_id'];
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$term_meta['sp_sections'] = $sections;
|
||||
@@ -124,7 +132,9 @@ class SP_Admin_Sports {
|
||||
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 ) );
|
||||
@@ -137,9 +147,13 @@ class SP_Admin_Sports {
|
||||
$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 ) );
|
||||
}
|
||||
|
||||
@@ -152,7 +166,9 @@ class SP_Admin_Sports {
|
||||
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 );
|
||||
@@ -174,7 +190,9 @@ class SP_Admin_Sports {
|
||||
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 ) );
|
||||
@@ -188,7 +206,9 @@ class SP_Admin_Sports {
|
||||
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 ++;
|
||||
}
|
||||
@@ -199,7 +219,9 @@ class SP_Admin_Sports {
|
||||
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 ++;
|
||||
}
|
||||
@@ -210,14 +232,15 @@ class SP_Admin_Sports {
|
||||
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 ) {
|
||||
@@ -236,9 +259,9 @@ class SP_Admin_Sports {
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_sp_preset',
|
||||
'value' => 1
|
||||
)
|
||||
)
|
||||
'value' => 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Delete posts
|
||||
@@ -254,13 +277,17 @@ class SP_Admin_Sports {
|
||||
$post_array['post_title'] = $post;
|
||||
$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'] ) );
|
||||
}
|
||||
|
||||
// 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;
|
||||
@@ -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(
|
||||
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() {
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -38,8 +40,9 @@ class SP_Admin_Status {
|
||||
$file_data = str_replace( "\r", "\n", $file_data );
|
||||
$version = '';
|
||||
|
||||
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] )
|
||||
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
|
||||
$version = _cleanup_header_comment( $match[1] );
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
@@ -56,7 +59,7 @@ class SP_Admin_Status {
|
||||
$result = array();
|
||||
if ( $files ) {
|
||||
foreach ( $files as $key => $value ) {
|
||||
if ( ! in_array( $value, array( ".",".." ) ) ) {
|
||||
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 ) {
|
||||
|
||||
@@ -184,9 +184,22 @@ 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
|
||||
$options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
||||
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 ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true ), $value );
|
||||
endforeach;
|
||||
@@ -210,9 +223,22 @@ class SP_Admin_Taxonomies {
|
||||
<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
|
||||
$options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
||||
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 ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( in_array( $key, $sections ), true, false ), $value );
|
||||
endforeach;
|
||||
@@ -264,7 +290,9 @@ 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 ( function_exists( 'get_term_meta' ) ) {
|
||||
$new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'posts', $columns ) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
@@ -308,7 +336,9 @@ class SP_Admin_Taxonomies {
|
||||
$new_columns = array();
|
||||
$new_columns['sp_sections'] = __( 'Statistics', 'sportspress' );
|
||||
|
||||
if ( function_exists( 'get_term_meta' ) ) $new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
if ( function_exists( 'get_term_meta' ) ) {
|
||||
$new_columns['sp_order'] = __( 'Order', 'sportspress' );
|
||||
}
|
||||
|
||||
if ( array_key_exists( 'posts', $columns ) ) {
|
||||
$new_columns['posts'] = $columns['posts'];
|
||||
@@ -342,7 +372,16 @@ class SP_Admin_Taxonomies {
|
||||
|
||||
} 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 );
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Admin_Welcome class.
|
||||
@@ -96,8 +98,9 @@ class SP_Admin_Welcome {
|
||||
private function intro() {
|
||||
|
||||
// Flush after upgrades
|
||||
if ( ! empty( $_GET['sp-updated'] ) || ! empty( $_GET['sp-installed'] ) )
|
||||
if ( ! empty( $_GET['sp-updated'] ) || ! empty( $_GET['sp-installed'] ) ) {
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
|
||||
// Get major version number
|
||||
$version = explode( '.', SP()->version, 3 );
|
||||
@@ -110,28 +113,50 @@ class SP_Admin_Welcome {
|
||||
|
||||
<div class="about-text sp-about-text">
|
||||
<?php
|
||||
if ( ! empty( $_GET['sp-installed'] ) )
|
||||
if ( ! empty( $_GET['sp-installed'] ) ) {
|
||||
$message = __( 'Thanks, all done!', 'sportspress' );
|
||||
elseif ( ! empty( $_GET['sp-updated'] ) )
|
||||
} elseif ( ! empty( $_GET['sp-updated'] ) ) {
|
||||
$message = __( 'Thank you for updating to the latest version!', 'sportspress' );
|
||||
else
|
||||
} else {
|
||||
$message = __( 'Thanks for installing!', 'sportspress' );
|
||||
}
|
||||
|
||||
printf( __( '%s SportsPress %s has lots of refinements we think you’ll love.', 'sportspress' ), $message, $display_version );
|
||||
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 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' ) ) ); ?>">
|
||||
<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' ) ) ); ?>">
|
||||
</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>
|
||||
@@ -142,7 +167,7 @@ class SP_Admin_Welcome {
|
||||
* Output the about screen.
|
||||
*/
|
||||
public function about_screen() {
|
||||
include_once( 'class-sp-admin-settings.php' );
|
||||
include_once 'class-sp-admin-settings.php';
|
||||
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
|
||||
?>
|
||||
<div class="wrap about-wrap about-sportspress-wrap">
|
||||
@@ -277,8 +302,21 @@ class SP_Admin_Welcome {
|
||||
</div>
|
||||
|
||||
<?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>
|
||||
<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
|
||||
}
|
||||
@@ -331,7 +369,8 @@ class SP_Admin_Welcome {
|
||||
|
||||
foreach ( $contributors as $contributor ) {
|
||||
$contributor_list .= '<li class="wp-person">';
|
||||
$contributor_list .= sprintf( '<a href="%s" title="%s">',
|
||||
$contributor_list .= sprintf(
|
||||
'<a href="%s" title="%s">',
|
||||
esc_url( 'https://github.com/' . $contributor->login ),
|
||||
esc_html( sprintf( __( 'View %s', 'sportspress' ), $contributor->login ) )
|
||||
);
|
||||
@@ -383,22 +422,26 @@ class SP_Admin_Welcome {
|
||||
public function welcome() {
|
||||
|
||||
// Bail if no activation redirect transient is set
|
||||
if ( ! get_transient( '_sp_activation_redirect' ) )
|
||||
if ( ! get_transient( '_sp_activation_redirect' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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 )
|
||||
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' ) )
|
||||
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' ) ) )
|
||||
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' ) );
|
||||
|
||||
@@ -36,23 +36,23 @@ 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' );
|
||||
include 'class-sp-admin-editor.php';
|
||||
endif;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class SP_Admin {
|
||||
if ( ! empty( $_GET['page'] ) ) {
|
||||
switch ( $_GET['page'] ) {
|
||||
case 'sp-setup':
|
||||
include_once( 'class-sp-admin-setup-wizard.php' );
|
||||
include_once 'class-sp-admin-setup-wizard.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ class SP_Admin {
|
||||
|
||||
switch ( $screen->id ) {
|
||||
case 'dashboard':
|
||||
include( 'class-sp-admin-dashboard.php' );
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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 {
|
||||
@@ -32,9 +34,10 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
'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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* import function.
|
||||
@@ -68,7 +71,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
@@ -147,7 +152,12 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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 );
|
||||
@@ -195,7 +205,12 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Make sure team is published
|
||||
if ( $team_object->post_status != 'publish' ) :
|
||||
wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $team_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
|
||||
// Get team ID
|
||||
@@ -204,7 +219,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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 );
|
||||
@@ -263,7 +284,12 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Make sure outcome is published
|
||||
if ( $outcome_object->post_status != 'publish' ) :
|
||||
wp_update_post( array( 'ID' => $outcome_object->ID, 'post_status' => 'publish' ) );
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $outcome_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
|
||||
// Get outcome slug
|
||||
@@ -272,7 +298,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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 );
|
||||
@@ -342,7 +374,12 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Make sure player is published
|
||||
if ( $player_object->post_status != 'publish' ) :
|
||||
wp_update_post( array( 'ID' => $player_object->ID, 'post_status' => 'publish' ) );
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $player_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
|
||||
// Get player ID
|
||||
@@ -354,7 +391,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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 );
|
||||
@@ -427,7 +470,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();
|
||||
@@ -473,7 +516,7 @@ 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
|
||||
@@ -485,7 +528,8 @@ 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',
|
||||
@@ -496,11 +540,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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',
|
||||
@@ -511,7 +557,8 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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">
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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 {
|
||||
@@ -26,9 +28,10 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
'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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* import function.
|
||||
@@ -62,7 +65,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$player_name = sp_array_value( $row, $name_index );
|
||||
|
||||
@@ -81,7 +86,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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 );
|
||||
@@ -92,7 +103,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$player = array();
|
||||
|
||||
foreach ( $columns as $i => $key ) :
|
||||
if ( 'sp_player' === $key ) continue;
|
||||
if ( 'sp_player' === $key ) {
|
||||
continue;
|
||||
}
|
||||
$player[ $key ] = sp_array_value( $row, $i, '' );
|
||||
endforeach;
|
||||
|
||||
@@ -122,7 +135,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// 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,7 +170,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
echo '<div class="narrow">';
|
||||
|
||||
if ( $event ) {
|
||||
$args = array_merge( $_REQUEST, array( 'import' => 'sp_event_performance_csv', 'step' => '1' ) );
|
||||
$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' ) );
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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 {
|
||||
@@ -61,7 +63,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
@@ -114,7 +118,12 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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 );
|
||||
@@ -170,7 +179,12 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
// Make sure team is published
|
||||
if ( $team_object->post_status != 'publish' ) :
|
||||
wp_update_post( array( 'ID' => $team_object->ID, 'post_status' => 'publish' ) );
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $team_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
|
||||
// Get team ID
|
||||
@@ -179,7 +193,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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 );
|
||||
@@ -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();
|
||||
@@ -293,7 +313,8 @@ 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',
|
||||
@@ -304,11 +325,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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',
|
||||
@@ -319,7 +342,8 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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">
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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 {
|
||||
@@ -46,11 +48,13 @@ 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 ) :
|
||||
@@ -61,15 +65,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
check_admin_referer( 'import-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 );
|
||||
@ob_flush();
|
||||
@@ -126,7 +132,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
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 );
|
||||
|
||||
@@ -149,19 +155,33 @@ 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 ) : ?>
|
||||
<td>
|
||||
@@ -175,7 +195,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
</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 ); ?>" />
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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 {
|
||||
@@ -50,7 +52,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
@@ -65,7 +69,11 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
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();
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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 {
|
||||
@@ -60,7 +62,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
$row = array_filter( $row, 'strlen' );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
@@ -112,7 +116,12 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$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' ) );
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $player_object->ID,
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
$id = $player_object->ID;
|
||||
// Handle preservable data.
|
||||
@@ -121,7 +130,11 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$meta[ $p ] .= '|' . implode( '|', $terms );
|
||||
}
|
||||
else :
|
||||
$args = array( 'post_type' => 'sp_player', 'post_status' => 'publish', 'post_title' => wp_strip_all_tags( $name ) );
|
||||
$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;
|
||||
@@ -155,11 +168,22 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$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' ) );
|
||||
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 ) ) );
|
||||
$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 );
|
||||
@@ -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();
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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 {
|
||||
@@ -55,7 +57,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
@@ -74,11 +78,20 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$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' ) );
|
||||
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 ) );
|
||||
$args = array(
|
||||
'post_type' => 'sp_staff',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $name ),
|
||||
);
|
||||
$id = wp_insert_post( $args );
|
||||
|
||||
// Flag as import
|
||||
@@ -105,11 +118,22 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$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' ) );
|
||||
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 ) ) );
|
||||
$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 );
|
||||
@@ -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();
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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 {
|
||||
@@ -55,7 +57,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
|
||||
$row = array_filter( $row );
|
||||
|
||||
if ( empty( $row ) ) continue;
|
||||
if ( empty( $row ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
@@ -74,11 +78,20 @@ if ( class_exists( 'WP_Importer' ) ) {
|
||||
$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' ) );
|
||||
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 ) );
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => wp_strip_all_tags( $name ),
|
||||
);
|
||||
$id = wp_insert_post( $args );
|
||||
|
||||
// Flag as import
|
||||
@@ -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();
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -43,7 +46,8 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
@@ -52,12 +56,15 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
'sp_events' => __( 'Events', 'sportspress' ),
|
||||
'sp_layout' => __( 'Layout', 'sportspress' ),
|
||||
), $existing_columns );
|
||||
),
|
||||
$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 ) {
|
||||
@@ -79,7 +86,9 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
else :
|
||||
$current_team = get_post_meta( $post_id, 'sp_current_team', true );
|
||||
foreach ( $teams as $team_id ) :
|
||||
if ( ! $team_id ) continue;
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ) :
|
||||
echo esc_html( $team->post_title );
|
||||
@@ -107,15 +116,16 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_calendar' )
|
||||
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
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
@@ -124,7 +134,7 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -52,6 +55,7 @@ class SP_Admin_CPT_Column extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -54,13 +57,15 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* 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' )
|
||||
if ( $post->post_type == 'sp_event' ) {
|
||||
return __( '(Auto)', 'sportspress' );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
@@ -76,7 +81,9 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
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;
|
||||
if ( sizeof( $teams ) ) {
|
||||
return false;
|
||||
}
|
||||
endif;
|
||||
|
||||
return $maybe_empty;
|
||||
@@ -100,7 +107,9 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
while ( is_array( $team ) ) {
|
||||
$team = array_shift( array_filter( $team ) );
|
||||
}
|
||||
if ( $team > 0 ) $team_names[] = sp_team_short_name( $team );
|
||||
if ( $team > 0 ) {
|
||||
$team_names[] = sp_team_short_name( $team );
|
||||
}
|
||||
endforeach;
|
||||
|
||||
$team_names = array_unique( $team_names );
|
||||
@@ -122,7 +131,8 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['comments'] );
|
||||
$columns = array_merge( array(
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_format' => '<span class="dashicons sp-icon-calendar sp-tip" title="' . __( 'Format', 'sportspress' ) . '"></span>',
|
||||
'title' => null,
|
||||
@@ -133,9 +143,12 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_day' => __( 'Match Day', 'sportspress' ),
|
||||
), $existing_columns, array(
|
||||
),
|
||||
$existing_columns,
|
||||
array(
|
||||
'title' => __( 'Event', 'sportspress' ),
|
||||
) );
|
||||
)
|
||||
);
|
||||
return apply_filters( 'sportspress_event_admin_columns', $columns );
|
||||
}
|
||||
|
||||
@@ -151,7 +164,9 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
* Define the sortable columns in admin.
|
||||
*/
|
||||
public function orderby_columns( $query ) {
|
||||
if ( ! is_admin() ) return;
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$orderby = $query->get( 'orderby' );
|
||||
|
||||
@@ -163,6 +178,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
@@ -194,7 +210,9 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
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;
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
|
||||
if ( $team ) :
|
||||
@@ -247,7 +265,9 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
break;
|
||||
case 'sp_day':
|
||||
$day = get_post_meta( $post_id, 'sp_day', true );
|
||||
if ( '' === $day ) $day = __( 'Default', 'sportspress' );
|
||||
if ( '' === $day ) {
|
||||
$day = __( 'Default', 'sportspress' );
|
||||
}
|
||||
echo esc_html( $day );
|
||||
break;
|
||||
endswitch;
|
||||
@@ -259,8 +279,9 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_event' )
|
||||
if ( $typenow != 'sp_event' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
@@ -277,7 +298,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
@@ -286,16 +307,17 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
'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' ) )
|
||||
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
|
||||
@@ -307,8 +329,9 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
|
||||
if ( $typenow == 'sp_event' ) {
|
||||
// Avoid overriding relation operator if already set
|
||||
if ( !isset( $query->query_vars['meta_query']['relation'] ) )
|
||||
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(
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -43,7 +46,8 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
@@ -51,12 +55,15 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
'sp_player' => __( 'Players', 'sportspress' ),
|
||||
'sp_layout' => __( 'Layout', 'sportspress' ),
|
||||
), $existing_columns );
|
||||
),
|
||||
$existing_columns
|
||||
);
|
||||
return apply_filters( 'sportspress_list_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
@@ -83,9 +90,13 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
echo __( 'All', 'sportspress' );
|
||||
else :
|
||||
foreach ( $teams as $team_id ) :
|
||||
if ( ! $team_id ) continue;
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ) echo esc_html( $team->post_title ) . '<br>';
|
||||
if ( $team ) {
|
||||
echo esc_html( $team->post_title ) . '<br>';
|
||||
}
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
@@ -101,15 +112,16 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_list' )
|
||||
if ( $typenow != 'sp_list' ) {
|
||||
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
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
@@ -118,7 +130,7 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -49,6 +52,7 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -35,13 +38,15 @@ class SP_Admin_CPT_Official extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* 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' )
|
||||
if ( $post->post_type == 'sp_official' ) {
|
||||
return __( 'Name', 'sportspress' );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -50,6 +53,7 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -52,6 +55,7 @@ class SP_Admin_CPT_Performance extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -52,13 +55,15 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* 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' )
|
||||
if ( $post->post_type == 'sp_player' ) {
|
||||
return __( 'Name', 'sportspress' );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
@@ -68,7 +73,8 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
$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,
|
||||
@@ -76,14 +82,18 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
), $existing_columns, array(
|
||||
'title' => __( 'Name', '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 ) {
|
||||
@@ -107,7 +117,9 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
echo '—';
|
||||
else :
|
||||
foreach ( $teams as $team_id ) :
|
||||
if ( ! $team_id ) continue;
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ) :
|
||||
echo esc_html( $team->post_title );
|
||||
@@ -137,8 +149,9 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_player' )
|
||||
if ( $typenow != 'sp_player' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( taxonomy_exists( 'sp_position' ) ) :
|
||||
$selected = isset( $_REQUEST['sp_position'] ) ? sanitize_key( $_REQUEST['sp_position'] ) : null;
|
||||
@@ -146,7 +159,7 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all positions', 'sportspress' ),
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'sp_position',
|
||||
'selected' => $selected
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
@@ -167,7 +180,7 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
@@ -178,7 +191,7 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
@@ -191,7 +204,9 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
*/
|
||||
public function filters_query( $query ) {
|
||||
|
||||
if ( empty ( $query->query_vars['post_type'] ) || $query->query_vars['post_type'] !== 'sp_player' ) return $query;
|
||||
if ( empty( $query->query_vars['post_type'] ) || $query->query_vars['post_type'] !== 'sp_player' ) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
global $typenow, $wp_query;
|
||||
|
||||
@@ -213,8 +228,12 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
* @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;
|
||||
if ( $this->type !== $post_type ) {
|
||||
return;
|
||||
}
|
||||
if ( 'sp_number' !== $column_name ) {
|
||||
return;
|
||||
}
|
||||
|
||||
static $print_nonce = true;
|
||||
if ( $print_nonce ) {
|
||||
@@ -240,16 +259,24 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
* @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;
|
||||
if ( $this->type !== $post_type ) {
|
||||
return;
|
||||
}
|
||||
if ( 'sp_team' !== $column_name ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$teams = get_posts( array(
|
||||
$teams = get_posts(
|
||||
array(
|
||||
'post_type' => 'sp_team',
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
) );
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! $teams ) return;
|
||||
if ( ! $teams ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<fieldset class="inline-edit-col-right">
|
||||
<div class="inline-edit-col">
|
||||
@@ -278,14 +305,24 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
* @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;;
|
||||
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 ( ! 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 ( 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'] );
|
||||
@@ -303,8 +340,12 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
* @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;
|
||||
if ( $this->type !== $post_type ) {
|
||||
return;
|
||||
}
|
||||
if ( 'sp_team' !== $column_name ) {
|
||||
return;
|
||||
}
|
||||
|
||||
static $print_nonce = true;
|
||||
if ( $print_nonce ) {
|
||||
@@ -312,13 +353,17 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
|
||||
}
|
||||
|
||||
$teams = get_posts( array(
|
||||
$teams = get_posts(
|
||||
array(
|
||||
'post_type' => 'sp_team',
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
) );
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! $teams ) return;
|
||||
if ( ! $teams ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<fieldset class="inline-edit-col-right">
|
||||
<div class="inline-edit-col">
|
||||
@@ -345,8 +390,10 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
* Save bulk edit boxes
|
||||
*/
|
||||
public function bulk_save() {
|
||||
$_POST += array( "nonce" => '' );
|
||||
if ( ! wp_verify_nonce( $_POST["nonce"], plugin_basename( __FILE__ ) ) ) return;
|
||||
$_POST += array( 'nonce' => '' );
|
||||
if ( ! wp_verify_nonce( $_POST['nonce'], plugin_basename( __FILE__ ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_ids = ( ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
|
||||
|
||||
@@ -356,7 +403,9 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
|
||||
if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) continue;
|
||||
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 );
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -49,6 +52,7 @@ class SP_Admin_CPT_Result extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -49,6 +52,7 @@ class SP_Admin_CPT_Spec extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -43,13 +46,15 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* 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' )
|
||||
if ( $post->post_type == 'sp_staff' ) {
|
||||
return __( 'Name', 'sportspress' );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
@@ -59,21 +64,26 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
$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' )
|
||||
) );
|
||||
),
|
||||
$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 ) {
|
||||
@@ -89,7 +99,9 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
else :
|
||||
$current_teams = get_post_meta( $post_id, 'sp_current_team', false );
|
||||
foreach ( $teams as $team_id ) :
|
||||
if ( ! $team_id ) continue;
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
$team = get_post( $team_id );
|
||||
if ( $team ) :
|
||||
echo esc_html( $team->post_title );
|
||||
@@ -116,8 +128,9 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_staff' )
|
||||
if ( $typenow != 'sp_staff' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||
$args = array(
|
||||
@@ -134,7 +147,7 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
@@ -143,7 +156,7 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
}
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -52,6 +55,7 @@ class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -43,18 +46,22 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
$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 );
|
||||
),
|
||||
$existing_columns
|
||||
);
|
||||
return apply_filters( 'sportspress_table_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
*
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
@@ -83,15 +90,16 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_table' )
|
||||
if ( $typenow != 'sp_table' ) {
|
||||
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
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
@@ -100,7 +108,7 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -42,13 +45,15 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* 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' )
|
||||
if ( $post->post_type == 'sp_team' ) {
|
||||
return __( 'Name', 'sportspress' );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
@@ -58,7 +63,8 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
*/
|
||||
public function edit_columns( $existing_columns ) {
|
||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||
$columns = array_merge( array(
|
||||
$columns = array_merge(
|
||||
array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_icon' => '<span class="dashicons sp-icon-shield sp-tip" title="' . __( 'Logo', 'sportspress' ) . '"></span>',
|
||||
'title' => null,
|
||||
@@ -66,14 +72,18 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
), $existing_columns, array(
|
||||
),
|
||||
$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 ) {
|
||||
@@ -104,15 +114,16 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
public function filters() {
|
||||
global $typenow, $wp_query;
|
||||
|
||||
if ( $typenow != 'sp_team' )
|
||||
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
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
@@ -121,7 +132,7 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
'selected' => $selected,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ) ) :
|
||||
|
||||
@@ -29,6 +31,7 @@ class SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Change label for insert buttons.
|
||||
*
|
||||
* @access public
|
||||
* @param array $strings
|
||||
* @return array
|
||||
@@ -48,6 +51,7 @@ class SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding an event
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
* @version 2.6.8
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Admin_Meta_Boxes
|
||||
@@ -315,13 +317,27 @@ class SP_Admin_Meta_Boxes {
|
||||
* @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 );
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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
|
||||
@@ -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 {
|
||||
@@ -137,14 +143,28 @@ class SP_Meta_Box_Calendar_Data {
|
||||
$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 ( $teams ): foreach ( $teams as $team ):
|
||||
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 );
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
* @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
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ); ?>
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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
|
||||
@@ -29,7 +32,9 @@ class SP_Meta_Box_Column_Details extends SP_Meta_Box_Config {
|
||||
$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>
|
||||
@@ -56,7 +61,10 @@ class SP_Meta_Box_Column_Details extends SP_Meta_Box_Config {
|
||||
</select>
|
||||
<select name="sp_order">
|
||||
<?php
|
||||
$options = array( 'DESC' => __( 'Descending', 'sportspress' ), 'ASC' => __( 'Ascending', 'sportspress' ) );
|
||||
$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;
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Config
|
||||
@@ -26,7 +28,9 @@ class SP_Meta_Box_Config {
|
||||
global $wpdb;
|
||||
|
||||
$key = isset( $post['sp_key'] ) ? $post['sp_key'] : null;
|
||||
if ( ! $key ) $key = $post['post_title'];
|
||||
if ( ! $key ) {
|
||||
$key = $post['post_title'];
|
||||
}
|
||||
$id = sp_array_value( $post, 'post_ID', 'var' );
|
||||
$title = sp_get_eos_safe_slug( $key, $id );
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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,7 +25,9 @@ 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
|
||||
|
||||
@@ -31,22 +35,54 @@ class SP_Meta_Box_Equation {
|
||||
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' );
|
||||
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' );
|
||||
@@ -58,7 +94,14 @@ class SP_Meta_Box_Equation {
|
||||
endforeach;
|
||||
|
||||
// Add operators to options
|
||||
$options[ 'Operators' ] = array( '+' => '+', '-' => '−', '*' => '×', '/' => '÷', '(' => '(', ')' => ')' );
|
||||
$options['Operators'] = array(
|
||||
'+' => '+',
|
||||
'-' => '−',
|
||||
'*' => '×',
|
||||
'/' => '÷',
|
||||
'(' => '(',
|
||||
')' => ')',
|
||||
);
|
||||
|
||||
// Create array of constants
|
||||
$max = 10;
|
||||
@@ -79,20 +122,33 @@ class SP_Meta_Box_Equation {
|
||||
<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; ?>>
|
||||
<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 );
|
||||
@@ -101,10 +157,14 @@ class SP_Meta_Box_Equation {
|
||||
$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
|
||||
}
|
||||
?>
|
||||
<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
|
||||
@@ -146,7 +206,9 @@ class SP_Meta_Box_Equation {
|
||||
// Add vars to the array
|
||||
if ( isset( $variations ) && is_array( $variations ) ) :
|
||||
foreach ( $vars as $var ) :
|
||||
if ( $totals ) $arr[ '$' . $var->post_name ] = $var->post_title;
|
||||
if ( $totals ) {
|
||||
$arr[ '$' . $var->post_name ] = $var->post_title;
|
||||
}
|
||||
foreach ( $variations as $key => $value ) :
|
||||
$arr[ '$' . $var->post_name . $key ] = $var->post_title . ' ' . $value;
|
||||
endforeach;
|
||||
@@ -162,6 +224,7 @@ class SP_Meta_Box_Equation {
|
||||
|
||||
/**
|
||||
* Equation part labels for localization
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function equation_part_labels() {
|
||||
|
||||
@@ -8,7 +8,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_Details
|
||||
@@ -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' ) );
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -8,7 +8,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_Format
|
||||
|
||||
@@ -8,7 +8,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
|
||||
@@ -22,7 +24,12 @@ class SP_Meta_Box_Event_Mode {
|
||||
$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 ): ?>
|
||||
<?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>
|
||||
|
||||
@@ -9,7 +9,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
|
||||
@@ -20,7 +22,8 @@ class SP_Meta_Box_Event_Officials {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$duties = get_terms( array(
|
||||
$duties = get_terms(
|
||||
array(
|
||||
'taxonomy' => 'sp_duty',
|
||||
'hide_empty' => false,
|
||||
'orderby' => 'meta_value_num',
|
||||
@@ -28,14 +31,15 @@ class SP_Meta_Box_Event_Officials {
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'NOT EXISTS'
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'EXISTS'
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
),
|
||||
) );
|
||||
)
|
||||
);
|
||||
|
||||
$officials = (array) get_post_meta( $post->ID, 'sp_officials', true );
|
||||
|
||||
@@ -43,7 +47,8 @@ class SP_Meta_Box_Event_Officials {
|
||||
foreach ( $duties as $duty ) {
|
||||
?>
|
||||
<p><strong><?php echo esc_html( $duty->name ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_official',
|
||||
'name' => 'sp_officials[' . $duty->term_id . '][]',
|
||||
@@ -58,7 +63,8 @@ class SP_Meta_Box_Event_Officials {
|
||||
if ( ! sp_dropdown_pages( $args ) ) {
|
||||
sp_post_adder( 'sp_official', __( 'Add New', 'sportspress' ) );
|
||||
}
|
||||
?></p>
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,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_Performance
|
||||
@@ -22,22 +24,25 @@ 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;
|
||||
@@ -96,7 +101,9 @@ class SP_Meta_Box_Event_Performance {
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ( $teams as $key => $team_id ) :
|
||||
if ( -1 == $team_id ) continue;
|
||||
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 );
|
||||
@@ -131,7 +138,9 @@ class SP_Meta_Box_Event_Performance {
|
||||
$i = 0;
|
||||
|
||||
foreach ( $teams as $key => $team_id ) :
|
||||
if ( -1 == $team_id ) continue;
|
||||
if ( -1 == $team_id ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( -1 == $sections ) {
|
||||
// Get results for players in the team
|
||||
@@ -149,7 +158,24 @@ class SP_Meta_Box_Event_Performance {
|
||||
<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 ); ?>
|
||||
@@ -224,7 +250,10 @@ class SP_Meta_Box_Event_Performance {
|
||||
|
||||
// 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' ) );
|
||||
}
|
||||
@@ -234,7 +263,22 @@ class SP_Meta_Box_Event_Performance {
|
||||
<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 ); ?>
|
||||
@@ -316,7 +360,10 @@ class SP_Meta_Box_Event_Performance {
|
||||
</th>
|
||||
<?php } ?>
|
||||
<?php $i = 0; foreach ( $labels as $key => $label ) : ?>
|
||||
<?php if ( 'equation' === sp_array_value( $formats, $key, 'number' ) ) continue; ?>
|
||||
<?php
|
||||
if ( 'equation' === sp_array_value( $formats, $key, 'number' ) ) {
|
||||
continue;}
|
||||
?>
|
||||
<th>
|
||||
<?php if ( $has_checkboxes ) : ?>
|
||||
<?php if ( 0 == $i ) : ?>
|
||||
@@ -330,7 +377,10 @@ class SP_Meta_Box_Event_Performance {
|
||||
<?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,8 +413,11 @@ 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;
|
||||
<?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, '' );
|
||||
@@ -389,7 +442,9 @@ 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', '' );
|
||||
@@ -425,11 +480,11 @@ class SP_Meta_Box_Event_Performance {
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'NOT EXISTS'
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'EXISTS'
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
),
|
||||
'selected' => $selected,
|
||||
@@ -442,8 +497,11 @@ class SP_Meta_Box_Event_Performance {
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php foreach( $labels as $column => $label ):
|
||||
if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) continue;
|
||||
<?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' ) );
|
||||
@@ -456,8 +514,9 @@ class SP_Meta_Box_Event_Performance {
|
||||
$timeval = gmdate( 'i:s', $intval );
|
||||
$hours = floor( $intval / 3600 );
|
||||
|
||||
if ( '00' != $hours )
|
||||
if ( '00' != $hours ) {
|
||||
$timeval = $hours . ':' . $timeval;
|
||||
}
|
||||
|
||||
$timeval = preg_replace( '/^0/', '', $timeval );
|
||||
?>
|
||||
@@ -483,7 +542,10 @@ class SP_Meta_Box_Event_Performance {
|
||||
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,13 +593,17 @@ 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(
|
||||
$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]">';
|
||||
|
||||
@@ -556,8 +622,9 @@ 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;">';
|
||||
|
||||
@@ -565,7 +632,9 @@ class SP_Meta_Box_Event_Performance {
|
||||
|
||||
// Add players as selectable options
|
||||
foreach ( $data as $id => $performance ) :
|
||||
if ( ! $id || $id == $player_id ) continue;
|
||||
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;
|
||||
|
||||
@@ -8,7 +8,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_Results
|
||||
@@ -20,10 +22,11 @@ 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 );
|
||||
list( $columns, $usecolumns, $data ) = $event->results( true );
|
||||
@@ -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;
|
||||
@@ -96,10 +109,11 @@ 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();
|
||||
@@ -147,7 +161,9 @@ class SP_Meta_Box_Event_Results {
|
||||
);
|
||||
$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();
|
||||
foreach ( $outcomes as $outcome ) {
|
||||
@@ -175,7 +191,9 @@ class SP_Meta_Box_Event_Results {
|
||||
'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(
|
||||
@@ -186,7 +204,9 @@ class SP_Meta_Box_Event_Results {
|
||||
'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 );
|
||||
@@ -228,7 +248,7 @@ class SP_Meta_Box_Event_Results {
|
||||
array(
|
||||
'key' => 'sp_equation',
|
||||
'compare' => 'NOT IN',
|
||||
'value' => null
|
||||
'value' => null,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -263,22 +283,35 @@ class SP_Meta_Box_Event_Results {
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ( $data as $team_id => $team_results ) :
|
||||
if ( ! $team_id || -1 == $team_id ) continue;
|
||||
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',
|
||||
|
||||
@@ -8,7 +8,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_Shortcode
|
||||
@@ -19,7 +21,9 @@ class SP_Meta_Box_Event_Shortcode {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$shortcodes = apply_filters( 'sportspress_event_shortcodes', array(
|
||||
$shortcodes = apply_filters(
|
||||
'sportspress_event_shortcodes',
|
||||
array(
|
||||
'event_results' => __( 'Results', 'sportspress' ),
|
||||
'event_details' => __( 'Details', 'sportspress' ),
|
||||
'event_performance' => __( 'Box Score', 'sportspress' ),
|
||||
@@ -27,7 +31,8 @@ class SP_Meta_Box_Event_Shortcode {
|
||||
'event_officials' => __( 'Officials', 'sportspress' ),
|
||||
'event_teams' => __( 'Teams', 'sportspress' ),
|
||||
'event_full' => __( 'Full Info', 'sportspress' ),
|
||||
) );
|
||||
)
|
||||
);
|
||||
if ( $shortcodes ) {
|
||||
?>
|
||||
<p class="howto">
|
||||
|
||||
@@ -8,7 +8,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_Specs
|
||||
|
||||
@@ -8,7 +8,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_Teams
|
||||
@@ -101,7 +103,11 @@ class SP_Meta_Box_Event_Teams {
|
||||
$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>
|
||||
<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++;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,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_Video
|
||||
@@ -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
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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
|
||||
@@ -34,6 +36,7 @@ class SP_Meta_Box_List_Columns {
|
||||
_e( 'Rank', 'sportspress' );
|
||||
}
|
||||
?>
|
||||
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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
|
||||
@@ -63,7 +65,10 @@ class SP_Meta_Box_List_Data {
|
||||
<th><?php _e( 'Position', 'sportspress' ); ?></th>
|
||||
<?php } ?>
|
||||
<?php foreach ( $columns as $key => $label ) : ?>
|
||||
<?php if ( in_array( $key, array( 'number', 'team', 'position' ) ) ) continue; ?>
|
||||
<?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>
|
||||
@@ -75,16 +80,24 @@ class SP_Meta_Box_List_Data {
|
||||
if ( is_array( $data ) && sizeof( $data ) > 0 ) :
|
||||
$i = 0;
|
||||
foreach ( $data as $player_id => $player_stats ) :
|
||||
if ( !$player_id ) continue;
|
||||
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,7 +128,9 @@ 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(
|
||||
'post_type' => 'sp_team',
|
||||
@@ -139,11 +157,11 @@ class SP_Meta_Box_List_Data {
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'NOT EXISTS'
|
||||
'compare' => 'NOT EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_order',
|
||||
'compare' => 'EXISTS'
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
),
|
||||
'selected' => $selected,
|
||||
@@ -153,8 +171,11 @@ class SP_Meta_Box_List_Data {
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?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( $player_stats, $column, '' );
|
||||
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
|
||||
?>
|
||||
@@ -167,7 +188,12 @@ class SP_Meta_Box_List_Data {
|
||||
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>
|
||||
@@ -183,7 +209,11 @@ 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>
|
||||
@@ -193,17 +223,27 @@ class SP_Meta_Box_List_Data {
|
||||
if ( is_array( $data ) && sizeof( $data ) > 0 ) :
|
||||
$i = 0;
|
||||
foreach ( $data as $player_id => $player_stats ) :
|
||||
if ( !$player_id ) continue;
|
||||
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>
|
||||
@@ -215,7 +255,12 @@ class SP_Meta_Box_List_Data {
|
||||
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>
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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
|
||||
@@ -103,7 +105,11 @@ 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 ) : ?>
|
||||
<optgroup label="<?php echo esc_attr( $continent ); ?>">
|
||||
@@ -161,10 +167,10 @@ class SP_Meta_Box_List_Details {
|
||||
if ( 'manual' == $select ) {
|
||||
$player_filters = array( 'sp_league', 'sp_season' );
|
||||
if ( $team_id ) {
|
||||
if ( in_array( $era, [ 'all', 'past' ] ) ) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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' ); ?>
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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_Metric_Details
|
||||
@@ -24,7 +27,9 @@ class SP_Meta_Box_Metric_Details extends SP_Meta_Box_Config {
|
||||
public static function output( $post ) {
|
||||
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
||||
$visible = get_post_meta( $post->ID, 'sp_visible', true );
|
||||
if ( '' === $visible ) $visible = 1;
|
||||
if ( '' === $visible ) {
|
||||
$visible = 1;
|
||||
}
|
||||
?>
|
||||
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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_Outcome_Details
|
||||
@@ -36,12 +39,18 @@ class SP_Meta_Box_Outcome_Details extends SP_Meta_Box_Config {
|
||||
$result = get_page_by_path( $main_result, ARRAY_A, 'sp_result' );
|
||||
$label = sp_array_value( $result, 'post_title', __( 'Primary', 'sportspress' ) );
|
||||
|
||||
if ( '' === $color ) $color = '#888888';
|
||||
if ( '' === $color ) {
|
||||
$color = '#888888';
|
||||
}
|
||||
?>
|
||||
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<input name="sp_default_key" type="hidden" id="sp_default_key" value="<?php echo esc_attr( $post->post_name ); ?>">
|
||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo esc_attr( $post->post_name ); ?>"<?php if ( $readonly ) { ?> readonly="readonly"<?php } ?>>
|
||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo esc_attr( $post->post_name ); ?>"
|
||||
<?php
|
||||
if ( $readonly ) {
|
||||
?>
|
||||
readonly="readonly"<?php } ?>>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Abbreviation', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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_Performance_Details
|
||||
@@ -56,7 +59,11 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
||||
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<input name="sp_default_key" type="hidden" id="sp_default_key" value="<?php echo esc_attr( $post->post_name ); ?>">
|
||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo esc_attr( $post->post_name ); ?>"<?php if ( $readonly ) { ?> readonly="readonly"<?php } ?>>
|
||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo esc_attr( $post->post_name ); ?>"
|
||||
<?php
|
||||
if ( $readonly ) {
|
||||
?>
|
||||
readonly="readonly"<?php } ?>>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Singular', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
@@ -66,7 +73,17 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
||||
<p class="sp-section-selector">
|
||||
<select name="sp_section">
|
||||
<?php
|
||||
$options = apply_filters( 'sportspress_performance_sections', array( -1 => __( 'All', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
||||
$options = apply_filters(
|
||||
'sportspress_performance_sections',
|
||||
array(
|
||||
-1 => __( 'All', 'sportspress' ),
|
||||
0 => __( 'Offense', 'sportspress' ),
|
||||
1 => __(
|
||||
'Defense',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( $key == $section, true, false ), $value );
|
||||
endforeach;
|
||||
@@ -77,7 +94,19 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
||||
<p class="sp-format-selector">
|
||||
<select name="sp_format">
|
||||
<?php
|
||||
$options = apply_filters( 'sportspress_performance_formats', array( 'number' => __( 'Number', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ), 'text' => __( 'Text', 'sportspress' ), 'equation' => __( 'Equation', 'sportspress' ), 'checkbox' => __( 'Checkbox', 'sportspress' ) ) );
|
||||
$options = apply_filters(
|
||||
'sportspress_performance_formats',
|
||||
array(
|
||||
'number' => __( 'Number', 'sportspress' ),
|
||||
'time' => __( 'Time', 'sportspress' ),
|
||||
'text' => __( 'Text', 'sportspress' ),
|
||||
'equation' => __( 'Equation', 'sportspress' ),
|
||||
'checkbox' => __(
|
||||
'Checkbox',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( $key == $format, true, false ), $value );
|
||||
endforeach;
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @version 2.1.6
|
||||
*/
|
||||
|
||||
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_Performance_Equation
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Player_Columns
|
||||
@@ -25,8 +27,15 @@ class SP_Meta_Box_Player_Columns {
|
||||
<div class="sp-instance">
|
||||
<?php if ( $tabs ) { ?>
|
||||
<ul id="sp_column-tabs" class="sp-tab-bar category-tabs">
|
||||
<?php foreach ( $tabs as $index => $post_type ) { $object = get_post_type_object( $post_type ); ?>
|
||||
<li class="<?php if ( 0 == $index ) { ?>tabs<?php } ?>"><a href="#<?php echo esc_attr( $post_type ); ?>-all"><?php echo esc_html( $object->labels->menu_name ); ?></a></li>
|
||||
<?php
|
||||
foreach ( $tabs as $index => $post_type ) {
|
||||
$object = get_post_type_object( $post_type );
|
||||
?>
|
||||
<li class="
|
||||
<?php
|
||||
if ( 0 == $index ) {
|
||||
?>
|
||||
tabs<?php } ?>"><a href="#<?php echo esc_attr( $post_type ); ?>-all"><?php echo esc_html( $object->labels->menu_name ); ?></a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Player_Details
|
||||
@@ -71,7 +73,12 @@ class SP_Meta_Box_Player_Details {
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$teams = get_posts( array( 'post_type' => 'sp_team', 'posts_per_page' => -1 ) );
|
||||
$teams = get_posts(
|
||||
array(
|
||||
'post_type' => 'sp_team',
|
||||
'posts_per_page' => -1,
|
||||
)
|
||||
);
|
||||
$past_teams = array_filter( get_post_meta( $post->ID, 'sp_past_team', false ) );
|
||||
$current_teams = array_filter( get_post_meta( $post->ID, 'sp_current_team', false ) );
|
||||
?>
|
||||
@@ -80,7 +87,11 @@ class SP_Meta_Box_Player_Details {
|
||||
<p><input type="text" size="4" id="sp_number" name="sp_number" value="<?php echo esc_attr( $number ); ?>"></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">
|
||||
<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">
|
||||
<option value=""></option>
|
||||
<?php foreach ( $continents as $continent => $countries ) : ?>
|
||||
<optgroup label="<?php echo esc_attr( $continent ); ?>">
|
||||
@@ -93,7 +104,8 @@ class SP_Meta_Box_Player_Details {
|
||||
|
||||
<?php if ( taxonomy_exists( 'sp_position' ) ) { ?>
|
||||
<p><strong><?php _e( 'Positions', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'tax_input[sp_position][]',
|
||||
@@ -105,11 +117,13 @@ class SP_Meta_Box_Player_Details {
|
||||
'chosen' => true,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?></p>
|
||||
?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_current_team[]',
|
||||
@@ -121,10 +135,12 @@ class SP_Meta_Box_Player_Details {
|
||||
'chosen' => true,
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?></p>
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_past_team[]',
|
||||
@@ -136,11 +152,13 @@ class SP_Meta_Box_Player_Details {
|
||||
'chosen' => true,
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?></p>
|
||||
?>
|
||||
</p>
|
||||
|
||||
<?php if ( taxonomy_exists( 'sp_league' ) ) { ?>
|
||||
<p><strong><?php _e( 'Leagues', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'tax_input[sp_league][]',
|
||||
@@ -152,12 +170,14 @@ class SP_Meta_Box_Player_Details {
|
||||
'chosen' => true,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?></p>
|
||||
?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( taxonomy_exists( 'sp_season' ) ) { ?>
|
||||
<p><strong><?php _e( 'Seasons', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'tax_input[sp_season][]',
|
||||
@@ -169,7 +189,8 @@ class SP_Meta_Box_Player_Details {
|
||||
'chosen' => true,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?></p>
|
||||
?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Player_Metrics
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @version 1.6.1
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Player_Shortcode
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Player_Statistics
|
||||
@@ -51,7 +53,10 @@ class SP_Meta_Box_Player_Statistics {
|
||||
} else {
|
||||
// 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' ) );
|
||||
}
|
||||
@@ -95,7 +100,14 @@ class SP_Meta_Box_Player_Statistics {
|
||||
public static function table( $id = null, $league_id = null, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $leagues = array(), $has_checkboxes = false, $team_select = false, $formats = array(), $total_types = array() ) {
|
||||
$readonly = false;
|
||||
$teams = array_filter( get_post_meta( $id, 'sp_team', false ) );
|
||||
$buffer = apply_filters( 'sportspress_meta_box_player_statistics_table_buffer', array( 'teams' => $teams, 'readonly' => $readonly ), $id );
|
||||
$buffer = apply_filters(
|
||||
'sportspress_meta_box_player_statistics_table_buffer',
|
||||
array(
|
||||
'teams' => $teams,
|
||||
'readonly' => $readonly,
|
||||
),
|
||||
$id
|
||||
);
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table sp-player-statistics-table">
|
||||
@@ -107,7 +119,11 @@ class SP_Meta_Box_Player_Statistics {
|
||||
<?php _e( 'Team', 'sportspress' ); ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<?php foreach ( $columns as $key => $label ): if ( $key == 'team' ) continue; ?>
|
||||
<?php
|
||||
foreach ( $columns as $key => $label ) :
|
||||
if ( $key == 'team' ) {
|
||||
continue;}
|
||||
?>
|
||||
<th><?php echo esc_html( $label ); ?></th>
|
||||
<?php endforeach; ?>
|
||||
<?php do_action( 'sportspress_meta_box_player_statistics_table_header_row', $id, $league_id ); ?>
|
||||
@@ -122,9 +138,13 @@ class SP_Meta_Box_Player_Statistics {
|
||||
<?php if ( $team_select && apply_filters( 'sportspress_player_team_statistics', $league_id ) ) { ?>
|
||||
<td> </td>
|
||||
<?php } ?>
|
||||
<?php foreach ( $columns as $column => $label ): if ( $column == 'team' ) continue;
|
||||
<?php
|
||||
foreach ( $columns as $column => $label ) :
|
||||
if ( $column == 'team' ) {
|
||||
continue;}
|
||||
?>
|
||||
<td><?php
|
||||
<td>
|
||||
<?php
|
||||
$value = sp_array_value( sp_array_value( $data, 0, array() ), $column, null );
|
||||
$placeholder = sp_array_value( sp_array_value( $placeholders, 0, array() ), $column, 0 );
|
||||
|
||||
@@ -144,7 +164,8 @@ class SP_Meta_Box_Player_Statistics {
|
||||
echo '<input type="text" name="sp_statistics[' . $league_id . '][0][' . $column . ']" value="' . esc_attr( $value ) . '" placeholder="' . esc_attr( $placeholder ) . '"' . ( $readonly ? ' disabled="disabled"' : '' ) . ' data-sp-format="' . sp_array_value( $formats, $column, 'number' ) . '" data-sp-total-type="' . sp_array_value( $total_types, $column, 'total' ) . '" />';
|
||||
}
|
||||
}
|
||||
?></td>
|
||||
?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
<?php do_action( 'sportspress_meta_box_player_statistics_table_footer_row', $id, $league_id ); ?>
|
||||
</tr>
|
||||
@@ -153,11 +174,20 @@ class SP_Meta_Box_Player_Statistics {
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ( $data as $div_id => $div_stats ) :
|
||||
if ( $div_id === 'statistics' ) continue;
|
||||
if ( $div_id === 0 ) continue;
|
||||
if ( $div_id === 'statistics' ) {
|
||||
continue;
|
||||
}
|
||||
if ( $div_id === 0 ) {
|
||||
continue;
|
||||
}
|
||||
$div = get_term( $div_id, 'sp_season' );
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?> <?php echo implode( ' ', apply_filters( 'sportspress_meta_box_player_statistics_row_classes', array(), $league_id, $div_id ) ); ?>" data-league="<?php echo (int) $league_id; ?>" data-season="<?php echo (int) $div_id; ?>">
|
||||
<tr class="sp-row sp-post
|
||||
<?php
|
||||
if ( $i % 2 == 0 ) {
|
||||
echo ' alternate';}
|
||||
?>
|
||||
<?php echo implode( ' ', apply_filters( 'sportspress_meta_box_player_statistics_row_classes', array(), $league_id, $div_id ) ); ?>" data-league="<?php echo (int) $league_id; ?>" data-season="<?php echo (int) $div_id; ?>">
|
||||
<td>
|
||||
<label>
|
||||
<?php if ( ! apply_filters( 'sportspress_player_team_statistics', $league_id ) ) : ?>
|
||||
@@ -166,8 +196,11 @@ class SP_Meta_Box_Player_Statistics {
|
||||
<input type="checkbox" name="sp_leagues[<?php echo esc_attr( $league_id ); ?>][<?php echo esc_attr( $div_id ); ?>]" value="1" <?php checked( $value ); ?>>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if ( 0 === $div_id ) _e( 'Total', 'sportspress' );
|
||||
elseif ( 'WP_Error' != get_class( $div ) ) echo apply_filters( 'sportspress_meta_box_player_statistics_season_name', $div->name, $league_id, $div_id, $div_stats );
|
||||
if ( 0 === $div_id ) {
|
||||
_e( 'Total', 'sportspress' );
|
||||
} elseif ( 'WP_Error' != get_class( $div ) ) {
|
||||
echo apply_filters( 'sportspress_meta_box_player_statistics_season_name', $div->name, $league_id, $div_id, $div_stats );
|
||||
}
|
||||
?>
|
||||
</label>
|
||||
</td>
|
||||
@@ -209,12 +242,26 @@ class SP_Meta_Box_Player_Statistics {
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$collection = array( 'columns' => $columns, 'data' => $data, 'placeholders' => $placeholders, 'merged' => $merged, 'seasons_teams' => array(), 'has_checkboxes' => $has_checkboxes, 'formats' => $formats, 'total_types' => $total_types, 'buffer' => $buffer );
|
||||
$collection = array(
|
||||
'columns' => $columns,
|
||||
'data' => $data,
|
||||
'placeholders' => $placeholders,
|
||||
'merged' => $merged,
|
||||
'seasons_teams' => array(),
|
||||
'has_checkboxes' => $has_checkboxes,
|
||||
'formats' => $formats,
|
||||
'total_types' => $total_types,
|
||||
'buffer' => $buffer,
|
||||
);
|
||||
list( $columns, $data, $placeholders, $merged, $seasons_teams, $has_checkboxes, $formats, $total_types, $buffer ) = array_values( apply_filters( 'sportspress_meta_box_player_statistics_collection', $collection, $id, $league_id, $div_id, $value ) );
|
||||
?>
|
||||
<?php foreach ( $columns as $column => $label ): if ( $column == 'team' ) continue;
|
||||
<?php
|
||||
foreach ( $columns as $column => $label ) :
|
||||
if ( $column == 'team' ) {
|
||||
continue;}
|
||||
?>
|
||||
<td><?php
|
||||
<td>
|
||||
<?php
|
||||
$value = sp_array_value( sp_array_value( $data, $div_id, array() ), $column, null );
|
||||
$placeholder = sp_array_value( sp_array_value( $placeholders, $div_id, array() ), $column, 0 );
|
||||
|
||||
@@ -234,7 +281,8 @@ class SP_Meta_Box_Player_Statistics {
|
||||
echo '<input type="text" name="sp_statistics[' . $league_id . '][' . $div_id . '][' . $column . ']" value="' . esc_attr( $value ) . '" placeholder="' . esc_attr( $placeholder ) . '"' . ( $readonly ? ' disabled="disabled"' : '' ) . ' data-column="' . $column . '" />';
|
||||
}
|
||||
}
|
||||
?></td>
|
||||
?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
<?php do_action( 'sportspress_meta_box_player_statistics_table_row', $id, $league_id, $div_id, $team_select, $buffer, $i ); ?>
|
||||
</tr>
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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_Result_Details
|
||||
@@ -34,7 +37,11 @@ class SP_Meta_Box_Result_Details extends SP_Meta_Box_Config {
|
||||
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<input name="sp_default_key" type="hidden" id="sp_default_key" value="<?php echo esc_attr( $post->post_name ); ?>">
|
||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo esc_attr( $post->post_name ); ?>"<?php if ( $readonly ) { ?> readonly="readonly"<?php } ?>> <span class="description">(for, against)</span>
|
||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo esc_attr( $post->post_name ); ?>"
|
||||
<?php
|
||||
if ( $readonly ) {
|
||||
?>
|
||||
readonly="readonly"<?php } ?>> <span class="description">(for, against)</span>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Decimal Places', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-precision-selector">
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @version 1.9
|
||||
*/
|
||||
|
||||
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_Result_Equation
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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_Spec_Details
|
||||
@@ -24,7 +27,9 @@ class SP_Meta_Box_Spec_Details extends SP_Meta_Box_Config {
|
||||
public static function output( $post ) {
|
||||
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
||||
$visible = get_post_meta( $post->ID, 'sp_visible', true );
|
||||
if ( '' === $visible ) $visible = 1;
|
||||
if ( '' === $visible ) {
|
||||
$visible = 1;
|
||||
}
|
||||
?>
|
||||
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Staff_Details
|
||||
@@ -51,12 +53,18 @@ class SP_Meta_Box_Staff_Details {
|
||||
$roles = get_the_terms( $post->ID, 'sp_role' );
|
||||
$role_ids = is_array( $roles ) ? wp_list_pluck( $roles, 'term_id' ) : array();
|
||||
|
||||
$teams = get_posts( array( 'post_type' => 'sp_team', 'posts_per_page' => -1 ) );
|
||||
$teams = get_posts(
|
||||
array(
|
||||
'post_type' => 'sp_team',
|
||||
'posts_per_page' => -1,
|
||||
)
|
||||
);
|
||||
$past_teams = array_filter( get_post_meta( $post->ID, 'sp_past_team', false ) );
|
||||
$current_teams = array_filter( get_post_meta( $post->ID, 'sp_current_team', false ) );
|
||||
?>
|
||||
<p><strong><?php _e( 'Jobs', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_role',
|
||||
'name' => 'tax_input[sp_role][]',
|
||||
@@ -70,10 +78,15 @@ class SP_Meta_Box_Staff_Details {
|
||||
if ( ! sp_dropdown_taxonomies( $args ) ) :
|
||||
sp_taxonomy_adder( 'sp_role', 'sp_staff', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
?></p>
|
||||
?>
|
||||
</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">
|
||||
<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">
|
||||
<option value=""></option>
|
||||
<?php foreach ( $continents as $continent => $countries ) : ?>
|
||||
<optgroup label="<?php echo esc_attr( $continent ); ?>">
|
||||
@@ -85,7 +98,8 @@ class SP_Meta_Box_Staff_Details {
|
||||
</select></p>
|
||||
|
||||
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_current_team[]',
|
||||
@@ -97,10 +111,12 @@ class SP_Meta_Box_Staff_Details {
|
||||
'chosen' => true,
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?></p>
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_past_team[]',
|
||||
@@ -112,10 +128,12 @@ class SP_Meta_Box_Staff_Details {
|
||||
'chosen' => true,
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?></p>
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p><strong><?php _e( 'Leagues', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'tax_input[sp_league][]',
|
||||
@@ -127,10 +145,12 @@ class SP_Meta_Box_Staff_Details {
|
||||
'chosen' => true,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?></p>
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p><strong><?php _e( 'Seasons', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'tax_input[sp_season][]',
|
||||
@@ -142,7 +162,8 @@ class SP_Meta_Box_Staff_Details {
|
||||
'chosen' => true,
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?></p>
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @version 2.5.5
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Staff_Shortcode
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @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_Statistic_Details
|
||||
@@ -30,10 +33,18 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
|
||||
$visible = get_post_meta( $post->ID, 'sp_visible', true );
|
||||
|
||||
// Defaults
|
||||
if ( '' === $precision ) $precision = 0;
|
||||
if ( '' === $section ) $section = -1;
|
||||
if ( '' === $format ) $format = 'number';
|
||||
if ( '' === $visible ) $visible = 1;
|
||||
if ( '' === $precision ) {
|
||||
$precision = 0;
|
||||
}
|
||||
if ( '' === $section ) {
|
||||
$section = -1;
|
||||
}
|
||||
if ( '' === $format ) {
|
||||
$format = 'number';
|
||||
}
|
||||
if ( '' === $visible ) {
|
||||
$visible = 1;
|
||||
}
|
||||
?>
|
||||
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
@@ -48,7 +59,17 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
|
||||
<p class="sp-section-selector">
|
||||
<select name="sp_section">
|
||||
<?php
|
||||
$options = apply_filters( 'sportspress_performance_sections', array( -1 => __( 'All', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
||||
$options = apply_filters(
|
||||
'sportspress_performance_sections',
|
||||
array(
|
||||
-1 => __( 'All', 'sportspress' ),
|
||||
0 => __( 'Offense', 'sportspress' ),
|
||||
1 => __(
|
||||
'Defense',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( $key == $section, true, false ), $value );
|
||||
endforeach;
|
||||
@@ -59,7 +80,16 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
|
||||
<p>
|
||||
<select name="sp_format">
|
||||
<?php
|
||||
$options = apply_filters( 'sportspress_statistic_formats', array( 'number' => __( 'Number', 'sportspress' ), 'time' => __( 'Time', 'sportspress' ) ) );
|
||||
$options = apply_filters(
|
||||
'sportspress_statistic_formats',
|
||||
array(
|
||||
'number' => __( 'Number', 'sportspress' ),
|
||||
'time' => __(
|
||||
'Time',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( $key == $format, true, false ), $value );
|
||||
endforeach;
|
||||
@@ -70,7 +100,16 @@ class SP_Meta_Box_Statistic_Details extends SP_Meta_Box_Config {
|
||||
<p>
|
||||
<select name="sp_type">
|
||||
<?php
|
||||
$options = apply_filters( 'sportspress_statistic_total_types', array( 'total' => __( 'Total', 'sportspress' ), 'average' => __( 'Average', 'sportspress' ) ) );
|
||||
$options = apply_filters(
|
||||
'sportspress_statistic_total_types',
|
||||
array(
|
||||
'total' => __( 'Total', 'sportspress' ),
|
||||
'average' => __(
|
||||
'Average',
|
||||
'sportspress'
|
||||
),
|
||||
)
|
||||
);
|
||||
foreach ( $options as $key => $value ) :
|
||||
printf( '<option value="%s" %s>%s</option>', $key, selected( $key == $total, true, false ), $value );
|
||||
endforeach;
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* @version 1.9
|
||||
*/
|
||||
|
||||
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_Statistic_Equation
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Table_Data
|
||||
@@ -45,8 +47,9 @@ class SP_Meta_Box_Table_Data {
|
||||
* Admin edit table
|
||||
*/
|
||||
public static function table( $id = 0, $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $adjustments = array(), $highlight = null, $readonly = false ) {
|
||||
if ( is_array( $usecolumns ) )
|
||||
if ( is_array( $usecolumns ) ) {
|
||||
$usecolumns = array_filter( $usecolumns );
|
||||
}
|
||||
|
||||
$mode = sp_get_post_mode( $id );
|
||||
|
||||
@@ -62,7 +65,21 @@ class SP_Meta_Box_Table_Data {
|
||||
<?php if ( $readonly ) { ?>
|
||||
<p>
|
||||
<strong><?php echo get_the_title( $id ); ?></strong>
|
||||
<a class="add-new-h2 sp-add-new-h2" href="<?php echo esc_url( admin_url( add_query_arg( array( 'post' => $id, 'action' => 'edit' ), 'post.php' ) ) ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
|
||||
<a class="add-new-h2 sp-add-new-h2" href="
|
||||
<?php
|
||||
echo esc_url(
|
||||
admin_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'post' => $id,
|
||||
'action' => 'edit',
|
||||
),
|
||||
'post.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
?>
|
||||
"><?php _e( 'Edit', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
<?php } else { ?>
|
||||
<input type="hidden" name="sp_highlight" value="0">
|
||||
@@ -95,19 +112,29 @@ class SP_Meta_Box_Table_Data {
|
||||
if ( is_array( $data ) && sizeof( $data ) > 0 ) :
|
||||
$i = 0;
|
||||
foreach ( $data as $team_id => $team_stats ) :
|
||||
if ( !$team_id )
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$default_name = sp_array_value( $team_stats, 'name', '' );
|
||||
if ( $default_name == null )
|
||||
if ( $default_name == null ) {
|
||||
$default_name = get_the_title( $team_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 ( ! $readonly ) { ?>
|
||||
<td><input type="radio" class="sp-radio-toggle" name="sp_highlight" value="<?php echo esc_attr( $team_id ); ?>" <?php checked( $highlight, $team_id ); ?> <?php disabled( $readonly ); ?>></td>
|
||||
<?php } ?>
|
||||
<td>
|
||||
<?php if ( $show_team_logo ) echo get_the_post_thumbnail( $team_id, 'sportspress-fit-mini' ); ?>
|
||||
<?php
|
||||
if ( $show_team_logo ) {
|
||||
echo get_the_post_thumbnail( $team_id, 'sportspress-fit-mini' );}
|
||||
?>
|
||||
<?php if ( $readonly ) { ?>
|
||||
<?php echo esc_html( $default_name ); ?>
|
||||
<?php } else { ?>
|
||||
@@ -122,7 +149,8 @@ class SP_Meta_Box_Table_Data {
|
||||
</span>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
<?php
|
||||
foreach ( $columns as $column => $label ) :
|
||||
$value = sp_array_value( $team_stats, $column, '' );
|
||||
$placeholder = sp_array_value( sp_array_value( $placeholders, $team_id, array() ), $column, 0 );
|
||||
$placeholder = wp_strip_all_tags( $placeholder );
|
||||
@@ -136,7 +164,12 @@ class SP_Meta_Box_Table_Data {
|
||||
else :
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="<?php $colspan = sizeof( $columns ) + ( $readonly ? 1 : 2 ); echo $colspan; ?>">
|
||||
<td colspan="
|
||||
<?php
|
||||
$colspan = sizeof( $columns ) + ( $readonly ? 1 : 2 );
|
||||
echo $colspan;
|
||||
?>
|
||||
">
|
||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Data', 'sportspress' ) ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -161,14 +194,21 @@ class SP_Meta_Box_Table_Data {
|
||||
if ( is_array( $data ) && sizeof( $data ) > 0 ) :
|
||||
$i = 0;
|
||||
foreach ( $data as $team_id => $team_stats ) :
|
||||
if ( !$team_id )
|
||||
if ( ! $team_id ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<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_the_title( $team_id ); ?>
|
||||
</td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
<?php
|
||||
foreach ( $columns as $column => $label ) :
|
||||
$value = sp_array_value( sp_array_value( $adjustments, $team_id, array() ), $column, '' );
|
||||
?>
|
||||
<td><input type="text" name="sp_adjustments[<?php echo esc_attr( $team_id ); ?>][<?php echo esc_attr( $column ); ?>]" value="<?php echo esc_attr( $value ); ?>" placeholder="0" data-matrix="<?php echo esc_attr( $team_id ); ?>_<?php echo esc_attr( $column ); ?>" /></td>
|
||||
@@ -180,7 +220,12 @@ class SP_Meta_Box_Table_Data {
|
||||
else :
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="<?php $colspan = sizeof( $columns ) + 1; echo $colspan; ?>">
|
||||
<td colspan="
|
||||
<?php
|
||||
$colspan = sizeof( $columns ) + 1;
|
||||
echo $colspan;
|
||||
?>
|
||||
">
|
||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Data', 'sportspress' ) ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @version 2.7.9
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Table_Details
|
||||
@@ -97,8 +99,8 @@ class SP_Meta_Box_Table_Details {
|
||||
?>
|
||||
<p><strong><?php _e( 'Event Status (with results)', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<input type="checkbox" name="sp_event_status[]" value="publish" <?php echo ( in_array( "publish" , $event_status) ) ? 'checked' : false; ?>> Published/Played<br>
|
||||
<input type="checkbox" name="sp_event_status[]" value="future" <?php echo ( in_array( "future" , $event_status) ) ? 'checked' : false; ?>> Scheduled/Future<br>
|
||||
<input type="checkbox" name="sp_event_status[]" value="publish" <?php echo ( in_array( 'publish', $event_status ) ) ? 'checked' : false; ?>> Published/Played<br>
|
||||
<input type="checkbox" name="sp_event_status[]" value="future" <?php echo ( in_array( 'future', $event_status ) ) ? 'checked' : false; ?>> Scheduled/Future<br>
|
||||
</p>
|
||||
</div>
|
||||
<p><strong><?php _e( 'Sort by', 'sportspress' ); ?></strong></p>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user