Merge globals into single file, load options, and add text settings page

This commit is contained in:
Brian Miyaji
2014-03-18 16:39:53 +11:00
parent ee33f7b630
commit 37ebe39620
25 changed files with 748 additions and 497 deletions

View File

@@ -1,8 +1,7 @@
<?php
if ( !function_exists( 'sportspress_countdown' ) ) {
function sportspress_countdown( $args = array() ) {
function sportspress_countdown( $id = null, $args = array() ) {
$id = sportspress_array_value( $args, 'event', null );
$show_league = sportspress_array_value( $args, 'show_league', null );
if ( $id ):
@@ -35,7 +34,7 @@ if ( !function_exists( 'sportspress_countdown' ) ) {
$interval = date_diff( $now, $date );
$output .= '<p class="countdown sp-countdown"><time datetime="' . $post->post_date . '" data-countdown="' . str_replace( '-', '/', $post->post_date ) . '">' .
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->d ) ) . ' <small>' . __( 'days', 'sportspress' ) . '</small></span> ' .
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->days ) ) . ' <small>' . __( 'days', 'sportspress' ) . '</small></span> ' .
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->h ) ) . ' <small>' . __( 'hrs', 'sportspress' ) . '</small></span> ' .
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->i ) ) . ' <small>' . __( 'mins', 'sportspress' ) . '</small></span> ' .
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->s ) ) . ' <small>' . __( 'secs', 'sportspress' ) . '</small></span>' .
@@ -50,3 +49,17 @@ if ( !function_exists( 'sportspress_countdown' ) ) {
}
}
function sportspress_countdown_shortcode( $atts ) {
if ( isset( $atts['id'] ) ):
$id = $atts['id'];
unset( $atts['id'] );
elseif( isset( $atts[0] ) ):
$id = $atts[0];
unset( $atts[0] );
else:
$id = null;
endif;
return sportspress_countdown( $id, $atts );
}
add_shortcode('countdown', 'sportspress_countdown_shortcode');

View File

@@ -203,3 +203,18 @@ if ( !function_exists( 'sportspress_events_calendar' ) ) {
}
}
function sportspress_events_calendar_shortcode( $atts ) {
if ( isset( $atts['id'] ) ):
$id = $atts['id'];
unset( $atts['id'] );
elseif( isset( $atts[0] ) ):
$id = $atts[0];
unset( $atts[0] );
else:
$id = null;
endif;
$initial = isset( $atts['initial'] ) ? $atts['initial'] : true;
return sportspress_events_calendar( $id, $initial, $atts );
}
add_shortcode('events-calendar', 'sportspress_events_calendar_shortcode');

View File

@@ -2,8 +2,8 @@
if ( !function_exists( 'sportspress_events_list' ) ) {
function sportspress_events_list( $id = null, $args = '' ) {
$options = get_option( 'sportspress' );
$main_result = sportspress_array_value( $options, 'main_result', null );
global $sportspress_options;
$main_result = sportspress_array_value( $sportspress_options, 'main_result', null );
$defaults = array(
'show_all_events_link' => false,
@@ -125,3 +125,17 @@ if ( !function_exists( 'sportspress_events_list' ) ) {
}
}
function sportspress_events_list_shortcode( $atts ) {
if ( isset( $atts['id'] ) ):
$id = $atts['id'];
unset( $atts['id'] );
elseif( isset( $atts[0] ) ):
$id = $atts[0];
unset( $atts[0] );
else:
$id = null;
endif;
return sportspress_events_list( $id, $atts );
}
add_shortcode('events-list', 'sportspress_events_list_shortcode');

View File

@@ -2,16 +2,17 @@
if ( !function_exists( 'sportspress_league_table' ) ) {
function sportspress_league_table( $id = null, $args = '' ) {
if ( ! $id )
if ( ! $id || ! is_numeric( $id ) )
$id = get_the_ID();
$options = get_option( 'sportspress' );
global $sportspress_options;
$defaults = array(
'number' => -1,
'columns' => null,
'show_full_table_link' => false,
'show_team_logo' => sportspress_array_value( $options, 'league_table_show_team_logo', false ),
'show_team_logo' => sportspress_array_value( $sportspress_options, 'league_table_show_team_logo', false ),
'link_posts' => sportspress_array_value( $sportspress_options, 'league_table_link_posts', false ),
);
$r = wp_parse_args( $args, $defaults );
@@ -29,6 +30,9 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
$columns = sportspress_array_value( $r, 'columns', null );
if ( ! is_array( $columns ) )
$columns = explode( ',', $columns );
$output .= '<th class="data-number">' . __( 'Pos', 'sportspress' ) . '</th>';
foreach( $labels as $key => $label ):
@@ -58,6 +62,11 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
if ( $r['show_team_logo'] )
$name = get_the_post_thumbnail( $team_id, 'sportspress-fit-icon' ) . ' ' . $name;
if ( $r['link_posts'] ):
$permalink = get_post_permalink( $team_id );
$name = '<a href="' . $permalink . '">' . $name . '</a>';
endif;
$output .= '<td class="data-name">' . $name . '</td>';
foreach( $labels as $key => $value ):
@@ -84,3 +93,17 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
}
}
function sportspress_league_table_shortcode( $atts ) {
if ( isset( $atts['id'] ) ):
$id = $atts['id'];
unset( $atts['id'] );
elseif( isset( $atts[0] ) ):
$id = $atts[0];
unset( $atts[0] );
else:
$id = null;
endif;
return sportspress_league_table( $id, $atts );
}
add_shortcode('league-table', 'sportspress_league_table_shortcode');

View File

@@ -5,6 +5,8 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) {
if ( ! $id )
$id = get_the_ID();
global $sportspress_options;
$defaults = array(
'number' => -1,
'orderby' => 'default',
@@ -15,6 +17,7 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) {
'columns' => 3,
'size' => 'thumbnail',
'show_all_players_link' => false,
'show_names_on_hover' => sportspress_array_value( $sportspress_options, 'player_gallery_show_names_on_hover', true ),
);
$r = wp_parse_args( $args, $defaults );
@@ -93,7 +96,11 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) {
foreach( $data as $player_id => $statistics ):
$caption = get_the_title( $player_id );
if ( $r['show_names_on_hover'] ):
$caption = get_the_title( $player_id );
else:
$caption = null;
endif;
$thumbnail = get_the_post_thumbnail( $player_id, $size );
@@ -104,7 +111,7 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) {
<{$icontag} class='gallery-icon portrait'>"
. '<a href="' . get_permalink( $player_id ) . '">' . $thumbnail . '</a>'
. "</{$icontag}>";
if ( $captiontag && trim($caption) ) {
if ( $captiontag && trim( $caption ) ) {
$output .= '<a href="' . get_permalink( $player_id ) . '">' . "
<{$captiontag} class='wp-caption-text gallery-caption'>
" . wptexturize($caption) . "
@@ -128,3 +135,17 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) {
}
}
function sportspress_player_gallery_shortcode( $atts ) {
if ( isset( $atts['id'] ) ):
$id = $atts['id'];
unset( $atts['id'] );
elseif( isset( $atts[0] ) ):
$id = $atts[0];
unset( $atts[0] );
else:
$id = null;
endif;
return sportspress_player_gallery( $id, $atts );
}
add_shortcode('player-gallery', 'sportspress_player_gallery_shortcode');

View File

@@ -5,12 +5,15 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
if ( ! $id )
$id = get_the_ID();
global $sportspress_options;
$defaults = array(
'number' => -1,
'statistics' => null,
'orderby' => 'default',
'order' => 'ASC',
'show_all_players_link' => false,
'link_posts' => sportspress_array_value( $sportspress_options, 'player_list_link_posts', true ),
);
$r = wp_parse_args( $args, $defaults );
@@ -76,9 +79,12 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
$output .= '<td class="data-number">' . ( $number ? $number : '&nbsp;' ) . '</td>';
endif;
// Name as link
$permalink = get_post_permalink( $player_id );
$output .= '<td class="data-name">' . '<a href="' . $permalink . '">' . $name . '</a></td>';
if ( $r['link_posts'] ):
$permalink = get_post_permalink( $player_id );
$name = '<a href="' . $permalink . '">' . $name . '</a>';
endif;
$output .= '<td class="data-name">' . $name . '</td>';
foreach( $labels as $key => $value ):
if ( $key == 'name' )
@@ -102,3 +108,17 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
}
}
function sportspress_player_list_shortcode( $atts ) {
if ( isset( $atts['id'] ) ):
$id = $atts['id'];
unset( $atts['id'] );
elseif( isset( $atts[0] ) ):
$id = $atts[0];
unset( $atts[0] );
else:
$id = null;
endif;
return sportspress_player_list( $id, $atts );
}
add_shortcode('player-list', 'sportspress_player_list_shortcode');

View File

@@ -7,10 +7,10 @@ if ( !function_exists( 'sportspress_player_metrics' ) ) {
global $sportspress_countries;
$options = get_option( 'sportspress' );
global $sportspress_options;
$defaults = array(
'show_nationality_flag' => sportspress_array_value( $options, 'player_show_nationality_flag', true ),
'show_nationality_flag' => sportspress_array_value( $sportspress_options, 'player_show_nationality_flag', true ),
);
$r = wp_parse_args( $args, $defaults );