Documentation

WscSettings
in package

Table of Contents

Properties

$prefix  : string
$registeredFields  : array<string|int, mixed>

Methods

__construct()  : mixed
createSettingsPage()  : mixed
getAllFieldKeys()  : array<string|int, mixed>
Retrieves all registered ACF field keys.
getAllOptionsFromTypeSense()  : array<string|int, mixed>
Load options from TypeSense collection.
getBlogOption()  : mixed
Helper to get option value for a specific blog if blogId is given and valid, otherwise get global option.
getOption()  : mixed|null
Retrieves a global option value using Advanced Custom Fields (ACF).
getOptionFromAllSites()  : array<string|int, mixed>
Retrieves a specific option from all sites in a WordPress multisite network.
loadAllOptions()  : array<string|int, mixed>
Retrieves all ACF option values for registered fields from DB.
wscSettingsSaved()  : mixed
Callback triggered when settings are saved.
addFields()  : mixed

Properties

$registeredFields

private static array<string|int, mixed> $registeredFields = [['method' => 'addText', 'key' => 'country_of_sale', 'args' => ['label' => 'Country of Sale', 'instructions' => 'Enter the country where the products are sold (e.g., EU, US, CA).', 'required' => 1, 'default_value' => 'EU']], ['method' => 'addText', 'key' => 'site_locale', 'args' => ['label' => 'Site Language (Locale)', 'instructions' => 'Enter the language/locale for the site (e.g., en, fr).', 'required' => 1, 'default_value' => 'en']], ['method' => 'addText', 'key' => 'site_brand', 'args' => ['label' => 'Site Brand', 'instructions' => 'If this site is intended for a specific brand, enter it here; leave blank for default.', 'required' => 0, 'default_value' => '']], ['method' => 'addSelect', 'key' => 'site_brand_filter_mode', 'args' => ['label' => 'Brand Filter Mode', 'instructions' => 'Select how the brand filter list should be applied (Included = only listed brands will be shown, Excluded = all except listed brands).', 'required' => 1, 'choices' => ['included' => 'Included (only show listed brands)', 'excluded' => 'Excluded (hide listed brands)'], 'default_value' => 'excluded']], ['method' => 'addText', 'key' => 'site_brand_filter_list', 'args' => ['label' => 'Brand Filter List', 'instructions' => 'Enter brand slugs or names separated by commas (e.g., Sharp, VITADO, Blaupunkt, ...).', 'required' => 0, 'default_value' => 'VITADO']], ['method' => 'addText', 'key' => 'listing_statuses', 'args' => ['label' => 'Listing Collection Statuses', 'instructions' => 'Enter statuses for listing collections, separated by commas (e.g., Active, Inactive).', 'required' => 1, 'default_value' => 'Active']], ['method' => 'addText', 'key' => 'listing_logged_in_statuses', 'args' => ['label' => 'Listing Collection Statuses for Logged In Users only', 'instructions' => 'Enter statuses for listing collections for logged in users, separated by commas (e.g. Prelisted).', 'required' => 1, 'default_value' => 'Prelisted']], ['method' => 'addText', 'key' => 'listing_excluded_categories', 'args' => ['label' => 'Excluded Categories for Listing', 'instructions' => 'Enter categories to be excluded from the listing, separated by commas (e.g., Content, Website-cms).', 'required' => 1, 'default_value' => 'Content, Website-cms']], ['method' => 'addText', 'key' => 'product_statuses_for_search', 'args' => ['label' => 'Product Statuses for Search', 'instructions' => 'Enter product statuses for search collections, separated by commas (e.g., Active, End of life).', 'required' => 1, 'default_value' => 'Active, End of life']], ['method' => 'addNumber', 'key' => 'product_banners_relation_id', 'args' => ['label' => 'Product Banners Relation ID', 'instructions' => 'Enter the template ID for product banners relation.', 'required' => 1, 'default_value' => 1]], ['method' => 'addNumber', 'key' => 'product_accessories_relation_id', 'args' => ['label' => 'Product Accessories Relation ID', 'instructions' => 'Enter the template ID for product accessories relation.', 'required' => 1, 'default_value' => 2]], ['method' => 'addNumber', 'key' => 'product_related_products_relation_id', 'args' => ['label' => 'Product Related Products Relation ID', 'instructions' => 'Enter the template ID for related products relation.', 'required' => 1, 'default_value' => 3]], ['method' => 'addNumber', 'key' => 'product_awards_relation_id', 'args' => ['label' => 'Product Awards Relation ID', 'instructions' => 'Enter the template ID for product awards relation.', 'required' => 1, 'default_value' => 4]], ['method' => 'addText', 'key' => 'recommended_product_relation_id', 'args' => ['label' => 'Recommended product Relation ID', 'instructions' => 'Enter the template ID for Recommended product relation.', 'required' => 1, 'default_value' => 'Recommended product']], ['method' => 'addText', 'key' => 'recommended_products_relation_id', 'args' => ['label' => 'Recommended products Relation ID', 'instructions' => 'Enter the template ID for Recommended products relation.', 'required' => 1, 'default_value' => 'Recommended products']], ['method' => 'addNumber', 'key' => 'banners_content_category', 'args' => ['label' => 'Banners Content Category', 'instructions' => 'Enter the content category for banners.', 'required' => 1, 'default_value' => 79]], ['method' => 'addText', 'key' => 'product_group_ids', 'args' => ['label' => 'Product Group Attribute IDs', 'instructions' => 'Enter product group attribute IDs, separated by commas (e.g., model_variant_group, color_variant_group, size_variant_group).', 'required' => 1, 'default_value' => 'model_variant_group, color_variant_group, size_variant_group']], ['method' => 'addText', 'key' => 'logos_mime_types', 'args' => ['label' => 'Allowed Mime Types for Product Logos', 'instructions' => 'Enter allowed MIME types for product logos, separated by commas (e.g., image/png, image/jpeg, image/svg+xml).', 'default_value' => 'image/png, image/jpeg, image/svg+xml']], ['method' => 'addText', 'key' => 'logos_order_attribute_name', 'args' => ['label' => 'Logos Order Attribute Name', 'instructions' => 'Enter the name of the attribute that defines the order of logos.', 'required' => 1, 'default_value' => 'logo']], ['method' => 'addText', 'key' => 'logos_order_audio_listing_attribute_name', 'args' => ['label' => 'Logos Order for Audio Listing Attribute Name', 'instructions' => 'Enter the name of the attribute that defines the order of logos in audio listing cards.', 'required' => 1, 'default_value' => 'logos_product_list']], ['method' => 'addText', 'key' => 'logos_asset_name', 'args' => ['label' => 'Logos Asset Name', 'instructions' => 'Enter the name of the asset that contains logos.', 'required' => 1, 'default_value' => 'logos']], ['method' => 'addText', 'key' => 'size_group_id', 'args' => ['label' => 'Size Group ID', 'instructions' => 'Enter the ID for the size variant group.', 'required' => 1, 'default_value' => 'size_variant_group']], ['method' => 'addText', 'key' => 'variant_group_id', 'args' => ['label' => 'Variant Group ID', 'instructions' => 'Enter the ID for the model variant group.', 'required' => 1, 'default_value' => 'model_variant_group']], ['method' => 'addText', 'key' => 'color_group_id', 'args' => ['label' => 'Color Group ID', 'instructions' => 'Enter the ID for the color variant group.', 'required' => 1, 'default_value' => 'color_variant_group']], ['method' => 'addText', 'key' => 'main_product_attribute_id', 'args' => ['label' => 'Main Product Attribute ID', 'instructions' => 'Enter the attribute ID for the main product.', 'required' => 1, 'default_value' => 'variant_main_model']], ['method' => 'addTrueFalse', 'key' => 'include_external_in_search', 'args' => ['label' => 'Include External Products in Search', 'instructions' => 'Include or exclude external products in search results.', 'default_value' => 1, 'ui' => 1, 'ui_on_text' => 'Include', 'ui_off_text' => 'Exclude']], ['method' => 'addText', 'key' => 'external_products_xml', 'args' => ['label' => 'External Products XML Filename', 'instructions' => 'Enter the filename for the external products XML file.', 'required' => 1, 'default_value' => 'external-products-small.xml']], ['method' => 'addText', 'key' => 'website_attributes_tags', 'args' => ['label' => 'Website Attributes Tags', 'instructions' => 'Enter the tags for website attributes, separated by commas.', 'required' => 1, 'default_value' => 'website']], ['method' => 'addText', 'key' => 'filters_attribute_group_name', 'args' => ['label' => 'Filters Attribute Group Name', 'instructions' => 'Enter the name of the attribute group for web filters.', 'required' => 1, 'default_value' => 'Web-filters']], ['method' => 'addText', 'key' => 'web_color_attribute_id', 'args' => ['label' => 'Web Color Attribute ID', 'instructions' => 'Enter the ID for the web color attribute.', 'required' => 1, 'default_value' => 'web_color_codes']], ['method' => 'addText', 'key' => 'search_attributes', 'args' => ['label' => 'Search Attributes', 'instructions' => 'Enter the attributes used for search, separated by commas (e.g., product_name, product_code).', 'default_value' => 'product_name_short_consumer, product_name, marketing_headline, product_category, highlights, product_description, marketing_copy, web_search_terms']], ['method' => 'addText', 'key' => 'search_attribute_groups', 'args' => ['label' => 'Search Attribute Groups', 'instructions' => 'Enter the attribute groups used for search, separated by commas (e.g., TV Product Features, Audio Features).', 'default_value' => 'TV Product Features']], ['method' => 'addText', 'key' => 'search_banners_attributes', 'args' => ['label' => 'Search Banners Attributes', 'instructions' => 'Enter the attributes used for search, separated by commas (e.g., product_name, product_code).', 'default_value' => 'header, description']], ['method' => 'addText', 'key' => 'support_categories_tag_name', 'args' => ['label' => 'Support categories tag name', 'instructions' => 'Enter the attributes tag name used as categories in support page(e.g., support-category).', 'default_value' => 'support-categories']], ['method' => 'addTrueFalse', 'key' => 'enable_api_processing', 'args' => ['label' => 'Enable API Processing', 'instructions' => 'Enable or disable the API product updates processing feature.', 'default_value' => 1, 'ui' => 1, 'ui_on_text' => 'Enabled', 'ui_off_text' => 'Disabled']], ['method' => 'addTrueFalse', 'key' => 'enable_flixmedia_feed', 'args' => ['label' => 'Enable Flixmedia Feed Cron', 'instructions' => 'Enable or disable flixmedia feed cron generator.', 'default_value' => 1, 'ui' => 1, 'ui_on_text' => 'Enabled', 'ui_off_text' => 'Disabled']], ['method' => 'addText', 'key' => 'flixmedia_banner_title', 'args' => ['label' => 'Flixmedia Banner Title', 'instructions' => 'Enter the title for the static banner.']], ['method' => 'addText', 'key' => 'flixmedia_banner_subtitle', 'args' => ['label' => 'Flixmedia Banner Subtitle', 'instructions' => 'Enter the subtitle for the static banner.']], ['method' => 'addTextarea', 'key' => 'flixmedia_banner_text', 'args' => ['label' => 'Flixmedia Banner Text', 'instructions' => 'Enter the main text for the static banner.']], ['method' => 'addText', 'key' => 'flixmedia_banner_link_text', 'args' => ['label' => 'Flixmedia Banner Link Text', 'instructions' => 'Enter the text for the banner link.']], ['method' => 'addUrl', 'key' => 'flixmedia_banner_link_url', 'args' => ['label' => 'Flixmedia Banner Link URL', 'instructions' => 'Enter the URL for the banner link.']], ['method' => 'addUrl', 'key' => 'flixmedia_banner_image', 'args' => ['label' => 'Flixmedia Banner Image URL', 'instructions' => 'Enter the URL of the banner image.']], ['method' => 'addUrl', 'key' => 'flixmedia_banner_logo', 'args' => ['label' => 'Flixmedia Banner Logo URL', 'instructions' => 'Enter the URL of the banner logo.']]]

Methods

createSettingsPage()

public createSettingsPage() : mixed

getAllFieldKeys()

Retrieves all registered ACF field keys.

public static getAllFieldKeys() : array<string|int, mixed>

This function extracts the 'key' value from each registered field definition.

Return values
array<string|int, mixed>

An array of field keys.

getAllOptionsFromTypeSense()

Load options from TypeSense collection.

public static getAllOptionsFromTypeSense([int|null $blogId = null ]) : array<string|int, mixed>
Parameters
$blogId : int|null = null
Return values
array<string|int, mixed>

getBlogOption()

Helper to get option value for a specific blog if blogId is given and valid, otherwise get global option.

public static getBlogOption(string $selector[, int|null $blogId = null ]) : mixed
Parameters
$selector : string

Option key.

$blogId : int|null = null

Optional blog ID.

getOption()

Retrieves a global option value using Advanced Custom Fields (ACF).

public static getOption(string $selector) : mixed|null
Parameters
$selector : string

The option field name (without prefix).

Return values
mixed|null

The value of the option, or null if ACF is not available.

getOptionFromAllSites()

Retrieves a specific option from all sites in a WordPress multisite network.

public static getOptionFromAllSites(string $selector) : array<string|int, mixed>

This function iterates through all sites, switches to each site, fetches the specified ACF option, and then restores the main site context.

Parameters
$selector : string

The option key to retrieve.

Return values
array<string|int, mixed>

An associative array where keys are site IDs and values are the retrieved options.

loadAllOptions()

Retrieves all ACF option values for registered fields from DB.

public static loadAllOptions([int|null $blogId = null ]) : array<string|int, mixed>

For each registered field key, this function fetches the corresponding ACF option value, either from a specific site (if $blogId is provided) or from the global site.

Parameters
$blogId : int|null = null

Optional blog ID for multisite support.

Return values
array<string|int, mixed>

An associative array of [field_key => value].

wscSettingsSaved()

Callback triggered when settings are saved.

public wscSettingsSaved(string $post_id) : mixed

Checks if the save action occurred on the global options page and specifically on the 'wsc-settings' admin page. If so, it calls a method to refresh or repopulate the settings document for the current multisite blog.

Parameters
$post_id : string

The ID of the saved post, usually 'options' for options pages.


        
On this page

Search results