Automator_Review::maybe_ask_review()

Admin notice for review this plugin.


Source Source

File: src/core/admin/class-automator-review.php

	public function maybe_ask_review() {

		// check plugin install date
		$review_time = get_option( '_uncanny_automator_review_time', '' );

		if ( empty( $review_time ) ) {
			$review_time = current_time( 'timestamp' );
			update_option( '_uncanny_automator_review_time', $review_time );
		}

		$current_date = current_time( 'timestamp' );
		$days_after   = 10;
		if ( ! current_user_can( 'manage_options' ) ) {
			return;
		}

		if ( ceil( ( $current_date - $review_time ) / 86400 ) > $days_after ) {

			$_is_reminder   = get_option( '_uncanny_automator_review_reminder', '' );
			$_reminder_date = get_option( '_uncanny_automator_review_reminder_date', current_time( 'timestamp' ) );

			if ( ! empty( $_is_reminder ) && 'hide-forever' === $_is_reminder ) {
				return;
			}

			if ( ! empty( $_is_reminder ) && 'maybe-later' === $_is_reminder ) {
				// check reminder date difference
				if ( ceil( ( $current_date - $_reminder_date ) / 86400 ) < $days_after ) {
					return;
				}
			}

			$_previous_display_date = get_option( '_uncanny_automator_previous_display_date', '' );

			if ( ! empty( $_previous_display_date ) ) {
				$_previous_display_date = strtotime( $_previous_display_date );
				$current_date           = strtotime( date( 'Y-m-d', current_time( 'timestamp' ) ) );
				if ( $_previous_display_date != $current_date && ceil( ( $current_date - $_previous_display_date ) / 86400 ) < 3 ) {
					return;
				}
			}

			add_action( 'admin_notices', function () {

				// Check only Automator related pages.
				global $typenow;

				if ( empty( $typenow ) || 'uo-recipe' !== $typenow ) {
					return;
				}

				$screen = get_current_screen();

				if ( $screen->base === 'post' ) {
					return;
				}

				update_option( '_uncanny_automator_previous_display_date', date( 'Y-m-d', current_time( 'timestamp' ) ) );
				// Get data about Automator's version
				$is_pro  = false;
				$version = AUTOMATOR_PLUGIN_VERSION;
				if ( defined( 'AUTOMATOR_PRO_FILE' ) || class_exists( '\Uncanny_Automator_Pro\InitializePlugin' ) ) {
					$is_pro  = true;
					$version = \Uncanny_Automator_Pro\InitializePlugin::PLUGIN_VERSION;
				}

				// Send review URL
				$url_send_review = 'https://wordpress.org/support/plugin/uncanny-automator/reviews/?filter=5#new-post';

				// Send feedback URL
				$url_send_feedback_version = $is_pro ? 'Uncanny%20Automator%20Pro%20' . $version : 'Uncanny%20Automator%20' . $version;
				$url_send_feedback_source  = $is_pro ? 'uncanny_automator_pro' : 'uncanny_automator';
				$url_send_feedback         = 'https://automatorplugin.com/feedback/?version=' . $url_send_feedback_version . '&utm_source=' . $url_send_feedback_source . '&utm_medium=review_banner';
				$url_hide_forever          = add_query_arg( [ 'action' => 'uo-hide-forever' ] );
				$url_remind_later          = add_query_arg( [ 'action' => 'uo-maybe-later' ] );
				include Utilities::automator_get_view( 'review-banner.php' );
			} );
		}
	}


Top ↑

Changelog Changelog

Changelog
Version Description
2.1.4 Introduced.