Add team website url feature to admin

This commit is contained in:
Brian Miyaji
2014-05-30 23:19:10 +10:00
parent 2f21a4f3b2
commit 363c3b1532
5 changed files with 36 additions and 1 deletions

View File

@@ -31,6 +31,21 @@
margin-bottom: 1px !important;
}
.sp-link:before {
font: normal 20px/1 'dashicons';
speak: none;
display: inline-block;
padding: 0 2px 0 0;
top: 0;
left: -1px;
position: relative;
vertical-align: top;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none !important;
content: "\f504";
}
.fixed .column-sp_team .result,
.sp-calendar-table .result {
background: #888;

View File

@@ -120,7 +120,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
break;
case 'sp_team':
$teams = (array)get_post_meta( $post_id, 'sp_team', false );
$teams = array_filter( $teams );
$teams = array_unique( array_filter( $teams ) );
if ( empty( $teams ) ):
echo '—';
else:

View File

@@ -61,6 +61,7 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
'cb' => '<input type="checkbox" />',
'sp_icon' => '<span class="dashicons sp-icon-shield tips" title="' . __( 'Logo', 'sportspress' ) . '"></span>',
'title' => __( 'Team', 'sportspress' ),
'sp_url' => __( 'URL', 'sportspress' ),
'sp_abbreviation' => __( 'Abbreviation', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_season' => __( 'Seasons', 'sportspress' ),
@@ -77,6 +78,9 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
case 'sp_icon':
echo has_post_thumbnail( $post_id ) ? edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-fit-mini' ), '', '', $post_id ) : '';
break;
case 'sp_url':
echo sp_get_url( $post_id );
break;
case 'sp_abbreviation':
$abbreviation = get_post_meta ( $post_id, 'sp_abbreviation', true );
echo $abbreviation ? $abbreviation : '&mdash;';

View File

@@ -20,7 +20,14 @@ class SP_Meta_Box_Team_Details {
*/
public static function output( $post ) {
$abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true );
$url = get_post_meta( $post->ID, 'sp_url', true );
?>
<p><strong><?php _e( 'Site URL', 'sportspress' ); ?></strong></p>
<p><input type="text" class="widefat" id="sp_url" name="sp_url" value="<?php echo $url; ?>"></p>
<?php if ( $url ): ?>
<p><a class="sp-link" title="<?php _e( 'Visit Site', 'sportspress' ); ?>" href="<?php echo $url; ?>" target="_blank"><?php _e( 'Visit Site', 'sportspress' ); ?></a></p>
<?php endif; ?>
<p><strong><?php _e( 'Abbreviation', 'sportspress' ); ?></strong></p>
<p><input type="text" id="sp_abbreviation" name="sp_abbreviation" value="<?php echo $abbreviation; ?>"></p>
<p class="description"><?php _e( 'The abbreviation is not prominent by default; however, some themes may show it', 'sportspress' ); ?></p>
@@ -31,6 +38,7 @@ class SP_Meta_Box_Team_Details {
* Save meta box data
*/
public static function save( $post_id, $post ) {
update_post_meta( $post_id, 'sp_url', sp_array_value( $_POST, 'sp_url', '' ) );
update_post_meta( $post_id, 'sp_abbreviation', sp_array_value( $_POST, 'sp_abbreviation', '' ) );
}
}

View File

@@ -285,6 +285,14 @@ if ( !function_exists( 'sp_get_the_term_id' ) ) {
}
}
if ( !function_exists( 'sp_get_url' ) ) {
function sp_get_url( $post_id ) {
$url = get_post_meta( $post_id, 'sp_url', true );
if ( ! $url ) return;
return ' <a class="sp-link" href="' . $url . '" target="_blank" title="' . __( 'Visit Site', 'sportspress' ) . '">' . $url . '</a>';
}
}
if ( !function_exists( 'sp_get_post_precision' ) ) {
function sp_get_post_precision( $post_id ) {
$precision = get_post_meta ( $post_id, 'sp_precision', true );