*/
namespace RankMath\Admin;
use RankMath\Helper;
use RankMath\Traits\Ajax;
use RankMath\Traits\Hooker;
defined( 'ABSPATH' ) || exit;
/**
 * Ask_Review class.
 */
class Ask_Review {
	use Hooker, Ajax;
	/**
	 * Now.
	 *
	 * @var string
	 */
	public $current_time = '';
	/**
	 * Date of release of version 1.0.57. Turned into a timestamp in the constructor.
	 *
	 * @var string
	 */
	public $record_date = '2021-02-03 13:00';
	/**
	 * Rank Math plugin install date.
	 *
	 * @var string
	 */
	public $install_date = '';
	/**
	 * Constructor method.
	 */
	public function __construct() {
		$this->current_time = current_time( 'timestamp' );
		$this->record_date  = strtotime( $this->record_date );
		$this->install_date = get_option( 'rank_math_install_date' );
		if ( false === $this->install_date ) {
			$this->install_date = $this->current_time;
		}
	}
	/**
	 * Register hooks.
	 */
	public function hooks() {
		$this->ajax( 'already_reviewed', 'already_reviewed' );
		// Post editor tab.
		if ( $this->current_time > $this->install_date + ( 10 * DAY_IN_SECONDS ) ) {
			Helper::add_json( 'showReviewTab', true );
		}
		// Admin notice.
		$review_notice_date = $this->get_review_notice_date();
		if ( $this->current_time > $review_notice_date ) {
			if ( get_option( 'rank_math_review_notice_added' ) === false && ! Helper::has_notification( 'rank_math_pro_notice' ) ) {
				$this->add_notice();
			}
			// Make dismiss button work like the "Maybe later" link.
			$this->action( 'wp_helpers_notification_dismissed', 'review_notice_after_dismiss' );
		}
		$this->action( 'admin_footer', 'review_notice_js', 15 );
	}
	/**
	 * Add inline JS related to the review notice.
	 *
	 * @return void
	 */
	public function review_notice_js() {
		if ( ! Helper::has_notification( 'rank_math_review_plugin_notice' ) ) {
			return;
		}
		?>
		
		
		';
		// Translators: placeholder is the plugin name.
		$message .= sprintf( esc_html__( 'Hey, we noticed you\'ve been using %s for more than a week now – that\'s awesome!', 'rank-math' ), '' . _x( 'Rank Math SEO', 'plugin name inside the review notice', 'rank-math' ) . '' );
		$message .= '
';
		$message .= esc_html__( 'Could you please do us a BIG favor and give it a rating on WordPress.org to help us spread the word and boost our motivation?', 'rank-math' ) . '
Bhanu Ahluwalia
' . esc_html__( 'Co-founder of Rank Math', 'rank-math' ) . '
				' . esc_html__( 'Yes, you deserve it', 'rank-math' ) . '
				' . esc_html__( 'No, maybe later', 'rank-math' ) . '
				' . esc_html__( 'I already did', 'rank-math' ) . '