ap_get_views( integer $ref_id, string $type = 'question' )

Description #

Get views count from views table.

Parameters #

  • $ref_id
    integer (Required) Reference id.
  • $type
    string (Optional) View type. Default value: 'question'

Source #

File: includes/views.php

function ap_get_views( $ref_id, $type = 'question' ) {
	global $wpdb;
	$query = $wpdb->prepare( "SELECT count(*) FROM {$wpdb->ap_views} WHERE view_ref_id = %d AND view_type = %s", $ref_id, $type );

	$count = (int) $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared

	return $count;

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment