Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions includes/admin/post-types/class-sp-admin-cpt-staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public function edit_columns( $existing_columns ) {
'sp_team' => esc_attr__( 'Teams', 'sportspress' ),
'sp_league' => esc_attr__( 'Leagues', 'sportspress' ),
'sp_season' => esc_attr__( 'Seasons', 'sportspress' ),
'sp_phone' => esc_attr__( 'Phone number', 'sportspress' ),
'sp_mail' => esc_attr__( 'Mail address', 'sportspress' ),
),
$existing_columns,
array(
Expand Down Expand Up @@ -119,6 +121,12 @@ public function custom_columns( $column, $post_id ) {
case 'sp_season':
echo get_the_terms( $post_id, 'sp_season' ) ? wp_kses_post( the_terms( $post_id, 'sp_season' ) ) : '—';
break;
case 'sp_phone':
echo esc_html( get_post_meta( $post_id, 'sp_phone', true ) );
break;
case 'sp_mail':
echo esc_html( get_post_meta( $post_id, 'sp_mail', true ) );
break;
endswitch;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$continents = SP()->countries->continents;

$phone = get_post_meta( $post->ID, 'sp_phone', true );
$mail = get_post_meta( $post->ID, 'sp_mail', true );

$nationalities = get_post_meta( $post->ID, 'sp_nationality', false );
foreach ( $nationalities as $index => $nationality ) :
if ( 2 == strlen( $nationality ) ) :
Expand Down Expand Up @@ -164,6 +167,12 @@ public static function output( $post ) {
sp_dropdown_taxonomies( $args );
?>
</p>

<p><strong><?php esc_attr_e( 'Phone number', 'sportspress' ); ?></strong></p>
<p><input type="tel" id="sp_phone" name="sp_phone" value="<?php echo esc_attr( $phone ); ?>"></p>

<p><strong><?php esc_attr_e( 'Mail address', 'sportspress' ); ?></strong></p>
<p><input type="email" id="sp_mail" name="sp_mail" value="<?php echo esc_attr( $mail ); ?>"></p>
<?php
}

Expand All @@ -175,5 +184,7 @@ public static function save( $post_id, $post ) {
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array(), 'id' ) );
sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array(), 'id' ) );
sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array(), 'id' ) ), sp_array_value( $_POST, 'sp_past_team', array(), 'id' ) ) );
update_post_meta( $post_id, 'sp_phone', sp_array_value( $_POST, 'sp_phone', '', 'text' ) );
update_post_meta( $post_id, 'sp_mail', sp_array_value( $_POST, 'sp_mail', '', 'text' ) );
}
}
17 changes: 17 additions & 0 deletions includes/admin/settings/class-sp-settings-staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ public function get_settings() {
'default' => 'yes',
'type' => 'checkbox',
),

array(
'title' => esc_attr__( 'Contact', 'sportspress' ),
'desc' => esc_attr__( 'Display phone number', 'sportspress' ),
'id' => 'sportspress_staff_show_phone_number',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),

array(
'desc' => esc_attr__( 'Display mail address', 'sportspress' ),
'id' => 'sportspress_staff_show_mail_address',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
)
),
array(
Expand Down
20 changes: 20 additions & 0 deletions includes/class-sp-staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ public function nationalities() {
return get_post_meta( $this->ID, 'sp_nationality', false );
}

/**
* Returns phone number
*
* @access public
* @return string
*/
public function phone_number() {
return get_post_meta( $this->ID, 'sp_phone_number', true );
}

/**
* Returns mail address
*
* @access public
* @return string
*/
public function mail_address() {
return get_post_meta( $this->ID, 'sp_mail_address', true );
}

/**
* Returns role
*
Expand Down
12 changes: 12 additions & 0 deletions templates/staff-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
'show_current_teams' => get_option( 'sportspress_staff_show_current_teams', 'yes' ) == 'yes' ? true : false,
'show_past_teams' => get_option( 'sportspress_staff_show_past_teams', 'yes' ) == 'yes' ? true : false,
'show_nationality_flags' => get_option( 'sportspress_staff_show_flags', 'yes' ) == 'yes' ? true : false,
'show_phone_number' => get_option( 'sportspress_staff_show_phone_number', 'yes' ) == 'yes' ? true : false,
'show_mail_address' => get_option( 'sportspress_staff_show_mail_address', 'yes' ) == 'yes' ? true : false,
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
);

Expand All @@ -35,6 +37,8 @@
$nationalities = $staff->nationalities();
$current_teams = $staff->current_teams();
$past_teams = $staff->past_teams();
$phone_number = $staff->phone_number();
$mail_address = $staff->mail_address();

$data = array();
if ( $show_nationality && $nationalities && is_array( $nationalities ) ) :
Expand Down Expand Up @@ -75,6 +79,14 @@
$data[ esc_attr__( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
endif;

if ( $show_phone_number && $phone_number ) :
$data[ esc_attr__( 'Phone number', 'sportspress' ) ] = '<a href="tel:'.$phone_number.'">'.$phone_number.'</a>';
endif;

if ( $show_mail_address && $mail_address ) :
$data[ esc_attr__( 'Mail address', 'sportspress' ) ] = '<a href="mailto:'.$mail_address.'">'.$mail_address.'</a>';;
endif;

$data = apply_filters( 'sportspress_staff_details', $data, $id );

if ( empty( $data ) ) {
Expand Down