HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/html/ielts-store/wp-content/plugins/automatewoo/includes/Review.php
<?php
// phpcs:ignoreFile

namespace AutomateWoo;

/**
 * @class Review
 * @since 3.0.0
 */
class Review {

	/** @var int */
	private $comment_id = 0;

	/** @var int  */
	private $user_id = 0;

	/** @var string */
	private $email;

	/** @var int  */
	private $product_id = 0;

	/** @var \WP_Comment */
	private $comment;

	/** @var string */
	private $comment_status;

	/** @var bool */
	public $exists = false;


	/**
	 * @param \WP_Comment|int $comment
	 */
	public function __construct( $comment ) {
		if ( is_numeric( $comment ) ) {
			$comment = get_comment( $comment );
		}

		if ( ! $comment || 'review' !== $comment->comment_type || 'product' !== get_post_type( $comment->comment_post_ID ) ) {
			return;
		}

		$this->exists = true;
		$this->comment = $comment;
		$this->comment_id = (int) $comment->comment_ID;
		$this->user_id = (int) $comment->user_id;
		$this->product_id = (int) $comment->comment_post_ID;
		$this->email = Clean::email( $comment->comment_author_email );
		$this->comment_status = wp_get_comment_status( $comment );
	}


	/**
	 * @return int
	 */
	public function get_id() {
		return $this->comment_id;
	}


	/**
	 * @return int
	 */
	public function get_product_id() {
		return $this->product_id;
	}


	/**
	 * @return int
	 */
	public function get_user_id() {
		return $this->user_id;
	}


	/**
	 * @return int
	 */
	public function get_email() {
		return $this->email;
	}


	/**
	 * @return string
	 */
	public function get_content() {
		return Clean::textarea( $this->comment->comment_content );
	}


	/**
	 * @return int
	 */
	function get_rating() {
		return (int) get_comment_meta( $this->get_id(), 'rating', true );
	}

	/**
	 * Get the customer who made the review.
	 *
	 * @since 4.5
	 *
	 * @return Customer|bool
	 */
	public function get_customer() {
		return Customer_Factory::get_by_review( $this );
	}

	/**
	 * @return string
	 */
	public function get_comment_status() {
		return $this->comment_status;
	}

	/**
	 * @return boolean
	 */
	public function is_approved() {
		return $this->comment_status === 'approved';
	}

}