Exemple #1
0
 /**
  * Checks API key and URL combo validity
  *
  * Saves intermediate results to transient to avoid constant pinging of OP SL
  * @return void
  */
 function checkApiKeyValidity()
 {
     /*
      * Transient is not found
      */
     if (false === ($validity = get_transient(OptimizePress_Sl_Api::OPTION_API_KEY_STATUS))) {
         $validity = array('api_key' => op_sl_get_key(), 'installation_url' => op_sl_get_url(), 'status' => op_sl_ping() === true ? 1 : 0);
     }
     /*
      * If API key and URL combo is valid we are done
      */
     if ((int) $validity['status'] === 1 && $validity['api_key'] === op_sl_get_key() && $validity['installation_url'] === op_sl_get_url()) {
         set_transient(OptimizePress_Sl_Api::OPTION_API_KEY_STATUS, $validity, HOUR_IN_SECONDS * 6);
         return;
     }
     /*
      * We are nagging the user with our message
      */
     echo '<div class="update-nag">' . sprintf(__('There seems to be a problem with your OptimizePress API Key.  Please recheck it is entered correctly and if you still have problems <a href="%s" target="_blank">contact support</a>.', OP_SN), OP_SUPPORT_LINK) . '</div>';
 }
Exemple #2
0
 /**
  * Checks if user is eligible for updates and show him nag message
  * @since  2.2.2
  * @return void
  */
 function checkEligibility()
 {
     /*
      * User can disable eligibility notice, in that case nag won't be shown
      */
     if ('disabled' === get_transient(OptimizePress_Sl_Api::OPTION_ELIGIBILITY_STATUS . '_disabled')) {
         return;
     }
     /*
      * We need to skip if user hasn't added API key yet
      */
     $apiKey = op_sl_get_key();
     if (empty($apiKey)) {
         return;
     }
     /*
      * Lets check transients
      */
     if (false === ($eligibility = get_transient(OptimizePress_Sl_Api::OPTION_ELIGIBILITY_STATUS))) {
         $eligibility = array('installation_url' => op_sl_get_url(), 'status' => op_sl_eligible() === true ? 1 : 0);
     }
     set_transient(OptimizePress_Sl_Api::OPTION_ELIGIBILITY_STATUS, $eligibility, MINUTE_IN_SECONDS * 15);
     /*
      * If API key and URL combo is valid we are done
      */
     if ((int) $eligibility['status'] === 1 && $eligibility['installation_url'] === op_sl_get_url()) {
         return;
     }
     /*
      * We are nagging the user with our message
      */
     echo '<div class="update-nag">' . sprintf(__('You are not eligible for new updates. You can <a href="%s" target="_blank">prolong your subscription</a> or <a href="%s">disable this notification</a>.', OP_SN), 'http://www.optimizepress.com/updates-renewal/', admin_url('admin.php?action=optimizepress-disable-eligibility')) . '</div>';
 }