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
|
// Color picker
|
||||||
$('.colorpick').iris( {
|
$( '.colorpick' ).iris(
|
||||||
|
{
|
||||||
change: function(event, ui){
|
change: function(event, ui){
|
||||||
$(this).css( { backgroundColor: ui.color.toString() } );
|
$( this ).css( { backgroundColor: ui.color.toString() } );
|
||||||
},
|
},
|
||||||
hide: true,
|
hide: true,
|
||||||
border: true
|
border: true
|
||||||
} ).each( function() {
|
}
|
||||||
$(this).css( { backgroundColor: $(this).val() } );
|
).each(
|
||||||
})
|
function() {
|
||||||
.click(function(){
|
$( this ).css( { backgroundColor: $( this ).val() } );
|
||||||
$('.iris-picker').hide();
|
}
|
||||||
$(this).closest('.sp-color-box, td').find('.iris-picker').show();
|
)
|
||||||
});
|
.click(
|
||||||
|
function(){
|
||||||
|
$( '.iris-picker' ).hide();
|
||||||
|
$( this ).closest( '.sp-color-box, td' ).find( '.iris-picker' ).show();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$('body').click(function() {
|
$( 'body' ).click(
|
||||||
$('.iris-picker').hide();
|
function() {
|
||||||
});
|
$( '.iris-picker' ).hide();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$('.sp-color-box, .colorpick').click(function(event){
|
$( '.sp-color-box, .colorpick' ).click(
|
||||||
|
function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
jQuery(document).ready(function($){
|
jQuery( document ).ready(
|
||||||
|
function($){
|
||||||
|
|
||||||
// Dashboard countdown
|
// Dashboard countdown
|
||||||
$("#sportspress_dashboard_status .sp_status_list li.countdown").each(function() {
|
$( "#sportspress_dashboard_status .sp_status_list li.countdown" ).each(
|
||||||
var $this = $(this), finalDate = $(this).data('countdown');
|
function() {
|
||||||
$this.countdown(finalDate, function(event) {
|
var $this = $( this ), finalDate = $( this ).data( 'countdown' );
|
||||||
$this.find('strong').html(event.strftime("%D "+localized_strings.days+" %H:%M:%S"));
|
$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(
|
$options = array(
|
||||||
'event' => array(
|
'event' => array(
|
||||||
'details', 'results', 'performance', 'venue', 'officials', 'teams', 'full',
|
'details',
|
||||||
|
'results',
|
||||||
|
'performance',
|
||||||
|
'venue',
|
||||||
|
'officials',
|
||||||
|
'teams',
|
||||||
|
'full',
|
||||||
),
|
),
|
||||||
'team' => array(),
|
'team' => array(),
|
||||||
'player' => array(
|
'player' => array(
|
||||||
'details', 'statistics'
|
'details',
|
||||||
|
'statistics',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$options = apply_filters( 'sportspress_shortcodes', $options );
|
$options = apply_filters( 'sportspress_shortcodes', $options );
|
||||||
|
|
||||||
foreach ( $options as $name => $group ) {
|
foreach ( $options as $name => $group ) {
|
||||||
if ( empty( $group ) ) continue;
|
if ( empty( $group ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$shortcodes .= $name . '[' . implode( '|', $group ) . ']';
|
$shortcodes .= $name . '[' . implode( '|', $group ) . ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
$raw = apply_filters( 'sportspress_tinymce_strings', array(
|
$raw = apply_filters(
|
||||||
|
'sportspress_tinymce_strings',
|
||||||
|
array(
|
||||||
'shortcodes' => $shortcodes,
|
'shortcodes' => $shortcodes,
|
||||||
'insert' => __( 'SportsPress Shortcodes', 'sportspress' ),
|
'insert' => __( 'SportsPress Shortcodes', 'sportspress' ),
|
||||||
'auto' => __( 'Auto', 'sportspress' ),
|
'auto' => __( 'Auto', 'sportspress' ),
|
||||||
@@ -42,7 +53,8 @@ $raw = apply_filters( 'sportspress_tinymce_strings', array(
|
|||||||
'list' => __( 'List', 'sportspress' ),
|
'list' => __( 'List', 'sportspress' ),
|
||||||
'blocks' => __( 'Blocks', 'sportspress' ),
|
'blocks' => __( 'Blocks', 'sportspress' ),
|
||||||
'gallery' => __( 'Gallery', 'sportspress' ),
|
'gallery' => __( 'Gallery', 'sportspress' ),
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$formatted = array();
|
$formatted = array();
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +1,58 @@
|
|||||||
/* global tinymce */
|
/* global tinymce */
|
||||||
( function () {
|
( function () {
|
||||||
tinymce.PluginManager.add( 'sp_shortcodes_button', function( editor, url ) {
|
tinymce.PluginManager.add(
|
||||||
|
'sp_shortcodes_button',
|
||||||
|
function( editor, url ) {
|
||||||
var ed = tinymce.activeEditor;
|
var ed = tinymce.activeEditor;
|
||||||
|
|
||||||
var groups = ed.getLang( 'sportspress.shortcodes' ).split("]");
|
var groups = ed.getLang( 'sportspress.shortcodes' ).split( "]" );
|
||||||
var menu = new Array();
|
var menu = new Array();
|
||||||
|
|
||||||
groups.forEach(function(g) {
|
groups.forEach(
|
||||||
if ( "" == g ) return;
|
function(g) {
|
||||||
var p = g.split("[");
|
if ( "" == g ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var p = g.split( "[" );
|
||||||
var label = p.shift();
|
var label = p.shift();
|
||||||
var variations = p.shift();
|
var variations = p.shift();
|
||||||
var shortcodes = typeof variations!== 'undefined' ? variations.split("|") : [];
|
var shortcodes = typeof variations !== 'undefined' ? variations.split( "|" ) : [];
|
||||||
var submenu = new Array();
|
var submenu = new Array();
|
||||||
shortcodes.forEach(function(s) {
|
shortcodes.forEach(
|
||||||
submenu.push({
|
function(s) {
|
||||||
|
submenu.push(
|
||||||
|
{
|
||||||
text: ed.getLang( 'sportspress.' + s ),
|
text: ed.getLang( 'sportspress.' + s ),
|
||||||
onclick: function() {
|
onclick: function() {
|
||||||
// triggers the thickbox
|
// triggers the thickbox
|
||||||
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
|
var width = jQuery( window ).width(), H = jQuery( window ).height(), W = ( 720 < width ) ? 720 : width;
|
||||||
W = W - 80;
|
W = W - 80;
|
||||||
H = H - 84;
|
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 );
|
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 ),
|
text: ed.getLang( 'sportspress.' + label ),
|
||||||
menu: submenu
|
menu: submenu
|
||||||
});
|
}
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
editor.addButton( 'sp_shortcodes_button', {
|
editor.addButton(
|
||||||
title: ed.getLang('sportspress.insert'),
|
'sp_shortcodes_button',
|
||||||
|
{
|
||||||
|
title: ed.getLang( 'sportspress.insert' ),
|
||||||
text: false,
|
text: false,
|
||||||
icon: false,
|
icon: false,
|
||||||
type: 'menubutton',
|
type: 'menubutton',
|
||||||
menu: menu
|
menu: menu
|
||||||
});
|
}
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,37 +1,55 @@
|
|||||||
jQuery(document).ready(function($){
|
jQuery( document ).ready(
|
||||||
$("#title").keyup(function() {
|
function($){
|
||||||
val = $(this).val();
|
$( "#title" ).keyup(
|
||||||
if ( val == '' ) val = 'f(x)';
|
function() {
|
||||||
$(".sp-equation-variable").text( val + ' =' );
|
val = $( this ).val();
|
||||||
});
|
if ( val == '' ) {
|
||||||
|
val = 'f(x)';
|
||||||
|
}
|
||||||
|
$( ".sp-equation-variable" ).text( val + ' =' );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$(".sp-equation-parts .button").draggable({
|
$( ".sp-equation-parts .button" ).draggable(
|
||||||
|
{
|
||||||
appendTo: "body",
|
appendTo: "body",
|
||||||
helper: "clone",
|
helper: "clone",
|
||||||
cursor: "move",
|
cursor: "move",
|
||||||
distance: 10,
|
distance: 10,
|
||||||
containment: "#sp_equationdiv",
|
containment: "#sp_equationdiv",
|
||||||
}).click(function() {
|
}
|
||||||
$("<label class='button'></label>").text( $(this).text() ).append("<span class='remove'>×</span><input name='sp_equation[]' type='hidden' value='" + $(this).data("variable") + "'>").appendTo( $(".sp-equation-formula") );
|
).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",
|
activeClass: "ui-state-active",
|
||||||
hoverClass: "ui-state-hover",
|
hoverClass: "ui-state-hover",
|
||||||
accept: ".button:not(.ui-sortable-helper)",
|
accept: ".button:not(.ui-sortable-helper)",
|
||||||
drop: function( event, ui ) {
|
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") );
|
$( "<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",
|
items: ".button",
|
||||||
tolerance: "pointer",
|
tolerance: "pointer",
|
||||||
containment: "#sp_equationdiv",
|
containment: "#sp_equationdiv",
|
||||||
sort: function() {
|
sort: function() {
|
||||||
$( this ).removeClass( "ui-state-active" );
|
$( this ).removeClass( "ui-state-active" );
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$(".sp-equation-formula").on("click", ".button .remove", function() {
|
$( ".sp-equation-formula" ).on(
|
||||||
$(this).closest(".button").remove();
|
"click",
|
||||||
});
|
".button .remove",
|
||||||
});
|
function() {
|
||||||
|
$( this ).closest( ".button" ).remove();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,37 +1,52 @@
|
|||||||
jQuery(document).ready(function($){
|
jQuery( document ).ready(
|
||||||
|
function($){
|
||||||
|
|
||||||
// Icon picker
|
// Icon picker
|
||||||
$('.sp-icons input').on('change', function() {
|
$( '.sp-icons input' ).on(
|
||||||
if ('' == $(this).val()) {
|
'change',
|
||||||
$('.sp-custom-colors').hide();
|
function() {
|
||||||
$('.sp-custom-thumbnail').show();
|
if ('' == $( this ).val()) {
|
||||||
|
$( '.sp-custom-colors' ).hide();
|
||||||
|
$( '.sp-custom-thumbnail' ).show();
|
||||||
} else {
|
} else {
|
||||||
$('.sp-custom-thumbnail').hide();
|
$( '.sp-custom-thumbnail' ).hide();
|
||||||
$('.sp-custom-colors').show();
|
$( '.sp-custom-colors' ).show();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Color picker
|
// Color picker
|
||||||
$('.colorpick').iris( {
|
$( '.colorpick' ).iris(
|
||||||
|
{
|
||||||
change: function(event, ui){
|
change: function(event, ui){
|
||||||
$(this).css( { backgroundColor: ui.color.toString() } );
|
$( this ).css( { backgroundColor: ui.color.toString() } );
|
||||||
},
|
},
|
||||||
hide: true,
|
hide: true,
|
||||||
border: true
|
border: true
|
||||||
} ).each( function() {
|
}
|
||||||
$(this).css( { backgroundColor: $(this).val() } );
|
).each(
|
||||||
})
|
function() {
|
||||||
.click(function(){
|
$( this ).css( { backgroundColor: $( this ).val() } );
|
||||||
$('.iris-picker').hide();
|
}
|
||||||
$(this).closest('.sp-color-box-for-icon, td').find('.iris-picker').show();
|
)
|
||||||
});
|
.click(
|
||||||
|
function(){
|
||||||
|
$( '.iris-picker' ).hide();
|
||||||
|
$( this ).closest( '.sp-color-box-for-icon, td' ).find( '.iris-picker' ).show();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$('body').click(function() {
|
$( 'body' ).click(
|
||||||
$('.iris-picker').hide();
|
function() {
|
||||||
});
|
$( '.iris-picker' ).hide();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$('.sp-color-box-for-icon, .colorpick').click(function(event){
|
$( '.sp-color-box-for-icon, .colorpick' ).click(
|
||||||
|
function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -25,43 +25,57 @@
|
|||||||
|
|
||||||
// get the data
|
// get the data
|
||||||
var $number = $( '.column-sp_number', $post_row ).text();
|
var $number = $( '.column-sp_number', $post_row ).text();
|
||||||
var $current_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'current-teams' ) ).split(',');
|
var $current_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'current-teams' ) ).split( ',' );
|
||||||
var $past_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'past-teams' ) ).split(',');
|
var $past_teams = String( $( '.column-sp_team', $post_row ).find( '.sp-player-teams' ).data( 'past-teams' ) ).split( ',' );
|
||||||
|
|
||||||
// populate the data
|
// populate the data
|
||||||
$( ':input[name="sp_number"]', $edit_row ).val( $number );
|
$( ':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(
|
||||||
$(this).prop("checked", ($.inArray($(this).val(), $current_teams ) != -1));
|
function() {
|
||||||
});
|
$( this ).prop( "checked", ($.inArray( $( this ).val(), $current_teams ) != -1) );
|
||||||
$( ':input[name="sp_past_team[]"]', $edit_row ).each(function() {
|
}
|
||||||
$(this).prop("checked", ($.inArray($(this).val(), $past_teams ) != -1));
|
);
|
||||||
});
|
$( ':input[name="sp_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
|
// define the bulk edit row
|
||||||
var $bulk_row = $( '#bulk-edit' );
|
var $bulk_row = $( '#bulk-edit' );
|
||||||
|
|
||||||
// get the selected post ids that are being edited
|
// get the selected post ids that are being edited
|
||||||
var $post_ids = new Array();
|
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, '' ) );
|
$post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// get the data
|
// get the data
|
||||||
var $current_teams = [];
|
var $current_teams = [];
|
||||||
$bulk_row.find( 'input[name="sp_current_team[]"]:checked' ).each(function() {
|
$bulk_row.find( 'input[name="sp_current_team[]"]:checked' ).each(
|
||||||
$current_teams.push( $(this).val() );
|
function() {
|
||||||
});
|
$current_teams.push( $( this ).val() );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
var $past_teams = [];
|
var $past_teams = [];
|
||||||
$bulk_row.find( 'input[name="sp_past_team[]"]:checked' ).each(function() {
|
$bulk_row.find( 'input[name="sp_past_team[]"]:checked' ).each(
|
||||||
$past_teams.push( $(this).val() );
|
function() {
|
||||||
});
|
$past_teams.push( $( this ).val() );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// save the data
|
// save the data
|
||||||
$.ajax({
|
$.ajax(
|
||||||
|
{
|
||||||
url: ajaxurl, // this is a variable that WordPress has already defined for us
|
url: ajaxurl, // this is a variable that WordPress has already defined for us
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
async: false,
|
async: false,
|
||||||
@@ -71,9 +85,11 @@
|
|||||||
post_ids: $post_ids,
|
post_ids: $post_ids,
|
||||||
current_teams: $current_teams,
|
current_teams: $current_teams,
|
||||||
past_teams: $past_teams,
|
past_teams: $past_teams,
|
||||||
nonce: $("#sp_player_edit_nonce").val()
|
nonce: $( "#sp_player_edit_nonce" ).val()
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
})(jQuery);
|
})( jQuery );
|
||||||
|
|||||||
@@ -1,64 +1,92 @@
|
|||||||
jQuery(document).ready(function($){
|
jQuery( document ).ready(
|
||||||
|
function($){
|
||||||
|
|
||||||
// Display custom sport name field as needed
|
// Display custom sport name field as needed
|
||||||
$("body.toplevel_page_sportspress #sportspress_sport").change(function() {
|
$( "body.toplevel_page_sportspress #sportspress_sport" ).change(
|
||||||
$target = $("#sportspress_custom_sport_name");
|
function() {
|
||||||
if ( $(this).val() == "custom" )
|
$target = $( "#sportspress_custom_sport_name" );
|
||||||
|
if ( $( this ).val() == "custom" ) {
|
||||||
$target.show();
|
$target.show();
|
||||||
else
|
} else {
|
||||||
$target.hide();
|
$target.hide();
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Color picker
|
// Color picker
|
||||||
$('.colorpick').iris( {
|
$( '.colorpick' ).iris(
|
||||||
|
{
|
||||||
change: function(event, ui){
|
change: function(event, ui){
|
||||||
$(this).css( { backgroundColor: ui.color.toString() } );
|
$( this ).css( { backgroundColor: ui.color.toString() } );
|
||||||
},
|
},
|
||||||
hide: true,
|
hide: true,
|
||||||
border: true
|
border: true
|
||||||
} ).each( function() {
|
}
|
||||||
$(this).css( { backgroundColor: $(this).val() } );
|
).each(
|
||||||
})
|
function() {
|
||||||
.click(function(){
|
$( this ).css( { backgroundColor: $( this ).val() } );
|
||||||
$('.iris-picker').hide();
|
}
|
||||||
$(this).closest('.sp-color-box, td').find('.iris-picker').show();
|
)
|
||||||
});
|
.click(
|
||||||
|
function(){
|
||||||
|
$( '.iris-picker' ).hide();
|
||||||
|
$( this ).closest( '.sp-color-box, td' ).find( '.iris-picker' ).show();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$('body').click(function() {
|
$( 'body' ).click(
|
||||||
$('.iris-picker').hide();
|
function() {
|
||||||
});
|
$( '.iris-picker' ).hide();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$('.sp-color-box, .colorpick').click(function(event){
|
$( '.sp-color-box, .colorpick' ).click(
|
||||||
|
function(event){
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Chosen select
|
// Chosen select
|
||||||
$(".chosen-select").chosen({
|
$( ".chosen-select" ).chosen(
|
||||||
|
{
|
||||||
allow_single_deselect: true,
|
allow_single_deselect: true,
|
||||||
single_backstroke_delete: false,
|
single_backstroke_delete: false,
|
||||||
placeholder_text_multiple: localized_strings.none
|
placeholder_text_multiple: localized_strings.none
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Preset field modifier
|
// Preset field modifier
|
||||||
$(".sp-custom-input-wrapper .preset").click(function() {
|
$( ".sp-custom-input-wrapper .preset" ).click(
|
||||||
val = $(this).val();
|
function() {
|
||||||
if(val == "\\c\\u\\s\\t\\o\\m") return true;
|
val = $( this ).val();
|
||||||
example = $(this).attr("data-example");
|
if (val == "\\c\\u\\s\\t\\o\\m") {
|
||||||
$(this).closest(".sp-custom-input-wrapper").find(".value").val(val).siblings(".example").html(example);
|
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
|
// Select custom preset when field is brought to focus
|
||||||
$(".sp-custom-input-wrapper .value").focus(function() {
|
$( ".sp-custom-input-wrapper .value" ).focus(
|
||||||
$(this).siblings("label").find(".preset").prop("checked", true);
|
function() {
|
||||||
});
|
$( this ).siblings( "label" ).find( ".preset" ).prop( "checked", true );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Adjust example field when custom preset is entered
|
// Adjust example field when custom preset is entered
|
||||||
$(".sp-custom-input-wrapper .value").on("keyup", function() {
|
$( ".sp-custom-input-wrapper .value" ).on(
|
||||||
val = $(this).val();
|
"keyup",
|
||||||
if ( val === undefined ) return true;
|
function() {
|
||||||
format = $(this).attr("data-example-format");
|
val = $( this ).val();
|
||||||
example = format.replace(/__val__/g, val);
|
if ( val === undefined ) {
|
||||||
$(this).siblings(".example").html(example);
|
return true;
|
||||||
});
|
}
|
||||||
|
format = $( this ).attr( "data-example-format" );
|
||||||
|
example = format.replace( /__val__/g, val );
|
||||||
|
$( this ).siblings( ".example" ).html( example );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,54 +1,76 @@
|
|||||||
//Get variables form input values
|
// Get variables form input values
|
||||||
latitude = document.getElementById('term_meta[sp_latitude]').value;
|
latitude = document.getElementById( 'term_meta[sp_latitude]' ).value;
|
||||||
longitude = document.getElementById('term_meta[sp_longitude]').value;
|
longitude = document.getElementById( 'term_meta[sp_longitude]' ).value;
|
||||||
|
|
||||||
//Initialize the map and add the Search control box
|
// Initialize the map and add the Search control box
|
||||||
var map = L.map('sp-location-picker').setView([latitude, longitude], 15),
|
var map = L.map( 'sp-location-picker' ).setView( [latitude, longitude], 15 ),
|
||||||
geocoder = L.Control.Geocoder.nominatim(),
|
geocoder = L.Control.Geocoder.nominatim(),
|
||||||
control = L.Control.geocoder({
|
control = L.Control.geocoder(
|
||||||
|
{
|
||||||
geocoder: geocoder,
|
geocoder: geocoder,
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
defaultMarkGeocode: false
|
defaultMarkGeocode: false
|
||||||
}).addTo(map),
|
}
|
||||||
//Add a marker to use from the begining
|
).addTo( map ),
|
||||||
marker = L.marker([latitude, longitude],{draggable: true, autoPan: true}).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'
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||||
}).addTo(map);
|
}
|
||||||
|
).addTo( map );
|
||||||
|
|
||||||
//Pass the values to the fields after dragging
|
// Pass the values to the fields after dragging
|
||||||
marker.on('dragend', function (e) {
|
marker.on(
|
||||||
document.getElementById('term_meta[sp_latitude]').value = marker.getLatLng().lat;
|
'dragend',
|
||||||
document.getElementById('term_meta[sp_longitude]').value = marker.getLatLng().lng;
|
function (e) {
|
||||||
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
|
document.getElementById( 'term_meta[sp_latitude]' ).value = marker.getLatLng().lat;
|
||||||
|
document.getElementById( 'term_meta[sp_longitude]' ).value = marker.getLatLng().lng;
|
||||||
|
geocoder.reverse(
|
||||||
|
marker.getLatLng(),
|
||||||
|
map.options.crs.scale( map.getZoom() ),
|
||||||
|
function(results) {
|
||||||
var r = results[0];
|
var r = results[0];
|
||||||
if (r) {
|
if (r) {
|
||||||
document.getElementById('term_meta[sp_address]').value = r.name;
|
document.getElementById( 'term_meta[sp_address]' ).value = r.name;
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
});
|
)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
//After searching
|
// After searching
|
||||||
control.on('markgeocode', function(e) {
|
control.on(
|
||||||
|
'markgeocode',
|
||||||
|
function(e) {
|
||||||
var center = e.geocode.center;
|
var center = e.geocode.center;
|
||||||
var address = e.geocode.name;
|
var address = e.geocode.name;
|
||||||
map.setView([center.lat, center.lng], 15); //Center map to the new place
|
map.setView( [center.lat, center.lng], 15 ); // Center map to the new place
|
||||||
map.removeLayer(marker); //Remove previous marker
|
map.removeLayer( marker ); // Remove previous marker
|
||||||
marker = L.marker([center.lat, center.lng],{draggable: true, autoPan: true}).addTo(map); //Add new marker to use
|
marker = L.marker( [center.lat, center.lng],{draggable: true, autoPan: true} ).addTo( map ); // Add new marker to use
|
||||||
//Pass the values to the fields after searching
|
// Pass the values to the fields after searching
|
||||||
document.getElementById('term_meta[sp_latitude]').value = center.lat;
|
document.getElementById( 'term_meta[sp_latitude]' ).value = center.lat;
|
||||||
document.getElementById('term_meta[sp_longitude]').value = center.lng;
|
document.getElementById( 'term_meta[sp_longitude]' ).value = center.lng;
|
||||||
document.getElementById('term_meta[sp_address]').value = address;
|
document.getElementById( 'term_meta[sp_address]' ).value = address;
|
||||||
//Pass the values to the fields after dragging
|
// Pass the values to the fields after dragging
|
||||||
marker.on('dragend', function (e) {
|
marker.on(
|
||||||
document.getElementById('term_meta[sp_latitude]').value = marker.getLatLng().lat;
|
'dragend',
|
||||||
document.getElementById('term_meta[sp_longitude]').value = marker.getLatLng().lng;
|
function (e) {
|
||||||
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
|
document.getElementById( 'term_meta[sp_latitude]' ).value = marker.getLatLng().lat;
|
||||||
|
document.getElementById( 'term_meta[sp_longitude]' ).value = marker.getLatLng().lng;
|
||||||
|
geocoder.reverse(
|
||||||
|
marker.getLatLng(),
|
||||||
|
map.options.crs.scale( map.getZoom() ),
|
||||||
|
function(results) {
|
||||||
var r = results[0];
|
var r = results[0];
|
||||||
if (r) {
|
if (r) {
|
||||||
document.getElementById('term_meta[sp_address]').value = r.name;
|
document.getElementById( 'term_meta[sp_address]' ).value = r.name;
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
});
|
)
|
||||||
}).addTo(map);
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
).addTo( map );
|
||||||
|
|||||||
@@ -1,54 +1,76 @@
|
|||||||
//Get variables form input values
|
// Get variables form input values
|
||||||
latitude = document.getElementById('sp_latitude').value;
|
latitude = document.getElementById( 'sp_latitude' ).value;
|
||||||
longitude = document.getElementById('sp_longitude').value;
|
longitude = document.getElementById( 'sp_longitude' ).value;
|
||||||
|
|
||||||
//Initialize the map and add the Search control box
|
// Initialize the map and add the Search control box
|
||||||
var map = L.map('sp-location-picker').setView([latitude, longitude], 15),
|
var map = L.map( 'sp-location-picker' ).setView( [latitude, longitude], 15 ),
|
||||||
geocoder = L.Control.Geocoder.nominatim(),
|
geocoder = L.Control.Geocoder.nominatim(),
|
||||||
control = L.Control.geocoder({
|
control = L.Control.geocoder(
|
||||||
|
{
|
||||||
geocoder: geocoder,
|
geocoder: geocoder,
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
defaultMarkGeocode: false
|
defaultMarkGeocode: false
|
||||||
}).addTo(map),
|
}
|
||||||
//Add a marker to use from the begining
|
).addTo( map ),
|
||||||
marker = L.marker([latitude, longitude],{draggable: true, autoPan: true}).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'
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||||
}).addTo(map);
|
}
|
||||||
|
).addTo( map );
|
||||||
|
|
||||||
//Pass the values to the fields after dragging
|
// Pass the values to the fields after dragging
|
||||||
marker.on('dragend', function (e) {
|
marker.on(
|
||||||
document.getElementById('sp_latitude').value = marker.getLatLng().lat;
|
'dragend',
|
||||||
document.getElementById('sp_longitude').value = marker.getLatLng().lng;
|
function (e) {
|
||||||
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
|
document.getElementById( 'sp_latitude' ).value = marker.getLatLng().lat;
|
||||||
|
document.getElementById( 'sp_longitude' ).value = marker.getLatLng().lng;
|
||||||
|
geocoder.reverse(
|
||||||
|
marker.getLatLng(),
|
||||||
|
map.options.crs.scale( map.getZoom() ),
|
||||||
|
function(results) {
|
||||||
var r = results[0];
|
var r = results[0];
|
||||||
if (r) {
|
if (r) {
|
||||||
document.getElementById('sp_address').value = r.name;
|
document.getElementById( 'sp_address' ).value = r.name;
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
});
|
)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
//After searching
|
// After searching
|
||||||
control.on('markgeocode', function(e) {
|
control.on(
|
||||||
|
'markgeocode',
|
||||||
|
function(e) {
|
||||||
var center = e.geocode.center;
|
var center = e.geocode.center;
|
||||||
var address = e.geocode.name;
|
var address = e.geocode.name;
|
||||||
map.setView([center.lat, center.lng], 15); //Center map to the new place
|
map.setView( [center.lat, center.lng], 15 ); // Center map to the new place
|
||||||
map.removeLayer(marker); //Remove previous marker
|
map.removeLayer( marker ); // Remove previous marker
|
||||||
marker = L.marker([center.lat, center.lng],{draggable: true, autoPan: true}).addTo(map); //Add new marker to use
|
marker = L.marker( [center.lat, center.lng],{draggable: true, autoPan: true} ).addTo( map ); // Add new marker to use
|
||||||
//Pass the values to the fields after searching
|
// Pass the values to the fields after searching
|
||||||
document.getElementById('sp_latitude').value = center.lat;
|
document.getElementById( 'sp_latitude' ).value = center.lat;
|
||||||
document.getElementById('sp_longitude').value = center.lng;
|
document.getElementById( 'sp_longitude' ).value = center.lng;
|
||||||
document.getElementById('sp_address').value = address;
|
document.getElementById( 'sp_address' ).value = address;
|
||||||
//Pass the values to the fields after dragging
|
// Pass the values to the fields after dragging
|
||||||
marker.on('dragend', function (e) {
|
marker.on(
|
||||||
document.getElementById('sp_latitude').value = marker.getLatLng().lat;
|
'dragend',
|
||||||
document.getElementById('sp_longitude').value = marker.getLatLng().lng;
|
function (e) {
|
||||||
geocoder.reverse(marker.getLatLng(), map.options.crs.scale(map.getZoom()), function(results) {
|
document.getElementById( 'sp_latitude' ).value = marker.getLatLng().lat;
|
||||||
|
document.getElementById( 'sp_longitude' ).value = marker.getLatLng().lng;
|
||||||
|
geocoder.reverse(
|
||||||
|
marker.getLatLng(),
|
||||||
|
map.options.crs.scale( map.getZoom() ),
|
||||||
|
function(results) {
|
||||||
var r = results[0];
|
var r = results[0];
|
||||||
if (r) {
|
if (r) {
|
||||||
document.getElementById('sp_address').value = r.name;
|
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
|
// Tiptip
|
||||||
$(".sp-tip").tipTip({
|
$( ".sp-tip" ).tipTip(
|
||||||
|
{
|
||||||
delay: 200,
|
delay: 200,
|
||||||
fadeIn: 100,
|
fadeIn: 100,
|
||||||
fadeOut: 100
|
fadeOut: 100
|
||||||
});
|
}
|
||||||
$(".sp-desc-tip").tipTip({
|
);
|
||||||
|
$( ".sp-desc-tip" ).tipTip(
|
||||||
|
{
|
||||||
delay: 200,
|
delay: 200,
|
||||||
fadeIn: 100,
|
fadeIn: 100,
|
||||||
fadeOut: 100,
|
fadeOut: 100,
|
||||||
defaultPosition: 'right'
|
defaultPosition: 'right'
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Chosen select
|
// Chosen select
|
||||||
$(".chosen-select, #poststuff #post_author_override").chosen({
|
$( ".chosen-select, #poststuff #post_author_override" ).chosen(
|
||||||
|
{
|
||||||
allow_single_deselect: true,
|
allow_single_deselect: true,
|
||||||
search_contains: true,
|
search_contains: true,
|
||||||
single_backstroke_delete: false,
|
single_backstroke_delete: false,
|
||||||
disable_search_threshold: 10,
|
disable_search_threshold: 10,
|
||||||
placeholder_text_multiple: localized_strings.none
|
placeholder_text_multiple: localized_strings.none
|
||||||
});
|
}
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,41 +1,60 @@
|
|||||||
jQuery(document).ready(function($){
|
jQuery( document ).ready(
|
||||||
|
function($){
|
||||||
|
|
||||||
// Orderby affects order select in widget options
|
// Orderby affects order select in widget options
|
||||||
$("body").on("change", ".sp-select-orderby", function() {
|
$( "body" ).on(
|
||||||
$(this).closest(".widget-content").find(".sp-select-order").prop("disabled", $(this).val() == "default");
|
"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
|
// Calendar affects view all link checkbox in widget options
|
||||||
$("body").on("change", ".sp-event-calendar-select", function() {
|
$( "body" ).on(
|
||||||
$el = $(this).closest(".widget-content").find(".sp-event-calendar-show-all-toggle");
|
"change",
|
||||||
if($(this).val() == 0)
|
".sp-event-calendar-select",
|
||||||
|
function() {
|
||||||
|
$el = $( this ).closest( ".widget-content" ).find( ".sp-event-calendar-show-all-toggle" );
|
||||||
|
if ($( this ).val() == 0) {
|
||||||
$el.hide();
|
$el.hide();
|
||||||
else
|
} else {
|
||||||
$el.show();
|
$el.show();
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Show or hide datepicker
|
// Show or hide datepicker
|
||||||
$("body").on("change", ".sp-date-selector select", function() {
|
$( "body" ).on(
|
||||||
if ( $(this).val() == "range" ) {
|
"change",
|
||||||
$(this).closest(".sp-date-selector").find(".sp-date-range").show();
|
".sp-date-selector select",
|
||||||
|
function() {
|
||||||
|
if ( $( this ).val() == "range" ) {
|
||||||
|
$( this ).closest( ".sp-date-selector" ).find( ".sp-date-range" ).show();
|
||||||
} else {
|
} else {
|
||||||
$(this).closest(".sp-date-selector").find(".sp-date-range").hide();
|
$( this ).closest( ".sp-date-selector" ).find( ".sp-date-range" ).hide();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
$(".sp-date-selector select").trigger("change");
|
);
|
||||||
|
$( ".sp-date-selector select" ).trigger( "change" );
|
||||||
|
|
||||||
// Toggle date range selectors
|
// Toggle date range selectors
|
||||||
$("body").on("change", ".sp-date-relative input", function() {
|
$( "body" ).on(
|
||||||
$relative = $(this).closest(".sp-date-relative").siblings(".sp-date-range-relative").toggle(0, $(this).attr("checked"));
|
"change",
|
||||||
$absolute = $(this).closest(".sp-date-relative").siblings(".sp-date-range-absolute").toggle(0, $(this).attr("checked"));
|
".sp-date-relative input",
|
||||||
|
function() {
|
||||||
|
$relative = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-relative" ).toggle( 0, $( this ).attr( "checked" ) );
|
||||||
|
$absolute = $( this ).closest( ".sp-date-relative" ).siblings( ".sp-date-range-absolute" ).toggle( 0, $( this ).attr( "checked" ) );
|
||||||
|
|
||||||
if ($(this).attr("checked")) {
|
if ($( this ).attr( "checked" )) {
|
||||||
$relative.show();
|
$relative.show();
|
||||||
$absolute.hide();
|
$absolute.hide();
|
||||||
} else {
|
} else {
|
||||||
$absolute.show();
|
$absolute.show();
|
||||||
$relative.hide();
|
$relative.hide();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
$(".sp-date-selector input").trigger("change");
|
);
|
||||||
});
|
$( ".sp-date-selector input" ).trigger( "change" );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import apiFetch from '@wordpress/api-fetch';
|
import apiFetch from '@wordpress/api-fetch';
|
||||||
console.log(wp.api.collections.Posts());
|
console.log( wp.api.collections.Posts() );
|
||||||
|
|
||||||
wp.blocks.registerBlockType('sportspress/event-calendar', {
|
wp.blocks.registerBlockType(
|
||||||
|
'sportspress/event-calendar',
|
||||||
|
{
|
||||||
title: strings.event_calendar,
|
title: strings.event_calendar,
|
||||||
icon: 'calendar',
|
icon: 'calendar',
|
||||||
category: 'sportspress',
|
category: 'sportspress',
|
||||||
@@ -46,10 +48,10 @@ wp.blocks.registerBlockType('sportspress/event-calendar', {
|
|||||||
|
|
||||||
edit: function(props) {
|
edit: function(props) {
|
||||||
function updateContent(event) {
|
function updateContent(event) {
|
||||||
props.setAttributes({content: event.target.value})
|
props.setAttributes( {content: event.target.value} )
|
||||||
}
|
}
|
||||||
function updateColor(value) {
|
function updateColor(value) {
|
||||||
props.setAttributes({color: value.hex})
|
props.setAttributes( {color: value.hex} )
|
||||||
}
|
}
|
||||||
return React.createElement(
|
return React.createElement(
|
||||||
wp.components.Panel,
|
wp.components.Panel,
|
||||||
@@ -63,9 +65,13 @@ wp.blocks.registerBlockType('sportspress/event-calendar', {
|
|||||||
),
|
),
|
||||||
React.createElement(
|
React.createElement(
|
||||||
wp.components.SelectControl,
|
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}
|
return {label: post.post_title, value: post.ID}
|
||||||
}))}
|
}
|
||||||
|
)
|
||||||
|
)}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -78,4 +84,5 @@ wp.blocks.registerBlockType('sportspress/event-calendar', {
|
|||||||
props.attributes.content
|
props.attributes.content
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|||||||
@@ -19,20 +19,21 @@
|
|||||||
ignore: null
|
ignore: null
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!document.getElementById('fit-vids-style')) {
|
if ( ! document.getElementById( 'fit-vids-style' )) {
|
||||||
// appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
|
// appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
|
||||||
var head = document.head || document.getElementsByTagName('head')[0];
|
var head = document.head || document.getElementsByTagName( 'head' )[0];
|
||||||
var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
|
var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
|
||||||
var div = document.createElement("div");
|
var div = document.createElement( "div" );
|
||||||
div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
|
div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
|
||||||
head.appendChild(div.childNodes[1]);
|
head.appendChild( div.childNodes[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( options ) {
|
if ( options ) {
|
||||||
$.extend( settings, options );
|
$.extend( settings, options );
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.each(function(){
|
return this.each(
|
||||||
|
function(){
|
||||||
var selectors = [
|
var selectors = [
|
||||||
'iframe[src*="player.vimeo.com"]',
|
'iframe[src*="player.vimeo.com"]',
|
||||||
'iframe[src*="youtube.com"]',
|
'iframe[src*="youtube.com"]',
|
||||||
@@ -43,41 +44,44 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
if (settings.customSelector) {
|
if (settings.customSelector) {
|
||||||
selectors.push(settings.customSelector);
|
selectors.push( settings.customSelector );
|
||||||
}
|
}
|
||||||
|
|
||||||
var ignoreList = '.fitvidsignore';
|
var ignoreList = '.fitvidsignore';
|
||||||
|
|
||||||
if(settings.ignore) {
|
if (settings.ignore) {
|
||||||
ignoreList = ignoreList + ', ' + settings.ignore;
|
ignoreList = ignoreList + ', ' + settings.ignore;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $allVideos = $(this).find(selectors.join(','));
|
var $allVideos = $( this ).find( selectors.join( ',' ) );
|
||||||
$allVideos = $allVideos.not('object object'); // SwfObj conflict patch
|
$allVideos = $allVideos.not( 'object object' ); // SwfObj conflict patch
|
||||||
$allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video.
|
$allVideos = $allVideos.not( ignoreList ); // Disable FitVids on this video.
|
||||||
|
|
||||||
$allVideos.each(function(){
|
$allVideos.each(
|
||||||
var $this = $(this);
|
function(){
|
||||||
if($this.parents(ignoreList).length > 0) {
|
var $this = $( this );
|
||||||
|
if ($this.parents( ignoreList ).length > 0) {
|
||||||
return; // Disable FitVids on this video.
|
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.tagName.toLowerCase() === 'embed' && $this.parent( 'object' ).length || $this.parent( '.fluid-width-video-wrapper' ).length) {
|
||||||
if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
|
return; }
|
||||||
{
|
if (( ! $this.css( 'height' ) && ! $this.css( 'width' )) && (isNaN( $this.attr( 'height' ) ) || isNaN( $this.attr( 'width' ) ))) {
|
||||||
$this.attr('height', 9);
|
$this.attr( 'height', 9 );
|
||||||
$this.attr('width', 16);
|
$this.attr( 'width', 16 );
|
||||||
}
|
}
|
||||||
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
|
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr( 'height' ) && ! isNaN( parseInt( $this.attr( 'height' ), 10 ) )) ) ? parseInt( $this.attr( 'height' ), 10 ) : $this.height(),
|
||||||
width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
|
width = ! isNaN( parseInt( $this.attr( 'width' ), 10 ) ) ? parseInt( $this.attr( 'width' ), 10 ) : $this.width(),
|
||||||
aspectRatio = height / width;
|
aspectRatio = height / width;
|
||||||
if(!$this.attr('id')){
|
if ( ! $this.attr( 'id' )) {
|
||||||
var videoID = 'fitvid' + Math.floor(Math.random()*999999);
|
var videoID = 'fitvid' + Math.floor( Math.random() * 999999 );
|
||||||
$this.attr('id', videoID);
|
$this.attr( 'id', videoID );
|
||||||
}
|
}
|
||||||
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
|
$this.wrap( '<div class="fluid-width-video-wrapper"></div>' ).parent( '.fluid-width-video-wrapper' ).css( 'padding-top', (aspectRatio * 100) + '%' );
|
||||||
$this.removeAttr('height').removeAttr('width');
|
$this.removeAttr( 'height' ).removeAttr( 'width' );
|
||||||
});
|
}
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
// Works with either jQuery or Zepto
|
// Works with either jQuery or Zepto
|
||||||
})( window.jQuery || window.Zepto );
|
})( window.jQuery || window.Zepto );
|
||||||
|
|||||||
@@ -1,33 +1,35 @@
|
|||||||
function sp_viewport() {
|
function sp_viewport() {
|
||||||
var e = window, a = 'inner';
|
var e = window, a = 'inner';
|
||||||
if (!('innerWidth' in window )) {
|
if ( ! ('innerWidth' in window )) {
|
||||||
a = 'client';
|
a = 'client';
|
||||||
e = document.documentElement || document.body;
|
e = document.documentElement || document.body;
|
||||||
}
|
}
|
||||||
return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };
|
return { width : e[ a + 'Width' ] , height : e[ a + 'Height' ] };
|
||||||
}
|
}
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
|
|
||||||
/* Header */
|
/* Header */
|
||||||
if ( ! $('.sp-header').length ) {
|
if ( ! $( '.sp-header' ).length ) {
|
||||||
$('body').prepend( '<div class="sp-header sp-header-loaded"></div>' );
|
$( 'body' ).prepend( '<div class="sp-header sp-header-loaded"></div>' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Countdown */
|
/* Countdown */
|
||||||
$("[data-countdown]").each(function() {
|
$( "[data-countdown]" ).each(
|
||||||
var $this = $(this);
|
function() {
|
||||||
|
var $this = $( this );
|
||||||
// Get countdown time
|
// Get countdown time
|
||||||
var countDownDate = new Date($(this).data('countdown')).getTime();
|
var countDownDate = new Date( $( this ).data( 'countdown' ) ).getTime();
|
||||||
// Iterate every second
|
// Iterate every second
|
||||||
var x = setInterval(function() {
|
var x = setInterval(
|
||||||
|
function() {
|
||||||
|
|
||||||
// Get todays date and time
|
// Get todays date and time
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
|
|
||||||
// Convert curent date and time to UTC
|
// Convert curent date and time to UTC
|
||||||
var tzDifference = now.getTimezoneOffset();
|
var tzDifference = now.getTimezoneOffset();
|
||||||
var nowutc = new Date(now.getTime() + tzDifference * 60 * 1000);
|
var nowutc = new Date( now.getTime() + tzDifference * 60 * 1000 );
|
||||||
|
|
||||||
// Find the distance between now and the count down date
|
// Find the distance between now and the count down date
|
||||||
var distance = countDownDate - nowutc;
|
var distance = countDownDate - nowutc;
|
||||||
@@ -36,34 +38,43 @@ function sp_viewport() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Time calculations for days, hours, minutes and seconds
|
// Time calculations for days, hours, minutes and seconds
|
||||||
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
var days = Math.floor( distance / (1000 * 60 * 60 * 24) );
|
||||||
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
var hours = Math.floor( (distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) );
|
||||||
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
var minutes = Math.floor( (distance % (1000 * 60 * 60)) / (1000 * 60) );
|
||||||
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
var seconds = Math.floor( (distance % (1000 * 60)) / 1000 );
|
||||||
|
|
||||||
// Output the result
|
// Output the result
|
||||||
$this.html("<span>"+(days < 10 ? '0' + days : days)+" <small>" + localized_strings.days + "</small></span> "
|
$this.html(
|
||||||
+ "<span>"+('0' + hours).slice(-2)+" <small>" + localized_strings.hrs + "</small></span> "
|
"<span>" + (days < 10 ? '0' + days : days) + " <small>" + localized_strings.days + "</small></span> "
|
||||||
+ "<span>"+('0' + minutes).slice(-2)+" <small>" + localized_strings.mins + "</small></span> "
|
+ "<span>" + ('0' + hours).slice( -2 ) + " <small>" + localized_strings.hrs + "</small></span> "
|
||||||
+ "<span>"+('0' + seconds).slice(-2)+" <small>" + localized_strings.secs + "</small></span>" );
|
+ "<span>" + ('0' + minutes).slice( -2 ) + " <small>" + localized_strings.mins + "</small></span> "
|
||||||
}, 1000);
|
+ "<span>" + ('0' + seconds).slice( -2 ) + " <small>" + localized_strings.secs + "</small></span>"
|
||||||
});
|
);
|
||||||
|
},
|
||||||
|
1000
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/* Scrollable Tables */
|
/* Scrollable Tables */
|
||||||
$(".sp-scrollable-table").wrap("<div class=\"sp-scrollable-table-wrapper\"></div>");
|
$( ".sp-scrollable-table" ).wrap( "<div class=\"sp-scrollable-table-wrapper\"></div>" );
|
||||||
|
|
||||||
/* Selector Redirect */
|
/* Selector Redirect */
|
||||||
$(".sp-selector-redirect").change(function() {
|
$( ".sp-selector-redirect" ).change(
|
||||||
window.location = $(this).val();
|
function() {
|
||||||
});
|
window.location = $( this ).val();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/* Template Tabs */
|
/* Template Tabs */
|
||||||
$(".sp-tab-menu-item a").click(function() {
|
$( ".sp-tab-menu-item a" ).click(
|
||||||
$template = $(this).data("sp-tab");
|
function() {
|
||||||
$(this).closest(".sp-tab-menu-item").addClass("sp-tab-menu-item-active").siblings(".sp-tab-menu-item").removeClass("sp-tab-menu-item-active");
|
$template = $( this ).data( "sp-tab" );
|
||||||
$(this).closest(".sp-tab-group").find(".sp-tab-content-"+$template).show().siblings(".sp-tab-content").hide();
|
$( 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;
|
return false;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/* API method to get paging information */
|
/* API method to get paging information */
|
||||||
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
|
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
|
||||||
@@ -82,14 +93,20 @@ function sp_viewport() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Data Tables */
|
/* Data Tables */
|
||||||
$(".sp-data-table").each(function() {
|
$( ".sp-data-table" ).each(
|
||||||
sortable = $(this).hasClass("sp-sortable-table");
|
function() {
|
||||||
paginated = $(this).hasClass("sp-paginated-table");
|
sortable = $( this ).hasClass( "sp-sortable-table" );
|
||||||
display_length = parseInt($(this).attr("data-sp-rows"));
|
paginated = $( this ).hasClass( "sp-paginated-table" );
|
||||||
if ( display_length == undefined || isNaN( display_length ) ) display_length = 10;
|
display_length = parseInt( $( this ).attr( "data-sp-rows" ) );
|
||||||
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 ) {
|
if ( sortable || paginated ) {
|
||||||
$(this).dataTable({
|
$( this ).dataTable(
|
||||||
|
{
|
||||||
"order": [],
|
"order": [],
|
||||||
"autoWidth": false,
|
"autoWidth": false,
|
||||||
"searching": false,
|
"searching": false,
|
||||||
@@ -112,8 +129,10 @@ function sp_viewport() {
|
|||||||
"columnDefs": [
|
"columnDefs": [
|
||||||
{ "type": "num-fmt", "targets": [ ".data-number", ".data-rank" ] },
|
{ "type": "num-fmt", "targets": [ ".data-number", ".data-rank" ] },
|
||||||
]
|
]
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
})(jQuery);
|
})( jQuery );
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.5
|
* @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 ) ) {
|
if ( 'sp_calendar' !== get_post_type( $post ) ) {
|
||||||
wp_die( __( 'ERROR: This is not a valid feed template.', 'sportspress' ), '', array( 'response' => 404 ) );
|
wp_die( __( 'ERROR: This is not a valid feed template.', 'sportspress' ), '', array( 'response' => 404 ) );
|
||||||
@@ -29,41 +31,43 @@ $timezone = sanitize_option( 'timezone_string', get_option( 'timezone_string' )
|
|||||||
|
|
||||||
// Get the URL
|
// Get the URL
|
||||||
$url = add_query_arg( 'feed', 'sp-ical', get_post_permalink( $post ) );
|
$url = add_query_arg( 'feed', 'sp-ical', get_post_permalink( $post ) );
|
||||||
$url = wordwrap( $url , 60, "\r\n\t", true );
|
$url = wordwrap( $url, 60, "\r\n\t", true );
|
||||||
|
|
||||||
$output =
|
$output =
|
||||||
"BEGIN:VCALENDAR\r\n" .
|
"BEGIN:VCALENDAR\r\n" .
|
||||||
"VERSION:2.0\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" .
|
"CALSCALE:GREGORIAN\r\n" .
|
||||||
"METHOD:PUBLISH\r\n" .
|
"METHOD:PUBLISH\r\n" .
|
||||||
"URL:" . $url . "\r\n" .
|
'URL:' . $url . "\r\n" .
|
||||||
"X-FROM-URL:" . $url . "\r\n" .
|
'X-FROM-URL:' . $url . "\r\n" .
|
||||||
"NAME:" . $post->post_title . "\r\n" .
|
'NAME:' . $post->post_title . "\r\n" .
|
||||||
"X-WR-CALNAME:" . $post->post_title . "\r\n" .
|
'X-WR-CALNAME:' . $post->post_title . "\r\n" .
|
||||||
"DESCRIPTION:" . $post->post_title . "\r\n" .
|
'DESCRIPTION:' . $post->post_title . "\r\n" .
|
||||||
"X-WR-CALDESC:" . $post->post_title . "\r\n" .
|
'X-WR-CALDESC:' . $post->post_title . "\r\n" .
|
||||||
"REFRESH-INTERVAL;VALUE=DURATION:PT2M\r\n" .
|
"REFRESH-INTERVAL;VALUE=DURATION:PT2M\r\n" .
|
||||||
"X-PUBLISHED-TTL:PT2M\r\n" .
|
"X-PUBLISHED-TTL:PT2M\r\n" .
|
||||||
"TZID:" . $timezone . "\r\n" .
|
'TZID:' . $timezone . "\r\n" .
|
||||||
"X-WR-TIMEZONE:" . $timezone . "\r\n";
|
'X-WR-TIMEZONE:' . $timezone . "\r\n";
|
||||||
|
|
||||||
// Loop through each event
|
// Loop through each event
|
||||||
foreach ( $events as $event):
|
foreach ( $events as $event ) :
|
||||||
|
|
||||||
// Define date format
|
// Define date format
|
||||||
$date_format = 'Ymd\THis';
|
$date_format = 'Ymd\THis';
|
||||||
|
|
||||||
// Get description
|
// Get description
|
||||||
$description = preg_replace( '/([\,;])/','\\\$1', $event->post_content );
|
$description = preg_replace( '/([\,;])/', '\\\$1', $event->post_content );
|
||||||
$description = wordwrap( $description , 60, "\n\t" );
|
$description = wordwrap( $description, 60, "\n\t" );
|
||||||
|
|
||||||
// Initialize end time
|
// Initialize end time
|
||||||
$end = new DateTime( $event->post_date );
|
$end = new DateTime( $event->post_date );
|
||||||
|
|
||||||
// Get full time minutes
|
// Get full time minutes
|
||||||
$minutes = get_post_meta( $event->ID, 'sp_minutes', true );
|
$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
|
// Add full time minutes to end time
|
||||||
$end->add( new DateInterval( 'PT' . $minutes . 'M' ) );
|
$end->add( new DateInterval( 'PT' . $minutes . 'M' ) );
|
||||||
@@ -84,7 +88,7 @@ foreach ( $events as $event):
|
|||||||
// Add details to location
|
// Add details to location
|
||||||
$address = sp_array_value( $meta, 'sp_address', false );
|
$address = sp_array_value( $meta, 'sp_address', false );
|
||||||
if ( false !== $address ) {
|
if ( false !== $address ) {
|
||||||
$location = $venue->name . '\, ' . preg_replace('/([\,;])/','\\\$1', $address);
|
$location = $venue->name . '\, ' . preg_replace( '/([\,;])/', '\\\$1', $address );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate geo tag
|
// Generate geo tag
|
||||||
@@ -96,17 +100,19 @@ foreach ( $events as $event):
|
|||||||
$geo = false;
|
$geo = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$location = wordwrap( $location , 60, "\r\n\t" );
|
$location = wordwrap( $location, 60, "\r\n\t" );
|
||||||
|
|
||||||
// Get title or write summary based on scores
|
// Get title or write summary based on scores
|
||||||
$results = array();
|
$results = array();
|
||||||
$teams = (array)get_post_meta( $event->ID, 'sp_team', false );
|
$teams = (array) get_post_meta( $event->ID, 'sp_team', false );
|
||||||
$teams = array_filter( $teams );
|
$teams = array_filter( $teams );
|
||||||
$teams = array_unique( $teams );
|
$teams = array_unique( $teams );
|
||||||
if ( ! empty( $teams ) ) {
|
if ( ! empty( $teams ) ) {
|
||||||
$event_results = get_post_meta( $event->ID, 'sp_results', true );
|
$event_results = get_post_meta( $event->ID, 'sp_results', true );
|
||||||
foreach( $teams as $team_id ) {
|
foreach ( $teams as $team_id ) {
|
||||||
if ( ! $team_id ) continue;
|
if ( ! $team_id ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$team = get_post( $team_id );
|
$team = get_post( $team_id );
|
||||||
|
|
||||||
if ( $team ) {
|
if ( $team ) {
|
||||||
@@ -135,50 +141,56 @@ foreach ( $events as $event):
|
|||||||
$summary = $event->post_title;
|
$summary = $event->post_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Convert &#[0-9]+ entities to UTF-8
|
// 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 );
|
$summary = apply_filters( 'sportspress_ical_feed_summary', $summary, $event );
|
||||||
|
|
||||||
// Append to output string
|
// Append to output string
|
||||||
$output .=
|
$output .=
|
||||||
"BEGIN:VEVENT\r\n" .
|
"BEGIN:VEVENT\r\n" .
|
||||||
"SUMMARY:" . preg_replace( '/([\,;])/','\\\$1', $summary ) . "\r\n" .
|
'SUMMARY:' . preg_replace( '/([\,;])/', '\\\$1', $summary ) . "\r\n" .
|
||||||
"UID:$event->ID\r\n" .
|
"UID:$event->ID\r\n" .
|
||||||
"STATUS:CONFIRMED\r\n" .
|
"STATUS:CONFIRMED\r\n" .
|
||||||
"DTSTAMP:19700101T000000\r\n".
|
"DTSTAMP:19700101T000000\r\n" .
|
||||||
"DTSTART:" . mysql2date( $date_format, $event->post_date ) . "\r\n" .
|
'DTSTART:' . mysql2date( $date_format, $event->post_date ) . "\r\n" .
|
||||||
"DTEND:" . $end->format( $date_format ) . "\r\n" .
|
'DTEND:' . $end->format( $date_format ) . "\r\n" .
|
||||||
"LAST-MODIFIED:" . mysql2date( $date_format, $event->post_modified_gmt ) . "\r\n";
|
'LAST-MODIFIED:' . mysql2date( $date_format, $event->post_modified_gmt ) . "\r\n";
|
||||||
|
|
||||||
if ( $description ) {
|
if ( $description ) {
|
||||||
$output .= "DESCRIPTION:" . $description . "\r\n";
|
$output .= 'DESCRIPTION:' . $description . "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $location ) {
|
if ( $location ) {
|
||||||
$output .= "LOCATION:" . $location . "\r\n";
|
$output .= 'LOCATION:' . $location . "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $geo ) {
|
if ( $geo ) {
|
||||||
$output .= "GEO:" . $geo . "\r\n";
|
$output .= 'GEO:' . $geo . "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= "END:VEVENT\r\n";
|
$output .= "END:VEVENT\r\n";
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
// End output
|
// End output
|
||||||
$output .= "END:VCALENDAR";
|
$output .= 'END:VCALENDAR';
|
||||||
|
|
||||||
// Print headers
|
// Print headers
|
||||||
header('Content-type: text/calendar; charset=utf-8');
|
header( 'Content-type: text/calendar; charset=utf-8' );
|
||||||
|
|
||||||
// The E-Tag is not being changed when the output file is generated – Some Webdav clients do not like this and
|
// The E-Tag is not being changed when the output file is generated – Some Webdav clients do not like this and
|
||||||
// do not then 'see' that the file has changed – updates to the calendars are then not displayed to the user.
|
// do not then 'see' that the file has changed – updates to the calendars are then not displayed to the user.
|
||||||
// Props @garygomm https://wordpress.org/support/topic/calendar-feed-issue-not-updating-after-change/
|
// Props @garygomm https://wordpress.org/support/topic/calendar-feed-issue-not-updating-after-change/
|
||||||
$etag = md5($output);
|
$etag = md5( $output );
|
||||||
header('Etag:' . '"'.$etag.'"');
|
header( 'Etag:' . '"' . $etag . '"' );
|
||||||
|
|
||||||
header('Content-Disposition: inline; filename=' . $post->post_name . '.ics');
|
header( 'Content-Disposition: inline; filename=' . $post->post_name . '.ics' );
|
||||||
|
|
||||||
// Print content
|
// Print content
|
||||||
echo wp_kses_post( $output );
|
echo wp_kses_post( $output );
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ abstract class SP_Custom_Post {
|
|||||||
* @param mixed $post
|
* @param mixed $post
|
||||||
*/
|
*/
|
||||||
public function __construct( $post ) {
|
public function __construct( $post ) {
|
||||||
if ( $post instanceof WP_Post || $post instanceof SP_Custom_Post ):
|
if ( $post instanceof WP_Post || $post instanceof SP_Custom_Post ) :
|
||||||
$this->ID = absint( $post->ID );
|
$this->ID = absint( $post->ID );
|
||||||
$this->post = $post;
|
$this->post = $post;
|
||||||
else:
|
else :
|
||||||
$this->ID = absint( $post );
|
$this->ID = absint( $post );
|
||||||
$this->post = get_post( $this->ID );
|
$this->post = get_post( $this->ID );
|
||||||
endif;
|
endif;
|
||||||
@@ -53,9 +53,9 @@ abstract class SP_Custom_Post {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function __get( $key ) {
|
public function __get( $key ) {
|
||||||
if ( ! isset( $key ) ):
|
if ( ! isset( $key ) ) :
|
||||||
return $this->post;
|
return $this->post;
|
||||||
else:
|
else :
|
||||||
$value = get_post_meta( $this->ID, 'sp_' . $key, true );
|
$value = get_post_meta( $this->ID, 'sp_' . $key, true );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ abstract class SP_Secondary_Post extends SP_Custom_Post {
|
|||||||
* @param mixed $post
|
* @param mixed $post
|
||||||
*/
|
*/
|
||||||
public function __construct( $post ) {
|
public function __construct( $post ) {
|
||||||
if ( $post instanceof WP_Post || $post instanceof SP_Secondary_Post ):
|
if ( $post instanceof WP_Post || $post instanceof SP_Secondary_Post ) :
|
||||||
$this->ID = absint( $post->ID );
|
$this->ID = absint( $post->ID );
|
||||||
$this->post = $post;
|
$this->post = $post;
|
||||||
else:
|
else :
|
||||||
$this->ID = absint( $post );
|
$this->ID = absint( $post );
|
||||||
$this->post = get_post( $this->ID );
|
$this->post = get_post( $this->ID );
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class SP_Admin_AJAX {
|
|||||||
$id = sp_array_value( $_POST, 'post_id' );
|
$id = sp_array_value( $_POST, 'post_id' );
|
||||||
$results = sp_array_value( $_POST, 'results' );
|
$results = sp_array_value( $_POST, 'results' );
|
||||||
|
|
||||||
if ( sp_update_main_results ( $id, $results ) ) {
|
if ( sp_update_main_results( $id, $results ) ) {
|
||||||
wp_send_json_success();
|
wp_send_json_success();
|
||||||
} else {
|
} else {
|
||||||
wp_send_json_error();
|
wp_send_json_error();
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
* @version 2.6.15
|
* @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' ) ) :
|
if ( ! class_exists( 'SP_Admin_Assets' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Assets Class
|
* SP_Admin_Assets Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_Assets {
|
class SP_Admin_Assets {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook in tabs.
|
* Hook in tabs.
|
||||||
@@ -59,8 +61,8 @@ class SP_Admin_Assets {
|
|||||||
wp_enqueue_style( 'sportspress-admin-equation-styles', SP()->plugin_url() . '/assets/css/equation.css', array(), SP_VERSION );
|
wp_enqueue_style( 'sportspress-admin-equation-styles', SP()->plugin_url() . '/assets/css/equation.css', array(), SP_VERSION );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( in_array( $screen->id, apply_filters( 'sportspress_admin_datepicker_screen_ids', array( 'sp_calendar', 'sp_table', 'sp_list', 'widgets' ) ) ) || in_array( $hook, array('post.php', 'post-new.php') ) ) {
|
if ( in_array( $screen->id, apply_filters( 'sportspress_admin_datepicker_screen_ids', array( 'sp_calendar', 'sp_table', 'sp_list', 'widgets' ) ) ) || in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
|
||||||
wp_enqueue_style( 'jquery-ui-style' , '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css' );
|
wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css' );
|
||||||
wp_enqueue_style( 'sportspress-admin-datepicker-styles', SP()->plugin_url() . '/assets/css/datepicker.css', array( 'jquery-ui-style' ), SP_VERSION );
|
wp_enqueue_style( 'sportspress-admin-datepicker-styles', SP()->plugin_url() . '/assets/css/datepicker.css', array( 'jquery-ui-style' ), SP_VERSION );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ class SP_Admin_Assets {
|
|||||||
/**
|
/**
|
||||||
* Enqueue scripts
|
* Enqueue scripts
|
||||||
*/
|
*/
|
||||||
public function admin_scripts($hook) {
|
public function admin_scripts( $hook ) {
|
||||||
global $wp_query, $post;
|
global $wp_query, $post;
|
||||||
|
|
||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
@@ -93,7 +95,7 @@ class SP_Admin_Assets {
|
|||||||
wp_register_script( 'sportspress-admin-quickeditor', SP()->plugin_url() . '/assets/js/admin/quickeditor.js', array( 'jquery' ), SP_VERSION, true );
|
wp_register_script( 'sportspress-admin-quickeditor', SP()->plugin_url() . '/assets/js/admin/quickeditor.js', array( 'jquery' ), SP_VERSION, true );
|
||||||
|
|
||||||
// SportsPress admin pages
|
// SportsPress admin pages
|
||||||
if ( in_array( $screen->id, sp_get_screen_ids() ) || strpos( $screen->id, 'sportspress-config' ) || in_array($hook, array('post.php', 'post-new.php') ) ) {
|
if ( in_array( $screen->id, sp_get_screen_ids() ) || strpos( $screen->id, 'sportspress-config' ) || in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
|
||||||
|
|
||||||
wp_enqueue_script( 'jquery' );
|
wp_enqueue_script( 'jquery' );
|
||||||
wp_enqueue_script( 'chosen' );
|
wp_enqueue_script( 'chosen' );
|
||||||
@@ -106,15 +108,18 @@ class SP_Admin_Assets {
|
|||||||
wp_enqueue_script( 'jquery-fitvids' );
|
wp_enqueue_script( 'jquery-fitvids' );
|
||||||
wp_enqueue_script( 'sportspress-admin', SP()->plugin_url() . '/assets/js/admin/sportspress-admin.js', array( 'jquery', 'chosen', 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-tiptip', 'jquery-caret', 'jquery-fitvids' ), SP_VERSION, true );
|
wp_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' ),
|
'none' => __( 'None', 'sportspress' ),
|
||||||
'remove_text' => __( '— Remove —', 'sportspress' ),
|
'remove_text' => __( '— Remove —', 'sportspress' ),
|
||||||
'days' => __( 'days', 'sportspress' ),
|
'days' => __( 'days', 'sportspress' ),
|
||||||
'hrs' => __( 'hrs', 'sportspress' ),
|
'hrs' => __( 'hrs', 'sportspress' ),
|
||||||
'mins' => __( 'mins', 'sportspress' ),
|
'mins' => __( 'mins', 'sportspress' ),
|
||||||
'secs' => __( 'secs', '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
|
// Localize scripts
|
||||||
wp_localize_script( 'sportspress-admin', 'localized_strings', $strings );
|
wp_localize_script( 'sportspress-admin', 'localized_strings', $strings );
|
||||||
@@ -139,7 +144,7 @@ class SP_Admin_Assets {
|
|||||||
wp_enqueue_script( 'sportspress-admin-quickeditor' );
|
wp_enqueue_script( 'sportspress-admin-quickeditor' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
* @version 2.7.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' ) ) :
|
if ( ! class_exists( 'SP_Admin_Dashboard' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Dashboard Class
|
* SP_Admin_Dashboard Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_Dashboard {
|
class SP_Admin_Dashboard {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook in tabs.
|
* Hook in tabs.
|
||||||
@@ -31,7 +33,7 @@ class SP_Admin_Dashboard {
|
|||||||
* Init dashboard widgets
|
* Init dashboard widgets
|
||||||
*/
|
*/
|
||||||
public function init() {
|
public function init() {
|
||||||
//wp_add_dashboard_widget( 'sportspress_dashboard_news', __( 'Sports News', 'sportspress' ), array( $this, 'news_widget' ), null, null, 'side' );
|
// wp_add_dashboard_widget( 'sportspress_dashboard_news', __( 'Sports News', 'sportspress' ), array( $this, 'news_widget' ), null, null, 'side' );
|
||||||
wp_add_dashboard_widget( 'sportspress_dashboard_status', __( 'SportsPress', 'sportspress' ), array( $this, 'status_widget' ) );
|
wp_add_dashboard_widget( 'sportspress_dashboard_status', __( 'SportsPress', 'sportspress' ), array( $this, 'status_widget' ) );
|
||||||
add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 );
|
add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 );
|
||||||
}
|
}
|
||||||
@@ -41,17 +43,19 @@ class SP_Admin_Dashboard {
|
|||||||
*/
|
*/
|
||||||
function glance_items( $items = array() ) {
|
function glance_items( $items = array() ) {
|
||||||
$post_types = apply_filters( 'sportspress_glance_items', array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) );
|
$post_types = apply_filters( 'sportspress_glance_items', array( 'sp_event', 'sp_team', 'sp_player', 'sp_staff' ) );
|
||||||
foreach ( $post_types as $type ):
|
foreach ( $post_types as $type ) :
|
||||||
if ( ! post_type_exists( $type ) ) continue;
|
if ( ! post_type_exists( $type ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$num_posts = wp_count_posts( $type );
|
$num_posts = wp_count_posts( $type );
|
||||||
if ( $num_posts ):
|
if ( $num_posts ) :
|
||||||
$published = intval( $num_posts->publish );
|
$published = intval( $num_posts->publish );
|
||||||
$post_type = get_post_type_object( $type );
|
$post_type = get_post_type_object( $type );
|
||||||
$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'sportspress' );
|
$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'sportspress' );
|
||||||
$text = sprintf( $text, number_format_i18n( $published ) );
|
$text = sprintf( $text, number_format_i18n( $published ) );
|
||||||
if ( current_user_can( $post_type->cap->edit_posts ) ):
|
if ( current_user_can( $post_type->cap->edit_posts ) ) :
|
||||||
$output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $text . '</a>';
|
$output = '<a href="edit.php?post_type=' . $post_type->name . '">' . $text . '</a>';
|
||||||
else:
|
else :
|
||||||
$output = '<span>' . $text . '</span>';
|
$output = '<span>' . $text . '</span>';
|
||||||
endif;
|
endif;
|
||||||
echo '<li class="post-count ' . eac_attr( $post_type->name ) . '-count">' . esc_html( $output ) . '</li>';
|
echo '<li class="post-count ' . eac_attr( $post_type->name ) . '-count">' . esc_html( $output ) . '</li>';
|
||||||
@@ -71,7 +75,7 @@ class SP_Admin_Dashboard {
|
|||||||
$scheduled_count = isset( $count->future ) ? $count->future : 0;
|
$scheduled_count = isset( $count->future ) ? $count->future : 0;
|
||||||
$published_count = isset( $count->publish ) ? $count->publish : 0;
|
$published_count = isset( $count->publish ) ? $count->publish : 0;
|
||||||
$next_event = sp_get_next_event();
|
$next_event = sp_get_next_event();
|
||||||
if ( $next_event ):
|
if ( $next_event ) :
|
||||||
$now = new DateTime( current_time( 'mysql', 0 ) );
|
$now = new DateTime( current_time( 'mysql', 0 ) );
|
||||||
$date = new DateTime( $next_event->post_date );
|
$date = new DateTime( $next_event->post_date );
|
||||||
$interval = date_diff( $now, $date );
|
$interval = date_diff( $now, $date );
|
||||||
@@ -101,26 +105,26 @@ class SP_Admin_Dashboard {
|
|||||||
* Show news widget
|
* Show news widget
|
||||||
*/
|
*/
|
||||||
public function 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
|
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.
|
// Figure out how many total items there are, but limit it to 2.
|
||||||
$maxitems = $rss->get_item_quantity(5);
|
$maxitems = $rss->get_item_quantity( 5 );
|
||||||
// Build an array of all the items, starting with element 0 (first element).
|
// Build an array of all the items, starting with element 0 (first element).
|
||||||
$rss_items = $rss->get_items(0, $maxitems);
|
$rss_items = $rss->get_items( 0, $maxitems );
|
||||||
}
|
}
|
||||||
if (!empty($maxitems)) {
|
if ( ! empty( $maxitems ) ) {
|
||||||
?>
|
?>
|
||||||
<div class="rss-widget">
|
<div class="rss-widget">
|
||||||
<ul>
|
<ul>
|
||||||
<?php foreach ($rss_items as $item) { ?>
|
<?php foreach ( $rss_items as $item ) { ?>
|
||||||
<li><a class="rsswidget" href="<?php echo esc_url( $item->get_permalink() ); ?>" target="_blank"><?php echo esc_attr( $item->get_title() ); ?></a> <span class="rss-date"><?php echo esc_html( $item->get_date('j F Y') ); ?></span></li>
|
<li><a class="rsswidget" href="<?php echo esc_url( $item->get_permalink() ); ?>" target="_blank"><?php echo esc_attr( $item->get_title() ); ?></a> <span class="rss-date"><?php echo esc_html( $item->get_date( 'j F Y' ) ); ?></span></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
* @category Admin
|
* @category Admin
|
||||||
* @package SportsPress/Admin
|
* @package SportsPress/Admin
|
||||||
* @version 2.4
|
* @version 2.4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit; // Exit if accessed directly
|
exit; // Exit if accessed directly
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
* @version 2.5.1
|
* @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' ) ) :
|
if ( ! class_exists( 'SP_Admin_Importers' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Importers Class
|
* SP_Admin_Importers Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_Importers {
|
class SP_Admin_Importers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook in tabs.
|
* Hook in tabs.
|
||||||
@@ -29,33 +31,36 @@ class SP_Admin_Importers {
|
|||||||
*/
|
*/
|
||||||
public function register_importers() {
|
public function register_importers() {
|
||||||
global $pagenow;
|
global $pagenow;
|
||||||
$importers = apply_filters( 'sportspress_importers', array(
|
$importers = apply_filters(
|
||||||
|
'sportspress_importers',
|
||||||
|
array(
|
||||||
'sp_event_csv' => array(
|
'sp_event_csv' => array(
|
||||||
'name' => __( 'SportsPress Events (CSV)', 'sportspress' ),
|
'name' => __( 'SportsPress Events (CSV)', 'sportspress' ),
|
||||||
'description' => __( 'Import <strong>events</strong> from a csv file.', 'sportspress'),
|
'description' => __( 'Import <strong>events</strong> from a csv file.', 'sportspress' ),
|
||||||
'callback' => array( $this, 'events_importer' ),
|
'callback' => array( $this, 'events_importer' ),
|
||||||
),
|
),
|
||||||
'sp_fixture_csv' => array(
|
'sp_fixture_csv' => array(
|
||||||
'name' => __( 'SportsPress Fixtures (CSV)', 'sportspress' ),
|
'name' => __( 'SportsPress Fixtures (CSV)', 'sportspress' ),
|
||||||
'description' => __( 'Import <strong>upcoming events</strong> from a csv file.', 'sportspress'),
|
'description' => __( 'Import <strong>upcoming events</strong> from a csv file.', 'sportspress' ),
|
||||||
'callback' => array( $this, 'fixtures_importer' ),
|
'callback' => array( $this, 'fixtures_importer' ),
|
||||||
),
|
),
|
||||||
'sp_team_csv' => array(
|
'sp_team_csv' => array(
|
||||||
'name' => __( 'SportsPress Teams (CSV)', 'sportspress' ),
|
'name' => __( 'SportsPress Teams (CSV)', 'sportspress' ),
|
||||||
'description' => __( 'Import <strong>teams</strong> from a csv file.', 'sportspress'),
|
'description' => __( 'Import <strong>teams</strong> from a csv file.', 'sportspress' ),
|
||||||
'callback' => array( $this, 'teams_importer' ),
|
'callback' => array( $this, 'teams_importer' ),
|
||||||
),
|
),
|
||||||
'sp_player_csv' => array(
|
'sp_player_csv' => array(
|
||||||
'name' => __( 'SportsPress Players (CSV)', 'sportspress' ),
|
'name' => __( 'SportsPress Players (CSV)', 'sportspress' ),
|
||||||
'description' => __( 'Import <strong>players</strong> from a csv file.', 'sportspress'),
|
'description' => __( 'Import <strong>players</strong> from a csv file.', 'sportspress' ),
|
||||||
'callback' => array( $this, 'players_importer' ),
|
'callback' => array( $this, 'players_importer' ),
|
||||||
),
|
),
|
||||||
'sp_staff_csv' => array(
|
'sp_staff_csv' => array(
|
||||||
'name' => __( 'SportsPress Staff (CSV)', 'sportspress' ),
|
'name' => __( 'SportsPress Staff (CSV)', 'sportspress' ),
|
||||||
'description' => __( 'Import <strong>staff</strong> from a csv file.', 'sportspress'),
|
'description' => __( 'Import <strong>staff</strong> from a csv file.', 'sportspress' ),
|
||||||
'callback' => array( $this, 'staff_importer' ),
|
'callback' => array( $this, 'staff_importer' ),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if ( 'import.php' !== $pagenow ) {
|
if ( 'import.php' !== $pagenow ) {
|
||||||
$importers['sp_event_performance_csv'] = array(
|
$importers['sp_event_performance_csv'] = array(
|
||||||
@@ -154,13 +159,14 @@ class SP_Admin_Importers {
|
|||||||
|
|
||||||
if ( ! class_exists( 'WP_Importer' ) ) {
|
if ( ! class_exists( 'WP_Importer' ) ) {
|
||||||
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
|
$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 $class_wp_importer;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
require 'importers/class-sp-importer.php';
|
require 'importers/class-sp-importer.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
* @version 2.7.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' ) ) :
|
if ( ! class_exists( 'SP_Admin_Menus' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Menus Class
|
* SP_Admin_Menus Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_Menus {
|
class SP_Admin_Menus {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook in tabs.
|
* Hook in tabs.
|
||||||
@@ -41,8 +43,9 @@ class SP_Admin_Menus {
|
|||||||
public function admin_menu() {
|
public function admin_menu() {
|
||||||
global $menu;
|
global $menu;
|
||||||
|
|
||||||
if ( current_user_can( 'manage_sportspress' ) )
|
if ( current_user_can( 'manage_sportspress' ) ) {
|
||||||
$menu[] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator 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' );
|
$main_page = add_menu_page( __( 'SportsPress', 'sportspress' ), __( 'SportsPress', 'sportspress' ), 'manage_sportspress', 'sportspress', array( $this, 'settings_page' ), apply_filters( 'sportspress_menu_icon', null ), '51.5' );
|
||||||
}
|
}
|
||||||
@@ -58,14 +61,14 @@ class SP_Admin_Menus {
|
|||||||
* Add menu item
|
* Add menu item
|
||||||
*/
|
*/
|
||||||
public function leagues_menu() {
|
public function leagues_menu() {
|
||||||
add_submenu_page( 'sportspress', __( 'Leagues', 'sportspress' ), __( 'Leagues', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_league');
|
add_submenu_page( 'sportspress', __( 'Leagues', 'sportspress' ), __( 'Leagues', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_league' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add menu item
|
* Add menu item
|
||||||
*/
|
*/
|
||||||
public function seasons_menu() {
|
public function seasons_menu() {
|
||||||
add_submenu_page( 'sportspress', __( 'Seasons', 'sportspress' ), __( 'Seasons', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_season');
|
add_submenu_page( 'sportspress', __( 'Seasons', 'sportspress' ), __( 'Seasons', 'sportspress' ), 'manage_sportspress', 'edit-tags.php?taxonomy=sp_season' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,7 +80,9 @@ class SP_Admin_Menus {
|
|||||||
public function menu_highlight() {
|
public function menu_highlight() {
|
||||||
global $typenow;
|
global $typenow;
|
||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
if ( ! is_object( $screen ) ) return;
|
if ( ! is_object( $screen ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( $screen->id == 'sp_role' ) {
|
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' );
|
$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 ) ) {
|
} elseif ( is_sp_config_type( $typenow ) ) {
|
||||||
@@ -100,15 +105,17 @@ class SP_Admin_Menus {
|
|||||||
public function menu_rename() {
|
public function menu_rename() {
|
||||||
global $menu, $submenu;
|
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' );
|
$submenu['sportspress'][0][0] = __( 'Settings', 'sportspress' );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function parent_file( $parent_file ) {
|
public function parent_file( $parent_file ) {
|
||||||
global $current_screen;
|
global $current_screen;
|
||||||
$taxonomy = $current_screen->taxonomy;
|
$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';
|
$parent_file = 'sportspress';
|
||||||
|
}
|
||||||
return $parent_file;
|
return $parent_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,9 +139,9 @@ class SP_Admin_Menus {
|
|||||||
$sportspress_staff = array_search( 'edit.php?post_type=sp_staff', $menu_order );
|
$sportspress_staff = array_search( 'edit.php?post_type=sp_staff', $menu_order );
|
||||||
|
|
||||||
// Loop through menu order and do some rearranging
|
// Loop through menu order and do some rearranging
|
||||||
foreach ( $menu_order as $index => $item ):
|
foreach ( $menu_order as $index => $item ) :
|
||||||
|
|
||||||
if ( ( ( 'sportspress' ) == $item ) ):
|
if ( ( ( 'sportspress' ) == $item ) ) :
|
||||||
$sportspress_menu_order[] = 'separator-sportspress';
|
$sportspress_menu_order[] = 'separator-sportspress';
|
||||||
$sportspress_menu_order[] = $item;
|
$sportspress_menu_order[] = $item;
|
||||||
$sportspress_menu_order[] = 'edit.php?post_type=sp_event';
|
$sportspress_menu_order[] = 'edit.php?post_type=sp_event';
|
||||||
@@ -149,13 +156,13 @@ class SP_Admin_Menus {
|
|||||||
|
|
||||||
// Apply to added menu items
|
// Apply to added menu items
|
||||||
$menu_items = apply_filters( 'sportspress_menu_items', array() );
|
$menu_items = apply_filters( 'sportspress_menu_items', array() );
|
||||||
foreach ( $menu_items as $menu_item ):
|
foreach ( $menu_items as $menu_item ) :
|
||||||
$sportspress_menu_order[] = $menu_item;
|
$sportspress_menu_order[] = $menu_item;
|
||||||
$index = array_search( $menu_item, $menu_order );
|
$index = array_search( $menu_item, $menu_order );
|
||||||
unset( $menu_order[ $index ] );
|
unset( $menu_order[ $index ] );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
elseif ( !in_array( $item, array( 'separator-sportspress' ) ) ) :
|
elseif ( ! in_array( $item, array( 'separator-sportspress' ) ) ) :
|
||||||
$sportspress_menu_order[] = $item;
|
$sportspress_menu_order[] = $item;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -167,11 +174,13 @@ class SP_Admin_Menus {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* custom_menu_order
|
* custom_menu_order
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function custom_menu_order() {
|
public function custom_menu_order() {
|
||||||
if ( ! current_user_can( 'manage_sportspress' ) )
|
if ( ! current_user_can( 'manage_sportspress' ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,45 +191,46 @@ class SP_Admin_Menus {
|
|||||||
global $menu, $submenu, $current_user;
|
global $menu, $submenu, $current_user;
|
||||||
|
|
||||||
// Find where our separator is in the menu
|
// Find where our separator is in the menu
|
||||||
foreach( $menu as $key => $data ):
|
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;
|
$separator_position = $key;
|
||||||
|
}
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
// Swap our separator post type with a menu separator
|
// Swap our separator post type with a menu separator
|
||||||
if ( isset( $separator_position ) ):
|
if ( isset( $separator_position ) ) :
|
||||||
$menu[ $separator_position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
|
$menu[ $separator_position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Remove "Leagues" and "Seasons" links from Events submenu
|
// Remove "Leagues" and "Seasons" links from Events submenu
|
||||||
if ( isset( $submenu['edit.php?post_type=sp_event'] ) ):
|
if ( isset( $submenu['edit.php?post_type=sp_event'] ) ) :
|
||||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_leagues' ) );
|
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_leagues' ) );
|
||||||
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_seasons' ) );
|
$submenu['edit.php?post_type=sp_event'] = array_filter( $submenu['edit.php?post_type=sp_event'], array( $this, 'remove_seasons' ) );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Remove "Venues", "Leagues" and "Seasons" links from Teams submenu
|
// Remove "Venues", "Leagues" and "Seasons" links from Teams submenu
|
||||||
if ( isset( $submenu['edit.php?post_type=sp_team'] ) ):
|
if ( isset( $submenu['edit.php?post_type=sp_team'] ) ) :
|
||||||
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_venues' ) );
|
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_venues' ) );
|
||||||
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_leagues' ) );
|
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_leagues' ) );
|
||||||
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_seasons' ) );
|
$submenu['edit.php?post_type=sp_team'] = array_filter( $submenu['edit.php?post_type=sp_team'], array( $this, 'remove_seasons' ) );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Remove "Leagues" and "Seasons" links from Players submenu
|
// Remove "Leagues" and "Seasons" links from Players submenu
|
||||||
if ( isset( $submenu['edit.php?post_type=sp_player'] ) ):
|
if ( isset( $submenu['edit.php?post_type=sp_player'] ) ) :
|
||||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_leagues' ) );
|
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_leagues' ) );
|
||||||
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_seasons' ) );
|
$submenu['edit.php?post_type=sp_player'] = array_filter( $submenu['edit.php?post_type=sp_player'], array( $this, 'remove_seasons' ) );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Remove "Leagues" and "Seasons" links from Staff submenu
|
// Remove "Leagues" and "Seasons" links from Staff submenu
|
||||||
if ( isset( $submenu['edit.php?post_type=sp_staff'] ) ):
|
if ( isset( $submenu['edit.php?post_type=sp_staff'] ) ) :
|
||||||
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_leagues' ) );
|
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_leagues' ) );
|
||||||
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_seasons' ) );
|
$submenu['edit.php?post_type=sp_staff'] = array_filter( $submenu['edit.php?post_type=sp_staff'], array( $this, 'remove_seasons' ) );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$user_roles = $current_user->roles;
|
$user_roles = $current_user->roles;
|
||||||
$user_role = array_shift($user_roles);
|
$user_role = array_shift( $user_roles );
|
||||||
|
|
||||||
if ( in_array( $user_role, array( 'sp_player', 'sp_staff', 'sp_event_manager', 'sp_team_manager' ) ) ):
|
if ( in_array( $user_role, array( 'sp_player', 'sp_staff', 'sp_event_manager', 'sp_team_manager' ) ) ) :
|
||||||
remove_menu_page( 'upload.php' );
|
remove_menu_page( 'upload.php' );
|
||||||
remove_menu_page( 'edit-comments.php' );
|
remove_menu_page( 'edit-comments.php' );
|
||||||
remove_menu_page( 'tools.php' );
|
remove_menu_page( 'tools.php' );
|
||||||
@@ -231,14 +241,14 @@ class SP_Admin_Menus {
|
|||||||
* Init the config page
|
* Init the config page
|
||||||
*/
|
*/
|
||||||
public function config_page() {
|
public function config_page() {
|
||||||
include( 'views/html-admin-config.php' );
|
include 'views/html-admin-config.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init the settings page
|
* Init the settings page
|
||||||
*/
|
*/
|
||||||
public function settings_page() {
|
public function settings_page() {
|
||||||
include_once( 'class-sp-admin-settings.php' );
|
include_once 'class-sp-admin-settings.php';
|
||||||
SP_Admin_Settings::output();
|
SP_Admin_Settings::output();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,13 +281,13 @@ class SP_Admin_Menus {
|
|||||||
public static function sitemap_taxonomy_post_types( $post_types = array(), $taxonomy = 'sp_venue' ) {
|
public static function sitemap_taxonomy_post_types( $post_types = array(), $taxonomy = 'sp_venue' ) {
|
||||||
$post_types = array_intersect( $post_types, sp_primary_post_types() );
|
$post_types = array_intersect( $post_types, sp_primary_post_types() );
|
||||||
// Remove teams from venues taxonomy post type array
|
// Remove teams from venues taxonomy post type array
|
||||||
if ( $taxonomy === 'sp_venue' && ( $key = array_search( 'sp_team', $post_types ) ) !== false ):
|
if ( $taxonomy === 'sp_venue' && ( $key = array_search( 'sp_team', $post_types ) ) !== false ) :
|
||||||
unset( $post_types[ $key ] );
|
unset( $post_types[ $key ] );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
return $post_types;
|
return $post_types;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
* @version 2.3
|
* @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' ) ) :
|
if ( ! class_exists( 'SP_Admin_Notices' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Notices Class
|
* SP_Admin_Notices Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_Notices {
|
class SP_Admin_Notices {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook in tabs.
|
* Hook in tabs.
|
||||||
@@ -40,7 +42,9 @@ class SP_Admin_Notices {
|
|||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
$notices = get_option( 'sportspress_admin_notices', array() );
|
$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' ) ) ) {
|
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 ) );
|
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
|
* Show the setup notices
|
||||||
*/
|
*/
|
||||||
public function setup_notice() {
|
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
|
* Displays a notice when the user doesn't have access to edit a post type
|
||||||
*/
|
*/
|
||||||
public function no_access_notice() {
|
public function no_access_notice() {
|
||||||
include( 'views/html-notice-no-access.php' );
|
include 'views/html-notice-no-access.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the Theme Check notice
|
* Show the Theme Check notice
|
||||||
*/
|
*/
|
||||||
public function 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;
|
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' );
|
$core_templates = $status->scan_template_files( SP()->plugin_path() . '/templates' );
|
||||||
$outdated = false;
|
$outdated = false;
|
||||||
|
|
||||||
@@ -120,7 +124,7 @@ class SP_Admin_Notices {
|
|||||||
$theme_file = get_stylesheet_directory() . '/sportspress/' . $file;
|
$theme_file = get_stylesheet_directory() . '/sportspress/' . $file;
|
||||||
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
|
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
|
||||||
$theme_file = get_template_directory() . '/' . $file;
|
$theme_file = get_template_directory() . '/' . $file;
|
||||||
} elseif( file_exists( get_template_directory() . '/sportspress/' . $file ) ) {
|
} elseif ( file_exists( get_template_directory() . '/sportspress/' . $file ) ) {
|
||||||
$theme_file = get_template_directory() . '/sportspress/' . $file;
|
$theme_file = get_template_directory() . '/sportspress/' . $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,10 +140,10 @@ class SP_Admin_Notices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( $outdated ) {
|
if ( $outdated ) {
|
||||||
include( 'views/html-notice-template-check.php' );
|
include 'views/html-notice-template-check.php';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,20 +8,24 @@
|
|||||||
* @version 2.7.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' ) ) :
|
if ( ! class_exists( 'SP_Admin_Permalink_Settings' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Permalink_Settings Class
|
* SP_Admin_Permalink_Settings Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_Permalink_Settings {
|
class SP_Admin_Permalink_Settings {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook in tabs.
|
* Hook in tabs.
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->slugs = apply_filters( 'sportspress_permalink_slugs', array(
|
$this->slugs = apply_filters(
|
||||||
|
'sportspress_permalink_slugs',
|
||||||
|
array(
|
||||||
array( 'event', __( 'Events', 'sportspress' ) ),
|
array( 'event', __( 'Events', 'sportspress' ) ),
|
||||||
array( 'venue', __( 'Venues', 'sportspress' ) ),
|
array( 'venue', __( 'Venues', 'sportspress' ) ),
|
||||||
array( 'calendar', __( 'Calendars', 'sportspress' ) ),
|
array( 'calendar', __( 'Calendars', 'sportspress' ) ),
|
||||||
@@ -33,7 +37,8 @@ class SP_Admin_Permalink_Settings {
|
|||||||
array( 'position', __( 'Positions', 'sportspress' ) ),
|
array( 'position', __( 'Positions', 'sportspress' ) ),
|
||||||
array( 'list', __( 'Player Lists', 'sportspress' ) ),
|
array( 'list', __( 'Player Lists', 'sportspress' ) ),
|
||||||
array( 'staff', __( 'Staff', 'sportspress' ) ),
|
array( 'staff', __( 'Staff', 'sportspress' ) ),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
add_action( 'admin_init', array( $this, 'settings_init' ) );
|
add_action( 'admin_init', array( $this, 'settings_init' ) );
|
||||||
add_action( 'admin_init', array( $this, 'settings_save' ) );
|
add_action( 'admin_init', array( $this, 'settings_save' ) );
|
||||||
@@ -47,7 +52,7 @@ class SP_Admin_Permalink_Settings {
|
|||||||
add_settings_section( 'sportspress-permalink', __( 'SportsPress', 'sportspress' ), array( $this, 'settings' ), 'permalink' );
|
add_settings_section( 'sportspress-permalink', __( 'SportsPress', 'sportspress' ), array( $this, 'settings' ), 'permalink' );
|
||||||
|
|
||||||
// Add our settings
|
// Add our settings
|
||||||
foreach ( $this->slugs as $slug ):
|
foreach ( $this->slugs as $slug ) :
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
$slug[0], // id
|
$slug[0], // id
|
||||||
$slug[1], // setting title
|
$slug[1], // setting title
|
||||||
@@ -65,7 +70,8 @@ class SP_Admin_Permalink_Settings {
|
|||||||
$slug = array_shift( $this->slugs );
|
$slug = array_shift( $this->slugs );
|
||||||
$key = $slug[0];
|
$key = $slug[0];
|
||||||
$text = get_option( 'sportspress_' . $key . '_slug', null );
|
$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,24 +85,27 @@ class SP_Admin_Permalink_Settings {
|
|||||||
* Save the settings
|
* Save the settings
|
||||||
*/
|
*/
|
||||||
public function settings_save() {
|
public function settings_save() {
|
||||||
if ( ! is_admin() )
|
if ( ! is_admin() ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['sportspress_event_slug'] ) ):
|
if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['sportspress_event_slug'] ) ) :
|
||||||
foreach ( $this->slugs as $slug ):
|
foreach ( $this->slugs as $slug ) :
|
||||||
$key = 'sportspress_' . $slug[0] . '_slug';
|
$key = 'sportspress_' . $slug[0] . '_slug';
|
||||||
$value = null;
|
$value = null;
|
||||||
if ( isset( $_POST[ $key ] ) )
|
if ( isset( $_POST[ $key ] ) ) {
|
||||||
$value = sanitize_text_field( $_POST[ $key ] );
|
$value = sanitize_text_field( $_POST[ $key ] );
|
||||||
if ( empty( $value ) )
|
}
|
||||||
|
if ( empty( $value ) ) {
|
||||||
delete_option( $key );
|
delete_option( $key );
|
||||||
else
|
} else {
|
||||||
update_option( $key, $value );
|
update_option( $key, $value );
|
||||||
|
}
|
||||||
endforeach;
|
endforeach;
|
||||||
sp_flush_rewrite_rules();
|
sp_flush_rewrite_rules();
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
* @version 2.0
|
* @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' ) ) :
|
if ( ! class_exists( 'SP_Admin_Post_Types' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Post_Types Class
|
* SP_Admin_Post_Types Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_Post_Types {
|
class SP_Admin_Post_Types {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -31,17 +33,17 @@ class SP_Admin_Post_Types {
|
|||||||
* Conditonally load classes and functions only needed when viewing a post type.
|
* Conditonally load classes and functions only needed when viewing a post type.
|
||||||
*/
|
*/
|
||||||
public function include_post_type_handlers() {
|
public function include_post_type_handlers() {
|
||||||
include_once( 'post-types/class-sp-admin-meta-boxes.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-result.php';
|
||||||
include_once( 'post-types/class-sp-admin-cpt-outcome.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-performance.php';
|
||||||
include_once( 'post-types/class-sp-admin-cpt-column.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-metric.php';
|
||||||
include_once( 'post-types/class-sp-admin-cpt-statistic.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-event.php';
|
||||||
include_once( 'post-types/class-sp-admin-cpt-team.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-player.php';
|
||||||
include_once( 'post-types/class-sp-admin-cpt-staff.php' );
|
include_once 'post-types/class-sp-admin-cpt-staff.php';
|
||||||
do_action( 'sportspress_include_post_type_handlers' );
|
do_action( 'sportspress_include_post_type_handlers' );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,9 +54,9 @@ class SP_Admin_Post_Types {
|
|||||||
$post_types = sp_post_types();
|
$post_types = sp_post_types();
|
||||||
$config_types = sp_config_types();
|
$config_types = sp_config_types();
|
||||||
$post_type = get_post_type( $post_id );
|
$post_type = get_post_type( $post_id );
|
||||||
if ( in_array( $post_type, $post_types ) ):
|
if ( in_array( $post_type, $post_types ) ) :
|
||||||
delete_post_meta( $post_id, '_sp_sample' );
|
delete_post_meta( $post_id, '_sp_sample' );
|
||||||
elseif ( in_array( $post_type, $config_types ) ):
|
elseif ( in_array( $post_type, $config_types ) ) :
|
||||||
delete_post_meta( $post_id, '_sp_preset' );
|
delete_post_meta( $post_id, '_sp_preset' );
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
@@ -68,39 +70,41 @@ class SP_Admin_Post_Types {
|
|||||||
public function post_updated_messages( $messages ) {
|
public function post_updated_messages( $messages ) {
|
||||||
global $typenow, $post;
|
global $typenow, $post;
|
||||||
|
|
||||||
if ( is_sp_config_type( $typenow ) ):
|
if ( is_sp_config_type( $typenow ) ) :
|
||||||
$obj = get_post_type_object( $typenow );
|
$obj = get_post_type_object( $typenow );
|
||||||
|
|
||||||
for ( $i = 0; $i <= 10; $i++ ):
|
for ( $i = 0; $i <= 10; $i++ ) :
|
||||||
$messages['post'][ $i ] = __( 'Settings saved.', 'sportspress' ) .
|
$messages['post'][ $i ] = __( 'Settings saved.', 'sportspress' ) .
|
||||||
' <a href="' . esc_url( admin_url( 'edit.php?post_type=' . $typenow ) ) . '">' .
|
' <a href="' . esc_url( admin_url( 'edit.php?post_type=' . $typenow ) ) . '">' .
|
||||||
__( 'View All', 'sportspress' ) . '</a>';
|
__( 'View All', 'sportspress' ) . '</a>';
|
||||||
endfor;
|
endfor;
|
||||||
elseif ( is_sp_post_type( $typenow ) ):
|
elseif ( is_sp_post_type( $typenow ) ) :
|
||||||
$obj = get_post_type_object( $typenow );
|
$obj = get_post_type_object( $typenow );
|
||||||
|
|
||||||
$messages['post'][1] = __( 'Changes saved.', 'sportspress' ) .
|
$messages['post'][1] = __( 'Changes saved.', 'sportspress' ) .
|
||||||
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
|
' <a href="' . esc_url( get_permalink( $post->ID ) ) . '">' . $obj->labels->view_item . '</a>';
|
||||||
|
|
||||||
$messages['post'][4] = __( 'Changes saved.', 'sportspress' );
|
$messages['post'][4] = __( 'Changes saved.', 'sportspress' );
|
||||||
|
|
||||||
$messages['post'][6] = __( 'Success!', 'sportspress' ) .
|
$messages['post'][6] = __( 'Success!', 'sportspress' ) .
|
||||||
' <a href="' . esc_url( get_permalink($post->ID) ) . '">' . $obj->labels->view_item . '</a>';
|
' <a href="' . esc_url( get_permalink( $post->ID ) ) . '">' . $obj->labels->view_item . '</a>';
|
||||||
|
|
||||||
$messages['post'][7] = __( 'Changes saved.', 'sportspress' );
|
$messages['post'][7] = __( 'Changes saved.', 'sportspress' );
|
||||||
|
|
||||||
$messages['post'][8] = __( 'Success!', 'sportspress' ) .
|
$messages['post'][8] = __( 'Success!', 'sportspress' ) .
|
||||||
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
|
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '">' .
|
||||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||||
|
|
||||||
$messages['post'][9] = sprintf(
|
$messages['post'][9] = sprintf(
|
||||||
__( 'Scheduled for: <b>%1$s</b>.', 'sportspress' ),
|
__( '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 ) ),
|
||||||
' <a target="_blank" href="' . esc_url( get_permalink($post->ID) ) . '">' .
|
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>';
|
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||||
|
|
||||||
$messages['post'][10] = __( 'Success!', 'sportspress' ) .
|
$messages['post'][10] = __( 'Success!', 'sportspress' ) .
|
||||||
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '">' .
|
' <a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '">' .
|
||||||
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
sprintf( __( 'Preview %s', 'sportspress' ), $obj->labels->singular_name ) . '</a>';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -116,7 +120,7 @@ class SP_Admin_Post_Types {
|
|||||||
}
|
}
|
||||||
return $meta_boxes;
|
return $meta_boxes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,14 @@ class SP_Admin_Sample_Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Insert term
|
// 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
|
// Add meta to term if is array
|
||||||
if ( ! is_wp_error( $inserted ) && is_array( $term ) && array_key_exists( 'meta', $term ) ) {
|
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();
|
$post['tax_input'] = array();
|
||||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
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
|
// Insert post
|
||||||
$id = wp_insert_post( $post );
|
$id = wp_insert_post( $post );
|
||||||
@@ -213,15 +236,30 @@ class SP_Admin_Sample_Data {
|
|||||||
$post['tax_input'] = array();
|
$post['tax_input'] = array();
|
||||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
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' );
|
$taxonomies = array( 'sp_position' );
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
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 ) ) {
|
if ( $terms && ! is_wp_error( $terms ) ) {
|
||||||
$post['tax_input'][ $taxonomy ] = $terms;
|
$post['tax_input'][ $taxonomy ] = $terms;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// Insert post
|
// Insert post
|
||||||
$id = wp_insert_post( $post );
|
$id = wp_insert_post( $post );
|
||||||
@@ -277,7 +315,9 @@ class SP_Admin_Sample_Data {
|
|||||||
);
|
);
|
||||||
$performance_posts = get_posts( $args );
|
$performance_posts = get_posts( $args );
|
||||||
foreach ( $performance_posts as $performance_post ) {
|
foreach ( $performance_posts as $performance_post ) {
|
||||||
if ( sizeof( $columns ) >= 5 ) continue;
|
if ( sizeof( $columns ) >= 5 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$columns[] = $performance_post->post_name;
|
$columns[] = $performance_post->post_name;
|
||||||
}
|
}
|
||||||
$args = array(
|
$args = array(
|
||||||
@@ -308,13 +348,28 @@ class SP_Admin_Sample_Data {
|
|||||||
$post['tax_input'] = array();
|
$post['tax_input'] = array();
|
||||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
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' );
|
$taxonomies = array( 'sp_role' );
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
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;
|
$post['tax_input'][ $taxonomy ] = $terms;
|
||||||
};
|
}
|
||||||
|
|
||||||
// Insert post
|
// Insert post
|
||||||
$id = wp_insert_post( $post );
|
$id = wp_insert_post( $post );
|
||||||
@@ -349,15 +404,36 @@ class SP_Admin_Sample_Data {
|
|||||||
if ( $index < 3 ) {
|
if ( $index < 3 ) {
|
||||||
$post_status = 'publish';
|
$post_status = 'publish';
|
||||||
$post_year = $current_year - 1;
|
$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 {
|
} else {
|
||||||
$post_status = 'future';
|
$post_status = 'future';
|
||||||
$post_year = $current_year + 1;
|
$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
|
// The away team should be the next inserted team, or the first if this is the last event
|
||||||
if ( $i == 2 ) $away_index = 0;
|
if ( $i == 2 ) {
|
||||||
else $away_index = $i + 1;
|
$away_index = 0;
|
||||||
|
} else {
|
||||||
|
$away_index = $i + 1;
|
||||||
|
}
|
||||||
$post = array(
|
$post = array(
|
||||||
'post_title' => $teams[ $i ]['name'] . ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ' . $teams[ $away_index ]['name'],
|
'post_title' => $teams[ $i ]['name'] . ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ' . $teams[ $away_index ]['name'],
|
||||||
'post_type' => 'sp_event',
|
'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_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',
|
'post_date' => $post_year . '-' . sprintf( '%02d', 3 + $i * 3 ) . '-' . sprintf( '%02d', 5 + $i * 10 ) . ' ' . ( 18 + $i ) . ':00:00',
|
||||||
'tax_input' => array(
|
'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_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;
|
$results[ $home_team_id ][ $result_post->post_name ] = 1 + $result_post_index;
|
||||||
}
|
}
|
||||||
$outcome = reset( $outcome_posts );
|
$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
|
// Separate teams with zero
|
||||||
@@ -437,7 +534,9 @@ class SP_Admin_Sample_Data {
|
|||||||
$results[ $away_team_id ][ $result_post->post_name ] = '0';
|
$results[ $away_team_id ][ $result_post->post_name ] = '0';
|
||||||
}
|
}
|
||||||
$outcome = next( $outcome_posts );
|
$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 ) {
|
if ( 'publish' === $post_status ) {
|
||||||
@@ -469,7 +568,7 @@ class SP_Admin_Sample_Data {
|
|||||||
'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ),
|
'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ),
|
||||||
'post_type' => 'sp_calendar',
|
'post_type' => 'sp_calendar',
|
||||||
'post_status' => 'publish',
|
'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
|
// Insert post
|
||||||
@@ -495,9 +594,25 @@ class SP_Admin_Sample_Data {
|
|||||||
/*
|
/*
|
||||||
* Insert league table
|
* 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 );
|
$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 );
|
$season = reset( $seasons );
|
||||||
$post = array(
|
$post = array(
|
||||||
'post_title' => $league->name . ' ' . $season->name,
|
'post_title' => $league->name . ' ' . $season->name,
|
||||||
@@ -605,7 +720,9 @@ class SP_Admin_Sample_Data {
|
|||||||
// Get columns
|
// Get columns
|
||||||
$columns = array( 'team' );
|
$columns = array( 'team' );
|
||||||
$performance_post = reset( $performance_posts );
|
$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 meta
|
||||||
update_post_meta( $id, 'sp_format', 'list' );
|
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_columns', $columns );
|
||||||
update_post_meta( $id, 'sp_grouping', '0' );
|
update_post_meta( $id, 'sp_grouping', '0' );
|
||||||
update_post_meta( $id, 'sp_order', 'DESC' );
|
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
|
* Update player list and league table per team
|
||||||
@@ -638,14 +757,14 @@ class SP_Admin_Sample_Data {
|
|||||||
'meta_query' => array(
|
'meta_query' => array(
|
||||||
array(
|
array(
|
||||||
'key' => '_sp_sample',
|
'key' => '_sp_sample',
|
||||||
'value' => 1
|
'value' => 1,
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Delete posts
|
// Delete posts
|
||||||
$old_posts = get_posts( $args );
|
$old_posts = get_posts( $args );
|
||||||
foreach( $old_posts as $post ):
|
foreach ( $old_posts as $post ) :
|
||||||
wp_delete_post( $post->ID, true );
|
wp_delete_post( $post->ID, true );
|
||||||
endforeach;
|
endforeach;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
* @version 2.7.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' ) ) :
|
if ( ! class_exists( 'SP_Admin_Settings' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Settings
|
* SP_Admin_Settings
|
||||||
*/
|
*/
|
||||||
class SP_Admin_Settings {
|
class SP_Admin_Settings {
|
||||||
|
|
||||||
private static $settings = array();
|
private static $settings = array();
|
||||||
private static $errors = array();
|
private static $errors = array();
|
||||||
@@ -29,28 +31,28 @@ class SP_Admin_Settings {
|
|||||||
if ( empty( self::$settings ) ) {
|
if ( empty( self::$settings ) ) {
|
||||||
$settings = array();
|
$settings = array();
|
||||||
|
|
||||||
include_once( 'class-sp-admin-sports.php' );
|
include_once 'class-sp-admin-sports.php';
|
||||||
include_once( 'settings/class-sp-settings-page.php' );
|
include_once 'settings/class-sp-settings-page.php';
|
||||||
|
|
||||||
$settings[] = include( 'settings/class-sp-settings-modules.php' );
|
$settings[] = include 'settings/class-sp-settings-modules.php';
|
||||||
$settings[] = include( 'settings/class-sp-settings-general.php' );
|
$settings[] = include 'settings/class-sp-settings-general.php';
|
||||||
$settings[] = include( 'settings/class-sp-settings-events.php' );
|
$settings[] = include 'settings/class-sp-settings-events.php';
|
||||||
$settings[] = include( 'settings/class-sp-settings-teams.php' );
|
$settings[] = include 'settings/class-sp-settings-teams.php';
|
||||||
$settings[] = include( 'settings/class-sp-settings-players.php' );
|
$settings[] = include 'settings/class-sp-settings-players.php';
|
||||||
$settings[] = include( 'settings/class-sp-settings-staff.php' );
|
$settings[] = include 'settings/class-sp-settings-staff.php';
|
||||||
|
|
||||||
$settings = apply_filters( 'sportspress_get_settings_pages', $settings );
|
$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 (
|
if (
|
||||||
( ! is_multisite() && current_user_can( 'manage_options' ) ) ||
|
( ! is_multisite() && current_user_can( 'manage_options' ) ) ||
|
||||||
( is_multisite() && current_user_can( 'manage_network_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 );
|
self::$settings = apply_filters( 'sportspress_get_settings_config_pages', $settings );
|
||||||
}
|
}
|
||||||
@@ -63,8 +65,9 @@ class SP_Admin_Settings {
|
|||||||
public static function save() {
|
public static function save() {
|
||||||
global $current_section, $current_tab;
|
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' ) );
|
die( __( 'Action failed. Please refresh the page and retry.', 'sportspress' ) );
|
||||||
|
}
|
||||||
|
|
||||||
// Trigger actions
|
// Trigger actions
|
||||||
do_action( 'sportspress_settings_save_' . $current_tab );
|
do_action( 'sportspress_settings_save_' . $current_tab );
|
||||||
@@ -78,6 +81,7 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a message
|
* Add a message
|
||||||
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
*/
|
*/
|
||||||
public static function add_message( $text ) {
|
public static function add_message( $text ) {
|
||||||
@@ -86,6 +90,7 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an override
|
* Add an override
|
||||||
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
*/
|
*/
|
||||||
public static function add_override( $text ) {
|
public static function add_override( $text ) {
|
||||||
@@ -94,6 +99,7 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an error
|
* Add an error
|
||||||
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
*/
|
*/
|
||||||
public static function add_error( $text ) {
|
public static function add_error( $text ) {
|
||||||
@@ -105,16 +111,19 @@ class SP_Admin_Settings {
|
|||||||
*/
|
*/
|
||||||
public static function show_messages() {
|
public static function show_messages() {
|
||||||
if ( sizeof( self::$errors ) > 0 ) {
|
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>';
|
echo '<div id="message" class="error fade"><p><strong>' . esc_html( $error ) . '</strong></p></div>';
|
||||||
|
}
|
||||||
} elseif ( sizeof( self::$overrides ) > 0 ) {
|
} 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>';
|
echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $override ) . '</strong></p></div>';
|
||||||
|
}
|
||||||
} elseif ( sizeof( self::$messages ) > 0 ) {
|
} 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>';
|
echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $message ) . '</strong></p></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings page.
|
* 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_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(
|
wp_localize_script(
|
||||||
'none' => __( 'None', 'sportspress' )
|
'sportspress_settings',
|
||||||
) );
|
'localized_strings',
|
||||||
|
array(
|
||||||
|
'none' => __( 'None', 'sportspress' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// Include settings pages
|
// Include settings pages
|
||||||
self::get_settings_pages();
|
self::get_settings_pages();
|
||||||
@@ -143,15 +156,18 @@ class SP_Admin_Settings {
|
|||||||
$current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( $_REQUEST['section'] );
|
$current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( $_REQUEST['section'] );
|
||||||
|
|
||||||
// Save settings if data has been posted
|
// Save settings if data has been posted
|
||||||
if ( ! empty( $_POST ) )
|
if ( ! empty( $_POST ) ) {
|
||||||
self::save();
|
self::save();
|
||||||
|
}
|
||||||
|
|
||||||
// Add any posted messages
|
// Add any posted messages
|
||||||
if ( ! empty( $_GET['sp_error'] ) )
|
if ( ! empty( $_GET['sp_error'] ) ) {
|
||||||
self::add_error( stripslashes( $_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::add_message( stripslashes( $_GET['sp_message'] ) );
|
||||||
|
}
|
||||||
|
|
||||||
self::show_messages();
|
self::show_messages();
|
||||||
|
|
||||||
@@ -181,20 +197,22 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
$key = key( $option_array[ $option_name ] );
|
$key = key( $option_array[ $option_name ] );
|
||||||
|
|
||||||
if ( isset( $option_values[ $key ] ) )
|
if ( isset( $option_values[ $key ] ) ) {
|
||||||
$option_value = $option_values[ $key ];
|
$option_value = $option_values[ $key ];
|
||||||
else
|
} else {
|
||||||
$option_value = null;
|
$option_value = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Single value
|
// Single value
|
||||||
} else {
|
} else {
|
||||||
$option_value = get_option( $option_name, null );
|
$option_value = get_option( $option_name, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_array( $option_value ) )
|
if ( is_array( $option_value ) ) {
|
||||||
$option_value = array_map( 'stripslashes', $option_value );
|
$option_value = array_map( 'stripslashes', $option_value );
|
||||||
elseif ( ! is_null( $option_value ) )
|
} elseif ( ! is_null( $option_value ) ) {
|
||||||
$option_value = stripslashes( $option_value );
|
$option_value = stripslashes( $option_value );
|
||||||
|
}
|
||||||
|
|
||||||
return $option_value === null ? $default : $option_value;
|
return $option_value === null ? $default : $option_value;
|
||||||
}
|
}
|
||||||
@@ -209,22 +227,42 @@ class SP_Admin_Settings {
|
|||||||
*/
|
*/
|
||||||
public static function output_fields( $options ) {
|
public static function output_fields( $options ) {
|
||||||
foreach ( $options as $value ) {
|
foreach ( $options as $value ) {
|
||||||
if ( ! isset( $value['type'] ) ) continue;
|
if ( ! isset( $value['type'] ) ) {
|
||||||
if ( ! isset( $value['id'] ) ) $value['id'] = '';
|
continue;
|
||||||
if ( ! isset( $value['title'] ) ) $value['title'] = isset( $value['name'] ) ? $value['name'] : '';
|
}
|
||||||
if ( ! isset( $value['class'] ) ) $value['class'] = '';
|
if ( ! isset( $value['id'] ) ) {
|
||||||
if ( ! isset( $value['css'] ) ) $value['css'] = '';
|
$value['id'] = '';
|
||||||
if ( ! isset( $value['default'] ) ) $value['default'] = '';
|
}
|
||||||
if ( ! isset( $value['desc'] ) ) $value['desc'] = '';
|
if ( ! isset( $value['title'] ) ) {
|
||||||
if ( ! isset( $value['desc_tip'] ) ) $value['desc_tip'] = false;
|
$value['title'] = isset( $value['name'] ) ? $value['name'] : '';
|
||||||
if ( ! isset( $value['placeholder'] ) ) $value['placeholder'] = '';
|
}
|
||||||
|
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 attribute handling
|
||||||
$custom_attributes = array();
|
$custom_attributes = array();
|
||||||
|
|
||||||
if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) )
|
if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) {
|
||||||
foreach ( $value['custom_attributes'] as $attribute => $attribute_value )
|
foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) {
|
||||||
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
|
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Description handling
|
// Description handling
|
||||||
if ( $value['desc_tip'] === true ) {
|
if ( $value['desc_tip'] === true ) {
|
||||||
@@ -261,7 +299,7 @@ class SP_Admin_Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Switch based on type
|
// Switch based on type
|
||||||
switch( $value['type'] ) {
|
switch ( $value['type'] ) {
|
||||||
|
|
||||||
// Section Titles
|
// Section Titles
|
||||||
case 'title':
|
case 'title':
|
||||||
@@ -273,7 +311,7 @@ class SP_Admin_Settings {
|
|||||||
if ( ! empty( $value['desc'] ) ) {
|
if ( ! empty( $value['desc'] ) ) {
|
||||||
echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) );
|
echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) );
|
||||||
}
|
}
|
||||||
echo '<table class="form-table">'. "\n\n";
|
echo '<table class="form-table">' . "\n\n";
|
||||||
if ( ! empty( $value['id'] ) ) {
|
if ( ! empty( $value['id'] ) ) {
|
||||||
do_action( 'sportspress_settings_' . sanitize_title( $value['id'] ) );
|
do_action( 'sportspress_settings_' . sanitize_title( $value['id'] ) );
|
||||||
}
|
}
|
||||||
@@ -295,9 +333,8 @@ class SP_Admin_Settings {
|
|||||||
case 'text':
|
case 'text':
|
||||||
case 'email':
|
case 'email':
|
||||||
case 'number':
|
case 'number':
|
||||||
case 'color' :
|
case 'color':
|
||||||
case 'password' :
|
case 'password':
|
||||||
|
|
||||||
$type = $value['type'];
|
$type = $value['type'];
|
||||||
$class = '';
|
$class = '';
|
||||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
$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>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||||
<?php echo esc_html( $tip ); ?>
|
<?php echo esc_html( $tip ); ?>
|
||||||
</th>
|
</th>
|
||||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||||
<input
|
<input
|
||||||
name="<?php echo esc_attr( $value['id'] ); ?>"
|
name="<?php echo esc_attr( $value['id'] ); ?>"
|
||||||
id="<?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 implode( ' ', $custom_attributes ); ?>
|
||||||
/> <?php echo wp_kses_post( $description ); ?>
|
/> <?php echo wp_kses_post( $description ); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr><?php
|
</tr>
|
||||||
|
<?php
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Textarea
|
// Textarea
|
||||||
case 'textarea':
|
case 'textarea':
|
||||||
|
|
||||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||||
|
|
||||||
?><tr valign="top">
|
?>
|
||||||
|
<tr valign="top">
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||||
<?php echo esc_html( $tip ); ?>
|
<?php echo esc_html( $tip ); ?>
|
||||||
</th>
|
</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 ); ?>
|
<?php echo wp_kses_post( $description ); ?>
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
@@ -349,66 +387,95 @@ class SP_Admin_Settings {
|
|||||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||||
><?php echo esc_textarea( $option_value ); ?></textarea>
|
><?php echo esc_textarea( $option_value ); ?></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr><?php
|
</tr>
|
||||||
|
<?php
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Select boxes
|
// Select boxes
|
||||||
case 'select' :
|
case 'select':
|
||||||
case 'multiselect' :
|
case 'multiselect':
|
||||||
|
|
||||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||||
|
|
||||||
?><tr valign="top">
|
?>
|
||||||
|
<tr valign="top">
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||||
<?php echo esc_html( $tip ); ?>
|
<?php echo esc_html( $tip ); ?>
|
||||||
</th>
|
</th>
|
||||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||||
<select
|
<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'] ); ?>"
|
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||||
style="<?php echo esc_attr( $value['css'] ); ?>"
|
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 echo implode( ' ', $custom_attributes ); ?>
|
||||||
<?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
|
<?php
|
||||||
|
if ( $value['type'] == 'multiselect' ) {
|
||||||
|
echo 'multiple="multiple"';}
|
||||||
|
?>
|
||||||
>
|
>
|
||||||
<?php
|
<?php
|
||||||
foreach ( $value['options'] as $key => $val ) {
|
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 );
|
selected( in_array( $key, $option_value ), true );
|
||||||
else
|
} else {
|
||||||
selected( $option_value, $key );
|
selected( $option_value, $key );
|
||||||
|
}
|
||||||
|
|
||||||
?>><?php echo esc_attr( $val ); ?></option>
|
?>
|
||||||
|
><?php echo esc_attr( $val ); ?></option>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select> <?php echo wp_kses_post( $description ); ?>
|
</select> <?php echo wp_kses_post( $description ); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr><?php
|
</tr>
|
||||||
|
<?php
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Select boxes with optgroup
|
// Select boxes with optgroup
|
||||||
case 'groupselect' :
|
case 'groupselect':
|
||||||
|
|
||||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||||
|
|
||||||
?><tr valign="top">
|
?>
|
||||||
|
<tr valign="top">
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||||
<?php echo esc_html( $tip ); ?>
|
<?php echo esc_html( $tip ); ?>
|
||||||
</th>
|
</th>
|
||||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||||
<select
|
<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'] ); ?>"
|
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||||
style="<?php echo esc_attr( $value['css'] ); ?>"
|
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 echo implode( ' ', $custom_attributes ); ?>
|
||||||
<?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
|
<?php
|
||||||
|
if ( $value['type'] == 'multiselect' ) {
|
||||||
|
echo 'multiple="multiple"';}
|
||||||
|
?>
|
||||||
>
|
>
|
||||||
<?php
|
<?php
|
||||||
foreach ( $value['options'] as $group => $options ) {
|
foreach ( $value['options'] as $group => $options ) {
|
||||||
@@ -417,14 +484,17 @@ class SP_Admin_Settings {
|
|||||||
<?php
|
<?php
|
||||||
foreach ( $options as $key => $val ) {
|
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 );
|
selected( in_array( $key, $option_value ), true );
|
||||||
else
|
} else {
|
||||||
selected( $option_value, $key );
|
selected( $option_value, $key );
|
||||||
|
}
|
||||||
|
|
||||||
?>><?php echo esc_attr( $val ); ?></option>
|
?>
|
||||||
|
><?php echo esc_attr( $val ); ?></option>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -434,31 +504,46 @@ class SP_Admin_Settings {
|
|||||||
?>
|
?>
|
||||||
</select> <?php echo wp_kses_post( $description ); ?>
|
</select> <?php echo wp_kses_post( $description ); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr><?php
|
</tr>
|
||||||
|
<?php
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Select sport
|
// Select sport
|
||||||
case 'sport' :
|
case 'sport':
|
||||||
|
|
||||||
$default = apply_filters( 'sportspress_default_sport', 'soccer' );
|
$default = apply_filters( 'sportspress_default_sport', 'soccer' );
|
||||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
$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();
|
$categories = SP_Admin_Sports::sport_category_names();
|
||||||
|
|
||||||
?><tr valign="top">
|
?>
|
||||||
|
<tr valign="top">
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||||
<?php echo esc_html( $tip ); ?>
|
<?php echo esc_html( $tip ); ?>
|
||||||
</th>
|
</th>
|
||||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||||
<select
|
<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'] ); ?>"
|
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||||
style="<?php echo esc_attr( $value['css'] ); ?>"
|
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 echo implode( ' ', $custom_attributes ); ?>
|
||||||
<?php if ( $value['type'] == 'multiselect' ) echo 'multiple="multiple"'; ?>
|
<?php
|
||||||
|
if ( $value['type'] == 'multiselect' ) {
|
||||||
|
echo 'multiple="multiple"';}
|
||||||
|
?>
|
||||||
>
|
>
|
||||||
<?php
|
<?php
|
||||||
foreach ( $value['options'] as $group => $options ) {
|
foreach ( $value['options'] as $group => $options ) {
|
||||||
@@ -467,14 +552,17 @@ class SP_Admin_Settings {
|
|||||||
<?php
|
<?php
|
||||||
foreach ( $options as $key => $val ) {
|
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 );
|
selected( in_array( $key, $option_value ), true );
|
||||||
else
|
} else {
|
||||||
selected( $option_value, $key );
|
selected( $option_value, $key );
|
||||||
|
}
|
||||||
|
|
||||||
?>><?php echo esc_attr( $val ); ?></option>
|
?>
|
||||||
|
><?php echo esc_attr( $val ); ?></option>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -490,20 +578,21 @@ class SP_Admin_Settings {
|
|||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr><?php
|
</tr>
|
||||||
|
<?php
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Radio inputs
|
// Radio inputs
|
||||||
case 'radio' :
|
case 'radio':
|
||||||
|
|
||||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||||
|
|
||||||
?><tr valign="top">
|
?>
|
||||||
|
<tr valign="top">
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
||||||
<?php echo wp_kses_post( $tip ); ?>
|
<?php echo wp_kses_post( $tip ); ?>
|
||||||
</th>
|
</th>
|
||||||
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ) ?>">
|
<td class="forminp forminp-<?php echo esc_attr( $value['type'] ); ?>">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<?php echo wp_kses_post( $description ); ?>
|
<?php echo wp_kses_post( $description ); ?>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -527,12 +616,12 @@ class SP_Admin_Settings {
|
|||||||
</ul>
|
</ul>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr><?php
|
</tr>
|
||||||
|
<?php
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Checkbox input
|
// Checkbox input
|
||||||
case 'checkbox' :
|
case 'checkbox':
|
||||||
|
|
||||||
$option_value = self::get_option( $value['id'], $value['default'] );
|
$option_value = self::get_option( $value['id'], $value['default'] );
|
||||||
$visbility_class = array();
|
$visbility_class = array();
|
||||||
|
|
||||||
@@ -555,7 +644,7 @@ class SP_Admin_Settings {
|
|||||||
if ( ! isset( $value['checkboxgroup'] ) || 'start' == $value['checkboxgroup'] ) {
|
if ( ! isset( $value['checkboxgroup'] ) || 'start' == $value['checkboxgroup'] ) {
|
||||||
?>
|
?>
|
||||||
<tr valign="top" class="<?php echo esc_attr( implode( ' ', $visbility_class ) ); ?>">
|
<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">
|
<td class="forminp forminp-checkbox">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<?php
|
<?php
|
||||||
@@ -567,7 +656,7 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
if ( ! empty( $value['title'] ) ) {
|
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
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,7 +667,7 @@ class SP_Admin_Settings {
|
|||||||
id="<?php echo esc_attr( $value['id'] ); ?>"
|
id="<?php echo esc_attr( $value['id'] ); ?>"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
value="1"
|
value="1"
|
||||||
<?php checked( $option_value, 'yes'); ?>
|
<?php checked( $option_value, 'yes' ); ?>
|
||||||
<?php echo implode( ' ', $custom_attributes ); ?>
|
<?php echo implode( ' ', $custom_attributes ); ?>
|
||||||
/> <?php echo wp_kses_post( $description ); ?>
|
/> <?php echo wp_kses_post( $description ); ?>
|
||||||
</label> <?php echo wp_kses_post( $tip ); ?>
|
</label> <?php echo wp_kses_post( $tip ); ?>
|
||||||
@@ -615,8 +704,9 @@ class SP_Admin_Settings {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function save_fields( $options ) {
|
public static function save_fields( $options ) {
|
||||||
if ( empty( $_POST ) )
|
if ( empty( $_POST ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Options to update will be stored here
|
// Options to update will be stored here
|
||||||
$update_options = array();
|
$update_options = array();
|
||||||
@@ -624,8 +714,9 @@ class SP_Admin_Settings {
|
|||||||
// Loop options and get values to save
|
// Loop options and get values to save
|
||||||
foreach ( $options as $value ) {
|
foreach ( $options as $value ) {
|
||||||
|
|
||||||
if ( ! isset( $value['id'] ) )
|
if ( ! isset( $value['id'] ) ) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$type = isset( $value['type'] ) ? esc_attr( $value['type'] ) : '';
|
$type = isset( $value['type'] ) ? esc_attr( $value['type'] ) : '';
|
||||||
|
|
||||||
@@ -635,8 +726,7 @@ class SP_Admin_Settings {
|
|||||||
switch ( $type ) {
|
switch ( $type ) {
|
||||||
|
|
||||||
// Standard types
|
// Standard types
|
||||||
case 'checkbox' :
|
case 'checkbox':
|
||||||
|
|
||||||
if ( isset( $_POST[ $value['id'] ] ) ) {
|
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||||
$option_value = 'yes';
|
$option_value = 'yes';
|
||||||
} else {
|
} else {
|
||||||
@@ -645,9 +735,8 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'textarea' :
|
case 'textarea':
|
||||||
|
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||||
if ( isset( $_POST[$value['id']] ) ) {
|
|
||||||
$option_value = wp_kses_post( trim( stripslashes( $_POST[ $value['id'] ] ) ) );
|
$option_value = wp_kses_post( trim( stripslashes( $_POST[ $value['id'] ] ) ) );
|
||||||
} else {
|
} else {
|
||||||
$option_value = '';
|
$option_value = '';
|
||||||
@@ -655,17 +744,16 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'text' :
|
case 'text':
|
||||||
case 'email':
|
case 'email':
|
||||||
case 'number':
|
case 'number':
|
||||||
case 'select' :
|
case 'select':
|
||||||
case 'groupselect' :
|
case 'groupselect':
|
||||||
case 'sport' :
|
case 'sport':
|
||||||
case 'color' :
|
case 'color':
|
||||||
case 'password' :
|
case 'password':
|
||||||
case 'radio' :
|
case 'radio':
|
||||||
|
if ( isset( $_POST[ $value['id'] ] ) ) {
|
||||||
if ( isset( $_POST[$value['id']] ) ) {
|
|
||||||
$option_value = sanitize_text_field( stripslashes( $_POST[ $value['id'] ] ) );
|
$option_value = sanitize_text_field( stripslashes( $_POST[ $value['id'] ] ) );
|
||||||
} else {
|
} else {
|
||||||
$option_value = '';
|
$option_value = '';
|
||||||
@@ -674,22 +762,21 @@ class SP_Admin_Settings {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// Special types
|
// Special types
|
||||||
case "multiselect" :
|
case 'multiselect':
|
||||||
case "multi_select_countries" :
|
case 'multi_select_countries':
|
||||||
|
|
||||||
// Get countries array
|
// 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'] ] ) );
|
$selected_countries = array_map( 'sanitize_text_field', array_map( 'stripslashes', (array) $_POST[ $value['id'] ] ) );
|
||||||
else
|
} else {
|
||||||
$selected_countries = array();
|
$selected_countries = array();
|
||||||
|
}
|
||||||
|
|
||||||
$option_value = $selected_countries;
|
$option_value = $selected_countries;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Custom handling
|
// Custom handling
|
||||||
default :
|
default:
|
||||||
|
|
||||||
do_action( 'sportspress_update_option_' . $type, $value );
|
do_action( 'sportspress_update_option_' . $type, $value );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -706,11 +793,13 @@ class SP_Admin_Settings {
|
|||||||
$option_name = current( array_keys( $option_array ) );
|
$option_name = current( array_keys( $option_array ) );
|
||||||
|
|
||||||
// Get old option value
|
// 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() );
|
$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();
|
$update_options[ $option_name ] = array();
|
||||||
|
}
|
||||||
|
|
||||||
// Set keys and value
|
// Set keys and value
|
||||||
$key = key( $option_array[ $option_name ] );
|
$key = key( $option_array[ $option_name ] );
|
||||||
@@ -728,11 +817,12 @@ class SP_Admin_Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now save the options
|
// Now save the options
|
||||||
foreach( $update_options as $name => $value )
|
foreach ( $update_options as $name => $value ) {
|
||||||
update_option( $name, $value );
|
update_option( $name, $value );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
* @category Admin
|
* @category Admin
|
||||||
* @package SportsPress/Admin
|
* @package SportsPress/Admin
|
||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ class SP_Admin_Setup_Wizard {
|
|||||||
|
|
||||||
/** @var array Tweets user can optionally send after install */
|
/** @var array Tweets user can optionally send after install */
|
||||||
private $tweets = array(
|
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(
|
'introduction' => array(
|
||||||
'name' => __( 'Introduction', 'sportspress' ),
|
'name' => __( 'Introduction', 'sportspress' ),
|
||||||
'view' => array( $this, 'sp_setup_introduction' ),
|
'view' => array( $this, 'sp_setup_introduction' ),
|
||||||
'handler' => ''
|
'handler' => '',
|
||||||
),
|
),
|
||||||
'basics' => array(
|
'basics' => array(
|
||||||
'name' => __( 'Basic Setup', 'sportspress' ),
|
'name' => __( 'Basic Setup', 'sportspress' ),
|
||||||
'view' => array( $this, 'sp_setup_basics' ),
|
'view' => array( $this, 'sp_setup_basics' ),
|
||||||
'handler' => array( $this, 'sp_setup_basics_save' )
|
'handler' => array( $this, 'sp_setup_basics_save' ),
|
||||||
),
|
),
|
||||||
'teams' => array(
|
'teams' => array(
|
||||||
'name' => __( 'Teams', 'sportspress' ),
|
'name' => __( 'Teams', 'sportspress' ),
|
||||||
'view' => array( $this, 'sp_setup_teams' ),
|
'view' => array( $this, 'sp_setup_teams' ),
|
||||||
'handler' => array( $this, 'sp_setup_teams_save' )
|
'handler' => array( $this, 'sp_setup_teams_save' ),
|
||||||
),
|
),
|
||||||
'players_staff' => array(
|
'players_staff' => array(
|
||||||
'name' => __( 'Players', 'sportspress' ) . ' & ' . __( 'Staff', 'sportspress' ),
|
'name' => __( 'Players', 'sportspress' ) . ' & ' . __( 'Staff', 'sportspress' ),
|
||||||
@@ -84,13 +84,13 @@ class SP_Admin_Setup_Wizard {
|
|||||||
'pages' => array(
|
'pages' => array(
|
||||||
'name' => __( 'Pages', 'sportspress' ),
|
'name' => __( 'Pages', 'sportspress' ),
|
||||||
'view' => array( $this, 'sp_setup_pages' ),
|
'view' => array( $this, 'sp_setup_pages' ),
|
||||||
'handler' => array( $this, 'sp_setup_pages_save' )
|
'handler' => array( $this, 'sp_setup_pages_save' ),
|
||||||
),
|
),
|
||||||
'next_steps' => array(
|
'next_steps' => array(
|
||||||
'name' => __( 'Ready!', 'sportspress' ),
|
'name' => __( 'Ready!', 'sportspress' ),
|
||||||
'view' => array( $this, 'sp_setup_ready' ),
|
'view' => array( $this, 'sp_setup_ready' ),
|
||||||
'handler' => ''
|
'handler' => '',
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
|
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
|
||||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||||
@@ -105,10 +105,13 @@ class SP_Admin_Setup_Wizard {
|
|||||||
|
|
||||||
do_action( 'sp_setup_geocoder_scripts' );
|
do_action( 'sp_setup_geocoder_scripts' );
|
||||||
|
|
||||||
$strings = apply_filters( 'sportspress_localized_strings', array(
|
$strings = apply_filters(
|
||||||
|
'sportspress_localized_strings',
|
||||||
|
array(
|
||||||
'none' => __( 'None', 'sportspress' ),
|
'none' => __( 'None', 'sportspress' ),
|
||||||
'remove_text' => __( '— Remove —', 'sportspress' ),
|
'remove_text' => __( '— Remove —', 'sportspress' ),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// Localize scripts
|
// Localize scripts
|
||||||
wp_localize_script( 'sportspress-setup', 'localized_strings', $strings );
|
wp_localize_script( 'sportspress-setup', 'localized_strings', $strings );
|
||||||
@@ -172,13 +175,15 @@ class SP_Admin_Setup_Wizard {
|
|||||||
?>
|
?>
|
||||||
<ol class="sp-setup-steps">
|
<ol class="sp-setup-steps">
|
||||||
<?php foreach ( $ouput_steps as $step_key => $step ) : ?>
|
<?php foreach ( $ouput_steps as $step_key => $step ) : ?>
|
||||||
<li class="<?php
|
<li class="
|
||||||
|
<?php
|
||||||
if ( $step_key === $this->step ) {
|
if ( $step_key === $this->step ) {
|
||||||
echo 'active';
|
echo 'active';
|
||||||
} elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
|
} elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
|
||||||
echo 'done';
|
echo 'done';
|
||||||
}
|
}
|
||||||
?>"><?php echo esc_html( $step['name'] ); ?></li>
|
?>
|
||||||
|
"><?php echo esc_html( $step['name'] ); ?></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ol>
|
</ol>
|
||||||
<?php
|
<?php
|
||||||
@@ -223,24 +228,26 @@ class SP_Admin_Setup_Wizard {
|
|||||||
<td>
|
<td>
|
||||||
<select id="timezone_string" name="timezone_string" class="<?php echo esc_attr( $class ); ?>">
|
<select id="timezone_string" name="timezone_string" class="<?php echo esc_attr( $class ); ?>">
|
||||||
<?php
|
<?php
|
||||||
$current_offset = get_option('gmt_offset');
|
$current_offset = get_option( 'gmt_offset' );
|
||||||
$tzstring = get_option('timezone_string');
|
$tzstring = get_option( 'timezone_string' );
|
||||||
|
|
||||||
$check_zone_info = true;
|
$check_zone_info = true;
|
||||||
|
|
||||||
// Remove old Etc mappings. Fallback to gmt_offset.
|
// Remove old Etc mappings. Fallback to gmt_offset.
|
||||||
if ( false !== strpos($tzstring,'Etc/GMT') )
|
if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
|
||||||
$tzstring = '';
|
$tzstring = '';
|
||||||
|
}
|
||||||
|
|
||||||
if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists
|
if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
|
||||||
$check_zone_info = false;
|
$check_zone_info = false;
|
||||||
if ( 0 == $current_offset )
|
if ( 0 == $current_offset ) {
|
||||||
$tzstring = 'UTC+0';
|
$tzstring = 'UTC+0';
|
||||||
elseif ($current_offset < 0)
|
} elseif ( $current_offset < 0 ) {
|
||||||
$tzstring = 'UTC' . $current_offset;
|
$tzstring = 'UTC' . $current_offset;
|
||||||
else
|
} else {
|
||||||
$tzstring = 'UTC+' . $current_offset;
|
$tzstring = 'UTC+' . $current_offset;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
echo wp_timezone_choice( $tzstring );
|
echo wp_timezone_choice( $tzstring );
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
@@ -253,7 +260,9 @@ class SP_Admin_Setup_Wizard {
|
|||||||
$options = SP_Admin_Sports::get_preset_options();
|
$options = SP_Admin_Sports::get_preset_options();
|
||||||
$default = apply_filters( 'sportspress_default_sport', 'soccer' );
|
$default = apply_filters( 'sportspress_default_sport', 'soccer' );
|
||||||
$sport = get_option( 'sportspress_sport', $default );
|
$sport = get_option( 'sportspress_sport', $default );
|
||||||
if ( 'none' === $sport ) $sport = $default;
|
if ( 'none' === $sport ) {
|
||||||
|
$sport = $default;
|
||||||
|
}
|
||||||
$categories = SP_Admin_Sports::sport_category_names();
|
$categories = SP_Admin_Sports::sport_category_names();
|
||||||
?>
|
?>
|
||||||
<select name="sport" id="sport" class="sp-select-sport <?php echo esc_attr( $class ); ?>">
|
<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 = '';
|
$timezone_string = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $timezone_string ) )
|
if ( isset( $timezone_string ) ) {
|
||||||
update_option( 'timezone_string', $timezone_string );
|
update_option( 'timezone_string', $timezone_string );
|
||||||
|
}
|
||||||
|
|
||||||
if ( isset( $gmt_offset ) )
|
if ( isset( $gmt_offset ) ) {
|
||||||
update_option( 'gmt_offset', $gmt_offset );
|
update_option( 'gmt_offset', $gmt_offset );
|
||||||
|
}
|
||||||
|
|
||||||
// Update sport
|
// Update sport
|
||||||
$sport = sanitize_text_field( $_POST['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>
|
<th scope="row"><?php _e( 'Rival Team', 'sportspress' ); ?></th>
|
||||||
<td>
|
<td>
|
||||||
<input name="away_team" type="text" class="widefat" placeholder="<?php _e( 'Who are you playing against next?', 'sportspress' ); ?>">
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -396,8 +407,14 @@ class SP_Admin_Setup_Wizard {
|
|||||||
$post['tax_input'] = array();
|
$post['tax_input'] = array();
|
||||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
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 );
|
wp_insert_post( $post );
|
||||||
|
|
||||||
// Add home team
|
// Add home team
|
||||||
@@ -412,7 +429,14 @@ class SP_Admin_Setup_Wizard {
|
|||||||
* Players & Staff Setup.
|
* Players & Staff Setup.
|
||||||
*/
|
*/
|
||||||
public function sp_setup_players_staff() {
|
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>
|
<h1><?php esc_html_e( 'Player & Staff Setup', 'sportspress' ); ?></h1>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
@@ -423,10 +447,14 @@ class SP_Admin_Setup_Wizard {
|
|||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
<?php for ( $i = 0; $i < 3; $i++ ) { ?>
|
<?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 } ?>
|
<?php } ?>
|
||||||
</ul>
|
</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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -455,7 +483,13 @@ class SP_Admin_Setup_Wizard {
|
|||||||
check_admin_referer( 'sp-setup' );
|
check_admin_referer( 'sp-setup' );
|
||||||
|
|
||||||
// Get home team
|
// 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 );
|
$team = reset( $teams );
|
||||||
|
|
||||||
// Add players
|
// Add players
|
||||||
@@ -464,11 +498,19 @@ class SP_Admin_Setup_Wizard {
|
|||||||
$post['tax_input'] = array();
|
$post['tax_input'] = array();
|
||||||
$taxonomies = array( 'sp_league', 'sp_season' );
|
$taxonomies = array( 'sp_league', 'sp_season' );
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
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'] ) ) {
|
if ( is_array( $_POST['players'] ) ) {
|
||||||
foreach ( $_POST['players'] as $i => $player ) {
|
foreach ( $_POST['players'] as $i => $player ) {
|
||||||
if ( empty( $player['name'] ) ) continue;
|
if ( empty( $player['name'] ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$post['post_title'] = $player['name'];
|
$post['post_title'] = $player['name'];
|
||||||
$id = wp_insert_post( $post );
|
$id = wp_insert_post( $post );
|
||||||
@@ -517,7 +559,7 @@ class SP_Admin_Setup_Wizard {
|
|||||||
?>
|
?>
|
||||||
<h1><?php _e( 'Venue Setup', 'sportspress' ); ?></h1>
|
<h1><?php _e( 'Venue Setup', 'sportspress' ); ?></h1>
|
||||||
<form method="post">
|
<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">
|
<table class="form-table" cellspacing="0">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php _e( 'Name', 'sportspress' ); ?></th>
|
<th scope="row"><?php _e( 'Name', 'sportspress' ); ?></th>
|
||||||
@@ -554,7 +596,13 @@ class SP_Admin_Setup_Wizard {
|
|||||||
check_admin_referer( 'sp-setup' );
|
check_admin_referer( 'sp-setup' );
|
||||||
|
|
||||||
// Get home team
|
// 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 );
|
$team = reset( $teams );
|
||||||
|
|
||||||
// Insert venue
|
// Insert venue
|
||||||
@@ -588,11 +636,14 @@ class SP_Admin_Setup_Wizard {
|
|||||||
* Pages Step.
|
* Pages Step.
|
||||||
*/
|
*/
|
||||||
public function sp_setup_pages() {
|
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_calendar' => __( 'Organize and publish calendars using different layouts.', 'sportspress' ),
|
||||||
'sp_table' => __( 'Create automated league tables to keep track of team standings.', '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' ),
|
'sp_list' => __( 'Create team rosters, player galleries, and ranking charts.', 'sportspress' ),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
?>
|
?>
|
||||||
<h1><?php _e( 'Pages', 'sportspress' ); ?></h1>
|
<h1><?php _e( 'Pages', 'sportspress' ); ?></h1>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
@@ -601,7 +652,9 @@ class SP_Admin_Setup_Wizard {
|
|||||||
<?php foreach ( $pages as $post_type => $description ) { ?>
|
<?php foreach ( $pages as $post_type => $description ) { ?>
|
||||||
<?php
|
<?php
|
||||||
$obj = get_post_type_object( $post_type );
|
$obj = get_post_type_object( $post_type );
|
||||||
if ( ! is_object( $obj ) ) continue;
|
if ( ! is_object( $obj ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?php echo esc_html( $obj->labels->singular_name ); ?></th>
|
<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() {
|
public function sp_setup_pages_save() {
|
||||||
check_admin_referer( 'sp-setup' );
|
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_calendar' => __( 'Organize and publish calendars using different layouts.', 'sportspress' ),
|
||||||
'sp_table' => __( 'Create automated league tables to keep track of team standings.', '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' ),
|
'sp_list' => __( 'Create team rosters, player galleries, and ranking charts.', 'sportspress' ),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// Initialize post
|
// Initialize post
|
||||||
$post = array( 'post_status' => 'publish' );
|
$post = array( 'post_status' => 'publish' );
|
||||||
@@ -640,11 +696,20 @@ class SP_Admin_Setup_Wizard {
|
|||||||
// Insert posts
|
// Insert posts
|
||||||
foreach ( $pages as $post_type => $description ) {
|
foreach ( $pages as $post_type => $description ) {
|
||||||
$obj = get_post_type_object( $post_type );
|
$obj = get_post_type_object( $post_type );
|
||||||
if ( ! is_object( $obj ) ) continue;
|
if ( ! is_object( $obj ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip if post exists
|
// Skip if post exists
|
||||||
$posts = get_posts( array( 'posts_per_page' => 1, 'post_type' => $post_type ) );
|
$posts = get_posts(
|
||||||
if ( $posts ) continue;
|
array(
|
||||||
|
'posts_per_page' => 1,
|
||||||
|
'post_type' => $post_type,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if ( $posts ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Add post args
|
// Add post args
|
||||||
$post['post_title'] = $obj->labels->singular_name;
|
$post['post_title'] = $obj->labels->singular_name;
|
||||||
@@ -680,9 +745,9 @@ class SP_Admin_Setup_Wizard {
|
|||||||
'meta_query' => array(
|
'meta_query' => array(
|
||||||
array(
|
array(
|
||||||
'key' => '_sp_first',
|
'key' => '_sp_first',
|
||||||
'value' => 1
|
'value' => 1,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -696,13 +761,30 @@ class SP_Admin_Setup_Wizard {
|
|||||||
if ( 'player' === get_option( 'sportspress_mode', 'team' ) ) {
|
if ( 'player' === get_option( 'sportspress_mode', 'team' ) ) {
|
||||||
$team_post_type = 'sp_player';
|
$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
|
// 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
|
// 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
|
// Initialize post
|
||||||
$post['post_type'] = 'sp_event';
|
$post['post_type'] = 'sp_event';
|
||||||
@@ -712,14 +794,23 @@ class SP_Admin_Setup_Wizard {
|
|||||||
// Add taxonomies
|
// Add taxonomies
|
||||||
$taxonomies = array( 'sp_league', 'sp_season', 'sp_venue' );
|
$taxonomies = array( 'sp_league', 'sp_season', 'sp_venue' );
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
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
|
// Add post title
|
||||||
if ( is_array( $teams ) && sizeof( $teams ) ) {
|
if ( is_array( $teams ) && sizeof( $teams ) ) {
|
||||||
$team_names = array();
|
$team_names = array();
|
||||||
foreach ( $teams as $team ) {
|
foreach ( $teams as $team ) {
|
||||||
if ( ! $team ) continue;
|
if ( ! $team ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$team_names[] = $team->post_title;
|
$team_names[] = $team->post_title;
|
||||||
}
|
}
|
||||||
$post['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
|
$post['post_title'] = implode( ' ' . get_option( 'sportspress_event_teams_delimiter', 'vs' ) . ' ', $team_names );
|
||||||
@@ -733,7 +824,9 @@ class SP_Admin_Setup_Wizard {
|
|||||||
// Add teams
|
// Add teams
|
||||||
if ( is_array( $teams ) && sizeof( $teams ) ) {
|
if ( is_array( $teams ) && sizeof( $teams ) ) {
|
||||||
foreach ( $teams as $team ) {
|
foreach ( $teams as $team ) {
|
||||||
if ( ! $team ) continue;
|
if ( ! $team ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
add_post_meta( $id, 'sp_team', $team->ID );
|
add_post_meta( $id, 'sp_team', $team->ID );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -741,7 +834,9 @@ class SP_Admin_Setup_Wizard {
|
|||||||
// Add players
|
// Add players
|
||||||
add_post_meta( $id, 'sp_player', 0 );
|
add_post_meta( $id, 'sp_player', 0 );
|
||||||
foreach ( $players as $player ) {
|
foreach ( $players as $player ) {
|
||||||
if ( ! $player ) continue;
|
if ( ! $player ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
add_post_meta( $id, 'sp_player', $player );
|
add_post_meta( $id, 'sp_player', $player );
|
||||||
}
|
}
|
||||||
add_post_meta( $id, 'sp_player', 0 );
|
add_post_meta( $id, 'sp_player', 0 );
|
||||||
@@ -758,7 +853,9 @@ class SP_Admin_Setup_Wizard {
|
|||||||
$id = $this->sp_setup_ready_actions();
|
$id = $this->sp_setup_ready_actions();
|
||||||
shuffle( $this->tweets );
|
shuffle( $this->tweets );
|
||||||
|
|
||||||
$steps = apply_filters( 'sportspress_setup_wizard_next_steps', array(
|
$steps = apply_filters(
|
||||||
|
'sportspress_setup_wizard_next_steps',
|
||||||
|
array(
|
||||||
'first' => array(
|
'first' => array(
|
||||||
'label' => __( 'Next Steps', 'sportspress' ),
|
'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>',
|
'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' ),
|
'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>',
|
'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>
|
<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>
|
<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>
|
||||||
|
|||||||
@@ -40,11 +40,13 @@ class SP_Admin_Sports {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach( $files as $file ) {
|
foreach ( $files as $file ) {
|
||||||
$json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $slug . '/' . $file );
|
$json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $slug . '/' . $file );
|
||||||
$data = json_decode( $json_data, true );
|
$data = json_decode( $json_data, true );
|
||||||
if ( ! is_array( $data ) ) continue;
|
if ( ! is_array( $data ) ) {
|
||||||
$id = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file );
|
continue;
|
||||||
|
}
|
||||||
|
$id = preg_replace( '/\\.[^.\\s]{3,4}$/', '', $file );
|
||||||
$presets[ $id ] = $data;
|
$presets[ $id ] = $data;
|
||||||
$name = array_key_exists( 'name', $data ) ? __( $data['name'], 'sportspress' ) : $id;
|
$name = array_key_exists( 'name', $data ) ? __( $data['name'], 'sportspress' ) : $id;
|
||||||
|
|
||||||
@@ -70,14 +72,18 @@ class SP_Admin_Sports {
|
|||||||
public static function get_preset( $id ) {
|
public static function get_preset( $id ) {
|
||||||
$json_data = @file_get_contents( SP()->plugin_path() . '/presets/' . $id . '.json', true );
|
$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' );
|
$dir = scandir( SP()->plugin_path() . '/presets' );
|
||||||
if ( $dir ) {
|
if ( $dir ) {
|
||||||
foreach ( $dir as $key => $value ) {
|
foreach ( $dir as $key => $value ) {
|
||||||
if ( substr( $value, 0, 1 ) !== '.' && strpos( $value, '.' ) === false ) {
|
if ( substr( $value, 0, 1 ) !== '.' && strpos( $value, '.' ) === false ) {
|
||||||
$json_data = @file_get_contents( SP()->plugin_path() . '/presets/' . $value . '/' . $id . '.json', true );
|
$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 ) );
|
$sections = sp_array_value( $position, 'sections', array( 0, 1 ) );
|
||||||
}
|
}
|
||||||
$term = wp_insert_term( $name, 'sp_position' );
|
$term = wp_insert_term( $name, 'sp_position' );
|
||||||
if ( is_wp_error( $term ) ) continue;
|
if ( is_wp_error( $term ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$t_id = $term['term_id'];
|
$t_id = $term['term_id'];
|
||||||
$term_meta = get_option( "taxonomy_$t_id" );
|
$term_meta = get_option( "taxonomy_$t_id" );
|
||||||
$term_meta['sp_sections'] = $sections;
|
$term_meta['sp_sections'] = $sections;
|
||||||
@@ -124,7 +132,9 @@ class SP_Admin_Sports {
|
|||||||
self::delete_preset_posts( $post_type );
|
self::delete_preset_posts( $post_type );
|
||||||
foreach ( $outcomes as $index => $outcome ) {
|
foreach ( $outcomes as $index => $outcome ) {
|
||||||
$post = self::get_post_array( $outcome, $post_type );
|
$post = self::get_post_array( $outcome, $post_type );
|
||||||
if ( empty( $post ) ) continue;
|
if ( empty( $post ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$id = self::insert_preset_post( $post, $index );
|
$id = self::insert_preset_post( $post, $index );
|
||||||
update_post_meta( $id, 'sp_abbreviation', sp_array_value( $outcome, 'abbreviation', null ) );
|
update_post_meta( $id, 'sp_abbreviation', sp_array_value( $outcome, 'abbreviation', null ) );
|
||||||
update_post_meta( $id, 'sp_condition', sp_array_value( $outcome, 'condition', null ) );
|
update_post_meta( $id, 'sp_condition', sp_array_value( $outcome, 'condition', null ) );
|
||||||
@@ -137,9 +147,13 @@ class SP_Admin_Sports {
|
|||||||
$primary_result = 0;
|
$primary_result = 0;
|
||||||
foreach ( $results as $index => $result ) {
|
foreach ( $results as $index => $result ) {
|
||||||
$post = self::get_post_array( $result, $post_type );
|
$post = self::get_post_array( $result, $post_type );
|
||||||
if ( empty( $post ) ) continue;
|
if ( empty( $post ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$id = self::insert_preset_post( $post, $index );
|
$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 ) );
|
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 );
|
self::delete_preset_posts( $post_type );
|
||||||
foreach ( $performances as $index => $performance ) {
|
foreach ( $performances as $index => $performance ) {
|
||||||
$post = self::get_post_array( $performance, $post_type );
|
$post = self::get_post_array( $performance, $post_type );
|
||||||
if ( empty( $post ) ) continue;
|
if ( empty( $post ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$id = self::insert_preset_post( $post, $index );
|
$id = self::insert_preset_post( $post, $index );
|
||||||
if ( isset( $performance['position'] ) ) {
|
if ( isset( $performance['position'] ) ) {
|
||||||
wp_set_object_terms( $id, $performance['position'], 'sp_position', false );
|
wp_set_object_terms( $id, $performance['position'], 'sp_position', false );
|
||||||
@@ -174,7 +190,9 @@ class SP_Admin_Sports {
|
|||||||
self::delete_preset_posts( $post_type );
|
self::delete_preset_posts( $post_type );
|
||||||
foreach ( $columns as $index => $column ) {
|
foreach ( $columns as $index => $column ) {
|
||||||
$post = self::get_post_array( $column, $post_type );
|
$post = self::get_post_array( $column, $post_type );
|
||||||
if ( empty( $post ) ) continue;
|
if ( empty( $post ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$id = self::insert_preset_post( $post, $index );
|
$id = self::insert_preset_post( $post, $index );
|
||||||
update_post_meta( $id, 'sp_equation', sp_array_value( $column, 'equation', null ) );
|
update_post_meta( $id, 'sp_equation', sp_array_value( $column, 'equation', null ) );
|
||||||
update_post_meta( $id, 'sp_precision', sp_array_value( $column, 'precision', 0 ) );
|
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 );
|
self::delete_preset_posts( $post_type );
|
||||||
foreach ( $metrics as $index => $metric ) {
|
foreach ( $metrics as $index => $metric ) {
|
||||||
$post = self::get_post_array( $metric, $post_type );
|
$post = self::get_post_array( $metric, $post_type );
|
||||||
if ( empty( $post ) ) continue;
|
if ( empty( $post ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$id = self::insert_preset_post( $post, $i + $index );
|
$id = self::insert_preset_post( $post, $i + $index );
|
||||||
$i ++;
|
$i ++;
|
||||||
}
|
}
|
||||||
@@ -199,7 +219,9 @@ class SP_Admin_Sports {
|
|||||||
self::delete_preset_posts( $post_type );
|
self::delete_preset_posts( $post_type );
|
||||||
foreach ( $specs as $index => $spec ) {
|
foreach ( $specs as $index => $spec ) {
|
||||||
$post = self::get_post_array( $spec, $post_type );
|
$post = self::get_post_array( $spec, $post_type );
|
||||||
if ( empty( $post ) ) continue;
|
if ( empty( $post ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$id = self::insert_preset_post( $post, $i + $index );
|
$id = self::insert_preset_post( $post, $i + $index );
|
||||||
$i ++;
|
$i ++;
|
||||||
}
|
}
|
||||||
@@ -210,14 +232,15 @@ class SP_Admin_Sports {
|
|||||||
self::delete_preset_posts( $post_type );
|
self::delete_preset_posts( $post_type );
|
||||||
foreach ( $statistics as $index => $statistic ) {
|
foreach ( $statistics as $index => $statistic ) {
|
||||||
$post = self::get_post_array( $statistic, $post_type );
|
$post = self::get_post_array( $statistic, $post_type );
|
||||||
if ( empty( $post ) ) continue;
|
if ( empty( $post ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$id = self::insert_preset_post( $post, $i + $index );
|
$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_equation', sp_array_value( $statistic, 'equation', null ) );
|
||||||
update_post_meta( $id, 'sp_precision', sp_array_value( $statistic, 'precision', 0 ) );
|
update_post_meta( $id, 'sp_precision', sp_array_value( $statistic, 'precision', 0 ) );
|
||||||
update_post_meta( $id, 'sp_type', sp_array_value( $statistic, 'type', 'total' ) );
|
update_post_meta( $id, 'sp_type', sp_array_value( $statistic, 'type', 'total' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
$options = sp_array_value( $preset, 'options', array() );
|
$options = sp_array_value( $preset, 'options', array() );
|
||||||
foreach ( $options as $option => $value ) {
|
foreach ( $options as $option => $value ) {
|
||||||
@@ -236,14 +259,14 @@ class SP_Admin_Sports {
|
|||||||
'meta_query' => array(
|
'meta_query' => array(
|
||||||
array(
|
array(
|
||||||
'key' => '_sp_preset',
|
'key' => '_sp_preset',
|
||||||
'value' => 1
|
'value' => 1,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Delete posts
|
// Delete posts
|
||||||
$old_posts = get_posts( $args );
|
$old_posts = get_posts( $args );
|
||||||
foreach( $old_posts as $post ):
|
foreach ( $old_posts as $post ) :
|
||||||
wp_delete_post( $post->ID, true );
|
wp_delete_post( $post->ID, true );
|
||||||
endforeach;
|
endforeach;
|
||||||
}
|
}
|
||||||
@@ -254,13 +277,17 @@ class SP_Admin_Sports {
|
|||||||
$post_array['post_title'] = $post;
|
$post_array['post_title'] = $post;
|
||||||
$post_array['post_name'] = sp_get_eos_safe_slug( $post_array['post_title'] );
|
$post_array['post_name'] = sp_get_eos_safe_slug( $post_array['post_title'] );
|
||||||
} elseif ( is_array( $post ) ) {
|
} 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_title'] = $post['name'];
|
||||||
$post_array['post_name'] = sp_array_value( $post, 'id', sp_get_eos_safe_slug( $post_array['post_title'] ) );
|
$post_array['post_name'] = sp_array_value( $post, 'id', sp_get_eos_safe_slug( $post_array['post_title'] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return empty array if post with same slug already exists
|
// 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
|
// Set post type
|
||||||
$post_array['post_type'] = $post_type;
|
$post_array['post_type'] = $post_type;
|
||||||
@@ -287,21 +314,26 @@ class SP_Admin_Sports {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sport category names
|
* Sport category names
|
||||||
|
*
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public static function sport_category_names() {
|
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' ),
|
'team-sports' => __( 'Team Sports', 'sportspress' ),
|
||||||
'racket-sports' => __( 'Racket Sports', 'sportspress' ),
|
'racket-sports' => __( 'Racket Sports', 'sportspress' ),
|
||||||
'water-sports' => __( 'Water Sports', 'sportspress' ),
|
'water-sports' => __( 'Water Sports', 'sportspress' ),
|
||||||
'target-sports' => __( 'Target Sports', 'sportspress' ),
|
'target-sports' => __( 'Target Sports', 'sportspress' ),
|
||||||
'esports' => __( 'Esports', 'sportspress' ),
|
'esports' => __( 'Esports', 'sportspress' ),
|
||||||
'other' => __( 'Other', 'sportspress' ),
|
'other' => __( 'Other', 'sportspress' ),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sport preset names for localization
|
* Sport preset names for localization
|
||||||
|
*
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public static function sport_preset_names() {
|
public static function sport_preset_names() {
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
* @version 1.4
|
* @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' ) ) :
|
if ( ! class_exists( 'SP_Admin_Status' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Status Class
|
* SP_Admin_Status Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_Status {
|
class SP_Admin_Status {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve metadata from a file. Based on WP Core's get_file_data function
|
* Retrieve metadata from a file. Based on WP Core's get_file_data function
|
||||||
@@ -38,10 +40,11 @@ class SP_Admin_Status {
|
|||||||
$file_data = str_replace( "\r", "\n", $file_data );
|
$file_data = str_replace( "\r", "\n", $file_data );
|
||||||
$version = '';
|
$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] );
|
$version = _cleanup_header_comment( $match[1] );
|
||||||
|
}
|
||||||
|
|
||||||
return $version ;
|
return $version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,7 +59,7 @@ class SP_Admin_Status {
|
|||||||
$result = array();
|
$result = array();
|
||||||
if ( $files ) {
|
if ( $files ) {
|
||||||
foreach ( $files as $key => $value ) {
|
foreach ( $files as $key => $value ) {
|
||||||
if ( ! in_array( $value, array( ".",".." ) ) ) {
|
if ( ! in_array( $value, array( '.', '..' ) ) ) {
|
||||||
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
|
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
|
||||||
$sub_files = $this->scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
|
$sub_files = $this->scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
|
||||||
foreach ( $sub_files as $sub_file ) {
|
foreach ( $sub_files as $sub_file ) {
|
||||||
@@ -70,7 +73,7 @@ class SP_Admin_Status {
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class SP_Admin_Taxonomies {
|
|||||||
|
|
||||||
// Get latitude and longitude from the last added venue
|
// Get latitude and longitude from the last added venue
|
||||||
$terms = get_terms( 'sp_venue', $args );
|
$terms = get_terms( 'sp_venue', $args );
|
||||||
if ( $terms && array_key_exists( 0, $terms) && is_object( reset( $terms ) ) ):
|
if ( $terms && array_key_exists( 0, $terms ) && is_object( reset( $terms ) ) ) :
|
||||||
$term = reset( $terms );
|
$term = reset( $terms );
|
||||||
$t_id = $term->term_id;
|
$t_id = $term->term_id;
|
||||||
$term_meta = get_option( "taxonomy_$t_id" );
|
$term_meta = get_option( "taxonomy_$t_id" );
|
||||||
@@ -108,7 +108,7 @@ class SP_Admin_Taxonomies {
|
|||||||
$address = sp_array_value( $term_meta, 'sp_address', '' );
|
$address = sp_array_value( $term_meta, 'sp_address', '' );
|
||||||
endif;
|
endif;
|
||||||
// Sanitize latitude and longitude, fallback to default.
|
// Sanitize latitude and longitude, fallback to default.
|
||||||
if( ! is_numeric( $latitude) || ! is_numeric( $longitude) ):
|
if ( ! is_numeric( $latitude ) || ! is_numeric( $longitude ) ) :
|
||||||
$latitude = '-37.8165647';
|
$latitude = '-37.8165647';
|
||||||
$longitude = '144.9475055';
|
$longitude = '144.9475055';
|
||||||
endif;
|
endif;
|
||||||
@@ -184,10 +184,23 @@ class SP_Admin_Taxonomies {
|
|||||||
?>
|
?>
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label><?php _e( 'Statistics', 'sportspress' ); ?></label>
|
<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
|
<?php
|
||||||
$options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
if ( is_rtl() ) :
|
||||||
foreach ( $options as $key => $value ):
|
?>
|
||||||
|
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 );
|
printf( '<option value="%s" %s>%s</option>', $key, selected( true ), $value );
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
@@ -210,10 +223,23 @@ class SP_Admin_Taxonomies {
|
|||||||
<th scope="row" valign="top"><label for="term_meta[sp_sections]"><?php _e( 'Statistics', 'sportspress' ); ?></label></th>
|
<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="">
|
<input type="hidden" name="term_meta[sp_sections]" value="">
|
||||||
<td>
|
<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
|
<?php
|
||||||
$options = apply_filters( 'sportspress_performance_sections', array( 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
if ( is_rtl() ) :
|
||||||
foreach ( $options as $key => $value ):
|
?>
|
||||||
|
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 );
|
printf( '<option value="%s" %s>%s</option>', $key, selected( in_array( $key, $sections ), true, false ), $value );
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
@@ -243,8 +269,8 @@ class SP_Admin_Taxonomies {
|
|||||||
$term_meta = get_option( "taxonomy_$t_id" );
|
$term_meta = get_option( "taxonomy_$t_id" );
|
||||||
$cat_keys = array_keys( $_POST['term_meta'] );
|
$cat_keys = array_keys( $_POST['term_meta'] );
|
||||||
foreach ( $cat_keys as $key ) {
|
foreach ( $cat_keys as $key ) {
|
||||||
if ( isset ( $_POST['term_meta'][ $key ] ) ) {
|
if ( isset( $_POST['term_meta'][ $key ] ) ) {
|
||||||
$term_meta[$key] = sanitize_text_field( $_POST['term_meta'][ $key ] );
|
$term_meta[ $key ] = sanitize_text_field( $_POST['term_meta'][ $key ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_option( "taxonomy_$t_id", $term_meta );
|
update_option( "taxonomy_$t_id", $term_meta );
|
||||||
@@ -264,9 +290,11 @@ class SP_Admin_Taxonomies {
|
|||||||
public function taxonomy_columns( $columns ) {
|
public function taxonomy_columns( $columns ) {
|
||||||
$new_columns = array();
|
$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) ) {
|
if ( array_key_exists( 'posts', $columns ) ) {
|
||||||
$new_columns['posts'] = $columns['posts'];
|
$new_columns['posts'] = $columns['posts'];
|
||||||
|
|
||||||
unset( $columns['posts'] );
|
unset( $columns['posts'] );
|
||||||
@@ -286,7 +314,7 @@ class SP_Admin_Taxonomies {
|
|||||||
$new_columns = array();
|
$new_columns = array();
|
||||||
$new_columns['sp_address'] = __( 'Address', 'sportspress' );
|
$new_columns['sp_address'] = __( 'Address', 'sportspress' );
|
||||||
|
|
||||||
if ( array_key_exists('posts', $columns) ) {
|
if ( array_key_exists( 'posts', $columns ) ) {
|
||||||
$new_columns['posts'] = $columns['posts'];
|
$new_columns['posts'] = $columns['posts'];
|
||||||
unset( $columns['posts'] );
|
unset( $columns['posts'] );
|
||||||
}
|
}
|
||||||
@@ -308,9 +336,11 @@ class SP_Admin_Taxonomies {
|
|||||||
$new_columns = array();
|
$new_columns = array();
|
||||||
$new_columns['sp_sections'] = __( 'Statistics', 'sportspress' );
|
$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) ) {
|
if ( array_key_exists( 'posts', $columns ) ) {
|
||||||
$new_columns['posts'] = $columns['posts'];
|
$new_columns['posts'] = $columns['posts'];
|
||||||
unset( $columns['posts'] );
|
unset( $columns['posts'] );
|
||||||
}
|
}
|
||||||
@@ -342,7 +372,16 @@ class SP_Admin_Taxonomies {
|
|||||||
|
|
||||||
} elseif ( $column == 'sp_sections' ) {
|
} 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 );
|
$sections = sp_get_term_sections( $id );
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,11 @@
|
|||||||
* @category Admin
|
* @category Admin
|
||||||
* @package SportsPress/Admin
|
* @package SportsPress/Admin
|
||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Welcome class.
|
* SP_Admin_Welcome class.
|
||||||
@@ -30,7 +32,7 @@ class SP_Admin_Welcome {
|
|||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->plugin = 'sportspress/sportspress.php';
|
$this->plugin = 'sportspress/sportspress.php';
|
||||||
|
|
||||||
add_action( 'admin_menu', array( $this, 'admin_menus') );
|
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
|
||||||
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
||||||
add_action( 'admin_init', array( $this, 'welcome' ) );
|
add_action( 'admin_init', array( $this, 'welcome' ) );
|
||||||
}
|
}
|
||||||
@@ -50,17 +52,17 @@ class SP_Admin_Welcome {
|
|||||||
$welcome_page_title = __( 'Welcome to SportsPress', 'sportspress' );
|
$welcome_page_title = __( 'Welcome to SportsPress', 'sportspress' );
|
||||||
|
|
||||||
switch ( $_GET['page'] ) {
|
switch ( $_GET['page'] ) {
|
||||||
case 'sp-about' :
|
case 'sp-about':
|
||||||
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-about', array( $this, 'about_screen' ) );
|
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-about', array( $this, 'about_screen' ) );
|
||||||
add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
|
add_action( 'admin_print_styles-' . $page, array( $this, 'admin_css' ) );
|
||||||
break;
|
break;
|
||||||
case 'sp-credits' :
|
case 'sp-credits':
|
||||||
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-credits', array( $this, 'credits_screen' ) );
|
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-credits', array( $this, 'credits_screen' ) );
|
||||||
add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
|
add_action( 'admin_print_styles-' . $page, array( $this, 'admin_css' ) );
|
||||||
break;
|
break;
|
||||||
case 'sp-translators' :
|
case 'sp-translators':
|
||||||
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-translators', array( $this, 'translators_screen' ) );
|
$page = add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sp-translators', array( $this, 'translators_screen' ) );
|
||||||
add_action( 'admin_print_styles-'. $page, array( $this, 'admin_css' ) );
|
add_action( 'admin_print_styles-' . $page, array( $this, 'admin_css' ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,8 +98,9 @@ class SP_Admin_Welcome {
|
|||||||
private function intro() {
|
private function intro() {
|
||||||
|
|
||||||
// Flush after upgrades
|
// Flush after upgrades
|
||||||
if ( ! empty( $_GET['sp-updated'] ) || ! empty( $_GET['sp-installed'] ) )
|
if ( ! empty( $_GET['sp-updated'] ) || ! empty( $_GET['sp-installed'] ) ) {
|
||||||
flush_rewrite_rules();
|
flush_rewrite_rules();
|
||||||
|
}
|
||||||
|
|
||||||
// Get major version number
|
// Get major version number
|
||||||
$version = explode( '.', SP()->version, 3 );
|
$version = explode( '.', SP()->version, 3 );
|
||||||
@@ -110,28 +113,50 @@ class SP_Admin_Welcome {
|
|||||||
|
|
||||||
<div class="about-text sp-about-text">
|
<div class="about-text sp-about-text">
|
||||||
<?php
|
<?php
|
||||||
if ( ! empty( $_GET['sp-installed'] ) )
|
if ( ! empty( $_GET['sp-installed'] ) ) {
|
||||||
$message = __( 'Thanks, all done!', 'sportspress' );
|
$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' );
|
$message = __( 'Thank you for updating to the latest version!', 'sportspress' );
|
||||||
else
|
} else {
|
||||||
$message = __( 'Thanks for installing!', 'sportspress' );
|
$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>
|
</div>
|
||||||
|
|
||||||
<p class="sportspress-actions">
|
<a href="
|
||||||
<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>
|
<?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="<?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>
|
<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>
|
<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>
|
</p>
|
||||||
|
|
||||||
<h2 class="nav-tab-wrapper">
|
<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' ); ?>
|
<?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' ); ?>
|
<?php _e( 'Credits', 'sportspress' ); ?>
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
</h2>
|
||||||
@@ -142,7 +167,7 @@ class SP_Admin_Welcome {
|
|||||||
* Output the about screen.
|
* Output the about screen.
|
||||||
*/
|
*/
|
||||||
public function 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' : '' );
|
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
|
||||||
?>
|
?>
|
||||||
<div class="wrap about-wrap about-sportspress-wrap">
|
<div class="wrap about-wrap about-sportspress-wrap">
|
||||||
@@ -151,11 +176,11 @@ class SP_Admin_Welcome {
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Save settings
|
// Save settings
|
||||||
if ( isset( $_POST['timezone_string'] ) ):
|
if ( isset( $_POST['timezone_string'] ) ) :
|
||||||
update_option( 'timezone_string', sanitize_text_field( $_POST['timezone_string'] ) );
|
update_option( 'timezone_string', sanitize_text_field( $_POST['timezone_string'] ) );
|
||||||
update_option( 'sportspress_basic_setup', 1 );
|
update_option( 'sportspress_basic_setup', 1 );
|
||||||
endif;
|
endif;
|
||||||
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) ):
|
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) ) :
|
||||||
$sport = sanitize_text_field( $_POST['sportspress_sport'] );
|
$sport = sanitize_text_field( $_POST['sportspress_sport'] );
|
||||||
SP_Admin_Sports::apply_preset( $sport );
|
SP_Admin_Sports::apply_preset( $sport );
|
||||||
update_option( 'sportspress_sport', $sport );
|
update_option( 'sportspress_sport', $sport );
|
||||||
@@ -167,7 +192,7 @@ class SP_Admin_Welcome {
|
|||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
if ( isset( $_POST['add_sample_data'] ) ):
|
if ( isset( $_POST['add_sample_data'] ) ) :
|
||||||
SP_Admin_Sample_Data::delete_posts();
|
SP_Admin_Sample_Data::delete_posts();
|
||||||
SP_Admin_Sample_Data::insert_posts();
|
SP_Admin_Sample_Data::insert_posts();
|
||||||
endif;
|
endif;
|
||||||
@@ -227,7 +252,7 @@ class SP_Admin_Welcome {
|
|||||||
|
|
||||||
<a class="button button-primary button-hero" href="<?php echo esc_url( apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ) ); ?>"><?php _e( 'Upgrade to Pro', 'sportspress' ); ?></a>
|
<a class="button button-primary button-hero" href="<?php echo esc_url( apply_filters( 'sportspress_pro_url', 'http://tboy.co/pro' ) ); ?>"><?php _e( 'Upgrade to Pro', 'sportspress' ); ?></a>
|
||||||
|
|
||||||
<p><?php _e( 'Get SportsPress Pro to get access to all modules. You can upgrade any time without losing any of your data.','sportspress' ); ?></p>
|
<p><?php _e( 'Get SportsPress Pro to get access to all modules. You can upgrade any time without losing any of your data.', 'sportspress' ); ?></p>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
@@ -277,8 +302,21 @@ class SP_Admin_Welcome {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php do_action( 'sportspress_after_welcome_features' ); ?>
|
<?php do_action( 'sportspress_after_welcome_features' ); ?>
|
||||||
|
<a href="
|
||||||
<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>
|
<?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>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -331,7 +369,8 @@ class SP_Admin_Welcome {
|
|||||||
|
|
||||||
foreach ( $contributors as $contributor ) {
|
foreach ( $contributors as $contributor ) {
|
||||||
$contributor_list .= '<li class="wp-person">';
|
$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_url( 'https://github.com/' . $contributor->login ),
|
||||||
esc_html( sprintf( __( 'View %s', 'sportspress' ), $contributor->login ) )
|
esc_html( sprintf( __( 'View %s', 'sportspress' ), $contributor->login ) )
|
||||||
);
|
);
|
||||||
@@ -383,22 +422,26 @@ class SP_Admin_Welcome {
|
|||||||
public function welcome() {
|
public function welcome() {
|
||||||
|
|
||||||
// Bail if no activation redirect transient is set
|
// Bail if no activation redirect transient is set
|
||||||
if ( ! get_transient( '_sp_activation_redirect' ) )
|
if ( ! get_transient( '_sp_activation_redirect' ) ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the redirect transient
|
// Delete the redirect transient
|
||||||
delete_transient( '_sp_activation_redirect' );
|
delete_transient( '_sp_activation_redirect' );
|
||||||
|
|
||||||
// Bail if we are waiting to install or update via the interface update/install links
|
// 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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Bail if activating from network, or bulk, or within an iFrame
|
// 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;
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! get_option( 'sportspress_completed_setup' ) ) {
|
if ( ! get_option( 'sportspress_completed_setup' ) ) {
|
||||||
wp_redirect( admin_url( 'admin.php?page=sp-setup' ) );
|
wp_redirect( admin_url( 'admin.php?page=sp-setup' ) );
|
||||||
|
|||||||
@@ -36,31 +36,31 @@ class SP_Admin {
|
|||||||
*/
|
*/
|
||||||
public function includes() {
|
public function includes() {
|
||||||
// Functions
|
// Functions
|
||||||
include_once( 'sp-admin-functions.php' );
|
include_once 'sp-admin-functions.php';
|
||||||
|
|
||||||
// Classes
|
// Classes
|
||||||
include_once( 'class-sp-admin-post-types.php' );
|
include_once 'class-sp-admin-post-types.php';
|
||||||
include_once( 'class-sp-admin-taxonomies.php' );
|
include_once 'class-sp-admin-taxonomies.php';
|
||||||
include_once( 'class-sp-admin-ajax.php' );
|
include_once 'class-sp-admin-ajax.php';
|
||||||
|
|
||||||
// Classes we only need if the ajax is not-ajax
|
// Classes we only need if the ajax is not-ajax
|
||||||
if ( ! is_ajax() ) {
|
if ( ! is_ajax() ) {
|
||||||
include( 'class-sp-admin-menus.php' );
|
include 'class-sp-admin-menus.php';
|
||||||
include( 'class-sp-admin-welcome.php' );
|
include 'class-sp-admin-welcome.php';
|
||||||
include( 'class-sp-admin-notices.php' );
|
include 'class-sp-admin-notices.php';
|
||||||
include( 'class-sp-admin-assets.php' );
|
include 'class-sp-admin-assets.php';
|
||||||
include( 'class-sp-admin-permalink-settings.php' );
|
include 'class-sp-admin-permalink-settings.php';
|
||||||
|
|
||||||
if ( 'yes' == get_option( 'sportspress_rich_editing', 'yes' ) ):
|
if ( 'yes' == get_option( 'sportspress_rich_editing', 'yes' ) ) :
|
||||||
include( 'class-sp-admin-editor.php' );
|
include 'class-sp-admin-editor.php';
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup/welcome
|
// Setup/welcome
|
||||||
if ( ! empty( $_GET['page'] ) ) {
|
if ( ! empty( $_GET['page'] ) ) {
|
||||||
switch ( $_GET['page'] ) {
|
switch ( $_GET['page'] ) {
|
||||||
case 'sp-setup' :
|
case 'sp-setup':
|
||||||
include_once( 'class-sp-admin-setup-wizard.php' );
|
include_once 'class-sp-admin-setup-wizard.php';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,8 +73,8 @@ class SP_Admin {
|
|||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
|
|
||||||
switch ( $screen->id ) {
|
switch ( $screen->id ) {
|
||||||
case 'dashboard' :
|
case 'dashboard':
|
||||||
include( 'class-sp-admin-dashboard.php' );
|
include 'class-sp-admin-dashboard.php';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ class SP_Admin {
|
|||||||
public function prevent_admin_access() {
|
public function prevent_admin_access() {
|
||||||
$prevent_access = false;
|
$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;
|
$prevent_access = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.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' ) ) {
|
if ( class_exists( 'WP_Importer' ) ) {
|
||||||
class SP_Event_Importer extends SP_Importer {
|
class SP_Event_Importer extends SP_Importer {
|
||||||
@@ -32,9 +34,10 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
'sp_player' => __( 'Players', 'sportspress' ),
|
'sp_player' => __( 'Players', 'sportspress' ),
|
||||||
);
|
);
|
||||||
$performance_labels = sp_get_var_labels( 'sp_performance' );
|
$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 );
|
$this->columns = array_merge( $this->columns, $performance_labels );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* import function.
|
* import function.
|
||||||
@@ -47,7 +50,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||||
$this->imported = $this->skipped = 0;
|
$this->imported = $this->skipped = 0;
|
||||||
|
|
||||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||||
$this->footer();
|
$this->footer();
|
||||||
die();
|
die();
|
||||||
endif;
|
endif;
|
||||||
@@ -64,15 +67,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$result_labels = sp_get_var_labels( 'sp_result' );
|
$result_labels = sp_get_var_labels( 'sp_result' );
|
||||||
$performance_labels = sp_get_var_labels( 'sp_performance' );
|
$performance_labels = sp_get_var_labels( 'sp_performance' );
|
||||||
|
|
||||||
foreach ( $rows as $row ):
|
foreach ( $rows as $row ) :
|
||||||
|
|
||||||
$row = array_filter( $row );
|
$row = array_filter( $row );
|
||||||
|
|
||||||
if ( empty( $row ) ) continue;
|
if ( empty( $row ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$meta = array();
|
$meta = array();
|
||||||
|
|
||||||
foreach ( $columns as $index => $key ):
|
foreach ( $columns as $index => $key ) :
|
||||||
$meta[ $key ] = sp_array_value( $row, $index );
|
$meta[ $key ] = sp_array_value( $row, $index );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
@@ -105,16 +110,16 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$player = array(
|
$player = array(
|
||||||
sp_array_value( $meta, 'sp_player' ),
|
sp_array_value( $meta, 'sp_player' ),
|
||||||
);
|
);
|
||||||
unset( $meta['sp_player' ] );
|
unset( $meta['sp_player'] );
|
||||||
foreach ( $performance_labels as $key => $label ):
|
foreach ( $performance_labels as $key => $label ) :
|
||||||
$player[] = sp_array_value( $meta, $key, '' );
|
$player[] = sp_array_value( $meta, $key, '' );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
// Add new event if date is given
|
// Add new event if date is given
|
||||||
if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ):
|
if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ) :
|
||||||
|
|
||||||
// Add player performance to last event if available
|
// Add player performance to last event if available
|
||||||
if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ):
|
if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ) :
|
||||||
update_post_meta( $id, 'sp_players', $players );
|
update_post_meta( $id, 'sp_players', $players );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -124,7 +129,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
// Format date
|
// Format date
|
||||||
$date = str_replace( '/', '-', trim( $date ) );
|
$date = str_replace( '/', '-', trim( $date ) );
|
||||||
$date_array = explode( '-', $date );
|
$date_array = explode( '-', $date );
|
||||||
switch ( $date_format ):
|
switch ( $date_format ) :
|
||||||
case 'dd/mm/yyyy':
|
case 'dd/mm/yyyy':
|
||||||
$date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
|
$date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
|
||||||
substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
|
substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
|
||||||
@@ -142,12 +147,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
endswitch;
|
endswitch;
|
||||||
|
|
||||||
// Add time to date if given
|
// Add time to date if given
|
||||||
if ( ! empty( $time ) ):
|
if ( ! empty( $time ) ) :
|
||||||
$date .= ' ' . trim( $time );
|
$date .= ' ' . trim( $time );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Define post type args
|
// 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
|
// Insert event
|
||||||
$id = wp_insert_post( $args );
|
$id = wp_insert_post( $args );
|
||||||
@@ -159,17 +169,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
update_post_meta( $id, '_sp_import', 1 );
|
update_post_meta( $id, '_sp_import', 1 );
|
||||||
|
|
||||||
// Update event format
|
// Update event format
|
||||||
if ( $event_format ):
|
if ( $event_format ) :
|
||||||
update_post_meta( $id, 'sp_format', $event_format );
|
update_post_meta( $id, 'sp_format', $event_format );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Update league
|
// Update league
|
||||||
if ( $league ):
|
if ( $league ) :
|
||||||
wp_set_object_terms( $id, $league, 'sp_league', false );
|
wp_set_object_terms( $id, $league, 'sp_league', false );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Update season
|
// Update season
|
||||||
if ( $season ):
|
if ( $season ) :
|
||||||
wp_set_object_terms( $id, $season, 'sp_season', false );
|
wp_set_object_terms( $id, $season, 'sp_season', false );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -182,7 +192,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add new team if team name is given
|
// Add new team if team name is given
|
||||||
if ( sizeof( $team ) > 0 && ! empty( $team[0] ) ):
|
if ( sizeof( $team ) > 0 && ! empty( $team[0] ) ) :
|
||||||
|
|
||||||
// List team columns
|
// List team columns
|
||||||
list( $team_name, $result, $outcome ) = $team;
|
list( $team_name, $result, $outcome ) = $team;
|
||||||
@@ -191,20 +201,31 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$team_object = get_page_by_title( stripslashes( $team_name ), OBJECT, 'sp_team' );
|
$team_object = get_page_by_title( stripslashes( $team_name ), OBJECT, 'sp_team' );
|
||||||
|
|
||||||
// Get or insert team
|
// Get or insert team
|
||||||
if ( $team_object ):
|
if ( $team_object ) :
|
||||||
|
|
||||||
// Make sure team is published
|
// Make sure team is published
|
||||||
if ( $team_object->post_status != 'publish' ):
|
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;
|
endif;
|
||||||
|
|
||||||
// Get team ID
|
// Get team ID
|
||||||
$team_id = $team_object->ID;
|
$team_id = $team_object->ID;
|
||||||
|
|
||||||
else:
|
else :
|
||||||
|
|
||||||
// Insert team
|
// 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
|
// Flag as import
|
||||||
update_post_meta( $team_id, '_sp_import', 1 );
|
update_post_meta( $team_id, '_sp_import', 1 );
|
||||||
@@ -212,17 +233,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Update league
|
// Update league
|
||||||
if ( $league ):
|
if ( $league ) :
|
||||||
wp_set_object_terms( $team_id, $league, 'sp_league', true );
|
wp_set_object_terms( $team_id, $league, 'sp_league', true );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Update season
|
// Update season
|
||||||
if ( $season ):
|
if ( $season ) :
|
||||||
wp_set_object_terms( $team_id, $season, 'sp_season', true );
|
wp_set_object_terms( $team_id, $season, 'sp_season', true );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add to event if exists
|
// Add to event if exists
|
||||||
if ( isset( $id ) ):
|
if ( isset( $id ) ) :
|
||||||
|
|
||||||
// Add team to event
|
// Add team to event
|
||||||
add_post_meta( $id, 'sp_team', $team_id );
|
add_post_meta( $id, 'sp_team', $team_id );
|
||||||
@@ -235,21 +256,21 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
// Create team results array from result keys
|
// Create team results array from result keys
|
||||||
$team_results = array();
|
$team_results = array();
|
||||||
if ( sizeof( $result_labels ) > 0 ):
|
if ( sizeof( $result_labels ) > 0 ) :
|
||||||
foreach( $result_labels as $key => $label ):
|
foreach ( $result_labels as $key => $label ) :
|
||||||
$team_results[ $key ] = trim( array_shift( $results ) );
|
$team_results[ $key ] = trim( array_shift( $results ) );
|
||||||
endforeach;
|
endforeach;
|
||||||
$team_results[ 'outcome' ] = array();
|
$team_results['outcome'] = array();
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Explode outcomes into array
|
// Explode outcomes into array
|
||||||
$outcomes = explode( '|', $outcome );
|
$outcomes = explode( '|', $outcome );
|
||||||
|
|
||||||
// Add outcome slugs to team outcomes array
|
// Add outcome slugs to team outcomes array
|
||||||
foreach ( $outcomes as $outcome ):
|
foreach ( $outcomes as $outcome ) :
|
||||||
|
|
||||||
// Continue if outcome doesn't exist
|
// Continue if outcome doesn't exist
|
||||||
if ( $outcome == null ):
|
if ( $outcome == null ) :
|
||||||
continue;
|
continue;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -259,20 +280,31 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
// Get or insert outcome
|
// Get or insert outcome
|
||||||
$outcome_object = get_page_by_title( stripslashes( $outcome ), OBJECT, 'sp_outcome' );
|
$outcome_object = get_page_by_title( stripslashes( $outcome ), OBJECT, 'sp_outcome' );
|
||||||
|
|
||||||
if ( $outcome_object ):
|
if ( $outcome_object ) :
|
||||||
|
|
||||||
// Make sure outcome is published
|
// Make sure outcome is published
|
||||||
if ( $outcome_object->post_status != 'publish' ):
|
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;
|
endif;
|
||||||
|
|
||||||
// Get outcome slug
|
// Get outcome slug
|
||||||
$outcome_slug = $outcome_object->post_name;
|
$outcome_slug = $outcome_object->post_name;
|
||||||
|
|
||||||
else:
|
else :
|
||||||
|
|
||||||
// Insert outcome
|
// 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
|
// Get outcome slug
|
||||||
$post_data = get_post( $outcome_id, ARRAY_A );
|
$post_data = get_post( $outcome_id, ARRAY_A );
|
||||||
@@ -284,7 +316,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add to team results array
|
// Add to team results array
|
||||||
$team_results[ 'outcome' ][] = $outcome_slug;
|
$team_results['outcome'][] = $outcome_slug;
|
||||||
|
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
@@ -292,7 +324,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$event_results = get_post_meta( $id, 'sp_results', true );
|
$event_results = get_post_meta( $id, 'sp_results', true );
|
||||||
|
|
||||||
// Create new array if results not exists
|
// Create new array if results not exists
|
||||||
if ( ! $event_results ):
|
if ( ! $event_results ) :
|
||||||
$event_results = array();
|
$event_results = array();
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -328,7 +360,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add new player if player name is given
|
// Add new player if player name is given
|
||||||
if ( sizeof( $player ) > 0 && ! empty( $player[0] ) ):
|
if ( sizeof( $player ) > 0 && ! empty( $player[0] ) ) :
|
||||||
|
|
||||||
// Get and unset player name leaving us with the performance
|
// Get and unset player name leaving us with the performance
|
||||||
$player_name = $player[0];
|
$player_name = $player[0];
|
||||||
@@ -338,11 +370,16 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
|
$player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
|
||||||
|
|
||||||
// Get or insert player
|
// Get or insert player
|
||||||
if ( $player_object ):
|
if ( $player_object ) :
|
||||||
|
|
||||||
// Make sure player is published
|
// Make sure player is published
|
||||||
if ( $player_object->post_status != 'publish' ):
|
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;
|
endif;
|
||||||
|
|
||||||
// Get player ID
|
// Get player ID
|
||||||
@@ -351,10 +388,16 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
// Get player number
|
// Get player number
|
||||||
$player_number = get_post_meta( $player_id, 'sp_number', true );
|
$player_number = get_post_meta( $player_id, 'sp_number', true );
|
||||||
|
|
||||||
else:
|
else :
|
||||||
|
|
||||||
// Insert player
|
// 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
|
// Flag as import
|
||||||
update_post_meta( $player_id, '_sp_import', 1 );
|
update_post_meta( $player_id, '_sp_import', 1 );
|
||||||
@@ -368,29 +411,29 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Update league
|
// Update league
|
||||||
if ( $league ):
|
if ( $league ) :
|
||||||
wp_set_object_terms( $player_id, $league, 'sp_league', true );
|
wp_set_object_terms( $player_id, $league, 'sp_league', true );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Update season
|
// Update season
|
||||||
if ( $season ):
|
if ( $season ) :
|
||||||
wp_set_object_terms( $player_id, $season, 'sp_season', true );
|
wp_set_object_terms( $player_id, $season, 'sp_season', true );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add to event if exists
|
// Add to event if exists
|
||||||
if ( isset( $id ) ):
|
if ( isset( $id ) ) :
|
||||||
|
|
||||||
// Add player to event
|
// Add player to event
|
||||||
add_post_meta( $id, 'sp_player', $player_id );
|
add_post_meta( $id, 'sp_player', $player_id );
|
||||||
|
|
||||||
// Add player performance to array if team is available
|
// Add player performance to array if team is available
|
||||||
if ( isset( $team_id ) ):
|
if ( isset( $team_id ) ) :
|
||||||
|
|
||||||
// Initialize performance array
|
// Initialize performance array
|
||||||
$performance = array( 'number' => $player_number );
|
$performance = array( 'number' => $player_number );
|
||||||
|
|
||||||
// Map keys to player performance
|
// Map keys to player performance
|
||||||
foreach ( $performance_labels as $key => $label ):
|
foreach ( $performance_labels as $key => $label ) :
|
||||||
$performance[ $key ] = array_shift( $player );
|
$performance[ $key ] = array_shift( $player );
|
||||||
endforeach;
|
endforeach;
|
||||||
$players[ $team_id ][ $player_id ] = $performance;
|
$players[ $team_id ][ $player_id ] = $performance;
|
||||||
@@ -401,14 +444,14 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$past_teams = get_post_meta( $player_id, 'sp_past_team', false );
|
$past_teams = get_post_meta( $player_id, 'sp_past_team', false );
|
||||||
|
|
||||||
// Add team if not exists in player
|
// Add team if not exists in player
|
||||||
if ( ! in_array( $team_id, $player_teams ) ):
|
if ( ! in_array( $team_id, $player_teams ) ) :
|
||||||
add_post_meta( $player_id, 'sp_team', $team_id );
|
add_post_meta( $player_id, 'sp_team', $team_id );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add as past team or set current team if not set
|
// Add as past team or set current team if not set
|
||||||
if ( ! $current_team ):
|
if ( ! $current_team ) :
|
||||||
update_post_meta( $player_id, 'sp_current_team', $team_id );
|
update_post_meta( $player_id, 'sp_current_team', $team_id );
|
||||||
elseif ( $current_team != $team_id && ! in_array( $team_id, $past_teams ) ):
|
elseif ( $current_team != $team_id && ! in_array( $team_id, $past_teams ) ) :
|
||||||
add_post_meta( $player_id, 'sp_past_team', $team_id );
|
add_post_meta( $player_id, 'sp_past_team', $team_id );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -421,13 +464,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
// Add player performance to last event if available
|
// Add player performance to last event if available
|
||||||
if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ):
|
if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ) :
|
||||||
update_post_meta( $id, 'sp_players', $players );
|
update_post_meta( $id, 'sp_players', $players );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Show Result
|
// Show Result
|
||||||
echo '<div class="updated settings-error below-h2"><p>
|
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>';
|
</p></div>';
|
||||||
|
|
||||||
$this->import_end();
|
$this->import_end();
|
||||||
@@ -437,7 +480,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* Performs post-import cleanup of files and the cache
|
* Performs post-import cleanup of files and the cache
|
||||||
*/
|
*/
|
||||||
function import_end() {
|
function import_end() {
|
||||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_event') . '">' . __( 'View Events', 'sportspress' ) . '</a>' . '</p>';
|
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_event' ) . '">' . __( 'View Events', 'sportspress' ) . '</a>' . '</p>';
|
||||||
|
|
||||||
do_action( 'import_end' );
|
do_action( 'import_end' );
|
||||||
}
|
}
|
||||||
@@ -450,7 +493,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
*/
|
*/
|
||||||
function greet() {
|
function greet() {
|
||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||||
echo '<p>' . sprintf( __( 'Events need to be defined with columns in a specific order (3+ columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/events-sample.csv' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Events need to be defined with columns in a specific order (3+ columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/events-sample.csv' ) . '</p>';
|
||||||
echo '<p>' . sprintf( __( 'Supports CSV files generated by <a href="%s">LeagueLobster</a>.', 'sportspress' ), 'http://tboy.co/leaguelobster' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Supports CSV files generated by <a href="%s">LeagueLobster</a>.', 'sportspress' ), 'http://tboy.co/leaguelobster' ) . '</p>';
|
||||||
wp_import_upload_form( 'admin.php?import=sp_event_csv&step=1' );
|
wp_import_upload_form( 'admin.php?import=sp_event_csv&step=1' );
|
||||||
@@ -473,7 +516,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
<fieldset id="post-formats-select">
|
<fieldset id="post-formats-select">
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?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>
|
<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
|
<?php
|
||||||
@@ -485,33 +528,37 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><label><?php _e( 'League', 'sportspress' ); ?></label><br/></th>
|
<th scope="row"><label><?php _e( 'League', 'sportspress' ); ?></label><br/></th>
|
||||||
<td><?php
|
<td>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'sp_league',
|
'name' => 'sp_league',
|
||||||
'values' => 'slug',
|
'values' => 'slug',
|
||||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
if ( ! sp_dropdown_taxonomies( $args ) ) :
|
||||||
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
||||||
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
|
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
?></td>
|
?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><label><?php _e( 'Season', 'sportspress' ); ?></label><br/></th>
|
<th scope="row"><label><?php _e( 'Season', 'sportspress' ); ?></label><br/></th>
|
||||||
<td><?php
|
<td>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'sp_season',
|
'name' => 'sp_season',
|
||||||
'values' => 'slug',
|
'values' => 'slug',
|
||||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
if ( ! sp_dropdown_taxonomies( $args ) ) :
|
||||||
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
||||||
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
|
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
?></td>
|
?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.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' ) ) {
|
if ( class_exists( 'WP_Importer' ) ) {
|
||||||
class SP_Event_Performance_Importer extends SP_Importer {
|
class SP_Event_Performance_Importer extends SP_Importer {
|
||||||
@@ -26,9 +28,10 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
'sp_player' => __( 'Player', 'sportspress' ),
|
'sp_player' => __( 'Player', 'sportspress' ),
|
||||||
);
|
);
|
||||||
$performance_labels = sp_get_var_labels( 'sp_performance' );
|
$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 );
|
$this->columns = array_merge( $this->columns, $performance_labels );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* import function.
|
* import function.
|
||||||
@@ -41,7 +44,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
function import( $array = array(), $columns = array( 'sp_player' ) ) {
|
function import( $array = array(), $columns = array( 'sp_player' ) ) {
|
||||||
$this->imported = $this->skipped = 0;
|
$this->imported = $this->skipped = 0;
|
||||||
|
|
||||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||||
$this->footer();
|
$this->footer();
|
||||||
die();
|
die();
|
||||||
endif;
|
endif;
|
||||||
@@ -58,30 +61,38 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$team_performance = array();
|
$team_performance = array();
|
||||||
$name_index = (int) array_search( 'sp_player', $columns );
|
$name_index = (int) array_search( 'sp_player', $columns );
|
||||||
|
|
||||||
foreach ( $rows as $row ):
|
foreach ( $rows as $row ) :
|
||||||
|
|
||||||
$row = array_filter( $row );
|
$row = array_filter( $row );
|
||||||
|
|
||||||
if ( empty( $row ) ) continue;
|
if ( empty( $row ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$player_name = sp_array_value( $row, $name_index );
|
$player_name = sp_array_value( $row, $name_index );
|
||||||
|
|
||||||
if ( ! $player_name ):
|
if ( ! $player_name ) :
|
||||||
$this->skipped ++;
|
$this->skipped ++;
|
||||||
continue;
|
continue;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
|
$player_object = get_page_by_title( stripslashes( $player_name ), OBJECT, 'sp_player' );
|
||||||
|
|
||||||
if ( $player_object ):
|
if ( $player_object ) :
|
||||||
|
|
||||||
// Get player ID
|
// Get player ID
|
||||||
$player_id = $player_object->ID;
|
$player_id = $player_object->ID;
|
||||||
|
|
||||||
else:
|
else :
|
||||||
|
|
||||||
// Insert player
|
// 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
|
// Flag as import
|
||||||
update_post_meta( $player_id, '_sp_import', 1 );
|
update_post_meta( $player_id, '_sp_import', 1 );
|
||||||
@@ -91,8 +102,10 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$team_players[] = $player_id;
|
$team_players[] = $player_id;
|
||||||
$player = array();
|
$player = array();
|
||||||
|
|
||||||
foreach ( $columns as $i => $key ):
|
foreach ( $columns as $i => $key ) :
|
||||||
if ( 'sp_player' === $key ) continue;
|
if ( 'sp_player' === $key ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$player[ $key ] = sp_array_value( $row, $i, '' );
|
$player[ $key ] = sp_array_value( $row, $i, '' );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
@@ -100,13 +113,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
if ( $event && $team ):
|
if ( $event && $team ) :
|
||||||
$the_players = get_post_meta( $event, 'sp_player', false );
|
$the_players = get_post_meta( $event, 'sp_player', false );
|
||||||
$players = array();
|
$players = array();
|
||||||
for ( $i = 0; $i < $teams; $i++ ):
|
for ( $i = 0; $i < $teams; $i++ ) :
|
||||||
if ( $index == $i ):
|
if ( $index == $i ) :
|
||||||
array_push( $players, $team_players );
|
array_push( $players, $team_players );
|
||||||
else:
|
else :
|
||||||
array_push( $players, sp_array_between( $the_players, 0, $i ) );
|
array_push( $players, sp_array_between( $the_players, 0, $i ) );
|
||||||
endif;
|
endif;
|
||||||
endfor;
|
endfor;
|
||||||
@@ -122,7 +135,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
// Show Result
|
// Show Result
|
||||||
echo '<div class="updated settings-error below-h2"><p>
|
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>';
|
</p></div>';
|
||||||
|
|
||||||
$this->import_end( $event );
|
$this->import_end( $event );
|
||||||
@@ -132,7 +145,15 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* Performs post-import cleanup of files and the cache
|
* Performs post-import cleanup of files and the cache
|
||||||
*/
|
*/
|
||||||
function import_end( $event = 0 ) {
|
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' );
|
do_action( 'import_end' );
|
||||||
}
|
}
|
||||||
@@ -149,8 +170,14 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
|
|
||||||
if ( $event ) {
|
if ( $event ) {
|
||||||
$args = array_merge( $_REQUEST, array( 'import' => 'sp_event_performance_csv', 'step' => '1' ) );
|
$args = array_merge(
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
$_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>';
|
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' ) );
|
wp_import_upload_form( add_query_arg( $args, 'admin.php' ) );
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7
|
* @version 2.7
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
if ( class_exists( 'WP_Importer' ) ) {
|
if ( class_exists( 'WP_Importer' ) ) {
|
||||||
class SP_Fixture_Importer extends SP_Importer {
|
class SP_Fixture_Importer extends SP_Importer {
|
||||||
@@ -44,7 +46,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||||
$this->imported = $this->skipped = 0;
|
$this->imported = $this->skipped = 0;
|
||||||
|
|
||||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||||
$this->footer();
|
$this->footer();
|
||||||
die();
|
die();
|
||||||
endif;
|
endif;
|
||||||
@@ -57,15 +59,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : $_POST['sp_season'] );
|
$season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : $_POST['sp_season'] );
|
||||||
$date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : $_POST['sp_date_format'] );
|
$date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : $_POST['sp_date_format'] );
|
||||||
|
|
||||||
foreach ( $rows as $row ):
|
foreach ( $rows as $row ) :
|
||||||
|
|
||||||
$row = array_filter( $row );
|
$row = array_filter( $row );
|
||||||
|
|
||||||
if ( empty( $row ) ) continue;
|
if ( empty( $row ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$meta = array();
|
$meta = array();
|
||||||
|
|
||||||
foreach ( $columns as $index => $key ):
|
foreach ( $columns as $index => $key ) :
|
||||||
$meta[ $key ] = sp_array_value( $row, $index );
|
$meta[ $key ] = sp_array_value( $row, $index );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
@@ -83,7 +87,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Add new event if date is given
|
// Add new event if date is given
|
||||||
if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ):
|
if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ) :
|
||||||
|
|
||||||
// List event columns
|
// List event columns
|
||||||
list( $date, $time, $venue, $day ) = $event;
|
list( $date, $time, $venue, $day ) = $event;
|
||||||
@@ -91,7 +95,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
// Format date
|
// Format date
|
||||||
$date = str_replace( '/', '-', trim( $date ) );
|
$date = str_replace( '/', '-', trim( $date ) );
|
||||||
$date_array = explode( '-', $date );
|
$date_array = explode( '-', $date );
|
||||||
switch ( $date_format ):
|
switch ( $date_format ) :
|
||||||
case 'dd/mm/yyyy':
|
case 'dd/mm/yyyy':
|
||||||
$date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
|
$date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
|
||||||
substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
|
substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
|
||||||
@@ -109,12 +113,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
endswitch;
|
endswitch;
|
||||||
|
|
||||||
// Add time to date if given
|
// Add time to date if given
|
||||||
if ( ! empty( $time ) ):
|
if ( ! empty( $time ) ) :
|
||||||
$date .= ' ' . trim( $time );
|
$date .= ' ' . trim( $time );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Define post type args
|
// 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
|
// Insert event
|
||||||
$id = wp_insert_post( $args );
|
$id = wp_insert_post( $args );
|
||||||
@@ -123,17 +132,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
update_post_meta( $id, '_sp_import', 1 );
|
update_post_meta( $id, '_sp_import', 1 );
|
||||||
|
|
||||||
// Update event format
|
// Update event format
|
||||||
if ( $event_format ):
|
if ( $event_format ) :
|
||||||
update_post_meta( $id, 'sp_format', $event_format );
|
update_post_meta( $id, 'sp_format', $event_format );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Update league
|
// Update league
|
||||||
if ( $league ):
|
if ( $league ) :
|
||||||
wp_set_object_terms( $id, $league, 'sp_league', false );
|
wp_set_object_terms( $id, $league, 'sp_league', false );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Update season
|
// Update season
|
||||||
if ( $season ):
|
if ( $season ) :
|
||||||
wp_set_object_terms( $id, $season, 'sp_season', false );
|
wp_set_object_terms( $id, $season, 'sp_season', false );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -156,30 +165,41 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add teams to event
|
// Add teams to event
|
||||||
if ( sizeof( $teams ) > 0 ):
|
if ( sizeof( $teams ) > 0 ) :
|
||||||
|
|
||||||
foreach ( $teams as $team_name ):
|
foreach ( $teams as $team_name ) :
|
||||||
|
|
||||||
if ( '' !== $team_name ):
|
if ( '' !== $team_name ) :
|
||||||
|
|
||||||
// Find out if team exists
|
// Find out if team exists
|
||||||
$team_object = get_page_by_title( stripslashes( $team_name ), OBJECT, 'sp_team' );
|
$team_object = get_page_by_title( stripslashes( $team_name ), OBJECT, 'sp_team' );
|
||||||
|
|
||||||
// Get or insert team
|
// Get or insert team
|
||||||
if ( $team_object ):
|
if ( $team_object ) :
|
||||||
|
|
||||||
// Make sure team is published
|
// Make sure team is published
|
||||||
if ( $team_object->post_status != 'publish' ):
|
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;
|
endif;
|
||||||
|
|
||||||
// Get team ID
|
// Get team ID
|
||||||
$team_id = $team_object->ID;
|
$team_id = $team_object->ID;
|
||||||
|
|
||||||
else:
|
else :
|
||||||
|
|
||||||
// Insert team
|
// 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
|
// Flag as import
|
||||||
update_post_meta( $team_id, '_sp_import', 1 );
|
update_post_meta( $team_id, '_sp_import', 1 );
|
||||||
@@ -187,17 +207,17 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Update league
|
// Update league
|
||||||
if ( $league ):
|
if ( $league ) :
|
||||||
wp_set_object_terms( $team_id, $league, 'sp_league', true );
|
wp_set_object_terms( $team_id, $league, 'sp_league', true );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Update season
|
// Update season
|
||||||
if ( $season ):
|
if ( $season ) :
|
||||||
wp_set_object_terms( $team_id, $season, 'sp_season', true );
|
wp_set_object_terms( $team_id, $season, 'sp_season', true );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add to event if exists
|
// Add to event if exists
|
||||||
if ( isset( $id ) ):
|
if ( isset( $id ) ) :
|
||||||
|
|
||||||
// Add team to event
|
// Add team to event
|
||||||
add_post_meta( $id, 'sp_team', $team_id );
|
add_post_meta( $id, 'sp_team', $team_id );
|
||||||
@@ -225,7 +245,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
else:
|
else :
|
||||||
|
|
||||||
// Add empty team to event
|
// Add empty team to event
|
||||||
add_post_meta( $id, 'sp_team', -1 );
|
add_post_meta( $id, 'sp_team', -1 );
|
||||||
@@ -240,7 +260,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
// Show Result
|
// Show Result
|
||||||
echo '<div class="updated settings-error below-h2"><p>
|
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>';
|
</p></div>';
|
||||||
|
|
||||||
$this->import_end();
|
$this->import_end();
|
||||||
@@ -250,7 +270,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* Performs post-import cleanup of files and the cache
|
* Performs post-import cleanup of files and the cache
|
||||||
*/
|
*/
|
||||||
function import_end() {
|
function import_end() {
|
||||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_event') . '">' . __( 'View Fixtures', 'sportspress' ) . '</a>' . '</p>';
|
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_event' ) . '">' . __( 'View Fixtures', 'sportspress' ) . '</a>' . '</p>';
|
||||||
|
|
||||||
do_action( 'import_end' );
|
do_action( 'import_end' );
|
||||||
}
|
}
|
||||||
@@ -263,7 +283,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
*/
|
*/
|
||||||
function greet() {
|
function greet() {
|
||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||||
echo '<p>' . sprintf( __( 'Fixtures need to be defined with columns in a specific order (4+ columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/fixtures-sample.csv' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Fixtures need to be defined with columns in a specific order (4+ columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/fixtures-sample.csv' ) . '</p>';
|
||||||
echo '<p>' . sprintf( __( 'Supports CSV files generated by <a href="%s">LeagueLobster</a>.', 'sportspress' ), 'http://tboy.co/leaguelobster' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Supports CSV files generated by <a href="%s">LeagueLobster</a>.', 'sportspress' ), 'http://tboy.co/leaguelobster' ) . '</p>';
|
||||||
wp_import_upload_form( 'admin.php?import=sp_fixture_csv&step=1' );
|
wp_import_upload_form( 'admin.php?import=sp_fixture_csv&step=1' );
|
||||||
@@ -293,33 +313,37 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><label><?php _e( 'League', 'sportspress' ); ?></label><br/></th>
|
<th scope="row"><label><?php _e( 'League', 'sportspress' ); ?></label><br/></th>
|
||||||
<td><?php
|
<td>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'sp_league',
|
'name' => 'sp_league',
|
||||||
'values' => 'slug',
|
'values' => 'slug',
|
||||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
if ( ! sp_dropdown_taxonomies( $args ) ) :
|
||||||
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
||||||
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
|
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
?></td>
|
?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><label><?php _e( 'Season', 'sportspress' ); ?></label><br/></th>
|
<th scope="row"><label><?php _e( 'Season', 'sportspress' ); ?></label><br/></th>
|
||||||
<td><?php
|
<td>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'sp_season',
|
'name' => 'sp_season',
|
||||||
'values' => 'slug',
|
'values' => 'slug',
|
||||||
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
'show_option_none' => __( '— Not set —', 'sportspress' ),
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
if ( ! sp_dropdown_taxonomies( $args ) ) :
|
||||||
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
|
||||||
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
|
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
?></td>
|
?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.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' ) ) {
|
if ( class_exists( 'WP_Importer' ) ) {
|
||||||
class SP_Importer extends WP_Importer {
|
class SP_Importer extends WP_Importer {
|
||||||
@@ -46,32 +48,36 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
function dispatch() {
|
function dispatch() {
|
||||||
$this->header();
|
$this->header();
|
||||||
|
|
||||||
if ( ! empty( $_POST['delimiter'] ) )
|
if ( ! empty( $_POST['delimiter'] ) ) {
|
||||||
$this->delimiter = stripslashes( trim( sanitize_text_field( $_POST['delimiter'] ) ) );
|
$this->delimiter = stripslashes( trim( sanitize_text_field( $_POST['delimiter'] ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $this->delimiter )
|
if ( ! $this->delimiter ) {
|
||||||
$this->delimiter = ',';
|
$this->delimiter = ',';
|
||||||
|
}
|
||||||
|
|
||||||
$step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
|
$step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
|
||||||
switch ( $step ):
|
switch ( $step ) :
|
||||||
case 0:
|
case 0:
|
||||||
$this->greet();
|
$this->greet();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
check_admin_referer( 'import-upload' );
|
check_admin_referer( 'import-upload' );
|
||||||
if ( $this->handle_upload() ):
|
if ( $this->handle_upload() ) :
|
||||||
|
|
||||||
if ( $this->id )
|
if ( $this->id ) {
|
||||||
$file = get_attached_file( $this->id );
|
$file = get_attached_file( $this->id );
|
||||||
else
|
} else {
|
||||||
$file = ABSPATH . $this->file_url;
|
$file = ABSPATH . $this->file_url;
|
||||||
|
}
|
||||||
|
|
||||||
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
|
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
|
||||||
|
|
||||||
if ( function_exists( 'gc_enable' ) )
|
if ( function_exists( 'gc_enable' ) ) {
|
||||||
gc_enable();
|
gc_enable();
|
||||||
|
}
|
||||||
|
|
||||||
@set_time_limit(0);
|
@set_time_limit( 0 );
|
||||||
@ob_flush();
|
@ob_flush();
|
||||||
@flush();
|
@flush();
|
||||||
|
|
||||||
@@ -80,7 +86,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
check_admin_referer( 'import-upload' );
|
check_admin_referer( 'import-upload' );
|
||||||
if ( isset( $_POST['sp_import'] ) ):
|
if ( isset( $_POST['sp_import'] ) ) :
|
||||||
$columns = array_filter( sp_array_value( $_POST, 'sp_columns', array( 'post_title' ) ) );
|
$columns = array_filter( sp_array_value( $_POST, 'sp_columns', array( 'post_title' ) ) );
|
||||||
$this->import( $_POST['sp_import'], array_values( $columns ) );
|
$this->import( $_POST['sp_import'], array_values( $columns ) );
|
||||||
endif;
|
endif;
|
||||||
@@ -100,7 +106,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
?>
|
?>
|
||||||
<select name="sp_columns[]" data-index="<?php echo array_search( $selected, array_keys( $this->columns ) ); ?>">
|
<select name="sp_columns[]" data-index="<?php echo array_search( $selected, array_keys( $this->columns ) ); ?>">
|
||||||
<option value="0">— <?php _e( 'Disable', 'sportspress' ); ?> —</option>
|
<option value="0">— <?php _e( 'Disable', 'sportspress' ); ?> —</option>
|
||||||
<?php foreach ( $this->columns as $key => $label ): ?>
|
<?php foreach ( $this->columns as $key => $label ) : ?>
|
||||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $selected, $key ); ?>><?php echo esc_html( $label ); ?></option>
|
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $selected, $key ); ?>><?php echo esc_html( $label ); ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
@@ -119,26 +125,26 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
$this->imported = $this->skipped = 0;
|
$this->imported = $this->skipped = 0;
|
||||||
|
|
||||||
if ( ! is_file($file) ):
|
if ( ! is_file( $file ) ) :
|
||||||
$this->footer();
|
$this->footer();
|
||||||
die();
|
die();
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
ini_set( 'auto_detect_line_endings', '1' );
|
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 );
|
$header = fgetcsv( $handle, 0, $this->delimiter );
|
||||||
|
|
||||||
if ( sizeof( $header ) >= 1 ):
|
if ( sizeof( $header ) >= 1 ) :
|
||||||
$action = 'admin.php?import=' . $this->import_page . '&step=2';
|
$action = 'admin.php?import=' . $this->import_page . '&step=2';
|
||||||
?>
|
?>
|
||||||
<form enctype="multipart/form-data" id="import-upload-form" class="sportspress" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
|
<form enctype="multipart/form-data" id="import-upload-form" class="sportspress" method="post" action="<?php echo esc_attr( wp_nonce_url( $action, 'import-upload' ) ); ?>">
|
||||||
<?php $this->options(); ?>
|
<?php $this->options(); ?>
|
||||||
<table class="wp-list-table sp-data-table sp-import-table widefat fixed pages">
|
<table class="wp-list-table sp-data-table sp-import-table widefat fixed pages">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<?php foreach ( $this->columns as $key => $label ): ?>
|
<?php foreach ( $this->columns as $key => $label ) : ?>
|
||||||
<th scope="col" class="manage-column">
|
<th scope="col" class="manage-column">
|
||||||
<?php $this->dropdown( $key ); ?>
|
<?php $this->dropdown( $key ); ?>
|
||||||
</th>
|
</th>
|
||||||
@@ -149,21 +155,35 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ): ?>
|
<?php while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== false ) : ?>
|
||||||
<tr>
|
<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>
|
<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>
|
</td>
|
||||||
<?php $index ++; endforeach; ?>
|
<?php
|
||||||
|
$index ++;
|
||||||
|
endforeach;
|
||||||
|
?>
|
||||||
<td class="sp-actions-column">
|
<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( '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>
|
<a href="#" title="<?php _e( 'Insert row after', 'sportspress' ); ?>" class="dashicons dashicons-plus-alt sp-add-row"></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php $this->imported++; endwhile; ?>
|
<?php
|
||||||
|
$this->imported++;
|
||||||
|
endwhile;
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<?php foreach ( $this->columns as $key => $label ): ?>
|
<?php foreach ( $this->columns as $key => $label ) : ?>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" class="widefat" name="sp_import[]">
|
<input type="text" class="widefat" name="sp_import[]">
|
||||||
</td>
|
</td>
|
||||||
@@ -175,14 +195,14 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p class="sp-post-count alignright">
|
<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>
|
||||||
<p class="submit">
|
<p class="submit">
|
||||||
<input type="submit" class="button button-primary button-hero" value="<?php echo esc_attr( $this->import_label ); ?>" />
|
<input type="submit" class="button button-primary button-hero" value="<?php echo esc_attr( $this->import_label ); ?>" />
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
else:
|
else :
|
||||||
|
|
||||||
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'sportspress' ) . '</strong><br />';
|
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'sportspress' ) . '</strong><br />';
|
||||||
_e( 'The CSV is invalid.', 'sportspress' ) . '</p>';
|
_e( 'The CSV is invalid.', 'sportspress' ) . '</p>';
|
||||||
@@ -239,7 +259,6 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
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
|
* Added to http_request_timeout filter to force timeout at 60 seconds during import
|
||||||
|
*
|
||||||
* @param int $val
|
* @param int $val
|
||||||
* @return int 60
|
* @return int 60
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.5.1
|
* @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' ) ) {
|
if ( class_exists( 'WP_Importer' ) ) {
|
||||||
class SP_Official_Importer extends SP_Importer {
|
class SP_Official_Importer extends SP_Importer {
|
||||||
@@ -39,33 +41,39 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||||
$this->imported = $this->skipped = 0;
|
$this->imported = $this->skipped = 0;
|
||||||
|
|
||||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||||
$this->footer();
|
$this->footer();
|
||||||
die();
|
die();
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$rows = array_chunk( $array, sizeof( $columns ) );
|
$rows = array_chunk( $array, sizeof( $columns ) );
|
||||||
|
|
||||||
foreach ( $rows as $row ):
|
foreach ( $rows as $row ) :
|
||||||
|
|
||||||
$row = array_filter( $row );
|
$row = array_filter( $row );
|
||||||
|
|
||||||
if ( empty( $row ) ) continue;
|
if ( empty( $row ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$meta = array();
|
$meta = array();
|
||||||
|
|
||||||
foreach ( $columns as $index => $key ):
|
foreach ( $columns as $index => $key ) :
|
||||||
$meta[ $key ] = sp_array_value( $row, $index );
|
$meta[ $key ] = sp_array_value( $row, $index );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$name = sp_array_value( $meta, 'post_title' );
|
$name = sp_array_value( $meta, 'post_title' );
|
||||||
|
|
||||||
if ( ! $name ):
|
if ( ! $name ) :
|
||||||
$this->skipped++;
|
$this->skipped++;
|
||||||
continue;
|
continue;
|
||||||
endif;
|
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 );
|
$id = wp_insert_post( $args );
|
||||||
|
|
||||||
@@ -75,7 +83,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
// Show Result
|
// Show Result
|
||||||
echo '<div class="updated settings-error below-h2"><p>
|
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>';
|
</p></div>';
|
||||||
|
|
||||||
$this->import_end();
|
$this->import_end();
|
||||||
@@ -85,7 +93,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* Performs post-import cleanup of files and the cache
|
* Performs post-import cleanup of files and the cache
|
||||||
*/
|
*/
|
||||||
function import_end() {
|
function import_end() {
|
||||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_official') . '">' . __( 'View Officials', 'sportspress' ) . '</a>' . '</p>';
|
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_official' ) . '">' . __( 'View Officials', 'sportspress' ) . '</a>' . '</p>';
|
||||||
|
|
||||||
do_action( 'import_end' );
|
do_action( 'import_end' );
|
||||||
}
|
}
|
||||||
@@ -108,7 +116,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
*/
|
*/
|
||||||
function greet() {
|
function greet() {
|
||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||||
echo '<p>' . sprintf( __( 'Officials need to be defined with columns in a specific order. <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/officials-sample.csv' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Officials need to be defined with columns in a specific order. <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/officials-sample.csv' ) . '</p>';
|
||||||
wp_import_upload_form( 'admin.php?import=sp_official_csv&step=1' );
|
wp_import_upload_form( 'admin.php?import=sp_official_csv&step=1' );
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7
|
* @version 2.7
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
if ( class_exists( 'WP_Importer' ) ) {
|
if ( class_exists( 'WP_Importer' ) ) {
|
||||||
class SP_Player_Importer extends SP_Importer {
|
class SP_Player_Importer extends SP_Importer {
|
||||||
@@ -46,7 +48,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||||
$this->imported = $this->skipped = 0;
|
$this->imported = $this->skipped = 0;
|
||||||
|
|
||||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||||
$this->footer();
|
$this->footer();
|
||||||
die();
|
die();
|
||||||
endif;
|
endif;
|
||||||
@@ -56,11 +58,13 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
// Get Date of Birth format from post vars
|
// Get Date of Birth format from post vars
|
||||||
$date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : sanitize_text_field( $_POST['sp_date_format'] ) );
|
$date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : sanitize_text_field( $_POST['sp_date_format'] ) );
|
||||||
|
|
||||||
foreach ( $rows as $row ):
|
foreach ( $rows as $row ) :
|
||||||
|
|
||||||
$row = array_filter( $row, 'strlen' );
|
$row = array_filter( $row, 'strlen' );
|
||||||
|
|
||||||
if ( empty( $row ) ) continue;
|
if ( empty( $row ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$meta = array();
|
$meta = array();
|
||||||
|
|
||||||
@@ -76,7 +80,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$meta[ $p ] = '';
|
$meta[ $p ] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $columns as $index => $key ):
|
foreach ( $columns as $index => $key ) :
|
||||||
$meta[ $key ] = sp_array_value( $row, $index );
|
$meta[ $key ] = sp_array_value( $row, $index );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
@@ -86,7 +90,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
// Format date of birth
|
// Format date of birth
|
||||||
$date = str_replace( '/', '-', trim( $date ) );
|
$date = str_replace( '/', '-', trim( $date ) );
|
||||||
$date_array = explode( '-', $date );
|
$date_array = explode( '-', $date );
|
||||||
switch ( $date_format ):
|
switch ( $date_format ) :
|
||||||
case 'dd/mm/yyyy':
|
case 'dd/mm/yyyy':
|
||||||
$date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
|
$date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' .
|
||||||
substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
|
substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' .
|
||||||
@@ -103,16 +107,21 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
substr( str_pad( sp_array_value( $date_array, 2, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 );
|
substr( str_pad( sp_array_value( $date_array, 2, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 );
|
||||||
endswitch;
|
endswitch;
|
||||||
|
|
||||||
if ( ! $name ):
|
if ( ! $name ) :
|
||||||
$this->skipped++;
|
$this->skipped++;
|
||||||
continue;
|
continue;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Get or insert player
|
// Get or insert player
|
||||||
$player_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_player' ) : false;
|
$player_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_player' ) : false;
|
||||||
if ( $player_object ):
|
if ( $player_object ) :
|
||||||
if ( $player_object->post_status != 'publish' ):
|
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;
|
endif;
|
||||||
$id = $player_object->ID;
|
$id = $player_object->ID;
|
||||||
// Handle preservable data.
|
// Handle preservable data.
|
||||||
@@ -120,10 +129,14 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
$terms = wp_get_object_terms( $id, $p, array( 'fields' => 'names' ) );
|
$terms = wp_get_object_terms( $id, $p, array( 'fields' => 'names' ) );
|
||||||
$meta[ $p ] .= '|' . implode( '|', $terms );
|
$meta[ $p ] .= '|' . implode( '|', $terms );
|
||||||
}
|
}
|
||||||
else:
|
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
|
// Check if a DoB was set
|
||||||
if( '0000-00-00' !== $date ){
|
if ( '0000-00-00' !== $date ) {
|
||||||
$args['post_date'] = $date;
|
$args['post_date'] = $date;
|
||||||
}
|
}
|
||||||
$id = wp_insert_post( $args );
|
$id = wp_insert_post( $args );
|
||||||
@@ -148,18 +161,29 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
wp_set_object_terms( $id, $seasons, 'sp_season', false );
|
wp_set_object_terms( $id, $seasons, 'sp_season', false );
|
||||||
|
|
||||||
// Update teams
|
// Update teams
|
||||||
$teams = (array)explode( '|', sp_array_value( $meta, 'sp_team' ) );
|
$teams = (array) explode( '|', sp_array_value( $meta, 'sp_team' ) );
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $teams as $team ):
|
foreach ( $teams as $team ) :
|
||||||
// Get or insert team
|
// Get or insert team
|
||||||
$team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
|
$team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
|
||||||
if ( $team_object ):
|
if ( $team_object ) :
|
||||||
if ( $team_object->post_status != 'publish' ):
|
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;
|
endif;
|
||||||
$team_id = $team_object->ID;
|
$team_id = $team_object->ID;
|
||||||
else:
|
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
|
// Flag as import
|
||||||
update_post_meta( $team_id, '_sp_import', 1 );
|
update_post_meta( $team_id, '_sp_import', 1 );
|
||||||
wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
|
wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
|
||||||
@@ -170,7 +194,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
add_post_meta( $id, 'sp_team', $team_id );
|
add_post_meta( $id, 'sp_team', $team_id );
|
||||||
|
|
||||||
// Update current team if first in array, otherwise use as past team
|
// Update current team if first in array, otherwise use as past team
|
||||||
if ( $i == 0 ):
|
if ( $i == 0 ) :
|
||||||
update_post_meta( $id, 'sp_current_team', $team_id );
|
update_post_meta( $id, 'sp_current_team', $team_id );
|
||||||
else :
|
else :
|
||||||
add_post_meta( $id, 'sp_past_team', $team_id );
|
add_post_meta( $id, 'sp_past_team', $team_id );
|
||||||
@@ -181,7 +205,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
// Update nationality
|
// Update nationality
|
||||||
$nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
|
$nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
|
||||||
if ( $nationality == '*' ) $nationality = '';
|
if ( $nationality == '*' ) {
|
||||||
|
$nationality = '';
|
||||||
|
}
|
||||||
update_post_meta( $id, 'sp_nationality', $nationality );
|
update_post_meta( $id, 'sp_nationality', $nationality );
|
||||||
|
|
||||||
$this->imported++;
|
$this->imported++;
|
||||||
@@ -190,7 +216,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
// Show Result
|
// Show Result
|
||||||
echo '<div class="updated settings-error below-h2"><p>
|
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>';
|
</p></div>';
|
||||||
|
|
||||||
$this->import_end();
|
$this->import_end();
|
||||||
@@ -200,7 +226,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* Performs post-import cleanup of files and the cache
|
* Performs post-import cleanup of files and the cache
|
||||||
*/
|
*/
|
||||||
function import_end() {
|
function import_end() {
|
||||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_player') . '">' . __( 'View Players', 'sportspress' ) . '</a>' . '</p>';
|
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_player' ) . '">' . __( 'View Players', 'sportspress' ) . '</a>' . '</p>';
|
||||||
|
|
||||||
do_action( 'import_end' );
|
do_action( 'import_end' );
|
||||||
}
|
}
|
||||||
@@ -223,7 +249,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
*/
|
*/
|
||||||
function greet() {
|
function greet() {
|
||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||||
echo '<p>' . sprintf( __( 'Players need to be defined with columns in a specific order (8 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/players-sample.csv' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Players need to be defined with columns in a specific order (8 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/players-sample.csv' ) . '</p>';
|
||||||
wp_import_upload_form( 'admin.php?import=sp_player_csv&step=1' );
|
wp_import_upload_form( 'admin.php?import=sp_player_csv&step=1' );
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.5.5
|
* @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' ) ) {
|
if ( class_exists( 'WP_Importer' ) ) {
|
||||||
class SP_Staff_Importer extends SP_Importer {
|
class SP_Staff_Importer extends SP_Importer {
|
||||||
@@ -44,41 +46,52 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||||
$this->imported = $this->skipped = 0;
|
$this->imported = $this->skipped = 0;
|
||||||
|
|
||||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||||
$this->footer();
|
$this->footer();
|
||||||
die();
|
die();
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$rows = array_chunk( $array, sizeof( $columns ) );
|
$rows = array_chunk( $array, sizeof( $columns ) );
|
||||||
|
|
||||||
foreach ( $rows as $row ):
|
foreach ( $rows as $row ) :
|
||||||
|
|
||||||
$row = array_filter( $row );
|
$row = array_filter( $row );
|
||||||
|
|
||||||
if ( empty( $row ) ) continue;
|
if ( empty( $row ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$meta = array();
|
$meta = array();
|
||||||
|
|
||||||
foreach ( $columns as $index => $key ):
|
foreach ( $columns as $index => $key ) :
|
||||||
$meta[ $key ] = sp_array_value( $row, $index );
|
$meta[ $key ] = sp_array_value( $row, $index );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$name = sp_array_value( $meta, 'post_title' );
|
$name = sp_array_value( $meta, 'post_title' );
|
||||||
|
|
||||||
if ( ! $name ):
|
if ( ! $name ) :
|
||||||
$this->skipped++;
|
$this->skipped++;
|
||||||
continue;
|
continue;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Get or insert staff
|
// Get or insert staff
|
||||||
$staff_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_staff' ) : false;
|
$staff_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_staff' ) : false;
|
||||||
if ( $staff_object ):
|
if ( $staff_object ) :
|
||||||
if ( $staff_object->post_status != 'publish' ):
|
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;
|
endif;
|
||||||
$id = $staff_object->ID;
|
$id = $staff_object->ID;
|
||||||
else:
|
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 );
|
$id = wp_insert_post( $args );
|
||||||
|
|
||||||
// Flag as import
|
// Flag as import
|
||||||
@@ -98,18 +111,29 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
wp_set_object_terms( $id, $seasons, 'sp_season', false );
|
wp_set_object_terms( $id, $seasons, 'sp_season', false );
|
||||||
|
|
||||||
// Update teams
|
// Update teams
|
||||||
$teams = (array)explode( '|', sp_array_value( $meta, 'sp_team' ) );
|
$teams = (array) explode( '|', sp_array_value( $meta, 'sp_team' ) );
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $teams as $team ):
|
foreach ( $teams as $team ) :
|
||||||
// Get or insert team
|
// Get or insert team
|
||||||
$team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
|
$team_object = get_page_by_title( stripslashes( $team ), OBJECT, 'sp_team' );
|
||||||
if ( $team_object ):
|
if ( $team_object ) :
|
||||||
if ( $team_object->post_status != 'publish' ):
|
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;
|
endif;
|
||||||
$team_id = $team_object->ID;
|
$team_id = $team_object->ID;
|
||||||
else:
|
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
|
// Flag as import
|
||||||
update_post_meta( $team_id, '_sp_import', 1 );
|
update_post_meta( $team_id, '_sp_import', 1 );
|
||||||
wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
|
wp_set_object_terms( $team_id, $leagues, 'sp_league', false );
|
||||||
@@ -120,7 +144,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
add_post_meta( $id, 'sp_team', $team_id );
|
add_post_meta( $id, 'sp_team', $team_id );
|
||||||
|
|
||||||
// Update current team if first in array
|
// Update current team if first in array
|
||||||
if ( $i == 0 ):
|
if ( $i == 0 ) :
|
||||||
update_post_meta( $id, 'sp_current_team', $team_id );
|
update_post_meta( $id, 'sp_current_team', $team_id );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -129,7 +153,9 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
// Update nationality
|
// Update nationality
|
||||||
$nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
|
$nationality = trim( strtolower( sp_array_value( $meta, 'sp_nationality' ) ) );
|
||||||
if ( $nationality == '*' ) $nationality = '';
|
if ( $nationality == '*' ) {
|
||||||
|
$nationality = '';
|
||||||
|
}
|
||||||
update_post_meta( $id, 'sp_nationality', $nationality );
|
update_post_meta( $id, 'sp_nationality', $nationality );
|
||||||
|
|
||||||
$this->imported++;
|
$this->imported++;
|
||||||
@@ -138,7 +164,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
// Show Result
|
// Show Result
|
||||||
echo '<div class="updated settings-error below-h2"><p>
|
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>';
|
</p></div>';
|
||||||
|
|
||||||
$this->import_end();
|
$this->import_end();
|
||||||
@@ -148,7 +174,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* Performs post-import cleanup of files and the cache
|
* Performs post-import cleanup of files and the cache
|
||||||
*/
|
*/
|
||||||
function import_end() {
|
function import_end() {
|
||||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_staff') . '">' . __( 'View Staff', 'sportspress' ) . '</a>' . '</p>';
|
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_staff' ) . '">' . __( 'View Staff', 'sportspress' ) . '</a>' . '</p>';
|
||||||
|
|
||||||
do_action( 'import_end' );
|
do_action( 'import_end' );
|
||||||
}
|
}
|
||||||
@@ -171,7 +197,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
*/
|
*/
|
||||||
function greet() {
|
function greet() {
|
||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||||
echo '<p>' . sprintf( __( 'Staff need to be defined with columns in a specific order (6 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/staff-sample.csv' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Staff need to be defined with columns in a specific order (6 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/staff-sample.csv' ) . '</p>';
|
||||||
wp_import_upload_form( 'admin.php?import=sp_staff_csv&step=1' );
|
wp_import_upload_form( 'admin.php?import=sp_staff_csv&step=1' );
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.5.5
|
* @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' ) ) {
|
if ( class_exists( 'WP_Importer' ) ) {
|
||||||
class SP_Team_Importer extends SP_Importer {
|
class SP_Team_Importer extends SP_Importer {
|
||||||
@@ -44,41 +46,52 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
function import( $array = array(), $columns = array( 'post_title' ) ) {
|
||||||
$this->imported = $this->skipped = 0;
|
$this->imported = $this->skipped = 0;
|
||||||
|
|
||||||
if ( ! is_array( $array ) || ! sizeof( $array ) ):
|
if ( ! is_array( $array ) || ! sizeof( $array ) ) :
|
||||||
$this->footer();
|
$this->footer();
|
||||||
die();
|
die();
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$rows = array_chunk( $array, sizeof( $columns ) );
|
$rows = array_chunk( $array, sizeof( $columns ) );
|
||||||
|
|
||||||
foreach ( $rows as $row ):
|
foreach ( $rows as $row ) :
|
||||||
|
|
||||||
$row = array_filter( $row );
|
$row = array_filter( $row );
|
||||||
|
|
||||||
if ( empty( $row ) ) continue;
|
if ( empty( $row ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$meta = array();
|
$meta = array();
|
||||||
|
|
||||||
foreach ( $columns as $index => $key ):
|
foreach ( $columns as $index => $key ) :
|
||||||
$meta[ $key ] = sp_array_value( $row, $index );
|
$meta[ $key ] = sp_array_value( $row, $index );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$name = sp_array_value( $meta, 'post_title' );
|
$name = sp_array_value( $meta, 'post_title' );
|
||||||
|
|
||||||
if ( ! $name ):
|
if ( ! $name ) :
|
||||||
$this->skipped++;
|
$this->skipped++;
|
||||||
continue;
|
continue;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Get or insert team
|
// Get or insert team
|
||||||
$team_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_team' ) : false;
|
$team_object = sp_array_value( $_POST, 'merge', 0 ) ? get_page_by_title( stripslashes( $name ), OBJECT, 'sp_team' ) : false;
|
||||||
if ( $team_object ):
|
if ( $team_object ) :
|
||||||
if ( $team_object->post_status != 'publish' ):
|
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;
|
endif;
|
||||||
$id = $team_object->ID;
|
$id = $team_object->ID;
|
||||||
else:
|
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 );
|
$id = wp_insert_post( $args );
|
||||||
|
|
||||||
// Flag as import
|
// Flag as import
|
||||||
@@ -107,7 +120,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
// Show Result
|
// Show Result
|
||||||
echo '<div class="updated settings-error below-h2"><p>
|
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>';
|
</p></div>';
|
||||||
|
|
||||||
$this->import_end();
|
$this->import_end();
|
||||||
@@ -117,7 +130,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* Performs post-import cleanup of files and the cache
|
* Performs post-import cleanup of files and the cache
|
||||||
*/
|
*/
|
||||||
function import_end() {
|
function import_end() {
|
||||||
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url('edit.php?post_type=sp_team') . '">' . __( 'View Teams', 'sportspress' ) . '</a>' . '</p>';
|
echo '<p>' . __( 'All done!', 'sportspress' ) . ' <a href="' . admin_url( 'edit.php?post_type=sp_team' ) . '">' . __( 'View Teams', 'sportspress' ) . '</a>' . '</p>';
|
||||||
|
|
||||||
do_action( 'import_end' );
|
do_action( 'import_end' );
|
||||||
}
|
}
|
||||||
@@ -130,7 +143,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
*/
|
*/
|
||||||
function greet() {
|
function greet() {
|
||||||
echo '<div class="narrow">';
|
echo '<div class="narrow">';
|
||||||
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'</p>';
|
echo '<p>' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ) . '</p>';
|
||||||
echo '<p>' . sprintf( __( 'Teams need to be defined with columns in a specific order (3 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/teams-sample.csv' ) . '</p>';
|
echo '<p>' . sprintf( __( 'Teams need to be defined with columns in a specific order (3 columns). <a href="%s">Click here to download a sample</a>.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/teams-sample.csv' ) . '</p>';
|
||||||
wp_import_upload_form( 'admin.php?import=sp_team_csv&step=1' );
|
wp_import_upload_form( 'admin.php?import=sp_team_csv&step=1' );
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Calendar' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Calendar' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Calendar Class
|
* SP_Admin_CPT_Calendar Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -43,7 +46,8 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function edit_columns( $existing_columns ) {
|
public function edit_columns( $existing_columns ) {
|
||||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||||
$columns = array_merge( array(
|
$columns = array_merge(
|
||||||
|
array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Title', 'sportspress' ),
|
'title' => __( 'Title', 'sportspress' ),
|
||||||
'sp_league' => __( 'League', 'sportspress' ),
|
'sp_league' => __( 'League', 'sportspress' ),
|
||||||
@@ -52,38 +56,43 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
|||||||
'sp_team' => __( 'Team', 'sportspress' ),
|
'sp_team' => __( 'Team', 'sportspress' ),
|
||||||
'sp_events' => __( 'Events', 'sportspress' ),
|
'sp_events' => __( 'Events', 'sportspress' ),
|
||||||
'sp_layout' => __( 'Layout', 'sportspress' ),
|
'sp_layout' => __( 'Layout', 'sportspress' ),
|
||||||
), $existing_columns );
|
),
|
||||||
|
$existing_columns
|
||||||
|
);
|
||||||
return apply_filters( 'sportspress_calendar_admin_columns', $columns );
|
return apply_filters( 'sportspress_calendar_admin_columns', $columns );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_league':
|
case 'sp_league':
|
||||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
|
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
|
||||||
break;
|
break;
|
||||||
case 'sp_season':
|
case 'sp_season':
|
||||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
|
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
|
||||||
break;
|
break;
|
||||||
case 'sp_venue':
|
case 'sp_venue':
|
||||||
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : __( 'All', 'sportspress' );
|
echo get_the_terms( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : __( 'All', 'sportspress' );
|
||||||
break;
|
break;
|
||||||
case 'sp_team':
|
case 'sp_team':
|
||||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
$teams = (array) get_post_meta( $post_id, 'sp_team', false );
|
||||||
$teams = array_filter( $teams );
|
$teams = array_filter( $teams );
|
||||||
if ( empty( $teams ) ):
|
if ( empty( $teams ) ) :
|
||||||
echo __( 'All', 'sportspress' );
|
echo __( 'All', 'sportspress' );
|
||||||
else:
|
else :
|
||||||
$current_team = get_post_meta( $post_id, 'sp_current_team', true );
|
$current_team = get_post_meta( $post_id, 'sp_current_team', true );
|
||||||
foreach( $teams as $team_id ):
|
foreach ( $teams as $team_id ) :
|
||||||
if ( ! $team_id ) continue;
|
if ( ! $team_id ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$team = get_post( $team_id );
|
$team = get_post( $team_id );
|
||||||
if ( $team ):
|
if ( $team ) :
|
||||||
echo esc_html( $team->post_title );
|
echo esc_html( $team->post_title );
|
||||||
if ( $team_id == $current_team ):
|
if ( $team_id == $current_team ) :
|
||||||
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
||||||
endif;
|
endif;
|
||||||
echo '<br>';
|
echo '<br>';
|
||||||
@@ -107,15 +116,16 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
|||||||
public function filters() {
|
public function filters() {
|
||||||
global $typenow, $wp_query;
|
global $typenow, $wp_query;
|
||||||
|
|
||||||
if ( $typenow != 'sp_calendar' )
|
if ( $typenow != 'sp_calendar' ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||||
$args = array(
|
$args = array(
|
||||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'sp_league',
|
'name' => 'sp_league',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
|
|
||||||
@@ -124,7 +134,7 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
|||||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'sp_season',
|
'name' => 'sp_season',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
|
|
||||||
@@ -155,7 +165,7 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Column' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Column' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Column Class
|
* SP_Admin_CPT_Column Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Column extends SP_Admin_CPT {
|
class SP_Admin_CPT_Column extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -52,10 +55,11 @@ class SP_Admin_CPT_Column extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_key':
|
case 'sp_key':
|
||||||
global $post;
|
global $post;
|
||||||
echo esc_html( $post->post_name );
|
echo esc_html( $post->post_name );
|
||||||
@@ -75,7 +79,7 @@ class SP_Admin_CPT_Column extends SP_Admin_CPT {
|
|||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Event' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Event' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Event Class
|
* SP_Admin_CPT_Event Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -54,13 +57,15 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change title boxes in admin.
|
* Change title boxes in admin.
|
||||||
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param object $post
|
* @param object $post
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function enter_title_here( $text, $post ) {
|
public function enter_title_here( $text, $post ) {
|
||||||
if ( $post->post_type == 'sp_event' )
|
if ( $post->post_type == 'sp_event' ) {
|
||||||
return __( '(Auto)', 'sportspress' );
|
return __( '(Auto)', 'sportspress' );
|
||||||
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
@@ -73,10 +78,12 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function wp_insert_post_empty_content( $maybe_empty, $postarr ) {
|
public function wp_insert_post_empty_content( $maybe_empty, $postarr ) {
|
||||||
if ( $maybe_empty && 'sp_event' === sp_array_value( $postarr, 'post_type' ) ):
|
if ( $maybe_empty && 'sp_event' === sp_array_value( $postarr, 'post_type' ) ) :
|
||||||
$teams = sp_array_value( $postarr, 'sp_team', array() );
|
$teams = sp_array_value( $postarr, 'sp_team', array() );
|
||||||
$teams = array_filter( $teams );
|
$teams = array_filter( $teams );
|
||||||
if ( sizeof( $teams ) ) return false;
|
if ( sizeof( $teams ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
return $maybe_empty;
|
return $maybe_empty;
|
||||||
@@ -90,17 +97,19 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function wp_insert_post_data( $data, $postarr ) {
|
public function wp_insert_post_data( $data, $postarr ) {
|
||||||
if ( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ):
|
if ( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ) :
|
||||||
|
|
||||||
$teams = sp_array_value( $postarr, 'sp_team', array() );
|
$teams = sp_array_value( $postarr, 'sp_team', array() );
|
||||||
$teams = array_filter( $teams );
|
$teams = array_filter( $teams );
|
||||||
|
|
||||||
$team_names = array();
|
$team_names = array();
|
||||||
foreach ( $teams as $team ):
|
foreach ( $teams as $team ) :
|
||||||
while ( is_array( $team ) ) {
|
while ( is_array( $team ) ) {
|
||||||
$team = array_shift( array_filter( $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;
|
endforeach;
|
||||||
|
|
||||||
$team_names = array_unique( $team_names );
|
$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 ) {
|
public function edit_columns( $existing_columns ) {
|
||||||
unset( $existing_columns['author'], $existing_columns['comments'] );
|
unset( $existing_columns['author'], $existing_columns['comments'] );
|
||||||
$columns = array_merge( array(
|
$columns = array_merge(
|
||||||
|
array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'sp_format' => '<span class="dashicons sp-icon-calendar sp-tip" title="' . __( 'Format', 'sportspress' ) . '"></span>',
|
'sp_format' => '<span class="dashicons sp-icon-calendar sp-tip" title="' . __( 'Format', 'sportspress' ) . '"></span>',
|
||||||
'title' => null,
|
'title' => null,
|
||||||
@@ -133,9 +143,12 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
'sp_season' => __( 'Season', 'sportspress' ),
|
'sp_season' => __( 'Season', 'sportspress' ),
|
||||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||||
'sp_day' => __( 'Match Day', 'sportspress' ),
|
'sp_day' => __( 'Match Day', 'sportspress' ),
|
||||||
), $existing_columns, array(
|
),
|
||||||
|
$existing_columns,
|
||||||
|
array(
|
||||||
'title' => __( 'Event', 'sportspress' ),
|
'title' => __( 'Event', 'sportspress' ),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
return apply_filters( 'sportspress_event_admin_columns', $columns );
|
return apply_filters( 'sportspress_event_admin_columns', $columns );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,27 +164,30 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
* Define the sortable columns in admin.
|
* Define the sortable columns in admin.
|
||||||
*/
|
*/
|
||||||
public function orderby_columns( $query ) {
|
public function orderby_columns( $query ) {
|
||||||
if ( ! is_admin() ) return;
|
if ( ! is_admin() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$orderby = $query->get( 'orderby');
|
$orderby = $query->get( 'orderby' );
|
||||||
|
|
||||||
if ( 'sp_day' == $orderby ) {
|
if ( 'sp_day' == $orderby ) {
|
||||||
$query->set( 'meta_key','sp_day' );
|
$query->set( 'meta_key', 'sp_day' );
|
||||||
$query->set( 'orderby','meta_value_num' );
|
$query->set( 'orderby', 'meta_value_num' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_format':
|
case 'sp_format':
|
||||||
$format = get_post_meta( $post_id, 'sp_format', true );
|
$format = get_post_meta( $post_id, 'sp_format', true );
|
||||||
$formats = new SP_Formats();
|
$formats = new SP_Formats();
|
||||||
$event_formats = $formats->event;
|
$event_formats = $formats->event;
|
||||||
if ( array_key_exists( $format, $event_formats ) ):
|
if ( array_key_exists( $format, $event_formats ) ) :
|
||||||
echo '<span class="dashicons sp-icon-' . $format . ' sp-tip" title="' . $event_formats[ $format ] . '"></span>';
|
echo '<span class="dashicons sp-icon-' . $format . ' sp-tip" title="' . $event_formats[ $format ] . '"></span>';
|
||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
@@ -179,40 +195,42 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
echo apply_filters( 'sportspress_event_time_admin', get_post_time( 'H:i', false, $post_id, true ) );
|
echo apply_filters( 'sportspress_event_time_admin', get_post_time( 'H:i', false, $post_id, true ) );
|
||||||
break;
|
break;
|
||||||
case 'sp_team':
|
case 'sp_team':
|
||||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
$teams = (array) get_post_meta( $post_id, 'sp_team', false );
|
||||||
$teams = array_filter( $teams );
|
$teams = array_filter( $teams );
|
||||||
$teams = array_unique( $teams );
|
$teams = array_unique( $teams );
|
||||||
$reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
|
$reverse_teams = get_option( 'sportspress_event_reverse_teams', 'no' ) === 'yes' ? true : false;
|
||||||
if ( $reverse_teams ) {
|
if ( $reverse_teams ) {
|
||||||
$teams = array_reverse( $teams , true );
|
$teams = array_reverse( $teams, true );
|
||||||
}
|
}
|
||||||
if ( empty( $teams ) ):
|
if ( empty( $teams ) ) :
|
||||||
echo '—';
|
echo '—';
|
||||||
else:
|
else :
|
||||||
$results = get_post_meta( $post_id, 'sp_results', true );
|
$results = get_post_meta( $post_id, 'sp_results', true );
|
||||||
$main_result = get_option( 'sportspress_primary_result', null );
|
$main_result = get_option( 'sportspress_primary_result', null );
|
||||||
echo '<input type="hidden" name="sp_post_id" value="' . $post_id . '">';
|
echo '<input type="hidden" name="sp_post_id" value="' . $post_id . '">';
|
||||||
echo '<div class="sp-results">';
|
echo '<div class="sp-results">';
|
||||||
foreach( $teams as $team_id ):
|
foreach ( $teams as $team_id ) :
|
||||||
if ( ! $team_id ) continue;
|
if ( ! $team_id ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$team = get_post( $team_id );
|
$team = get_post( $team_id );
|
||||||
|
|
||||||
if ( $team ):
|
if ( $team ) :
|
||||||
$team_results = sportspress_array_value( $results, $team_id, null );
|
$team_results = sportspress_array_value( $results, $team_id, null );
|
||||||
|
|
||||||
if ( $main_result ):
|
if ( $main_result ) :
|
||||||
$team_result = sportspress_array_value( $team_results, $main_result, null );
|
$team_result = sportspress_array_value( $team_results, $main_result, null );
|
||||||
else:
|
else :
|
||||||
if ( is_array( $team_results ) ):
|
if ( is_array( $team_results ) ) :
|
||||||
end( $team_results );
|
end( $team_results );
|
||||||
$team_result = prev( $team_results );
|
$team_result = prev( $team_results );
|
||||||
$main_result = key( $team_results );
|
$main_result = key( $team_results );
|
||||||
else:
|
else :
|
||||||
$team_result = null;
|
$team_result = null;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( is_array( $team_results ) ):
|
if ( is_array( $team_results ) ) :
|
||||||
unset( $team_results['outcome'] );
|
unset( $team_results['outcome'] );
|
||||||
$team_results = array_filter( $team_results, 'sp_filter_non_empty' );
|
$team_results = array_filter( $team_results, 'sp_filter_non_empty' );
|
||||||
$team_results = implode( ' | ', $team_results );
|
$team_results = implode( ' | ', $team_results );
|
||||||
@@ -237,17 +255,19 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
case 'sp_league':
|
case 'sp_league':
|
||||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_season':
|
case 'sp_season':
|
||||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_venue':
|
case 'sp_venue':
|
||||||
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
echo get_the_terms( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_day':
|
case 'sp_day':
|
||||||
$day = get_post_meta ( $post_id, 'sp_day', true );
|
$day = get_post_meta( $post_id, 'sp_day', true );
|
||||||
if ( '' === $day ) $day = __( 'Default', 'sportspress' );
|
if ( '' === $day ) {
|
||||||
|
$day = __( 'Default', 'sportspress' );
|
||||||
|
}
|
||||||
echo esc_html( $day );
|
echo esc_html( $day );
|
||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
@@ -259,8 +279,9 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
public function filters() {
|
public function filters() {
|
||||||
global $typenow, $wp_query;
|
global $typenow, $wp_query;
|
||||||
|
|
||||||
if ( $typenow != 'sp_event' )
|
if ( $typenow != 'sp_event' ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||||
$args = array(
|
$args = array(
|
||||||
@@ -277,7 +298,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'sp_league',
|
'name' => 'sp_league',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
|
|
||||||
@@ -286,16 +307,17 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'sp_season',
|
'name' => 'sp_season',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
|
|
||||||
$selected = isset( $_REQUEST['match_day'] ) ? sanitize_text_field( $_REQUEST['match_day'] ) : null;
|
$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 . '">';
|
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 );
|
wp_nonce_field( 'sp-save-inline-results', 'sp-inline-nonce', false );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter in admin based on options
|
* Filter in admin based on options
|
||||||
@@ -306,9 +328,10 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
global $typenow, $wp_query;
|
global $typenow, $wp_query;
|
||||||
|
|
||||||
if ( $typenow == 'sp_event' ) {
|
if ( $typenow == 'sp_event' ) {
|
||||||
//Avoid overriding relation operator if already set
|
// 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';
|
$query->query_vars['meta_query']['relation'] = 'AND';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! empty( $_GET['team'] ) ) {
|
if ( ! empty( $_GET['team'] ) ) {
|
||||||
$query->query_vars['meta_query'][] = array(
|
$query->query_vars['meta_query'][] = array(
|
||||||
@@ -345,7 +368,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
|||||||
|
|
||||||
return $post_states;
|
return $post_states;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_List' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_List' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_List Class
|
* SP_Admin_CPT_List Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_List extends SP_Admin_CPT {
|
class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -43,7 +46,8 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function edit_columns( $existing_columns ) {
|
public function edit_columns( $existing_columns ) {
|
||||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||||
$columns = array_merge( array(
|
$columns = array_merge(
|
||||||
|
array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Title', 'sportspress' ),
|
'title' => __( 'Title', 'sportspress' ),
|
||||||
'sp_league' => __( 'League', 'sportspress' ),
|
'sp_league' => __( 'League', 'sportspress' ),
|
||||||
@@ -51,41 +55,48 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
|||||||
'sp_team' => __( 'Team', 'sportspress' ),
|
'sp_team' => __( 'Team', 'sportspress' ),
|
||||||
'sp_player' => __( 'Players', 'sportspress' ),
|
'sp_player' => __( 'Players', 'sportspress' ),
|
||||||
'sp_layout' => __( 'Layout', 'sportspress' ),
|
'sp_layout' => __( 'Layout', 'sportspress' ),
|
||||||
), $existing_columns );
|
),
|
||||||
|
$existing_columns
|
||||||
|
);
|
||||||
return apply_filters( 'sportspress_list_admin_columns', $columns );
|
return apply_filters( 'sportspress_list_admin_columns', $columns );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_player':
|
case 'sp_player':
|
||||||
$select = get_post_meta( $post_id, 'sp_select', true );
|
$select = get_post_meta( $post_id, 'sp_select', true );
|
||||||
if ( 'manual' == $select ):
|
if ( 'manual' == $select ) :
|
||||||
$players = array_filter( get_post_meta( $post_id, 'sp_player' ) );
|
$players = array_filter( get_post_meta( $post_id, 'sp_player' ) );
|
||||||
echo sizeof( $players );
|
echo sizeof( $players );
|
||||||
else:
|
else :
|
||||||
_e( 'Auto', 'sportspress' );
|
_e( 'Auto', 'sportspress' );
|
||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
case 'sp_league':
|
case 'sp_league':
|
||||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
|
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : __( 'All', 'sportspress' );
|
||||||
break;
|
break;
|
||||||
case 'sp_season':
|
case 'sp_season':
|
||||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
|
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : __( 'All', 'sportspress' );
|
||||||
break;
|
break;
|
||||||
case 'sp_team':
|
case 'sp_team':
|
||||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
$teams = (array) get_post_meta( $post_id, 'sp_team', false );
|
||||||
$teams = array_filter( $teams );
|
$teams = array_filter( $teams );
|
||||||
if ( empty( $teams ) ):
|
if ( empty( $teams ) ) :
|
||||||
echo __( 'All', 'sportspress' );
|
echo __( 'All', 'sportspress' );
|
||||||
else:
|
else :
|
||||||
foreach( $teams as $team_id ):
|
foreach ( $teams as $team_id ) :
|
||||||
if ( ! $team_id ) continue;
|
if ( ! $team_id ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$team = get_post( $team_id );
|
$team = get_post( $team_id );
|
||||||
if ( $team ) echo esc_html( $team->post_title ) . '<br>';
|
if ( $team ) {
|
||||||
|
echo esc_html( $team->post_title ) . '<br>';
|
||||||
|
}
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
@@ -101,15 +112,16 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
|||||||
public function filters() {
|
public function filters() {
|
||||||
global $typenow, $wp_query;
|
global $typenow, $wp_query;
|
||||||
|
|
||||||
if ( $typenow != 'sp_list' )
|
if ( $typenow != 'sp_list' ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||||
$args = array(
|
$args = array(
|
||||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'sp_league',
|
'name' => 'sp_league',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
|
|
||||||
@@ -118,7 +130,7 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
|||||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'sp_season',
|
'name' => 'sp_season',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
|
|
||||||
@@ -149,7 +161,7 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Metric' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Metric' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Metric Class
|
* SP_Admin_CPT_Metric Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Metric extends SP_Admin_CPT {
|
class SP_Admin_CPT_Metric extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -49,10 +52,11 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_key':
|
case 'sp_key':
|
||||||
global $post;
|
global $post;
|
||||||
echo esc_html( $post->post_name );
|
echo esc_html( $post->post_name );
|
||||||
@@ -63,7 +67,7 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
|
|||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.5.1
|
* @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' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Official' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Official' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Official Class
|
* SP_Admin_CPT_Official Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Official extends SP_Admin_CPT {
|
class SP_Admin_CPT_Official extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -35,17 +38,19 @@ class SP_Admin_CPT_Official extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change title boxes in admin.
|
* Change title boxes in admin.
|
||||||
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param object $post
|
* @param object $post
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function enter_title_here( $text, $post ) {
|
public function enter_title_here( $text, $post ) {
|
||||||
if ( $post->post_type == 'sp_official' )
|
if ( $post->post_type == 'sp_official' ) {
|
||||||
return __( 'Name', 'sportspress' );
|
return __( 'Name', 'sportspress' );
|
||||||
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Outcome' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Outcome' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Outcome Class
|
* SP_Admin_CPT_Outcome Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
|
class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -50,10 +53,11 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_key':
|
case 'sp_key':
|
||||||
global $post;
|
global $post;
|
||||||
echo esc_html( $post->post_name );
|
echo esc_html( $post->post_name );
|
||||||
@@ -68,7 +72,7 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
|
|||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Performance' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Performance' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Performance Class
|
* SP_Admin_CPT_Performance Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Performance extends SP_Admin_CPT {
|
class SP_Admin_CPT_Performance extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -52,10 +55,11 @@ class SP_Admin_CPT_Performance extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_icon':
|
case 'sp_icon':
|
||||||
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
||||||
break;
|
break;
|
||||||
@@ -77,7 +81,7 @@ class SP_Admin_CPT_Performance extends SP_Admin_CPT {
|
|||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Player' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Player' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Player Class
|
* SP_Admin_CPT_Player Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -52,13 +55,15 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change title boxes in admin.
|
* Change title boxes in admin.
|
||||||
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param object $post
|
* @param object $post
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function enter_title_here( $text, $post ) {
|
public function enter_title_here( $text, $post ) {
|
||||||
if ( $post->post_type == 'sp_player' )
|
if ( $post->post_type == 'sp_player' ) {
|
||||||
return __( 'Name', 'sportspress' );
|
return __( 'Name', 'sportspress' );
|
||||||
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
@@ -68,7 +73,8 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function edit_columns( $existing_columns ) {
|
public function edit_columns( $existing_columns ) {
|
||||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||||
$columns = array_merge( array(
|
$columns = array_merge(
|
||||||
|
array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'sp_number' => '<span class="dashicons sp-icon-tshirt sp-tip" title="' . __( 'Squad Number', 'sportspress' ) . '"></span>',
|
'sp_number' => '<span class="dashicons sp-icon-tshirt sp-tip" title="' . __( 'Squad Number', 'sportspress' ) . '"></span>',
|
||||||
'title' => null,
|
'title' => null,
|
||||||
@@ -76,20 +82,24 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||||
'sp_season' => __( 'Seasons', '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 );
|
return apply_filters( 'sportspress_player_admin_columns', $columns );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_number':
|
case 'sp_number':
|
||||||
echo esc_html( get_post_meta ( $post_id, 'sp_number', true ) );
|
echo esc_html( get_post_meta( $post_id, 'sp_number', true ) );
|
||||||
break;
|
break;
|
||||||
case 'sp_position':
|
case 'sp_position':
|
||||||
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
||||||
@@ -100,18 +110,20 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
$current_teams = array_filter( $current_teams );
|
$current_teams = array_filter( $current_teams );
|
||||||
$past_teams = array_filter( $past_teams );
|
$past_teams = array_filter( $past_teams );
|
||||||
echo '<span class="hidden sp-player-teams" data-current-teams="' . implode( ',', $current_teams ) . '" data-past-teams="' . implode( ',', $past_teams ) . '"></span>';
|
echo '<span class="hidden sp-player-teams" data-current-teams="' . implode( ',', $current_teams ) . '" data-past-teams="' . implode( ',', $past_teams ) . '"></span>';
|
||||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
$teams = (array) get_post_meta( $post_id, 'sp_team', false );
|
||||||
$teams = array_filter( $teams );
|
$teams = array_filter( $teams );
|
||||||
$teams = array_unique( $teams );
|
$teams = array_unique( $teams );
|
||||||
if ( empty( $teams ) ):
|
if ( empty( $teams ) ) :
|
||||||
echo '—';
|
echo '—';
|
||||||
else:
|
else :
|
||||||
foreach( $teams as $team_id ):
|
foreach ( $teams as $team_id ) :
|
||||||
if ( ! $team_id ) continue;
|
if ( ! $team_id ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$team = get_post( $team_id );
|
$team = get_post( $team_id );
|
||||||
if ( $team ):
|
if ( $team ) :
|
||||||
echo esc_html( $team->post_title );
|
echo esc_html( $team->post_title );
|
||||||
if ( in_array( $team_id, $current_teams ) ):
|
if ( in_array( $team_id, $current_teams ) ) :
|
||||||
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
||||||
endif;
|
endif;
|
||||||
echo '<br>';
|
echo '<br>';
|
||||||
@@ -120,13 +132,13 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
case 'sp_league':
|
case 'sp_league':
|
||||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_season':
|
case 'sp_season':
|
||||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_venue':
|
case 'sp_venue':
|
||||||
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
echo get_the_terms( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '—';
|
||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
@@ -137,16 +149,17 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
public function filters() {
|
public function filters() {
|
||||||
global $typenow, $wp_query;
|
global $typenow, $wp_query;
|
||||||
|
|
||||||
if ( $typenow != 'sp_player' )
|
if ( $typenow != 'sp_player' ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( taxonomy_exists( 'sp_position' ) ):
|
if ( taxonomy_exists( 'sp_position' ) ) :
|
||||||
$selected = isset( $_REQUEST['sp_position'] ) ? sanitize_key( $_REQUEST['sp_position'] ) : null;
|
$selected = isset( $_REQUEST['sp_position'] ) ? sanitize_key( $_REQUEST['sp_position'] ) : null;
|
||||||
$args = array(
|
$args = array(
|
||||||
'show_option_all' => __( 'Show all positions', 'sportspress' ),
|
'show_option_all' => __( 'Show all positions', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_position',
|
'taxonomy' => 'sp_position',
|
||||||
'name' => 'sp_position',
|
'name' => 'sp_position',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
endif;
|
endif;
|
||||||
@@ -161,24 +174,24 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
);
|
);
|
||||||
wp_dropdown_pages( $args );
|
wp_dropdown_pages( $args );
|
||||||
|
|
||||||
if ( taxonomy_exists( 'sp_league' ) ):
|
if ( taxonomy_exists( 'sp_league' ) ) :
|
||||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||||
$args = array(
|
$args = array(
|
||||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'sp_league',
|
'name' => 'sp_league',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( taxonomy_exists( 'sp_season' ) ):
|
if ( taxonomy_exists( 'sp_season' ) ) :
|
||||||
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
$selected = isset( $_REQUEST['sp_season'] ) ? sanitize_key( $_REQUEST['sp_season'] ) : null;
|
||||||
$args = array(
|
$args = array(
|
||||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'sp_season',
|
'name' => 'sp_season',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
endif;
|
endif;
|
||||||
@@ -191,7 +204,9 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function filters_query( $query ) {
|
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;
|
global $typenow, $wp_query;
|
||||||
|
|
||||||
@@ -213,8 +228,12 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
* @param string $post_type
|
* @param string $post_type
|
||||||
*/
|
*/
|
||||||
public function quick_edit_number( $column_name, $post_type ) {
|
public function quick_edit_number( $column_name, $post_type ) {
|
||||||
if ( $this->type !== $post_type ) return;
|
if ( $this->type !== $post_type ) {
|
||||||
if ( 'sp_number' !== $column_name ) return;
|
return;
|
||||||
|
}
|
||||||
|
if ( 'sp_number' !== $column_name ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static $print_nonce = true;
|
static $print_nonce = true;
|
||||||
if ( $print_nonce ) {
|
if ( $print_nonce ) {
|
||||||
@@ -240,16 +259,24 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
* @param string $post_type
|
* @param string $post_type
|
||||||
*/
|
*/
|
||||||
public function quick_edit_teams( $column_name, $post_type ) {
|
public function quick_edit_teams( $column_name, $post_type ) {
|
||||||
if ( $this->type !== $post_type ) return;
|
if ( $this->type !== $post_type ) {
|
||||||
if ( 'sp_team' !== $column_name ) return;
|
return;
|
||||||
|
}
|
||||||
|
if ( 'sp_team' !== $column_name ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$teams = get_posts( array(
|
$teams = get_posts(
|
||||||
|
array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'numberposts' => -1,
|
'numberposts' => -1,
|
||||||
'post_status' => 'publish',
|
'post_status' => 'publish',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if ( ! $teams ) return;
|
if ( ! $teams ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<fieldset class="inline-edit-col-right">
|
<fieldset class="inline-edit-col-right">
|
||||||
<div class="inline-edit-col">
|
<div class="inline-edit-col">
|
||||||
@@ -278,17 +305,27 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
* @param int $post_id
|
* @param int $post_id
|
||||||
*/
|
*/
|
||||||
public function quick_save( $post_id ) {
|
public function quick_save( $post_id ) {
|
||||||
if ( empty( $_POST ) ) return $post_id;
|
if ( empty( $_POST ) ) {
|
||||||
if ( ! current_user_can( 'edit_post', $post_id ) ) return $post_id;;
|
return $post_id;
|
||||||
|
}
|
||||||
|
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
||||||
|
return $post_id;
|
||||||
|
}
|
||||||
|
|
||||||
$_POST += array( "{$this->type}_edit_nonce" => '' );
|
$_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 ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||||
if ( isset( $post->post_type ) && $post->post_type == 'revision' ) return $post_id;
|
return $post_id;
|
||||||
|
}
|
||||||
|
if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
|
||||||
|
return $post_id;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isset( $_POST[ 'sp_number' ] ) ) {
|
if ( isset( $_POST['sp_number'] ) ) {
|
||||||
update_post_meta( $post_id, 'sp_number', $_POST[ 'sp_number' ] );
|
update_post_meta( $post_id, 'sp_number', $_POST['sp_number'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
|
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
|
||||||
@@ -303,8 +340,12 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
* @param string $post_type
|
* @param string $post_type
|
||||||
*/
|
*/
|
||||||
public function bulk_edit_teams( $column_name, $post_type ) {
|
public function bulk_edit_teams( $column_name, $post_type ) {
|
||||||
if ( $this->type !== $post_type ) return;
|
if ( $this->type !== $post_type ) {
|
||||||
if ( 'sp_team' !== $column_name ) return;
|
return;
|
||||||
|
}
|
||||||
|
if ( 'sp_team' !== $column_name ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static $print_nonce = true;
|
static $print_nonce = true;
|
||||||
if ( $print_nonce ) {
|
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' );
|
wp_nonce_field( plugin_basename( __FILE__ ), 'sp_player_edit_nonce' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$teams = get_posts( array(
|
$teams = get_posts(
|
||||||
|
array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'numberposts' => -1,
|
'numberposts' => -1,
|
||||||
'post_status' => 'publish',
|
'post_status' => 'publish',
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if ( ! $teams ) return;
|
if ( ! $teams ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<fieldset class="inline-edit-col-right">
|
<fieldset class="inline-edit-col-right">
|
||||||
<div class="inline-edit-col">
|
<div class="inline-edit-col">
|
||||||
@@ -345,10 +390,12 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
* Save bulk edit boxes
|
* Save bulk edit boxes
|
||||||
*/
|
*/
|
||||||
public function bulk_save() {
|
public function bulk_save() {
|
||||||
$_POST += array( "nonce" => '' );
|
$_POST += array( 'nonce' => '' );
|
||||||
if ( ! wp_verify_nonce( $_POST["nonce"], plugin_basename( __FILE__ ) ) ) return;
|
if ( ! wp_verify_nonce( $_POST['nonce'], plugin_basename( __FILE__ ) ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$post_ids = ( ! empty( $_POST[ 'post_ids' ] ) ) ? $_POST[ 'post_ids' ] : array();
|
$post_ids = ( ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
|
||||||
|
|
||||||
$current_teams = sp_array_value( $_POST, 'current_teams', array() );
|
$current_teams = sp_array_value( $_POST, 'current_teams', array() );
|
||||||
$past_teams = sp_array_value( $_POST, 'past_teams', array() );
|
$past_teams = sp_array_value( $_POST, 'past_teams', array() );
|
||||||
@@ -356,7 +403,9 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
|
|
||||||
if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
|
if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
|
||||||
foreach ( $post_ids as $post_id ) {
|
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_current_team', $current_teams );
|
||||||
sp_add_post_meta_recursive( $post_id, 'sp_past_team', $past_teams );
|
sp_add_post_meta_recursive( $post_id, 'sp_past_team', $past_teams );
|
||||||
@@ -366,7 +415,7 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
|||||||
|
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Result' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Result' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Result Class
|
* SP_Admin_CPT_Result Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Result extends SP_Admin_CPT {
|
class SP_Admin_CPT_Result extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -49,10 +52,11 @@ class SP_Admin_CPT_Result extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_key':
|
case 'sp_key':
|
||||||
global $post;
|
global $post;
|
||||||
echo esc_html( $post->post_name ) . 'for, ' . esc_html( $post->post_name ) . 'against';
|
echo esc_html( $post->post_name ) . 'for, ' . esc_html( $post->post_name ) . 'against';
|
||||||
@@ -63,7 +67,7 @@ class SP_Admin_CPT_Result extends SP_Admin_CPT {
|
|||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Spec' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Spec' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Spec Class
|
* SP_Admin_CPT_Spec Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Spec extends SP_Admin_CPT {
|
class SP_Admin_CPT_Spec extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -49,10 +52,11 @@ class SP_Admin_CPT_Spec extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_key':
|
case 'sp_key':
|
||||||
global $post;
|
global $post;
|
||||||
echo esc_html( $post->post_name );
|
echo esc_html( $post->post_name );
|
||||||
@@ -63,7 +67,7 @@ class SP_Admin_CPT_Spec extends SP_Admin_CPT {
|
|||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Staff' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Staff' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Staff Class
|
* SP_Admin_CPT_Staff Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -43,13 +46,15 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change title boxes in admin.
|
* Change title boxes in admin.
|
||||||
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param object $post
|
* @param object $post
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function enter_title_here( $text, $post ) {
|
public function enter_title_here( $text, $post ) {
|
||||||
if ( $post->post_type == 'sp_staff' )
|
if ( $post->post_type == 'sp_staff' ) {
|
||||||
return __( 'Name', 'sportspress' );
|
return __( 'Name', 'sportspress' );
|
||||||
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
@@ -59,41 +64,48 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function edit_columns( $existing_columns ) {
|
public function edit_columns( $existing_columns ) {
|
||||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||||
$columns = array_merge( array(
|
$columns = array_merge(
|
||||||
|
array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => null,
|
'title' => null,
|
||||||
'sp_role' => __( 'Job', 'sportspress' ),
|
'sp_role' => __( 'Job', 'sportspress' ),
|
||||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||||
'sp_season' => __( 'Seasons', '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 );
|
return apply_filters( 'sportspress_staff_admin_columns', $columns );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_role':
|
case 'sp_role':
|
||||||
echo get_the_terms( $post_id, 'sp_role' ) ? the_terms( $post_id, 'sp_role' ) : '—';
|
echo get_the_terms( $post_id, 'sp_role' ) ? the_terms( $post_id, 'sp_role' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_team':
|
case 'sp_team':
|
||||||
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
|
$teams = (array) get_post_meta( $post_id, 'sp_team', false );
|
||||||
$teams = array_filter( $teams );
|
$teams = array_filter( $teams );
|
||||||
if ( empty( $teams ) ):
|
if ( empty( $teams ) ) :
|
||||||
echo '—';
|
echo '—';
|
||||||
else:
|
else :
|
||||||
$current_teams = get_post_meta( $post_id, 'sp_current_team', false );
|
$current_teams = get_post_meta( $post_id, 'sp_current_team', false );
|
||||||
foreach( $teams as $team_id ):
|
foreach ( $teams as $team_id ) :
|
||||||
if ( ! $team_id ) continue;
|
if ( ! $team_id ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$team = get_post( $team_id );
|
$team = get_post( $team_id );
|
||||||
if ( $team ):
|
if ( $team ) :
|
||||||
echo esc_html( $team->post_title );
|
echo esc_html( $team->post_title );
|
||||||
if ( in_array( $team_id, $current_teams ) ):
|
if ( in_array( $team_id, $current_teams ) ) :
|
||||||
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
echo '<span class="dashicons dashicons-yes" title="' . __( 'Current Team', 'sportspress' ) . '"></span>';
|
||||||
endif;
|
endif;
|
||||||
echo '<br>';
|
echo '<br>';
|
||||||
@@ -102,10 +114,10 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
|||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
case 'sp_league':
|
case 'sp_league':
|
||||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_season':
|
case 'sp_season':
|
||||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
@@ -116,8 +128,9 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
|||||||
public function filters() {
|
public function filters() {
|
||||||
global $typenow, $wp_query;
|
global $typenow, $wp_query;
|
||||||
|
|
||||||
if ( $typenow != 'sp_staff' )
|
if ( $typenow != 'sp_staff' ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
$selected = isset( $_REQUEST['team'] ) ? sanitize_key( $_REQUEST['team'] ) : null;
|
||||||
$args = array(
|
$args = array(
|
||||||
@@ -134,7 +147,7 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
|||||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'sp_league',
|
'name' => 'sp_league',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
|
|
||||||
@@ -143,7 +156,7 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
|||||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'sp_season',
|
'name' => 'sp_season',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
}
|
}
|
||||||
@@ -164,7 +177,7 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.7.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_CPT' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Statistic' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Statistic' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Statistic Class
|
* SP_Admin_CPT_Statistic Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
|
class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -52,10 +55,11 @@ class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_icon':
|
case 'sp_icon':
|
||||||
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
||||||
break;
|
break;
|
||||||
@@ -75,7 +79,7 @@ class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
|
|||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.5
|
* @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' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Table' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Table' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Table Class
|
* SP_Admin_CPT_Table Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -43,34 +46,38 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function edit_columns( $existing_columns ) {
|
public function edit_columns( $existing_columns ) {
|
||||||
unset( $existing_columns['date'] );
|
unset( $existing_columns['date'] );
|
||||||
$columns = array_merge( array(
|
$columns = array_merge(
|
||||||
|
array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Title', 'sportspress' ),
|
'title' => __( 'Title', 'sportspress' ),
|
||||||
'sp_league' => __( 'League', 'sportspress' ),
|
'sp_league' => __( 'League', 'sportspress' ),
|
||||||
'sp_season' => __( 'Season', 'sportspress' ),
|
'sp_season' => __( 'Season', 'sportspress' ),
|
||||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||||
), $existing_columns );
|
),
|
||||||
|
$existing_columns
|
||||||
|
);
|
||||||
return apply_filters( 'sportspress_table_admin_columns', $columns );
|
return apply_filters( 'sportspress_table_admin_columns', $columns );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_league':
|
case 'sp_league':
|
||||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_season':
|
case 'sp_season':
|
||||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_team':
|
case 'sp_team':
|
||||||
$select = get_post_meta( $post_id, 'sp_select', true );
|
$select = get_post_meta( $post_id, 'sp_select', true );
|
||||||
if ( 'manual' == $select ):
|
if ( 'manual' == $select ) :
|
||||||
$teams = array_filter( get_post_meta( $post_id, 'sp_team' ) );
|
$teams = array_filter( get_post_meta( $post_id, 'sp_team' ) );
|
||||||
echo sizeof( $teams );
|
echo sizeof( $teams );
|
||||||
else:
|
else :
|
||||||
_e( 'Auto', 'sportspress' );
|
_e( 'Auto', 'sportspress' );
|
||||||
endif;
|
endif;
|
||||||
break;
|
break;
|
||||||
@@ -83,15 +90,16 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
|||||||
public function filters() {
|
public function filters() {
|
||||||
global $typenow, $wp_query;
|
global $typenow, $wp_query;
|
||||||
|
|
||||||
if ( $typenow != 'sp_table' )
|
if ( $typenow != 'sp_table' ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||||
$args = array(
|
$args = array(
|
||||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'sp_league',
|
'name' => 'sp_league',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
|
|
||||||
@@ -100,7 +108,7 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
|||||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'sp_season',
|
'name' => 'sp_season',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
|
|
||||||
@@ -131,7 +139,7 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,20 @@
|
|||||||
* @version 2.6
|
* @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' ) )
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) {
|
||||||
include( 'class-sp-admin-cpt.php' );
|
require 'class-sp-admin-cpt.php';
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Admin_CPT_Team' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT_Team' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT_Team Class
|
* SP_Admin_CPT_Team Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -42,13 +45,15 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change title boxes in admin.
|
* Change title boxes in admin.
|
||||||
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param object $post
|
* @param object $post
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function enter_title_here( $text, $post ) {
|
public function enter_title_here( $text, $post ) {
|
||||||
if ( $post->post_type == 'sp_team' )
|
if ( $post->post_type == 'sp_team' ) {
|
||||||
return __( 'Name', 'sportspress' );
|
return __( 'Name', 'sportspress' );
|
||||||
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
@@ -58,7 +63,8 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function edit_columns( $existing_columns ) {
|
public function edit_columns( $existing_columns ) {
|
||||||
unset( $existing_columns['author'], $existing_columns['date'] );
|
unset( $existing_columns['author'], $existing_columns['date'] );
|
||||||
$columns = array_merge( array(
|
$columns = array_merge(
|
||||||
|
array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'sp_icon' => '<span class="dashicons sp-icon-shield sp-tip" title="' . __( 'Logo', 'sportspress' ) . '"></span>',
|
'sp_icon' => '<span class="dashicons sp-icon-shield sp-tip" title="' . __( 'Logo', 'sportspress' ) . '"></span>',
|
||||||
'title' => null,
|
'title' => null,
|
||||||
@@ -66,34 +72,38 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
|||||||
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
|
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
|
||||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||||
), $existing_columns, array(
|
),
|
||||||
|
$existing_columns,
|
||||||
|
array(
|
||||||
'title' => __( 'Team', 'sportspress' ),
|
'title' => __( 'Team', 'sportspress' ),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
return apply_filters( 'sportspress_team_admin_columns', $columns );
|
return apply_filters( 'sportspress_team_admin_columns', $columns );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define our custom columns shown in admin.
|
* Define our custom columns shown in admin.
|
||||||
|
*
|
||||||
* @param string $column
|
* @param string $column
|
||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ) :
|
||||||
case 'sp_icon':
|
case 'sp_icon':
|
||||||
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
|
||||||
break;
|
break;
|
||||||
case 'sp_short_name':
|
case 'sp_short_name':
|
||||||
$short_name = get_post_meta ( $post_id, 'sp_short_name', true );
|
$short_name = get_post_meta( $post_id, 'sp_short_name', true );
|
||||||
echo $short_name ? esc_html( $short_name ) : '—';
|
echo $short_name ? esc_html( $short_name ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_abbreviation':
|
case 'sp_abbreviation':
|
||||||
$abbreviation = get_post_meta ( $post_id, 'sp_abbreviation', true );
|
$abbreviation = get_post_meta( $post_id, 'sp_abbreviation', true );
|
||||||
echo $abbreviation ? esc_html( $abbreviation ) : '—';
|
echo $abbreviation ? esc_html( $abbreviation ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_league':
|
case 'sp_league':
|
||||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
echo get_the_terms( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||||
break;
|
break;
|
||||||
case 'sp_season':
|
case 'sp_season':
|
||||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
echo get_the_terms( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
@@ -104,15 +114,16 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
|||||||
public function filters() {
|
public function filters() {
|
||||||
global $typenow, $wp_query;
|
global $typenow, $wp_query;
|
||||||
|
|
||||||
if ( $typenow != 'sp_team' )
|
if ( $typenow != 'sp_team' ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
$selected = isset( $_REQUEST['sp_league'] ) ? sanitize_key( $_REQUEST['sp_league'] ) : null;
|
||||||
$args = array(
|
$args = array(
|
||||||
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
'show_option_all' => __( 'Show all leagues', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'sp_league',
|
'name' => 'sp_league',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
|
|
||||||
@@ -121,11 +132,11 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
|||||||
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
'show_option_all' => __( 'Show all seasons', 'sportspress' ),
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'sp_season',
|
'name' => 'sp_season',
|
||||||
'selected' => $selected
|
'selected' => $selected,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
* @version 0.7
|
* @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' ) ) :
|
if ( ! class_exists( 'SP_Admin_CPT' ) ) :
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_CPT Class
|
* SP_Admin_CPT Class
|
||||||
*/
|
*/
|
||||||
class SP_Admin_CPT {
|
class SP_Admin_CPT {
|
||||||
|
|
||||||
protected $type = '';
|
protected $type = '';
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ class SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change label for insert buttons.
|
* Change label for insert buttons.
|
||||||
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $strings
|
* @param array $strings
|
||||||
* @return array
|
* @return array
|
||||||
@@ -48,6 +51,7 @@ class SP_Admin_CPT {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we're editing or adding an event
|
* Check if we're editing or adding an event
|
||||||
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
private function is_editing() {
|
private function is_editing() {
|
||||||
@@ -62,6 +66,6 @@ class SP_Admin_CPT {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
@@ -10,7 +10,9 @@
|
|||||||
* @version 2.6.8
|
* @version 2.6.8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Admin_Meta_Boxes
|
* SP_Admin_Meta_Boxes
|
||||||
@@ -315,13 +317,27 @@ class SP_Admin_Meta_Boxes {
|
|||||||
* @param object $post
|
* @param object $post
|
||||||
*/
|
*/
|
||||||
public function save_meta_boxes( $post_id, $post ) {
|
public function save_meta_boxes( $post_id, $post ) {
|
||||||
if ( empty( $post_id ) || empty( $post ) ) return;
|
if ( empty( $post_id ) || empty( $post ) ) {
|
||||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
|
return;
|
||||||
if ( is_int( wp_is_post_revision( $post ) ) ) return;
|
}
|
||||||
if ( is_int( wp_is_post_autosave( $post ) ) ) return;
|
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||||
if ( empty( $_POST['sportspress_meta_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_meta_nonce'], 'sportspress_save_data' ) ) return;
|
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 ( 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 );
|
do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Calendar_Columns
|
* SP_Meta_Box_Calendar_Columns
|
||||||
@@ -30,11 +32,11 @@ class SP_Meta_Box_Calendar_Columns {
|
|||||||
$columns = array();
|
$columns = array();
|
||||||
|
|
||||||
if ( 'teams' === $title_format ) {
|
if ( 'teams' === $title_format ) {
|
||||||
$columns[ 'event' ] = __( 'Home', 'sportspress' ) . ' | ' . __( 'Away', 'sportspress' );
|
$columns['event'] = __( 'Home', 'sportspress' ) . ' | ' . __( 'Away', 'sportspress' );
|
||||||
} elseif ( 'homeaway' === $title_format ) {
|
} elseif ( 'homeaway' === $title_format ) {
|
||||||
$columns[ 'event' ] = __( 'Teams', 'sportspress' );
|
$columns['event'] = __( 'Teams', 'sportspress' );
|
||||||
} else {
|
} else {
|
||||||
$columns[ 'event' ] = __( 'Title', 'sportspress' );
|
$columns['event'] = __( 'Title', 'sportspress' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'time' === $time_format || 'separate' === $time_format ) {
|
if ( 'time' === $time_format || 'separate' === $time_format ) {
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Calendar_Data
|
* SP_Meta_Box_Calendar_Data
|
||||||
@@ -41,7 +43,7 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
|
|
||||||
if ( is_array( $usecolumns ) ) {
|
if ( is_array( $usecolumns ) ) {
|
||||||
$usecolumns = array_filter( $usecolumns );
|
$usecolumns = array_filter( $usecolumns );
|
||||||
}else{
|
} else {
|
||||||
$usecolumns = array();
|
$usecolumns = array();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -57,7 +59,11 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
<label for="sp_columns_event">
|
<label for="sp_columns_event">
|
||||||
<?php
|
<?php
|
||||||
if ( 'teams' == $title_format ) {
|
if ( 'teams' == $title_format ) {
|
||||||
_e( 'Home', 'sportspress' ); ?> | <?php _e( 'Away', 'sportspress' );
|
_e( 'Home', 'sportspress' );
|
||||||
|
?>
|
||||||
|
|
|
||||||
|
<?php
|
||||||
|
_e( 'Away', 'sportspress' );
|
||||||
} elseif ( 'homeaway' == $title_format ) {
|
} elseif ( 'homeaway' == $title_format ) {
|
||||||
_e( 'Teams', 'sportspress' );
|
_e( 'Teams', 'sportspress' );
|
||||||
} else {
|
} else {
|
||||||
@@ -127,40 +133,54 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
if ( is_array( $data ) ):
|
if ( is_array( $data ) ) :
|
||||||
if ( sizeof( $data ) > 0 ):
|
if ( sizeof( $data ) > 0 ) :
|
||||||
$main_result = get_option( 'sportspress_primary_result', null );
|
$main_result = get_option( 'sportspress_primary_result', null );
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $data as $event ):
|
foreach ( $data as $event ) :
|
||||||
$teams = get_post_meta( $event->ID, 'sp_team' );
|
$teams = get_post_meta( $event->ID, 'sp_team' );
|
||||||
$results = get_post_meta( $event->ID, 'sp_results', true );
|
$results = get_post_meta( $event->ID, 'sp_results', true );
|
||||||
$video = get_post_meta( $event->ID, 'sp_video', true );
|
$video = get_post_meta( $event->ID, 'sp_video', true );
|
||||||
$main_results = array();
|
$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>
|
<td><?php echo get_post_time( get_option( 'date_format' ), false, $event, true ); ?></td>
|
||||||
<?php if ( is_array( $usecolumns ) && in_array( 'event', $usecolumns ) ) { ?>
|
<?php if ( is_array( $usecolumns ) && in_array( 'event', $usecolumns ) ) { ?>
|
||||||
<td>
|
<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-title
|
||||||
<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
|
<?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 );
|
$name = get_the_title( $team );
|
||||||
if ( $name ):
|
if ( $name ) :
|
||||||
$team_results = sp_array_value( $results, $team, null );
|
$team_results = sp_array_value( $results, $team, null );
|
||||||
|
|
||||||
if ( $main_result ):
|
if ( $main_result ) :
|
||||||
$team_result = sp_array_value( $team_results, $main_result, null );
|
$team_result = sp_array_value( $team_results, $main_result, null );
|
||||||
else:
|
else :
|
||||||
if ( is_array( $team_results ) ):
|
if ( is_array( $team_results ) ) :
|
||||||
end( $team_results );
|
end( $team_results );
|
||||||
$team_result = prev( $team_results );
|
$team_result = prev( $team_results );
|
||||||
else:
|
else :
|
||||||
$team_result = null;
|
$team_result = null;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $team_result != null ):
|
if ( $team_result != null ) :
|
||||||
$team_result = apply_filters( 'sportspress_calendar_team_result_admin', $team_result, $event->ID, $team );
|
$team_result = apply_filters( 'sportspress_calendar_team_result_admin', $team_result, $event->ID, $team );
|
||||||
$main_results[] = $team_result;
|
$main_results[] = $team_result;
|
||||||
unset( $team_results['outcome'] );
|
unset( $team_results['outcome'] );
|
||||||
@@ -170,7 +190,7 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
|
|
||||||
echo esc_html( $name ) . '<br>';
|
echo esc_html( $name ) . '<br>';
|
||||||
endif;
|
endif;
|
||||||
endforeach; else:
|
endforeach; else :
|
||||||
echo '—';
|
echo '—';
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
@@ -185,9 +205,9 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
if ( ! empty( $main_results ) ):
|
if ( ! empty( $main_results ) ) :
|
||||||
echo implode( ' - ', $main_results );
|
echo implode( ' - ', $main_results );
|
||||||
else:
|
else :
|
||||||
echo apply_filters( 'sportspress_event_time_admin', get_post_time( get_option( 'time_format' ), false, $event, true ), $event->ID );
|
echo apply_filters( 'sportspress_event_time_admin', get_post_time( get_option( 'time_format' ), false, $event, true ), $event->ID );
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
@@ -197,9 +217,9 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
<?php if ( ( is_array( $usecolumns ) && in_array( 'results', $usecolumns ) ) && in_array( $time_format, array( 'separate', 'results' ) ) ) { ?>
|
<?php if ( ( is_array( $usecolumns ) && in_array( 'results', $usecolumns ) ) && in_array( $time_format, array( 'separate', 'results' ) ) ) { ?>
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
if ( ! empty( $main_results ) ):
|
if ( ! empty( $main_results ) ) :
|
||||||
echo implode( ' - ', $main_results );
|
echo implode( ' - ', $main_results );
|
||||||
else:
|
else :
|
||||||
echo '-';
|
echo '-';
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
@@ -217,17 +237,17 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
<?php if ( is_array( $usecolumns ) && in_array( 'article', $usecolumns ) ) { ?>
|
<?php if ( is_array( $usecolumns ) && in_array( 'article', $usecolumns ) ) { ?>
|
||||||
<td>
|
<td>
|
||||||
<a href="<?php echo get_edit_post_link( $event->ID ); ?>#sp_articlediv">
|
<a href="<?php echo get_edit_post_link( $event->ID ); ?>#sp_articlediv">
|
||||||
<?php if ( $video ): ?>
|
<?php if ( $video ) : ?>
|
||||||
<div class="dashicons dashicons-video-alt"></div>
|
<div class="dashicons dashicons-video-alt"></div>
|
||||||
<?php elseif ( has_post_thumbnail( $event->ID ) ): ?>
|
<?php elseif ( has_post_thumbnail( $event->ID ) ) : ?>
|
||||||
<div class="dashicons dashicons-camera"></div>
|
<div class="dashicons dashicons-camera"></div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php
|
<?php
|
||||||
if ( $event->post_content == null ):
|
if ( $event->post_content == null ) :
|
||||||
_e( 'None', 'sportspress' );
|
_e( 'None', 'sportspress' );
|
||||||
elseif ( $event->post_status == 'publish' ):
|
elseif ( $event->post_status == 'publish' ) :
|
||||||
_e( 'Recap', 'sportspress' );
|
_e( 'Recap', 'sportspress' );
|
||||||
else:
|
else :
|
||||||
_e( 'Preview', 'sportspress' );
|
_e( 'Preview', 'sportspress' );
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
@@ -251,7 +271,7 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
<?php
|
<?php
|
||||||
$i++;
|
$i++;
|
||||||
endforeach;
|
endforeach;
|
||||||
else:
|
else :
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row alternate">
|
<tr class="sp-row alternate">
|
||||||
<td colspan="<?php echo sizeof( $usecolumns ); ?>">
|
<td colspan="<?php echo sizeof( $usecolumns ); ?>">
|
||||||
@@ -260,7 +280,7 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
else:
|
else :
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row alternate">
|
<tr class="sp-row alternate">
|
||||||
<td colspan="<?php echo sizeof( $usecolumns ); ?>">
|
<td colspan="<?php echo sizeof( $usecolumns ); ?>">
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Calendar_Details
|
* SP_Meta_Box_Calendar_Details
|
||||||
@@ -55,7 +57,7 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
<p>
|
<p>
|
||||||
<select name="sp_event_format" class="postform">
|
<select name="sp_event_format" class="postform">
|
||||||
<option value="all">All</option>
|
<option value="all">All</option>
|
||||||
<?php foreach ( SP()->formats->event as $key => $format ): ?>
|
<?php foreach ( SP()->formats->event as $key => $format ) : ?>
|
||||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $event_format, $key ); ?>><?php echo esc_html( $format ); ?></option>
|
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $event_format, $key ); ?>><?php echo esc_html( $format ); ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
@@ -121,7 +123,7 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
'placeholder' => __( 'All', 'sportspress' ),
|
'placeholder' => __( 'All', 'sportspress' ),
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_pages( $args ) ):
|
if ( ! sp_dropdown_pages( $args ) ) :
|
||||||
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
@@ -139,7 +141,7 @@ class SP_Meta_Box_Calendar_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
'placeholder' => __( 'All', 'sportspress' ),
|
'placeholder' => __( 'All', 'sportspress' ),
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_pages( $args ) ):
|
if ( ! sp_dropdown_pages( $args ) ) :
|
||||||
sp_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
|
sp_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Calendar_Feeds
|
* SP_Meta_Box_Calendar_Feeds
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Calendar_Format
|
* SP_Meta_Box_Calendar_Format
|
||||||
@@ -23,7 +25,7 @@ class SP_Meta_Box_Calendar_Format {
|
|||||||
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
||||||
?>
|
?>
|
||||||
<div id="post-formats-select">
|
<div id="post-formats-select">
|
||||||
<?php foreach ( SP()->formats->calendar as $key => $format ): ?>
|
<?php foreach ( SP()->formats->calendar as $key => $format ) : ?>
|
||||||
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( true, ( $key == 'calendar' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $format ); ?></label><br>
|
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( true, ( $key == 'calendar' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $format ); ?></label><br>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 1.6.1
|
* @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
|
* SP_Meta_Box_Calendar_Shortcode
|
||||||
@@ -20,7 +22,9 @@ class SP_Meta_Box_Calendar_Shortcode {
|
|||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
$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">
|
<p class="howto">
|
||||||
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
|
<?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
|
* @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' ) )
|
if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
|
||||||
include( 'class-sp-meta-box-config.php' );
|
require 'class-sp-meta-box-config.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Column_Details
|
* 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 );
|
$precision = get_post_meta( $post->ID, 'sp_precision', true );
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
if ( $precision == '' ) $precision = 0;
|
if ( $precision == '' ) {
|
||||||
|
$precision = 0;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
@@ -46,18 +51,21 @@ class SP_Meta_Box_Column_Details extends SP_Meta_Box_Config {
|
|||||||
<?php
|
<?php
|
||||||
$options = array( '0' => __( 'Disable', 'sportspress' ) );
|
$options = array( '0' => __( 'Disable', 'sportspress' ) );
|
||||||
$count = wp_count_posts( 'sp_column' );
|
$count = wp_count_posts( 'sp_column' );
|
||||||
for( $i = 1; $i <= $count->publish; $i++ ):
|
for ( $i = 1; $i <= $count->publish; $i++ ) :
|
||||||
$options[ $i ] = $i;
|
$options[ $i ] = $i;
|
||||||
endfor;
|
endfor;
|
||||||
foreach ( $options as $key => $value ):
|
foreach ( $options as $key => $value ) :
|
||||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
|
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $priority, false ), $value );
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
<select name="sp_order">
|
<select name="sp_order">
|
||||||
<?php
|
<?php
|
||||||
$options = array( 'DESC' => __( 'Descending', 'sportspress' ), 'ASC' => __( 'Ascending', 'sportspress' ) );
|
$options = array(
|
||||||
foreach ( $options as $key => $value ):
|
'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 );
|
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $order, false ), $value );
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -8,10 +8,13 @@
|
|||||||
* @version 1.9.4
|
* @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' ) )
|
if ( ! class_exists( 'SP_Meta_Box_Equation' ) ) {
|
||||||
include( 'class-sp-meta-box-equation.php' );
|
require 'class-sp-meta-box-equation.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Column_Equation
|
* SP_Meta_Box_Column_Equation
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Config
|
* SP_Meta_Box_Config
|
||||||
@@ -26,14 +28,16 @@ class SP_Meta_Box_Config {
|
|||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$key = isset( $post['sp_key'] ) ? $post['sp_key'] : null;
|
$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' );
|
$id = sp_array_value( $post, 'post_ID', 'var' );
|
||||||
$title = sp_get_eos_safe_slug( $key, $id );
|
$title = sp_get_eos_safe_slug( $key, $id );
|
||||||
|
|
||||||
$check_sql = "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
|
$check_sql = "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
|
||||||
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $title, $post['post_type'], $id ) );
|
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $title, $post['post_type'], $id ) );
|
||||||
|
|
||||||
if ( $post_name_check ):
|
if ( $post_name_check ) :
|
||||||
wp_delete_post( $post_name_check, true );
|
wp_delete_post( $post_name_check, true );
|
||||||
$post['post_status'] = 'draft';
|
$post['post_status'] = 'draft';
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Equation
|
* SP_Meta_Box_Equation
|
||||||
@@ -23,88 +25,146 @@ class SP_Meta_Box_Equation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function builder( $title = 'f(x)', $equation = '', $groups = array() ) {
|
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
|
$options = array(); // Multidimensional equation part options
|
||||||
$parts = array(); // Flattened equation part options
|
$parts = array(); // Flattened equation part options
|
||||||
|
|
||||||
// Add groups to options
|
// Add groups to options
|
||||||
foreach ( $groups as $group ):
|
foreach ( $groups as $group ) :
|
||||||
switch ( $group ):
|
switch ( $group ) :
|
||||||
case 'player_event':
|
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;
|
break;
|
||||||
case 'team_event':
|
case 'team_event':
|
||||||
$options[ 'Events' ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ), '$eventminutes' => __( 'Minutes', 'sportspress' ) );
|
$options['Events'] = array(
|
||||||
|
'$eventsplayed' => __( 'Played', 'sportspress' ),
|
||||||
|
'$eventminutes' => __( 'Minutes', 'sportspress' ),
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 'result':
|
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;
|
break;
|
||||||
case 'outcome':
|
case 'outcome':
|
||||||
$options[ 'Outcomes' ] = self::optgroup( 'sp_outcome' );
|
$options['Outcomes'] = self::optgroup( 'sp_outcome' );
|
||||||
break;
|
break;
|
||||||
case 'preset':
|
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;
|
break;
|
||||||
case 'subset':
|
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;
|
break;
|
||||||
case 'performance':
|
case 'performance':
|
||||||
$options[ 'Performance' ] = self::optgroup( 'sp_performance' );
|
$options['Performance'] = self::optgroup( 'sp_performance' );
|
||||||
break;
|
break;
|
||||||
case 'metric':
|
case 'metric':
|
||||||
$options[ 'Metrics' ] = self::optgroup( 'sp_metric' );
|
$options['Metrics'] = self::optgroup( 'sp_metric' );
|
||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
// Add operators to options
|
// Add operators to options
|
||||||
$options[ 'Operators' ] = array( '+' => '+', '-' => '−', '*' => '×', '/' => '÷', '(' => '(', ')' => ')' );
|
$options['Operators'] = array(
|
||||||
|
'+' => '+',
|
||||||
|
'-' => '−',
|
||||||
|
'*' => '×',
|
||||||
|
'/' => '÷',
|
||||||
|
'(' => '(',
|
||||||
|
')' => ')',
|
||||||
|
);
|
||||||
|
|
||||||
// Create array of constants
|
// Create array of constants
|
||||||
$max = 10;
|
$max = 10;
|
||||||
$constants = array();
|
$constants = array();
|
||||||
for ( $i = 0; $i <= $max; $i ++ ):
|
for ( $i = 0; $i <= $max; $i ++ ) :
|
||||||
$constants[$i] = $i;
|
$constants[ $i ] = $i;
|
||||||
endfor;
|
endfor;
|
||||||
|
|
||||||
// Add 100 to constants
|
// Add 100 to constants
|
||||||
$constants[100] = 100;
|
$constants[100] = 100;
|
||||||
|
|
||||||
// Add constants to options
|
// Add constants to options
|
||||||
$options[ 'Constants' ] = (array) $constants;
|
$options['Constants'] = (array) $constants;
|
||||||
|
|
||||||
$options = apply_filters( 'sportspress_equation_options', $options );
|
$options = apply_filters( 'sportspress_equation_options', $options );
|
||||||
?>
|
?>
|
||||||
<div class="sp-equation-builder">
|
<div class="sp-equation-builder">
|
||||||
<div class="sp-data-table-container sp-equation-parts">
|
<div class="sp-data-table-container sp-equation-parts">
|
||||||
<table class="widefat sp-data-table">
|
<table class="widefat sp-data-table">
|
||||||
<?php $i = 0; foreach ( $options as $label => $option ): ?>
|
<?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>
|
<th><?php _e( $label, 'sportspress' ); ?></th>
|
||||||
<td>
|
<td>
|
||||||
<?php foreach ( $option as $key => $value ): $parts[ $key ] = $value;
|
<?php
|
||||||
?><span class="button" data-variable="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value ); ?></span><?php
|
foreach ( $option as $key => $value ) :
|
||||||
endforeach; ?>
|
$parts[ $key ] = $value;
|
||||||
|
?>
|
||||||
|
<span class="button" data-variable="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value ); ?></span>
|
||||||
|
<?php
|
||||||
|
endforeach;
|
||||||
|
?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php $i++; endforeach; ?>
|
<?php
|
||||||
|
$i++;
|
||||||
|
endforeach;
|
||||||
|
?>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="sp-equation">
|
<div class="sp-equation">
|
||||||
<span class="sp-equation-variable"><?php echo esc_html( $title ); ?> = </span>
|
<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 );
|
$equation = trim( $equation );
|
||||||
if ( $equation !== '' ):
|
if ( $equation !== '' ) :
|
||||||
$equation = explode( ' ', $equation );
|
$equation = explode( ' ', $equation );
|
||||||
foreach ( $equation as $part ):
|
foreach ( $equation as $part ) :
|
||||||
if ( array_key_exists( $part, $parts ) ) {
|
if ( array_key_exists( $part, $parts ) ) {
|
||||||
$name = $parts[ $part ];
|
$name = $parts[ $part ];
|
||||||
} else {
|
} else {
|
||||||
$name = $part;
|
$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;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
?></span>
|
?>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
@@ -137,22 +197,24 @@ class SP_Meta_Box_Equation {
|
|||||||
$vars = get_posts( $args );
|
$vars = get_posts( $args );
|
||||||
|
|
||||||
// Add extra vars to the array
|
// Add extra vars to the array
|
||||||
if ( isset( $defaults ) && is_array( $defaults ) ):
|
if ( isset( $defaults ) && is_array( $defaults ) ) :
|
||||||
foreach ( $defaults as $key => $value ):
|
foreach ( $defaults as $key => $value ) :
|
||||||
$arr[ $key ] = $value;
|
$arr[ $key ] = $value;
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add vars to the array
|
// Add vars to the array
|
||||||
if ( isset( $variations ) && is_array( $variations ) ):
|
if ( isset( $variations ) && is_array( $variations ) ) :
|
||||||
foreach ( $vars as $var ):
|
foreach ( $vars as $var ) :
|
||||||
if ( $totals ) $arr[ '$' . $var->post_name ] = $var->post_title;
|
if ( $totals ) {
|
||||||
foreach ( $variations as $key => $value ):
|
$arr[ '$' . $var->post_name ] = $var->post_title;
|
||||||
|
}
|
||||||
|
foreach ( $variations as $key => $value ) :
|
||||||
$arr[ '$' . $var->post_name . $key ] = $var->post_title . ' ' . $value;
|
$arr[ '$' . $var->post_name . $key ] = $var->post_title . ' ' . $value;
|
||||||
endforeach;
|
endforeach;
|
||||||
endforeach;
|
endforeach;
|
||||||
else:
|
else :
|
||||||
foreach ( $vars as $var ):
|
foreach ( $vars as $var ) :
|
||||||
$arr[ '$' . $var->post_name ] = $var->post_title;
|
$arr[ '$' . $var->post_name ] = $var->post_title;
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
@@ -162,6 +224,7 @@ class SP_Meta_Box_Equation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Equation part labels for localization
|
* Equation part labels for localization
|
||||||
|
*
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public static function equation_part_labels() {
|
public static function equation_part_labels() {
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Event_Details
|
* SP_Meta_Box_Event_Details
|
||||||
@@ -39,7 +41,9 @@ class SP_Meta_Box_Event_Details {
|
|||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
foreach ( $taxonomies as $taxonomy ) {
|
foreach ( $taxonomies as $taxonomy ) {
|
||||||
if ( 'sp_venue' == $taxonomy ) continue;
|
if ( 'sp_venue' == $taxonomy ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sp_taxonomy_field( $taxonomy, $post, true, true, __( 'None', 'sportspress' ) );
|
sp_taxonomy_field( $taxonomy, $post, true, true, __( 'None', 'sportspress' ) );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Event_Format
|
* SP_Meta_Box_Event_Format
|
||||||
@@ -23,7 +25,7 @@ class SP_Meta_Box_Event_Format {
|
|||||||
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
||||||
?>
|
?>
|
||||||
<div id="post-formats-select">
|
<div id="post-formats-select">
|
||||||
<?php foreach ( SP()->formats->event as $key => $format ): ?>
|
<?php foreach ( SP()->formats->event as $key => $format ) : ?>
|
||||||
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( true, ( $key == 'league' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $format ); ?></label><br>
|
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( true, ( $key == 'league' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $format ); ?></label><br>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Event_Mode
|
* SP_Meta_Box_Event_Mode
|
||||||
@@ -22,7 +24,12 @@ class SP_Meta_Box_Event_Mode {
|
|||||||
$the_mode = sp_get_post_mode( $post->ID );
|
$the_mode = sp_get_post_mode( $post->ID );
|
||||||
?>
|
?>
|
||||||
<div id="post-formats-select">
|
<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>
|
<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; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Event_Officials
|
* SP_Meta_Box_Event_Officials
|
||||||
@@ -20,7 +22,8 @@ class SP_Meta_Box_Event_Officials {
|
|||||||
* Output the metabox
|
* Output the metabox
|
||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$duties = get_terms( array(
|
$duties = get_terms(
|
||||||
|
array(
|
||||||
'taxonomy' => 'sp_duty',
|
'taxonomy' => 'sp_duty',
|
||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
'orderby' => 'meta_value_num',
|
'orderby' => 'meta_value_num',
|
||||||
@@ -28,14 +31,15 @@ class SP_Meta_Box_Event_Officials {
|
|||||||
'relation' => 'OR',
|
'relation' => 'OR',
|
||||||
array(
|
array(
|
||||||
'key' => 'sp_order',
|
'key' => 'sp_order',
|
||||||
'compare' => 'NOT EXISTS'
|
'compare' => 'NOT EXISTS',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'key' => 'sp_order',
|
'key' => 'sp_order',
|
||||||
'compare' => 'EXISTS'
|
'compare' => 'EXISTS',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$officials = (array) get_post_meta( $post->ID, 'sp_officials', true );
|
$officials = (array) get_post_meta( $post->ID, 'sp_officials', true );
|
||||||
|
|
||||||
@@ -43,7 +47,8 @@ class SP_Meta_Box_Event_Officials {
|
|||||||
foreach ( $duties as $duty ) {
|
foreach ( $duties as $duty ) {
|
||||||
?>
|
?>
|
||||||
<p><strong><?php echo esc_html( $duty->name ); ?></strong></p>
|
<p><strong><?php echo esc_html( $duty->name ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_official',
|
'post_type' => 'sp_official',
|
||||||
'name' => 'sp_officials[' . $duty->term_id . '][]',
|
'name' => 'sp_officials[' . $duty->term_id . '][]',
|
||||||
@@ -58,7 +63,8 @@ class SP_Meta_Box_Event_Officials {
|
|||||||
if ( ! sp_dropdown_pages( $args ) ) {
|
if ( ! sp_dropdown_pages( $args ) ) {
|
||||||
sp_post_adder( 'sp_official', __( 'Add New', 'sportspress' ) );
|
sp_post_adder( 'sp_official', __( 'Add New', 'sportspress' ) );
|
||||||
}
|
}
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Event_Performance
|
* SP_Meta_Box_Event_Performance
|
||||||
@@ -22,29 +24,32 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
$event = new SP_Event( $post );
|
$event = new SP_Event( $post );
|
||||||
list( $labels, $columns, $stats, $teams, $formats, $order, $timed, $stars ) = $event->performance( true );
|
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 );
|
$timeline = $event->timeline( true );
|
||||||
else
|
} else {
|
||||||
$timeline = false;
|
$timeline = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Determine if columns are auto or manual
|
// 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;
|
$manual = true;
|
||||||
else
|
} else {
|
||||||
$manual = false;
|
$manual = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Determine if we need checkboxes
|
// Determine if we need checkboxes
|
||||||
if ( $manual )
|
if ( $manual ) {
|
||||||
$has_checkboxes = true;
|
$has_checkboxes = true;
|
||||||
else
|
} else {
|
||||||
$has_checkboxes = false;
|
$has_checkboxes = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get player number option
|
// Get player number option
|
||||||
$numbers = 'yes' == get_option( 'sportspress_event_show_player_numbers', 'yes' ) ? true : false;
|
$numbers = 'yes' == get_option( 'sportspress_event_show_player_numbers', 'yes' ) ? true : false;
|
||||||
|
|
||||||
// Get positions
|
// Get positions
|
||||||
$positions = array();
|
$positions = array();
|
||||||
if ( 'yes' == get_option( 'sportspress_event_show_position', 'yes' ) && taxonomy_exists( 'sp_position' ) ):
|
if ( 'yes' == get_option( 'sportspress_event_show_position', 'yes' ) && taxonomy_exists( 'sp_position' ) ) :
|
||||||
$args = array(
|
$args = array(
|
||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
'parent' => 0,
|
'parent' => 0,
|
||||||
@@ -95,27 +100,29 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
<?php self::footer( sp_array_value( $stats, -1 ), $labels, 0, $positions, $status, false, $numbers, -1, $formats ); ?>
|
<?php self::footer( sp_array_value( $stats, -1 ), $labels, 0, $positions, $status, false, $numbers, -1, $formats ); ?>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach ( $teams as $key => $team_id ):
|
foreach ( $teams as $key => $team_id ) :
|
||||||
if ( -1 == $team_id ) continue;
|
if ( -1 == $team_id ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Get results for players in the team
|
// Get results for players in the team
|
||||||
$players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
$players = sp_array_between( (array) get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||||
$players[] = -1;
|
$players[] = -1;
|
||||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||||
|
|
||||||
// Get team timeline
|
// Get team timeline
|
||||||
if ( is_array( $timeline ) ):
|
if ( is_array( $timeline ) ) :
|
||||||
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
|
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
|
||||||
else:
|
else :
|
||||||
$team_timeline = false;
|
$team_timeline = false;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
foreach ( $data as $player_id => $player_performance ):
|
foreach ( $data as $player_id => $player_performance ) :
|
||||||
|
|
||||||
// Get player timeline
|
// Get player timeline
|
||||||
if ( is_array( $team_timeline ) ):
|
if ( is_array( $team_timeline ) ) :
|
||||||
$player_timeline = (array) sp_array_value( $team_timeline, $player_id, array() );
|
$player_timeline = (array) sp_array_value( $team_timeline, $player_id, array() );
|
||||||
else:
|
else :
|
||||||
$player_timeline = false;
|
$player_timeline = false;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -130,26 +137,45 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
} else {
|
} else {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
foreach ( $teams as $key => $team_id ):
|
foreach ( $teams as $key => $team_id ) :
|
||||||
if ( -1 == $team_id ) continue;
|
if ( -1 == $team_id ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ( -1 == $sections ) {
|
if ( -1 == $sections ) {
|
||||||
// Get results for players in the team
|
// Get results for players in the team
|
||||||
$players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
$players = sp_array_between( (array) get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||||
$players[] = -1;
|
$players[] = -1;
|
||||||
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||||
|
|
||||||
// Get team timeline
|
// Get team timeline
|
||||||
if ( is_array( $timeline ) ):
|
if ( is_array( $timeline ) ) :
|
||||||
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
|
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
|
||||||
else:
|
else :
|
||||||
$team_timeline = false;
|
$team_timeline = false;
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
<strong><?php echo get_the_title( $team_id ); ?></strong>
|
<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>
|
</p>
|
||||||
<?php self::table( $labels, $columns, $data, $team_id, $has_checkboxes && $i === 0, $positions, $status, -1, $formats, $order, $numbers, $team_timeline, $timed, $stars ); ?>
|
<?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 ); ?>
|
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels, $columns, $data, $team_id ); ?>
|
||||||
@@ -181,12 +207,12 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
$performances = get_posts( $args );
|
$performances = get_posts( $args );
|
||||||
|
|
||||||
$labels = array( array(), array() );
|
$labels = array( array(), array() );
|
||||||
foreach ( $performances as $performance ):
|
foreach ( $performances as $performance ) :
|
||||||
$section = get_post_meta( $performance->ID, 'sp_section', true );
|
$section = get_post_meta( $performance->ID, 'sp_section', true );
|
||||||
if ( '' === $section ) {
|
if ( '' === $section ) {
|
||||||
$section = -1;
|
$section = -1;
|
||||||
}
|
}
|
||||||
switch ( $section ):
|
switch ( $section ) :
|
||||||
case 1:
|
case 1:
|
||||||
$labels[1][ $performance->post_name ] = $performance->post_title;
|
$labels[1][ $performance->post_name ] = $performance->post_title;
|
||||||
break;
|
break;
|
||||||
@@ -195,8 +221,8 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
endswitch;
|
endswitch;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$offense = (array)get_post_meta( $post_id, 'sp_offense', false );
|
$offense = (array) get_post_meta( $post_id, 'sp_offense', false );
|
||||||
$defense = (array)get_post_meta( $post_id, 'sp_defense', false );
|
$defense = (array) get_post_meta( $post_id, 'sp_defense', false );
|
||||||
$data = array();
|
$data = array();
|
||||||
if ( sizeof( $offense ) || sizeof( $defense ) ) {
|
if ( sizeof( $offense ) || sizeof( $defense ) ) {
|
||||||
// Get results for offensive players in the team
|
// Get results for offensive players in the team
|
||||||
@@ -210,21 +236,24 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
$data[1] = sp_array_combine( $defense, sp_array_value( $stats, $team_id, array() ) );
|
$data[1] = sp_array_combine( $defense, sp_array_value( $stats, $team_id, array() ) );
|
||||||
} else {
|
} else {
|
||||||
// Get results for all players in the team
|
// Get results for all players in the team
|
||||||
$players = sp_array_between( (array)get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
$players = sp_array_between( (array) get_post_meta( $post_id, 'sp_player', false ), 0, $key );
|
||||||
$players[] = -1;
|
$players[] = -1;
|
||||||
$data[0] = $data[1] = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
$data[0] = $data[1] = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get team timeline
|
// Get team timeline
|
||||||
if ( is_array( $timeline ) ):
|
if ( is_array( $timeline ) ) :
|
||||||
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
|
$team_timeline = (array) sp_array_value( $timeline, $team_id, array() );
|
||||||
else:
|
else :
|
||||||
$team_timeline = false;
|
$team_timeline = false;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Determine order of sections
|
// Determine order of sections
|
||||||
if ( 1 == $sections ) {
|
if ( 1 == $sections ) {
|
||||||
$section_order = array( 1 => __( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
|
$section_order = array(
|
||||||
|
1 => __( 'Defense', 'sportspress' ),
|
||||||
|
0 => __( 'Offense', 'sportspress' ),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
||||||
}
|
}
|
||||||
@@ -234,7 +263,22 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
<strong><?php echo get_the_title( $team_id ); ?> — <?php echo esc_html( $section_label ); ?></strong>
|
<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>
|
</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 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 ); ?>
|
<?php do_action( 'sportspress_after_event_performance_table_admin', $labels[ $section_id ], $columns, $data[ $section_id ], $team_id ); ?>
|
||||||
@@ -263,7 +307,7 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
$player_order = sp_array_value( $order, $team_id, array() );
|
$player_order = sp_array_value( $order, $team_id, array() );
|
||||||
if ( is_array( $player_order ) && sizeof( $player_order ) ) {
|
if ( is_array( $player_order ) && sizeof( $player_order ) ) {
|
||||||
foreach ( $player_order as $key ) {
|
foreach ( $player_order as $key ) {
|
||||||
if ( array_key_exists( $key, $data ) ):
|
if ( array_key_exists( $key, $data ) ) :
|
||||||
$players[ $key ] = $data[ $key ];
|
$players[ $key ] = $data[ $key ];
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
@@ -276,12 +320,12 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
$data = $players;
|
$data = $players;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $data as $player_id => $player_performance ):
|
foreach ( $data as $player_id => $player_performance ) :
|
||||||
|
|
||||||
// Get player timeline
|
// Get player timeline
|
||||||
if ( is_array( $team_timeline ) ):
|
if ( is_array( $team_timeline ) ) :
|
||||||
$player_timeline = (array) sp_array_value( $team_timeline, $player_id, array() );
|
$player_timeline = (array) sp_array_value( $team_timeline, $player_id, array() );
|
||||||
else:
|
else :
|
||||||
$player_timeline = false;
|
$player_timeline = false;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -315,22 +359,28 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
<?php _e( 'Position', 'sportspress' ); ?>
|
<?php _e( 'Position', 'sportspress' ); ?>
|
||||||
</th>
|
</th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php $i = 0; foreach ( $labels as $key => $label ): ?>
|
<?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>
|
<th>
|
||||||
<?php if ( $has_checkboxes ): ?>
|
<?php if ( $has_checkboxes ) : ?>
|
||||||
<?php if ( 0 == $i ): ?>
|
<?php if ( 0 == $i ) : ?>
|
||||||
<input type="hidden" name="sp_columns[]" value="">
|
<input type="hidden" name="sp_columns[]" value="">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<label for="sp_columns_<?php echo esc_attr( $key ); ?>">
|
<label for="sp_columns_<?php echo esc_attr( $key ); ?>">
|
||||||
<input type="checkbox" name="sp_columns[]" value="<?php echo esc_attr( $key ); ?>" id="sp_columns_<?php echo esc_attr( $key ); ?>" <?php checked( ! is_array( $columns ) || in_array( $key, $columns ) ); ?>>
|
<input type="checkbox" name="sp_columns[]" value="<?php echo esc_attr( $key ); ?>" id="sp_columns_<?php echo esc_attr( $key ); ?>" <?php checked( ! is_array( $columns ) || in_array( $key, $columns ) ); ?>>
|
||||||
<?php echo esc_html( $label ); ?>
|
<?php echo esc_html( $label ); ?>
|
||||||
</label>
|
</label>
|
||||||
<?php else: ?>
|
<?php else : ?>
|
||||||
<?php echo esc_html( $label ); ?>
|
<?php echo esc_html( $label ); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</th>
|
</th>
|
||||||
<?php $i++; endforeach; ?>
|
<?php
|
||||||
|
$i++;
|
||||||
|
endforeach;
|
||||||
|
?>
|
||||||
<?php if ( apply_filters( 'sportspress_event_performance_show_status', $status, $section ) ) { ?>
|
<?php if ( apply_filters( 'sportspress_event_performance_show_status', $status, $section ) ) { ?>
|
||||||
<th>
|
<th>
|
||||||
<?php _e( 'Status', 'sportspress' ); ?>
|
<?php _e( 'Status', 'sportspress' ); ?>
|
||||||
@@ -363,8 +413,11 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
<?php if ( ! empty( $positions ) ) { ?>
|
<?php if ( ! empty( $positions ) ) { ?>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php foreach( $labels as $column => $label ):
|
<?php
|
||||||
if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) continue;
|
foreach ( $labels as $column => $label ) :
|
||||||
|
if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$player_id = 0;
|
$player_id = 0;
|
||||||
$player_performance = sp_array_value( $data, $player_id, array() );
|
$player_performance = sp_array_value( $data, $player_id, array() );
|
||||||
$value = sp_array_value( $player_performance, $column, '' );
|
$value = sp_array_value( $player_performance, $column, '' );
|
||||||
@@ -389,7 +442,9 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
* Admin edit table row
|
* 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() ) {
|
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 );
|
$stars_type = get_option( 'sportspress_event_performance_stars_type', 0 );
|
||||||
$value = sp_array_value( $player_performance, 'number', '' );
|
$value = sp_array_value( $player_performance, 'number', '' );
|
||||||
@@ -413,7 +468,7 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
$selected = (array) sp_array_value( $player_performance, 'position', null );
|
$selected = (array) sp_array_value( $player_performance, 'position', null );
|
||||||
if ( $selected == null ):
|
if ( $selected == null ) :
|
||||||
$selected = (array) sp_get_the_term_id( $player_id, 'sp_position', 0 );
|
$selected = (array) sp_get_the_term_id( $player_id, 'sp_position', 0 );
|
||||||
endif;
|
endif;
|
||||||
$args = array(
|
$args = array(
|
||||||
@@ -425,11 +480,11 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
'relation' => 'OR',
|
'relation' => 'OR',
|
||||||
array(
|
array(
|
||||||
'key' => 'sp_order',
|
'key' => 'sp_order',
|
||||||
'compare' => 'NOT EXISTS'
|
'compare' => 'NOT EXISTS',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'key' => 'sp_order',
|
'key' => 'sp_order',
|
||||||
'compare' => 'EXISTS'
|
'compare' => 'EXISTS',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'selected' => $selected,
|
'selected' => $selected,
|
||||||
@@ -442,8 +497,11 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php foreach( $labels as $column => $label ):
|
<?php
|
||||||
if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) continue;
|
foreach ( $labels as $column => $label ) :
|
||||||
|
if ( 'equation' === sp_array_value( $formats, $column, 'number' ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$value = sp_array_value( $player_performance, $column, '' );
|
$value = sp_array_value( $player_performance, $column, '' );
|
||||||
$intval = intval( $value );
|
$intval = intval( $value );
|
||||||
$placeholder = sp_get_format_placeholder( sp_array_value( $formats, $column, 'number' ) );
|
$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 );
|
$timeval = gmdate( 'i:s', $intval );
|
||||||
$hours = floor( $intval / 3600 );
|
$hours = floor( $intval / 3600 );
|
||||||
|
|
||||||
if ( '00' != $hours )
|
if ( '00' != $hours ) {
|
||||||
$timeval = $hours . ':' . $timeval;
|
$timeval = $hours . ':' . $timeval;
|
||||||
|
}
|
||||||
|
|
||||||
$timeval = preg_replace( '/^0/', '', $timeval );
|
$timeval = preg_replace( '/^0/', '', $timeval );
|
||||||
?>
|
?>
|
||||||
@@ -483,7 +542,10 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
if ( is_array( $times ) ) {
|
if ( is_array( $times ) ) {
|
||||||
?>
|
?>
|
||||||
<hr>
|
<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>
|
<span class="description"><?php _e( 'mins', 'sportspress' ); ?></span>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -531,17 +593,21 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
*/
|
*/
|
||||||
public static function status_select( $team_id, $player_id, $value = null ) {
|
public static function status_select( $team_id, $player_id, $value = null ) {
|
||||||
|
|
||||||
if ( ! $team_id || ! $player_id )
|
if ( ! $team_id || ! $player_id ) {
|
||||||
return '—';
|
return '—';
|
||||||
|
}
|
||||||
|
|
||||||
$options = apply_filters( 'sportspress_event_performance_status_options', array(
|
$options = apply_filters(
|
||||||
|
'sportspress_event_performance_status_options',
|
||||||
|
array(
|
||||||
'lineup' => __( 'Starting Lineup', 'sportspress' ),
|
'lineup' => __( 'Starting Lineup', 'sportspress' ),
|
||||||
'sub' => __( 'Substitute', 'sportspress' ),
|
'sub' => __( 'Substitute', 'sportspress' ),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$output = '<select class="sp-sync-select" name="sp_players[' . $team_id . '][' . $player_id . '][status]">';
|
$output = '<select class="sp-sync-select" name="sp_players[' . $team_id . '][' . $player_id . '][status]">';
|
||||||
|
|
||||||
foreach( $options as $key => $name ):
|
foreach ( $options as $key => $name ) :
|
||||||
$output .= '<option value="' . $key . '"' . ( $key == $value ? ' selected' : '' ) . '>' . $name . '</option>';
|
$output .= '<option value="' . $key . '"' . ( $key == $value ? ' selected' : '' ) . '>' . $name . '</option>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
@@ -556,16 +622,19 @@ class SP_Meta_Box_Event_Performance {
|
|||||||
*/
|
*/
|
||||||
public static function sub_select( $team_id, $player_id, $value, $data = array() ) {
|
public static function sub_select( $team_id, $player_id, $value, $data = array() ) {
|
||||||
|
|
||||||
if ( ! $team_id || ! $player_id )
|
if ( ! $team_id || ! $player_id ) {
|
||||||
return '—';
|
return '—';
|
||||||
|
}
|
||||||
|
|
||||||
$output = '<select class="sp-sync-select" name="sp_players[' . $team_id . '][' . $player_id . '][sub]" style="display: none;">';
|
$output = '<select class="sp-sync-select" name="sp_players[' . $team_id . '][' . $player_id . '][sub]" style="display: none;">';
|
||||||
|
|
||||||
$output .= '<option value="0">' . __( 'None', 'sportspress' ) . '</option>';
|
$output .= '<option value="0">' . __( 'None', 'sportspress' ) . '</option>';
|
||||||
|
|
||||||
// Add players as selectable options
|
// Add players as selectable options
|
||||||
foreach( $data as $id => $performance ):
|
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 );
|
$number = get_post_meta( $id, 'sp_number', true );
|
||||||
$output .= '<option value="' . $id . '"' . ( $id == $value ? ' selected' : '' ) . '>' . ( $number ? $number . '. ' : '' ) . get_the_title( $id ) . '</option>';
|
$output .= '<option value="' . $id . '"' . ( $id == $value ? ' selected' : '' ) . '>' . ( $number ? $number . '. ' : '' ) . get_the_title( $id ) . '</option>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Event_Results
|
* SP_Meta_Box_Event_Results
|
||||||
@@ -20,10 +22,11 @@ class SP_Meta_Box_Event_Results {
|
|||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
// Determine if we need checkboxes
|
// 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;
|
$has_checkboxes = true;
|
||||||
else
|
} else {
|
||||||
$has_checkboxes = false;
|
$has_checkboxes = false;
|
||||||
|
}
|
||||||
|
|
||||||
$event = new SP_Event( $post );
|
$event = new SP_Event( $post );
|
||||||
list( $columns, $usecolumns, $data ) = $event->results( true );
|
list( $columns, $usecolumns, $data ) = $event->results( true );
|
||||||
@@ -34,7 +37,7 @@ class SP_Meta_Box_Event_Results {
|
|||||||
* Save meta box data
|
* Save meta box data
|
||||||
*/
|
*/
|
||||||
public static function save( $post_id, $post ) {
|
public static function save( $post_id, $post ) {
|
||||||
$results = (array)sp_array_value( $_POST, 'sp_results', array(), 'text' );
|
$results = (array) sp_array_value( $_POST, 'sp_results', array(), 'text' );
|
||||||
$main_result = get_option( 'sportspress_primary_result', null );
|
$main_result = get_option( 'sportspress_primary_result', null );
|
||||||
|
|
||||||
// Get player performance
|
// Get player performance
|
||||||
@@ -57,15 +60,25 @@ class SP_Meta_Box_Event_Results {
|
|||||||
if ( ! $finished ) {
|
if ( ! $finished ) {
|
||||||
foreach ( $performance as $team => $players ) {
|
foreach ( $performance as $team => $players ) {
|
||||||
foreach ( $players as $player => $pp ) {
|
foreach ( $players as $player => $pp ) {
|
||||||
if ( 0 >= $player ) continue;
|
if ( 0 >= $player ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
foreach ( $pp as $pk => $pv ) {
|
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 );
|
$pv = trim( $pv );
|
||||||
if ( '' == $pv ) continue;
|
if ( '' == $pv ) {
|
||||||
if ( ! ctype_digit( $pv ) ) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ( ! ctype_digit( $pv ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$finished = true;
|
$finished = true;
|
||||||
break;
|
break;
|
||||||
@@ -96,10 +109,11 @@ class SP_Meta_Box_Event_Results {
|
|||||||
$precision[ $result->post_name ] = (int) get_post_meta( $result->ID, 'sp_precision', true );
|
$precision[ $result->post_name ] = (int) get_post_meta( $result->ID, 'sp_precision', true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Apply equations to empty results
|
// Apply equations to empty results
|
||||||
foreach ( $equations as $key => $equation ) {
|
foreach ( $equations as $key => $equation ) {
|
||||||
if ( '' == $equation ) continue;
|
if ( '' == $equation ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
foreach ( $results as $team => $team_results ) {
|
foreach ( $results as $team => $team_results ) {
|
||||||
if ( '' === sp_array_value( $team_results, $key, '' ) ) {
|
if ( '' === sp_array_value( $team_results, $key, '' ) ) {
|
||||||
$totals = array();
|
$totals = array();
|
||||||
@@ -111,7 +125,7 @@ class SP_Meta_Box_Event_Results {
|
|||||||
$totals[ $pk ] = $value;
|
$totals[ $pk ] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$totals[ 'eventsplayed' ] = 1;
|
$totals['eventsplayed'] = 1;
|
||||||
$totals = apply_filters( 'sportspress_event_result_equation_vars', $totals, $performance, $team );
|
$totals = apply_filters( 'sportspress_event_result_equation_vars', $totals, $performance, $team );
|
||||||
$results[ $team ][ $key ] = sp_solve( $equation, $totals, sp_array_value( $precision, $key, 0 ), '' );
|
$results[ $team ][ $key ] = sp_solve( $equation, $totals, sp_array_value( $precision, $key, 0 ), '' );
|
||||||
}
|
}
|
||||||
@@ -147,11 +161,13 @@ class SP_Meta_Box_Event_Results {
|
|||||||
);
|
);
|
||||||
$outcomes = get_posts( $args );
|
$outcomes = get_posts( $args );
|
||||||
foreach ( $results as $team => $team_results ) {
|
foreach ( $results as $team => $team_results ) {
|
||||||
if ( array_key_exists( 'outcome', $team_results ) ) continue;
|
if ( array_key_exists( 'outcome', $team_results ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ( $outcomes ) {
|
if ( $outcomes ) {
|
||||||
$results[ $team ][ 'outcome' ] = array();
|
$results[ $team ]['outcome'] = array();
|
||||||
foreach ( $outcomes as $outcome ) {
|
foreach ( $outcomes as $outcome ) {
|
||||||
$results[ $team ][ 'outcome' ][] = $outcome->post_name;
|
$results[ $team ]['outcome'][] = $outcome->post_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +191,9 @@ class SP_Meta_Box_Event_Results {
|
|||||||
'meta_value' => '>',
|
'meta_value' => '>',
|
||||||
);
|
);
|
||||||
$gt_outcomes = get_posts( $args );
|
$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
|
// Get less than outcomes
|
||||||
$args = array(
|
$args = array(
|
||||||
@@ -186,7 +204,9 @@ class SP_Meta_Box_Event_Results {
|
|||||||
'meta_value' => '<',
|
'meta_value' => '<',
|
||||||
);
|
);
|
||||||
$lt_outcomes = get_posts( $args );
|
$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
|
// Get min and max values
|
||||||
$min = min( $primary_results );
|
$min = min( $primary_results );
|
||||||
@@ -201,9 +221,9 @@ class SP_Meta_Box_Event_Results {
|
|||||||
} else {
|
} else {
|
||||||
$outcomes = $default_outcomes;
|
$outcomes = $default_outcomes;
|
||||||
}
|
}
|
||||||
$results[ $key ][ 'outcome' ] = array();
|
$results[ $key ]['outcome'] = array();
|
||||||
foreach ( $outcomes as $outcome ) {
|
foreach ( $outcomes as $outcome ) {
|
||||||
$results[ $key ][ 'outcome' ][] = $outcome->post_name;
|
$results[ $key ]['outcome'][] = $outcome->post_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,7 +248,7 @@ class SP_Meta_Box_Event_Results {
|
|||||||
array(
|
array(
|
||||||
'key' => 'sp_equation',
|
'key' => 'sp_equation',
|
||||||
'compare' => 'NOT IN',
|
'compare' => 'NOT IN',
|
||||||
'value' => null
|
'value' => null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -242,14 +262,14 @@ class SP_Meta_Box_Event_Results {
|
|||||||
<th class="column-team">
|
<th class="column-team">
|
||||||
<?php _e( 'Team', 'sportspress' ); ?>
|
<?php _e( 'Team', 'sportspress' ); ?>
|
||||||
</th>
|
</th>
|
||||||
<?php foreach ( $columns as $key => $label ): ?>
|
<?php foreach ( $columns as $key => $label ) : ?>
|
||||||
<th class="column-<?php echo esc_attr( $key ); ?>">
|
<th class="column-<?php echo esc_attr( $key ); ?>">
|
||||||
<?php if ( $has_checkboxes ): ?>
|
<?php if ( $has_checkboxes ) : ?>
|
||||||
<label for="sp_result_columns_<?php echo esc_attr( $key ); ?>">
|
<label for="sp_result_columns_<?php echo esc_attr( $key ); ?>">
|
||||||
<input type="checkbox" name="sp_result_columns[]" value="<?php echo esc_attr( $key ); ?>" id="sp_result_columns_<?php echo esc_attr( $key ); ?>" <?php checked( ! is_array( $usecolumns ) || in_array( $key, $usecolumns ) ); ?>>
|
<input type="checkbox" name="sp_result_columns[]" value="<?php echo esc_attr( $key ); ?>" id="sp_result_columns_<?php echo esc_attr( $key ); ?>" <?php checked( ! is_array( $usecolumns ) || in_array( $key, $usecolumns ) ); ?>>
|
||||||
<?php echo esc_html( $label ); ?>
|
<?php echo esc_html( $label ); ?>
|
||||||
</label>
|
</label>
|
||||||
<?php else: ?>
|
<?php else : ?>
|
||||||
<?php echo esc_html( $label ); ?>
|
<?php echo esc_html( $label ); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</th>
|
</th>
|
||||||
@@ -262,23 +282,36 @@ class SP_Meta_Box_Event_Results {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $data as $team_id => $team_results ):
|
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>
|
<td>
|
||||||
<?php echo get_the_title( $team_id ); ?>
|
<?php echo get_the_title( $team_id ); ?>
|
||||||
</td>
|
</td>
|
||||||
<?php foreach( $columns as $column => $label ):
|
<?php
|
||||||
|
foreach ( $columns as $column => $label ) :
|
||||||
$value = sp_array_value( $team_results, $column, '' );
|
$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; ?>
|
<?php endforeach; ?>
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
$values = sp_array_value( $team_results, 'outcome', '' );
|
$values = sp_array_value( $team_results, 'outcome', '' );
|
||||||
if ( ! is_array( $values ) )
|
if ( ! is_array( $values ) ) {
|
||||||
$values = array( $values );
|
$values = array( $values );
|
||||||
|
}
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_outcome',
|
'post_type' => 'sp_outcome',
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Event_Shortcode
|
* SP_Meta_Box_Event_Shortcode
|
||||||
@@ -19,7 +21,9 @@ class SP_Meta_Box_Event_Shortcode {
|
|||||||
* Output the metabox
|
* Output the metabox
|
||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$shortcodes = apply_filters( 'sportspress_event_shortcodes', array(
|
$shortcodes = apply_filters(
|
||||||
|
'sportspress_event_shortcodes',
|
||||||
|
array(
|
||||||
'event_results' => __( 'Results', 'sportspress' ),
|
'event_results' => __( 'Results', 'sportspress' ),
|
||||||
'event_details' => __( 'Details', 'sportspress' ),
|
'event_details' => __( 'Details', 'sportspress' ),
|
||||||
'event_performance' => __( 'Box Score', 'sportspress' ),
|
'event_performance' => __( 'Box Score', 'sportspress' ),
|
||||||
@@ -27,7 +31,8 @@ class SP_Meta_Box_Event_Shortcode {
|
|||||||
'event_officials' => __( 'Officials', 'sportspress' ),
|
'event_officials' => __( 'Officials', 'sportspress' ),
|
||||||
'event_teams' => __( 'Teams', 'sportspress' ),
|
'event_teams' => __( 'Teams', 'sportspress' ),
|
||||||
'event_full' => __( 'Full Info', 'sportspress' ),
|
'event_full' => __( 'Full Info', 'sportspress' ),
|
||||||
) );
|
)
|
||||||
|
);
|
||||||
if ( $shortcodes ) {
|
if ( $shortcodes ) {
|
||||||
?>
|
?>
|
||||||
<p class="howto">
|
<p class="howto">
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Event_Specs
|
* SP_Meta_Box_Event_Specs
|
||||||
@@ -32,14 +34,14 @@ class SP_Meta_Box_Event_Specs {
|
|||||||
|
|
||||||
$vars = get_posts( $args );
|
$vars = get_posts( $args );
|
||||||
|
|
||||||
if ( $vars ):
|
if ( $vars ) :
|
||||||
foreach ( $vars as $var ):
|
foreach ( $vars as $var ) :
|
||||||
?>
|
?>
|
||||||
<p><strong><?php echo esc_html( $var->post_title ); ?></strong></p>
|
<p><strong><?php echo esc_html( $var->post_title ); ?></strong></p>
|
||||||
<p><input type="text" name="sp_specs[<?php echo esc_attr( $var->post_name ); ?>]" value="<?php echo esc_attr( sp_array_value( $metrics, $var->post_name, '' ) ); ?>" /></p>
|
<p><input type="text" name="sp_specs[<?php echo esc_attr( $var->post_name ); ?>]" value="<?php echo esc_attr( sp_array_value( $metrics, $var->post_name, '' ) ); ?>" /></p>
|
||||||
<?php
|
<?php
|
||||||
endforeach;
|
endforeach;
|
||||||
else:
|
else :
|
||||||
sp_post_adder( 'sp_spec', __( 'Add New', 'sportspress' ) );
|
sp_post_adder( 'sp_spec', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Event_Teams
|
* SP_Meta_Box_Event_Teams
|
||||||
@@ -23,7 +25,7 @@ class SP_Meta_Box_Event_Teams {
|
|||||||
$teams = (array) get_post_meta( $post->ID, 'sp_team', false );
|
$teams = (array) get_post_meta( $post->ID, 'sp_team', false );
|
||||||
$post_type = sp_get_post_mode_type( $post->ID );
|
$post_type = sp_get_post_mode_type( $post->ID );
|
||||||
if ( $limit && 'sp_player' !== $post_type ) {
|
if ( $limit && 'sp_player' !== $post_type ) {
|
||||||
for ( $i = 0; $i < $limit; $i ++ ):
|
for ( $i = 0; $i < $limit; $i ++ ) :
|
||||||
$team = array_shift( $teams );
|
$team = array_shift( $teams );
|
||||||
?>
|
?>
|
||||||
<div class="sp-instance">
|
<div class="sp-instance">
|
||||||
@@ -101,7 +103,11 @@ class SP_Meta_Box_Event_Teams {
|
|||||||
$j = 0;
|
$j = 0;
|
||||||
foreach ( $tabs as $slug => $tab ) {
|
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
|
<?php
|
||||||
$j++;
|
$j++;
|
||||||
}
|
}
|
||||||
@@ -132,7 +138,7 @@ class SP_Meta_Box_Event_Teams {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
'placeholder' => __( 'None', 'sportspress' ),
|
'placeholder' => __( 'None', 'sportspress' ),
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_pages( $args ) ):
|
if ( ! sp_dropdown_pages( $args ) ) :
|
||||||
sp_post_adder( $post_type, __( 'Add New', 'sportspress' ) );
|
sp_post_adder( $post_type, __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Event_Video
|
* SP_Meta_Box_Event_Video
|
||||||
@@ -20,7 +22,7 @@ class SP_Meta_Box_Event_Video {
|
|||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$video = get_post_meta( $post->ID, 'sp_video', true );
|
$video = get_post_meta( $post->ID, 'sp_video', true );
|
||||||
if ( $video ):
|
if ( $video ) :
|
||||||
?>
|
?>
|
||||||
<fieldset class="sp-video-embed">
|
<fieldset class="sp-video-embed">
|
||||||
<?php echo apply_filters( 'the_content', '[embed width="254"]' . $video . '[/embed]' ); ?>
|
<?php echo apply_filters( 'the_content', '[embed width="254"]' . $video . '[/embed]' ); ?>
|
||||||
@@ -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><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>
|
<p><a href="#" class="sp-remove-video"><?php _e( 'Cancel', 'sportspress' ); ?></a></p>
|
||||||
</fieldset>
|
</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>
|
<p><a href="#" class="sp-add-video"><?php _e( 'Add video', 'sportspress' ); ?></a></p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_List_Columns
|
* SP_Meta_Box_List_Columns
|
||||||
@@ -19,7 +21,7 @@ class SP_Meta_Box_List_Columns {
|
|||||||
* Output the metabox
|
* Output the metabox
|
||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$selected = (array)get_post_meta( $post->ID, 'sp_columns', true );
|
$selected = (array) get_post_meta( $post->ID, 'sp_columns', true );
|
||||||
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
|
||||||
?>
|
?>
|
||||||
<p><strong><?php _e( 'General', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'General', 'sportspress' ); ?></strong></p>
|
||||||
@@ -34,6 +36,7 @@ class SP_Meta_Box_List_Columns {
|
|||||||
_e( 'Rank', 'sportspress' );
|
_e( 'Rank', 'sportspress' );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_List_Data
|
* SP_Meta_Box_List_Data
|
||||||
@@ -21,8 +23,8 @@ class SP_Meta_Box_List_Data {
|
|||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
global $pagenow;
|
global $pagenow;
|
||||||
if ( is_admin() && in_array( $pagenow, array( 'post-new.php' ) ) && 'sp_list' == get_post_type() ) {
|
if ( is_admin() && in_array( $pagenow, array( 'post-new.php' ) ) && 'sp_list' == get_post_type() ) {
|
||||||
self::table( );
|
self::table();
|
||||||
}else{
|
} else {
|
||||||
$list = new SP_Player_List( $post );
|
$list = new SP_Player_List( $post );
|
||||||
list( $columns, $data, $placeholders, $merged, $orderby ) = $list->data( true );
|
list( $columns, $data, $placeholders, $merged, $orderby ) = $list->data( true );
|
||||||
$adjustments = $list->adjustments;
|
$adjustments = $list->adjustments;
|
||||||
@@ -62,8 +64,11 @@ class SP_Meta_Box_List_Data {
|
|||||||
<?php if ( array_key_exists( 'position', $columns ) ) { ?>
|
<?php if ( array_key_exists( 'position', $columns ) ) { ?>
|
||||||
<th><?php _e( 'Position', 'sportspress' ); ?></th>
|
<th><?php _e( 'Position', 'sportspress' ); ?></th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php foreach ( $columns as $key => $label ): ?>
|
<?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 ); ?>">
|
<th><label for="sp_columns_<?php echo esc_attr( $key ); ?>">
|
||||||
<?php echo esc_html( $label ); ?>
|
<?php echo esc_html( $label ); ?>
|
||||||
</label></th>
|
</label></th>
|
||||||
@@ -72,19 +77,27 @@ class SP_Meta_Box_List_Data {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
if ( is_array( $data ) && sizeof( $data ) > 0 ):
|
if ( is_array( $data ) && sizeof( $data ) > 0 ) :
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $data as $player_id => $player_stats ):
|
foreach ( $data as $player_id => $player_stats ) :
|
||||||
if ( !$player_id ) continue;
|
if ( ! $player_id ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$teams = get_post_meta( $player_id, 'sp_team', false );
|
$teams = get_post_meta( $player_id, 'sp_team', false );
|
||||||
$div = get_term( $player_id, 'sp_season' );
|
$div = get_term( $player_id, 'sp_season' );
|
||||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||||
|
|
||||||
$default_name = sp_array_value( $player_stats, 'name', '' );
|
$default_name = sp_array_value( $player_stats, 'name', '' );
|
||||||
if ( $default_name == null )
|
if ( $default_name == null ) {
|
||||||
$default_name = get_the_title( $player_id );
|
$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 ) ) { ?>
|
<?php if ( array_key_exists( 'number', $columns ) ) { ?>
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
@@ -97,7 +110,10 @@ class SP_Meta_Box_List_Data {
|
|||||||
</td>
|
</td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<td>
|
<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">
|
||||||
<span class="sp-default-value-input"><?php echo esc_html( $default_name ); ?></span>
|
<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>
|
<a class="dashicons dashicons-edit sp-edit" title="<?php _e( 'Edit', 'sportspress' ); ?>"></a>
|
||||||
@@ -112,7 +128,9 @@ class SP_Meta_Box_List_Data {
|
|||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
$selected = sp_array_value( $player_stats, 'team', get_post_meta( get_the_ID(), 'sp_team', true ) );
|
$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' );
|
$include = get_post_meta( $player_id, 'sp_team' );
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
@@ -139,11 +157,11 @@ class SP_Meta_Box_List_Data {
|
|||||||
'relation' => 'OR',
|
'relation' => 'OR',
|
||||||
array(
|
array(
|
||||||
'key' => 'sp_order',
|
'key' => 'sp_order',
|
||||||
'compare' => 'NOT EXISTS'
|
'compare' => 'NOT EXISTS',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'key' => 'sp_order',
|
'key' => 'sp_order',
|
||||||
'compare' => 'EXISTS'
|
'compare' => 'EXISTS',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'selected' => $selected,
|
'selected' => $selected,
|
||||||
@@ -153,8 +171,11 @@ class SP_Meta_Box_List_Data {
|
|||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php foreach( $columns as $column => $label ):
|
<?php
|
||||||
if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) continue;
|
foreach ( $columns as $column => $label ) :
|
||||||
|
if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$value = sp_array_value( $player_stats, $column, '' );
|
$value = sp_array_value( $player_stats, $column, '' );
|
||||||
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
|
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
|
||||||
?>
|
?>
|
||||||
@@ -164,10 +185,15 @@ class SP_Meta_Box_List_Data {
|
|||||||
<?php
|
<?php
|
||||||
$i++;
|
$i++;
|
||||||
endforeach;
|
endforeach;
|
||||||
else:
|
else :
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row alternate">
|
<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' ) ); ?>
|
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Data', 'sportspress' ) ); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -183,27 +209,41 @@ class SP_Meta_Box_List_Data {
|
|||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th><?php _e( 'Player', 'sportspress' ); ?></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>
|
<th><?php echo esc_html( $label ); ?></th>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
if ( is_array( $data ) && sizeof( $data ) > 0 ):
|
if ( is_array( $data ) && sizeof( $data ) > 0 ) :
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $data as $player_id => $player_stats ):
|
foreach ( $data as $player_id => $player_stats ) :
|
||||||
if ( !$player_id ) continue;
|
if ( ! $player_id ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$div = get_term( $player_id, 'sp_season' );
|
$div = get_term( $player_id, 'sp_season' );
|
||||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
$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 ( $number ? $number : ' ' ); ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?php echo get_the_title( $player_id ); ?>
|
<?php echo get_the_title( $player_id ); ?>
|
||||||
</td>
|
</td>
|
||||||
<?php foreach( $columns as $column => $label ):
|
<?php
|
||||||
if ( in_array( $column, array( 'number', 'team', 'position' ) ) ) continue;
|
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, '' );
|
$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>
|
<td><input type="text" name="sp_adjustments[<?php echo esc_attr( $player_id ); ?>][<?php echo esc_attr( $column ); ?>]" value="<?php echo esc_attr( $value ); ?>" placeholder="0" data-matrix="<?php echo esc_attr( $player_id ); ?>_<?php echo esc_attr( $column ); ?>" /></td>
|
||||||
@@ -212,10 +252,15 @@ class SP_Meta_Box_List_Data {
|
|||||||
<?php
|
<?php
|
||||||
$i++;
|
$i++;
|
||||||
endforeach;
|
endforeach;
|
||||||
else:
|
else :
|
||||||
?>
|
?>
|
||||||
<tr class="sp-row alternate">
|
<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' ) ); ?>
|
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Details', 'sportspress' ) ); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_List_Details
|
* SP_Meta_Box_List_Details
|
||||||
@@ -36,7 +38,7 @@ class SP_Meta_Box_List_Details {
|
|||||||
$date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
|
$date_relative = get_post_meta( $post->ID, 'sp_date_relative', true );
|
||||||
$continents = SP()->countries->continents;
|
$continents = SP()->countries->continents;
|
||||||
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
|
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
|
||||||
$default_nationality = get_option( 'sportspress_default_nationality' , false );
|
$default_nationality = get_option( 'sportspress_default_nationality', false );
|
||||||
?>
|
?>
|
||||||
<div>
|
<div>
|
||||||
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Heading', 'sportspress' ); ?></strong></p>
|
||||||
@@ -91,7 +93,7 @@ class SP_Meta_Box_List_Details {
|
|||||||
'selected' => $team_id,
|
'selected' => $team_id,
|
||||||
'values' => 'ID',
|
'values' => 'ID',
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_pages( $args ) ):
|
if ( ! sp_dropdown_pages( $args ) ) :
|
||||||
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
@@ -103,12 +105,16 @@ class SP_Meta_Box_List_Details {
|
|||||||
</p>
|
</p>
|
||||||
<p><strong><?php _e( 'Nationality', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Nationality', 'sportspress' ); ?></strong></p>
|
||||||
<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>
|
<option value=""></option>
|
||||||
<?php foreach ( $continents as $continent => $countries ): ?>
|
<?php foreach ( $continents as $continent => $countries ) : ?>
|
||||||
<optgroup label="<?php echo esc_attr( $continent ); ?>">
|
<optgroup label="<?php echo esc_attr( $continent ); ?>">
|
||||||
<?php foreach ( $countries as $code => $country ): ?>
|
<?php foreach ( $countries as $code => $country ) : ?>
|
||||||
<option value="<?php echo esc_attr( $code ); ?>" <?php selected ( in_array( $code, $nationalities ) ); ?>><?php echo esc_html( $country ); ?></option>
|
<option value="<?php echo esc_attr( $code ); ?>" <?php selected( in_array( $code, $nationalities ) ); ?>><?php echo esc_html( $country ); ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@@ -161,10 +167,10 @@ class SP_Meta_Box_List_Details {
|
|||||||
if ( 'manual' == $select ) {
|
if ( 'manual' == $select ) {
|
||||||
$player_filters = array( 'sp_league', 'sp_season' );
|
$player_filters = array( 'sp_league', 'sp_season' );
|
||||||
if ( $team_id ) {
|
if ( $team_id ) {
|
||||||
if ( in_array( $era, [ 'all', 'past' ] ) ) {
|
if ( in_array( $era, array( 'all', 'past' ) ) ) {
|
||||||
$player_filters[] = 'sp_past_team';
|
$player_filters[] = 'sp_past_team';
|
||||||
}
|
}
|
||||||
if ( in_array( $era, [ 'all', 'current' ] ) ) {
|
if ( in_array( $era, array( 'all', 'current' ) ) ) {
|
||||||
$player_filters[] = 'sp_current_team';
|
$player_filters[] = 'sp_current_team';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_List_Format
|
* SP_Meta_Box_List_Format
|
||||||
@@ -23,7 +25,7 @@ class SP_Meta_Box_List_Format {
|
|||||||
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
||||||
?>
|
?>
|
||||||
<div id="post-formats-select">
|
<div id="post-formats-select">
|
||||||
<?php foreach ( SP()->formats->list as $key => $format ): ?>
|
<?php foreach ( SP()->formats->list as $key => $format ) : ?>
|
||||||
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( true, ( $key == 'list' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $format ); ?></label><br>
|
<input type="radio" name="sp_format" class="post-format" id="post-format-<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( true, ( $key == 'list' && ! $the_format ) || $the_format == $key ); ?>> <label for="post-format-<?php echo esc_attr( $key ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $format ); ?></label><br>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 1.6.1
|
* @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
|
* SP_Meta_Box_List_Shortcode
|
||||||
@@ -20,7 +22,9 @@ class SP_Meta_Box_List_Shortcode {
|
|||||||
*/
|
*/
|
||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$the_format = get_post_meta( $post->ID, 'sp_format', true );
|
$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">
|
<p class="howto">
|
||||||
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
|
<?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
|
* @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' ) )
|
if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
|
||||||
include( 'class-sp-meta-box-config.php' );
|
require 'class-sp-meta-box-config.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Metric_Details
|
* 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 ) {
|
public static function output( $post ) {
|
||||||
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
||||||
$visible = get_post_meta( $post->ID, 'sp_visible', true );
|
$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><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -8,10 +8,13 @@
|
|||||||
* @version 2.7.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_Meta_Box_Config' ) )
|
if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
|
||||||
include( 'class-sp-meta-box-config.php' );
|
require 'class-sp-meta-box-config.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Outcome_Details
|
* 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' );
|
$result = get_page_by_path( $main_result, ARRAY_A, 'sp_result' );
|
||||||
$label = sp_array_value( $result, 'post_title', __( 'Primary', 'sportspress' ) );
|
$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><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
<input name="sp_default_key" type="hidden" id="sp_default_key" value="<?php echo esc_attr( $post->post_name ); ?>">
|
<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>
|
||||||
<p><strong><?php _e( 'Abbreviation', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Abbreviation', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
@@ -66,7 +75,7 @@ class SP_Meta_Box_Outcome_Details extends SP_Meta_Box_Config {
|
|||||||
'else' => sprintf( __( 'Default', 'sportspress' ), $label ),
|
'else' => sprintf( __( 'Default', 'sportspress' ), $label ),
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ( $options as $key => $value ):
|
foreach ( $options as $key => $value ) :
|
||||||
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $condition, false ), $value );
|
printf( '<option value="%s" %s>%s</option>', $key, selected( true, $key == $condition, false ), $value );
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -8,10 +8,13 @@
|
|||||||
* @version 2.7.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_Meta_Box_Config' ) )
|
if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
|
||||||
include( 'class-sp-meta-box-config.php' );
|
require 'class-sp-meta-box-config.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Performance_Details
|
* 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><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
<input name="sp_default_key" type="hidden" id="sp_default_key" value="<?php echo esc_attr( $post->post_name ); ?>">
|
<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>
|
||||||
<p><strong><?php _e( 'Singular', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Singular', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
@@ -66,8 +73,18 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
|||||||
<p class="sp-section-selector">
|
<p class="sp-section-selector">
|
||||||
<select name="sp_section">
|
<select name="sp_section">
|
||||||
<?php
|
<?php
|
||||||
$options = apply_filters( 'sportspress_performance_sections', array( -1 => __( 'All', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ), 1 => __( 'Defense', 'sportspress' ) ) );
|
$options = apply_filters(
|
||||||
foreach ( $options as $key => $value ):
|
'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 );
|
printf( '<option value="%s" %s>%s</option>', $key, selected( $key == $section, true, false ), $value );
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
@@ -77,8 +94,20 @@ class SP_Meta_Box_Performance_Details extends SP_Meta_Box_Config {
|
|||||||
<p class="sp-format-selector">
|
<p class="sp-format-selector">
|
||||||
<select name="sp_format">
|
<select name="sp_format">
|
||||||
<?php
|
<?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(
|
||||||
foreach ( $options as $key => $value ):
|
'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 );
|
printf( '<option value="%s" %s>%s</option>', $key, selected( $key == $format, true, false ), $value );
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -8,10 +8,13 @@
|
|||||||
* @version 2.1.6
|
* @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' ) )
|
if ( ! class_exists( 'SP_Meta_Box_Equation' ) ) {
|
||||||
include( 'class-sp-meta-box-equation.php' );
|
require 'class-sp-meta-box-equation.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Performance_Equation
|
* SP_Meta_Box_Performance_Equation
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Player_Columns
|
* SP_Meta_Box_Player_Columns
|
||||||
@@ -25,8 +27,15 @@ class SP_Meta_Box_Player_Columns {
|
|||||||
<div class="sp-instance">
|
<div class="sp-instance">
|
||||||
<?php if ( $tabs ) { ?>
|
<?php if ( $tabs ) { ?>
|
||||||
<ul id="sp_column-tabs" class="sp-tab-bar category-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 ); ?>
|
<?php
|
||||||
<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>
|
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 } ?>
|
<?php } ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Player_Details
|
* SP_Meta_Box_Player_Details
|
||||||
@@ -24,7 +26,7 @@ class SP_Meta_Box_Player_Details {
|
|||||||
|
|
||||||
$number = get_post_meta( $post->ID, 'sp_number', true );
|
$number = get_post_meta( $post->ID, 'sp_number', true );
|
||||||
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
|
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
|
||||||
$default_nationality = get_option( 'sportspress_default_nationality' , false );
|
$default_nationality = get_option( 'sportspress_default_nationality', false );
|
||||||
|
|
||||||
if ( empty( $nationalities ) && $default_nationality ) {
|
if ( empty( $nationalities ) && $default_nationality ) {
|
||||||
if ( $default_nationality != '' ) {
|
if ( $default_nationality != '' ) {
|
||||||
@@ -32,8 +34,8 @@ class SP_Meta_Box_Player_Details {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $nationalities as $index => $nationality ):
|
foreach ( $nationalities as $index => $nationality ) :
|
||||||
if ( 2 == strlen( $nationality ) ):
|
if ( 2 == strlen( $nationality ) ) :
|
||||||
$legacy = SP()->countries->legacy;
|
$legacy = SP()->countries->legacy;
|
||||||
$nationality = strtolower( $nationality );
|
$nationality = strtolower( $nationality );
|
||||||
$nationality = sp_array_value( $legacy, $nationality, null );
|
$nationality = sp_array_value( $legacy, $nationality, null );
|
||||||
@@ -41,37 +43,42 @@ class SP_Meta_Box_Player_Details {
|
|||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
if ( taxonomy_exists( 'sp_league' ) ):
|
if ( taxonomy_exists( 'sp_league' ) ) :
|
||||||
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
||||||
$league_ids = array();
|
$league_ids = array();
|
||||||
if ( $leagues ):
|
if ( $leagues ) :
|
||||||
foreach ( $leagues as $league ):
|
foreach ( $leagues as $league ) :
|
||||||
$league_ids[] = $league->term_id;
|
$league_ids[] = $league->term_id;
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( taxonomy_exists( 'sp_season' ) ):
|
if ( taxonomy_exists( 'sp_season' ) ) :
|
||||||
$seasons = get_the_terms( $post->ID, 'sp_season' );
|
$seasons = get_the_terms( $post->ID, 'sp_season' );
|
||||||
$season_ids = array();
|
$season_ids = array();
|
||||||
if ( $seasons ):
|
if ( $seasons ) :
|
||||||
foreach ( $seasons as $season ):
|
foreach ( $seasons as $season ) :
|
||||||
$season_ids[] = $season->term_id;
|
$season_ids[] = $season->term_id;
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( taxonomy_exists( 'sp_position' ) ):
|
if ( taxonomy_exists( 'sp_position' ) ) :
|
||||||
$positions = get_the_terms( $post->ID, 'sp_position' );
|
$positions = get_the_terms( $post->ID, 'sp_position' );
|
||||||
$position_ids = array();
|
$position_ids = array();
|
||||||
if ( $positions ):
|
if ( $positions ) :
|
||||||
foreach ( $positions as $position ):
|
foreach ( $positions as $position ) :
|
||||||
$position_ids[] = $position->term_id;
|
$position_ids[] = $position->term_id;
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
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 ) );
|
$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 ) );
|
$current_teams = array_filter( get_post_meta( $post->ID, 'sp_current_team', false ) );
|
||||||
?>
|
?>
|
||||||
@@ -80,12 +87,16 @@ 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><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><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>
|
<option value=""></option>
|
||||||
<?php foreach ( $continents as $continent => $countries ): ?>
|
<?php foreach ( $continents as $continent => $countries ) : ?>
|
||||||
<optgroup label="<?php echo esc_attr( $continent ); ?>">
|
<optgroup label="<?php echo esc_attr( $continent ); ?>">
|
||||||
<?php foreach ( $countries as $code => $country ): ?>
|
<?php foreach ( $countries as $code => $country ) : ?>
|
||||||
<option value="<?php echo esc_attr( $code ); ?>" <?php selected ( in_array( $code, $nationalities ) ); ?>><?php echo esc_html( $country ); ?></option>
|
<option value="<?php echo esc_attr( $code ); ?>" <?php selected( in_array( $code, $nationalities ) ); ?>><?php echo esc_html( $country ); ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
@@ -93,7 +104,8 @@ class SP_Meta_Box_Player_Details {
|
|||||||
|
|
||||||
<?php if ( taxonomy_exists( 'sp_position' ) ) { ?>
|
<?php if ( taxonomy_exists( 'sp_position' ) ) { ?>
|
||||||
<p><strong><?php _e( 'Positions', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Positions', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'taxonomy' => 'sp_position',
|
'taxonomy' => 'sp_position',
|
||||||
'name' => 'tax_input[sp_position][]',
|
'name' => 'tax_input[sp_position][]',
|
||||||
@@ -105,11 +117,13 @@ class SP_Meta_Box_Player_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'name' => 'sp_current_team[]',
|
'name' => 'sp_current_team[]',
|
||||||
@@ -121,10 +135,12 @@ class SP_Meta_Box_Player_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_pages( $args );
|
sp_dropdown_pages( $args );
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'name' => 'sp_past_team[]',
|
'name' => 'sp_past_team[]',
|
||||||
@@ -136,11 +152,13 @@ class SP_Meta_Box_Player_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_pages( $args );
|
sp_dropdown_pages( $args );
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
<?php if ( taxonomy_exists( 'sp_league' ) ) { ?>
|
<?php if ( taxonomy_exists( 'sp_league' ) ) { ?>
|
||||||
<p><strong><?php _e( 'Leagues', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Leagues', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'tax_input[sp_league][]',
|
'name' => 'tax_input[sp_league][]',
|
||||||
@@ -152,12 +170,14 @@ class SP_Meta_Box_Player_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if ( taxonomy_exists( 'sp_season' ) ) { ?>
|
<?php if ( taxonomy_exists( 'sp_season' ) ) { ?>
|
||||||
<p><strong><?php _e( 'Seasons', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Seasons', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'tax_input[sp_season][]',
|
'name' => 'tax_input[sp_season][]',
|
||||||
@@ -169,7 +189,8 @@ class SP_Meta_Box_Player_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Player_Metrics
|
* SP_Meta_Box_Player_Metrics
|
||||||
@@ -32,14 +34,14 @@ class SP_Meta_Box_Player_Metrics {
|
|||||||
|
|
||||||
$vars = get_posts( $args );
|
$vars = get_posts( $args );
|
||||||
|
|
||||||
if ( $vars ):
|
if ( $vars ) :
|
||||||
foreach ( $vars as $var ):
|
foreach ( $vars as $var ) :
|
||||||
?>
|
?>
|
||||||
<p><strong><?php echo esc_html( $var->post_title ); ?></strong></p>
|
<p><strong><?php echo esc_html( $var->post_title ); ?></strong></p>
|
||||||
<p><input type="text" name="sp_metrics[<?php echo esc_attr( $var->post_name ); ?>]" value="<?php echo esc_attr( sp_array_value( $metrics, $var->post_name, '' ) ); ?>" /></p>
|
<p><input type="text" name="sp_metrics[<?php echo esc_attr( $var->post_name ); ?>]" value="<?php echo esc_attr( sp_array_value( $metrics, $var->post_name, '' ) ); ?>" /></p>
|
||||||
<?php
|
<?php
|
||||||
endforeach;
|
endforeach;
|
||||||
else:
|
else :
|
||||||
sp_post_adder( 'sp_metric', __( 'Add New', 'sportspress' ) );
|
sp_post_adder( 'sp_metric', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 1.6.1
|
* @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
|
* SP_Meta_Box_Player_Shortcode
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Player_Statistics
|
* SP_Meta_Box_Player_Statistics
|
||||||
@@ -21,10 +23,10 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
$player = new SP_Player( $post );
|
$player = new SP_Player( $post );
|
||||||
$leagues = $player->get_terms_sorted_by_sp_order( 'sp_league' );
|
$leagues = $player->get_terms_sorted_by_sp_order( 'sp_league' );
|
||||||
if ( is_array ( $leagues ) ) {
|
if ( is_array( $leagues ) ) {
|
||||||
$league_num = sizeof( $leagues );
|
$league_num = sizeof( $leagues );
|
||||||
}else{
|
} else {
|
||||||
$league_num =0;
|
$league_num = 0;
|
||||||
}
|
}
|
||||||
$sections = get_option( 'sportspress_player_performance_sections', -1 );
|
$sections = get_option( 'sportspress_player_performance_sections', -1 );
|
||||||
$show_career_totals = 'yes' === get_option( 'sportspress_player_show_career_total', 'no' ) ? true : false;
|
$show_career_totals = 'yes' === get_option( 'sportspress_player_show_career_total', 'no' ) ? true : false;
|
||||||
@@ -33,7 +35,7 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
if ( -1 == $sections ) {
|
if ( -1 == $sections ) {
|
||||||
// Loop through statistics for each league
|
// Loop through statistics for each league
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $leagues as $league ):
|
foreach ( $leagues as $league ) :
|
||||||
?>
|
?>
|
||||||
<p><strong><?php echo esc_html( $league->name ); ?></strong></p>
|
<p><strong><?php echo esc_html( $league->name ); ?></strong></p>
|
||||||
<?php
|
<?php
|
||||||
@@ -51,7 +53,10 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
} else {
|
} else {
|
||||||
// Determine order of sections
|
// Determine order of sections
|
||||||
if ( 1 == $sections ) {
|
if ( 1 == $sections ) {
|
||||||
$section_order = array( 1 => __( 'Defense', 'sportspress' ), 0 => __( 'Offense', 'sportspress' ) );
|
$section_order = array(
|
||||||
|
1 => __( 'Defense', 'sportspress' ),
|
||||||
|
0 => __( 'Offense', 'sportspress' ),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
$section_order = array( __( 'Offense', 'sportspress' ), __( 'Defense', 'sportspress' ) );
|
||||||
}
|
}
|
||||||
@@ -60,7 +65,7 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
foreach ( $section_order as $section_id => $section_label ) {
|
foreach ( $section_order as $section_id => $section_label ) {
|
||||||
// Loop through statistics for each league
|
// Loop through statistics for each league
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $leagues as $league ):
|
foreach ( $leagues as $league ) :
|
||||||
?>
|
?>
|
||||||
<p><strong><?php echo esc_html( $league->name ); ?> — <?php echo esc_html( $section_label ); ?></strong></p>
|
<p><strong><?php echo esc_html( $league->name ); ?> — <?php echo esc_html( $section_label ); ?></strong></p>
|
||||||
<?php
|
<?php
|
||||||
@@ -95,19 +100,30 @@ 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() ) {
|
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;
|
$readonly = false;
|
||||||
$teams = array_filter( get_post_meta( $id, 'sp_team', 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">
|
<div class="sp-data-table-container">
|
||||||
<table class="widefat sp-data-table sp-player-statistics-table">
|
<table class="widefat sp-data-table sp-player-statistics-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
||||||
<?php if ( $team_select && apply_filters( 'sportspress_player_team_statistics', $league_id ) ): ?>
|
<?php if ( $team_select && apply_filters( 'sportspress_player_team_statistics', $league_id ) ) : ?>
|
||||||
<th>
|
<th>
|
||||||
<?php _e( 'Team', 'sportspress' ); ?>
|
<?php _e( 'Team', 'sportspress' ); ?>
|
||||||
</th>
|
</th>
|
||||||
<?php endif; ?>
|
<?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>
|
<th><?php echo esc_html( $label ); ?></th>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php do_action( 'sportspress_meta_box_player_statistics_table_header_row', $id, $league_id ); ?>
|
<?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 ) ) { ?>
|
<?php if ( $team_select && apply_filters( 'sportspress_player_team_statistics', $league_id ) ) { ?>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<?php } ?>
|
<?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 );
|
$value = sp_array_value( sp_array_value( $data, 0, array() ), $column, null );
|
||||||
$placeholder = sp_array_value( sp_array_value( $placeholders, 0, array() ), $column, 0 );
|
$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' ) . '" />';
|
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 endforeach; ?>
|
||||||
<?php do_action( 'sportspress_meta_box_player_statistics_table_footer_row', $id, $league_id ); ?>
|
<?php do_action( 'sportspress_meta_box_player_statistics_table_footer_row', $id, $league_id ); ?>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -152,29 +173,41 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $data as $div_id => $div_stats ):
|
foreach ( $data as $div_id => $div_stats ) :
|
||||||
if ( $div_id === 'statistics' ) continue;
|
if ( $div_id === 'statistics' ) {
|
||||||
if ( $div_id === 0 ) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ( $div_id === 0 ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$div = get_term( $div_id, 'sp_season' );
|
$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>
|
<td>
|
||||||
<label>
|
<label>
|
||||||
<?php if ( ! apply_filters( 'sportspress_player_team_statistics', $league_id ) ): ?>
|
<?php if ( ! apply_filters( 'sportspress_player_team_statistics', $league_id ) ) : ?>
|
||||||
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
||||||
<input type="hidden" name="sp_leagues[<?php echo esc_attr( $league_id ); ?>][<?php echo esc_attr( $div_id ); ?>]" value="-1">
|
<input type="hidden" name="sp_leagues[<?php echo esc_attr( $league_id ); ?>][<?php echo esc_attr( $div_id ); ?>]" value="-1">
|
||||||
<input type="checkbox" name="sp_leagues[<?php echo esc_attr( $league_id ); ?>][<?php echo esc_attr( $div_id ); ?>]" value="1" <?php checked( $value ); ?>>
|
<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 endif; ?>
|
||||||
<?php
|
<?php
|
||||||
if ( 0 === $div_id ) _e( 'Total', 'sportspress' );
|
if ( 0 === $div_id ) {
|
||||||
elseif ( 'WP_Error' != get_class( $div ) ) echo apply_filters( 'sportspress_meta_box_player_statistics_season_name', $div->name, $league_id, $div_id, $div_stats );
|
_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>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
<?php if ( $team_select && apply_filters( 'sportspress_player_team_statistics', $league_id ) ): ?>
|
<?php if ( $team_select && apply_filters( 'sportspress_player_team_statistics', $league_id ) ) : ?>
|
||||||
<?php if ( $div_id == 0 ): ?>
|
<?php if ( $div_id == 0 ) : ?>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<?php else: ?>
|
<?php else : ?>
|
||||||
<td>
|
<td>
|
||||||
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
||||||
<?php
|
<?php
|
||||||
@@ -201,7 +234,7 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_pages( $args ) ):
|
if ( ! sp_dropdown_pages( $args ) ) :
|
||||||
_e( '— None —', 'sportspress' );
|
_e( '— None —', 'sportspress' );
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
@@ -209,12 +242,26 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php
|
<?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 ) );
|
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 );
|
$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 );
|
$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 . '" />';
|
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 endforeach; ?>
|
||||||
<?php do_action( 'sportspress_meta_box_player_statistics_table_row', $id, $league_id, $div_id, $team_select, $buffer, $i ); ?>
|
<?php do_action( 'sportspress_meta_box_player_statistics_table_row', $id, $league_id, $div_id, $team_select, $buffer, $i ); ?>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -8,10 +8,13 @@
|
|||||||
* @version 2.7.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_Meta_Box_Config' ) )
|
if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
|
||||||
include( 'class-sp-meta-box-config.php' );
|
require 'class-sp-meta-box-config.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Result_Details
|
* 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><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
<input name="sp_default_key" type="hidden" id="sp_default_key" value="<?php echo esc_attr( $post->post_name ); ?>">
|
<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>
|
||||||
<p><strong><?php _e( 'Decimal Places', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Decimal Places', 'sportspress' ); ?></strong></p>
|
||||||
<p class="sp-precision-selector">
|
<p class="sp-precision-selector">
|
||||||
|
|||||||
@@ -8,10 +8,13 @@
|
|||||||
* @version 1.9
|
* @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' ) )
|
if ( ! class_exists( 'SP_Meta_Box_Equation' ) ) {
|
||||||
include( 'class-sp-meta-box-equation.php' );
|
require 'class-sp-meta-box-equation.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Result_Equation
|
* SP_Meta_Box_Result_Equation
|
||||||
|
|||||||
@@ -8,10 +8,13 @@
|
|||||||
* @version 2.7.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_Meta_Box_Config' ) )
|
if ( ! class_exists( 'SP_Meta_Box_Config' ) ) {
|
||||||
include( 'class-sp-meta-box-config.php' );
|
require 'class-sp-meta-box-config.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Spec_Details
|
* 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 ) {
|
public static function output( $post ) {
|
||||||
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
||||||
$visible = get_post_meta( $post->ID, 'sp_visible', true );
|
$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><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.7.9
|
* @version 2.7.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit; // Exit if accessed directly
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SP_Meta_Box_Staff_Details
|
* SP_Meta_Box_Staff_Details
|
||||||
@@ -23,8 +25,8 @@ class SP_Meta_Box_Staff_Details {
|
|||||||
$continents = SP()->countries->continents;
|
$continents = SP()->countries->continents;
|
||||||
|
|
||||||
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
|
$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
|
||||||
foreach ( $nationalities as $index => $nationality ):
|
foreach ( $nationalities as $index => $nationality ) :
|
||||||
if ( 2 == strlen( $nationality ) ):
|
if ( 2 == strlen( $nationality ) ) :
|
||||||
$legacy = SP()->countries->legacy;
|
$legacy = SP()->countries->legacy;
|
||||||
$nationality = strtolower( $nationality );
|
$nationality = strtolower( $nationality );
|
||||||
$nationality = sp_array_value( $legacy, $nationality, null );
|
$nationality = sp_array_value( $legacy, $nationality, null );
|
||||||
@@ -34,16 +36,16 @@ class SP_Meta_Box_Staff_Details {
|
|||||||
|
|
||||||
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
||||||
$league_ids = array();
|
$league_ids = array();
|
||||||
if ( $leagues ):
|
if ( $leagues ) :
|
||||||
foreach ( $leagues as $league ):
|
foreach ( $leagues as $league ) :
|
||||||
$league_ids[] = $league->term_id;
|
$league_ids[] = $league->term_id;
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$seasons = get_the_terms( $post->ID, 'sp_season' );
|
$seasons = get_the_terms( $post->ID, 'sp_season' );
|
||||||
$season_ids = array();
|
$season_ids = array();
|
||||||
if ( $seasons ):
|
if ( $seasons ) :
|
||||||
foreach ( $seasons as $season ):
|
foreach ( $seasons as $season ) :
|
||||||
$season_ids[] = $season->term_id;
|
$season_ids[] = $season->term_id;
|
||||||
endforeach;
|
endforeach;
|
||||||
endif;
|
endif;
|
||||||
@@ -51,12 +53,18 @@ class SP_Meta_Box_Staff_Details {
|
|||||||
$roles = get_the_terms( $post->ID, 'sp_role' );
|
$roles = get_the_terms( $post->ID, 'sp_role' );
|
||||||
$role_ids = is_array( $roles ) ? wp_list_pluck( $roles, 'term_id' ) : array();
|
$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 ) );
|
$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 ) );
|
$current_teams = array_filter( get_post_meta( $post->ID, 'sp_current_team', false ) );
|
||||||
?>
|
?>
|
||||||
<p><strong><?php _e( 'Jobs', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Jobs', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'taxonomy' => 'sp_role',
|
'taxonomy' => 'sp_role',
|
||||||
'name' => 'tax_input[sp_role][]',
|
'name' => 'tax_input[sp_role][]',
|
||||||
@@ -67,25 +75,31 @@ class SP_Meta_Box_Staff_Details {
|
|||||||
'property' => 'multiple',
|
'property' => 'multiple',
|
||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
if ( ! sp_dropdown_taxonomies( $args ) ):
|
if ( ! sp_dropdown_taxonomies( $args ) ) :
|
||||||
sp_taxonomy_adder( 'sp_role', 'sp_staff', __( 'Add New', 'sportspress' ) );
|
sp_taxonomy_adder( 'sp_role', 'sp_staff', __( 'Add New', 'sportspress' ) );
|
||||||
endif;
|
endif;
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p><strong><?php _e( 'Nationality', 'sportspress' ); ?></strong></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>
|
<option value=""></option>
|
||||||
<?php foreach ( $continents as $continent => $countries ): ?>
|
<?php foreach ( $continents as $continent => $countries ) : ?>
|
||||||
<optgroup label="<?php echo esc_attr( $continent ); ?>">
|
<optgroup label="<?php echo esc_attr( $continent ); ?>">
|
||||||
<?php foreach ( $countries as $code => $country ): ?>
|
<?php foreach ( $countries as $code => $country ) : ?>
|
||||||
<option value="<?php echo esc_attr( $code ); ?>" <?php selected ( in_array( $code, $nationalities ) ); ?>><?php echo esc_html( $country ); ?></option>
|
<option value="<?php echo esc_attr( $code ); ?>" <?php selected( in_array( $code, $nationalities ) ); ?>><?php echo esc_html( $country ); ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select></p>
|
</select></p>
|
||||||
|
|
||||||
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'name' => 'sp_current_team[]',
|
'name' => 'sp_current_team[]',
|
||||||
@@ -97,10 +111,12 @@ class SP_Meta_Box_Staff_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_pages( $args );
|
sp_dropdown_pages( $args );
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_team',
|
'post_type' => 'sp_team',
|
||||||
'name' => 'sp_past_team[]',
|
'name' => 'sp_past_team[]',
|
||||||
@@ -112,10 +128,12 @@ class SP_Meta_Box_Staff_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_pages( $args );
|
sp_dropdown_pages( $args );
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p><strong><?php _e( 'Leagues', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Leagues', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'taxonomy' => 'sp_league',
|
'taxonomy' => 'sp_league',
|
||||||
'name' => 'tax_input[sp_league][]',
|
'name' => 'tax_input[sp_league][]',
|
||||||
@@ -127,10 +145,12 @@ class SP_Meta_Box_Staff_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p><strong><?php _e( 'Seasons', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Seasons', 'sportspress' ); ?></strong></p>
|
||||||
<p><?php
|
<p>
|
||||||
|
<?php
|
||||||
$args = array(
|
$args = array(
|
||||||
'taxonomy' => 'sp_season',
|
'taxonomy' => 'sp_season',
|
||||||
'name' => 'tax_input[sp_season][]',
|
'name' => 'tax_input[sp_season][]',
|
||||||
@@ -142,7 +162,8 @@ class SP_Meta_Box_Staff_Details {
|
|||||||
'chosen' => true,
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sp_dropdown_taxonomies( $args );
|
sp_dropdown_taxonomies( $args );
|
||||||
?></p>
|
?>
|
||||||
|
</p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
* @version 2.5.5
|
* @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
|
* SP_Meta_Box_Staff_Shortcode
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user