HEX
Server: LiteSpeed
System: Linux linux31.centraldnserver.com 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: salamatk (1501)
PHP: 8.1.33
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open
Upload Files
File: //proc/self/cwd/wp-content/themes/xts-luman/framework/modules/wc-review-reminder/class-frontend.php
<?php
/**
 * Review reminder class.
 *
 * @package xts
 */

namespace XTS\Modules\Review_Reminder;

use XTS\Singleton;

/**
 * Review reminder class.
 */
class Frontend extends Singleton {

	/**
	 * Init.
	 */
	public function init() {
		if ( ! xts_get_opt( 'review_reminder_enabled' ) || ! xts_is_woocommerce_installed() ) {
			return;
		}

		// Add and save custom review meta data to mark this review as having been added via email.
		add_filter( 'woocommerce_product_review_comment_form_args', array( $this, 'add_custom_review_field' ) );
		add_action( 'comment_post', array( $this, 'save_custom_review_meta' ) );
	}

	/**
	 * Adds a custom hidden field to the WooCommerce review comment form to indicate
	 * whether the review was generated via the review reminder feature.
	 *
	 * @param array $comment_form The existing comment form fields.
	 *
	 * @return array The modified comment form fields with the custom hidden field added.
	 */
	public function add_custom_review_field( $comment_form ) {
		$value = 'no';

		if ( isset( $_GET['action'] ) && 'xts_review_reminder' === $_GET['action'] ) {
			$value = 'yes';
		}

		$comment_form['comment_field'] .= '<input type="hidden" name="_xts_review_reminder_generated" value="' . $value . '">';

		return $comment_form;
	}

	/**
	 * Saves custom review meta data when a WooCommerce product review is submitted.
	 *
	 * @param int $comment_id The ID of the comment being saved.
	 */
	public function save_custom_review_meta( $comment_id ) {
		$comment = get_comment( $comment_id );

		if ( 'review' === $comment->comment_type && isset( $_POST['_xts_review_reminder_generated'] ) ) {
			add_comment_meta( $comment_id, '_xts_review_reminder_generated', sanitize_text_field( wp_unslash( $_POST['_xts_review_reminder_generated'] ) ) );
		}
	}
}

Frontend::get_instance();