diff --git a/admin/actions/admin-menu.php b/admin/actions/admin-menu.php new file mode 100644 index 00000000..ce7baf9c --- /dev/null +++ b/admin/actions/admin-menu.php @@ -0,0 +1,32 @@ + $data ) { + if ( is_array( $data ) && array_key_exists( 2, $data ) && $data[2] == 'edit.php?post_type=sp_separator' ) + $position = $key; + } + + // Swap our placeholder post type with a menu separator + if ( $position ): + $menu[ $position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' ); + endif; + + // Remove "Add Configuration" link under SportsPress + unset( $submenu['edit.php?post_type=sp_config'][10] ); + + // Remove "Seasons" link under Events + unset( $submenu['edit.php?post_type=sp_event'][15] ); + + // Remove "Seasons" link under Players + unset( $submenu['edit.php?post_type=sp_player'][15] ); + + // Remove "Seasons" link under Staff + unset( $submenu['edit.php?post_type=sp_staff'][15] ); +} +add_action( 'admin_menu', 'sp_admin_menu' ); +?> \ No newline at end of file diff --git a/admin/actions/after-theme-setup.php b/admin/actions/after-theme-setup.php new file mode 100644 index 00000000..b4316505 --- /dev/null +++ b/admin/actions/after-theme-setup.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/admin/actions/manage-posts-columns.php b/admin/actions/manage-posts-columns.php new file mode 100644 index 00000000..795967cc --- /dev/null +++ b/admin/actions/manage-posts-columns.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/admin/actions/manage-posts-custom-column.php b/admin/actions/manage-posts-custom-column.php new file mode 100644 index 00000000..bc239443 --- /dev/null +++ b/admin/actions/manage-posts-custom-column.php @@ -0,0 +1,86 @@ + $outcome_slug, + 'post_type' => 'sp_outcome', + 'post_status' => 'publish', + 'posts_per_page' => 1 + ); + $outcomes = get_posts( $args ); + echo $team->post_title . ( $outcomes ? ' — ' . $outcomes[0]->post_title : '' ) . '
'; + endforeach; + elseif ( $post_type == 'sp_player' ): + $results = get_post_meta( $post_id, 'sp_results', true ); + foreach( $teams as $team_id ): + $team = get_post( $team_id ); + $outcome_slug = sp_array_value( sp_array_value( $results, $team_id, null ), 'outcome', null ); + + $args=array( + 'name' => $outcome_slug, + 'post_type' => 'sp_outcome', + 'post_status' => 'publish', + 'posts_per_page' => 1 + ); + $outcomes = get_posts( $args ); + echo $team->post_title . ( $outcomes ? ' — ' . $outcomes[0]->post_title : '' ) . '
'; + endforeach; + else: + foreach( $teams as $team_id ): + $team = get_post( $team_id ); + echo $team->post_title . '
'; + endforeach; + endif; + break; + case 'sp_equation': + echo sp_get_post_equation( $post_id ); + break; + case 'sp_order': + echo sp_get_post_order( $post_id ); + break; + case 'sp_key': + echo $post->post_name; + break; + case 'sp_format': + echo sp_get_post_format( $post_id ); + break; + case 'sp_player': + echo sp_the_posts( $post_id, 'sp_player' ); + break; + case 'sp_event': + echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—'; + break; + case 'sp_season': + echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—'; + break; + case 'sp_sponsor': + echo get_the_terms ( $post_id, 'sp_sponsor' ) ? the_terms( $post_id, 'sp_sponsor' ) : '—'; + break; + case 'sp_kickoff': + echo ( $post->post_status == 'future' ? __( 'Scheduled' ) : __( 'Played', 'sportspress' ) ) . '
' . date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ); + break; + case 'sp_address': + echo get_post_meta( $post_id, 'sp_address', true ) ? get_post_meta( $post_id, 'sp_address', true ) : '—'; + break; + endswitch; +} +add_action( 'manage_posts_custom_column', 'sp_manage_posts_custom_column', 10, 2 ); +add_action( 'manage_pages_custom_column', 'sp_manage_posts_custom_column', 10, 2 ); +?> \ No newline at end of file diff --git a/admin/actions/plugins-loaded.php b/admin/actions/plugins-loaded.php new file mode 100644 index 00000000..29b332df --- /dev/null +++ b/admin/actions/plugins-loaded.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/admin/actions/post-thumbnail-html.php b/admin/actions/post-thumbnail-html.php new file mode 100644 index 00000000..dd24b1cd --- /dev/null +++ b/admin/actions/post-thumbnail-html.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/admin/actions/restrict-manage-posts.php b/admin/actions/restrict-manage-posts.php new file mode 100644 index 00000000..7a360e4e --- /dev/null +++ b/admin/actions/restrict-manage-posts.php @@ -0,0 +1,37 @@ + sprintf( __( 'All %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ), + 'post_type' => 'sp_team', + 'name' => 'sp_team', + 'selected' => $selected + ); + // wp_dropdown_pages( $args ); + endif; + if ( in_array( $typenow, array( 'sp_player' ) ) ): + $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 ); + endif; + if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list' ) ) ): + $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 ); + endif; +} +add_action( 'restrict_manage_posts', 'sp_restrict_manage_posts' ); +?> \ No newline at end of file diff --git a/admin/actions/save-post.php b/admin/actions/save-post.php new file mode 100644 index 00000000..0933cb06 --- /dev/null +++ b/admin/actions/save-post.php @@ -0,0 +1,137 @@ + \ No newline at end of file diff --git a/admin/filters/admin-post-thumbnail-html.php b/admin/filters/admin-post-thumbnail-html.php new file mode 100644 index 00000000..b134ae60 --- /dev/null +++ b/admin/filters/admin-post-thumbnail-html.php @@ -0,0 +1,27 @@ + array( + 'Set featured image' => 'Select Logo', + 'Remove featured image' => 'Remove Logo', + ), + 'sp_player' => array( + 'Set featured image' => 'Select Photo', + 'Remove featured image' => 'Remove Photo', + ), + 'sp_staff' => array( + 'Set featured image' => 'Select Photo', + 'Remove featured image' => 'Remove Photo', + ), + ); + + $typenow = get_post_type( $post_id ); + if ( is_admin() && array_key_exists( $typenow, $texts ) ): + foreach ( $texts[ $typenow ] as $key => $value ): + $translated_text = str_replace( __( $key ), __( $value, 'sportspress' ), $translated_text ); + endforeach; + endif; + return $translated_text; +} +add_filter( 'admin_post_thumbnail_html', 'sp_admin_post_thumbnail_html', 10, 2 ); +?> \ No newline at end of file diff --git a/admin/filters/gettext.php b/admin/filters/gettext.php new file mode 100644 index 00000000..7d259e6f --- /dev/null +++ b/admin/filters/gettext.php @@ -0,0 +1,44 @@ + array( + 'Enter title here' => 'Team', + 'Set featured image' => 'Select Logo', + 'Set Featured Image' => 'Select Logo', + 'Remove featured image' => 'Remove Logo', + ), + 'sp_event' => array( + 'Enter title here' => '(no title)', + 'Scheduled for: %1$s' => 'Kick-off: %1$s', + 'Published on: %1$s' => 'Kick-off: %1$s', + 'Publish immediately' => 'Kick-off: %1$s', + ), + 'sp_player' => array( + 'Enter title here' => 'Name', + 'Set featured image' => 'Select Photo', + 'Set Featured Image' => 'Select Photo', + 'Remove featured image' => 'Remove Photo', + 'Scheduled for: %1$s' => 'Joined: %1$s', + 'Published on: %1$s' => 'Joined: %1$s', + 'Publish immediately' => 'Joined: %1$s', + ), + 'sp_staff' => array( + 'Enter title here' => 'Name', + 'Set featured image' => 'Select Photo', + 'Set Featured Image' => 'Select Photo', + 'Remove featured image' => 'Remove Photo', + 'Scheduled for: %1$s' => 'Joined: %1$s', + 'Published on: %1$s' => 'Joined: %1$s', + 'Publish immediately' => 'Joined: %1$s', + ), + ); + + if ( is_admin() && array_key_exists( $typenow, $texts ) && array_key_exists( $untranslated_text, $texts[ $typenow ] ) ) + return __( $texts[ $typenow ][ $untranslated_text ], 'sportspress' ); + else + return $translated_text; +} +add_filter( 'gettext', 'sp_gettext', 20, 3 ); +?> \ No newline at end of file diff --git a/admin/filters/pre-get-posts.php b/admin/filters/pre-get-posts.php new file mode 100644 index 00000000..6ceced8c --- /dev/null +++ b/admin/filters/pre-get-posts.php @@ -0,0 +1,16 @@ +query['post_type']; + + if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ): + $wp_query->set( 'orderby', 'menu_order' ); + $wp_query->set( 'order', 'ASC' ); + elseif ( $post_type == 'sp_event' ): + $wp_query->set( 'orderby', 'post_date' ); + $wp_query->set( 'order', 'ASC' ); + endif; + endif; +} +add_filter('pre_get_posts', 'sp_pre_get_posts'); +?> \ No newline at end of file diff --git a/admin/filters/sanitize-title.php b/admin/filters/sanitize-title.php new file mode 100644 index 00000000..e9aa1dec --- /dev/null +++ b/admin/filters/sanitize-title.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/admin/filters/the-content.php b/admin/filters/the-content.php new file mode 100644 index 00000000..103594f7 --- /dev/null +++ b/admin/filters/the-content.php @@ -0,0 +1,24 @@ +' . sp_get_table_html( $post->ID ) . '

'; + + elseif ( is_singular( 'sp_list' ) && in_the_loop() ): + + global $post; + + // Display player list + $content .= '

' . sp_get_list_html( $post->ID ) . '

'; + + endif; + + return $content; +} +add_filter('the_content', 'sportspress_the_content'); +?> \ No newline at end of file diff --git a/admin/filters/wp-insert-post-data.php b/admin/filters/wp-insert-post-data.php new file mode 100644 index 00000000..97b0770d --- /dev/null +++ b/admin/filters/wp-insert-post-data.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/admin/post-types/column.php b/admin/post-types/column.php index 4a4d715f..4bfac70b 100644 --- a/admin/post-types/column.php +++ b/admin/post-types/column.php @@ -37,7 +37,7 @@ function sp_column_meta_init() { } function sp_column_details_meta( $post ) { - global $sportspress_config_formats; + $formats = sp_get_config_formats(); $equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) ); $order = get_post_meta( $post->ID, 'sp_order', true ); @@ -55,7 +55,7 @@ function sp_column_details_meta( $post ) {

$value ): + foreach ( $formats as $key => $value ): printf( '', $key, selected( true, $key == $priority, false ), $value ); endforeach; ?> diff --git a/admin/post-types/statistic.php b/admin/post-types/statistic.php index 588e7458..9a50203d 100644 --- a/admin/post-types/statistic.php +++ b/admin/post-types/statistic.php @@ -37,7 +37,7 @@ function sp_statistic_meta_init() { } function sp_statistic_equation_meta( $post ) { - global $sportspress_config_formats; + $formats = sp_get_config_formats(); $equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) ); $order = get_post_meta( $post->ID, 'sp_order', true ); @@ -55,7 +55,7 @@ function sp_statistic_equation_meta( $post ) {

'; @@ -799,10 +818,11 @@ if ( !function_exists( 'sp_event_players_table' ) ) { $i = 0; foreach ( $data as $player_id => $player_statistics ): if ( !$player_id ) continue; + $number = get_post_meta( $player_id, 'sp_number', true ); ?> - + $label ): $value = sp_array_value( $player_statistics, $column, '' ); diff --git a/languages/sportspress-ja.mo b/i18n/languages/sportspress-ja.mo similarity index 100% rename from languages/sportspress-ja.mo rename to i18n/languages/sportspress-ja.mo diff --git a/languages/sportspress-ja.po b/i18n/languages/sportspress-ja.po similarity index 100% rename from languages/sportspress-ja.po rename to i18n/languages/sportspress-ja.po diff --git a/i18n/strings.php b/i18n/strings.php new file mode 100644 index 00000000..31d10ff1 --- /dev/null +++ b/i18n/strings.php @@ -0,0 +1,41 @@ +%1$s', 'sportspress' ); +__( 'Joined: %1$s', 'sportspress' ); +__( 'Select Photo', 'sportspress' ); +__( 'Remove Photo', 'sportspress' ); + +// Localize configuration formats +__( 'Integer', 'sportspress' ); +__( 'Decimal', 'sportspress' ); +__( 'Time', 'sportspress' ); +__( 'Custom Field', 'sportspress' ); +?> \ No newline at end of file diff --git a/sportspress-actions.php b/sportspress-actions.php deleted file mode 100644 index 72992d4e..00000000 --- a/sportspress-actions.php +++ /dev/null @@ -1,293 +0,0 @@ - $data ) { - if ( is_array( $data ) && array_key_exists( 2, $data ) && $data[2] == 'edit.php?post_type=sp_separator' ) - $position = $key; - } - - // Swap our placeholder post type with a menu separator - if ( $position ): - $menu[ $position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' ); - endif; - - // Remove "Add Configuration" link under SportsPress - unset( $submenu['edit.php?post_type=sp_config'][10] ); - - // Remove "Seasons" link under Events - unset( $submenu['edit.php?post_type=sp_event'][15] ); - - // Remove "Seasons" link under Players - unset( $submenu['edit.php?post_type=sp_player'][15] ); - - // Remove "Seasons" link under Staff - unset( $submenu['edit.php?post_type=sp_staff'][15] ); -} -add_action( 'admin_menu', 'sp_admin_menu' ); - -function sp_manage_posts_custom_column( $column, $post_id ) { - global $post; - switch ( $column ): - case 'sp_logo': - edit_post_link( get_the_post_thumbnail( $post_id, 'sp_icon' ), '', '', $post_id ); - break; - case 'sp_position': - echo get_the_terms ( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—'; - break; - case 'sp_team': - $post_type = get_post_type( $post ); - $teams = get_post_meta ( $post_id, 'sp_team', false ); - if ( $post_type == 'sp_event' ): - $results = get_post_meta( $post_id, 'sp_results', true ); - foreach( $teams as $team_id ): - $team = get_post( $team_id ); - $outcome_slug = sp_array_value( sp_array_value( $results, $team_id, null ), 'outcome', null ); - - $args=array( - 'name' => $outcome_slug, - 'post_type' => 'sp_outcome', - 'post_status' => 'publish', - 'posts_per_page' => 1 - ); - $outcomes = get_posts( $args ); - echo $team->post_title . ( $outcomes ? ' — ' . $outcomes[0]->post_title : '' ) . '
'; - endforeach; - else: - foreach( $teams as $team_id ): - $team = get_post( $team_id ); - echo $team->post_title . '
'; - endforeach; - endif; - break; - case 'sp_equation': - echo sp_get_post_equation( $post_id ); - break; - case 'sp_order': - echo sp_get_post_order( $post_id ); - break; - case 'sp_key': - echo $post->post_name; - break; - case 'sp_format': - echo sp_get_post_format( $post_id ); - break; - case 'sp_player': - echo sp_the_posts( $post_id, 'sp_player' ); - break; - case 'sp_event': - echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—'; - break; - case 'sp_season': - echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—'; - break; - case 'sp_sponsor': - echo get_the_terms ( $post_id, 'sp_sponsor' ) ? the_terms( $post_id, 'sp_sponsor' ) : '—'; - break; - case 'sp_kickoff': - echo ( $post->post_status == 'future' ? __( 'Scheduled' ) : __( 'Played', 'sportspress' ) ) . '
' . date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ); - break; - case 'sp_address': - echo get_post_meta( $post_id, 'sp_address', true ) ? get_post_meta( $post_id, 'sp_address', true ) : '—'; - break; - endswitch; -} -add_action( 'manage_posts_custom_column', 'sp_manage_posts_custom_column', 10, 2 ); -add_action( 'manage_pages_custom_column', 'sp_manage_posts_custom_column', 10, 2 ); - -function sp_manage_posts_columns() { - sp_highlight_admin_menu(); -} -add_action( 'manage_posts_columns', 'sp_manage_posts_columns' ); - -function sp_restrict_manage_posts() { - sp_highlight_admin_menu(); - global $typenow, $wp_query; - if ( in_array( $typenow, array( 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list' ) ) ): - $selected = isset( $_REQUEST['sp_team'] ) ? $_REQUEST['sp_team'] : null; - $args = array( - 'show_option_none' => sprintf( __( 'All %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ), - 'post_type' => 'sp_team', - 'name' => 'sp_team', - 'selected' => $selected - ); - // wp_dropdown_pages( $args ); - endif; - if ( in_array( $typenow, array( 'sp_player' ) ) ): - $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 ); - endif; - if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list' ) ) ): - $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 ); - endif; -} -add_action( 'restrict_manage_posts', 'sp_restrict_manage_posts' ); - -function sp_nonce() { - echo ''; -} - -function sp_save_post( $post_id ) { - global $post, $typenow; - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id; - if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; - if ( !isset( $_POST['sportspress_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_nonce'], plugin_basename( __FILE__ ) ) ) return $post_id; - switch ( $_POST['post_type'] ): - case ( 'sp_team' ): - - // Update columns - update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) ); - - break; - - case ( 'sp_event' ): - - // Get results - $results = (array)sp_array_value( $_POST, 'sp_results', array() ); - - // Update results - update_post_meta( $post_id, 'sp_results', $results ); - - // Update player statistics - update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', array() ) ); - - // Update team array - sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); - - // Update player array - sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) ); - - // Update staff array - sp_update_post_meta_recursive( $post_id, 'sp_staff', sp_array_value( $_POST, 'sp_staff', array() ) ); - - break; - - case ( 'sp_column' ): - - // Update format as string - update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'integer' ) ); - - // Update precision as integer - update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) ); - - // Update equation as string - update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) ); - - // Update sort order as string - update_post_meta( $post_id, 'sp_priority', sp_array_value( $_POST, 'sp_priority', '0' ) ); - - // Update sort order as string - update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', 'DESC' ) ); - - break; - - case ( 'sp_statistic' ): - - // Update format as string - update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'integer' ) ); - - // Update precision as integer - update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) ); - - // Update equation as string - update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) ); - - // Update sort order as string - update_post_meta( $post_id, 'sp_priority', sp_array_value( $_POST, 'sp_priority', '0' ) ); - - // Update sort order as string - update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', 'DESC' ) ); - - break; - - case ( 'sp_result' ): - - // Update format as string - update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'integer' ) ); - - break; - - case ( 'sp_player' ): - - // Update player statistics - update_post_meta( $post_id, 'sp_statistics', sp_array_value( $_POST, 'sp_statistics', array() ) ); - - // Update team array - sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); - - // Update player number - update_post_meta( $post_id, 'sp_number', sp_array_value( $_POST, 'sp_number', '' ) ); - - // Update player details array - update_post_meta( $post_id, 'sp_details', sp_array_value( $_POST, 'sp_details', array() ) ); - - break; - - case ( 'sp_staff' ): - - // Update team array - sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); - - break; - - case ( 'sp_table' ): - - // Update teams array - update_post_meta( $post_id, 'sp_teams', sp_array_value( $_POST, 'sp_teams', array() ) ); - - // Update season taxonomy - wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' ); - - // Update team array - sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); - - break; - - case ( 'sp_list' ): - - // Update players array - update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', array() ) ); - - // Update team array - update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); - - // Update season taxonomy - wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' ); - - //Update player array - sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) ); - - break; - - endswitch; -} -add_action( 'save_post', 'sp_save_post' ); -?> \ No newline at end of file diff --git a/sportspress-filters.php b/sportspress-filters.php deleted file mode 100644 index b9dcea3f..00000000 --- a/sportspress-filters.php +++ /dev/null @@ -1,118 +0,0 @@ - $value ): - $translated_text = str_replace( __( $key ), __( $value, 'sportspress' ), $translated_text ); - endforeach; - endif; - return $translated_text; -} -add_filter( 'admin_post_thumbnail_html', 'sp_admin_post_thumbnail_html', 10, 2 ); - -function sportspress_the_content( $content ) { - if ( is_singular( 'sp_team' ) && in_the_loop() ): - - elseif ( is_singular( 'sp_table' ) && in_the_loop() ): - - global $post; - - // Display league table - $content .= '

' . sp_get_table_html( $post->ID ) . '

'; - - elseif ( is_singular( 'sp_list' ) && in_the_loop() ): - - global $post; - - // Display player list - $content .= '

' . sp_get_list_html( $post->ID ) . '

'; - - endif; - - return $content; -} -add_filter('the_content', 'sportspress_the_content'); - -function sp_sanitize_title( $title ) { - - if ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ): - - $key = $_POST['sp_key']; - - if ( ! $key ) $key = $_POST['post_title']; - - $title = sp_get_eos_safe_slug( $key, sp_array_value( $_POST, 'ID', 'var' ) ); - - elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && $_POST['post_type'] == 'sp_event' ): - - // Auto slug generation - if ( $_POST['post_title'] == '' && ( $_POST['post_name'] == '' || is_int( $_POST['post_name'] ) ) ): - - $title = ''; - - endif; - - endif; - - return $title; -} -add_filter( 'sanitize_title', 'sp_sanitize_title' ); - -function sp_insert_post_data( $data, $postarr ) { - - if( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ): - - $teams = (array)$postarr['sp_team']; - - $team_names = array(); - foreach( $teams as $team ): - $team_names[] = get_the_title( $team ); - endforeach; - - $data['post_title'] = implode( ' ' . __( 'vs', 'sportspress' ) . ' ', $team_names ); - - endif; - - return $data; -} -add_filter( 'wp_insert_post_data' , 'sp_insert_post_data' , '99', 2 ); - -function sp_pre_get_posts( $wp_query ) { - if ( is_admin() ): - $post_type = $wp_query->query['post_type']; - - if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ): - $wp_query->set( 'orderby', 'menu_order' ); - $wp_query->set( 'order', 'ASC' ); - elseif ( $post_type == 'sp_event' ): - $wp_query->set( 'orderby', 'post_date' ); - $wp_query->set( 'order', 'ASC' ); - endif; - endif; -} -add_filter('pre_get_posts', 'sp_pre_get_posts'); -?> \ No newline at end of file diff --git a/sportspress-globals.php b/sportspress-globals.php deleted file mode 100644 index 832e99cc..00000000 --- a/sportspress-globals.php +++ /dev/null @@ -1,99 +0,0 @@ -%1$s', 'sportspress' ); -__( 'Joined: %1$s', 'sportspress' ); -__( 'Select Photo', 'sportspress' ); -__( 'Remove Photo', 'sportspress' ); - -// Localize configuration formats -__( 'Integer', 'sportspress' ); -__( 'Decimal', 'sportspress' ); -__( 'Time', 'sportspress' ); -__( 'Custom Field', 'sportspress' ); - -$sportspress_texts = array( - 'sp_team' => array( - 'Enter title here' => 'Team', - 'Set featured image' => 'Select Logo', - 'Set Featured Image' => 'Select Logo', - 'Remove featured image' => 'Remove Logo', - ), - 'sp_event' => array( - 'Enter title here' => '(no title)', - 'Scheduled for: %1$s' => 'Kick-off: %1$s', - 'Published on: %1$s' => 'Kick-off: %1$s', - 'Publish immediately' => 'Kick-off: %1$s', - ), - 'sp_player' => array( - 'Enter title here' => 'Name', - 'Set featured image' => 'Select Photo', - 'Set Featured Image' => 'Select Photo', - 'Remove featured image' => 'Remove Photo', - 'Scheduled for: %1$s' => 'Joined: %1$s', - 'Published on: %1$s' => 'Joined: %1$s', - 'Publish immediately' => 'Joined: %1$s', - ), - 'sp_staff' => array( - 'Enter title here' => 'Name', - 'Set featured image' => 'Select Photo', - 'Set Featured Image' => 'Select Photo', - 'Remove featured image' => 'Remove Photo', - 'Scheduled for: %1$s' => 'Joined: %1$s', - 'Published on: %1$s' => 'Joined: %1$s', - 'Publish immediately' => 'Joined: %1$s', - ), -); - -$sportspress_thumbnail_texts = array( - 'sp_team' => array( - 'Set featured image' => 'Select Logo', - 'Remove featured image' => 'Remove Logo', - ), - 'sp_player' => array( - 'Set featured image' => 'Select Photo', - 'Remove featured image' => 'Remove Photo', - ), - 'sp_staff' => array( - 'Set featured image' => 'Select Photo', - 'Remove featured image' => 'Remove Photo', - ), -); - -$sportspress_config_formats = array( - 'integer' => 'Integer', - 'decimal' => 'Decimal', - 'time' => 'Time', - 'custom' => 'Custom Field', -); -?> \ No newline at end of file diff --git a/sportspress.php b/sportspress.php index 95578ead..dacc2180 100644 --- a/sportspress.php +++ b/sportspress.php @@ -20,16 +20,16 @@ if ( !function_exists( 'add_action' ) ) { define( 'SPORTSPRESS_VERSION', '0.1' ); define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -define( 'SPORTSPRESS_PLUGIN_DIRNAME', dirname( __FILE__ ) ); +define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); // Libraries include dirname( __FILE__ ) . '/lib/eos/eos.class.php' ; -// Globals -include dirname( __FILE__ ) . '/sportspress-globals.php' ; +// Internationalization +include dirname( __FILE__ ) . '/i18n/strings.php'; // Functions -require_once dirname( __FILE__ ) . '/sportspress-functions.php'; +require_once dirname( __FILE__ ) . '/functions.php'; // Settings include dirname( __FILE__ ) . '/admin/settings/settings.php' ; @@ -72,10 +72,22 @@ include_once dirname( __FILE__ ) . '/admin/presets/volleyball.php'; include dirname( __FILE__ ) . '/install.php'; // Actions -require_once dirname( __FILE__ ) . '/sportspress-actions.php'; +require_once dirname( __FILE__ ) . '/admin/actions/plugins-loaded.php'; +require_once dirname( __FILE__ ) . '/admin/actions/post-thumbnail-html.php'; +require_once dirname( __FILE__ ) . '/admin/actions/after-theme-setup.php'; +require_once dirname( __FILE__ ) . '/admin/actions/admin-menu.php'; +require_once dirname( __FILE__ ) . '/admin/actions/manage-posts-custom-column.php'; +require_once dirname( __FILE__ ) . '/admin/actions/manage-posts-columns.php'; +require_once dirname( __FILE__ ) . '/admin/actions/restrict-manage-posts.php'; +require_once dirname( __FILE__ ) . '/admin/actions/save-post.php'; // Filters -require_once dirname( __FILE__ ) . '/sportspress-filters.php'; +require_once dirname( __FILE__ ) . '/admin/filters/gettext.php'; +require_once dirname( __FILE__ ) . '/admin/filters/admin-post-thumbnail-html.php'; +require_once dirname( __FILE__ ) . '/admin/filters/the-content.php'; +require_once dirname( __FILE__ ) . '/admin/filters/sanitize-title.php'; +require_once dirname( __FILE__ ) . '/admin/filters/wp-insert-post-data.php'; +require_once dirname( __FILE__ ) . '/admin/filters/pre-get-posts.php'; // Admin Styles function sp_admin_styles() {