Пример #1
0
 /**
  * Initializes the admin notices.
  *
  * @return \Aventura\Wprss\Core\Licensing\Settings
  */
 protected function _initNotices()
 {
     $noticesCollection = wprss_admin_notice_get_collection();
     foreach ($this->getManager()->getAddons() as $_addonId => $_addonName) {
         $_year = date('Y');
         $noticesCollection->add_notice(array('id' => sprintf('empty_license_notice_%s', $_addonId), 'addon' => $_addonId, 'notice_type' => 'error', 'condition' => array(array($this, 'emptyLicenseKeyNoticeCondition')), 'content' => sprintf(__('<p>Remember to <a href="%1$s">enter your license key</a> for the <strong>WP RSS Aggregator - %2$s</strong> add-on to benefit from updates and support.</p>', WPRSS_TEXT_DOMAIN), esc_attr(admin_url('edit.php?post_type=wprss_feed&page=wprss-aggregator-settings&tab=licenses_settings')), $_addonName)))->add_notice(array('id' => sprintf('saved_inactive_license_notice_%s', $_addonId), 'addon' => $_addonId, 'notice_type' => 'error', 'condition' => array(array($this, 'savedInactiveLicenseNoticeCondition')), 'content' => sprintf(__('<p>The license key for the <strong>WP RSS Aggregator - %2$s</strong> add-on is saved but not activated. In order to benefit from updates and support, it must be <a href="%1$s">activated</a>.</p>', WPRSS_TEXT_DOMAIN), esc_attr(admin_url('edit.php?post_type=wprss_feed&page=wprss-aggregator-settings&tab=licenses_settings')), $_addonName)))->add_notice(array('id' => sprintf('soon_to_expire_license_notice_%s_%s', $_addonId, $_year), 'addon' => $_addonId, 'notice_type' => 'error', 'condition' => array(array($this, 'soonToExpireLicenseNoticeCondition')), 'content' => sprintf(__('<p>The license for the <strong>WP RSS Aggregator - %2$s</strong> add-on is about to expire. Make sure to renew it to keep receiving updates and benefit from support.</p>', WPRSS_TEXT_DOMAIN), esc_attr(admin_url('edit.php?post_type=wprss_feed&page=wprss-aggregator-settings&tab=licenses_settings')), $_addonName)));
     }
     return $this;
 }
Пример #2
0
 /**
  * Initializes the admin notices.
  *
  * @return \Aventura\Wprss\Core\Licensing\Settings
  */
 protected function _initNotices()
 {
     $noticesCollection = wprss_admin_notice_get_collection();
     foreach ($this->getManager()->getAddons() as $_addonId => $_addonName) {
         $_notice = array('id' => sprintf('invalid_licenses_exist_%s', $_addonId), 'notice_type' => 'error', 'content' => $this->getInvalidLicenseNoticeContent($_addonId), 'condition' => array(array($this, 'invalidLicensesNoticeCondition')), 'addon' => $_addonId);
         $noticesCollection->add_notice($_notice);
     }
     return $this;
 }
 /**
  * Used to hide a notice, typically responding to a frontend event.
  *
  * @since 4.7.4
  * @param array|string $notice Notice or notice ID.
  * @param string $nonce The nonce from the frontend.
  * @return \WPRSS_Admin_Notices This instance.
  * @throws Exception If no notice ID specified, or no notice found for it,
  *	or specified nonce does not belong to the notice, or the nonce is not right.
  */
 public function hide_notice($notice, $nonce)
 {
     if (is_array($notice)) {
         $notice = isset($notice['id']) ? $notice['id'] : null;
     }
     if (is_null($notice)) {
         throw new Exception(sprintf('Could not hide notice: Notice ID must be specified'));
     }
     if (is_null($nonce)) {
         throw new Exception(sprintf('Could not hide notice: nonce must be specified'));
     }
     if (!($notice = $this->get_notices($notice))) {
         throw new Exception(sprintf('Could not hide notice: No notice found for ID "%1$s"', $notice));
     }
     // Is it the right nonce?
     if ($notice['nonce'] !== $nonce) {
         throw new Exception(sprintf('Could not hide notice: Nonce "%1$s" does not belong to notice "%2$s"', $nonce, $notice_id));
     }
     // Verify nonce
     if (!wp_verify_nonce($nonce, $this->generate_nonce_code($notice))) {
         throw new Exception(sprintf('Could not hide notice: Nonce "%1$s" is incorrect', $nonce));
     }
     wprss_admin_notice_get_collection()->set_notice_active($notice, false);
     return $this;
 }