From 12ba104f194b912c5548839bb9cdfc51a10331a0 Mon Sep 17 00:00:00 2001
From: Sebastian Gurlt
Date: Thu, 17 Mar 2022 09:41:12 +0100
Subject: [PATCH 1/5] Add contact information for staff members.
---
.../post-types/class-sp-admin-cpt-staff.php | 8 ++++++++
.../class-sp-meta-box-staff-details.php | 11 ++++++++++
.../settings/class-sp-settings-staff.php | 17 ++++++++++++++++
includes/class-sp-staff.php | 20 +++++++++++++++++++
templates/staff-details.php | 12 +++++++++++
5 files changed, 68 insertions(+)
diff --git a/includes/admin/post-types/class-sp-admin-cpt-staff.php b/includes/admin/post-types/class-sp-admin-cpt-staff.php
index a185548a..3102adc2 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-staff.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-staff.php
@@ -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(
@@ -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;
}
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php
index 75c800a3..d9f74d56 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php
@@ -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 ) ) :
@@ -164,6 +167,12 @@ public static function output( $post ) {
sp_dropdown_taxonomies( $args );
?>
+
+
+
+
+
+
'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(
diff --git a/includes/class-sp-staff.php b/includes/class-sp-staff.php
index 6187d3d6..50fe884f 100644
--- a/includes/class-sp-staff.php
+++ b/includes/class-sp-staff.php
@@ -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
*
diff --git a/templates/staff-details.php b/templates/staff-details.php
index 4183f460..43263721 100644
--- a/templates/staff-details.php
+++ b/templates/staff-details.php
@@ -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,
);
@@ -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 ) ) :
@@ -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' ) ] = ''.$phone_number.'';
+endif;
+
+if ( $show_mail_address && $mail_address ) :
+ $data[ esc_attr__( 'Mail address', 'sportspress' ) ] = ''.$mail_address.'';;
+endif;
+
$data = apply_filters( 'sportspress_staff_details', $data, $id );
if ( empty( $data ) ) {
From bb09d110c891451f2d4c9d8d1eec176948a7c7b3 Mon Sep 17 00:00:00 2001
From: Sebastian Gurlt
Date: Wed, 23 Mar 2022 13:02:28 +0100
Subject: [PATCH 2/5] Add website field for staff members.
---
includes/admin/post-types/class-sp-admin-cpt-staff.php | 1 +
.../meta-boxes/class-sp-meta-box-staff-details.php | 5 +++++
includes/admin/settings/class-sp-settings-staff.php | 7 +++++++
includes/class-sp-staff.php | 10 ++++++++++
templates/staff-details.php | 8 +++++++-
5 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/includes/admin/post-types/class-sp-admin-cpt-staff.php b/includes/admin/post-types/class-sp-admin-cpt-staff.php
index 3102adc2..b7bf3152 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-staff.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-staff.php
@@ -74,6 +74,7 @@ public function edit_columns( $existing_columns ) {
'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(
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php
index d9f74d56..9bce9099 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-staff-details.php
@@ -26,6 +26,7 @@ public static function output( $post ) {
$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 ) :
@@ -173,6 +174,9 @@ public static function output( $post ) {
+
+
+
'sportspress_staff_show_mail_address',
'default' => 'yes',
'type' => 'checkbox',
+ ),
+
+ array(
+ 'desc' => esc_attr__( 'Display website', 'sportspress' ),
+ 'id' => 'sportspress_staff_show_website',
+ 'default' => 'yes',
+ 'type' => 'checkbox',
'checkboxgroup' => 'end',
),
)
diff --git a/includes/class-sp-staff.php b/includes/class-sp-staff.php
index 50fe884f..b5aba84b 100644
--- a/includes/class-sp-staff.php
+++ b/includes/class-sp-staff.php
@@ -62,6 +62,16 @@ public function mail_address() {
return get_post_meta( $this->ID, 'sp_mail_address', true );
}
+ /**
+ * Returns website
+ *
+ * @access public
+ * @return string
+ */
+ public function website() {
+ return get_post_meta( $this->ID, 'sp_website', true );
+ }
+
/**
* Returns role
*
diff --git a/templates/staff-details.php b/templates/staff-details.php
index 43263721..e3c65d21 100644
--- a/templates/staff-details.php
+++ b/templates/staff-details.php
@@ -25,6 +25,7 @@
'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,
);
@@ -39,6 +40,7 @@
$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 ) ) :
@@ -84,7 +86,11 @@
endif;
if ( $show_mail_address && $mail_address ) :
- $data[ esc_attr__( 'Mail address', 'sportspress' ) ] = ''.$mail_address.'';;
+ $data[ esc_attr__( 'Mail address', 'sportspress' ) ] = ''.$mail_address.'';
+endif;
+
+if ( $show_website && $website ) :
+ $data[ esc_attr__( 'Website', 'sportspress' ) ] = ''.$website.'';
endif;
$data = apply_filters( 'sportspress_staff_details', $data, $id );
From f821367a121de47bb50d1e3aab3ce83dc9257160 Mon Sep 17 00:00:00 2001
From: Sebastian Gurlt
Date: Wed, 23 Mar 2022 13:07:13 +0100
Subject: [PATCH 3/5] Staff - Fix checkbox group.
---
includes/admin/settings/class-sp-settings-staff.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/includes/admin/settings/class-sp-settings-staff.php b/includes/admin/settings/class-sp-settings-staff.php
index 12e63f0f..1614e4e5 100644
--- a/includes/admin/settings/class-sp-settings-staff.php
+++ b/includes/admin/settings/class-sp-settings-staff.php
@@ -114,6 +114,7 @@ public function get_settings() {
'id' => 'sportspress_staff_show_mail_address',
'default' => 'yes',
'type' => 'checkbox',
+ 'checkboxgroup' => '',
),
array(
From 2bf88673030c8b8ed6a0e4b0445b733ae4176595 Mon Sep 17 00:00:00 2001
From: Sebastian Gurlt
Date: Wed, 23 Mar 2022 13:18:19 +0100
Subject: [PATCH 4/5] Fix mail and phone getter.
---
includes/class-sp-staff.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/class-sp-staff.php b/includes/class-sp-staff.php
index b5aba84b..1d54bb76 100644
--- a/includes/class-sp-staff.php
+++ b/includes/class-sp-staff.php
@@ -49,7 +49,7 @@ public function nationalities() {
* @return string
*/
public function phone_number() {
- return get_post_meta( $this->ID, 'sp_phone_number', true );
+ return get_post_meta( $this->ID, 'sp_phone', true );
}
/**
@@ -59,7 +59,7 @@ public function phone_number() {
* @return string
*/
public function mail_address() {
- return get_post_meta( $this->ID, 'sp_mail_address', true );
+ return get_post_meta( $this->ID, 'sp_mail', true );
}
/**
From 0e49ea65df9560519ea27cef0a9334133dd7b032 Mon Sep 17 00:00:00 2001
From: Sebastian Gurlt
Date: Wed, 23 Mar 2022 13:31:59 +0100
Subject: [PATCH 5/5] Show website on staff overview page.
---
includes/admin/post-types/class-sp-admin-cpt-staff.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/includes/admin/post-types/class-sp-admin-cpt-staff.php b/includes/admin/post-types/class-sp-admin-cpt-staff.php
index b7bf3152..d40658c5 100644
--- a/includes/admin/post-types/class-sp-admin-cpt-staff.php
+++ b/includes/admin/post-types/class-sp-admin-cpt-staff.php
@@ -128,6 +128,9 @@ public function custom_columns( $column, $post_id ) {
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;
}