Begin SportsPress
Add basic helpers, post types and taxonomies.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -12,3 +12,6 @@ wp-content/cache/
|
||||
wp-content/backups/
|
||||
sitemap.xml
|
||||
sitemap.xml.gz
|
||||
.DS_STORE
|
||||
psd/
|
||||
demo/
|
||||
77
calendar.php
Normal file
77
calendar.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
function sp_calendar_cpt_init() {
|
||||
$name = __( 'Calendars', 'sportspress' );
|
||||
$singular_name = __( 'Calendar', 'sportspress' );
|
||||
$labels = sp_get_cpt_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
|
||||
'rewrite' => array( 'slug' => 'calendar' ),
|
||||
);
|
||||
register_post_type( 'sp_calendar', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_calendar_cpt_init' );
|
||||
|
||||
function sp_calendar_edit_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_calendar_columns', 'sp_calendar_edit_columns' );
|
||||
|
||||
function sp_calendar_custom_columns( $column ) {
|
||||
global $post, $post_id, $typenow;
|
||||
if ( $typenow == 'sp_calendar' ):
|
||||
switch ($column):
|
||||
case 'sp_team':
|
||||
echo 'TEAMS';
|
||||
break;
|
||||
case 'sp_league':
|
||||
the_terms( $post_id, 'sp_league' );
|
||||
break;
|
||||
case 'sp_season':
|
||||
the_terms( $post_id, 'sp_season' );
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
}
|
||||
add_action( 'manage_posts_custom_column', 'sp_calendar_custom_columns' );
|
||||
|
||||
function sp_calendar_request_filter_dropdowns() {
|
||||
global $typenow, $wp_query;
|
||||
if ( $typenow == 'sp_calendar' ) {
|
||||
|
||||
// Leagues
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Seasons
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'sp_calendar_request_filter_dropdowns' );
|
||||
?>
|
||||
14
defaults.php
Normal file
14
defaults.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
$sp_options = array(
|
||||
'settings' => array(
|
||||
'sp_event_team_count' => 2,
|
||||
),
|
||||
);
|
||||
|
||||
foreach( $sp_options as $optiongroupkey => $optiongroup ) {
|
||||
foreach( $optiongroup as $key => $value ) {
|
||||
if ( get_option( $key ) === false )
|
||||
update_option( $key, $value );
|
||||
}
|
||||
}
|
||||
?>
|
||||
319
event.php
Normal file
319
event.php
Normal file
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
function sp_event_cpt_init() {
|
||||
$name = __( 'Events', 'sportspress' );
|
||||
$singular_name = __( 'Event', 'sportspress' );
|
||||
$labels = sp_get_cpt_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'author', 'comments', 'page-attributes' ),
|
||||
'register_meta_box_cb' => 'sp_event_meta_init',
|
||||
'rewrite' => array( 'slug' => 'event' ),
|
||||
);
|
||||
register_post_type( 'sp_event', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_event_cpt_init' );
|
||||
|
||||
function sp_event_display_scheduled( $posts ) {
|
||||
global $wp_query, $wpdb;
|
||||
if ( is_single() && $wp_query->post_count == 0 && isset( $wp_query->query_vars['sp_event'] )) {
|
||||
$posts = $wpdb->get_results( $wp_query->request );
|
||||
}
|
||||
return $posts;
|
||||
}
|
||||
add_filter( 'the_posts', 'sp_event_display_scheduled' );
|
||||
|
||||
function sp_event_text_replace( $input, $text, $domain ) {
|
||||
global $post;
|
||||
if ( is_admin() && get_post_type( $post ) == 'sp_event' )
|
||||
switch ( $text ):
|
||||
case 'Scheduled for: <b>%1$s</b>':
|
||||
return __( 'Kick-off: <b>%1$s</b>', 'sportspress' );
|
||||
break;
|
||||
case 'Published on: <b>%1$s</b>':
|
||||
return __( 'Kick-off: <b>%1$s</b>', 'sportspress' );
|
||||
break;
|
||||
case 'Publish <b>immediately</b>':
|
||||
return __( 'Kick-off: <b>%1$s</b>', 'sportspress' );
|
||||
break;
|
||||
default:
|
||||
return $input;
|
||||
endswitch;
|
||||
return $input;
|
||||
}
|
||||
add_filter( 'gettext', 'sp_event_text_replace', 20, 3 );
|
||||
|
||||
function sp_event_meta_init() {
|
||||
add_meta_box(
|
||||
'sp_teamdiv',
|
||||
__( 'Teams', 'sportspress' ),
|
||||
'sp_event_team_meta',
|
||||
'sp_event',
|
||||
'normal',
|
||||
'high'
|
||||
);
|
||||
add_meta_box(
|
||||
'sp_articlediv',
|
||||
__( 'Article', 'sportspress' ),
|
||||
'sp_event_article_meta',
|
||||
'sp_event',
|
||||
'normal',
|
||||
'high'
|
||||
);
|
||||
}
|
||||
|
||||
function sp_event_team_meta( $post, $metabox ) {
|
||||
global $post_id;
|
||||
$limit = get_option( 'sp_event_team_count' );
|
||||
for ( $i = 1; $i <= $limit; $i++ ):
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sportspress[sp_team_' . $i . ']',
|
||||
'selected' => get_post_meta( $post_id, 'sp_team_' . $i, true ),
|
||||
);
|
||||
echo '<label for="sp_team_' . $i . '">' . __( 'Team', 'sportspress' ) . ' ' . $i . ':</label>' . PHP_EOL;
|
||||
wp_dropdown_pages( $args );
|
||||
/*
|
||||
$players = unserialize( get_post_meta( $post_id, 'sp_players', true ) );
|
||||
?>
|
||||
<div class="categorydiv" id="sp_team_<?php echo $i; ?>">
|
||||
<ul class="tb_stats-tabs category-tabs">
|
||||
<li class="tabs"><a href="#tb_home_lineup" tabindex="3"><?php _e( 'Players', 'sportspress' ); ?></a></li>
|
||||
<li class="hide-if-no-js"><a href="#tb_home_subs" tabindex="3"><?php _e( 'Staff', 'sportspress' ); ?></a></li>
|
||||
</ul>
|
||||
<div id="tb_home_lineup" class="tabs-panel">
|
||||
<?php tb_match_player_stats_table( $players, $home_club, 'home', 'lineup' ); ?>
|
||||
</div>
|
||||
<div id="tb_home_subs" class="tabs-panel" style="display: none;">
|
||||
<?php tb_match_player_stats_table( $players, $home_club, 'home', 'subs' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="categorydiv" id="tb_away_players">
|
||||
<h4><?php _ex( 'Away', 'team', 'sportspress' ); ?></h4>
|
||||
<ul class="tb_stats-tabs category-tabs">
|
||||
<li class="tabs"><a href="#tb_away_lineup" tabindex="3"><?php _e( 'Players', 'sportspress' ); ?></a></li>
|
||||
<li class="hide-if-no-js"><a href="#tb_away_subs" tabindex="3"><?php _e( 'Staff', 'sportspress' ); ?></a></li>
|
||||
</ul>
|
||||
<div id="tb_away_lineup" class="tabs-panel">
|
||||
<?php tb_match_player_stats_table( $players, $away_club, 'away', 'lineup' ); ?>
|
||||
</div>
|
||||
<div id="tb_away_subs" class="tabs-panel" style="display: none;">
|
||||
<?php tb_match_player_stats_table( $players, $away_club, 'away', 'subs' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
// swap teams
|
||||
$('#tb_match-fixture-meta .tb-swap-teams-button').click(function() {
|
||||
// swap club buttons
|
||||
var home_button = $('#tb_home_club_button');
|
||||
var away_button = $('#tb_away_club_button');
|
||||
var temp = $(home_button).html();
|
||||
$(home_button).html($(away_button).html());
|
||||
$(away_button).html(temp);
|
||||
// swap club inputs
|
||||
var home_input = $('#tb_home_club');
|
||||
var away_input = $('#tb_away_club');
|
||||
var temp = $(home_input).val();
|
||||
$(home_input).val($(away_input).val());
|
||||
$(away_input).val(temp);
|
||||
});
|
||||
// stats tabs
|
||||
$('.tb_stats-tabs a').click(function(){
|
||||
var t = $(this).attr('href');
|
||||
$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
|
||||
$(this).parent().parent().parent().find('.tabs-panel').hide();
|
||||
$(t).show();
|
||||
return false;
|
||||
});
|
||||
$('#tb_match-players-meta table input[type="checkbox"]').live('change', function() {
|
||||
player_id = $(this).attr('data-player');
|
||||
$(this).closest('tr').find('input[type="number"]').prop('readonly', !$(this).prop('checked'));
|
||||
$(this).closest('tr').find('select').prop('disabled', !$(this).prop('checked'));
|
||||
});
|
||||
// update auto goals
|
||||
tb_update_auto_goals = function() {
|
||||
home_goals = 0;
|
||||
away_goals = 0;
|
||||
$('#tb_match-players-meta #tb_home_players table .goals input:not([readonly])').each(function() {
|
||||
home_goals += parseInt($(this).val());
|
||||
});
|
||||
$('#tb_match-players-meta #tb_away_players table .goals input:not([readonly])').each(function() {
|
||||
away_goals += parseInt($(this).val());
|
||||
});
|
||||
manual_home_goals = $('#tb_match-details-meta #results-table input#tb_goals_manual_home').val();
|
||||
manual_away_goals = $('#tb_match-details-meta #results-table input#tb_goals_manual_away').val();
|
||||
$('#tb_match-details-meta #results-table input#tb_goals_auto_home').val(home_goals);
|
||||
$('#tb_match-details-meta #results-table input#tb_goals_auto_away').val(away_goals);
|
||||
$('#tb_match-details-meta #results-table input#tb_goals_total_home').val(parseInt(home_goals) + parseInt(manual_home_goals));
|
||||
$('#tb_match-details-meta #results-table input#tb_goals_total_away').val(parseInt(away_goals) + parseInt(manual_away_goals));
|
||||
}
|
||||
$('#tb_match-players-meta table input[type="checkbox"]').live('click', function() {
|
||||
tb_update_auto_goals();
|
||||
});
|
||||
$('#tb_match-details-meta #results-table input, #tb_match-players-meta table .goals input, #tb_match-players-meta table input[type="checkbox"]').live('change', function() {
|
||||
tb_update_auto_goals();
|
||||
});
|
||||
// refresh players list
|
||||
tb_refresh_players_lists = function(side) {
|
||||
tb_refresh_players_list(side, 'lineup');
|
||||
tb_refresh_players_list(side, 'subs');
|
||||
}
|
||||
tb_refresh_players_list = function(side, type) {
|
||||
nonce = '<?php echo wp_create_nonce('tb_players_nonce'); ?>';
|
||||
club = $('#tb_' + side + '_club').val();
|
||||
$.ajax({
|
||||
type : 'post',
|
||||
dataType : 'html',
|
||||
url : ajaxurl,
|
||||
data : {
|
||||
action: 'tb_players_table',
|
||||
nonce: nonce,
|
||||
club: club,
|
||||
side: side,
|
||||
type: type
|
||||
},
|
||||
success: function(response) {
|
||||
$('#tb_match-players-meta #tb_' + side + '_' + type).html(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
$('#tb_home_club').live('change', function() {
|
||||
tb_refresh_players_lists('home');
|
||||
})
|
||||
$('#tb_away_club').live('change', function() {
|
||||
tb_refresh_players_lists('away');
|
||||
})
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
*/
|
||||
endfor;
|
||||
echo '<input type="hidden" name="sp_event_team_nonce" id="sp_event_team_nonce" value="' . wp_create_nonce( plugin_basename( __FILE__ ) ) . '" />';
|
||||
}
|
||||
|
||||
function sp_event_article_meta( $post, $metabox ) {
|
||||
wp_editor( $post->post_content, 'content' );
|
||||
}
|
||||
|
||||
function sp_event_save() {
|
||||
global $post, $post_id, $typenow;
|
||||
if ( $typenow == 'sp_event' && isset( $_POST ) ) {
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id;
|
||||
if ( ! isset( $_POST['sp_event_team_nonce'] ) || ! wp_verify_nonce( $_POST['sp_event_team_nonce'], plugin_basename( __FILE__ ) ) ) return $post_id;
|
||||
$sportspress = (array)$_POST['sportspress'];
|
||||
foreach ( $sportspress as $key => $value ):
|
||||
update_post_meta( $post_id, $key, $value );
|
||||
endforeach;
|
||||
}
|
||||
}
|
||||
add_action( 'save_post', 'sp_event_save' );
|
||||
|
||||
function sp_event_edit_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Event', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_sponsor' => __( 'Sponsor', 'sportspress' ),
|
||||
'sp_kickoff' => __( 'Kick-off', 'sportspress' ),
|
||||
'date' => __( 'Date' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_event_columns', 'sp_event_edit_columns' );
|
||||
|
||||
function sp_event_custom_columns( $column, $post_id ) {
|
||||
global $typenow;
|
||||
if ( $typenow == 'sp_event' ):
|
||||
switch ( $column ):
|
||||
case 'sp_team':
|
||||
$limit = get_option( 'sp_event_team_count' );
|
||||
for ( $i = 1; $i <= $limit; $i++ ):
|
||||
$team = get_post_meta( $post_id, 'sp_team_' . $i, true );
|
||||
edit_post_link( get_the_title( $team ), '', '<br />', $team );
|
||||
endfor;
|
||||
break;
|
||||
case 'sp_league':
|
||||
the_terms( $post_id, 'sp_league' );
|
||||
break;
|
||||
case 'sp_season':
|
||||
the_terms( $post_id, 'sp_season' );
|
||||
break;
|
||||
case 'sp_sponsor':
|
||||
the_terms( $post_id, 'sp_sponsor' );
|
||||
break;
|
||||
case 'sp_kickoff':
|
||||
echo get_the_time ( get_option ( 'time_format' ) );
|
||||
break;
|
||||
case 'date':
|
||||
echo get_the_date ( get_option ( 'date_format' ) );
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
}
|
||||
add_action( 'manage_posts_custom_column', 'sp_event_custom_columns', 10, 2 );
|
||||
|
||||
/*
|
||||
function sp_event_edit_sortable_columns( $columns ) {
|
||||
$columns['sp_team'] = 'sp_team';
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_event_sortable_columns', 'sp_event_edit_sortable_columns' );
|
||||
|
||||
function sp_event_column_sorting( $vars ) {
|
||||
if( isset( $vars['orderby'] ) && 'sp_team' == $vars['orderby'] ){
|
||||
$vars = array_merge( $vars, array(
|
||||
'meta_key' => 'sp_team_1',
|
||||
'orderby' => 'meta_value'
|
||||
) );
|
||||
}
|
||||
return $vars;
|
||||
}
|
||||
add_filter('requests', 'sp_event_column_sorting');
|
||||
*/
|
||||
|
||||
function sp_event_request_filter_dropdowns() {
|
||||
global $typenow, $wp_query;
|
||||
if ( $typenow == 'sp_event' ) {
|
||||
|
||||
// Leagues
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Seasons
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Sponsors
|
||||
$selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_sponsor',
|
||||
'name' => 'sp_sponsor',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'sp_event_request_filter_dropdowns' );
|
||||
?>
|
||||
85
helpers.php
Normal file
85
helpers.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
if ( ! function_exists( 'sp_get_cpt_labels' ) ) {
|
||||
function sp_get_cpt_labels( $name, $singular_name ) {
|
||||
$labels = array(
|
||||
'name' => $name,
|
||||
'singular_name' => $singular_name,
|
||||
'all_items' => sprintf( __( 'All %s', 'sportspress' ), $name ),
|
||||
'add_new_item' => sprintf( __( 'Add New %s', 'sportspress' ), $singular_name ),
|
||||
'edit_item' => sprintf( __( 'Edit %s', 'sportspress' ), $singular_name ),
|
||||
'new_item' => sprintf( __( 'New %s', 'sportspress' ), $singular_name ),
|
||||
'view_item' => sprintf( __( 'View %s', 'sportspress' ), $singular_name ),
|
||||
'search_items' => sprintf( __( 'Search %s', 'sportspress' ), $name ),
|
||||
'not_found' => sprintf( __( 'No %s found', 'sportspress' ), $name ),
|
||||
'not_found_in_trash' => sprintf( __( 'No %s found in trash', 'sportspress' ), $name ),
|
||||
'parent_item_colon' => sprintf( __( 'Parent %s:', 'sportspress' ), $singular_name ),
|
||||
);
|
||||
return $labels;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'sp_get_tax_labels' ) ) {
|
||||
function sp_get_tax_labels( $name, $singular_name ) {
|
||||
$labels = array(
|
||||
'name' => __( $name, 'sportspress' ),
|
||||
'singular_name' => __( $singular_name, 'sportspress' ),
|
||||
'all_items' => sprintf( __( 'All %s', 'sportspress' ), __( $name, 'sportspress' ) ),
|
||||
'edit_item' => sprintf( __( 'Edit %s', 'sportspress' ), __( $singular_name, 'sportspress' ) ),
|
||||
'view_item' => sprintf( __( 'View %s', 'sportspress' ), __( $singular_name, 'sportspress' ) ),
|
||||
'update_item' => sprintf( __( 'Update %s', 'sportspress' ), __( $singular_name, 'sportspress' ) ),
|
||||
'add_new_item' => sprintf( __( 'Add New %s', 'sportspress' ), __( $singular_name, 'sportspress' ) ),
|
||||
'new_item_name' => __( $singular_name, 'sportspress' ),
|
||||
'parent_item' => sprintf( __( 'Parent %s', 'sportspress' ), __( $singular_name, 'sportspress' ) ),
|
||||
'parent_item_colon' => sprintf( __( 'Parent %s:', 'sportspress' ), __( $singular_name, 'sportspress' ) ),
|
||||
'search_items' => sprintf( __( 'Search %s', 'sportspress' ), __( $name, 'sportspress' ) ),
|
||||
'not_found' => sprintf( __( 'No %s found', 'sportspress' ), __( $name, 'sportspress' ) ),
|
||||
);
|
||||
return $labels;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'sp_dropdown_taxonomies' ) ) {
|
||||
function sp_dropdown_taxonomies( $args = array() ) {
|
||||
$defaults = array(
|
||||
'show_option_all' => false,
|
||||
'show_option_none' => false,
|
||||
'taxonomy' => null,
|
||||
'name' => null,
|
||||
'selected' => null,
|
||||
);
|
||||
$args = array_merge( $defaults, $args );
|
||||
$terms = get_terms( $args['taxonomy'] );
|
||||
$name = ( $args['name'] ) ? $args['name'] : $args['taxonomy'];
|
||||
if ( $terms ) {
|
||||
printf( '<select name="%s" class="postform">', $name );
|
||||
if ( $args['show_option_all'] ) {
|
||||
printf( '<option value="0">%s</option>', $args['show_option_all'] );
|
||||
}
|
||||
if ( $args['show_option_none'] ) {
|
||||
printf( '<option value="-1">%s</option>', $args['show_option_none'] );
|
||||
}
|
||||
foreach ( $terms as $term ) {
|
||||
printf( '<option value="%s" %s>%s</option>', $term->slug, selected( true, $args['selected'] == $term->slug ), $term->name );
|
||||
}
|
||||
print( '</select>' );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'sp_team_logo' ) ) {
|
||||
function sp_team_logo( $post_id = null ) {
|
||||
if ( ! isset( $post_id ) )
|
||||
global $post_id;
|
||||
if ( has_post_thumbnail( $post_id ) ):
|
||||
the_post_thumbnail( 'sp_icon' );
|
||||
else:
|
||||
$parents = get_post_ancestors( $post_id );
|
||||
foreach ( $parents as $parent ) {
|
||||
if( has_post_thumbnail( $parent ) ) {
|
||||
echo get_the_post_thumbnail( $parent, 'sp_icon');
|
||||
break;
|
||||
}
|
||||
}
|
||||
endif;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
BIN
images/menu.png
Normal file
BIN
images/menu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
languages/sportspress-ja.mo
Normal file
BIN
languages/sportspress-ja.mo
Normal file
Binary file not shown.
205
languages/sportspress-ja.po
Normal file
205
languages/sportspress-ja.po
Normal file
@@ -0,0 +1,205 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: SportsPress 0.1\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2013-07-24 00:16+1000\n"
|
||||
"PO-Revision-Date: 2013-07-24 02:54+1000\n"
|
||||
"Last-Translator: ThemeBoy <translate@themeboy.com>\n"
|
||||
"Language-Team: ThemeBoy <translate@themeboy.com>\n"
|
||||
"Language: ja\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e;_x;_ex\n"
|
||||
"X-Poedit-Basepath: .\n"
|
||||
"X-Generator: Poedit 1.5.7\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-SearchPath-0: ..\n"
|
||||
|
||||
#: ../calendar.php:3
|
||||
msgid "Calendars"
|
||||
msgstr "カレンダー"
|
||||
|
||||
#: ../calendar.php:4
|
||||
msgid "Calendar"
|
||||
msgstr "カレンダー"
|
||||
|
||||
#: ../calendar.php:21 ../table.php:21
|
||||
msgid "Title"
|
||||
msgstr "タイトル"
|
||||
|
||||
#: ../calendar.php:22 ../event.php:83 ../table.php:22 ../team.php:3
|
||||
msgid "Teams"
|
||||
msgstr "チーム"
|
||||
|
||||
#: ../calendar.php:23 ../event.php:84 ../league.php:4 ../player.php:24
|
||||
#: ../staff.php:24 ../table.php:23 ../team.php:42
|
||||
msgid "League"
|
||||
msgstr "リーグ"
|
||||
|
||||
#: ../calendar.php:24 ../event.php:85 ../player.php:25 ../season.php:4
|
||||
#: ../staff.php:25 ../table.php:24 ../team.php:43
|
||||
msgid "Season"
|
||||
msgstr "シーズン"
|
||||
|
||||
#: ../calendar.php:56 ../calendar.php:67 ../event.php:129 ../event.php:140
|
||||
#: ../event.php:151 ../helpers.php:7 ../helpers.php:26 ../player.php:61
|
||||
#: ../player.php:72 ../player.php:83 ../player.php:94 ../staff.php:57
|
||||
#: ../staff.php:68 ../staff.php:79 ../table.php:56 ../table.php:67
|
||||
#: ../team.php:76 ../team.php:87 ../team.php:98
|
||||
#, php-format
|
||||
msgid "All %s"
|
||||
msgstr "すべての%s"
|
||||
|
||||
#: ../calendar.php:56 ../event.php:129 ../league.php:3 ../player.php:72
|
||||
#: ../staff.php:68 ../table.php:56 ../team.php:76
|
||||
msgid "Leagues"
|
||||
msgstr "リーグ"
|
||||
|
||||
#: ../calendar.php:67 ../event.php:140 ../player.php:83 ../season.php:3
|
||||
#: ../staff.php:79 ../table.php:67 ../team.php:87
|
||||
msgid "Seasons"
|
||||
msgstr "シーズン"
|
||||
|
||||
#: ../event.php:3
|
||||
msgid "Events"
|
||||
msgstr "試合"
|
||||
|
||||
#: ../event.php:4 ../event.php:82
|
||||
msgid "Event"
|
||||
msgstr "試合"
|
||||
|
||||
#: ../event.php:33 ../event.php:36 ../event.php:39
|
||||
#, php-format
|
||||
msgid "Kick-off: <b>%1$s</b>"
|
||||
msgstr "キックオフ: <b>%1$s</b>"
|
||||
|
||||
#: ../event.php:52 ../player.php:23 ../staff.php:22 ../team.php:4
|
||||
#: ../team.php:41
|
||||
msgid "Team"
|
||||
msgstr "チーム"
|
||||
|
||||
#: ../event.php:62
|
||||
msgid "Article"
|
||||
msgstr "記事"
|
||||
|
||||
#: ../event.php:86 ../player.php:26 ../sponsor.php:4 ../team.php:44
|
||||
msgid "Sponsor"
|
||||
msgstr "スポンサー"
|
||||
|
||||
#: ../event.php:87
|
||||
msgid "Kick-off"
|
||||
msgstr "キックオフ"
|
||||
|
||||
#: ../event.php:88
|
||||
msgid "Date"
|
||||
msgstr "日付"
|
||||
|
||||
#: ../event.php:151 ../player.php:94 ../sponsor.php:3 ../team.php:98
|
||||
msgid "Sponsors"
|
||||
msgstr "スポンサー"
|
||||
|
||||
#: ../helpers.php:8 ../helpers.php:30 ../team.php:26 ../team.php:29
|
||||
#, php-format
|
||||
msgid "Add New %s"
|
||||
msgstr "新規%sを追加"
|
||||
|
||||
#: ../helpers.php:9 ../helpers.php:27
|
||||
#, php-format
|
||||
msgid "Edit %s"
|
||||
msgstr "%sを編集"
|
||||
|
||||
#: ../helpers.php:10
|
||||
#, php-format
|
||||
msgid "New %s"
|
||||
msgstr "新規%s"
|
||||
|
||||
#: ../helpers.php:11 ../helpers.php:28
|
||||
#, php-format
|
||||
msgid "View %s"
|
||||
msgstr "%sを表示"
|
||||
|
||||
#: ../helpers.php:12 ../helpers.php:34
|
||||
#, php-format
|
||||
msgid "Search %s"
|
||||
msgstr "%sを検索"
|
||||
|
||||
#: ../helpers.php:13 ../helpers.php:35
|
||||
#, php-format
|
||||
msgid "No %s found"
|
||||
msgstr "%sは見つかりませんでした"
|
||||
|
||||
#: ../helpers.php:14
|
||||
#, php-format
|
||||
msgid "No %s found in trash"
|
||||
msgstr "ゴミ箱内に%sは見つかりませんでした。"
|
||||
|
||||
#: ../helpers.php:15 ../helpers.php:33
|
||||
#, php-format
|
||||
msgid "Parent %s:"
|
||||
msgstr "親%s:"
|
||||
|
||||
#: ../helpers.php:29
|
||||
#, php-format
|
||||
msgid "Update %s"
|
||||
msgstr "%sを更新"
|
||||
|
||||
#: ../helpers.php:32
|
||||
#, php-format
|
||||
msgid "Parent %s"
|
||||
msgstr "親%s"
|
||||
|
||||
#: ../player.php:3
|
||||
msgid "Players"
|
||||
msgstr "選手"
|
||||
|
||||
#: ../player.php:4
|
||||
msgid "Player"
|
||||
msgstr "選手"
|
||||
|
||||
#: ../player.php:21 ../staff.php:21
|
||||
msgid "Name"
|
||||
msgstr "名前"
|
||||
|
||||
#: ../player.php:22 ../position.php:4 ../staff.php:23
|
||||
msgid "Position"
|
||||
msgstr "ポジション"
|
||||
|
||||
#: ../player.php:61 ../position.php:3 ../staff.php:57
|
||||
msgid "Positions"
|
||||
msgstr "ポジション"
|
||||
|
||||
#: ../staff.php:3 ../staff.php:4
|
||||
msgid "Staff"
|
||||
msgstr "スタッフ"
|
||||
|
||||
#: ../table.php:3
|
||||
msgid "Tables"
|
||||
msgstr "順位表"
|
||||
|
||||
#: ../table.php:4
|
||||
msgid "Table"
|
||||
msgstr "順位表"
|
||||
|
||||
#: ../team.php:23 ../team.php:26 ../team.php:29
|
||||
msgid "Logo"
|
||||
msgstr "ロゴ"
|
||||
|
||||
#: ../tournament.php:3
|
||||
msgid "Tournaments"
|
||||
msgstr "大会"
|
||||
|
||||
#: ../tournament.php:4
|
||||
msgid "Tournament"
|
||||
msgstr "大会"
|
||||
|
||||
#: ../venue.php:3
|
||||
msgid "Venues"
|
||||
msgstr "会場"
|
||||
|
||||
#: ../venue.php:4
|
||||
msgid "Venue"
|
||||
msgstr "会場"
|
||||
|
||||
#~ msgid "League Table"
|
||||
#~ msgstr "順位表"
|
||||
17
league.php
Normal file
17
league.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
function sp_league_tax_init() {
|
||||
$name = __( 'Leagues', 'sportspress' );
|
||||
$singular_name = __( 'League', 'sportspress' );
|
||||
$object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_calendar' );
|
||||
$labels = sp_get_tax_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => 'league' ),
|
||||
);
|
||||
register_taxonomy( 'sp_league', $object_type, $args );
|
||||
}
|
||||
add_action( 'init', 'sp_league_tax_init' );
|
||||
?>
|
||||
107
player.php
Normal file
107
player.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
function sp_player_cpt_init() {
|
||||
$name = __( 'Players', 'sportspress' );
|
||||
$singular_name = __( 'Player', 'sportspress' );
|
||||
$labels = sp_get_cpt_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
|
||||
'rewrite' => array( 'slug' => 'player' ),
|
||||
);
|
||||
register_post_type( 'sp_player', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_player_cpt_init' );
|
||||
|
||||
function sp_player_edit_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_icon' => ' ',
|
||||
'title' => __( 'Name', 'sportspress' ),
|
||||
'sp_position' => __( 'Position', 'sportspress' ),
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_sponsor' => __( 'Sponsor', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_player_columns', 'sp_player_edit_columns' );
|
||||
|
||||
function sp_player_custom_columns( $column ) {
|
||||
global $post, $post_id, $typenow;
|
||||
if ( $typenow == 'sp_player' ):
|
||||
switch ($column):
|
||||
case 'sp_icon':
|
||||
if ( has_post_thumbnail() ) the_post_thumbnail( 'sp_icon' );
|
||||
break;
|
||||
case 'sp_position':
|
||||
the_terms( $post_id, 'sp_position' );
|
||||
break;
|
||||
case 'sp_league':
|
||||
the_terms( $post_id, 'sp_league' );
|
||||
break;
|
||||
case 'sp_season':
|
||||
the_terms( $post_id, 'sp_season' );
|
||||
break;
|
||||
case 'sp_sponsor':
|
||||
the_terms( $post_id, 'sp_sponsor' );
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
}
|
||||
add_action( 'manage_posts_custom_column', 'sp_player_custom_columns' );
|
||||
|
||||
function sp_player_request_filter_dropdowns() {
|
||||
global $typenow, $wp_query;
|
||||
if ( $typenow == 'sp_player' ) {
|
||||
|
||||
// Positions
|
||||
$selected = isset( $_REQUEST['sp_position'] ) ? $_REQUEST['sp_position'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'sp_position',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Leagues
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Seasons
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Sponsors
|
||||
$selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_sponsor',
|
||||
'name' => 'sp_sponsor',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'sp_player_request_filter_dropdowns' );
|
||||
?>
|
||||
17
position.php
Normal file
17
position.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
function sp_position_tax_init() {
|
||||
$name = __( 'Positions', 'sportspress' );
|
||||
$singular_name = __( 'Position', 'sportspress' );
|
||||
$object_type = array( 'sp_player', 'sp_staff' );
|
||||
$labels = sp_get_tax_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => 'position' ),
|
||||
);
|
||||
register_taxonomy( 'sp_position', $object_type, $args );
|
||||
}
|
||||
add_action( 'init', 'sp_position_tax_init' );
|
||||
?>
|
||||
17
season.php
Normal file
17
season.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
function sp_season_tax_init() {
|
||||
$name = __( 'Seasons', 'sportspress' );
|
||||
$singular_name = __( 'Season', 'sportspress' );
|
||||
$object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_calendar' );
|
||||
$labels = sp_get_tax_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => 'season' ),
|
||||
);
|
||||
register_taxonomy( 'sp_season', $object_type, $args );
|
||||
}
|
||||
add_action( 'init', 'sp_season_tax_init' );
|
||||
?>
|
||||
113
settings.php
Normal file
113
settings.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
function sp_settings_menu() {
|
||||
add_submenu_page(
|
||||
'options-general.php',
|
||||
__( 'SportsPress', 'sportspress' ),
|
||||
__( 'Sportspress', 'sportspress' ),
|
||||
'manage_options',
|
||||
'sp_settings',
|
||||
'sp_settings_page'
|
||||
);
|
||||
}
|
||||
add_action('admin_menu', 'sp_settings_menu');
|
||||
|
||||
function sp_settings_page() {
|
||||
if ( true | ! current_user_can( 'manage_options' ) ) wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
||||
$hidden_field_name = 'tb_submit_hidden';
|
||||
?>
|
||||
<div class="wrap">
|
||||
<div id="icon-options-general" class="icon32"><br></div>
|
||||
<h2><?php _e('General Settings', 'sportspress'); ?></h2>
|
||||
<?php
|
||||
if( isset( $_POST[ $hidden_field_name ] ) && $_POST[ $hidden_field_name ] == 'Y' ) {
|
||||
global $tb_option_fields;
|
||||
foreach( $tb_option_fields['settings'] as $option_field => $value ) {
|
||||
$new_value = isset( $_POST[$option_field] ) ? $_POST[$option_field] : null;
|
||||
update_option( $option_field, stripslashes( $new_value ) );
|
||||
}
|
||||
?>
|
||||
<div id="message" class="updated"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<form name="sportspress_form" method="post" action="">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e( 'Home Team', 'sportspress' ); ?></th>
|
||||
<td>
|
||||
<?php $option_slug = 'tb_default_club'; ?>
|
||||
<?php
|
||||
tb_dropdown_posts( array(
|
||||
'post_type' => 'tb_club',
|
||||
'limit' => -1,
|
||||
'show_option_none' => __( 'None' ),
|
||||
'selected' => get_option( $option_slug ),
|
||||
'name' => $option_slug,
|
||||
'id' => $option_slug
|
||||
) );
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row"><label for="tb_region_code"><?php _e( 'Country', 'sportspress' ); ?></label></th>
|
||||
<td>
|
||||
<?php
|
||||
global $tb_countries_of_the_world;
|
||||
asort( $tb_countries_of_the_world );
|
||||
echo form_dropdown( 'tb_region_code', $tb_countries_of_the_world, get_option( 'tb_region_code' ) );
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e( 'Header' ); ?></th>
|
||||
<td>
|
||||
<?php $option_slug = 'tb_header_sponsor'; ?>
|
||||
<label for="<?php echo $option_slug; ?>"><?php _e( 'Sponsor', 'sportspress' ); ?> 1:</label>
|
||||
<?php
|
||||
tb_dropdown_posts( array(
|
||||
'post_type' => 'tb_sponsor',
|
||||
'limit' => -1,
|
||||
'show_option_none' => __( 'None' ),
|
||||
'selected' => get_option( $option_slug ),
|
||||
'name' => $option_slug,
|
||||
'id' => $option_slug
|
||||
) );
|
||||
?><br />
|
||||
<?php $option_slug = 'tb_header_sponsor_2'; ?>
|
||||
<label for="<?php echo $option_slug; ?>"><?php _e( 'Sponsor', 'sportspress' ); ?> 2:</label>
|
||||
<?php
|
||||
tb_dropdown_posts( array(
|
||||
'post_type' => 'tb_sponsor',
|
||||
'limit' => -1,
|
||||
'show_option_none' => __( 'None' ),
|
||||
'selected' => get_option( $option_slug ),
|
||||
'name' => $option_slug,
|
||||
'id' => $option_slug
|
||||
) );
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e( 'Footer' ); ?></th>
|
||||
<td>
|
||||
<?php $option_slug = 'tb_footer_show_sponsors'; ?>
|
||||
<input name="<?php echo $option_slug; ?>" type="checkbox" id="<?php echo $option_slug; ?>" value="1"<?php if( get_option( $option_slug ) ) echo ' checked' ?> />
|
||||
<label for="<?php echo $option_slug; ?>"><?php _e( 'Sponsors', 'sportspress' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e( 'Layout' ); ?></th>
|
||||
<td>
|
||||
<?php $option_slug = 'tb_responsive'; ?>
|
||||
<input name="<?php echo $option_slug; ?>" type="checkbox" id="<?php echo $option_slug; ?>" value="1"<?php if( get_option( $option_slug ) ) echo ' checked' ?> />
|
||||
<label for="<?php echo $option_slug; ?>"><?php _e( 'Responsive', 'sportspress' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
|
||||
<?php submit_button( null, 'primary', 'save-sportspress-options' ); ?>
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
17
sponsor.php
Normal file
17
sponsor.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
function sp_sponsor_tax_init() {
|
||||
$name = __( 'Sponsors', 'sportspress' );
|
||||
$singular_name = __( 'Sponsor', 'sportspress' );
|
||||
$object_type = array( 'sp_team', 'sp_event', 'sp_player', 'sp_tournament', 'sp_venue' );
|
||||
$labels = sp_get_tax_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => 'sponsor' ),
|
||||
);
|
||||
register_taxonomy( 'sp_sponsor', $object_type, $args );
|
||||
}
|
||||
add_action( 'init', 'sp_sponsor_tax_init' );
|
||||
?>
|
||||
103
sportspress-admin.css
Normal file
103
sportspress-admin.css
Normal file
@@ -0,0 +1,103 @@
|
||||
#adminmenu #toplevel_page_sp_settings div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_team div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_event div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_player div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_staff div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_sponsor div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_table div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_calendar div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_tournament div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_venue div.wp-menu-image {
|
||||
background-image: url(images/menu.png);
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
#adminmenu #toplevel_page_sp_settings div.wp-menu-image {
|
||||
background-position: 1px -33px;
|
||||
}
|
||||
#adminmenu #toplevel_page_sp_settings:hover div.wp-menu-image,
|
||||
#adminmenu #toplevel_page_sp_settings.wp-has-current-submenu div.wp-menu-image,
|
||||
#adminmenu #toplevel_page_sp_settings.current div.wp-menu-image {
|
||||
background-position: 1px -1px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_team div.wp-menu-image {
|
||||
background-position: 1px -97px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_team:hover div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_team.wp-has-current-submenu div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_team.current div.wp-menu-image {
|
||||
background-position: 1px -65px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_event div.wp-menu-image {
|
||||
background-position: -29px -33px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_event:hover div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_event.wp-has-current-submenu div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_event.current div.wp-menu-image {
|
||||
background-position: -29px -1px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_player div.wp-menu-image {
|
||||
background-position: -59px -33px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_player:hover div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_player.wp-has-current-submenu div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_player.current div.wp-menu-image {
|
||||
background-position: -59px -1px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_staff div.wp-menu-image {
|
||||
background-position: -89px -33px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_staff:hover div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_staff.wp-has-current-submenu div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_staff.current div.wp-menu-image {
|
||||
background-position: -89px -1px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_table div.wp-menu-image {
|
||||
background-position: -119px -33px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_table:hover div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_table.wp-has-current-submenu div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_table.current div.wp-menu-image {
|
||||
background-position: -119px -1px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_calendar div.wp-menu-image {
|
||||
background-position: -149px -33px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_calendar:hover div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_calendar.wp-has-current-submenu div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_calendar.current div.wp-menu-image {
|
||||
background-position: -149px -1px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_tournament div.wp-menu-image {
|
||||
background-position: -179px -33px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_tournament:hover div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_tournament.wp-has-current-submenu div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_tournament.current div.wp-menu-image {
|
||||
background-position: -179px -1px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_venue div.wp-menu-image {
|
||||
background-position: -209px -33px;
|
||||
}
|
||||
#adminmenu #menu-posts-sp_venue:hover div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_venue.wp-has-current-submenu div.wp-menu-image,
|
||||
#adminmenu #menu-posts-sp_venue.current div.wp-menu-image {
|
||||
background-position: -209px -1px;
|
||||
}
|
||||
|
||||
#sp_articlediv .wp-editor-container{
|
||||
background-color:#fff;
|
||||
}
|
||||
.widefat th.column-sp_icon,
|
||||
.widefat td.column-sp_icon {
|
||||
width: 32px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* admin skin */
|
||||
/*
|
||||
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, #adminmenu li.current a.menu-top, .folded #adminmenu li.wp-has-current-submenu, .folded #adminmenu li.current.menu-top, #adminmenu li.wp-has-current-submenu .wp-menu-arrow, #adminmenu li.current .wp-menu-arrow, #adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head,
|
||||
#adminmenu li.wp-has-current-submenu .wp-menu-arrow div, #adminmenu li.current .wp-menu-arrow div {
|
||||
background: #0082c2 !important;
|
||||
border-color: #0082c2 !important;
|
||||
}
|
||||
*/
|
||||
65
sportspress.php
Normal file
65
sportspress.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* @package SportsPress
|
||||
*/
|
||||
/*
|
||||
Plugin Name: SportsPress
|
||||
Plugin URI: http://sportspress.com/sportspress
|
||||
Description: Currently in development.
|
||||
Version: 0.1
|
||||
Author: ThemeBoy
|
||||
Author URI: http://sportspress.com
|
||||
License: GPL2
|
||||
*/
|
||||
|
||||
// Make sure we don't expose any info if called directly
|
||||
if ( !function_exists( 'add_action' ) ) {
|
||||
echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
|
||||
exit;
|
||||
}
|
||||
|
||||
define( 'SPORTSPRESS_VERSION', '0.1' );
|
||||
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
// Helpers
|
||||
require_once dirname( __FILE__ ) . '/helpers.php';
|
||||
|
||||
// Defaults
|
||||
include dirname( __FILE__ ) . '/defaults.php' ;
|
||||
|
||||
// Settings
|
||||
include dirname( __FILE__ ) . '/settings.php' ;
|
||||
|
||||
// Custom post types
|
||||
require_once dirname( __FILE__ ) . '/team.php';
|
||||
require_once dirname( __FILE__ ) . '/event.php';
|
||||
require_once dirname( __FILE__ ) . '/player.php';
|
||||
require_once dirname( __FILE__ ) . '/staff.php';
|
||||
require_once dirname( __FILE__ ) . '/table.php';
|
||||
require_once dirname( __FILE__ ) . '/calendar.php';
|
||||
require_once dirname( __FILE__ ) . '/tournament.php';
|
||||
|
||||
// Taxonomies
|
||||
require_once dirname( __FILE__ ) . '/league.php';
|
||||
require_once dirname( __FILE__ ) . '/season.php';
|
||||
require_once dirname( __FILE__ ) . '/venue.php';
|
||||
require_once dirname( __FILE__ ) . '/position.php';
|
||||
require_once dirname( __FILE__ ) . '/sponsor.php';
|
||||
|
||||
// Stylesheets
|
||||
include dirname( __FILE__ ) . '/styles.php' ;
|
||||
|
||||
// Flush rewrite rules on activation to make sure permalinks work properly
|
||||
function sp_rewrite_flush() {
|
||||
sp_team_cpt_init();
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
register_activation_hook( __FILE__, 'sp_rewrite_flush' );
|
||||
|
||||
function sp_init() {
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
load_plugin_textdomain ( 'sportspress', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
||||
add_image_size( 'sp_icon', 32, 32, false );
|
||||
}
|
||||
add_action( 'plugins_loaded', 'sp_init' );
|
||||
?>
|
||||
93
staff.php
Normal file
93
staff.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
function sp_staff_cpt_init() {
|
||||
$name = __( 'Staff', 'sportspress' );
|
||||
$singular_name = __( 'Staff', 'sportspress' );
|
||||
$labels = sp_get_cpt_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
|
||||
'rewrite' => array( 'slug' => 'staff' ),
|
||||
);
|
||||
register_post_type( 'sp_staff', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_staff_cpt_init' );
|
||||
|
||||
function sp_staff_edit_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_icon' => ' ',
|
||||
'title' => __( 'Name', 'sportspress' ),
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
'sp_position' => __( 'Position', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_staff_columns', 'sp_staff_edit_columns' );
|
||||
|
||||
function sp_staff_custom_columns( $column ) {
|
||||
global $post, $post_id, $typenow;
|
||||
if ( $typenow == 'sp_staff' ):
|
||||
switch ($column):
|
||||
case 'sp_icon':
|
||||
if ( has_post_thumbnail() ) the_post_thumbnail( 'sp_icon' );
|
||||
break;
|
||||
case 'sp_position':
|
||||
the_terms( $post_id, 'sp_position' );
|
||||
break;
|
||||
case 'sp_league':
|
||||
the_terms( $post_id, 'sp_league' );
|
||||
break;
|
||||
case 'sp_season':
|
||||
the_terms( $post_id, 'sp_season' );
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
}
|
||||
add_action( 'manage_posts_custom_column', 'sp_staff_custom_columns' );
|
||||
|
||||
function sp_staff_request_filter_dropdowns() {
|
||||
global $typenow, $wp_query;
|
||||
if ( $typenow == 'sp_staff' ) {
|
||||
|
||||
// Positions
|
||||
$selected = isset( $_REQUEST['sp_position'] ) ? $_REQUEST['sp_position'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Positions', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_position',
|
||||
'name' => 'sp_position',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Leagues
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Seasons
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'sp_staff_request_filter_dropdowns' );
|
||||
?>
|
||||
22
styles.php
Normal file
22
styles.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
function sp_enqueue_styles() {
|
||||
wp_register_style( 'stylesheet', get_bloginfo('stylesheet_url' ) );
|
||||
wp_enqueue_style( 'stylesheet' );
|
||||
wp_register_style( 'jquery-fancybox', get_template_directory_uri() . '/js/fancybox/jquery.fancybox-1.3.4.css' );
|
||||
wp_enqueue_style( 'jquery-fancybox' );
|
||||
}
|
||||
//add_action( 'wp_print_styles', 'sp_enqueue_styles' );
|
||||
|
||||
function sp_admin_styles_init() {
|
||||
// wp_enqueue_style( 'thickbox' );
|
||||
wp_register_style( 'sportspress-admin.css', SPORTSPRESS_PLUGIN_URL . 'sportspress-admin.css', array(), '1.0' );
|
||||
wp_enqueue_style( 'sportspress-admin.css');
|
||||
}
|
||||
add_action( 'admin_init', 'sp_admin_styles_init' );
|
||||
|
||||
function sp_adminbar_enqueue_styles() {
|
||||
wp_register_style( 'adminbar-stylesheet', get_template_directory_uri() . '/css/adminbar.css' );
|
||||
wp_enqueue_style( 'adminbar-stylesheet' );
|
||||
}
|
||||
//add_action( 'wp_head', 'sp_adminbar_enqueue_styles' );
|
||||
?>
|
||||
77
table.php
Normal file
77
table.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
function sp_table_cpt_init() {
|
||||
$name = __( 'Tables', 'sportspress' );
|
||||
$singular_name = __( 'Table', 'sportspress' );
|
||||
$labels = sp_get_cpt_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => false,
|
||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
|
||||
'rewrite' => array( 'slug' => 'table' ),
|
||||
);
|
||||
register_post_type( 'sp_table', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_table_cpt_init' );
|
||||
|
||||
function sp_table_edit_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_table_columns', 'sp_table_edit_columns' );
|
||||
|
||||
function sp_table_custom_columns( $column ) {
|
||||
global $post, $post_id, $typenow;
|
||||
if ( $typenow == 'sp_table' ):
|
||||
switch ($column):
|
||||
case 'sp_team':
|
||||
echo 'TEAMS';
|
||||
break;
|
||||
case 'sp_league':
|
||||
the_terms( $post_id, 'sp_league' );
|
||||
break;
|
||||
case 'sp_season':
|
||||
the_terms( $post_id, 'sp_season' );
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
}
|
||||
add_action( 'manage_posts_custom_column', 'sp_table_custom_columns' );
|
||||
|
||||
function sp_table_request_filter_dropdowns() {
|
||||
global $typenow, $wp_query;
|
||||
if ( $typenow == 'sp_table' ) {
|
||||
|
||||
// Leagues
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Seasons
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'sp_table_request_filter_dropdowns' );
|
||||
?>
|
||||
114
team.php
Normal file
114
team.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
function sp_team_cpt_init() {
|
||||
$name = __( 'Teams', 'sportspress' );
|
||||
$singular_name = __( 'Team', 'sportspress' );
|
||||
$labels = sp_get_cpt_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => true,
|
||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
|
||||
'rewrite' => array( 'slug' => 'team' ),
|
||||
);
|
||||
register_post_type( 'sp_team', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_team_cpt_init' );
|
||||
|
||||
function sp_team_text_replace( $input, $text, $domain ) {
|
||||
global $post;
|
||||
if ( is_admin() && get_post_type( $post ) == 'sp_team' )
|
||||
switch ( $text ):
|
||||
case 'Featured Image':
|
||||
return __( 'Logo', 'themeboy' );
|
||||
break;
|
||||
default:
|
||||
return $input;
|
||||
endswitch;
|
||||
return $input;
|
||||
}
|
||||
add_filter( 'gettext', 'sp_team_text_replace', 20, 3 );
|
||||
|
||||
function sp_team_edit_columns($columns) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_icon' => ' ',
|
||||
'title' => __( 'Team', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_sponsor' => __( 'Sponsor', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_team_columns', 'sp_team_edit_columns' );
|
||||
|
||||
function sp_team_custom_columns( $column ) {
|
||||
global $post, $post_id, $typenow;
|
||||
if ( $typenow == 'sp_team' ):
|
||||
switch ( $column ):
|
||||
case 'sp_icon':
|
||||
sp_team_logo( $post_id );
|
||||
break;
|
||||
case 'sp_league':
|
||||
if ( get_the_terms ( $post_id, 'sp_league' ) )
|
||||
the_terms( $post_id, 'sp_league' );
|
||||
else
|
||||
echo '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
if ( get_the_terms ( $post_id, 'sp_season' ) )
|
||||
the_terms( $post_id, 'sp_season' );
|
||||
else
|
||||
echo '—';
|
||||
break;
|
||||
case 'sp_sponsor':
|
||||
if ( get_the_terms ( $post_id, 'sp_sponsor' ) )
|
||||
the_terms( $post_id, 'sp_sponsor' );
|
||||
else
|
||||
echo '—';
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
}
|
||||
add_action( 'manage_pages_custom_column', 'sp_team_custom_columns' );
|
||||
|
||||
function sp_team_request_filter_dropdowns() {
|
||||
global $typenow, $wp_query;
|
||||
if ( $typenow == 'sp_team' ) {
|
||||
|
||||
// Leagues
|
||||
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Seasons
|
||||
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
// Sponsors
|
||||
$selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_sponsor',
|
||||
'name' => 'sp_sponsor',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'sp_team_request_filter_dropdowns' );
|
||||
?>
|
||||
66
tournament.php
Normal file
66
tournament.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
function sp_tournament_cpt_init() {
|
||||
$name = __( 'Tournaments', 'sportspress' );
|
||||
$singular_name = __( 'Tournament', 'sportspress' );
|
||||
$labels = sp_get_cpt_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => true,
|
||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'page-attributes' ),
|
||||
'rewrite' => array( 'slug' => 'tournament' ),
|
||||
);
|
||||
register_post_type( 'sp_tournament', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_tournament_cpt_init' );
|
||||
|
||||
function sp_tournament_edit_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_event' => __( 'Events', 'sportspress' ),
|
||||
'sp_sponsor' => __( 'Sponsor', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_tournament_columns', 'sp_tournament_edit_columns' );
|
||||
|
||||
function sp_tournament_custom_columns( $column ) {
|
||||
global $post, $post_id, $typenow;
|
||||
if ( $typenow == 'sp_tournament' ):
|
||||
switch ($column):
|
||||
case 'sp_team':
|
||||
echo 'TEAMS';
|
||||
break;
|
||||
case 'sp_event':
|
||||
the_terms( $post_id, 'sp_event' );
|
||||
break;
|
||||
case 'sp_sponsor':
|
||||
the_terms( $post_id, 'sp_sponsor' );
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
}
|
||||
add_action( 'manage_pages_custom_column', 'sp_tournament_custom_columns' );
|
||||
|
||||
function sp_tournament_request_filter_dropdowns() {
|
||||
global $typenow, $wp_query;
|
||||
if ( $typenow == 'sp_tournament' ) {
|
||||
|
||||
// Sponsors
|
||||
$selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_sponsor',
|
||||
'name' => 'sp_sponsor',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
echo PHP_EOL;
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'sp_tournament_request_filter_dropdowns' );
|
||||
?>
|
||||
61
venue.php
Normal file
61
venue.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
function sp_venue_cpt_init() {
|
||||
$name = __( 'Venues', 'sportspress' );
|
||||
$singular_name = __( 'Venue', 'sportspress' );
|
||||
$labels = sp_get_cpt_labels( $name, $singular_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => true,
|
||||
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ),
|
||||
'rewrite' => array( 'slug' => 'venue' ),
|
||||
);
|
||||
register_post_type( 'sp_venue', $args );
|
||||
}
|
||||
add_action( 'init', 'sp_venue_cpt_init' );
|
||||
|
||||
function sp_venue_edit_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Venue', 'sportspress' ),
|
||||
'sp_address' => __( 'Address', 'sportspress' ),
|
||||
'sp_sponsor' => __( 'Sponsor', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_venue_columns', 'sp_venue_edit_columns' );
|
||||
|
||||
function sp_venue_custom_columns( $column, $post_id ) {
|
||||
global $typenow;
|
||||
if ( $typenow == 'sp_venue' ):
|
||||
switch ( $column ):
|
||||
case 'sp_sponsor':
|
||||
the_terms( $post_id, 'sp_sponsor' );
|
||||
break;
|
||||
case 'sp_address':
|
||||
echo get_post_meta( $post_id, 'sp_address', true );
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
}
|
||||
add_action( 'manage_posts_custom_column', 'sp_venue_custom_columns', 10, 2 );
|
||||
|
||||
function sp_venue_request_filter_dropdowns() {
|
||||
global $typenow, $wp_query;
|
||||
if ( $typenow == 'sp_venue' ) {
|
||||
|
||||
// Sponsors
|
||||
$selected = isset( $_REQUEST['sp_sponsor'] ) ? $_REQUEST['sp_sponsor'] : null;
|
||||
$args = array(
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Sponsors', 'sportspress' ) ),
|
||||
'taxonomy' => 'sp_sponsor',
|
||||
'name' => 'sp_sponsor',
|
||||
'selected' => $selected
|
||||
);
|
||||
sp_dropdown_taxonomies( $args );
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'sp_venue_request_filter_dropdowns' );
|
||||
?>
|
||||
Reference in New Issue
Block a user