From 62888f53715a50800d1e5e47658e9933f694458a Mon Sep 17 00:00:00 2001 From: savvasha Date: Mon, 12 Aug 2019 13:00:03 +0300 Subject: [PATCH] Add comment support to Teams/Clubs pages --- .../admin/settings/class-sp-settings-teams.php | 8 ++++++++ includes/class-sp-post-types.php | 14 ++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/includes/admin/settings/class-sp-settings-teams.php b/includes/admin/settings/class-sp-settings-teams.php index 3043de94..f7023164 100644 --- a/includes/admin/settings/class-sp-settings-teams.php +++ b/includes/admin/settings/class-sp-settings-teams.php @@ -81,6 +81,14 @@ class SP_Settings_Teams extends SP_Settings_Page { 'default' => 'no', 'type' => 'checkbox', ), + + array( + 'title' => __( 'Comments', 'sportspress' ), + 'desc' => __( 'Allow people to post comments on Team page', 'sportspress' ), + 'id' => 'sportspress_team_comment_status', + 'default' => 'no', + 'type' => 'checkbox', + ), )), array( diff --git a/includes/class-sp-post-types.php b/includes/class-sp-post-types.php index 23b5a8f5..b3e82381 100644 --- a/includes/class-sp-post-types.php +++ b/includes/class-sp-post-types.php @@ -447,9 +447,7 @@ class SP_Post_types { register_post_type( 'sp_event', apply_filters( 'sportspress_register_post_type_event', $args ) ); - register_post_type( 'sp_team', - apply_filters( 'sportspress_register_post_type_team', - array( + $args = array( 'labels' => array( 'name' => __( 'Teams', 'sportspress' ), 'singular_name' => __( 'Team', 'sportspress' ), @@ -480,9 +478,13 @@ class SP_Post_types { 'show_in_rest' => true, 'rest_controller_class' => 'SP_REST_Posts_Controller', 'rest_base' => 'teams', - ) - ) - ); + ); + + if ( get_option( 'sportspress_team_comment_status', 'no' ) == 'yes' ): + $args[ 'supports' ][] = 'comments'; + endif; + + register_post_type( 'sp_team', apply_filters( 'sportspress_register_post_type_team', $args ) ); register_post_type( 'sp_player', apply_filters( 'sportspress_register_post_type_player',