/** * Gets the singleton instance of this class to ensure that it only ever gets constructed correctly once. * * @return bool|Catalyst_API */ public static function instance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
/** * Get the site's subscription level, either from the cache or from the remote API. * * 0 - unregistered * 10 - free * 20 - premium * * @return int */ public function get_subscription_level() { $level = get_transient('seoslides_level'); if (false === $level) { $level = 0; $api_key = get_option('seoslides_api_key', ''); if (!empty($api_key)) { $catalyst = Catalyst_API::instance(); $catalyst->set_api_key($api_key); $subscriptions = $catalyst->get_subscription_plans(); if (in_array('c8c8ee061df0601b7eb9ef90946100eded29e3d1e68b4dbe82e05aabb6042f8a', $subscriptions)) { $level = 20; } elseif (in_array('e41a557640b1b8c2e73b5abe0460d10c56fd6052d30da96511ba80acf9fe0ccf', $subscriptions)) { $level = 10; } } set_transient('seoslides_level', $level, 60 * 60); } return (int) $level; }