Enhance shortcode menu with Thickbox prompt

This commit is contained in:
Brian Miyaji
2014-07-12 02:33:53 +10:00
parent 89276205fd
commit bfb06c64bc
11 changed files with 900 additions and 230 deletions

View File

@@ -74,14 +74,35 @@
text-align: center;
}
.wp-media-buttons .add_sportspress span.wp-media-buttons-icon:before {
font: normal 20px/1 sportspress, dashicons;
/* Prefs */
.sp-prefs .button {
margin: 0 3px 4px 0;
padding: 0 7px 1px 5px;
}
.sp-prefs .button input[type=checkbox] {
background: transparent;
border: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.sp-prefs .button input[type=checkbox]:not(:checked):before {
float: left;
display: inline-block;
vertical-align: middle;
width: 16px;
font: 400 21px/1 dashicons;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
content: '\f111';
content: '\f335';
margin: -3px 0 0 -4px;
color: #a00;
}
/* TinyMCE */
i.mce-i-sp_shortcodes_button:before, span.mce_sp_shortcodes_button:before {
font-family: 'sportspress';
speak: none;

View File

@@ -3,15 +3,22 @@
$strings = 'tinyMCE.addI18n({' . _WP_Editors::$mce_locale . ':{
sportspress:{
insert: "' . esc_js( __( 'SportsPress shortcodes', 'sportspress' ) ) . '",
auto: "' . esc_js( __( 'Auto', 'sportspress' ) ) . '",
manual: "' . esc_js( __( 'Manual', 'sportspress' ) ) . '",
single: "' . esc_js( __( 'Single', 'sportspress' ) ) . '",
select: "' . esc_js( __( 'Select...', 'sportspress' ) ) . '",
countdown: "' . esc_js( __( 'Countdown', 'sportspress' ) ) . '",
event_details: "' . esc_js( __( 'Event Details', 'sportspress' ) ) . '",
event_results: "' . esc_js( __( 'Event Results', 'sportspress' ) ) . '",
event_performance: "' . esc_js( __( 'Event Performance', 'sportspress' ) ) . '",
event_calendar: "' . esc_js( __( 'Event Calendar', 'sportspress' ) ) . '",
event_list: "' . esc_js( __( 'Event List', 'sportspress' ) ) . '",
event_blocks: "' . esc_js( __( 'Event Blocks', 'sportspress' ) ) . '",
event: "' . esc_js( __( 'Event', 'sportspress' ) ) . '",
details: "' . esc_js( __( 'Details', 'sportspress' ) ) . '",
results: "' . esc_js( __( 'Results', 'sportspress' ) ) . '",
performance: "' . esc_js( __( 'Performance', 'sportspress' ) ) . '",
calendar: "' . esc_js( __( 'Calendar', 'sportspress' ) ) . '",
list: "' . esc_js( __( 'List', 'sportspress' ) ) . '",
blocks: "' . esc_js( __( 'Blocks', 'sportspress' ) ) . '",
league_table: "' . esc_js( __( 'League Table', 'sportspress' ) ) . '",
player_list: "' . esc_js( __( 'Player List', 'sportspress' ) ) . '",
player_gallery: "' . esc_js( __( 'Player Gallery', 'sportspress' ) ) . '"
player: "' . esc_js( __( 'Player', 'sportspress' ) ) . '",
statistics: "' . esc_js( __( 'Statistics', 'sportspress' ) ) . '",
list: "' . esc_js( __( 'List', 'sportspress' ) ) . '",
gallery: "' . esc_js( __( 'Gallery', 'sportspress' ) ) . '"
}
}})';
}})';

View File

@@ -10,63 +10,202 @@
menu: [
{
text: ed.getLang( 'sportspress.countdown' ),
onclick: function() {
editor.insertContent( '[countdown id="" live=""]' );
}
menu: [
{
text: ed.getLang( 'sportspress.manual' ),
onclick: function() {
editor.insertContent( '[countdown id="" live="1"]' );
}
},
{
text: ed.getLang( 'sportspress.auto' ),
onclick: function() {
editor.insertContent( '[countdown]' );
}
}
]
},
{
text: ed.getLang( 'sportspress.event_details' ),
onclick: function() {
editor.insertContent( '[event_details id=""]' );
}
},
{
text: ed.getLang( 'sportspress.event_results' ),
onclick: function() {
editor.insertContent( '[event_results id=""]' );
}
},
{
text: ed.getLang( 'sportspress.event_performance' ),
onclick: function() {
editor.insertContent( '[event_performance id=""]' );
}
},
{
text: ed.getLang( 'sportspress.event_calendar' ),
onclick: function() {
editor.insertContent( '[event_calendar id="" status="default" show_all_events_link="0"]' );
}
},
{
text: ed.getLang( 'sportspress.event_list' ),
onclick: function() {
editor.insertContent( '[event_list id="" status="default" show_all_events_link="0"]' );
}
},
{
text: ed.getLang( 'sportspress.event_blocks' ),
onclick: function() {
editor.insertContent( '[event_blocks id="" status="default" show_all_events_link="0"]' );
}
text: ed.getLang( 'sportspress.event' ),
menu: [
{
text: ed.getLang( 'sportspress.single' ),
menu: [
{
text: ed.getLang( 'sportspress.details' ),
onclick: function() {
editor.insertContent( '[event_details id=""]' );
}
},
{
text: ed.getLang( 'sportspress.results' ),
onclick: function() {
editor.insertContent( '[event_results id=""]' );
}
},
{
text: ed.getLang( 'sportspress.performance' ),
onclick: function() {
editor.insertContent( '[event_performance id=""]' );
}
}
]
},
{
text: ed.getLang( 'sportspress.calendar' ),
menu: [
{
text: ed.getLang( 'sportspress.select' ),
onclick : function() {
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_event_calendar' );
}
},
{
text: ed.getLang( 'sportspress.manual' ),
onclick: function() {
editor.insertContent( '[event_calendar id="" status="default" initial="1" show_all_events_link="0"]' );
}
},
{
text: ed.getLang( 'sportspress.auto' ),
onclick: function() {
editor.insertContent( '[event_calendar]' );
}
}
]
},
{
text: ed.getLang( 'sportspress.list' ),
menu: [
{
text: ed.getLang( 'sportspress.select' ),
onclick : function() {
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_event_list' );
}
},
{
text: ed.getLang( 'sportspress.manual' ),
onclick: function() {
editor.insertContent( '[event_list id="" status="default" show_all_events_link="0"]' );
}
}
]
},
{
text: ed.getLang( 'sportspress.blocks' ),
menu: [
{
text: ed.getLang( 'sportspress.select' ),
onclick : function() {
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_event_blocks' );
}
},
{
text: ed.getLang( 'sportspress.manual' ),
onclick: function() {
editor.insertContent( '[event_blocks id="" status="default" show_all_events_link="0"]' );
}
}
]
}
]
},
{
text: ed.getLang( 'sportspress.league_table' ),
onclick: function() {
editor.insertContent( '[league_table id="" number="-1" show_team_logo="1" link_posts="0" show_full_table_link="0"]' );
}
menu: [
{
text: ed.getLang( 'sportspress.select' ),
onclick : function() {
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_league_table' );
}
},
{
text: ed.getLang( 'sportspress.manual' ),
onclick: function() {
editor.insertContent( '[league_table id="" number="-1" show_team_logo="1" link_posts="0" show_full_table_link="0"]' );
}
}
]
},
{
text: ed.getLang( 'sportspress.player_list' ),
onclick: function() {
editor.insertContent( '[player_list id="" number="-1" orderby="default" order="ASC" show_all_players_link="0"]' );
}
},
{
text: ed.getLang( 'sportspress.player_gallery' ),
onclick: function() {
editor.insertContent( '[event_blocks id="" number="-1" columns="3" orderby="default" order="ASC" size="thumbnail" show_all_players_link="0"]' );
}
text: ed.getLang( 'sportspress.player' ),
menu: [
{
text: ed.getLang( 'sportspress.single' ),
menu: [
{
text: ed.getLang( 'sportspress.details' ),
onclick: function() {
editor.insertContent( '[player_details id=""]' );
}
},
{
text: ed.getLang( 'sportspress.statistics' ),
onclick: function() {
editor.insertContent( '[player_statistics id=""]' );
}
}
]
},
{
text: ed.getLang( 'sportspress.list' ),
menu: [
{
text: ed.getLang( 'sportspress.select' ),
onclick : function() {
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_player_list' );
}
},
{
text: ed.getLang( 'sportspress.manual' ),
onclick: function() {
editor.insertContent( '[player_list id="" number="-1" orderby="default" order="ASC" show_all_players_link="0"]' );
}
}
]
},
{
text: ed.getLang( 'sportspress.gallery' ),
menu: [
{
text: ed.getLang( 'sportspress.select' ),
onclick : function() {
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( 'My WIndow POPUP Title', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=sp_choose_player_gallery' );
}
},
{
text: ed.getLang( 'sportspress.manual' ),
onclick: function() {
editor.insertContent( '[player_gallery id="" number="-1" columns="3" orderby="default" order="ASC" size="thumbnail" show_all_players_link="0"]' );
}
}
]
}
]
}
]
});

View File

@@ -7,7 +7,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 2.0
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) {
/**
* SP_Admin_Editor class.
*
* @since 2.0
* @since 1.2
*/
class SP_Admin_Editor {

View File

@@ -0,0 +1,483 @@
<?php
/**
* Post Types Admin
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'SP_Admin_Thickbox' ) ) :
/**
* SP_Admin_Thickbox Class
*/
class SP_Admin_Thickbox {
/**
* Constructor
*/
public function __construct() {
add_action( 'admin_footer', array( $this, 'admin_footer' ) );
}
/**
* Admin Footer For Thickbox
*
* Prints the footer code needed for the TinyMCE modal window.
*
* @since 1.2
* @global $pagenow
* @global $typenow
* @return void
*/
function admin_footer() {
global $pagenow, $typenow;
// Only run in post/page creation and edit screens
if ( in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'post-edit.php' ) ) ) { ?>
<script type="text/javascript">
function insertSportsPress( type ) {
var $div = jQuery('#sp-thickbox-' + type);
// All shortcodes have an ID
var args = {id: $div.find('[name=id]').val()};
// Extract args based on type
if ( 'event_calendar' == type ) {
args['status'] = $div.find('[name=status]').val();
args['show_all_events_link'] = $div.find('[name=show_all_events_link]').val() == 'on' ? 1 : 0;
} else if ( 'event_list' == type ) {
args['status'] = $div.find('[name=status]').val();
args['date'] = $div.find('[name=date]').val();
args['number'] = $div.find('[name=number]').val();
args['order'] = $div.find('[name=order]').val();
args['columns'] = $div.find('[name="columns[]"]:checked').map(function() { return this.value; }).get().join(',');
args['show_all_events_link'] = $div.find('[name=show_all_events_link]').val() == 'on' ? 1 : 0;
} else if ( 'event_blocks' == type ) {
args['status'] = $div.find('[name=status]').val();
args['date'] = $div.find('[name=date]').val();
args['number'] = $div.find('[name=number]').val();
args['order'] = $div.find('[name=order]').val();
args['show_all_events_link'] = $div.find('[name=show_all_events_link]').val() == 'on' ? 1 : 0;
} else if ( 'league_table' == type ) {
args['number'] = $div.find('[name=number]').val();
args['columns'] = $div.find('[name="columns[]"]:checked').map(function() { return this.value; }).get().join(',');
args['show_team_logo'] = $div.find('[name=show_team_logo]').val() == 'on' ? 1 : 0;
args['show_full_table_link'] = $div.find('[name=show_full_table_link]').val() == 'on' ? 1 : 0;
} else if ( 'player_list' == type ) {
args['number'] = $div.find('[name=number]').val();
args['columns'] = $div.find('[name="columns[]"]:checked').map(function() { return this.value; }).get().join(',');
args['orderby'] = $div.find('[name=orderby]').val();
args['order'] = $div.find('[name=order]').val();
args['show_all_players_link'] = $div.find('[name=show_all_players_link]').val() == 'on' ? 1 : 0;
} else if ( 'player_gallery' == type ) {
args['number'] = $div.find('[name=number]').val();
args['orderby'] = $div.find('[name=orderby]').val();
args['order'] = $div.find('[name=order]').val();
args['show_all_players_link'] = $div.find('[name=show_all_players_link]').val() == 'on' ? 1 : 0;
args['show_names_on_hover'] = $div.find('[name=show_names_on_hover]').val() == 'on' ? 1 : 0;
}
// Generate the shortcode
var shortcode = '[' + type;
for ( var key in args ) {
if ( args.hasOwnProperty( key ) ) {
shortcode += ' ' + key + '="' + args[key] + '"';
}
}
shortcode += ']';
// Send the shortcode to the editor
window.send_to_editor( shortcode );
}
</script>
<?php
ob_start();
$args = array(
'post_type' => 'sp_calendar',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
$calendar_dropdown = ob_get_clean();
ob_start();
$args = array(
'post_type' => 'sp_table',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
$league_table_dropdown = ob_get_clean();
ob_start();
$args = array(
'post_type' => 'sp_list',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
$player_list_dropdown = ob_get_clean();
ob_start();
$args = array(
'prepend_options' => array(
'default' => __( 'Default', 'sportspress' ),
'number' => __( 'Number', 'sportspress' ),
'name' => __( 'Name', 'sportspress' ),
'eventsplayed' => __( 'Played', 'sportspress' )
),
'post_type' => array( 'sp_metric', 'sp_performance', 'sp_statistic' ),
'name' => 'orderby',
'id' => 'orderby',
'values' => 'slug'
);
sp_dropdown_pages( $args );
$player_list_orderby_dropdown = ob_get_clean();
?>
<div id="sp_choose_event_calendar" style="display: none;">
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_calendar">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?>
<?php echo $calendar_dropdown; ?>
</label>
</p>
<p>
<label>
<?php _e( 'Status:', 'sportspress' ); ?>
<?php
$args = array(
'name' => 'status',
'show_option_default' => __( 'Default', 'sportspress' ),
);
sp_dropdown_statuses( $args );
?>
</label>
</p>
<p>
<label>
<?php _e( 'Display link to view all events', 'sportspress' ); ?>
<input type="checkbox" name="show_all_events_link" id="show_all_events_link">
</label>
</p>
<p class="submit">
<input type="button" id="edd-insert-download" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('event_calendar');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
</div>
<div id="sp_choose_event_list" style="display: none;">
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_list">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?>
<?php echo $calendar_dropdown; ?>
</label>
</p>
<p>
<label>
<?php _e( 'Status:', 'sportspress' ); ?>
<?php
$args = array(
'name' => 'status',
'show_option_default' => __( 'Default', 'sportspress' ),
);
sp_dropdown_statuses( $args );
?>
</label>
</p>
<p>
<label>
<?php _e( 'Date:', 'sportspress' ); ?>
<select id="date" name="date">
<option value="default"><?php _e( 'Default', 'sportspress' ); ?></option>
<option value=""><?php _e( 'All', 'sportspress' ); ?></option>
<option value="w"><?php _e( 'This week', 'sportspress' ); ?></option>
<option value="day"><?php _e( 'Today', 'sportspress' ); ?></option>
</select>
</label>
</p>
<p>
<label>
<?php _e( 'Number of events to show:', 'sportspress' ); ?>
<input type="text" size="3" name="number" id="number" value="5">
</label>
</p>
<p>
<label>
<?php _e( 'Sort Order:', 'sportspress' ); ?>
<select id="order" name="order">
<option value="default"><?php _e( 'Default', 'sportspress' ); ?></option>
<option value="ASC"><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC"><?php _e( 'Descending', 'sportspress' ); ?></option>
</select>
</label>
</p>
<p class="sp-prefs">
<?php _e( 'Columns:', 'sportspress' ); ?><br>
<?php
$the_columns = array(
'event' => __( 'Event', 'sportspress' ),
'teams' => __( 'Teams', 'sportspress' ),
'time' => __( 'Time', 'sportspress' ),
'venue' => __( 'Venue', 'sportspress' ),
'article' => __( 'Article', 'sportspress' ),
);
$field_name = 'columns[]';
$field_id = 'columns';
?>
<?php foreach ( $the_columns as $key => $label ): ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $key; ?>" value="<?php echo $key; ?>" checked="checked"><?php echo $label; ?></label>
<?php endforeach; ?>
</p>
<p>
<label>
<input type="checkbox" name="show_all_events_link" id="show_all_events_link">
<?php _e( 'Display link to view all events', 'sportspress' ); ?>
</label>
</p>
<p class="submit">
<input type="button" id="edd-insert-download" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('event_list');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
</div>
<div id="sp_choose_event_blocks" style="display: none;">
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_blocks">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?>
<?php echo $calendar_dropdown; ?>
</label>
</p>
<p>
<label>
<?php _e( 'Status:', 'sportspress' ); ?>
<?php
$args = array(
'name' => 'status',
'show_option_default' => __( 'Default', 'sportspress' ),
);
sp_dropdown_statuses( $args );
?>
</label>
</p>
<p>
<label>
<?php _e( 'Date:', 'sportspress' ); ?>
<select id="date" name="date">
<option value="default"><?php _e( 'Default', 'sportspress' ); ?></option>
<option value=""><?php _e( 'All', 'sportspress' ); ?></option>
<option value="w"><?php _e( 'This week', 'sportspress' ); ?></option>
<option value="day"><?php _e( 'Today', 'sportspress' ); ?></option>
</select>
</label>
</p>
<p>
<label>
<?php _e( 'Number of events to show:', 'sportspress' ); ?>
<input type="text" size="3" name="number" id="number" value="5">
</label>
</p>
<p>
<label>
<?php _e( 'Sort Order:', 'sportspress' ); ?>
<select id="order" name="order">
<option value="default"><?php _e( 'Default', 'sportspress' ); ?></option>
<option value="ASC"><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC"><?php _e( 'Descending', 'sportspress' ); ?></option>
</select>
</label>
</p>
<p>
<label>
<input type="checkbox" name="show_all_events_link" id="show_all_events_link">
<?php _e( 'Display link to view all events', 'sportspress' ); ?>
</label>
</p>
<p class="submit">
<input type="button" id="edd-insert-download" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('event_blocks');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
</div>
<div id="sp_choose_league_table" style="display: none;">
<div class="wrap sp-thickbox-content" id="sp-thickbox-league_table">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'League Table', 'sportspress' ) ); ?>
<?php echo $league_table_dropdown; ?>
</label>
</p>
<p>
<label>
<?php _e( 'Number of teams to show:', 'sportspress' ); ?>
<input type="text" size="3" name="number" id="number" value="5">
</label>
</p>
<p class="sp-prefs">
<?php _e( 'Columns:', 'sportspress' ); ?><br>
<?php
$args = array(
'post_type' => 'sp_column',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$the_columns = get_posts( $args );
$field_name = 'columns[]';
$field_id = 'columns';
?>
<?php foreach ( $the_columns as $column ): ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $column->post_name; ?>" value="<?php echo $column->post_name; ?>" checked="checked"><?php echo $column->post_title; ?></label>
<?php endforeach; ?>
</p>
<p>
<label>
<input type="checkbox" name="show_team_logo" id="show_team_logo">
<?php _e( 'Display logos', 'sportspress' ); ?>
</label>
</p>
<p>
<label>
<input type="checkbox" name="show_full_table_link" id="show_full_table_link">
<?php _e( 'Display link to view full table', 'sportspress' ); ?>
</label>
</p>
<p class="submit">
<input type="button" id="edd-insert-download" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('league_table');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
</div>
<div id="sp_choose_player_list" style="display: none;">
<div class="wrap sp-thickbox-content" id="sp-thickbox-player_list">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player List', 'sportspress' ) ); ?>
<?php echo $player_list_dropdown; ?>
</label>
</p>
<p>
<label>
<?php _e( 'Number of players to show:', 'sportspress' ); ?>
<input type="text" size="3" name="number" id="number" value="5">
</label>
</p>
<p class="sp-prefs">
<?php _e( 'Columns:', 'sportspress' ); ?><br>
<?php
$args = array(
'post_type' => array( 'sp_metric', 'sp_performance', 'sp_statistic' ),
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$the_columns = get_posts( $args );
$field_name = 'columns[]';
$field_id = 'columns';
?>
<?php foreach ( $the_columns as $column ): ?>
<label class="button"><input name="<?php echo $field_name; ?>" type="checkbox" id="<?php echo $field_id . '-' . $column->post_name; ?>" value="<?php echo $column->post_name; ?>" checked="checked"><?php echo $column->post_title; ?></label>
<?php endforeach; ?>
</p>
<p>
<label>
<?php _e( 'Sort by:', 'sportspress' ); ?>
<?php echo $player_list_orderby_dropdown; ?>
</label>
</p>
<p>
<label>
<?php _e( 'Sort Order:', 'sportspress' ); ?>
<select id="order" name="order">
<option value=""><?php _e( 'Default', 'sportspress' ); ?></option>
<option value="ASC"><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC"><?php _e( 'Descending', 'sportspress' ); ?></option>
</select>
</label>
</p>
<p>
<label>
<input type="checkbox" name="show_all_players_link" id="show_all_players_link">
<?php _e( 'Display link to view all players', 'sportspress' ); ?>
</label>
</p>
<p class="submit">
<input type="button" id="edd-insert-download" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('player_list');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
</div>
<div id="sp_choose_player_gallery" style="display: none;">
<div class="wrap sp-thickbox-content" id="sp-thickbox-player_gallery">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player List', 'sportspress' ) ); ?>
<?php echo $player_list_dropdown; ?>
</label>
</p>
<p>
<label>
<?php _e( 'Number of players to show:', 'sportspress' ); ?>
<input type="text" size="3" name="number" id="number" value="5">
</label>
</p>
<p>
<label>
<?php _e( 'Sort by:', 'sportspress' ); ?>
<?php echo $player_list_orderby_dropdown; ?>
</label>
</p>
<p>
<label>
<?php _e( 'Sort Order:', 'sportspress' ); ?>
<select id="order" name="order">
<option value=""><?php _e( 'Default', 'sportspress' ); ?></option>
<option value="ASC"><?php _e( 'Ascending', 'sportspress' ); ?></option>
<option value="DESC"><?php _e( 'Descending', 'sportspress' ); ?></option>
</select>
</label>
</p>
<p>
<label>
<input type="checkbox" name="show_all_players_link" id="show_all_players_link">
<?php _e( 'Display link to view all players', 'sportspress' ); ?>
</label>
</p>
<p>
<label>
<input type="checkbox" name="show_names_on_hover" id="show_names_on_hover">
<?php _e( 'Display player names on hover', 'sportspress' ); ?>
</label>
</p>
<p class="submit">
<input type="button" id="edd-insert-download" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('player_gallery');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
</div>
<?php
}
}
}
endif;
return new SP_Admin_Thickbox();

View File

@@ -42,7 +42,11 @@ class SP_Admin {
include( 'class-sp-admin-notices.php' );
include( 'class-sp-admin-assets.php' );
include( 'class-sp-admin-permalink-settings.php' );
include( 'class-sp-admin-editor.php' );
if ( get_option( 'sportspress_rich_editing', true ) ):
include( 'class-sp-admin-editor.php' );
include( 'class-sp-admin-thickbox.php' );
endif;
// Help
// if ( apply_filters( 'sportspress_enable_admin_help_tab', true ) )

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 1.1.4
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -145,9 +145,18 @@ class SP_Settings_General extends SP_Settings_Page {
'id' => 'sportspress_enable_live_countdowns',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
'checkboxgroup' => '',
'desc_tip' => __( 'This will enable a script allowing the countdowns to be animated.', 'sportspress' ),
),
array(
'desc' => __( 'Shortcode menu', 'sportspress' ),
'id' => 'sportspress_rich_editing',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
'desc_tip' => __( 'This will enable a shortcode menu to be displayed in the visual editor.', 'sportspress' ),
),
array(
'title' => __( 'Header Offset', 'sportspress' ),

View File

@@ -15,9 +15,11 @@ class SP_Event extends SP_Custom_Post{
public function status() {
$post_status = $this->post->post_status;
$results = get_post_meta( $this->ID, 'sp_results', true );
foreach( $results as $result ) {
if ( count( array_filter( $result ) ) > 0 ) {
return 'results';
if ( is_array( $results ) ) {
foreach( $results as $result ) {
if ( count( array_filter( $result ) ) > 0 ) {
return 'results';
}
}
}
return $post_status;
@@ -54,40 +56,42 @@ class SP_Event extends SP_Custom_Post{
}
public function performance( $admin = false ) {
$teams = (array)get_post_meta( $this->ID, 'sp_team', false );
$teams = get_post_meta( $this->ID, 'sp_team', false );
$performance = (array)get_post_meta( $this->ID, 'sp_players', true );
$labels = sp_get_var_labels( 'sp_performance' );
$columns = get_post_meta( $this->ID, 'sp_columns', true );
foreach( $teams as $i => $team_id ):
$players = sp_array_between( (array)get_post_meta( $this->ID, 'sp_player', false ), 0, $i );
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
if ( is_array( $teams ) ):
foreach( $teams as $i => $team_id ):
$players = sp_array_between( (array)get_post_meta( $this->ID, 'sp_player', false ), 0, $i );
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
$totals = array();
foreach( $labels as $key => $label ):
$totals[ $key ] = 0;
endforeach;
foreach( $data as $player_id => $player_performance ):
$totals = array();
foreach( $labels as $key => $label ):
if ( array_key_exists( $key, $totals ) ):
$totals[ $key ] += sp_array_value( $player_performance, $key, 0 );
$totals[ $key ] = 0;
endforeach;
foreach( $data as $player_id => $player_performance ):
foreach( $labels as $key => $label ):
if ( array_key_exists( $key, $totals ) ):
$totals[ $key ] += sp_array_value( $player_performance, $key, 0 );
endif;
endforeach;
if ( ! array_key_exists( 'number', $player_performance ) ):
$performance[ $team_id ][ $player_id ]['number'] = get_post_meta( $player_id, 'sp_number', true );
endif;
if ( ! array_key_exists( 'position', $player_performance ) || $player_performance['position'] == null ):
$performance[ $team_id ][ $player_id ]['position'] = get_post_meta( $player_id, 'sp_position', true );
endif;
endforeach;
if ( ! array_key_exists( 'number', $player_performance ) ):
$performance[ $team_id ][ $player_id ]['number'] = get_post_meta( $player_id, 'sp_number', true );
endif;
if ( ! array_key_exists( 'position', $player_performance ) || $player_performance['position'] == null ):
$performance[ $team_id ][ $player_id ]['position'] = get_post_meta( $player_id, 'sp_position', true );
endif;
endforeach;
foreach( $totals as $key => $value ):
$manual_total = sp_array_value( sp_array_value( $performance, 0, array() ), $key, null );
if ( $manual_total != null ):
$totals[ $key ] = $manual_total;
endif;
foreach( $totals as $key => $value ):
$manual_total = sp_array_value( sp_array_value( $performance, 0, array() ), $key, null );
if ( $manual_total != null ):
$totals[ $key ] = $manual_total;
endif;
endforeach;
endforeach;
endforeach;
endif;
if ( $admin ):
return array( $labels, $columns, $performance, $teams );

View File

@@ -7,7 +7,7 @@
* @author ThemeBoy
* @category Core
* @package SportsPress/Functions
* @version 1.1.4
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -273,7 +273,7 @@ if ( !function_exists( 'sp_array_combine' ) ) {
endforeach;
foreach ( $keys as $key ):
if ( ! array_key_exists( $key, $output ) )
if ( $key !== false && ! array_key_exists( $key, $output ) )
$output[ $key ] = array();
endforeach;

View File

@@ -4,7 +4,7 @@
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 1.1
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -23,6 +23,7 @@ $defaults = array(
'paginated' => get_option( 'sportspress_calendar_paginated', 'yes' ) == 'yes' ? true : false,
'rows' => get_option( 'sportspress_calendar_rows', 10 ),
'order' => 'default',
'columns' => null,
'show_all_events_link' => false,
);
@@ -39,7 +40,7 @@ $data = $calendar->data();
$usecolumns = $calendar->columns;
if ( isset( $columns ) )
$usecolumns = $columns;
$usecolumns = explode( ',', $columns );
?>
<div class="sp-table-wrapper sp-scrollable-table-wrapper">
<table class="sp-event-list sp-data-table<?php if ( $responsive ) { ?> sp-responsive-table<?php } if ( $paginated ) { ?> sp-paginated-table<?php } ?>" data-sp-rows="<?php echo $rows; ?>">

View File

@@ -4,7 +4,7 @@
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 1.1
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -23,7 +23,7 @@ unset( $performance[0] );
$performance = array_filter( $performance );
$teams = (array)get_post_meta( $id, 'sp_team', false );
$teams = get_post_meta( $id, 'sp_team', false );
$status = $event->status();
$show_players = get_option( 'sportspress_event_show_players', 'yes' ) == 'yes' ? true : false;
@@ -31,146 +31,148 @@ $link_posts = get_option( 'sportspress_event_link_players', 'yes' ) == 'yes' ? t
$sortable = get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false;
$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false;
foreach( $teams as $index => $team_id ):
if ( ! $team_id ) continue;
if ( is_array( $teams ) ):
foreach( $teams as $index => $team_id ):
if ( ! $team_id ) continue;
// Get results for players in the team
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index );
$has_players = sizeof( $players ) > 1;
// Get results for players in the team
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index );
$has_players = sizeof( $players ) > 1;
if ( ! $has_players && $status != 'results' ) continue;
if ( ! $has_players && $status != 'results' ) continue;
$totals = array();
$totals = array();
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
?>
<h4 class="sp-table=caption"><?php echo get_the_title( $team_id ); ?></h4>
<?php
if ( get_option( 'sportspress_event_show_staff', 'yes' ) == 'yes' ):
sp_get_template( 'event-staff.php', array( 'id' => $id, 'index' => $index ) );
endif;
?>
<div class="sp-table-wrapper sp-scrollable-table-wrapper">
<table class="sp-event-performance sp-data-table <?php if ( $responsive ) { ?> sp-responsive-table<?php } if ( $has_players && $sortable ) { ?> sp-sortable-table<?php } ?>">
<thead>
<tr>
<?php if ( $has_players ): ?>
<th class="data-number">#</th>
<th class="data-name"><?php _e( 'Player', 'sportspress' ); ?></th>
<?php endif; foreach( $labels as $key => $label ): ?>
<th class="data-<?php echo $key; ?>"><?php echo $label; ?></th>
<?php endforeach; ?>
</tr>
</thead>
<?php if ( $show_players && $has_players ): ?>
<tbody>
<?php
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
?>
<h4 class="sp-table=caption"><?php echo get_the_title( $team_id ); ?></h4>
<?php
if ( get_option( 'sportspress_event_show_staff', 'yes' ) == 'yes' ):
sp_get_template( 'event-staff.php', array( 'id' => $id, 'index' => $index ) );
endif;
?>
<div class="sp-table-wrapper sp-scrollable-table-wrapper">
<table class="sp-event-performance sp-data-table <?php if ( $responsive ) { ?> sp-responsive-table<?php } if ( $has_players && $sortable ) { ?> sp-sortable-table<?php } ?>">
<thead>
<tr>
<?php if ( $has_players ): ?>
<th class="data-number">#</th>
<th class="data-name"><?php _e( 'Player', 'sportspress' ); ?></th>
<?php endif; foreach( $labels as $key => $label ): ?>
<th class="data-<?php echo $key; ?>"><?php echo $label; ?></th>
<?php endforeach; ?>
</tr>
</thead>
<?php if ( $show_players && $has_players ): ?>
<tbody>
<?php
$lineups = array_filter( $data, array( $event, 'lineup_filter' ) );
$subs = array_filter( $data, array( $event, 'sub_filter' ) );
$lineups = array_filter( $data, array( $event, 'lineup_filter' ) );
$subs = array_filter( $data, array( $event, 'sub_filter' ) );
$lineup_sub_relation = array();
foreach ( $subs as $sub_id => $sub ):
if ( ! $sub_id )
continue;
$lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id;
endforeach;
$i = 0;
foreach( $data as $player_id => $row ):
if ( ! $player_id )
continue;
$name = get_the_title( $player_id );
if ( ! $name )
continue;
echo '<tr class="' . sp_array_value( $row, 'status', 'lineup' ) . ' ' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
$number = sp_array_value( $row, 'number', '&nbsp;' );
// Player number
echo '<td class="data-number">' . $number . '</td>';
if ( $link_posts ):
$permalink = get_post_permalink( $player_id );
$name = '<a href="' . $permalink . '">' . $name . '</a>';
if ( isset( $row['status'] ) && $row['status'] == 'sub' ):
$name = '(' . $name . ')';
endif;
endif;
if ( array_key_exists( $player_id, $lineup_sub_relation ) ):
$name .= ' <span class="sub-in" title="' . get_the_title( $lineup_sub_relation[ $player_id ] ) . '">' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . '</span>';
elseif ( isset( $row['sub'] ) && $row['sub'] ):
$name .= ' <span class="sub-out" title="' . get_the_title( $row[ 'sub' ] ) . '">' . sp_array_value( sp_array_value( $data, $row['sub'], array() ), 'number', null ) . '</span>';
endif;
echo '<td class="data-name">' . $name . '</td>';
foreach( $labels as $key => $label ):
if ( $key == 'name' )
$lineup_sub_relation = array();
foreach ( $subs as $sub_id => $sub ):
if ( ! $sub_id )
continue;
if ( $key == 'position' ):
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$position = get_term_by( 'id', $row[ $key ], 'sp_position' );
$value = $position->name;
else:
$value = '&mdash;';
endif;
else:
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$value = $row[ $key ];
else:
$value = 0;
endif;
endif;
if ( ! array_key_exists( $key, $totals ) ):
$totals[ $key ] = 0;
endif;
$totals[ $key ] += $value;
echo '<td class="data-' . $key . '">' . $value . '</td>';
$lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id;
endforeach;
echo '</tr>';
$i = 0;
foreach( $data as $player_id => $row ):
$i++;
endforeach;
?>
</tbody>
<?php endif; ?>
<?php if ( $status == 'results' && array_key_exists( 0, $data ) ): ?>
<<?php echo ( $show_players && $has_players ? 'tfoot' : 'tbody' ); ?>>
<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">
<?php
if ( $has_players ):
echo '<td class="data-number">&nbsp;</td>';
echo '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
endif;
$row = $data[0];
foreach( $labels as $key => $label ):
if ( $key == 'name' )
if ( ! $player_id )
continue;
if ( $key == 'position' ):
$value = '&mdash;';
elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$value = $row[ $key ];
else:
$value = sp_array_value( $totals, $key, 0 );
$name = get_the_title( $player_id );
if ( ! $name )
continue;
echo '<tr class="' . sp_array_value( $row, 'status', 'lineup' ) . ' ' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
$number = sp_array_value( $row, 'number', '&nbsp;' );
// Player number
echo '<td class="data-number">' . $number . '</td>';
if ( $link_posts ):
$permalink = get_post_permalink( $player_id );
$name = '<a href="' . $permalink . '">' . $name . '</a>';
if ( isset( $row['status'] ) && $row['status'] == 'sub' ):
$name = '(' . $name . ')';
endif;
endif;
echo '<td class="data-' . $key . '">' . $value . '</td>';
if ( array_key_exists( $player_id, $lineup_sub_relation ) ):
$name .= ' <span class="sub-in" title="' . get_the_title( $lineup_sub_relation[ $player_id ] ) . '">' . sp_array_value( sp_array_value( $data, $lineup_sub_relation[ $player_id ], array() ), 'number', null ) . '</span>';
elseif ( isset( $row['sub'] ) && $row['sub'] ):
$name .= ' <span class="sub-out" title="' . get_the_title( $row[ 'sub' ] ) . '">' . sp_array_value( sp_array_value( $data, $row['sub'], array() ), 'number', null ) . '</span>';
endif;
echo '<td class="data-name">' . $name . '</td>';
foreach( $labels as $key => $label ):
if ( $key == 'name' )
continue;
if ( $key == 'position' ):
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$position = get_term_by( 'id', $row[ $key ], 'sp_position' );
$value = $position->name;
else:
$value = '&mdash;';
endif;
else:
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$value = $row[ $key ];
else:
$value = 0;
endif;
endif;
if ( ! array_key_exists( $key, $totals ) ):
$totals[ $key ] = 0;
endif;
$totals[ $key ] += $value;
echo '<td class="data-' . $key . '">' . $value . '</td>';
endforeach;
echo '</tr>';
$i++;
endforeach;
?>
</tr>
</<?php echo ( $has_players ? 'tfoot' : 'tbody' ); ?>>
<?php endif; ?>
</table>
</div>
<?php
endforeach;
</tbody>
<?php endif; ?>
<?php if ( $status == 'results' && array_key_exists( 0, $data ) ): ?>
<<?php echo ( $show_players && $has_players ? 'tfoot' : 'tbody' ); ?>>
<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">
<?php
if ( $has_players ):
echo '<td class="data-number">&nbsp;</td>';
echo '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
endif;
$row = $data[0];
foreach( $labels as $key => $label ):
if ( $key == 'name' )
continue;
if ( $key == 'position' ):
$value = '&mdash;';
elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$value = $row[ $key ];
else:
$value = sp_array_value( $totals, $key, 0 );
endif;
echo '<td class="data-' . $key . '">' . $value . '</td>';
endforeach;
?>
</tr>
</<?php echo ( $has_players ? 'tfoot' : 'tbody' ); ?>>
<?php endif; ?>
</table>
</div>
<?php
endforeach;
endif;