Fix permissions, add post filters
This commit is contained in:
@@ -11,24 +11,26 @@ function sportspress_admin_init() {
|
||||
);
|
||||
|
||||
$caps = array(
|
||||
'publish',
|
||||
'read',
|
||||
'delete',
|
||||
'delete_others',
|
||||
'delete_private',
|
||||
'delete_published',
|
||||
'read_private',
|
||||
'edit',
|
||||
'edit_others',
|
||||
'edit_private',
|
||||
'edit_published',
|
||||
'read_private',
|
||||
'publish',
|
||||
'delete',
|
||||
'delete_others',
|
||||
'delete_private',
|
||||
'delete_published',
|
||||
);
|
||||
|
||||
// Site Admin
|
||||
$administrator = get_role( 'administrator' );
|
||||
|
||||
foreach( $post_types as $post_type ):
|
||||
$administrator->add_cap( 'read_' . $post_type );
|
||||
$administrator->add_cap( 'edit_' . $post_type );
|
||||
$administrator->add_cap( 'delete_' . $post_type );
|
||||
foreach ( $caps as $cap ):
|
||||
$administrator->add_cap( $cap . '_' . $post_type . 's' );
|
||||
endforeach;
|
||||
|
||||
@@ -34,6 +34,7 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
||||
$team = get_post( $team_id );
|
||||
$outcome_slug = sportspress_array_value( sportspress_array_value( $results, $team_id, null ), 'outcome', null );
|
||||
|
||||
echo $team->post_title;
|
||||
if ( $outcome_slug && $outcome_slug != '-1' ):
|
||||
$args=array(
|
||||
'name' => $outcome_slug,
|
||||
@@ -43,10 +44,12 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
||||
);
|
||||
$outcomes = get_posts( $args );
|
||||
|
||||
echo $team->post_title . ( $outcomes ? ' — ' . $outcomes[0]->post_title : '' ) . '<br>';
|
||||
else:
|
||||
echo $team->post_title . '<br>';
|
||||
if ( sizeof( $outcomes ) ):
|
||||
$outcome = reset( $outcomes );
|
||||
echo ' — ' . $outcome->post_title;
|
||||
endif;
|
||||
endif;
|
||||
echo '<br>';
|
||||
endforeach;
|
||||
elseif ( $post_type == 'sp_player' ):
|
||||
$results = get_post_meta( $post_id, 'sp_results', true );
|
||||
|
||||
13
admin/hooks/parse-query.php
Normal file
13
admin/hooks/parse-query.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
function sportspress_parse_query( $query ) {
|
||||
global $pagenow, $typenow;
|
||||
|
||||
if ( is_admin() && $pagenow == 'edit.php' ):
|
||||
|
||||
if( in_array( $typenow, array( 'sp_event', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) && isset( $_GET['team'] ) ):
|
||||
$query->query_vars['meta_key'] = 'sp_team';
|
||||
$query->query_vars['meta_value'] = $_GET['team'];
|
||||
endif;
|
||||
endif;
|
||||
}
|
||||
add_filter('parse_query', 'sportspress_parse_query');
|
||||
@@ -1,15 +1,18 @@
|
||||
<?php
|
||||
function sportspress_pre_get_posts( $wp_query ) {
|
||||
if ( is_admin() ):
|
||||
$post_type = $wp_query->query['post_type'];
|
||||
function sportspress_pre_get_posts( $query ) {
|
||||
if( !is_admin() )
|
||||
return $query;
|
||||
|
||||
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;
|
||||
$post_type = $query->query['post_type'];
|
||||
|
||||
if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ):
|
||||
$query->set( 'orderby', 'menu_order' );
|
||||
$query->set( 'order', 'ASC' );
|
||||
elseif ( $post_type == 'sp_event' ):
|
||||
$query->set( 'orderby', 'post_date' );
|
||||
$query->set( 'order', 'ASC' );
|
||||
endif;
|
||||
|
||||
return $query;
|
||||
}
|
||||
add_filter('pre_get_posts', 'sportspress_pre_get_posts');
|
||||
|
||||
@@ -32,5 +32,16 @@ function sportspress_restrict_manage_posts() {
|
||||
);
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
endif;
|
||||
if ( in_array( $typenow, array( 'sp_event', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ):
|
||||
$selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'team',
|
||||
'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Teams', 'sportspress' ) ),
|
||||
'selected' => $selected,
|
||||
'values' => 'ID',
|
||||
);
|
||||
sportspress_dropdown_pages( $args );
|
||||
endif;
|
||||
}
|
||||
add_action( 'restrict_manage_posts', 'sportspress_restrict_manage_posts' );
|
||||
|
||||
@@ -6,7 +6,7 @@ function sportspress_enqueue_scripts() {
|
||||
// Scripts
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.exp', true );
|
||||
wp_enqueue_script( 'jquery-datatables', SPORTSPRESS_PLUGIN_URL .'/assets/js/jquery.dataTables.min.js', array( 'jquery' ), '1.9.4', true );
|
||||
wp_enqueue_script( 'sportspress', SPORTSPRESS_PLUGIN_URL .'/assets/js/sportspress.js', array( 'jquery' ), time(), true );
|
||||
wp_enqueue_script( 'jquery-datatables', SPORTSPRESS_PLUGIN_URL .'assets/js/jquery.dataTables.min.js', array( 'jquery' ), '1.9.4', true );
|
||||
wp_enqueue_script( 'sportspress', SPORTSPRESS_PLUGIN_URL .'assets/js/sportspress.js', array( 'jquery' ), time(), true );
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'sportspress_enqueue_scripts' );
|
||||
@@ -47,7 +47,7 @@ function sportspress_player_meta_init( $post ) {
|
||||
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_player_team_meta', 'sp_player', 'side', 'high' );
|
||||
add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'sportspress_player_metrics_meta', 'sp_player', 'normal', 'high' );
|
||||
|
||||
if ( $leagues && ! empty( $leagues ) && $seasons && is_array( $seasons ) && is_object( $seasons[0] ) ):
|
||||
if ( $leagues && ! empty( $leagues ) && $seasons && ! empty( $seasons ) ):
|
||||
add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sportspress_player_stats_meta', 'sp_player', 'normal', 'high' );
|
||||
endif;
|
||||
|
||||
@@ -131,7 +131,7 @@ function sportspress_player_stats_meta( $post ) {
|
||||
|
||||
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = sportspress_get_player_statistics_data( $post->ID, $league->term_id, true );
|
||||
|
||||
sportspress_edit_player_statistics_table( $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) );
|
||||
sportspress_edit_player_statistics_table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) );
|
||||
|
||||
endforeach;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,32 @@ global $sportspress_sports;
|
||||
$sportspress_sports['rugby'] = array(
|
||||
'name' => __( 'Rugby', 'sportspress' ),
|
||||
'posts' => array(
|
||||
// Results
|
||||
'sp_result' => array(
|
||||
array(
|
||||
'post_title' => __( 'Points', 'sportspress' ),
|
||||
'post_name' => 'points',
|
||||
),
|
||||
array(
|
||||
'post_title' => __( 'Bonus', 'sportspress' ),
|
||||
'post_name' => 'bonus',
|
||||
),
|
||||
),
|
||||
// Outcomes
|
||||
'sp_outcome' => array(
|
||||
array(
|
||||
'post_title' => 'W',
|
||||
'post_name' => 'w',
|
||||
),
|
||||
array(
|
||||
'post_title' => 'D',
|
||||
'post_name' => 'd',
|
||||
),
|
||||
array(
|
||||
'post_title' => 'L',
|
||||
'post_name' => 'l',
|
||||
),
|
||||
),
|
||||
// Table Columns
|
||||
'sp_column' => array(
|
||||
array(
|
||||
@@ -11,6 +37,7 @@ $sportspress_sports['rugby'] = array(
|
||||
'post_name' => 'p',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$eventsplayed',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
@@ -18,6 +45,7 @@ $sportspress_sports['rugby'] = array(
|
||||
'post_name' => 'w',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$w',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
@@ -25,6 +53,7 @@ $sportspress_sports['rugby'] = array(
|
||||
'post_name' => 'd',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$d',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
@@ -32,54 +61,100 @@ $sportspress_sports['rugby'] = array(
|
||||
'post_name' => 'l',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$l',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'B',
|
||||
'post_name' => 'b',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$b',
|
||||
'sp_equation' => '$bonus',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'F',
|
||||
'post_name' => 'f',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$ptsfor',
|
||||
'sp_equation' => '$pointsfor',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'A',
|
||||
'post_name' => 'a',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$ptsagainst',
|
||||
'sp_equation' => '$pointsagainst',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => '+/-',
|
||||
'post_name' => 'pd',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$ptsfor - $ptsagainst',
|
||||
'sp_equation' => '$pointsfor - $pointsagainst',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'Pts',
|
||||
'post_name' => 'pts',
|
||||
'meta' => array(
|
||||
'sp_equation' => '( $w + $b ) * 2 + $d',
|
||||
'sp_equation' => '( $w + $bonus ) * 2 + $d',
|
||||
'sp_precision' => 1,
|
||||
'sp_priority' => '1',
|
||||
'sp_order' => 'DESC',
|
||||
),
|
||||
),
|
||||
),
|
||||
// Statistics
|
||||
// Player Metrics
|
||||
'sp_metric' => array(
|
||||
array(
|
||||
'post_title' => __( 'Height', 'sportspress' ),
|
||||
'post_name' => 'height',
|
||||
),
|
||||
array(
|
||||
'post_title' => __( 'Weight', 'sportspress' ),
|
||||
'post_name' => 'weight',
|
||||
),
|
||||
),
|
||||
// Player Statistics
|
||||
'sp_statistic' => array(
|
||||
),
|
||||
// Results
|
||||
'sp_result' => array(
|
||||
),
|
||||
// Outcomes
|
||||
'sp_outcome' => array(
|
||||
array(
|
||||
'post_title' => __( 'Points', 'sportspress' ),
|
||||
'post_name' => 'points',
|
||||
'meta' => array(
|
||||
'sp_calculate' => 'sum',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => __( 'Tries', 'sportspress' ),
|
||||
'post_name' => 'tries',
|
||||
'meta' => array(
|
||||
'sp_calculate' => 'sum',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => __( 'Conversions', 'sportspress' ),
|
||||
'post_name' => 'conversions',
|
||||
'meta' => array(
|
||||
'sp_calculate' => 'sum',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => __( 'Penalty Goals', 'sportspress' ),
|
||||
'post_name' => 'penaltygoals',
|
||||
'meta' => array(
|
||||
'sp_calculate' => 'sum',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => __( 'Drop Goals', 'sportspress' ),
|
||||
'post_name' => 'dropgoals',
|
||||
'meta' => array(
|
||||
'sp_calculate' => 'sum',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -4,166 +4,11 @@ global $sportspress_sports;
|
||||
$sportspress_sports['soccer'] = array(
|
||||
'name' => __( 'Association Football (Soccer)', 'sportspress' ),
|
||||
'posts' => array(
|
||||
// Table Columns
|
||||
'sp_column' => array(
|
||||
array(
|
||||
'post_title' => 'P',
|
||||
'post_name' => 'p',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$eventsplayed',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'W',
|
||||
'post_name' => 'w',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$w',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'D',
|
||||
'post_name' => 'd',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$d',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'L',
|
||||
'post_name' => 'l',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$l',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'F',
|
||||
'post_name' => 'f',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$goalsfor',
|
||||
'sp_priority' => '3',
|
||||
'sp_order' => 'DESC',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'A',
|
||||
'post_name' => 'a',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$goalsagainst',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'GD',
|
||||
'post_name' => 'gd',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$goalsfor - $goalsagainst',
|
||||
'sp_priority' => '2',
|
||||
'sp_order' => 'DESC',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'Pts',
|
||||
'post_name' => 'pts',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$w * 3 + $d',
|
||||
'sp_priority' => '1',
|
||||
'sp_order' => 'DESC',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
// Player Statistics
|
||||
'sp_statistic' => array(
|
||||
array(
|
||||
'post_title' => 'Goals',
|
||||
'post_name' => 'goals',
|
||||
'meta' => array(
|
||||
'sp_equation' => '',
|
||||
'sp_priority' => '1',
|
||||
'sp_order' => 'DESC',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'Assists',
|
||||
'post_name' => 'assists',
|
||||
'meta' => array(
|
||||
'sp_equation' => '',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'Yellow Cards',
|
||||
'post_name' => 'yellowcards',
|
||||
'meta' => array(
|
||||
'sp_equation' => '',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'Red Cards',
|
||||
'post_name' => 'redcards',
|
||||
'meta' => array(
|
||||
'sp_equation' => '',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
// Player Metrics
|
||||
'sp_metric' => array(
|
||||
array(
|
||||
'post_title' => 'Appearances',
|
||||
'post_name' => 'appearances',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$eventsplayed',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'Height',
|
||||
'post_name' => 'height',
|
||||
'meta' => array(
|
||||
'sp_equation' => '',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'Weight',
|
||||
'post_name' => 'weight',
|
||||
'meta' => array(
|
||||
'sp_equation' => '',
|
||||
'sp_format' => 'integer',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
// Results
|
||||
'sp_result' => array(
|
||||
array(
|
||||
'post_title' => 'Goals',
|
||||
'post_title' => __( 'Goals', 'sportspress' ),
|
||||
'post_name' => 'goals',
|
||||
'meta' => array(
|
||||
'sp_format' => 'integer',
|
||||
),
|
||||
),
|
||||
),
|
||||
// Outcomes
|
||||
@@ -181,5 +26,120 @@ $sportspress_sports['soccer'] = array(
|
||||
'post_name' => 'l',
|
||||
),
|
||||
),
|
||||
// Table Columns
|
||||
'sp_column' => array(
|
||||
array(
|
||||
'post_title' => 'P',
|
||||
'post_name' => 'p',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$eventsplayed',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'W',
|
||||
'post_name' => 'w',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$w',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'D',
|
||||
'post_name' => 'd',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$d',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'L',
|
||||
'post_name' => 'l',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$l',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'F',
|
||||
'post_name' => 'f',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$goalsfor',
|
||||
'sp_precision' => 1,
|
||||
'sp_priority' => '3',
|
||||
'sp_order' => 'DESC',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'A',
|
||||
'post_name' => 'a',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$goalsagainst',
|
||||
'sp_precision' => 1,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'GD',
|
||||
'post_name' => 'gd',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$goalsfor - $goalsagainst',
|
||||
'sp_precision' => 1,
|
||||
'sp_priority' => '2',
|
||||
'sp_order' => 'DESC',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => 'Pts',
|
||||
'post_name' => 'pts',
|
||||
'meta' => array(
|
||||
'sp_equation' => '$w * 3 + $d',
|
||||
'sp_precision' => 1,
|
||||
'sp_priority' => '1',
|
||||
'sp_order' => 'DESC',
|
||||
),
|
||||
),
|
||||
),
|
||||
// Player Metrics
|
||||
'sp_metric' => array(
|
||||
array(
|
||||
'post_title' => __( 'Height', 'sportspress' ),
|
||||
'post_name' => 'height',
|
||||
),
|
||||
array(
|
||||
'post_title' => __( 'Weight', 'sportspress' ),
|
||||
'post_name' => 'weight',
|
||||
),
|
||||
),
|
||||
// Player Statistics
|
||||
'sp_statistic' => array(
|
||||
array(
|
||||
'post_title' => __( 'Goals', 'sportspress' ),
|
||||
'post_name' => 'goals',
|
||||
'meta' => array(
|
||||
'sp_calculate' => 'sum',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => __( 'Assists', 'sportspress' ),
|
||||
'post_name' => 'assists',
|
||||
'meta' => array(
|
||||
'sp_calculate' => 'sum',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => __( 'Yellow Cards', 'sportspress' ),
|
||||
'post_name' => 'yellowcards',
|
||||
'meta' => array(
|
||||
'sp_calculate' => 'sum',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'post_title' => __( 'Red Cards', 'sportspress' ),
|
||||
'post_name' => 'redcards',
|
||||
'meta' => array(
|
||||
'sp_calculate' => 'sum',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -17,10 +17,14 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
|
||||
$seasons = get_the_terms( $id, 'sp_season' );
|
||||
|
||||
$terms = array();
|
||||
if ( isset( $leagues[0] ) )
|
||||
$terms[] = $leagues[0]->name;
|
||||
if ( isset( $seasons[0] ) )
|
||||
$terms[] = $seasons[0]->name;
|
||||
if ( sizeof( $leagues ) ):
|
||||
$league = reset( $leagues );
|
||||
$terms[] = $league->name;
|
||||
endif;
|
||||
if ( sizeof( $seasons ) ):
|
||||
$season = reset( $seasons );
|
||||
$terms[] = $season->name;
|
||||
endif;
|
||||
|
||||
$title = sizeof( $terms ) ? implode( ' — ', $terms ) : get_the_title( $id );
|
||||
|
||||
|
||||
@@ -57,8 +57,9 @@ add_action( 'sp_venue_edit_form_fields', 'sportspress_venue_edit_form_fields', 1
|
||||
|
||||
// Get latitude and longitude from the last added venue
|
||||
$terms = get_terms( 'sp_venue', $args );
|
||||
if ( $terms && array_key_exists( 0, $terms) && is_object( $terms[0] ) ):
|
||||
$t_id = $terms[0]->term_id;
|
||||
if ( $terms && array_key_exists( 0, $terms) && is_object( reset( $terms ) ) ):
|
||||
$term = reset( $terms );
|
||||
$t_id = $term->term_id;
|
||||
$term_meta = get_option( "taxonomy_$t_id" );
|
||||
$latitude = sportspress_array_value( $term_meta, 'sp_latitude', '40.7324319' );
|
||||
$longitude = sportspress_array_value( $term_meta, 'sp_longitude', '-73.82480799999996' );
|
||||
|
||||
Reference in New Issue
Block a user