Rating_Admin
Rating_Admin class.
Namespace: WebberZone\Knowledge_Base\Pro\Rating
Since: 3.0.0
Source: includes/rating/class-rating-admin.php line 24
Methods
__construct()
Constructor.
Since: 3.0.0
Line: 31
public function __construct( );
enqueue_admin_assets()
Enqueue admin assets for rating management.
Since: 3.0.0
Line: 62
public function enqueue_admin_assets( $hook );
| Type | Name | Description |
|---|---|---|
string | $hook | Current admin page hook. |
add_rating_column()
Add rating column to admin posts list.
Since: 3.0.0
Line: 112
public function add_rating_column( $columns ): array;
| Type | Name | Description |
|---|---|---|
array | $columns | Existing columns. |
Returns: array — Modified columns.
display_rating_column()
Display rating column content.
Since: 3.0.0
Line: 135
public function display_rating_column( $column, $post_id );
| Type | Name | Description |
|---|---|---|
string | $column | Column name. |
int | $post_id | Post ID. |
make_rating_column_sortable()
Make rating column sortable.
Setting the value to an array with [orderby, true] makes the initial sort order descending (best ratings first).
Since: 3.0.0
Line: 179
public function make_rating_column_sortable( $columns ): array;
| Type | Name | Description |
|---|---|---|
array | $columns | Sortable columns. |
Returns: array — Modified sortable columns.
rating_column_orderby()
Handle rating column sorting using Bayesian average.
Uses Bayesian average (weighted rating) to balance quality and quantity. This prevents articles with few votes but high ratings from dominating, while still rewarding genuinely good content.
Formula: weighted_score = (v / (v + m)) * R + (m / (v + m)) * C Where:
- v = number of votes for this article
- m = minimum votes required (default: 10)
- R = average rating for this article
- C = mean rating across all articles
Since: 3.0.0
Line: 202
public function rating_column_orderby( $query );
| Type | Name | Description |
|---|---|---|
\WP_Query | $query | The WP_Query instance. |
bayesian_rating_clauses()
Modify query to sort by cached Bayesian rating.
Uses the pre-calculated _wzkb_bayesian_rating meta key for efficient sorting.
Since: 3.0.0
Line: 226
public function bayesian_rating_clauses( $clauses, $query ): array;
| Type | Name | Description |
|---|---|---|
array | $clauses | Query clauses. |
\WP_Query | $query | The WP_Query instance. |
Returns: array — Modified clauses.
add_rating_row_actions()
Add “Reset Rating” row action.
Since: 3.0.0
Line: 252
public function add_rating_row_actions( $actions, $post ): array;
| Type | Name | Description |
|---|---|---|
array | $actions | Row actions. |
\WP_Post | $post | Post object. |
Returns: array — Modified actions.
ajax_reset_article_rating()
Handle AJAX request to reset individual article rating.
Since: 3.0.0
Line: 285
public function ajax_reset_article_rating( );