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

@@ -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');