Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature staff phone mail website #432

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 12 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,9 @@ 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' ),
'sp_website' => esc_attr__( 'Website', 'sportspress' ),
),
$existing_columns,
array(
Expand Down Expand Up @@ -119,6 +122,15 @@ 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;
case 'sp_website':
echo esc_html( get_post_meta( $post_id, 'sp_website', true ) );
break;
endswitch;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ 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 );
$website = get_post_meta( $post->ID, 'sp_website', 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 +168,15 @@ 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>

<p><strong><?php esc_attr_e( 'Website', 'sportspress' ); ?></strong></p>
<p><input type="url" id="sp_website" name="sp_website" value="<?php echo esc_attr( $website ); ?>"></p>
<?php
}

Expand All @@ -175,5 +188,8 @@ 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' ) );
update_post_meta( $post_id, 'sp_website', sp_array_value( $_POST, 'sp_website', '', 'text' ) );
}
}
25 changes: 25 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,31 @@ 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' => '',
),

array(
'desc' => esc_attr__( 'Display website', 'sportspress' ),
'id' => 'sportspress_staff_show_website',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
)
),
array(
Expand Down
30 changes: 30 additions & 0 deletions includes/class-sp-staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,36 @@ 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', true );
}

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

/**
* Returns website
*
* @access public
* @return string
*/
public function website() {
return get_post_meta( $this->ID, 'sp_website', true );
}

/**
* Returns role
*
Expand Down
18 changes: 18 additions & 0 deletions templates/staff-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
'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,
'show_website' => get_option( 'sportspress_staff_show_website', 'yes' ) == 'yes' ? true : false,
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
);

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

$data = array();
if ( $show_nationality && $nationalities && is_array( $nationalities ) ) :
Expand Down Expand Up @@ -75,6 +81,18 @@
$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;

if ( $show_website && $website ) :
$data[ esc_attr__( 'Website', 'sportspress' ) ] = '<a target="_blank" href="'.$website.'">'.$website.'</a>';
endif;

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

if ( empty( $data ) ) {
Expand Down