offsetExists( $pluginId ) ) { throw new \InvalidArgumentException( sprintf( 'The extension %d is already registered.', $pluginId ) ); } $this->offsetSet( $pluginId, new \EDD_License( $pluginFile, $pluginName, $currentVersion, 'Easy Digital Downloads', $optionName, null, $pluginId ) ); } /** * Returns all registered extensions, regardless of whether they have licenses activated. * * At some point we could make this public, just making it private for now so that we have * flexibility to change exactly what it returns in the future. * * @since 2.11.4 * * @return \EDD_License[] */ private function getExtensions() { return $this->getArrayCopy(); } /** * Counts the number of licensed extensions active on this site. * Note: This only looks at extensions registered via this registry, then filters down * to those that have a license key entered. It does not check to verify if the license * key is actually valid / not expired. * * @since 2.11.4 * * @return int */ public function countLicensedExtensions() { $licensedExtensions = array_filter( $this->getExtensions(), function ( \EDD_License $license ) { return ! empty( $license->license ); } ); return count( $licensedExtensions ); } }