Use ajax for shortcode generator menu in editor

This commit is contained in:
Brian Miyaji
2014-07-13 03:43:38 +10:00
parent bfb06c64bc
commit 45b7aa5275
10 changed files with 850 additions and 628 deletions

View File

@@ -8,23 +8,6 @@
icon: false,
type: 'menubutton',
menu: [
{
text: ed.getLang( 'sportspress.countdown' ),
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' ),
menu: [
@@ -34,111 +17,73 @@
{
text: ed.getLang( 'sportspress.details' ),
onclick: function() {
editor.insertContent( '[event_details id=""]' );
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( ed.getLang( 'sportspress.event' ) + ' - ' + ed.getLang( 'sportspress.details' ), 'admin-ajax.php?action=sportspress_event_details_shortcode&width=' + W + '&height=' + H );
}
},
{
text: ed.getLang( 'sportspress.results' ),
onclick: function() {
editor.insertContent( '[event_results id=""]' );
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( ed.getLang( 'sportspress.event' ) + ' - ' + ed.getLang( 'sportspress.results' ), 'admin-ajax.php?action=sportspress_event_results_shortcode&width=' + W + '&height=' + H );
}
},
{
text: ed.getLang( 'sportspress.performance' ),
onclick: function() {
editor.insertContent( '[event_performance id=""]' );
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( ed.getLang( 'sportspress.event' ) + ' - ' + ed.getLang( 'sportspress.performance' ), 'admin-ajax.php?action=sportspress_event_performance_shortcode&width=' + W + '&height=' + H );
}
}
]
},
{
text: ed.getLang( 'sportspress.countdown' ),
onclick: function() {
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( ed.getLang( 'sportspress.event' ) + ' - ' + ed.getLang( 'sportspress.countdown' ), 'admin-ajax.php?action=sportspress_countdown_shortcode&width=' + W + '&height=' + H );
}
},
{
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' );
tb_show( ed.getLang( 'sportspress.event' ) + ' - ' + ed.getLang( 'sportspress.calendar' ), 'admin-ajax.php?action=sportspress_event_calendar_shortcode&width=' + W + '&height=' + H );
}
},
{
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' );
tb_show( ed.getLang( 'sportspress.event' ) + ' - ' + ed.getLang( 'sportspress.list' ), 'admin-ajax.php?action=sportspress_event_list_shortcode&width=' + W + '&height=' + H );
}
},
{
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' ),
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"]' );
tb_show( ed.getLang( 'sportspress.event' ) + ' - ' + ed.getLang( 'sportspress.blocks' ), 'admin-ajax.php?action=sportspress_event_blocks_shortcode&width=' + W + '&height=' + H );
}
}
]
@@ -152,62 +97,58 @@
{
text: ed.getLang( 'sportspress.details' ),
onclick: function() {
editor.insertContent( '[player_details id=""]' );
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( ed.getLang( 'sportspress.player' ) + ' - ' + ed.getLang( 'sportspress.details' ), 'admin-ajax.php?action=sportspress_player_details_shortcode&width=' + W + '&height=' + H );
}
},
{
text: ed.getLang( 'sportspress.statistics' ),
onclick: function() {
editor.insertContent( '[player_statistics id=""]' );
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( ed.getLang( 'sportspress.player' ) + ' - ' + ed.getLang( 'sportspress.statistics' ), 'admin-ajax.php?action=sportspress_player_statistics_shortcode&width=' + W + '&height=' + H );
}
}
]
},
{
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' );
tb_show( ed.getLang( 'sportspress.player' ) + ' - ' + ed.getLang( 'sportspress.list' ), 'admin-ajax.php?action=sportspress_player_list_shortcode&width=' + W + '&height=' + H );
}
},
{
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' );
tb_show( ed.getLang( 'sportspress.player' ) + ' - ' + ed.getLang( 'sportspress.gallery' ), 'admin-ajax.php?action=sportspress_player_gallery_shortcode&width=' + W + '&height=' + H );
}
}
]
},
{
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"]' );
text: ed.getLang( 'sportspress.league_table' ),
onclick : function() {
// triggers the thickbox
var width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
W = W - 80;
H = H - 84;
tb_show( ed.getLang( 'sportspress.league_table' ), 'admin-ajax.php?action=sportspress_league_table_shortcode&width=' + W + '&height=' + H );
}
}
]
}
]
}
]
});
});
})();

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 1.1.6
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 1.1
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

View File

@@ -1,483 +0,0 @@
<?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

@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 0.7
* @version 1.2
*/
class SP_Admin {
@@ -45,7 +45,6 @@ class SP_Admin {
if ( get_option( 'sportspress_rich_editing', true ) ):
include( 'class-sp-admin-editor.php' );
include( 'class-sp-admin-thickbox.php' );
endif;
// Help

View File

@@ -7,7 +7,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta_Boxes
* @version 1.1.4
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

754
includes/class-sp-ajax.php Normal file
View File

@@ -0,0 +1,754 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SportsPress SP_AJAX
*
* AJAX Event Handler
*
* @class SP_AJAX
* @version 1.2
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy
*/
class SP_AJAX {
/**
* Hook into ajax events
*/
public function __construct() {
// sportspress_EVENT => nopriv
$ajax_events = array(
'countdown_shortcode' => false,
'event_details_shortcode' => false,
'event_results_shortcode' => false,
'event_performance_shortcode' => false,
'event_calendar_shortcode' => false,
'event_list_shortcode' => false,
'event_blocks_shortcode' => false,
'league_table_shortcode' => false,
'player_details_shortcode' => false,
'player_statistics_shortcode' => false,
'player_list_shortcode' => false,
'player_gallery_shortcode' => false,
);
foreach ( $ajax_events as $ajax_event => $nopriv ) {
add_action( 'wp_ajax_sportspress_' . $ajax_event, array( $this, $ajax_event ) );
if ( $nopriv ) {
add_action( 'wp_ajax_nopriv_sportspress_' . $ajax_event, array( $this, $ajax_event ) );
}
}
}
/**
* AJAX countdown shortcode
*/
public function countdown_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_calendar">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_event',
'name' => 'id',
'values' => 'ID',
'show_option_all' => __( '(Auto)', 'sportspress' ),
'show_dates' => true,
'post_status' => 'future',
);
sp_dropdown_pages( $args );
?>
</label>
</p>
<p>
<label>
<input class="checkbox" type="checkbox" name="show_venue">
<?php _e( 'Display venue', 'sportspress' ); ?>
</label>
</p>
<p>
<label>
<input class="checkbox" type="checkbox" name="show_league">
<?php _e( 'Display league', 'sportspress' ); ?>
</label>
</p>
<p class="submit">
<input type="button" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('countdown');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
<?php
self::scripts();
die();
}
/**
* AJAX event_details shortcode
*/
public function event_details_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_details">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_event',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
?>
</label>
</p>
<p class="submit">
<input type="button" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('event_details');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
<?php
self::scripts();
die();
}
/**
* AJAX event_results shortcode
*/
public function event_results_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_results">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_event',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
?>
</label>
</p>
<p class="submit">
<input type="button" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('event_results');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
<?php
self::scripts();
die();
}
/**
* AJAX event_performance shortcode
*/
public function event_performance_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_performance">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Event', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_event',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
?>
</label>
</p>
<p class="submit">
<input type="button" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('event_performance');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
<?php
self::scripts();
die();
}
/**
* AJAX event_calendar shortcode
*/
public function event_calendar_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_calendar">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_calendar',
'name' => 'id',
'values' => 'ID',
'show_option_all' => __( 'All', 'sportspress' ),
);
sp_dropdown_pages( $args );
?>
</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" 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>
<?php
self::scripts();
die();
}
/**
* AJAX event_list shortcode
*/
public function event_list_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_list">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_calendar',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
?>
</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" 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>
<?php
self::scripts();
die();
}
/**
* AJAX event_blocks shortcode
*/
public function event_blocks_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-event_blocks">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Calendar', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_calendar',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
?>
</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" 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>
<?php
self::scripts();
die();
}
/**
* AJAX league_table shortcode
*/
public function league_table_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-league_table">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'League Table', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_table',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
?>
</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" 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>
<?php
self::scripts();
die();
}
/**
* AJAX player_details shortcode
*/
public function player_details_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-player_details">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_player',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
?>
</label>
</p>
<p class="submit">
<input type="button" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('player_details');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
<?php
self::scripts();
die();
}
/**
* AJAX player_statistics shortcode
*/
public function player_statistics_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-player_statistics">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_player',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
?>
</label>
</p>
<p class="submit">
<input type="button" class="button-primary" value="<?php echo sprintf( __( 'Insert %s', 'sportspress' ), __( 'Shortcode', 'sportspress' ) ); ?>" onclick="insertSportsPress('player_statistics');" />
<a class="button-secondary" onclick="tb_remove();" title="<?php _e( 'Cancel', 'sportspress' ); ?>"><?php _e( 'Cancel', 'sportspress' ); ?></a>
</p>
</div>
<?php
self::scripts();
die();
}
/**
* AJAX player_list shortcode
*/
public function player_list_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-player_list">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player List', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_list',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
?>
</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
$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 );
?>
</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" 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>
<?php
self::scripts();
die();
}
/**
* AJAX player_gallery shortcode
*/
public function player_gallery_shortcode() {
?>
<div class="wrap sp-thickbox-content" id="sp-thickbox-player_gallery">
<p>
<label>
<?php printf( __( 'Select %s:', 'sportspress' ), __( 'Player List', 'sportspress' ) ); ?>
<?php
$args = array(
'post_type' => 'sp_list',
'name' => 'id',
'values' => 'ID',
);
sp_dropdown_pages( $args );
?>
</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
$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 );
?>
</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" 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>
<?php
self::scripts();
die();
}
public function scripts() {
?>
<script type="text/javascript">
function insertSportsPress( type ) {
var $div = jQuery('.sp-thickbox-content');
// Initialize shortcode arguments
var args = {};
// Add ID if available and not 0
id = $div.find('[name=id]').val();
if ( id != 0 ) args.id = id;
// Extract args based on type
if ( 'countdown' == type ) {
args.show_venue = $div.find('[name=show_venue]:checked').length;
args.show_league = $div.find('[name=show_league]:checked').length;
} else if ( 'event_calendar' == type ) {
args.status = $div.find('[name=status]').val();
args.show_all_events_link = $div.find('[name=show_all_events_link]:checked').length;
} 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]:checked').length;
} 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]:checked').length;
} 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]:checked').length;
args.show_full_table_link = $div.find('[name=show_full_table_link]:checked').length;
} 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]:checked').length;
} 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]:checked').length;
args.show_names_on_hover = $div.find('[name=show_names_on_hover]:checked').length;
}
// 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
}
}
new SP_AJAX();

View File

@@ -5,7 +5,7 @@
* The SportsPress event class handles individual event data.
*
* @class SP_Event
* @version 1.1
* @version 1.2
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy

View File

@@ -3,7 +3,7 @@
* SP_Shortcodes class.
*
* @class SP_Shortcodes
* @version 0.7
* @version 1.2
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy

View File

@@ -204,6 +204,10 @@ final class SportsPress {
include_once( 'includes/admin/class-sp-admin.php' );
}
if ( defined( 'DOING_AJAX' ) ) {
$this->ajax_includes();
}
if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
$this->frontend_includes();
}
@@ -225,6 +229,13 @@ final class SportsPress {
include_once( 'includes/class-sp-wpml.php' );
}
/**
* Include required ajax files.
*/
public function ajax_includes() {
include_once( 'includes/class-sp-ajax.php' ); // Ajax functions for admin and the front-end
}
/**
* Include required frontend files.
*/