From 4ef31bda92435821fd8ace5beaffb883b03ac95b Mon Sep 17 00:00:00 2001 From: "A. H. M. Nazmul Hasan Monshi" Date: Tue, 6 Sep 2022 20:10:17 +0600 Subject: [PATCH 1/4] Css class added for user roles in topics and replies --- src/includes/replies/template.php | 5 ++++- src/includes/topics/template.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/includes/replies/template.php b/src/includes/replies/template.php index 1cc57181..a7931532 100644 --- a/src/includes/replies/template.php +++ b/src/includes/replies/template.php @@ -1353,12 +1353,15 @@ function bbp_reply_author_role( $args = array() ) { * @return string Reply author role */ function bbp_get_reply_author_role( $args = array() ) { + $reply_id = ! empty( $args['reply_id'] ) ? intval( $args['reply_id'] ) : 0; + $reply_id = bbp_get_reply_id( $reply_id ); + $css_role = strtolower( bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ) ); // Parse arguments against default values $r = bbp_parse_args( $args, array( 'reply_id' => 0, 'class' => false, - 'before' => '
', + 'before' => '
', 'after' => '
' ), 'get_reply_author_role' ); diff --git a/src/includes/topics/template.php b/src/includes/topics/template.php index 020f1cc7..fdaf6e10 100644 --- a/src/includes/topics/template.php +++ b/src/includes/topics/template.php @@ -1589,12 +1589,15 @@ function bbp_topic_author_role( $args = array() ) { * @return string topic author role */ function bbp_get_topic_author_role( $args = array() ) { + $topic_id = ! empty( $args['topic_id'] ) ? intval( $args['topic_id'] ) : 0; + $topic_id = bbp_get_topic_id( $topic_id ); + $css_role = strtolower( bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) ) ); // Parse arguments against default values $r = bbp_parse_args( $args, array( 'topic_id' => 0, 'class' => false, - 'before' => '
', + 'before' => '
', 'after' => '
' ), 'get_topic_author_role' ); From a000797d1587ec91b12ae0330cb313e9adce2303 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 7 Sep 2022 08:39:14 +0600 Subject: [PATCH 2/4] Code updated to match coding standard --- src/includes/replies/template.php | 11 ++++++----- src/includes/topics/template.php | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/includes/replies/template.php b/src/includes/replies/template.php index a7931532..e79bae17 100644 --- a/src/includes/replies/template.php +++ b/src/includes/replies/template.php @@ -1353,20 +1353,21 @@ function bbp_reply_author_role( $args = array() ) { * @return string Reply author role */ function bbp_get_reply_author_role( $args = array() ) { - $reply_id = ! empty( $args['reply_id'] ) ? intval( $args['reply_id'] ) : 0; - $reply_id = bbp_get_reply_id( $reply_id ); - $css_role = strtolower( bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ) ); - // Parse arguments against default values $r = bbp_parse_args( $args, array( 'reply_id' => 0, 'class' => false, - 'before' => '
', + 'before' => '
', 'after' => '
' ), 'get_reply_author_role' ); $reply_id = bbp_get_reply_id( $r['reply_id'] ); $role = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ); + $css_role = sanitize_key( strtolower( $role ) ); + + if( empty( $args['before'] ) ) { + $r['before'] = '
'; + } // Backwards compatibilty with old 'class' argument if ( ! empty( $r['class'] ) ) { diff --git a/src/includes/topics/template.php b/src/includes/topics/template.php index fdaf6e10..fe8a0a3f 100644 --- a/src/includes/topics/template.php +++ b/src/includes/topics/template.php @@ -1589,20 +1589,21 @@ function bbp_topic_author_role( $args = array() ) { * @return string topic author role */ function bbp_get_topic_author_role( $args = array() ) { - $topic_id = ! empty( $args['topic_id'] ) ? intval( $args['topic_id'] ) : 0; - $topic_id = bbp_get_topic_id( $topic_id ); - $css_role = strtolower( bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) ) ); - // Parse arguments against default values $r = bbp_parse_args( $args, array( 'topic_id' => 0, 'class' => false, - 'before' => '
', + 'before' => '
', 'after' => '
' ), 'get_topic_author_role' ); $topic_id = bbp_get_topic_id( $r['topic_id'] ); $role = bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) ); + $css_role = sanitize_key( strtolower( $role ) ); + + if( empty( $args['before'] ) ) { + $r['before'] = '
'; + } // Backwards compatibilty with old 'class' argument if ( ! empty( $r['class'] ) ) { From f3523173fabe45e7343f4fcbd1f1fe697fe562a0 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 7 Sep 2022 11:09:24 +0600 Subject: [PATCH 3/4] strtolower removed and using sanitize_key instead --- src/includes/replies/template.php | 2 +- src/includes/topics/template.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/includes/replies/template.php b/src/includes/replies/template.php index e79bae17..96e492ab 100644 --- a/src/includes/replies/template.php +++ b/src/includes/replies/template.php @@ -1363,7 +1363,7 @@ function bbp_get_reply_author_role( $args = array() ) { $reply_id = bbp_get_reply_id( $r['reply_id'] ); $role = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ); - $css_role = sanitize_key( strtolower( $role ) ); + $css_role = sanitize_key( $role ); if( empty( $args['before'] ) ) { $r['before'] = '
'; diff --git a/src/includes/topics/template.php b/src/includes/topics/template.php index fe8a0a3f..0f145292 100644 --- a/src/includes/topics/template.php +++ b/src/includes/topics/template.php @@ -1599,7 +1599,7 @@ function bbp_get_topic_author_role( $args = array() ) { $topic_id = bbp_get_topic_id( $r['topic_id'] ); $role = bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) ); - $css_role = sanitize_key( strtolower( $role ) ); + $css_role = sanitize_key( $role ); if( empty( $args['before'] ) ) { $r['before'] = '
'; From ec6ce96c3ad312e446e146b673ecc2b90443f3e1 Mon Sep 17 00:00:00 2001 From: "A. H. M. Nazmul Hasan Monshi" Date: Sat, 22 Oct 2022 21:25:43 +0600 Subject: [PATCH 4/4] minor change --- src/includes/replies/template.php | 2 +- src/includes/topics/template.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/includes/replies/template.php b/src/includes/replies/template.php index 96e492ab..374bdd6d 100644 --- a/src/includes/replies/template.php +++ b/src/includes/replies/template.php @@ -1365,7 +1365,7 @@ function bbp_get_reply_author_role( $args = array() ) { $role = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ); $css_role = sanitize_key( $role ); - if( empty( $args['before'] ) ) { + if ( empty( $args['before'] ) ) { $r['before'] = '
'; } diff --git a/src/includes/topics/template.php b/src/includes/topics/template.php index 0f145292..d8182ccb 100644 --- a/src/includes/topics/template.php +++ b/src/includes/topics/template.php @@ -1601,7 +1601,7 @@ function bbp_get_topic_author_role( $args = array() ) { $role = bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) ); $css_role = sanitize_key( $role ); - if( empty( $args['before'] ) ) { + if ( empty( $args['before'] ) ) { $r['before'] = '
'; }