horizedEmailAddresses($type = 'authorized'): array { $data = $this ->getApi($this->settings->get(self::API_KEY_SETTING_NAME)) ->getAuthorizedEmailAddresses(); if ($data && $type === 'all') { return $data; } return isset($data[$type]) ? $data[$type] : []; } /** * Create Authorized Email Address */ public function createAuthorizedEmailAddress(string $emailAddress) { return $this ->getApi($this->settings->get(self::API_KEY_SETTING_NAME)) ->createAuthorizedEmailAddress($emailAddress); } /** * Get a list of sender domains * returns an assoc array of [domainName => Array(DNS responses)] * pass in the domain arg to return only the DNS response for the domain * For format see @see https://github.com/mailpoet/services-bridge#sender-domains */ public function getAuthorizedSenderDomains($domain = 'all'): array { $domain = strtolower($domain); $allSenderDomains = []; $data = $this->getRawSenderDomainData(); if ($data === null) { return []; } foreach ($data as $subarray) { if (isset($subarray['domain'])) { $allSenderDomains[strtolower($subarray['domain'])] = $subarray['dns'] ?? []; } } if ($domain !== 'all') { // return an empty array if the provided domain can not be found return $allSenderDomains[$domain] ?? []; } return $allSenderDomains; } public function getRawSenderDomainData(): ?array { return $this ->getApi($this->settings->get(self::API_KEY_SETTING_NAME)) ->getAuthorizedSenderDomains(); } /** * Create a new Sender domain record * returns an Array of DNS response or array of error * @see https://github.com/mailpoet/services-bridge#verify-a-sender-domain for response format */ public function createAuthorizedSenderDomain(string $domain): array { $data = $this ->getApi($this->settings->get(self::API_KEY_SETTING_NAME)) ->createAuthorizedSenderDomain($domain); return $data['dns'] ?? $data; } /** * Verify Sender Domain records * returns an Array of DNS response or an array of error * @see https://github.com/mailpoet/services-bridge#verify-a-sender-domain */ public function verifyAuthorizedSenderDomain(string $domain): array { return $this ->getApi($this->settings->get(self::API_KEY_SETTING_NAME)) ->verifyAuthorizedSenderDomain($domain); } public function checkMSSKey($apiKey) { $result = $this ->getApi($apiKey) ->checkMSSKey(); return $this->processKeyCheckResult($result); } private function storeSubscriptionType(?string $subscriptionType): void { if (in_array($subscriptionType, self::SUBSCRIPTION_TYPES, true)) { $this->settings->set( self::SUBSCRIPTION_TYPE_SETTING_NAME, $subscriptionType ); } } public function storeMSSKeyAndState($key, $state) { return $this->storeKeyAndState(API::KEY_CHECK_TYPE_MSS, $key, $state); } public function checkPremiumKey($key) { $result = $this ->getApi($key) ->checkPremiumKey(); return $this->processKeyCheckResult($result); } private function processKeyCheckResult(array $result) { $stateMap = [ 200 => self::KEY_VALID, 401 => self::KEY_INVALID, 402 => self::KEY_ALREADY_USED, 403 => self::KEY_VALID_UNDERPRIVILEGED, ]; if (!empty($result['code']) && isset($stateMap[$result['code']])) { if ( $stateMap[$result['code']] == self::KEY_VALID && !empty($result['data']['expire_at']) ) { $keyState = self::KEY_EXPIRING; } else { $keyState = $stateMap[$result['code']]; } } else { $keyState = self::KEY_CHECK_ERROR; } // Map of access error messages. // The message is set by shop when a subscription has limited access to the feature. // Insufficient privileges - is the default state if the plan doesn't include the feature. // If the bridge returns 403 and there is a message set by the shop it returns the message. $accessRestrictionsMap = [ API::ERROR_MESSAGE_INSUFFICIENT_PRIVILEGES => self::KEY_ACCESS_INSUFFICIENT_PRIVILEGES, API::ERROR_MESSAGE_SUBSCRIBERS_LIMIT_REACHED => self::KEY_ACCESS_SUBSCRIBERS_LIMIT, API::ERROR_MESSAGE_EMAIL_VOLUME_LIMIT_REACHED => self::KEY_ACCESS_EMAIL_VOLUME_LIMIT, ]; $accessRestriction = null; if (!empty($result['code']) && $result['code'] === 403 && !empty($result['error_message'])) { $accessRestriction = $accessRestrictionsMap[$result['error_message']] ?? null; } return $this->buildKeyState( $keyState, $result, $accessRestriction ); } public function storePremiumKeyAndState($key, $state) { return $this->storeKeyAndState(API::KEY_CHECK_TYPE_PREMIUM, $key, $state); } private function storeKeyAndState(string $keyType, ?string $key, ?array $state) { if ($keyType === API::KEY_CHECK_TYPE_PREMIUM) { $keySettingName = self::PREMIUM_KEY_SETTING_NAME; $keyStateSettingName = self::PREMIUM_KEY_STATE_SETTING_NAME; } else { $keySettingName = self::API_KEY_SETTING_NAME; $keyStateSettingName = self::API_KEY_STATE_SETTING_NAME; } if ( empty($state['state']) || $state['state'] === self::KEY_CHECK_ERROR ) { return false; } $previousKey = $this->settings->get($keySettingName); // If the key remain the same and the new state is not valid we want to preserve the data from the previous state. // The data contain information about state limits. We need those to display the correct information to users. if (empty($state['data']) && $previousKey === $key) { $previousState = $this->settings->get($keyStateSettingName); if (!empty($previousState['data'])) { $state['data'] = $previousState['data']; } } // store the key itself if ($previousKey !== $key) { $this->settings->set( $keySettingName, $key ); } // store the key state $this->settings->set( $keyStateSettingName, $state ); // store the subscription type if (!empty($state['data']) && !empty($state['data']['subscription_type'])) { $this->storeSubscriptionType($state['data']['subscription_type']); } } private function buildKeyState($keyState, $result, ?string $accessRestriction): array { return [ 'state' => $keyState, 'access_restriction' => $accessRestriction, 'data' => !empty($result['data']) ? $result['data'] : null, 'code' => !empty($result['code']) ? $result['code'] : self::CHECK_ERROR_UNKNOWN, ]; } public function updateSubscriberCount(string $key, int $count): bool { return $this->getApi($key)->updateSubscriberCount($count); } public function invalidateMssKey() { $key = $this->settings->get(self::API_KEY_SETTING_NAME); $this->storeMSSKeyAndState($key, $this->buildKeyState( self::KEY_INVALID, ['code' => API::RESPONSE_CODE_KEY_INVALID], null )); } }
Fatal error: Uncaught Error: Class "MailPoet\Services\Bridge" not found in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php:4848 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5672): MailPoetGenerated\FreeCachedContainer->getBridgeService() #1 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(5662): MailPoetGenerated\FreeCachedContainer->getMPMarketingChannelDataControllerService() #2 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2622): MailPoetGenerated\FreeCachedContainer->getMPMarketingChannelControllerService() #3 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2612): MailPoetGenerated\FreeCachedContainer->getHooksWooCommerceService() #4 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2640): MailPoetGenerated\FreeCachedContainer->getHooks2Service() #5 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #6 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #7 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #8 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #9 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(194): require_once('/htdocs/wp-cont...') #10 /htdocs/wp-settings.php(526): include_once('/htdocs/wp-cont...') #11 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #12 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #13 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #14 /htdocs/index.php(17): require('/htdocs/wp-blog...') #15 {main} thrown in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php on line 4848
esult[] = $this->get_item_value( $item, $key ); } return new static( $result ); } /** * Group the collection items by specific key in each collection item. * * @param $group_by * * @return $this */ public function group_by( $group_by ) { $result = []; foreach ( $this->items as $item ) { $group_key = $this->get_item_value( $item, $group_by, 0 ); $result[ $group_key ][] = $item; } return new static( $result ); } /** * Sort keys * * @param false $descending * * @return $this */ public function sort_keys( $descending = false ) { $items = $this->items; if ( $descending ) { krsort( $items ); } else { ksort( $items ); } return new static( $items ); } /** * Get specific item from the collection. * * @param $key * @param null $default * * @return mixed|null */ public function get( $key, $default = null ) { if ( ! array_key_exists( $key, $this->items ) ) { return $default; } return $this->items[ $key ]; } /** * Get the first item. * * @param null $default * * @return mixed|null */ public function first( $default = null ) { if ( $this->is_empty() ) { return $default; } foreach ( $this->items as $item ) { return $item; } } /** * Find an element from the items. * * @param callable $callback * @param null $default * * @return mixed|null */ public function find( callable $callback, $default = null ) { foreach ( $this->all() as $key => $item ) { if ( $callback( $item, $key ) ) { return $item; } } return $default; } /** * @param callable|string|int $value * * @return bool */ public function contains( $value ) { $callback = $value instanceof \Closure ? $value : function ( $item ) use ( $value ) { return $item === $value; }; foreach ( $this->all() as $key => $item ) { if ( $callback( $item, $key ) ) { return true; } } return false; } /** * Make sure all the values inside the array are uniques. * * @param null|string|string[] $keys * * @return $this */ public function unique( $keys = null ) { if ( ! $keys ) { return new static( array_unique( $this->items ) ); } if ( ! is_array( $keys ) ) { $keys = [ $keys ]; } $exists = []; return $this->filter( function ( $item ) use ( $keys, &$exists ) { $value = null; foreach ( $keys as $key ) { $current_value = $this->get_item_value( $item, $key ); $value .= "{$key}:{$current_value};"; } // If no value for the specific key return the item. if ( null === $value ) { return true; } // If value is not exists, add to the exists array and return the item. if ( ! in_array( $value, $exists, true ) ) { $exists[] = $value; return true; } return false; } ); } /** * @return array */ public function keys() { return array_keys( $this->items ); } /** * @return bool */ public function is_empty() { return empty( $this->items ); } /** * @return array */ public function all() { return $this->items; } /** * @return array */ public function values() { return array_values( $this->all() ); } /** * Support only one level depth. * * @return $this */ public function flatten() { $result = []; foreach ( $this->all() as $item ) { $item = $item instanceof Collection ? $item->all() : $item; if ( ! is_array( $item ) ) { $result[] = $item; } else { $values = array_values( $item ); foreach ( $values as $value ) { $result[] = $value; } } } return new static( $result ); } /** * @param ...$values * * @return $this */ public function push( ...$values ) { foreach ( $values as $value ) { $this->items[] = $value; } return $this; } public function prepend( ...$values ) { $this->items = array_merge( $values, $this->items ); return $this; } /** * @param mixed $offset * * @return bool */ #[\ReturnTypeWillChange] public function offsetExists( $offset ) { return isset( $this->items[ $offset ] ); } /** * @param mixed $offset * * @return mixed */ #[\ReturnTypeWillChange] public function offsetGet( $offset ) { return $this->items[ $offset ]; } /** * @param mixed $offset * @param mixed $value */ #[\ReturnTypeWillChange] public function offsetSet( $offset, $value ) { if ( is_null( $offset ) ) { $this->items[] = $value; } else { $this->items[ $offset ] = $value; } } /** * @param mixed $offset */ #[\ReturnTypeWillChange] public function offsetUnset( $offset ) { unset( $this->items[ $offset ] ); } /** * @return \ArrayIterator|\Traversable */ #[\ReturnTypeWillChange] public function getIterator() { return new \ArrayIterator( $this->items ); } /** * @return int|void */ #[\ReturnTypeWillChange] public function count() { return count( $this->items ); } /** * @param $item * @param $key * @param null $default * * @return mixed|null */ private function get_item_value( $item, $key, $default = null ) { $value = $default; if ( is_object( $item ) && isset( $item->{$key} ) ) { $value = $item->{$key}; } elseif ( is_array( $item ) && isset( $item[ $key ] ) ) { $value = $item[ $key ]; } return $value; } }
Fatal error: Uncaught Error: Class "Elementor\Core\Utils\Collection" not found in /htdocs/wp-content/plugins/elementor/includes/utils.php:796 Stack trace: #0 /htdocs/wp-content/plugins/elementor/core/logger/manager.php(41): Elementor\Utils::is_elementor_path('/htdocs/wp-cont...') #1 [internal function]: Elementor\Core\Logger\Manager->shutdown() #2 {main} thrown in /htdocs/wp-content/plugins/elementor/includes/utils.php on line 796