public static function init()
 {
     self::$license_key = trim(get_option(self::LICENSE_KEY_OPTION, ''));
     self::$uid = trim(get_option(self::LICENSE_UID_OPTION, 0));
     if (is_admin()) {
         // AJAX
         add_action('wp_ajax_si_get_license', array(__CLASS__, 'maybe_get_free_license'), 10, 0);
     }
     add_filter('si_get_purchase_link', array(__CLASS__, 'add_uid_to_url'));
     add_filter('si_get_sa_link', array(__CLASS__, 'add_uid_to_url'));
     // Messaging
     add_action('si_settings_page', array(__CLASS__, 'thank_for_registering'), 10, 0);
 }
 public static function get_marketplace_addons()
 {
     $cache_key = '_si_marketplace_addons_v' . self::SI_VERSION;
     $cached_addons = get_transient($cache_key);
     if ($cached_addons) {
         if (!empty($cached_addons)) {
             return $cached_addons;
         }
     }
     $uid = class_exists('SI_Free_License') ? SI_Free_License::uid() : 0;
     $ref = $uid ? $uid : 'na';
     // data to send in our API request
     $api_params = array('action' => 'sa_marketplace_api', 'item_name' => urlencode(self::PLUGIN_NAME), 'url' => urlencode(home_url()), 'uid' => $uid, 'ref' => $ref);
     // Call the custom API.
     $response = wp_safe_remote_get(add_query_arg($api_params, self::API_CB . 'wp-admin/admin-ajax.php'), array('timeout' => 15, 'sslverify' => false));
     // make sure the response came back okay
     if (is_wp_error($response)) {
         return false;
     }
     // decode the license data
     $marketplace_items = json_decode(wp_remote_retrieve_body($response));
     set_transient($cache_key, $marketplace_items, 60 * 60 * 24 * 5);
     return $marketplace_items;
 }