showReviewNotice() ) { return; } // Show notice and delete the current status (if any) delete_option(WPACU_PLUGIN_ID .'_review_notice_status'); $goBackToCurrentUrl = '&_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ); $closeNoticeUrl = esc_url(wp_nonce_url( admin_url('admin-post.php?action='.WPACU_PLUGIN_ID.'_close_review_notice&wpacu_close_reason=_wpacu_close_reason_' . $goBackToCurrentUrl), WPACU_PLUGIN_ID . '_close_review_notice' )); $closeNoticeMaybeLaterUrl = str_replace('_wpacu_close_reason_', 'maybe_later', $closeNoticeUrl); $closeNoticeNeverShowItUrl = str_replace('_wpacu_close_reason_', 'never_show_it', $closeNoticeUrl); ?>


~ Gabriel Livan, Lead Developer

:)       

showReviewNotice() ) { return; } ?> doCloseNotice(); } /** * Conditions for showing the notice (all should be met): * 1) Used the plugin at least for a week (or a few days if at least 30 assets were unloaded) * 2) At least 10 assets unloaded * 3) The WIKI was read or one of the minify/combine options were enabled * * @return bool */ public function showReviewNotice() { if ($this->showReviewNotice !== null) { return $this->showReviewNotice; // already set } // On URL request (for debugging) if ( isset($_GET['wpacu_show_review_notice']) ) { $this->showReviewNotice = true; return $this->showReviewNotice; } // If another Asset CleanUp notice (e.g. for plugin tracking) is already shown // don't also show this one below/above it if (defined('WPACU_ADMIN_TRACKING_NOTICE_SHOWN')) { $this->showReviewNotice = false; return $this->showReviewNotice; } $screen = get_current_screen(); $doNotTriggerOnScreens = array( 'options-general', 'tools', 'users', 'user', 'profile', 'plugins', 'plugin-editor', 'plugin-install' ); if (isset($screen->base) && in_array($screen->base, $doNotTriggerOnScreens)) { $this->showReviewNotice = false; return $this->showReviewNotice; } $settings = new Settings(); $allSettings = $settings->getAll(); $conditionOneToShow = ( $allSettings['wiki_read'] == 1 || $allSettings['minify_loaded_css'] == 1 || $allSettings['combine_loaded_css'] == 1 || $allSettings['minify_loaded_js'] == 1 || $allSettings['combine_loaded_js'] == 1 ); if ( ! $conditionOneToShow ) { $this->showReviewNotice = false; return $this->showReviewNotice; } $noticeStatus = get_option(WPACU_PLUGIN_ID .'_review_notice_status'); if (isset($noticeStatus['status']) && $noticeStatus['status'] === 'never_show_it') { $this->showReviewNotice = false; return $this->showReviewNotice; // Never show it (user has chosen or the primary button was clicked) } if (isset($noticeStatus['status'], $noticeStatus['updated_at']) && $noticeStatus['status'] === 'maybe_later') { // Two weeks after the review notice is closed to show up later $showNoticeAfterTimestamp = ($noticeStatus['updated_at'] + (DAY_IN_SECONDS * 14)); // If two weeks haven't passed since the user has chosen "Nope, maybe later" then do not show the notice yet if (time() < $showNoticeAfterTimestamp) { $this->showReviewNotice = false; return $this->showReviewNotice; } } // Make sure that at least {$daysPassedAfterFirstUsage} days has passed after the first usage of the plugin was recorded $firstUsageTimestamp = get_option(WPACU_PLUGIN_ID.'_first_usage'); if (! $firstUsageTimestamp) { $this->showReviewNotice = false; return $this->showReviewNotice; } $unloadedTotalAssets = Misc::getTotalUnloadedAssets(); // Show the notice after one week $daysPassedAfterFirstUsage = 7; // Unloaded at least thirty assets? Show the notice sooner if ($unloadedTotalAssets >= 30) { $daysPassedAfterFirstUsage = 4; } if ( (time() - $firstUsageTimestamp) < ($daysPassedAfterFirstUsage * DAY_IN_SECONDS) ) { $this->showReviewNotice = false; return $this->showReviewNotice; } $toReturn = ( $unloadedTotalAssets >= 10 ); // finally, there have to be at least 10 unloaded assets $this->showReviewNotice = $toReturn; return $toReturn; } /** * Either via page reload or AJAX call */ public function doCloseNotice() { $doRedirect = isset($_GET['wpacu_close_reason']) && ! defined('DOING_AJAX'); $reason = isset($_REQUEST['wpacu_close_reason']) && in_array($_REQUEST['wpacu_close_reason'], self::$closingReasons) ? sanitize_text_field($_REQUEST['wpacu_close_reason']) : false; if (! $reason) { return; } $performUpdate = false; if ($reason === 'never_show_it') { Misc::addUpdateOption(WPACU_PLUGIN_ID . '_review_notice_status', array('status' => 'never_show_it')); $performUpdate = true; } elseif ($reason === 'maybe_later') { // Set the current timestamp and show it later (e.g. in 2 weeks from now) Misc::addUpdateOption(WPACU_PLUGIN_ID . '_review_notice_status', array('status' => 'maybe_later', 'updated_at' => time())); $performUpdate = true; } // AJAX call return if ($performUpdate && $doRedirect === false) { echo 'success'; exit(); } // The AJAX call should be successful // This redirect is made as a fallback in case the page is reloaded if ( $doRedirect && wp_get_referer() ) { wp_safe_redirect( wp_get_referer() ); exit(); } } }