WooCommerce Code Reference

PatternsHelper
in package

Patterns Helper class.

Table of Contents

delete_patterns_ai_data_post()  : WP_Post|null
Delete the post that has the generated data by the AI for the patterns.
get_image_url()  : string
Fetches the AI-selected image for the pattern or returns the default image.
get_patterns_ai_data_post()  : WP_Post|null
Returns the post that has the generated data by the AI for the patterns.
get_patterns_dictionary()  : array<string|int, mixed>|WP_Error
Get the Patterns Dictionary.
upsert_patterns_ai_data_post()  : WP_Error|null
Upsert the patterns AI data.
find_pattern_by_slug()  : array<string|int, mixed>|null
Searches for a pattern by slug in a given dictionary.

Methods

delete_patterns_ai_data_post()

Delete the post that has the generated data by the AI for the patterns.

public static delete_patterns_ai_data_post() : WP_Post|null
Return values
WP_Post|null

get_image_url()

Fetches the AI-selected image for the pattern or returns the default image.

public static get_image_url(array<string|int, mixed> $images, int $index, string $default_image) : string
Parameters
$images : array<string|int, mixed>

The array of images.

$index : int

The index of the image to return.

$default_image : string

The default image to return.

Return values
stringThe image.

get_patterns_ai_data_post()

Returns the post that has the generated data by the AI for the patterns.

public static get_patterns_ai_data_post() : WP_Post|null
Return values
WP_Post|null

get_patterns_dictionary()

Get the Patterns Dictionary.

public static get_patterns_dictionary([string|null $pattern_slug = null ]) : array<string|int, mixed>|WP_Error
Parameters
$pattern_slug : string|null = null

The pattern slug.

Return values
array<string|int, mixed>|WP_ErrorReturns pattern dictionary or WP_Error on failure.

upsert_patterns_ai_data_post()

Upsert the patterns AI data.

public static upsert_patterns_ai_data_post(array<string|int, mixed> $patterns_dictionary) : WP_Error|null
Parameters
$patterns_dictionary : array<string|int, mixed>

The patterns dictionary.

Return values
WP_Error|null

find_pattern_by_slug()

Searches for a pattern by slug in a given dictionary.

private static find_pattern_by_slug(array<string|int, mixed> $patterns_dictionary, string $slug) : array<string|int, mixed>|null
Parameters
$patterns_dictionary : array<string|int, mixed>

The patterns' dictionary.

$slug : string

The slug to search for.

Return values
array<string|int, mixed>|nullReturns the pattern if found, otherwise null.