ConfigProvider
in package
This class serves as an abstraction layer for managing various settings and variables required for the plugin's functionality. The ConfigProvider class centralizes configuration management, ensuring that if the source of settings changes (e.g., from environment variables, WordPress Option pages, etc.), only the implementation of the relevant methods in this class needs to be updated.
This approach enhances maintainability by reducing the need for code changes throughout the plugin, promoting flexibility and easier management of configuration data.
Table of Contents
Properties
- $optionCache : array<string|int, mixed>
Methods
- getAllOptions() : array<string|int, mixed>
- Get all options as an associative array.
- getBannersContentCategoryId() : string|null
- Get the Content Category ID for banners for the specified blog/site.
- getBrand() : mixed
- Get the brand name for a specific blog/site.
- getBrandFilterList() : array<string|int, mixed>
- Get the list of brands used for filtering for the specified blog/site.
- getBrandFilterMode() : string|null
- Get the brand filter mode (included or excluded) for the specified blog/site.
- getColorGroupId() : string|null
- Get the ID of the color group for the specified blog/site.
- getCountry() : string|null
- Get the country of sale for the specified blog/site.
- getExternalProductsBackupFile() : string
- Returns the backup file path for external products collection.
- getExternalProductsFolder() : string
- Returns the folder path for external products data.
- getExternalProductsXml() : string|null
- Get the filename for the external products XML for the specified blog/site.
- getFiltersAttributeName() : string|null
- Get the name of the attribute group used for filters for the specified blog/site.
- getListingExcludedCategories() : mixed
- Get product categories excluded from listing collections for the specified blog/site.
- getListingLoggedInStatuses() : mixed
- Get statuses for listing collections for logged-in users for the specified blog/site.
- getListingStatuses() : mixed
- Get statuses for listing collections for the specified blog/site.
- getLocale() : string|null
- Get the language/locale for the specified blog/site.
- getLogosAssetName() : string|null
- Get the asset name that contains the logos for the specified blog/site.
- getLogosMimeTypes() : array<string|int, mixed>
- Get allowed MIME types for product logos for the specified blog/site.
- getLogosOrderAttributeName() : string|null
- Get the name of the attribute that defines the logo order for the specified blog/site.
- getLogosOrderAudioListingAttributeName() : string|null
- Get the name of the attribute that defines the logo order in the audio listing for the specified blog/site.
- getMainProductAttributeId() : string|null
- Get the main product attribute ID for the specified blog/site.
- getProductAccessoriesRelationId() : string|null
- Get the Content Template ID for product accessories relation for the specified blog/site.
- getProductAwardsRelationId() : string|null
- Get the Content Template ID for product awards relation for the specified blog/site.
- getProductBannersRelationId() : string|null
- Get the Content Template ID for product banners relation for the specified blog/site.
- getProductGroupIds() : array<string|int, mixed>
- Get product group attribute IDs for the specified blog/site.
- getProductRelatedProductsRelationId() : string|null
- Get the Content Template ID for product related products relation for the specified blog/site.
- getProductStatusesForSearch() : mixed
- Get product statuses used for search collections for the specified blog/site.
- getRecommendedProductRelationId() : string|null
- Get the Content Template ID for recommended product relation for the specified blog/site.
- getRecommendedProductsRelationId() : string|null
- Get the Content Template ID for recommended products relation for the specified blog/site.
- getSearchAttributeGroups() : array<string|int, mixed>
- Returns the attribute groups used for search.
- getSearchAttributes() : array<string|int, mixed>
- Returns the attributes used for search.
- getSearchBannersAttributes() : array<string|int, mixed>
- Returns the attributes used for search in banners.
- getSizeGroupId() : string|null
- Get the size group ID for the specified blog/site.
- getSupportCategoryAttributeTagName() : string
- Returns the support category tag name.
- getVariantGroupId() : string|null
- Get the ID of the variant group for the specified blog/site.
- getWebColorAttributeId() : string|null
- Get the ID of the web color attribute for the specified blog/site.
- getWebsiteAttributesTags() : array<string|int, mixed>
- Get the tags used for website attributes for the specified blog/site.
- isApiProcessingEnabled() : bool
- Returns whether the API processing is enabled or not.
- isExternalProductsIncluded() : bool
- Determine whether external products should be included in search results.
- isFlixmediaFeedEnabled() : bool
- Checks if the automatic Flixmedia feed generation via cron is enabled.
- getCachedOption() : mixed
- Universal internal getter with caching.
Properties
$optionCache
private
static array<string|int, mixed>
$optionCache
= []
Methods
getAllOptions()
Get all options as an associative array.
public
static getAllOptions([int|null $blogId = null ]) : array<string|int, mixed>
Parameters
- $blogId : int|null = null
-
Optional blog ID to get options from a specific site.
Return values
array<string|int, mixed>getBannersContentCategoryId()
Get the Content Category ID for banners for the specified blog/site.
public
static getBannersContentCategoryId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetBrand()
Get the brand name for a specific blog/site.
public
static getBrand([int|null $blogId = null ]) : mixed
If $blogId is provided and valid, returns the blog-specific brand option. Otherwise, returns the global brand option.
Parameters
- $blogId : int|null = null
-
Optional blog ID to get brand for a specific site.
Return values
mixed —Brand name or null if not set.
getBrandFilterList()
Get the list of brands used for filtering for the specified blog/site.
public
static getBrandFilterList([int|null $blogId = null ]) : array<string|int, mixed>
Returns an array of trimmed brand slugs/names.
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
array<string|int, mixed>getBrandFilterMode()
Get the brand filter mode (included or excluded) for the specified blog/site.
public
static getBrandFilterMode([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetColorGroupId()
Get the ID of the color group for the specified blog/site.
public
static getColorGroupId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetCountry()
Get the country of sale for the specified blog/site.
public
static getCountry([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the country for a specific site.
Return values
string|null —Country of sale or null if not set.
getExternalProductsBackupFile()
Returns the backup file path for external products collection.
public
static getExternalProductsBackupFile() : string
Return values
string —Path to the backup file.
getExternalProductsFolder()
Returns the folder path for external products data.
public
static getExternalProductsFolder() : string
Return values
string —Absolute path to external products folder.
getExternalProductsXml()
Get the filename for the external products XML for the specified blog/site.
public
static getExternalProductsXml([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetFiltersAttributeName()
Get the name of the attribute group used for filters for the specified blog/site.
public
static getFiltersAttributeName([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetListingExcludedCategories()
Get product categories excluded from listing collections for the specified blog/site.
public
static getListingExcludedCategories([string $returnType = 'string' ][, int|null $blogId = null ]) : mixed
Parameters
- $returnType : string = 'string'
-
The return type ('string' or 'array').
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
getListingLoggedInStatuses()
Get statuses for listing collections for logged-in users for the specified blog/site.
public
static getListingLoggedInStatuses([string $returnType = 'string' ][, int|null $blogId = null ]) : mixed
Parameters
- $returnType : string = 'string'
-
The return type ('string' or 'array').
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
getListingStatuses()
Get statuses for listing collections for the specified blog/site.
public
static getListingStatuses([string $returnType = 'string' ][, int|null $blogId = null ]) : mixed
Parameters
- $returnType : string = 'string'
-
The return type ('string' or 'array').
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
getLocale()
Get the language/locale for the specified blog/site.
public
static getLocale([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the locale for a specific site.
Return values
string|null —Language/locale or null if not set.
getLogosAssetName()
Get the asset name that contains the logos for the specified blog/site.
public
static getLogosAssetName([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetLogosMimeTypes()
Get allowed MIME types for product logos for the specified blog/site.
public
static getLogosMimeTypes([int|null $blogId = null ]) : array<string|int, mixed>
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
array<string|int, mixed>getLogosOrderAttributeName()
Get the name of the attribute that defines the logo order for the specified blog/site.
public
static getLogosOrderAttributeName([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetLogosOrderAudioListingAttributeName()
Get the name of the attribute that defines the logo order in the audio listing for the specified blog/site.
public
static getLogosOrderAudioListingAttributeName([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetMainProductAttributeId()
Get the main product attribute ID for the specified blog/site.
public
static getMainProductAttributeId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetProductAccessoriesRelationId()
Get the Content Template ID for product accessories relation for the specified blog/site.
public
static getProductAccessoriesRelationId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetProductAwardsRelationId()
Get the Content Template ID for product awards relation for the specified blog/site.
public
static getProductAwardsRelationId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetProductBannersRelationId()
Get the Content Template ID for product banners relation for the specified blog/site.
public
static getProductBannersRelationId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetProductGroupIds()
Get product group attribute IDs for the specified blog/site.
public
static getProductGroupIds([int|null $blogId = null ]) : array<string|int, mixed>
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
array<string|int, mixed>getProductRelatedProductsRelationId()
Get the Content Template ID for product related products relation for the specified blog/site.
public
static getProductRelatedProductsRelationId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetProductStatusesForSearch()
Get product statuses used for search collections for the specified blog/site.
public
static getProductStatusesForSearch([string $returnType = 'string' ][, int|null $blogId = null ]) : mixed
Parameters
- $returnType : string = 'string'
-
The return type ('string' or 'array').
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
getRecommendedProductRelationId()
Get the Content Template ID for recommended product relation for the specified blog/site.
public
static getRecommendedProductRelationId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetRecommendedProductsRelationId()
Get the Content Template ID for recommended products relation for the specified blog/site.
public
static getRecommendedProductsRelationId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetSearchAttributeGroups()
Returns the attribute groups used for search.
public
static getSearchAttributeGroups([int|null $blogId = null ]) : array<string|int, mixed>
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
array<string|int, mixed> —List of searchable attribute groups.
getSearchAttributes()
Returns the attributes used for search.
public
static getSearchAttributes([int|null $blogId = null ]) : array<string|int, mixed>
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
array<string|int, mixed> —List of searchable attributes.
getSearchBannersAttributes()
Returns the attributes used for search in banners.
public
static getSearchBannersAttributes([int|null $blogId = null ]) : array<string|int, mixed>
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
array<string|int, mixed> —List of searchable attributes in banners.
getSizeGroupId()
Get the size group ID for the specified blog/site.
public
static getSizeGroupId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetSupportCategoryAttributeTagName()
Returns the support category tag name.
public
static getSupportCategoryAttributeTagName([int|null $blogId = null ]) : string
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string —Support category tag name.
getVariantGroupId()
Get the ID of the variant group for the specified blog/site.
public
static getVariantGroupId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetWebColorAttributeId()
Get the ID of the web color attribute for the specified blog/site.
public
static getWebColorAttributeId([int|null $blogId = null ]) : string|null
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
string|nullgetWebsiteAttributesTags()
Get the tags used for website attributes for the specified blog/site.
public
static getWebsiteAttributesTags([int|null $blogId = null ]) : array<string|int, mixed>
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
array<string|int, mixed>isApiProcessingEnabled()
Returns whether the API processing is enabled or not.
public
static isApiProcessingEnabled([int|null $blogId = null ]) : bool
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
bool —True if API processing is enabled, false if disabled.
isExternalProductsIncluded()
Determine whether external products should be included in search results.
public
static isExternalProductsIncluded([int|null $blogId = null ]) : bool
Retrieves the configuration option 'include_external_in_search' for the given blog ID, using a cached value if available. This setting controls whether externally sourced products are included in the TypeSense search results.
Parameters
- $blogId : int|null = null
-
The blog ID to retrieve the configuration for. If null, the default is used.
Return values
bool —True if external products should be included, false otherwise.
isFlixmediaFeedEnabled()
Checks if the automatic Flixmedia feed generation via cron is enabled.
public
static isFlixmediaFeedEnabled([int|null $blogId = null ]) : bool
This function retrieves the configuration setting to determine whether
the cron job for automatic Flixmedia feed generation is enabled or not.
It returns true if the cron job is enabled, or false if it is disabled.
By default, the cron job is enabled if the setting is not configured.
Parameters
- $blogId : int|null = null
-
Optional blog ID to get the setting from a specific site.
Return values
bool —True if the cron job for Flixmedia feed generation is enabled, false if disabled.
getCachedOption()
Universal internal getter with caching.
private
static getCachedOption(string $key[, int|null $blogId = null ]) : mixed
Parameters
- $key : string
- $blogId : int|null = null