extends information on Users page in Admin Menu with comment counts settings page configurable for standard functions easy to integrate (ships with multi/sidebar- and dashboard-widget
Requirement for this plugin: Your users have to be registered and logged in to comment – Thus, Featuring CountComments will not work properly in weblogs where anonymous comments are allowed!
Counts the number of comments made by a user who is currently logged in or has a particular attribute.
$params:
user_attribute: one of the user’s attributes (matching query_type), for example, the user_id or a WP_User object; if no user_attribute is given, will fallback to currently logged in user
query_type: corresponding SQL-field of user’s attribute or WP_User object; default is user_id
user_id
display_name
user_nicename
user_email
user_login
WP_User object
format: if set to true (default), the output will be formatted using the attributes zero, one, more and thousands_separator; false = process plain count value
zero, one, more: for formatted output – %c gets replaced with the number of comments
‘zero’ => ‘0 comments’
‘one’ => ‘1 comment’
‘more’ => ‘%c comments’
thousands_separator: divides counts by thousand delimiters; default , => e.g. 1,386
display: if you want to return the count (e.g. for storing it in a variable) instead of echoing it with this function-call, set display to false; default setting is true
The following example outputs the comment count of the user with the registered e-mail address ‘j.doe@example.com’.
Counts the number of comments made by a user who wrote a certain comment or the current comment in the comment-loop.
$params:
comment: a comment object or comment id; if empty retrieves current comment
format: if set to true (default), the output will be formatted using the attributes zero, one, more and thousands_separator; false = process plain count value
zero, one, more: for formatted output – %c gets replaced with the number of comments
‘zero’ => ‘0 comments’
‘one’ => ‘1 comment’
‘more’ => ‘%c comments’
thousands_separator: divides counts by thousand delimiters default , => e.g. 1,386
display: if you want to return the count (e.g. for storing it in a variable) instead of echoing it with this function-call, set display to false; default setting is true
in_loop: if set to true (default), the query count for all user who wrote a comment which belongs to the post of the handed over comment will be cached; otherwise the comment count will be retrieved only for the user who posted the comment
The following example outputs the number of comments of the author with the current comment in the comment loop:
<?php
global $featuring_countcomments;
$featuring_countcomments->count_by_comment();
?>
In case you want to set the default parameters globally rather than handing them over on every function call, you can add the filterfeaturing_countcomments_defaults in for example featuring-countcomments.php or your own customization plugin (recommended).
Please note that parameters which you hand over to a function call ($featuring_countcomments->count_by_user or $featuring_countcomments->count_by_comment) will always override the defaults parameters, even if they have been set by a filter or in the admin menu.
featuring_countcomments_dashboard_widget
Receives an array which is used for the dashboard-widget-function call to $featuring_countcomments->count_by_user. display and format will automatically be set to true and user_parameter to null to receive the current user’s count.
featuring_countcomments_dashboard_widget_text
Receives a string which is used in the dashboard-widget. %c will be replaced by the comment count of the user who is currently logged in.
featuring_countcomments_dashboard_right_now
Receives an array which is used for the dashboard-right-now-box-function call to $featuring_countcomments->count_by_user. display and format will automatically be set to true and user_parameter to null to retrieve the comment count of currently logged in user.
featuring_countcomments_dashboard_right_now_text
Receives a string which is used in the right-now box on the dashboard. %c will be replaced by the comment count of the user who is currently logged in.
featuring_countcomments_user_profile
Receives an array which is used for the user-profile-function call to $featuring_countcomments->count_by_user. display and format will automatically be set to true and user_parameter to null to retrieve the comment count of currently logged in user.
featuring_countcomments_user_profile_text
Receives a string which is used in the user’s profile page. %c will be replaced by the comment count of the user who is currently logged in.
featuring_countcomments_users_custom_column
Receives an array which is used for the users-page-function call to $featuring_countcomments->count_by_user. display and format will automatically be set to true and user_parameter to the user-id of each row to retrieve the user’s comment count.
This website uses cookies to improve your experience. If you decide to use this website, you agree that certain cookies will be used. If you do not agree please close this website. Read moreACCEPT
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are as essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
Featuring CountComments
€0
extends information on Users page in Admin Menu with comment counts settings page configurable for standard functions easy to integrate (ships with multi/sidebar- and dashboard-widget
1.64
2017.08.30
20
3.3
4.9.23
5.3
0.00
0
Description
Requirement for this plugin: Your users have to be registered and logged in to comment – Thus, Featuring CountComments will not work properly in weblogs where anonymous comments are allowed!
Please find the version for WordPress
Plugin’s website: https://www.bernhard-riedl.com/projects/
Author’s website: https://www.bernhard-riedl.com/
Attention! – Geeks’ stuff ahead! 😉
API
Parameters can either be passed as an array or a URL query type string (e.g. “display=0&format=0”). Please note that WordPress parses all arguments as strings, thus booleans have to be 0 or 1 if used in query type strings whereas for arrays real booleans should be used.
$featuring_countcomments->count_by_user($params=array())
Counts the number of comments made by a user who is currently logged in or has a particular attribute.
$params:
user_attribute
: one of the user’s attributes (matchingquery_type
), for example, the user_id or a WP_User object; if no user_attribute is given, will fallback to currently logged in userquery_type
: corresponding SQL-field of user’s attribute or WP_User object; default isuser_id
format
: if set to true (default), the output will be formatted using the attributeszero
,one
,more
andthousands_separator
; false = process plain count valuezero
,one
,more
: for formatted output – %c gets replaced with the number of commentsthousands_separator
: divides counts by thousand delimiters; default,
=> e.g. 1,386display
: if you want to return the count (e.g. for storing it in a variable) instead of echoing it with this function-call, setdisplay
tofalse
; default setting istrue
The following example outputs the comment count of the user with the registered e-mail address ‘j.doe@example.com’.
$featuring_countcomments->count_by_comment($params=array())
Counts the number of comments made by a user who wrote a certain comment or the current comment in the comment-loop.
$params:
comment
: a comment object or comment id; if empty retrieves current commentformat
: if set to true (default), the output will be formatted using the attributeszero
,one
,more
andthousands_separator
; false = process plain count valuezero
,one
,more
: for formatted output – %c gets replaced with the number of commentsthousands_separator
: divides counts by thousand delimiters default,
=> e.g. 1,386display
: if you want to return the count (e.g. for storing it in a variable) instead of echoing it with this function-call, setdisplay
tofalse
; default setting istrue
in_loop
: if set to true (default), the query count for all user who wrote a comment which belongs to the post of the handed overcomment
will be cached; otherwise the comment count will be retrieved only for the user who posted thecomment
The following example outputs the number of comments of the author with the current comment in the comment loop:
Shortcodes
How-to for shortcodes
General Example:
Enter the following text anywhere in a post or page to output the comment count of user
xyz
:Available Shortcode:
Invokes
$featuring_countcomments->count_by_user($params)
.Invokes
$featuring_countcomments->count_by_comment($params)
.Filters
How-To for filters
General Example:
Available Filters:
In case you want to set the default parameters globally rather than handing them over on every function call, you can add the filter
featuring_countcomments_defaults
in for example featuring-countcomments.php or your own customization plugin (recommended).Please note that parameters which you hand over to a function call (
$featuring_countcomments->count_by_user
or$featuring_countcomments->count_by_comment
) will always override the defaults parameters, even if they have been set by a filter or in the admin menu.Receives an array which is used for the dashboard-widget-function call to
$featuring_countcomments->count_by_user
.display
andformat
will automatically be set to true anduser_parameter
to null to receive the current user’s count.Receives a string which is used in the dashboard-widget.
%c
will be replaced by the comment count of the user who is currently logged in.Receives an array which is used for the dashboard-right-now-box-function call to
$featuring_countcomments->count_by_user
.display
andformat
will automatically be set to true anduser_parameter
to null to retrieve the comment count of currently logged in user.Receives a string which is used in the right-now box on the dashboard.
%c
will be replaced by the comment count of the user who is currently logged in.Receives an array which is used for the user-profile-function call to
$featuring_countcomments->count_by_user
.display
andformat
will automatically be set to true anduser_parameter
to null to retrieve the comment count of currently logged in user.Receives a string which is used in the user’s profile page.
%c
will be replaced by the comment count of the user who is currently logged in.Receives an array which is used for the users-page-function call to
$featuring_countcomments->count_by_user
.display
andformat
will automatically be set to true anduser_parameter
to the user-id of each row to retrieve the user’s comment count.