diff --git a/actions.php b/actions.php new file mode 100644 index 00000000..488ba31c --- /dev/null +++ b/actions.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/calendar.php b/calendar.php index 09d090dc..b63aaed2 100644 --- a/calendar.php +++ b/calendar.php @@ -35,10 +35,16 @@ function sp_calendar_custom_columns( $column ) { echo 'TEAMS'; break; case 'sp_league': - the_terms( $post_id, 'sp_league' ); + if ( get_the_terms ( $post_id, 'sp_league' ) ) + the_terms( $post_id, 'sp_league' ); + else + echo '—'; break; case 'sp_season': - the_terms( $post_id, 'sp_season' ); + if ( get_the_terms ( $post_id, 'sp_season' ) ) + the_terms( $post_id, 'sp_season' ); + else + echo '—'; break; endswitch; endif; diff --git a/event.php b/event.php index fc201f10..8cb2e7f4 100644 --- a/event.php +++ b/event.php @@ -10,7 +10,7 @@ function sp_event_cpt_init() { 'hierarchical' => false, 'supports' => array( 'title', 'author', 'comments', 'page-attributes' ), 'register_meta_box_cb' => 'sp_event_meta_init', - 'rewrite' => array( 'slug' => 'event' ), + 'rewrite' => array( 'slug' => 'event' ) ); register_post_type( 'sp_event', $args ); } @@ -30,13 +30,13 @@ function sp_event_text_replace( $input, $text, $domain ) { if ( is_admin() && get_post_type( $post ) == 'sp_event' ) switch ( $text ): case 'Scheduled for: %1$s': - return __( 'Kick-off: %1$s', 'sportspress' ); + return __( 'Kick-off', 'sportspress' ) . ': %1$s'; break; case 'Published on: %1$s': - return __( 'Kick-off: %1$s', 'sportspress' ); + return __( 'Kick-off', 'sportspress' ) . ': %1$s'; break; case 'Publish immediately': - return __( 'Kick-off: %1$s', 'sportspress' ); + return __( 'Kick-off', 'sportspress' ) . ': %1$s'; break; default: return $input; @@ -46,22 +46,10 @@ function sp_event_text_replace( $input, $text, $domain ) { 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' - ); + remove_meta_box( 'submitdiv', 'sp_event', 'side' ); + add_meta_box( 'submitdiv', __( 'Kick-off', 'sportspress' ), 'post_submit_meta_box', 'sp_event', 'side', 'high' ); + 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 ) { @@ -73,8 +61,8 @@ function sp_event_team_meta( $post, $metabox ) { 'name' => 'sportspress[sp_team_' . $i . ']', 'selected' => get_post_meta( $post_id, 'sp_team_' . $i, true ), ); - echo '' . PHP_EOL; wp_dropdown_pages( $args ); + echo '
' . PHP_EOL; /* $players = unserialize( get_post_meta( $post_id, 'sp_players', true ) ); ?> @@ -220,8 +208,7 @@ function sp_event_edit_columns( $columns ) { 'sp_league' => __( 'League', 'sportspress' ), 'sp_season' => __( 'Season', 'sportspress' ), 'sp_sponsor' => __( 'Sponsor', 'sportspress' ), - 'sp_kickoff' => __( 'Kick-off', 'sportspress' ), - 'date' => __( 'Date' ), + 'sp_kickoff' => __( 'Kick-off', 'sportspress' ) ); return $columns; } @@ -235,48 +222,45 @@ function sp_event_custom_columns( $column, $post_id ) { $limit = get_option( 'sp_event_team_count' ); for ( $i = 1; $i <= $limit; $i++ ): $team = get_post_meta( $post_id, 'sp_team_' . $i, true ); + $parents = get_post_ancestors( $team ); + foreach ( $parents as $parent ) { + edit_post_link( get_the_title( $parent ), '', ' — ', $parent ); + } edit_post_link( get_the_title( $team ), '', '
', $team ); endfor; break; case 'sp_league': - the_terms( $post_id, 'sp_league' ); + if ( get_the_terms ( $post_id, 'sp_league' ) ) + the_terms( $post_id, 'sp_league' ); + else + echo '—'; break; case 'sp_season': - the_terms( $post_id, 'sp_season' ); + if ( get_the_terms ( $post_id, 'sp_season' ) ) + the_terms( $post_id, 'sp_season' ); + else + echo '—'; break; case 'sp_sponsor': - the_terms( $post_id, 'sp_sponsor' ); + if ( get_the_terms ( $post_id, 'sp_sponsor' ) ) + the_terms( $post_id, 'sp_sponsor' ); + else + echo '—'; break; case 'sp_kickoff': - echo get_the_time ( get_option ( 'time_format' ) ); - break; - case 'date': - echo get_the_date ( get_option ( 'date_format' ) ); + echo get_the_date ( get_option ( 'date_format' ) ) . '
' . get_the_time ( get_option ( 'time_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'; + $columns['sp_kickoff'] = 'sp_kickoff'; 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' ) { diff --git a/filters.php b/filters.php new file mode 100644 index 00000000..580f5a9f --- /dev/null +++ b/filters.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/helpers.php b/helpers.php index f3329ee5..3d19e27b 100644 --- a/helpers.php +++ b/helpers.php @@ -64,22 +64,23 @@ if ( ! function_exists( 'sp_dropdown_taxonomies' ) ) { print( '' ); } } - 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; - } +} + +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; - } + } + endif; } } ?> \ No newline at end of file diff --git a/hooks.php b/hooks.php new file mode 100644 index 00000000..ab112550 --- /dev/null +++ b/hooks.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/player.php b/player.php index a56b6ab4..e1202334 100644 --- a/player.php +++ b/player.php @@ -38,16 +38,28 @@ function sp_player_custom_columns( $column ) { if ( has_post_thumbnail() ) the_post_thumbnail( 'sp_icon' ); break; case 'sp_position': - the_terms( $post_id, 'sp_position' ); + if ( get_the_terms ( $post_id, 'sp_position' ) ) + the_terms( $post_id, 'sp_position' ); + else + echo '—'; break; case 'sp_league': - the_terms( $post_id, 'sp_league' ); + if ( get_the_terms ( $post_id, 'sp_league' ) ) + the_terms( $post_id, 'sp_league' ); + else + echo '—'; break; case 'sp_season': - the_terms( $post_id, 'sp_season' ); + if ( get_the_terms ( $post_id, 'sp_season' ) ) + the_terms( $post_id, 'sp_season' ); + else + echo '—'; break; case 'sp_sponsor': - the_terms( $post_id, 'sp_sponsor' ); + if ( get_the_terms ( $post_id, 'sp_sponsor' ) ) + the_terms( $post_id, 'sp_sponsor' ); + else + echo '—'; break; endswitch; endif; diff --git a/scripts.php b/scripts.php new file mode 100644 index 00000000..2fd0e6fa --- /dev/null +++ b/scripts.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/settings.php b/settings.php index aeb9f1c9..b605136f 100644 --- a/settings.php +++ b/settings.php @@ -3,7 +3,7 @@ function sp_settings_menu() { add_submenu_page( 'options-general.php', __( 'SportsPress', 'sportspress' ), - __( 'Sportspress', 'sportspress' ), + __( 'SportsPress', 'sportspress' ), 'manage_options', 'sp_settings', 'sp_settings_page' @@ -12,6 +12,8 @@ function sp_settings_menu() { add_action('admin_menu', 'sp_settings_menu'); function sp_settings_page() { + echo ''; + /* 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'; ?> @@ -110,4 +112,4 @@ function sp_settings_page() { - \ No newline at end of file + \ No newline at end of file diff --git a/sportspress-admin.css b/sportspress-admin.css index f0ee922f..c93fb761 100644 --- a/sportspress-admin.css +++ b/sportspress-admin.css @@ -84,7 +84,14 @@ background-position: -209px -1px; } -#sp_articlediv .wp-editor-container{ +#poststuff #sp_kickoffdiv .inside { + margin: 0; + padding: 0; +} +#sp_kickoffdiv #timestampdiv p { + display: none; +} +#sp_articlediv .wp-editor-container { background-color:#fff; } .widefat th.column-sp_icon, diff --git a/sportspress-admin.js b/sportspress-admin.js new file mode 100644 index 00000000..dd211f45 --- /dev/null +++ b/sportspress-admin.js @@ -0,0 +1,3 @@ +jQuery(document).ready(function(){ + jQuery('.sp_datepicker').datepicker(); +}); \ No newline at end of file diff --git a/sportspress.php b/sportspress.php index 8b092c28..46dd8a1e 100644 --- a/sportspress.php +++ b/sportspress.php @@ -30,7 +30,7 @@ include dirname( __FILE__ ) . '/defaults.php' ; // Settings include dirname( __FILE__ ) . '/settings.php' ; -// Custom post types +// Custom Post Types require_once dirname( __FILE__ ) . '/team.php'; require_once dirname( __FILE__ ) . '/event.php'; require_once dirname( __FILE__ ) . '/player.php'; @@ -46,20 +46,14 @@ require_once dirname( __FILE__ ) . '/venue.php'; require_once dirname( __FILE__ ) . '/position.php'; require_once dirname( __FILE__ ) . '/sponsor.php'; -// Stylesheets -include dirname( __FILE__ ) . '/styles.php' ; +// Styles +include_once 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' ); +// Scripts +include_once dirname( __FILE__ ) . '/scripts.php' ; -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' ); +// Hooks, Actions, and Filters +require_once dirname( __FILE__ ) . '/hooks.php'; +require_once dirname( __FILE__ ) . '/actions.php'; +require_once dirname( __FILE__ ) . '/filters.php'; ?> \ No newline at end of file diff --git a/staff.php b/staff.php index 5d635937..880a6df5 100644 --- a/staff.php +++ b/staff.php @@ -37,13 +37,22 @@ function sp_staff_custom_columns( $column ) { if ( has_post_thumbnail() ) the_post_thumbnail( 'sp_icon' ); break; case 'sp_position': - the_terms( $post_id, 'sp_position' ); + if ( get_the_terms ( $post_id, 'sp_position' ) ) + the_terms( $post_id, 'sp_position' ); + else + echo '—'; break; case 'sp_league': - the_terms( $post_id, 'sp_league' ); + if ( get_the_terms ( $post_id, 'sp_league' ) ) + the_terms( $post_id, 'sp_league' ); + else + echo '—'; break; case 'sp_season': - the_terms( $post_id, 'sp_season' ); + if ( get_the_terms ( $post_id, 'sp_season' ) ) + the_terms( $post_id, 'sp_season' ); + else + echo '—'; break; endswitch; endif; diff --git a/table.php b/table.php index 80f6e6ea..d29f2a6a 100644 --- a/table.php +++ b/table.php @@ -35,10 +35,16 @@ function sp_table_custom_columns( $column ) { echo 'TEAMS'; break; case 'sp_league': - the_terms( $post_id, 'sp_league' ); + if ( get_the_terms ( $post_id, 'sp_league' ) ) + the_terms( $post_id, 'sp_league' ); + else + echo '—'; break; case 'sp_season': - the_terms( $post_id, 'sp_season' ); + if ( get_the_terms ( $post_id, 'sp_season' ) ) + the_terms( $post_id, 'sp_season' ); + else + echo '—'; break; endswitch; endif; diff --git a/team.php b/team.php index 93fa7c67..96310545 100644 --- a/team.php +++ b/team.php @@ -9,6 +9,7 @@ function sp_team_cpt_init() { 'public' => true, 'hierarchical' => true, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes' ), + 'register_meta_box_cb' => 'sp_team_meta_init', 'rewrite' => array( 'slug' => 'team' ), ); register_post_type( 'sp_team', $args ); @@ -19,8 +20,14 @@ 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' ); + case 'Set featured image': + return sprintf( __( 'Add %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ); + break; + case 'Set Featured Image': + return sprintf( __( 'Add %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ); + break; + case 'Remove featured image': + return sprintf( __( 'Remove %s', 'sportspress' ), __( 'Logo', 'sportspress' ) ); break; default: return $input; @@ -29,6 +36,13 @@ function sp_team_text_replace( $input, $text, $domain ) { } add_filter( 'gettext', 'sp_team_text_replace', 20, 3 ); +function sp_team_meta_init() { + remove_meta_box( 'postimagediv', 'sp_team', 'side' ); + add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'high' ); + remove_meta_box( 'pageparentdiv', 'sp_team', 'side' ); + add_meta_box( 'pageparentdiv', __( 'Team', 'sportspress' ), 'page_attributes_meta_box', 'sp_team', 'side', 'high' ); +} + function sp_team_edit_columns($columns) { $columns = array( 'cb' => '', @@ -47,7 +61,7 @@ function sp_team_custom_columns( $column ) { if ( $typenow == 'sp_team' ): switch ( $column ): case 'sp_icon': - sp_team_logo( $post_id ); + the_post_thumbnail( 'sp_icon' ); break; case 'sp_league': if ( get_the_terms ( $post_id, 'sp_league' ) ) diff --git a/tournament.php b/tournament.php index 38cdc117..9f602e57 100644 --- a/tournament.php +++ b/tournament.php @@ -35,10 +35,13 @@ function sp_tournament_custom_columns( $column ) { echo 'TEAMS'; break; case 'sp_event': - the_terms( $post_id, 'sp_event' ); + echo 'EVENTS'; break; case 'sp_sponsor': - the_terms( $post_id, 'sp_sponsor' ); + if ( get_the_terms ( $post_id, 'sp_sponsor' ) ) + the_terms( $post_id, 'sp_sponsor' ); + else + echo '—'; break; endswitch; endif; diff --git a/venue.php b/venue.php index 36c61873..3458e8a3 100644 --- a/venue.php +++ b/venue.php @@ -31,7 +31,10 @@ function sp_venue_custom_columns( $column, $post_id ) { if ( $typenow == 'sp_venue' ): switch ( $column ): case 'sp_sponsor': - the_terms( $post_id, 'sp_sponsor' ); + if ( get_the_terms ( $post_id, 'sp_sponsor' ) ) + the_terms( $post_id, 'sp_sponsor' ); + else + echo '—'; break; case 'sp_address': echo get_post_meta( $post_id, 'sp_address', true );