Recent

Rating class Pro only

Rating

Rating System Class.

Namespace: WebberZone\Knowledge_Base\Pro\Rating
Since: 3.0.0
Source: includes/rating/class-rating.php line 27

Methods

__construct()

Constructor.

Since: 3.0.0
Line: 66

public function __construct(  );

hooks()

Register hooks.

Since: 3.0.0
Line: 87

public function hooks(  );

add_rating_to_content()

Add rating display to article content.

Since: 3.0.0
Line: 122

public function add_rating_to_content( $content ): string;
TypeNameDescription
string$contentPost content.

Returns: string — Modified content with rating.

get_rating_html()

Get rating HTML for display.

Since: 3.0.0
Line: 164

public function get_rating_html( $post_id, $rating_mode ): string;
TypeNameDescription
int$post_idPost ID.
string$rating_modeRating mode (binary or scale).

Returns: string — Rating HTML.

get_rating_stats() static

Get rating statistics for a post.

Since: 3.0.0
Line: 276

static public function get_rating_stats( $post_id ): array;
TypeNameDescription
int$post_idPost ID.

Returns: array — Rating statistics.

get_top_rated_articles_query() static

Get top-rated articles query.

Returns a WP_Query object for top-rated articles sorted by rating.

Since: 3.0.0
Line: 301

static public function get_top_rated_articles_query( $args = ... ): \WP_Query;
TypeNameDescription
array$argsQuery arguments (numberposts, exclude).

Returns: \WP_Query — Query object for top-rated articles.

compute_bayesian_score() static

Compute Bayesian rating score.

Score = (C * m + k * r) / (C + k)

  • r: item average (scale: 1-5; binary: positive ratio 0-1)
  • k: item total votes
  • m: global mean (scale: global avg 1-5; binary: global positive ratio)
  • C: prior weight (tunable constant)

Since: 3.0.0
Line: 406

static public function compute_bayesian_score( int $total, int $sum, string $mode ): float;
TypeNameDescription
int$totalTotal votes for the item.
int$sumSum of ratings (scale) or positives (binary handled via $average).
string$modeRating mode ‘binary’ or ‘scale’.

Returns: float — Bayesian score on 0-5 scale for scale mode, 0-1 for binary.

render_top_rated_articles() static

Render top-rated articles list markup.

Since: 3.0.0
Line: 529

static public function render_top_rated_articles( $attributes = ... ): string;
TypeNameDescription
array$attributesBlock attributes (limit, showExcerpt, showRating, title).

Returns: string — HTML output.

has_user_voted()

Check if user has already voted.

Uses the configured tracking method for duplicate prevention.

Since: 3.0.0
Line: 710

public function has_user_voted( $post_id ): bool;
TypeNameDescription
int$post_idPost ID.

Returns: bool — True if user has voted.

ajax_submit_rating()

Handle AJAX rating submission.

Since: 3.0.0
Line: 862

public function ajax_submit_rating(  );

enqueue_assets()

Enqueue frontend assets.

Since: 3.0.0
Line: 1267

public function enqueue_assets(  );

enqueue_admin_assets()

Enqueue admin assets for rating management.

Since: 3.0.0
Line: 1326

public function enqueue_admin_assets( $hook );
TypeNameDescription
string$hookCurrent admin page hook.

rating_shortcode()

Shortcode to display rating system.

Usage: [wzkb_rating id=“123” show_stats=“yes”]

Since: 3.0.0
Line: 1378

public function rating_shortcode( $atts ): string;
TypeNameDescription
array$attsShortcode attributes.

Returns: string — Rating HTML.

process_rating_tools()

Process rating tools form submissions.

Runs on admin_init to process forms before page rendering.

Since: 3.0.0
Line: 1414

public function process_rating_tools(  );

render_rating_tools()

Render rating tools on tools page.

Since: 3.0.0
Line: 1454

public function render_rating_tools(  );

register_privacy_exporter()

Register personal data exporter for Knowledge Base ratings.

Since: 3.0.0
Line: 1765

public function register_privacy_exporter( $exporters ): array;
TypeNameDescription
array$exportersExisting exporters.

Returns: array — Modified exporters.

register_privacy_eraser()

Register personal data eraser for Knowledge Base ratings.

Since: 3.0.0
Line: 1782

public function register_privacy_eraser( $erasers ): array;
TypeNameDescription
array$erasersExisting erasers.

Returns: array — Modified erasers.

personal_data_exporter()

Export personal data related to Knowledge Base article ratings.

Exports rating participation and feedback for the user identified by email address. Only data explicitly linked to a user (user IDs / feedback entries) is exported; aggregate rating statistics remain anonymous.

Since: 3.0.0
Line: 1804

public function personal_data_exporter( $email_address, $page = ... ): array;
TypeNameDescription
string$email_addressUser email address.
int$pagePage number (1-based).

Returns: array — Export data and completion flag.

personal_data_eraser()

Erase personal data related to Knowledge Base article ratings.

Removes user identifiers and feedback entries for the user identified by email address. Aggregate rating statistics are retained.

Since: 3.0.0
Line: 1961

public function personal_data_eraser( $email_address, $page = ... ): array;
TypeNameDescription
string$email_addressUser email address.
int$pagePage number (1-based).

Returns: array — Erasure result and completion flag.

add_rating_help_tabs()

Add rating help tabs to tools page.

Since: 3.0.0
Line: 2074

public function add_rating_help_tabs( $screen );
TypeNameDescription
\WP_Screen$screenCurrent screen object.