LLMS_Admin_Review::maybe_show_notice()

Determine if the notice should be displayed and display it


Return Return

(null|false|void) Returns null when there are permission issues, false when the notification is not set to be displayed, and has no return when the notice is successfully displayed.


Top ↑

Source Source

File: includes/admin/class-llms-admin-review.php

	public function maybe_show_notice() {

		// Only show review request to admins.
		if ( ! current_user_can( 'manage_lifterlms' ) ) {
			return null;
		}

		// Verify that we can do a check for reviews.
		$review      = get_option( 'llms_review' );
		$time        = time();
		$enrollments = 0;

		// No review info stored, create a stub.
		if ( ! $review ) {

			update_option(
				'llms_review',
				array(
					'time'      => $time,
					'dismissed' => false,
				)
			);
			return false;

		}

		// Review has not been dismissed and LifterLMS has been installed at least a week.
		if ( ( isset( $review['dismissed'] ) && ! $review['dismissed'] ) && isset( $review['time'] ) && ( $review['time'] + WEEK_IN_SECONDS <= $time ) ) {

			// Show if the enrollments threshold is reached.
			global $wpdb;
			$enrollments = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}lifterlms_user_postmeta WHERE meta_key = '_status' AND meta_value = 'enrolled'" ); // no-cache ok.

		}

		// Only load if we have 30 or more enrollments.
		if ( $enrollments < 30 ) {
			return false;
		}

		$enrollments = self::round_down( $enrollments );

		include 'views/notices/review-request.php';

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.14.0 Only show to users with manage_lifterlms instead of only admins.
3.24.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.