Replace deprecated functions

This commit is contained in:
Brian Miyaji
2014-03-28 16:53:15 +11:00
parent 461b4f394c
commit 1add35a47f
58 changed files with 348 additions and 471 deletions

View File

@@ -38,7 +38,7 @@ class SP_Admin_Dashboard {
* Show status widget
*/
public function status_widget() {
$next_event = sportspress_get_next_event();
$next_event = sp_get_next_event();
$now = new DateTime( current_time( 'mysql', 0 ) );
$date = new DateTime( $next_event->post_date );
$interval = date_diff( $now, $date );

View File

@@ -42,15 +42,15 @@ class SP_Admin_Menus {
public function menu_highlight() {
global $typenow;
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) )
sportspress_highlight_admin_menu();
sp_highlight_admin_menu();
elseif ( $typenow == 'sp_calendar' )
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' );
sp_highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' );
elseif ( $typenow == 'sp_table' )
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );
sp_highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );
elseif ( $typenow == 'sp_list' )
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' );
sp_highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' );
elseif ( $typenow == 'sp_directory' )
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit.php?post_type=sp_directory' );
sp_highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit.php?post_type=sp_directory' );
}
/**

View File

@@ -93,7 +93,7 @@ class SP_Admin_Permalink_Settings {
else
update_option( $key, $value );
endforeach;
sportspress_flush_rewrite_rules();
sp_flush_rewrite_rules();
endif;
}
}

View File

@@ -50,8 +50,8 @@ class SP_Admin_Taxonomies {
$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' );
$latitude = sp_array_value( $term_meta, 'sp_latitude', '40.7324319' );
$longitude = sp_array_value( $term_meta, 'sp_longitude', '-73.82480799999996' );
else:
$latitude = '40.7324319';
$longitude = '-73.82480799999996';

View File

@@ -120,8 +120,8 @@ if ( class_exists( 'WP_Importer' ) ) {
$season = ( empty( $_POST['sp_season'] ) ? false : $_POST['sp_season'] );
// Get labels from result and performance post types
$result_labels = sportspress_get_var_labels( 'sp_result' );
$performance_labels = sportspress_get_var_labels( 'sp_performance' );
$result_labels = sp_get_var_labels( 'sp_result' );
$performance_labels = sp_get_var_labels( 'sp_performance' );
while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ):
@@ -311,7 +311,7 @@ if ( class_exists( 'WP_Importer' ) ) {
// Add delimiter if event name is set
if ( $title ):
$title .= ' ' . sportspress_array_value( $sportspress_options, 'event_teams_delimiter', 'vs' ) . ' ';
$title .= ' ' . sp_array_value( $sportspress_options, 'event_teams_delimiter', 'vs' ) . ' ';
endif;
// Append team name to event name
@@ -575,9 +575,9 @@ if ( class_exists( 'WP_Importer' ) ) {
'values' => 'slug',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
if ( ! sp_dropdown_taxonomies( $args ) ):
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?></td>
</tr>
@@ -590,9 +590,9 @@ if ( class_exists( 'WP_Importer' ) ) {
'values' => 'slug',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
if ( ! sp_dropdown_taxonomies( $args ) ):
echo '<p>' . __( 'None', 'sportspress' ) . '</p>';
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?></td>
</tr>

View File

@@ -92,10 +92,10 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
endif;
break;
case 'sp_events':
echo sizeof( sportspress_get_calendar_data( $post_id ) );
echo sizeof( sp_get_calendar_data( $post_id ) );
break;
case 'sp_views':
echo sportspress_get_post_views( $post_id );
echo sp_get_post_views( $post_id );
break;
endswitch;
}
@@ -125,7 +125,7 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
if ( $typenow != 'sp_calendar' )
return;
sportspress_highlight_admin_menu();
sp_highlight_admin_menu();
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
$args = array(
@@ -134,7 +134,7 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
'name' => 'sp_league',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
$args = array(
@@ -143,7 +143,7 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
'name' => 'sp_season',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
$args = array(

View File

@@ -60,13 +60,13 @@ class SP_Admin_CPT_Column extends SP_Admin_CPT {
echo $post->post_name;
break;
case 'sp_equation':
echo sportspress_get_post_equation( $post_id );
echo sp_get_post_equation( $post_id );
break;
case 'sp_precision':
echo sportspress_get_post_precision( $post_id );
echo sp_get_post_precision( $post_id );
break;
case 'sp_order':
echo sportspress_get_post_order( $post_id );
echo sp_get_post_order( $post_id );
break;
endswitch;
}

View File

@@ -69,14 +69,14 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
if ( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ):
$teams = sportspress_array_value( $postarr, 'sp_team', array() );
$teams = sp_array_value( $postarr, 'sp_team', array() );
$team_names = array();
foreach( $teams as $team ):
$team_names[] = get_the_title( $team );
endforeach;
$data['post_title'] = implode( ' ' . sportspress_array_value( $sportspress_options, 'event_teams_delimiter', 'vs' ) . ' ', $team_names );
$data['post_title'] = implode( ' ' . sp_array_value( $sportspress_options, 'event_teams_delimiter', 'vs' ) . ' ', $team_names );
endif;
@@ -152,7 +152,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '&mdash;';
break;
case 'sp_views':
echo sportspress_get_post_views( $post_id );
echo sp_get_post_views( $post_id );
break;
endswitch;
}
@@ -182,7 +182,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
if ( $typenow != 'sp_event' )
return;
sportspress_highlight_admin_menu();
sp_highlight_admin_menu();
$selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
$args = array(
@@ -201,7 +201,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
'name' => 'sp_league',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
$args = array(
@@ -210,7 +210,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
'name' => 'sp_season',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
}
/**

View File

@@ -62,7 +62,7 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
public function custom_columns( $column, $post_id ) {
switch ( $column ):
case 'sp_player':
echo sportspress_posts( $post_id, 'sp_player' );
echo sp_posts( $post_id, 'sp_player' );
break;
case 'sp_league':
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '&mdash;';
@@ -84,7 +84,7 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
endif;
break;
case 'sp_views':
echo sportspress_get_post_views( $post_id );
echo sp_get_post_views( $post_id );
break;
endswitch;
}
@@ -114,7 +114,7 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
if ( $typenow != 'sp_list' )
return;
sportspress_highlight_admin_menu();
sp_highlight_admin_menu();
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
$args = array(
@@ -123,7 +123,7 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
'name' => 'sp_league',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
$args = array(
@@ -132,7 +132,7 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
'name' => 'sp_season',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
$args = array(

View File

@@ -62,7 +62,7 @@ class SP_Admin_CPT_Performance extends SP_Admin_CPT {
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '&mdash;';
break;
case 'sp_calculate':
echo sportspress_get_post_calculate( $post_id );
echo sp_get_post_calculate( $post_id );
break;
endswitch;
}

View File

@@ -89,16 +89,16 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
else:
$results = get_post_meta( $post_id, 'sp_results', true );
global $sportspress_options;
$main_result = sportspress_array_value( $sportspress_options, 'main_result', null );
$main_result = sp_array_value( $sportspress_options, 'main_result', null );
foreach( $teams as $team_id ):
if ( ! $team_id ) continue;
$team = get_post( $team_id );
if ( $team ):
$team_results = sportspress_array_value( $results, $team_id, null );
$team_results = sp_array_value( $results, $team_id, null );
if ( $main_result ):
$team_result = sportspress_array_value( $team_results, $main_result, null );
$team_result = sp_array_value( $team_results, $main_result, null );
else:
if ( is_array( $team_results ) ):
end( $team_results );
@@ -131,7 +131,7 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
echo get_the_terms ( $post_id, 'sp_venue' ) ? the_terms( $post_id, 'sp_venue' ) : '&mdash;';
break;
case 'sp_views':
echo sportspress_get_post_views( $post_id );
echo sp_get_post_views( $post_id );
break;
endswitch;
}
@@ -161,7 +161,7 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
if ( $typenow != 'sp_player' )
return;
sportspress_highlight_admin_menu();
sp_highlight_admin_menu();
$selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
$args = array(
@@ -180,7 +180,7 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
'name' => 'sp_league',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
$args = array(
@@ -189,7 +189,7 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
'name' => 'sp_season',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
}
/**

View File

@@ -108,7 +108,7 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '&mdash;';
break;
case 'sp_views':
echo sportspress_get_post_views( $post_id );
echo sp_get_post_views( $post_id );
break;
endswitch;
}
@@ -138,7 +138,7 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
if ( $typenow != 'sp_staff' )
return;
sportspress_highlight_admin_menu();
sp_highlight_admin_menu();
$selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
$args = array(
@@ -157,7 +157,7 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
'name' => 'sp_league',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
$args = array(
@@ -166,7 +166,7 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
'name' => 'sp_season',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
}
/**

View File

@@ -67,10 +67,10 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '&mdash;';
break;
case 'sp_team':
echo sportspress_posts( $post_id, 'sp_team' );
echo sp_posts( $post_id, 'sp_team' );
break;
case 'sp_views':
echo sportspress_get_post_views( $post_id );
echo sp_get_post_views( $post_id );
break;
endswitch;
}
@@ -100,7 +100,7 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
if ( $typenow != 'sp_table' )
return;
sportspress_highlight_admin_menu();
sp_highlight_admin_menu();
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
$args = array(
@@ -109,7 +109,7 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
'name' => 'sp_league',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
$args = array(
@@ -118,7 +118,7 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
'name' => 'sp_season',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['team'] ) ? $_REQUEST['team'] : null;
$args = array(

View File

@@ -82,7 +82,7 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '&mdash;';
break;
case 'sp_views':
echo sportspress_get_post_views( $post_id );
echo sp_get_post_views( $post_id );
break;
endswitch;
}
@@ -112,7 +112,7 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
if ( $typenow != 'sp_team' )
return;
sportspress_highlight_admin_menu();
sp_highlight_admin_menu();
$selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null;
$args = array(
@@ -121,7 +121,7 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
'name' => 'sp_league',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
$selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null;
$args = array(
@@ -130,7 +130,7 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
'name' => 'sp_season',
'selected' => $selected
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
}
}

View File

@@ -19,17 +19,14 @@ class SP_Meta_Box_Calendar_Data {
* Output the metabox
*/
public static function output( $post ) {
list( $data, $usecolumns ) = sportspress_get_calendar_data( $post->ID, true );
sportspress_edit_calendar_table( $data, $usecolumns );
sportspress_nonce();
list( $data, $usecolumns ) = sp_get_calendar_data( $post->ID, true );
sp_edit_calendar_table( $data, $usecolumns );
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
}
}

View File

@@ -20,9 +20,9 @@ class SP_Meta_Box_Calendar_Details {
*/
public static function output( $post ) {
global $sportspress_formats;
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
$venue_id = sportspress_get_the_term_id( $post->ID, 'sp_venue', 0 );
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
$venue_id = sp_get_the_term_id( $post->ID, 'sp_venue', 0 );
$team_id = get_post_meta( $post->ID, 'sp_team', true );
$formats = get_post_meta( $post->ID, 'sp_format' );
?>
@@ -37,8 +37,8 @@ class SP_Meta_Box_Calendar_Details {
'selected' => $league_id,
'values' => 'term_id'
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -52,8 +52,8 @@ class SP_Meta_Box_Calendar_Details {
'selected' => $season_id,
'values' => 'term_id'
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -67,8 +67,8 @@ class SP_Meta_Box_Calendar_Details {
'selected' => $venue_id,
'values' => 'term_id'
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -82,8 +82,8 @@ class SP_Meta_Box_Calendar_Details {
'selected' => $team_id,
'values' => 'ID'
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -95,9 +95,9 @@ class SP_Meta_Box_Calendar_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
update_post_meta( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', 0 ) );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', 0 ) );
}
}

View File

@@ -34,6 +34,6 @@ class SP_Meta_Box_Calendar_Format {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'calendar' ) );
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'calendar' ) );
}
}

View File

@@ -36,7 +36,7 @@ class SP_Meta_Box_Column_Details {
<p class="sp-equation-selector">
<?php
foreach ( $equation as $piece ):
sportspress_equation_selector( $post->ID, $piece, array( 'team_event', 'result', 'outcome' ) );
sp_equation_selector( $post->ID, $piece, array( 'team_event', 'result', 'outcome' ) );
endforeach;
?>
</p>
@@ -74,10 +74,10 @@ class SP_Meta_Box_Column_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
sportspress_delete_duplicate_post( $_POST );
update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) );
update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) );
update_post_meta( $post_id, 'sp_priority', sportspress_array_value( $_POST, 'sp_priority', '0' ) );
update_post_meta( $post_id, 'sp_order', sportspress_array_value( $_POST, 'sp_order', 'DESC' ) );
sp_delete_duplicate_post( $_POST );
update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) );
update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) );
update_post_meta( $post_id, 'sp_priority', sp_array_value( $_POST, 'sp_priority', '0' ) );
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', 'DESC' ) );
}
}

View File

@@ -19,10 +19,10 @@ class SP_Meta_Box_Event_Details {
* Output the metabox
*/
public static function output( $post ) {
$type = sportspress_get_the_term_id( $post->ID, 'sp_type', null );
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
$venue_id = sportspress_get_the_term_id( $post->ID, 'sp_venue', 0 );
$type = sp_get_the_term_id( $post->ID, 'sp_type', null );
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
$venue_id = sp_get_the_term_id( $post->ID, 'sp_venue', 0 );
?>
<div>
<fieldset class="sp-event-format-field sp-league-event-field sp-friendly-event-field">
@@ -36,8 +36,8 @@ class SP_Meta_Box_Event_Details {
'values' => 'term_id',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -51,8 +51,8 @@ class SP_Meta_Box_Event_Details {
'values' => 'term_id',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -67,8 +67,8 @@ class SP_Meta_Box_Event_Details {
'values' => 'term_id',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_venue', 'sp_event', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( 'sp_venue', 'sp_event', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -80,8 +80,8 @@ class SP_Meta_Box_Event_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_venue', 0 ), 'sp_venue' );
}
}

View File

@@ -34,6 +34,6 @@ class SP_Meta_Box_Event_Format {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'league' ) );
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'league' ) );
}
}

View File

@@ -23,19 +23,19 @@ class SP_Meta_Box_Event_Performance {
$stats = (array)get_post_meta( $post->ID, 'sp_players', true );
// Get columns from performance variables
$columns = sportspress_get_var_labels( 'sp_performance' );
$columns = sp_get_var_labels( 'sp_performance' );
foreach ( $teams as $key => $team_id ):
if ( ! $team_id ) continue;
// Get results for players in the team
$players = sportspress_array_between( (array)get_post_meta( $post->ID, 'sp_player', false ), 0, $key );
$data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
$players = sp_array_between( (array)get_post_meta( $post->ID, 'sp_player', false ), 0, $key );
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
?>
<div>
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
<?php sportspress_edit_event_players_table( $columns, $data, $team_id ); ?>
<?php sp_edit_event_players_table( $columns, $data, $team_id ); ?>
</div>
<?php
@@ -46,6 +46,6 @@ class SP_Meta_Box_Event_Performance {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_players', sportspress_array_value( $_POST, 'sp_players', array() ) );
update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', array() ) );
}
}

View File

@@ -24,14 +24,14 @@ class SP_Meta_Box_Event_Results {
$results = (array)get_post_meta( $post->ID, 'sp_results', true );
// Get columns from result variables
$columns = sportspress_get_var_labels( 'sp_result' );
$columns = sp_get_var_labels( 'sp_result' );
// Get results for all teams
$data = sportspress_array_combine( $teams, $results );
$data = sp_array_combine( $teams, $results );
?>
<div>
<?php sportspress_edit_event_results_table( $columns, $data ); ?>
<?php sp_edit_event_results_table( $columns, $data ); ?>
</div>
<?php
}
@@ -40,7 +40,7 @@ class SP_Meta_Box_Event_Results {
* Save meta box data
*/
public static function save( $post_id, $post ) {
$results = (array)sportspress_array_value( $_POST, 'sp_results', array() );
$results = (array)sp_array_value( $_POST, 'sp_results', array() );
update_post_meta( $post_id, 'sp_results', $results );
}
}

View File

@@ -41,8 +41,8 @@ class SP_Meta_Box_Event_Teams {
<li class="wp-tab"><a href="#sp_staff-all"><?php _e( 'Staff', 'sportspress' ); ?></a></li>
</ul>
<?php
sportspress_post_checklist( $post->ID, 'sp_player', 'block', 'sp_current_team', $key );
sportspress_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_current_team', $key );
sp_post_checklist( $post->ID, 'sp_player', 'block', 'sp_current_team', $key );
sp_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_current_team', $key );
?>
</div>
<?php endforeach; ?>
@@ -67,8 +67,8 @@ class SP_Meta_Box_Event_Teams {
* Save meta box data
*/
public static function save( $post_id, $post ) {
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
sportspress_update_post_meta_recursive( $post_id, 'sp_player', sportspress_array_value( $_POST, 'sp_player', array() ) );
sportspress_update_post_meta_recursive( $post_id, 'sp_staff', sportspress_array_value( $_POST, 'sp_staff', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_staff', sp_array_value( $_POST, 'sp_staff', array() ) );
}
}

View File

@@ -42,6 +42,6 @@ class SP_Meta_Box_Event_Video {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_video', sportspress_array_value( $_POST, 'sp_video', null ) );
update_post_meta( $post_id, 'sp_video', sp_array_value( $_POST, 'sp_video', null ) );
}
}

View File

@@ -19,16 +19,16 @@ class SP_Meta_Box_List_Data {
* Output the metabox
*/
public static function output( $post ) {
list( $columns, $usecolumns, $data, $placeholders, $merged ) = sportspress_get_player_list_data( $post->ID, true );
list( $columns, $usecolumns, $data, $placeholders, $merged ) = sp_get_player_list_data( $post->ID, true );
sportspress_edit_player_list_table( $columns, $usecolumns, $data, $placeholders );
sp_edit_player_list_table( $columns, $usecolumns, $data, $placeholders );
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
update_post_meta( $post_id, 'sp_players', sportspress_array_value( $_POST, 'sp_players', array() ) );
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', array() ) );
}
}

View File

@@ -19,8 +19,8 @@ class SP_Meta_Box_List_Details {
* Output the metabox
*/
public static function output( $post ) {
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
$team_id = get_post_meta( $post->ID, 'sp_team', true );
$orderby = get_post_meta( $post->ID, 'sp_orderby', true );
$order = get_post_meta( $post->ID, 'sp_order', true );
@@ -35,8 +35,8 @@ class SP_Meta_Box_List_Details {
'selected' => $league_id,
'values' => 'term_id',
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -49,8 +49,8 @@ class SP_Meta_Box_List_Details {
'selected' => $season_id,
'values' => 'term_id',
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -64,8 +64,8 @@ class SP_Meta_Box_List_Details {
'selected' => $team_id,
'values' => 'ID',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -83,8 +83,8 @@ class SP_Meta_Box_List_Details {
'selected' => $orderby,
'values' => 'slug',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -97,8 +97,8 @@ class SP_Meta_Box_List_Details {
</p>
<p><strong><?php _e( 'Players', 'sportspress' ); ?></strong></p>
<?php
sportspress_post_checklist( $post->ID, 'sp_player', 'block', 'sp_team' );
sportspress_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
sp_post_checklist( $post->ID, 'sp_player', 'block', 'sp_team' );
sp_post_adder( 'sp_player', __( 'Add New', 'sportspress' ) );
?>
</div>
<?php
@@ -108,11 +108,11 @@ class SP_Meta_Box_List_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
update_post_meta( $post_id, 'sp_orderby', sportspress_array_value( $_POST, 'sp_orderby', array() ) );
update_post_meta( $post_id, 'sp_order', sportspress_array_value( $_POST, 'sp_order', array() ) );
sportspress_update_post_meta_recursive( $post_id, 'sp_player', sportspress_array_value( $_POST, 'sp_player', array() ) );
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
update_post_meta( $post_id, 'sp_orderby', sp_array_value( $_POST, 'sp_orderby', array() ) );
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
}
}

View File

@@ -34,6 +34,6 @@ class SP_Meta_Box_List_Format {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'list' ) );
update_post_meta( $post_id, 'sp_format', sp_array_value( $_POST, 'sp_format', 'list' ) );
}
}

View File

@@ -32,6 +32,6 @@ class SP_Meta_Box_Outcome_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
sportspress_delete_duplicate_post( $_POST );
sp_delete_duplicate_post( $_POST );
}
}

View File

@@ -24,7 +24,7 @@ class SP_Meta_Box_Performance_Details {
?>
<p><strong><?php _e( 'Calculate', 'sportspress' ); ?></strong></p>
<p class="sp-calculate-selector">
<?php sportspress_calculate_selector( $post->ID, $calculate ); ?>
<?php sp_calculate_selector( $post->ID, $calculate ); ?>
</p>
<?php
}
@@ -33,7 +33,7 @@ class SP_Meta_Box_Performance_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
sportspress_delete_duplicate_post( $_POST );
update_post_meta( $post_id, 'sp_calculate', sportspress_array_value( $_POST, 'sp_calculate', 'DESC' ) );
sp_delete_duplicate_post( $_POST );
update_post_meta( $post_id, 'sp_calculate', sp_array_value( $_POST, 'sp_calculate', 'DESC' ) );
}
}

View File

@@ -80,7 +80,7 @@ class SP_Meta_Box_Player_Details {
'property' => 'multiple',
'chosen' => true,
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
?></p>
<p><strong><?php _e( 'Current Team', 'sportspress' ); ?></strong></p>
@@ -95,7 +95,7 @@ class SP_Meta_Box_Player_Details {
'class' => 'sp-current-team widefat',
'chosen' => true,
);
sportspress_dropdown_pages( $args );
sp_dropdown_pages( $args );
?></p>
<p><strong><?php _e( 'Past Teams', 'sportspress' ); ?></strong></p>
@@ -110,7 +110,7 @@ class SP_Meta_Box_Player_Details {
'property' => 'multiple',
'chosen' => true,
);
sportspress_dropdown_pages( $args );
sp_dropdown_pages( $args );
?></p>
<p><strong><?php _e( 'Leagues', 'sportspress' ); ?></strong></p>
@@ -125,7 +125,7 @@ class SP_Meta_Box_Player_Details {
'property' => 'multiple',
'chosen' => true,
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
?></p>
<p><strong><?php _e( 'Seasons', 'sportspress' ); ?></strong></p>
@@ -140,7 +140,7 @@ class SP_Meta_Box_Player_Details {
'property' => 'multiple',
'chosen' => true,
);
sportspress_dropdown_taxonomies( $args );
sp_dropdown_taxonomies( $args );
?></p>
<?php
}
@@ -149,10 +149,10 @@ class SP_Meta_Box_Player_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_number', sportspress_array_value( $_POST, 'sp_number', '' ) );
update_post_meta( $post_id, 'sp_nationality', sportspress_array_value( $_POST, 'sp_nationality', '' ) );
update_post_meta( $post_id, 'sp_current_team', sportspress_array_value( $_POST, 'sp_current_team', null ) );
sportspress_update_post_meta_recursive( $post_id, 'sp_past_team', sportspress_array_value( $_POST, 'sp_past_team', array() ) );
sportspress_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sportspress_array_value( $_POST, 'sp_current_team', null ) ), sportspress_array_value( $_POST, 'sp_past_team', array() ) ) );
update_post_meta( $post_id, 'sp_number', sp_array_value( $_POST, 'sp_number', '' ) );
update_post_meta( $post_id, 'sp_nationality', sp_array_value( $_POST, 'sp_nationality', '' ) );
update_post_meta( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', null ) );
sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', null ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) );
}
}

View File

@@ -50,11 +50,11 @@ class SP_Meta_Box_Player_Metrics {
foreach ( $vars as $var ):
?>
<p><strong><?php echo $var->post_title; ?></strong></p>
<p><input type="text" name="sp_metrics[<?php echo $var->post_name; ?>]" value="<?php echo sportspress_array_value( $metrics, $var->post_name, '' ); ?>" /></p>
<p><input type="text" name="sp_metrics[<?php echo $var->post_name; ?>]" value="<?php echo sp_array_value( $metrics, $var->post_name, '' ); ?>" /></p>
<?php
endforeach;
else:
sportspress_post_adder( 'sp_metric', __( 'Add New', 'sportspress' ) );
sp_post_adder( 'sp_metric', __( 'Add New', 'sportspress' ) );
endif;
}
@@ -62,6 +62,6 @@ class SP_Meta_Box_Player_Metrics {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_metrics', sportspress_array_value( $_POST, 'sp_metrics', array() ) );
update_post_meta( $post_id, 'sp_metrics', sp_array_value( $_POST, 'sp_metrics', array() ) );
}
}

View File

@@ -32,9 +32,9 @@ class SP_Meta_Box_Player_Performance {
<?php
endif;
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = sportspress_get_player_performance_data( $post->ID, $league->term_id, true );
list( $columns, $data, $placeholders, $merged, $seasons_teams ) = sp_get_player_performance_data( $post->ID, $league->term_id, true );
sportspress_edit_player_performance_table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) );
sp_edit_player_performance_table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) );
endforeach;
}
@@ -43,8 +43,8 @@ class SP_Meta_Box_Player_Performance {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_leagues', sportspress_array_value( $_POST, 'sp_leagues', array() ) );
update_post_meta( $post_id, 'sp_leagues', sp_array_value( $_POST, 'sp_leagues', array() ) );
if ( current_user_can( 'edit_sp_teams' ) )
update_post_meta( $post_id, 'sp_performance', sportspress_array_value( $_POST, 'sp_performance', array() ) );
update_post_meta( $post_id, 'sp_performance', sp_array_value( $_POST, 'sp_performance', array() ) );
}
}

View File

@@ -32,6 +32,6 @@ class SP_Meta_Box_Result_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
sportspress_delete_duplicate_post( $_POST );
sp_delete_duplicate_post( $_POST );
}
}

View File

@@ -19,18 +19,15 @@ class SP_Meta_Box_Table_Data {
* Output the metabox
*/
public static function output( $post ) {
list( $columns, $usecolumns, $data, $placeholders, $merged ) = sportspress_get_league_table_data( $post->ID, true );
sportspress_edit_league_table( $columns, $usecolumns, $data, $placeholders );
sportspress_nonce();
list( $columns, $usecolumns, $data, $placeholders, $merged ) = sp_get_league_table_data( $post->ID, true );
sp_edit_league_table( $columns, $usecolumns, $data, $placeholders );
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
update_post_meta( $post_id, 'sp_teams', sportspress_array_value( $_POST, 'sp_teams', array() ) );
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
update_post_meta( $post_id, 'sp_teams', sp_array_value( $_POST, 'sp_teams', array() ) );
}
}

View File

@@ -20,8 +20,8 @@ class SP_Meta_Box_Table_Details {
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
?>
<div>
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
@@ -33,8 +33,8 @@ class SP_Meta_Box_Table_Details {
'selected' => $league_id,
'values' => 'term_id'
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( 'sp_league', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -47,15 +47,15 @@ class SP_Meta_Box_Table_Details {
'selected' => $season_id,
'values' => 'term_id'
);
if ( ! sportspress_dropdown_taxonomies( $args ) ):
sportspress_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_taxonomies( $args ) ):
sp_taxonomy_adder( 'sp_season', 'sp_team', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
<p><strong><?php _e( 'Teams', 'sportspress' ); ?></strong></p>
<?php
sportspress_post_checklist( $post->ID, 'sp_team', 'block', 'sp_season' );
sportspress_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
sp_post_checklist( $post->ID, 'sp_team', 'block', 'sp_season' );
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
?>
</div>
<?php
@@ -65,8 +65,8 @@ class SP_Meta_Box_Table_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
sportspress_update_post_meta_recursive( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
}
}

View File

@@ -19,7 +19,6 @@ class SP_Meta_Box_Team_Columns {
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$leagues = (array)get_the_terms( $post->ID, 'sp_league' );
$league_num = sizeof( $leagues );
@@ -34,9 +33,9 @@ class SP_Meta_Box_Team_Columns {
<?php
endif;
list( $columns, $data, $placeholders, $merged, $leagues_seasons ) = sportspress_get_team_columns_data( $post->ID, $league_id, true );
list( $columns, $data, $placeholders, $merged, $leagues_seasons ) = sp_get_team_columns_data( $post->ID, $league_id, true );
sportspress_edit_team_columns_table( $league_id, $columns, $data, $placeholders, $merged, $leagues_seasons, ! current_user_can( 'edit_sp_tables' ) );
sp_edit_team_columns_table( $league_id, $columns, $data, $placeholders, $merged, $leagues_seasons, ! current_user_can( 'edit_sp_tables' ) );
endforeach;
}
@@ -45,8 +44,8 @@ class SP_Meta_Box_Team_Columns {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_leagues_seasons', sportspress_array_value( $_POST, 'sp_leagues_seasons', array() ) );
update_post_meta( $post_id, 'sp_leagues_seasons', sp_array_value( $_POST, 'sp_leagues_seasons', array() ) );
if ( current_user_can( 'edit_sp_tables' ) )
update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) );
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
}
}

View File

@@ -316,9 +316,9 @@ class SP_Settings_Config extends SP_Settings_Page {
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo $row->post_name; ?></td>
<td><?php echo sportspress_get_post_equation( $row->ID, $row->post_name ); ?></td>
<td><?php echo sportspress_get_post_precision( $row->ID ); ?></td>
<td><?php echo sportspress_get_post_order( $row->ID ); ?></td>
<td><?php echo sp_get_post_equation( $row->ID, $row->post_name ); ?></td>
<td><?php echo sp_get_post_precision( $row->ID ); ?></td>
<td><?php echo sp_get_post_order( $row->ID ); ?></td>
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
</tr>
<?php $i++; endforeach; ?>
@@ -417,7 +417,7 @@ class SP_Settings_Config extends SP_Settings_Page {
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo get_the_terms ( $row->ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : '&mdash;'; ?></td>
<td><?php echo sportspress_get_post_calculate( $row->ID ); ?></td>
<td><?php echo sp_get_post_calculate( $row->ID ); ?></td>
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
</tr>
<?php $i++; endforeach; ?>

View File

@@ -191,7 +191,7 @@ if ( !function_exists( 'sp_flush_rewrite_rules' ) ) {
if ( !function_exists( 'sp_nonce' ) ) {
function sp_nonce() {
echo '<input type="hidden" name="sportspress_nonce" id="sportspress_nonce" value="' . wp_create_nonce( plugin_basename( SP_PLUGIN_FILE ) ) . '" />';
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
}
}
@@ -341,18 +341,6 @@ if ( !function_exists( 'sp_get_post_order' ) ) {
}
}
if ( !function_exists( 'sp_get_config_formats' ) ) {
function sp_get_config_formats() {
$arr = array(
'integer' => __( 'Integer', 'sportspress' ),
'decimal' => __( 'Decimal', 'sportspress' ),
'time' => __( 'Time', 'sportspress' ),
'custom' => __( 'Custom Field', 'sportspress' ),
);
return $arr;
}
}
if ( !function_exists( 'sp_dropdown_taxonomies' ) ) {
function sp_dropdown_taxonomies( $args = array() ) {
$defaults = array(
@@ -589,7 +577,7 @@ if ( !function_exists( 'sp_post_checklist' ) ) {
<ul class="categorychecklist form-no-clear">
<li class="sp-select-all-container"><label class="selectit"><input type="checkbox" class="sp-select-all"> <strong><?php _e( 'Select All', 'sportspress' ); ?></strong></label></li>
<?php
$selected = sportspress_array_between( (array)get_post_meta( $post_id, $meta, false ), 0, $index );
$selected = sp_array_between( (array)get_post_meta( $post_id, $meta, false ), 0, $index );
$posts = get_pages( array( 'post_type' => $meta, 'number' => 0 ) );
if ( empty( $posts ) ):
$query = array( 'post_type' => $meta, 'numberposts' => -1, 'post_per_page' => -1 );
@@ -715,19 +703,19 @@ if ( !function_exists( 'sp_equation_selector' ) ) {
$options[ __( 'Events', 'sportspress' ) ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ) );
break;
case 'result':
$options[ __( 'Results', 'sportspress' ) ] = sportspress_get_equation_optgroup_array( $postid, 'sp_result', array( 'for' => '&rarr;', 'against' => '&larr;' ), null, false );
$options[ __( 'Results', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_result', array( 'for' => '&rarr;', 'against' => '&larr;' ), null, false );
break;
case 'outcome':
$options[ __( 'Outcomes', 'sportspress' ) ] = sportspress_get_equation_optgroup_array( $postid, 'sp_outcome', array() );
$options[ __( 'Outcomes', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_outcome', array() );
$options[ __( 'Outcomes', 'sportspress' ) ]['$streak'] = __( 'Streak', 'sportspress' );
$options[ __( 'Outcomes', 'sportspress' ) ]['$last5'] = __( 'Last 5', 'sportspress' );
$options[ __( 'Outcomes', 'sportspress' ) ]['$last10'] = __( 'Last 10', 'sportspress' );
break;
case 'column':
$options[ __( 'Columns', 'sportspress' ) ] = sportspress_get_equation_optgroup_array( $postid, 'sp_column' );
$options[ __( 'Columns', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_column' );
break;
case 'performance':
$options[ __( 'Performance', 'sportspress' ) ] = sportspress_get_equation_optgroup_array( $postid, 'sp_performance' );
$options[ __( 'Performance', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_performance' );
break;
endswitch;
endforeach;
@@ -772,22 +760,6 @@ if ( !function_exists( 'sp_equation_selector' ) ) {
}
}
if ( !function_exists( 'sp_get_term_names' ) ) {
function sp_get_term_names( $id = null, $post_type = null ) {
if ( ! $id || ! $post_type )
return false;
$terms = get_the_terms( $id, $post_type );
$output = array();
foreach ( $terms as $term ):
$output[ $term->slug ] = $term->name;
endforeach;
return $output;
}
}
if ( !function_exists( 'sp_get_var_labels' ) ) {
function sp_get_var_labels( $post_type ) {
$args = array(
@@ -837,28 +809,6 @@ if ( !function_exists( 'sp_get_var_equations' ) ) {
}
}
if ( !function_exists( 'sp_get_var_calculates' ) ) {
function sp_get_var_calculates( $post_type ) {
$args = array(
'post_type' => $post_type,
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$vars = get_posts( $args );
$output = array();
foreach ( $vars as $var ):
$calculate = get_post_meta( $var->ID, 'sp_calculate', true );
$output[ $var->post_name ] = $calculate;
endforeach;
return $output;
}
}
if ( !function_exists( 'sp_edit_calendar_table' ) ) {
function sp_edit_calendar_table( $data = array(), $usecolumns = null ) {
if ( is_array( $usecolumns ) )
@@ -907,7 +857,7 @@ if ( !function_exists( 'sp_edit_calendar_table' ) ) {
<?php
if ( is_array( $data ) && sizeof( $data ) > 0 ):
global $sportspress_options;
$main_result = sportspress_array_value( $sportspress_options, 'main_result', null );
$main_result = sp_array_value( $sportspress_options, 'main_result', null );
$i = 0;
foreach ( $data as $event ):
$teams = get_post_meta( $event->ID, 'sp_team' );
@@ -922,10 +872,10 @@ if ( !function_exists( 'sp_edit_calendar_table' ) ) {
foreach ( $teams as $team ):
$name = get_the_title( $team );
if ( $name ):
$team_results = sportspress_array_value( $results, $team, null );
$team_results = sp_array_value( $results, $team, null );
if ( $main_result ):
$team_result = sportspress_array_value( $team_results, $main_result, null );
$team_result = sp_array_value( $team_results, $main_result, null );
else:
if ( is_array( $team_results ) ):
end( $team_results );
@@ -992,7 +942,7 @@ if ( !function_exists( 'sp_edit_league_table' ) ) {
if ( is_array( $usecolumns ) )
$usecolumns = array_filter( $usecolumns );
global $sportspress_options;
$show_team_logo = sportspress_array_value( $sportspress_options, 'league_table_show_team_logo', false );
$show_team_logo = sp_array_value( $sportspress_options, 'league_table_show_team_logo', false );
?>
<div class="sp-data-table-container">
<table class="widefat sp-data-table sp-league-table">
@@ -1016,7 +966,7 @@ if ( !function_exists( 'sp_edit_league_table' ) ) {
continue;
$div = get_term( $team_id, 'sp_season' );
$default_name = sportspress_array_value( $team_stats, 'name', '' );
$default_name = sp_array_value( $team_stats, 'name', '' );
if ( $default_name == null )
$default_name = get_the_title( $team_id );
?>
@@ -1028,14 +978,14 @@ if ( !function_exists( 'sp_edit_league_table' ) ) {
<a class="dashicons dashicons-edit sp-edit-name" title="<?php _e( 'Edit', 'sportspress' ); ?>"></a>
</span>
<span class="hidden sp-custom-name">
<input type="text" name="sp_teams[<?php echo $team_id; ?>][name]" class="name sp-custom-name-input" value="<?php echo sportspress_array_value( $team_stats, 'name', '' ); ?>" placeholder="<?php echo get_the_title( $team_id ); ?>">
<input type="text" name="sp_teams[<?php echo $team_id; ?>][name]" class="name sp-custom-name-input" value="<?php echo sp_array_value( $team_stats, 'name', '' ); ?>" placeholder="<?php echo get_the_title( $team_id ); ?>">
<a class="button button-secondary sp-cancel"><?php _e( 'Cancel', 'sportspress' ); ?></a>
<a class="button button-primary sp-save"><?php _e( 'Save', 'sportspress' ); ?></a>
</span>
</td>
<?php foreach( $columns as $column => $label ):
$value = sportspress_array_value( $team_stats, $column, '' );
$placeholder = sportspress_array_value( sportspress_array_value( $placeholders, $team_id, array() ), $column, 0 );
$value = sp_array_value( $team_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $team_id, array() ), $column, 0 );
?>
<td><input type="text" name="sp_teams[<?php echo $team_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
<?php endforeach; ?>
@@ -1094,8 +1044,8 @@ if ( !function_exists( 'sp_edit_player_list_table' ) ) {
<?php echo get_the_title( $player_id ); ?>
</td>
<?php foreach( $columns as $column => $label ):
$value = sportspress_array_value( $player_stats, $column, '' );
$placeholder = sportspress_array_value( sportspress_array_value( $placeholders, $player_id, array() ), $column, 0 );
$value = sp_array_value( $player_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
?>
<td><input type="text" name="sp_players[<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
<?php endforeach; ?>
@@ -1143,17 +1093,17 @@ if ( !function_exists( 'sp_edit_team_columns_table' ) ) {
?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>
<input type="checkbox" name="sp_leagues_seasons[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" id="sp_leagues_seasons_<?php echo $league_id; ?>_<?php echo $div_id; ?>" value="1" <?php checked( sportspress_array_value( $seasons, $div_id, 0 ), 1 ); ?>>
<input type="checkbox" name="sp_leagues_seasons[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" id="sp_leagues_seasons_<?php echo $league_id; ?>_<?php echo $div_id; ?>" value="1" <?php checked( sp_array_value( $seasons, $div_id, 0 ), 1 ); ?>>
</td>
<td>
<label for="sp_leagues_seasons_<?php echo $league_id; ?>_<?php echo $div_id; ?>"><?php echo $div->name; ?></label>
</td>
<?php foreach( $columns as $column => $label ):
$value = sportspress_array_value( sportspress_array_value( $data, $div_id, array() ), $column, 0 );
$value = sp_array_value( sp_array_value( $data, $div_id, array() ), $column, 0 );
?>
<td><?php
$value = sportspress_array_value( sportspress_array_value( $data, $div_id, array() ), $column, null );
$placeholder = sportspress_array_value( sportspress_array_value( $placeholders, $div_id, array() ), $column, 0 );
$value = sp_array_value( sp_array_value( $data, $div_id, array() ), $column, null );
$placeholder = sp_array_value( sp_array_value( $placeholders, $div_id, array() ), $column, 0 );
echo '<input type="text" name="sp_columns[' . $league_id . '][' . $div_id . '][' . $column . ']" value="' . $value . '" placeholder="' . $placeholder . '"' . ( $readonly ? ' disabled="disabled"' : '' ) . ' />';
?></td>
<?php endforeach; ?>
@@ -1200,7 +1150,7 @@ if ( !function_exists( 'sp_edit_player_performance_table' ) ) {
</td>
<td>
<?php
$value = sportspress_array_value( $seasons_teams, $div_id, '-1' );
$value = sp_array_value( $seasons_teams, $div_id, '-1' );
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']',
@@ -1224,7 +1174,7 @@ if ( !function_exists( 'sp_edit_player_performance_table' ) ) {
),
),
);
if ( ! sportspress_dropdown_pages( $args ) ):
if ( ! sp_dropdown_pages( $args ) ):
_e( 'No results found.', 'sportspress' );
endif;
?>
@@ -1232,8 +1182,8 @@ if ( !function_exists( 'sp_edit_player_performance_table' ) ) {
<?php foreach( $columns as $column => $label ):
?>
<td><?php
$value = sportspress_array_value( sportspress_array_value( $data, $div_id, array() ), $column, null );
$placeholder = sportspress_array_value( sportspress_array_value( $placeholders, $div_id, array() ), $column, 0 );
$value = sp_array_value( sp_array_value( $data, $div_id, array() ), $column, null );
$placeholder = sp_array_value( sp_array_value( $placeholders, $div_id, array() ), $column, 0 );
echo '<input type="text" name="sp_performance[' . $league_id . '][' . $div_id . '][' . $column . ']" value="' . $value . '" placeholder="' . $placeholder . '"' . ( $readonly ? ' disabled="disabled"' : '' ) . ' />';
?></td>
<?php endforeach; ?>
@@ -1274,13 +1224,13 @@ if ( !function_exists( 'sp_edit_event_results_table' ) ) {
<?php echo get_the_title( $team_id ); ?>
</td>
<?php foreach( $columns as $column => $label ):
$value = sportspress_array_value( $team_results, $column, '' );
$value = sp_array_value( $team_results, $column, '' );
?>
<td><input type="text" name="sp_results[<?php echo $team_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" /></td>
<?php endforeach; ?>
<td>
<?php
$values = sportspress_array_value( $team_results, 'outcome', '' );
$values = sp_array_value( $team_results, 'outcome', '' );
if ( ! is_array( $values ) )
$values = array( $values );
@@ -1295,7 +1245,7 @@ if ( !function_exists( 'sp_edit_event_results_table' ) ) {
'property' => 'multiple',
'chosen' => true,
);
sportspress_dropdown_pages( $args );
sp_dropdown_pages( $args );
?>
</td>
</tr>
@@ -1384,15 +1334,15 @@ if ( !function_exists( 'sp_edit_event_players_table' ) ) {
<td><?php echo ( $number ? $number : '&nbsp;' ); ?></td>
<td><?php echo get_the_title( $player_id ); ?></td>
<?php foreach( $columns as $column => $label ):
$value = sportspress_array_value( $player_performance, $column, '' );
$value = sp_array_value( $player_performance, $column, '' );
?>
<td>
<input class="sp-player-<?php echo $column; ?>-input" type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" />
</td>
<?php endforeach; ?>
<td class="sp-status-selector">
<?php echo sportspress_event_player_status_selector( $team_id, $player_id, sportspress_array_value( $player_performance, 'status', null ) ); ?>
<?php echo sportspress_event_player_sub_selector( $team_id, $player_id, sportspress_array_value( $player_performance, 'sub', null ), $data ); ?>
<?php echo sp_event_player_status_selector( $team_id, $player_id, sp_array_value( $player_performance, 'status', null ) ); ?>
<?php echo sp_event_player_sub_selector( $team_id, $player_id, sp_array_value( $player_performance, 'sub', null ), $data ); ?>
</td>
</tr>
<?php
@@ -1404,8 +1354,8 @@ if ( !function_exists( 'sp_edit_event_players_table' ) ) {
<td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></td>
<?php foreach( $columns as $column => $label ):
$player_id = 0;
$player_performance = sportspress_array_value( $data, 0, array() );
$value = sportspress_array_value( $player_performance, $column, '' );
$player_performance = sp_array_value( $data, 0, array() );
$value = sp_array_value( $player_performance, $column, '' );
?>
<td><input type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" /></td>
<?php endforeach; ?>
@@ -1418,27 +1368,6 @@ if ( !function_exists( 'sp_edit_event_players_table' ) ) {
}
}
if ( !function_exists( 'sp_player_nationality_selector' ) ) {
function sp_player_nationality_selector( $value = null ) {
$options = array(
'lineup' => __( 'Starting Lineup', 'sportspress' ),
'sub' => __( 'Substitute', 'sportspress' ),
);
$output = '<select name="sp_players[' . $team_id . '][' . $player_id . '][status]">';
foreach( $options as $key => $name ):
$output .= '<option value="' . $key . '"' . ( $key == $value ? ' selected' : '' ) . '>' . $name . '</option>';
endforeach;
$output .= '</select>';
return $output;
}
}
if ( !function_exists( 'sp_post_adder' ) ) {
function sp_post_adder( $post_type = 'post', $label = null ) {
$obj = get_post_type_object( $post_type );
@@ -1491,30 +1420,6 @@ if ( !function_exists( 'sp_update_post_meta_recursive' ) ) {
}
}
if ( !function_exists( 'sp_render_option_field' ) ) {
function sp_render_option_field( $group, $name, $type = 'text' ) {
$options = get_option( $group );
$value = '';
if ( is_array( $options ) && array_key_exists( $name, $options ) ):
$value = $options[ $name ];
endif;
switch ( $type ):
case 'textarea':
echo '<textarea id="' . $name . '" name="' . $group . '[' . $name . ']" rows="10" cols="50">' . $value . '</textarea>';
break;
case 'checkbox':
echo '<input type="checkbox" id="' . $name . '" name="' . $group . '[' . $name . ']" value="1" ' . checked( 1, isset( $value ) ? $value : 0, false ) . '/>';
break;
default:
echo '<input type="text" id="' . $name . '" name="' . $group . '[' . $name . ']" value="' . $value . '" />';
break;
endswitch;
}
}
if ( !function_exists( 'sp_get_eos_safe_slug' ) ) {
function sp_get_eos_safe_slug( $title, $post_id = 'var' ) {
@@ -1522,7 +1427,7 @@ if ( !function_exists( 'sp_get_eos_safe_slug' ) ) {
$title = strtolower( $title );
// Replace all numbers with words
$title = sportspress_numbers_to_words( $title );
$title = sp_numbers_to_words( $title );
// Remove all other non-alphabet characters
$title = preg_replace( "/[^a-z]/", '', $title );
@@ -1530,7 +1435,7 @@ if ( !function_exists( 'sp_get_eos_safe_slug' ) ) {
// Convert post ID to words if title is empty
if ( $title == '' ):
$title = sportspress_numbers_to_words( $post_id );
$title = sp_numbers_to_words( $post_id );
endif;
@@ -1545,12 +1450,12 @@ if ( !function_exists( 'sp_solve' ) ) {
if ( strpos( $equation, '$streak' ) !== false ):
// Return direct value
return sportspress_array_value( $vars, 'streak', '-' );
return sp_array_value( $vars, 'streak', '-' );
elseif ( strpos( $equation, '$last5' ) !== false ):
// Return imploded string
$last5 = sportspress_array_value( $vars, 'last5', array( 0 ) );
$last5 = sp_array_value( $vars, 'last5', array( 0 ) );
if ( array_sum( $last5 ) > 0 ):
return implode( '-', $last5 );
else:
@@ -1560,7 +1465,7 @@ if ( !function_exists( 'sp_solve' ) ) {
elseif ( strpos( $equation, '$last10' ) !== false ):
// Return imploded string
$last10 = sportspress_array_value( $vars, 'last10', array( 0 ) );
$last10 = sp_array_value( $vars, 'last10', array( 0 ) );
if ( array_sum( $last10 ) > 0 ):
return implode( '-', $last10 );
else:
@@ -1574,7 +1479,7 @@ if ( !function_exists( 'sp_solve' ) ) {
unset( $vars['last5'] );
unset( $vars['last10'] );
if ( sportspress_array_value( $vars, 'eventsplayed', 0 ) <= 0 )
if ( sp_array_value( $vars, 'eventsplayed', 0 ) <= 0 )
return '-';
// Clearance to begin calculating remains true if all equation variables are in vars
@@ -1608,20 +1513,6 @@ if ( !function_exists( 'sp_solve' ) ) {
}
if ( !function_exists( 'sp_event_players_lineup_filter' ) ) {
function sp_event_players_lineup_filter( $arr ) {
return sportspress_array_value( $arr, 'status', 'lineup' ) == 'lineup';
}
}
if ( !function_exists( 'sp_event_players_sub_filter' ) ) {
function sp_event_players_sub_filter( $arr ) {
return sportspress_array_value( $arr, 'status', 'lineup' ) == 'sub';
}
}
if ( !function_exists( 'sp_get_calendar_data' ) ) {
function sp_get_calendar_data( $post_id = null, $admin = false ) {
global $pagenow;
@@ -1716,13 +1607,13 @@ if ( !function_exists( 'sp_get_team_columns_data' ) ) {
$seasons = (array)get_the_terms( $post_id, 'sp_season' );
$columns = (array)get_post_meta( $post_id, 'sp_columns', true );
$leagues_seasons = sportspress_array_value( (array)get_post_meta( $post_id, 'sp_leagues_seasons', true ), $league_id, array() );
$leagues_seasons = sp_array_value( (array)get_post_meta( $post_id, 'sp_leagues_seasons', true ), $league_id, array() );
// Get labels from result variables
$result_labels = (array)sportspress_get_var_labels( 'sp_result' );
$result_labels = (array)sp_get_var_labels( 'sp_result' );
// Get labels from outcome variables
$outcome_labels = (array)sportspress_get_var_labels( 'sp_outcome' );
$outcome_labels = (array)sp_get_var_labels( 'sp_outcome' );
// Generate array of all season ids and season names
$div_ids = array();
@@ -1737,10 +1628,10 @@ if ( !function_exists( 'sp_get_team_columns_data' ) ) {
$data = array();
// Get all seasons populated with data where available
$data = sportspress_array_combine( $div_ids, sportspress_array_value( $columns, $league_id, array() ) );
$data = sp_array_combine( $div_ids, sp_array_value( $columns, $league_id, array() ) );
// Get equations from column variables
$equations = sportspress_get_var_equations( 'sp_column' );
$equations = sp_get_var_equations( 'sp_column' );
// Initialize placeholders array
$placeholders = array();
@@ -1885,23 +1776,23 @@ if ( !function_exists( 'sp_get_team_columns_data' ) ) {
// Generate array of placeholder values for each league
$placeholders[ $div_id ] = array();
foreach ( $equations as $key => $value ):
$placeholders[ $div_id ][ $key ] = sportspress_solve( $value['equation'], $totals, $value['precision'] );
$placeholders[ $div_id ][ $key ] = sp_solve( $value['equation'], $totals, $value['precision'] );
endforeach;
endforeach;
// Get columns from column variables
$columns = sportspress_get_var_labels( 'sp_column' );
$columns = sp_get_var_labels( 'sp_column' );
// Merge the data and placeholders arrays
$merged = array();
foreach( $placeholders as $season_id => $season_data ):
if ( ! sportspress_array_value( $leagues_seasons, $season_id, 0 ) )
if ( ! sp_array_value( $leagues_seasons, $season_id, 0 ) )
continue;
$season_name = sportspress_array_value( $season_names, $season_id, '&nbsp;' );
$season_name = sp_array_value( $season_names, $season_id, '&nbsp;' );
// Add season name to row
$merged[ $season_id ] = array(
@@ -1935,20 +1826,20 @@ if ( !function_exists( 'sp_get_team_columns_data' ) ) {
if ( !function_exists( 'sp_get_league_table_data' ) ) {
function sp_get_league_table_data( $post_id, $breakdown = false ) {
$league_id = sportspress_get_the_term_id( $post_id, 'sp_league', 0 );
$div_id = sportspress_get_the_term_id( $post_id, 'sp_season', 0 );
$league_id = sp_get_the_term_id( $post_id, 'sp_league', 0 );
$div_id = sp_get_the_term_id( $post_id, 'sp_season', 0 );
$team_ids = (array)get_post_meta( $post_id, 'sp_team', false );
$table_stats = (array)get_post_meta( $post_id, 'sp_teams', true );
$usecolumns = get_post_meta( $post_id, 'sp_columns', true );
// Get labels from result variables
$result_labels = (array)sportspress_get_var_labels( 'sp_result' );
$result_labels = (array)sp_get_var_labels( 'sp_result' );
// Get labels from outcome variables
$outcome_labels = (array)sportspress_get_var_labels( 'sp_outcome' );
$outcome_labels = (array)sp_get_var_labels( 'sp_outcome' );
// Get all leagues populated with stats where available
$tempdata = sportspress_array_combine( $team_ids, $table_stats );
$tempdata = sp_array_combine( $team_ids, $table_stats );
// Create entry for each team in totals
$totals = array();
@@ -1994,7 +1885,7 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) {
$static = get_post_meta( $team_id, 'sp_columns', true );
// Add static stats to placeholders
$placeholders[ $team_id ] = sportspress_array_value( $static, $div_id, array() );
$placeholders[ $team_id ] = sp_array_value( $static, $div_id, array() );
endforeach;
@@ -2074,7 +1965,7 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) {
$totals[ $team_id ][ $key . 'for' ] += $value;
foreach( $results as $other_team_id => $other_result ):
if ( $other_team_id != $team_id && array_key_exists( $key . 'against', $totals[ $team_id ] ) ):
$totals[ $team_id ][ $key . 'against' ] += sportspress_array_value( $other_result, $key, 0 );
$totals[ $team_id ][ $key . 'against' ] += sp_array_value( $other_result, $key, 0 );
endif;
endforeach;
endif;
@@ -2137,18 +2028,18 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) {
$meta = get_post_meta( $stat->ID );
// Add equation to object
$stat->equation = sportspress_array_value( sportspress_array_value( $meta, 'sp_equation', array() ), 0, 0 );
$stat->precision = sportspress_array_value( sportspress_array_value( $meta, 'sp_precision', array() ), 0, 0 );
$stat->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, 0 );
$stat->precision = sp_array_value( sp_array_value( $meta, 'sp_precision', array() ), 0, 0 );
// Add column name to columns
$columns[ $stat->post_name ] = $stat->post_title;
// Add order to priorities if priority is set and does not exist in array already
$priority = sportspress_array_value( sportspress_array_value( $meta, 'sp_priority', array() ), 0, 0 );
$priority = sp_array_value( sp_array_value( $meta, 'sp_priority', array() ), 0, 0 );
if ( $priority && ! array_key_exists( $priority, $sportspress_column_priorities ) ):
$sportspress_column_priorities[ $priority ] = array(
'column' => $stat->post_name,
'order' => sportspress_array_value( sportspress_array_value( $meta, 'sp_order', array() ), 0, 'DESC' )
'order' => sp_array_value( sp_array_value( $meta, 'sp_order', array() ), 0, 'DESC' )
);
endif;
@@ -2163,8 +2054,8 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) {
continue;
foreach ( $stats as $stat ):
if ( sportspress_array_value( $placeholders[ $team_id ], $stat->post_name, '' ) == '' ):
$placeholders[ $team_id ][ $stat->post_name ] = sportspress_solve( $stat->equation, sportspress_array_value( $totals, $team_id, array() ), $stat->precision );
if ( sp_array_value( $placeholders[ $team_id ], $stat->post_name, '' ) == '' ):
$placeholders[ $team_id ][ $stat->post_name ] = sp_solve( $stat->equation, sp_array_value( $totals, $team_id, array() ), $stat->precision );
endif;
endforeach;
endforeach;
@@ -2191,7 +2082,7 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) {
endforeach;
endforeach;
uasort( $merged, 'sportspress_sort_table_teams' );
uasort( $merged, 'sp_sort_table_teams' );
// Rearrange data array to reflect values
$data = array();
@@ -2216,13 +2107,6 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) {
}
}
if ( !function_exists( 'sp_sort_sports' ) ) {
function sp_sort_sports ( $a, $b ) {
return strcmp( sportspress_array_value( $a, 'name', '' ), sportspress_array_value( $b, 'name', '' ) );
}
}
if ( !function_exists( 'sp_sort_table_teams' ) ) {
function sp_sort_table_teams ( $a, $b ) {
@@ -2232,10 +2116,10 @@ if ( !function_exists( 'sp_sort_table_teams' ) ) {
foreach( $sportspress_column_priorities as $priority ):
// Proceed if columns are not equal
if ( sportspress_array_value( $a, $priority['column'], 0 ) != sportspress_array_value( $b, $priority['column'], 0 ) ):
if ( sp_array_value( $a, $priority['column'], 0 ) != sp_array_value( $b, $priority['column'], 0 ) ):
// Compare column values
$output = sportspress_array_value( $a, $priority['column'], 0 ) - sportspress_array_value( $b, $priority['column'], 0 );
$output = sp_array_value( $a, $priority['column'], 0 ) - sp_array_value( $b, $priority['column'], 0 );
// Flip value if descending order
if ( $priority['order'] == 'DESC' ) $output = 0 - $output;
@@ -2247,14 +2131,14 @@ if ( !function_exists( 'sp_sort_table_teams' ) ) {
endforeach;
// Default sort by alphabetical
return strcmp( sportspress_array_value( $a, 'name', '' ), sportspress_array_value( $b, 'name', '' ) );
return strcmp( sp_array_value( $a, 'name', '' ), sp_array_value( $b, 'name', '' ) );
}
}
if ( !function_exists( 'sp_get_player_list_data' ) ) {
function sp_get_player_list_data( $post_id, $admin = false ) {
$league_id = sportspress_get_the_term_id( $post_id, 'sp_league', 0 );
$div_id = sportspress_get_the_term_id( $post_id, 'sp_season', 0 );
$league_id = sp_get_the_term_id( $post_id, 'sp_league', 0 );
$div_id = sp_get_the_term_id( $post_id, 'sp_season', 0 );
$team_id = get_post_meta( $post_id, 'sp_team', true );
$player_ids = (array)get_post_meta( $post_id, 'sp_player', false );
$stats = (array)get_post_meta( $post_id, 'sp_players', true );
@@ -2263,10 +2147,10 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
$usecolumns = get_post_meta( $post_id, 'sp_columns', true );
// Get labels from result variables
$columns = (array)sportspress_get_var_labels( 'sp_performance' );
$columns = (array)sp_get_var_labels( 'sp_performance' );
// Get all leagues populated with stats where available
$tempdata = sportspress_array_combine( $player_ids, $stats );
$tempdata = sp_array_combine( $player_ids, $stats );
// Create entry for each player in totals
$totals = array();
@@ -2341,7 +2225,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
if ( ! array_key_exists( $team_id, $teams ) )
continue;
$players = sportspress_array_value( $teams, $team_id, array() );
$players = sp_array_value( $teams, $team_id, array() );
foreach ( $players as $player_id => $player_performance ):
@@ -2349,7 +2233,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
continue;
// Increment events played
if ( sportspress_array_value( $player_performance, 'status' ) != 'sub' || sportspress_array_value( $player_performance, 'sub', 0 ) ):
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
$totals[ $player_id ]['eventsplayed']++;
endif;
@@ -2373,7 +2257,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
continue;
// Increment events played
if ( sportspress_array_value( $player_performance, 'status' ) != 'sub' || sportspress_array_value( $player_performance, 'sub', 0 ) ):
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
$totals[ $player_id ]['eventsplayed']++;
endif;
@@ -2410,7 +2294,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
$meta = get_post_meta( $performance->ID );
// Add equation to object
$performance->equation = sportspress_array_value( sportspress_array_value( $meta, 'sp_equation', array() ), 0, 0 );
$performance->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, 0 );
// Add column name to columns
$columns[ $performance->post_name ] = $performance->post_title;
@@ -2429,7 +2313,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
array_unshift( $performances, $epstat );
foreach ( $performances as $performance ):
if ( sportspress_array_value( $placeholders[ $player_id ], $performance->post_name, '' ) == '' ):
if ( sp_array_value( $placeholders[ $player_id ], $performance->post_name, '' ) == '' ):
if ( $performance->post_name == 'eventsplayed' ):
$calculate = 'total';
@@ -2440,17 +2324,17 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
if ( $calculate && $calculate == 'average' ):
// Reflect average
$eventsplayed = (int)sportspress_array_value( $totals[ $player_id ], 'eventsplayed', 0 );
$eventsplayed = (int)sp_array_value( $totals[ $player_id ], 'eventsplayed', 0 );
if ( ! $eventsplayed ):
$placeholders[ $player_id ][ $performance->post_name ] = 0;
else:
$placeholders[ $player_id ][ $performance->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $performance->post_name, 0 ) / $eventsplayed;
$placeholders[ $player_id ][ $performance->post_name ] = sp_array_value( sp_array_value( $totals, $player_id, array() ), $performance->post_name, 0 ) / $eventsplayed;
endif;
else:
// Reflect total
$placeholders[ $player_id ][ $performance->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $performance->post_name, 0 );
$placeholders[ $player_id ][ $performance->post_name ] = sp_array_value( sp_array_value( $totals, $player_id, array() ), $performance->post_name, 0 );
endif;
@@ -2486,7 +2370,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
'order' => $order,
),
);
uasort( $merged, 'sportspress_sort_list_players' );
uasort( $merged, 'sp_sort_list_players' );
endif;
// Rearrange data array to reflect performance
@@ -2514,8 +2398,8 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
if ( !function_exists( 'sp_get_player_roster_data' ) ) {
function sp_get_player_roster_data( $post_id, $admin = false ) {
$league_id = sportspress_get_the_term_id( $post_id, 'sp_league', 0 );
$div_id = sportspress_get_the_term_id( $post_id, 'sp_season', 0 );
$league_id = sp_get_the_term_id( $post_id, 'sp_league', 0 );
$div_id = sp_get_the_term_id( $post_id, 'sp_season', 0 );
$team_id = get_post_meta( $post_id, 'sp_team', true );
$player_ids = (array)get_post_meta( $post_id, 'sp_player', false );
$stats = (array)get_post_meta( $post_id, 'sp_players', true );
@@ -2523,10 +2407,10 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
$order = get_post_meta( $post_id, 'sp_order', true );
// Get labels from result variables
$columns = (array)sportspress_get_var_labels( 'sp_performance' );
$columns = (array)sp_get_var_labels( 'sp_performance' );
// Get all leagues populated with stats where available
$tempdata = sportspress_array_combine( $player_ids, $stats );
$tempdata = sp_array_combine( $player_ids, $stats );
// Create entry for each player in totals
$totals = array();
@@ -2607,7 +2491,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
if ( ! array_key_exists( $team_id, $teams ) )
continue;
$players = sportspress_array_value( $teams, $team_id, array() );
$players = sp_array_value( $teams, $team_id, array() );
foreach ( $players as $player_id => $player_performance ):
@@ -2615,7 +2499,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
continue;
// Increment events played
if ( sportspress_array_value( $player_performance, 'status' ) != 'sub' || sportspress_array_value( $player_performance, 'sub', 0 ) ):
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
$totals[ $player_id ]['eventsplayed']++;
endif;
@@ -2639,7 +2523,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
continue;
// Increment events played
if ( sportspress_array_value( $player_performance, 'status' ) != 'sub' || sportspress_array_value( $player_performance, 'sub', 0 ) ):
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
$totals[ $player_id ]['eventsplayed']++;
endif;
@@ -2676,7 +2560,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
$meta = get_post_meta( $performance->ID );
// Add equation to object
$performance->equation = sportspress_array_value( sportspress_array_value( $meta, 'sp_equation', array() ), 0, 0 );
$performance->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, 0 );
// Add column name to columns
$columns[ $performance->post_name ] = $performance->post_title;
@@ -2695,7 +2579,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
array_unshift( $performances, $epstat );
foreach ( $performances as $performance ):
if ( sportspress_array_value( $placeholders[ $player_id ], $performance->post_name, '' ) == '' ):
if ( sp_array_value( $placeholders[ $player_id ], $performance->post_name, '' ) == '' ):
if ( $performance->post_name == 'eventsplayed' ):
$calculate = 'total';
@@ -2706,17 +2590,17 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
if ( $calculate && $calculate == 'average' ):
// Reflect average
$eventsplayed = (int)sportspress_array_value( $totals[ $player_id ], 'eventsplayed', 0 );
$eventsplayed = (int)sp_array_value( $totals[ $player_id ], 'eventsplayed', 0 );
if ( ! $eventsplayed ):
$placeholders[ $player_id ][ $performance->post_name ] = 0;
else:
$placeholders[ $player_id ][ $performance->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $performance->post_name, 0 ) / $eventsplayed;
$placeholders[ $player_id ][ $performance->post_name ] = sp_array_value( sp_array_value( $totals, $player_id, array() ), $performance->post_name, 0 ) / $eventsplayed;
endif;
else:
// Reflect total
$placeholders[ $player_id ][ $performance->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $performance->post_name, 0 );
$placeholders[ $player_id ][ $performance->post_name ] = sp_array_value( sp_array_value( $totals, $player_id, array() ), $performance->post_name, 0 );
endif;
@@ -2752,7 +2636,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
'order' => $order,
),
);
uasort( $merged, 'sportspress_sort_list_players' );
uasort( $merged, 'sp_sort_list_players' );
endif;
// Rearrange data array to reflect performance
@@ -2780,16 +2664,16 @@ if ( !function_exists( 'sp_sort_list_players' ) ) {
foreach( $sportspress_performance_priorities as $priority ):
// Proceed if columns are not equal
if ( sportspress_array_value( $a, $priority['key'], 0 ) != sportspress_array_value( $b, $priority['key'], 0 ) ):
if ( sp_array_value( $a, $priority['key'], 0 ) != sp_array_value( $b, $priority['key'], 0 ) ):
if ( $priority['key'] == 'name' ):
$output = strcmp( sportspress_array_value( $a, 'name', null ), sportspress_array_value( $b, 'name', null ) );
$output = strcmp( sp_array_value( $a, 'name', null ), sp_array_value( $b, 'name', null ) );
else:
// Compare performance values
$output = sportspress_array_value( $a, $priority['key'], 0 ) - sportspress_array_value( $b, $priority['key'], 0 );
$output = sp_array_value( $a, $priority['key'], 0 ) - sp_array_value( $b, $priority['key'], 0 );
endif;
@@ -2803,7 +2687,7 @@ if ( !function_exists( 'sp_sort_list_players' ) ) {
endforeach;
// Default sort by number
return sportspress_array_value( $a, 'number', 0 ) - sportspress_array_value( $b, 'number', 0 );
return sp_array_value( $a, 'number', 0 ) - sp_array_value( $b, 'number', 0 );
}
}
@@ -2813,17 +2697,17 @@ if ( !function_exists( 'sp_get_player_metrics_data' ) ) {
$metrics = (array)get_post_meta( $post_id, 'sp_metrics', true );
// Get labels from metric variables
$metric_labels = (array)sportspress_get_var_labels( 'sp_metric' );
$metric_labels = (array)sp_get_var_labels( 'sp_metric' );
$data = array();
foreach( $metric_labels as $key => $value ):
$metric = sportspress_array_value( $metrics, $key, null );
$metric = sp_array_value( $metrics, $key, null );
if ( $metric == null )
continue;
$data[ $value ] = sportspress_array_value( $metrics, $key, '&nbsp;' );
$data[ $value ] = sp_array_value( $metrics, $key, '&nbsp;' );
endforeach;
@@ -2838,7 +2722,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
$seasons = (array)get_the_terms( $post_id, 'sp_season' );
$positions = get_the_terms( $post_id, 'sp_position' );
$stats = (array)get_post_meta( $post_id, 'sp_performance', true );
$seasons_teams = sportspress_array_value( (array)get_post_meta( $post_id, 'sp_leagues', true ), $league_id, array() );
$seasons_teams = sp_array_value( (array)get_post_meta( $post_id, 'sp_leagues', true ), $league_id, array() );
$args = array(
'post_type' => 'sp_performance',
@@ -2885,11 +2769,11 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
$tempdata = array();
// Get all seasons populated with stats where available
$tempdata = sportspress_array_combine( $div_ids, sportspress_array_value( $stats, $league_id, array() ) );
$tempdata = sp_array_combine( $div_ids, sp_array_value( $stats, $league_id, array() ) );
foreach ( $div_ids as $div_id ):
$team_id = sportspress_array_value( $seasons_teams, $div_id, '-1' );
$team_id = sp_array_value( $seasons_teams, $div_id, '-1' );
$totals = array( 'eventsattended' => 0, 'eventsplayed' => 0 );
@@ -2930,8 +2814,8 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
// Add all team performance
foreach ( $team_performance as $players ):
if ( array_key_exists( $post_id, $players ) ):
$player_performance = sportspress_array_value( $players, $post_id, array() );
if ( sportspress_array_value( $player_performance, 'status' ) != 'sub' || sportspress_array_value( $player_performance, 'sub', 0 ) ):
$player_performance = sp_array_value( $players, $post_id, array() );
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
$totals['eventsplayed']++;
endif;
foreach ( $player_performance as $key => $value ):
@@ -2950,17 +2834,17 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
if ( $value == 'average' ):
// Reflect average
$eventsplayed = (int)sportspress_array_value( $totals, 'eventsplayed', 0 );
$eventsplayed = (int)sp_array_value( $totals, 'eventsplayed', 0 );
if ( ! $eventsplayed ):
$placeholders[ $div_id ][ $key ] = 0;
else:
$placeholders[ $div_id ][ $key ] = sportspress_array_value( $totals, $key, 0 ) / $eventsplayed;
$placeholders[ $div_id ][ $key ] = sp_array_value( $totals, $key, 0 ) / $eventsplayed;
endif;
else:
// Reflect total
$placeholders[ $div_id ][ $key ] = sportspress_array_value( $totals, $key, 0 );
$placeholders[ $div_id ][ $key ] = sp_array_value( $totals, $key, 0 );
endif;
@@ -2973,7 +2857,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
foreach( $placeholders as $season_id => $season_data ):
$team_id = sportspress_array_value( $seasons_teams, $season_id, array() );
$team_id = sp_array_value( $seasons_teams, $season_id, array() );
if ( ! $team_id || $team_id == '-1' )
continue;
@@ -2981,7 +2865,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
$team_name = get_the_title( $team_id );
$team_permalink = get_permalink( $team_id );
$season_name = sportspress_array_value( $season_names, $season_id, '&nbsp;' );
$season_name = sp_array_value( $season_names, $season_id, '&nbsp;' );
// Add season name to row
$merged[ $season_id ] = array(
@@ -3034,8 +2918,8 @@ if ( !function_exists( 'sp_delete_duplicate_post' ) ) {
$key = isset( $post['sp_key'] ) ? $post['sp_key'] : null;
if ( ! $key ) $key = $post['post_title'];
$id = sportspress_array_value( $post, 'post_ID', 'var' );
$title = sportspress_get_eos_safe_slug( $key, $id );
$id = sp_array_value( $post, 'post_ID', 'var' );
$title = sp_get_eos_safe_slug( $key, $id );
$check_sql = "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $title, $post['post_type'], $id ) );

View File

@@ -49,7 +49,7 @@ function sportspress_default_venue_content( $query ) {
if ( ! is_tax( 'sp_venue' ) )
return;
$slug = sportspress_array_value( $query->query, 'sp_venue', null );
$slug = sp_array_value( $query->query, 'sp_venue', null );
if ( ! $slug )
return;
@@ -57,9 +57,9 @@ function sportspress_default_venue_content( $query ) {
$venue = get_term_by( 'slug', $slug, 'sp_venue' );
$t_id = $venue->term_id;
$venue_meta = get_option( "taxonomy_$t_id" );
$address = sportspress_array_value( $venue_meta, 'sp_address', null );
$latitude = sportspress_array_value( $venue_meta, 'sp_latitude', null );
$longitude = sportspress_array_value( $venue_meta, 'sp_longitude', null );
$address = sp_array_value( $venue_meta, 'sp_address', null );
$latitude = sp_array_value( $venue_meta, 'sp_latitude', null );
$longitude = sp_array_value( $venue_meta, 'sp_longitude', null );
if ( $latitude != null && $longitude != null )
echo '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
@@ -194,13 +194,13 @@ function sportspress_pre_get_posts( $query ) {
}
add_filter('pre_get_posts', 'sportspress_pre_get_posts');
function sportspress_posts_where( $where, $that ) {
function sp_posts_where( $where, $that ) {
global $wpdb;
if( 'sp_event' == $that->query_vars['post_type'] && is_archive() )
$where = str_replace( "{$wpdb->posts}.post_status = 'publish'", "{$wpdb->posts}.post_status = 'publish' OR $wpdb->posts.post_status = 'future'", $where );
return $where;
}
add_filter( 'posts_where', 'sportspress_posts_where', 2, 10 );
add_filter( 'posts_where', 'sp_posts_where', 2, 10 );
function sportspress_sanitize_title( $title ) {
@@ -214,9 +214,9 @@ function sportspress_sanitize_title( $title ) {
if ( ! $key ) $key = $_POST['post_title'];
$id = sportspress_array_value( $_POST, 'post_ID', 'var' );
$id = sp_array_value( $_POST, 'post_ID', 'var' );
$title = sportspress_get_eos_safe_slug( $key, $id );
$title = sp_get_eos_safe_slug( $key, $id );
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && $_POST['post_type'] == 'sp_event' ):
@@ -235,7 +235,7 @@ add_filter( 'sanitize_title', 'sportspress_sanitize_title' );
function sportspress_the_content( $content ) {
if ( is_single() || is_page() )
sportspress_set_post_views( get_the_ID() );
sp_set_post_views( get_the_ID() );
return $content;
}
add_filter( 'the_content', 'sportspress_the_content' );

View File

@@ -49,8 +49,8 @@ class SP_Widget_Countdown extends WP_Widget {
'show_dates' => true,
'post_status' => 'future',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_event', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_event', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>

View File

@@ -49,8 +49,8 @@ class SP_Widget_Event_Calendar extends WP_Widget {
'values' => 'ID',
'class' => 'sp-event-calendar-select widefat',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>

View File

@@ -53,8 +53,8 @@ class SP_Widget_Event_List extends WP_Widget {
'values' => 'ID',
'class' => 'sp-event-calendar-select widefat',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_calendar', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>

View File

@@ -57,8 +57,8 @@ class SP_Widget_League_Table extends WP_Widget {
'values' => 'ID',
'class' => 'widefat',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_table', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_table', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>

View File

@@ -60,8 +60,8 @@ class SP_Widget_Player_Gallery extends WP_Widget {
'values' => 'ID',
'class' => 'widefat',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -85,8 +85,8 @@ class SP_Widget_Player_Gallery extends WP_Widget {
'values' => 'slug',
'class' => 'sp-select-orderby widefat',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>

View File

@@ -60,8 +60,8 @@ class SP_Widget_Player_list extends WP_Widget {
'values' => 'ID',
'class' => 'widefat',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
@@ -106,8 +106,8 @@ class SP_Widget_Player_list extends WP_Widget {
'values' => 'slug',
'class' => 'sp-select-orderby widefat',
);
if ( ! sportspress_dropdown_pages( $args ) ):
sportspress_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
if ( ! sp_dropdown_pages( $args ) ):
sp_post_adder( 'sp_list', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>

View File

@@ -5,7 +5,7 @@ else:
$args = array();
if ( isset( $team ) )
$args = array( 'key' => 'sp_team', 'value' => $team );
$post = sportspress_get_next_event( $args );
$post = sp_get_next_event( $args );
endif;
$output = '';

View File

@@ -15,7 +15,7 @@ $defaults = array(
extract( $defaults, EXTR_SKIP );
if ( isset( $id ) ):
$events = sportspress_get_calendar_data( $id );
$events = sp_get_calendar_data( $id );
$event_ids = array();
foreach ( $events as $event ):
$event_ids[] = $event->ID;

View File

@@ -1,6 +1,6 @@
<?php
global $sportspress_options;
$primary_result = sportspress_array_value( $sportspress_options, 'sportspress_primary_result', null );
$primary_result = sp_array_value( $sportspress_options, 'sportspress_primary_result', null );
$defaults = array(
'number' => -1,
@@ -14,7 +14,7 @@ extract( $defaults, EXTR_SKIP );
<thead>
<tr>
<?php
list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true );
list( $data, $usecolumns ) = sp_get_calendar_data( $id, true );
if ( isset( $columns ) )
$usecolumns = $columns;
@@ -67,10 +67,10 @@ extract( $defaults, EXTR_SKIP );
foreach ( $teams as $team ):
$name = get_the_title( $team );
if ( $name ):
$team_results = sportspress_array_value( $results, $team, null );
$team_results = sp_array_value( $results, $team, null );
if ( $primary_result ):
$team_result = sportspress_array_value( $team_results, $primary_result, null );
$team_result = sp_array_value( $team_results, $primary_result, null );
else:
if ( is_array( $team_results ) ):
end( $team_results );

View File

@@ -7,7 +7,7 @@ if ( ! isset( $id ) )
$teams = (array)get_post_meta( $id, 'sp_team', false );
$staff = (array)get_post_meta( $id, 'sp_staff', false );
$stats = (array)get_post_meta( $id, 'sp_players', true );
$performance_labels = sportspress_get_var_labels( 'sp_performance' );
$performance_labels = sp_get_var_labels( 'sp_performance' );
$link_posts = get_option( 'sportspress_event_link_players', 'yes' ) == 'yes' ? true : false;
$sortable = get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false;
$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false;
@@ -20,11 +20,11 @@ foreach( $teams as $key => $team_id ):
$totals = array();
// Get results for players in the team
$players = sportspress_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
if ( sizeof( $players ) <= 1 ) continue;
$data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
$data = sp_array_combine( $players, sp_array_value( $stats, $team_id, array() ) );
$output .= '<h3>' . get_the_title( $team_id ) . '</h3>';
@@ -108,7 +108,7 @@ foreach( $teams as $key => $team_id ):
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$value = $row[ $key ];
else:
$value = sportspress_array_value( $totals, $key, 0 );
$value = sp_array_value( $totals, $key, 0 );
endif;
$output .= '<td class="data-' . $key . '">' . $value . '</td>';
endforeach;

View File

@@ -3,8 +3,8 @@ if ( ! isset( $id ) )
$id = get_the_ID();
$teams = (array)get_post_meta( $id, 'sp_team', false );
$results = array_filter( sportspress_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) ), 'array_filter' );
$result_labels = sportspress_get_var_labels( 'sp_result' );
$results = array_filter( sp_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) ), 'array_filter' );
$result_labels = sp_get_var_labels( 'sp_result' );
$output = '';
@@ -17,7 +17,7 @@ if ( empty( $results ) )
return false;
foreach( $results as $team_id => $result ):
if ( sportspress_array_value( $result, 'outcome', '-1' ) != '-1' ):
if ( sp_array_value( $result, 'outcome', '-1' ) != '-1' ):
unset( $result['outcome'] );

View File

@@ -14,9 +14,9 @@ foreach( $venues as $venue ):
$t_id = $venue->term_id;
$term_meta = get_option( "taxonomy_$t_id" );
$address = sportspress_array_value( $term_meta, 'sp_address', '' );
$latitude = sportspress_array_value( $term_meta, 'sp_latitude', 0 );
$longitude = sportspress_array_value( $term_meta, 'sp_longitude', 0 );
$address = sp_array_value( $term_meta, 'sp_address', '' );
$latitude = sp_array_value( $term_meta, 'sp_latitude', 0 );
$longitude = sp_array_value( $term_meta, 'sp_longitude', 0 );
$output .= '<h3>' . SP()->text->string('Venue', 'event') . '</h3>';
$output .= '<p><a href="' . get_term_link( $t_id, 'sp_venue' ) . '">' . $venue->name . '</a><br><small>' . $address . '</small></p>';

View File

@@ -17,7 +17,7 @@ extract( $defaults, EXTR_SKIP );
$output = '<div class="sp-table-wrapper">' .
'<table class="sp-league-table sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
$data = sportspress_get_league_table_data( $id );
$data = sp_get_league_table_data( $id );
// The first row should be column labels
$labels = $data[0];
@@ -49,7 +49,7 @@ foreach( $data as $team_id => $row ):
if ( isset( $limit ) && $i >= $limit ) continue;
$name = sportspress_array_value( $row, 'name', null );
$name = sp_array_value( $row, 'name', null );
if ( ! $name ) continue;
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
@@ -71,7 +71,7 @@ foreach( $data as $team_id => $row ):
if ( $key == 'name' )
continue;
if ( ! is_array( $columns ) || in_array( $key, $columns ) )
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '&mdash;' ) . '</td>';
$output .= '<td class="data-' . $key . '">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach;
$output .= '</tr>';

View File

@@ -34,7 +34,7 @@ $float = is_rtl() ? 'right' : 'left';
$selector = 'sp-player-gallery-' . $id;
$data = sportspress_get_player_list_data( $id );
$data = sp_get_player_list_data( $id );
// The first row should be column labels
$labels = $data[0];
@@ -53,7 +53,7 @@ else:
'order' => $order,
),
);
uasort( $data, 'sportspress_sort_list_players' );
uasort( $data, 'sp_sort_list_players' );
endif;
$gallery_style = $gallery_div = '';

View File

@@ -7,7 +7,7 @@ if ( ! isset( $id ) )
$responsive = get_option( 'sportspress_enable_responsive_tables', 'yes' ) == 'yes' ? true : false;
$data = sportspress_get_player_performance_data( $id, $league->term_id );
$data = sp_get_player_performance_data( $id, $league->term_id );
// The first row should be column labels
$labels = $data[0];
@@ -36,7 +36,7 @@ foreach( $data as $season_id => $row ):
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
foreach( $labels as $key => $value ):
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '&mdash;' ) . '</td>';
$output .= '<td class="data-' . $key . '">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach;
$output .= '</tr>';

View File

@@ -18,7 +18,7 @@ extract( $defaults, EXTR_SKIP );
$output = '<div class="sp-table-wrapper">' .
'<table class="sp-player-list sp-data-table' . ( $responsive ? ' sp-responsive-table' : '' ) . ( $sortable ? ' sp-sortable-table' : '' ) . '">' . '<thead>' . '<tr>';
$data = sportspress_get_player_list_data( $id );
$data = sp_get_player_list_data( $id );
// The first row should be column labels
$labels = $data[0];
@@ -37,7 +37,7 @@ else:
'order' => $order,
),
);
uasort( $data, 'sportspress_sort_list_players' );
uasort( $data, 'sp_sort_list_players' );
endif;
if ( in_array( $orderby, array( 'number', 'name' ) ) ):
@@ -61,7 +61,7 @@ if ( is_int( $number ) && $number > 0 )
foreach( $data as $player_id => $row ):
if ( isset( $limit ) && $i >= $limit ) continue;
$name = sportspress_array_value( $row, 'name', null );
$name = sp_array_value( $row, 'name', null );
if ( ! $name ) continue;
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
@@ -85,7 +85,7 @@ foreach( $data as $player_id => $row ):
if ( $key == 'name' )
continue;
if ( ! is_array( $performance ) || in_array( $key, $performance ) )
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '&mdash;' ) . '</td>';
$output .= '<td class="data-' . $key . '">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach;
$output .= '</tr>';

View File

@@ -15,11 +15,11 @@ $countries = SP()->countries->countries;
$nationality = get_post_meta( $id, 'sp_nationality', true );
$current_team = get_post_meta( $id, 'sp_current_team', true );
$past_teams = get_post_meta( $id, 'sp_past_team', false );
$metrics = sportspress_get_player_metrics_data( $id );
$metrics = sp_get_player_metrics_data( $id );
$common = array();
if ( $nationality ):
$country_name = sportspress_array_value( $countries, $nationality, null );
$country_name = sp_array_value( $countries, $nationality, null );
$common[ SP()->text->string('Nationality', 'player') ] = $country_name ? ( $show_nationality_flag ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '&mdash;';
endif;

View File

@@ -12,7 +12,7 @@ $r = wp_parse_args( $args, $defaults );
$output = '';
$data = sportspress_get_player_roster_data( $id );
$data = sp_get_player_roster_data( $id );
// The first row should be column labels
$labels = $data[0];
@@ -20,7 +20,7 @@ $labels = $data[0];
// Remove the first row to leave us with the actual data
unset( $data[0] );
$performance = sportspress_array_value( $r, 'performance', null );
$performance = sp_array_value( $r, 'performance', null );
if ( $r['orderby'] == 'default' ):
$r['orderby'] = get_post_meta( $id, 'sp_orderby', true );
@@ -33,7 +33,7 @@ else:
'order' => $r['order'],
),
);
uasort( $data, 'sportspress_sort_list_players' );
uasort( $data, 'sp_sort_list_players' );
endif;
$positions = get_terms ( 'sp_position' );
@@ -59,14 +59,14 @@ foreach ( $positions as $position ):
// Name as link
$permalink = get_post_permalink( $player_id );
$name = sportspress_array_value( $row, 'name', sportspress_array_value( $row, 'name', '&nbsp;' ) );
$name = sp_array_value( $row, 'name', sp_array_value( $row, 'name', '&nbsp;' ) );
$rows .= '<td class="data-name">' . '<a href="' . $permalink . '">' . $name . '</a></td>';
foreach( $labels as $key => $value ):
if ( $key == 'name' )
continue;
if ( ! is_array( $performance ) || in_array( $key, $performance ) )
$rows .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '&mdash;' ) . '</td>';
$rows .= '<td class="data-' . $key . '">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach;
$rows .= '</tr>';

View File

@@ -12,7 +12,7 @@ $output = '';
// Loop through data for each league
foreach ( $leagues as $league ):
$data = sportspress_get_team_columns_data( $id, $league->term_id );
$data = sp_get_team_columns_data( $id, $league->term_id );
if ( sizeof( $data ) <= 1 )
continue;
@@ -40,7 +40,7 @@ foreach ( $leagues as $league ):
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
foreach( $labels as $key => $value ):
$output .= '<td class="data-' . $key . '">' . sportspress_array_value( $row, $key, '&mdash;' ) . '</td>';
$output .= '<td class="data-' . $key . '">' . sp_array_value( $row, $key, '&mdash;' ) . '</td>';
endforeach;
$output .= '</tr>';