Tracker implements Registerable, Standard_Service

Tracks when products and terms are added, updated or deleted and updates the index accordingly.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Registerable
Standard_Service

Table of Contents

$is_saving  : bool
Is wp_insert_post running?
$indexer  : Indexer
Indexer service.
__construct()  : void
Get things started.
create_attribute_filter()  : void
When a new attribute has been added check if an "all" attribute exists, if it does - create the child filter.
delete_attribute_filter()  : void
Delete the related attribute filter when an attribute is removed.
delete_post()  : void
Delete indexed data when a post is deleted.
delete_term()  : void
Cleanup term related data from the index, when the term is deleted.
edit_term()  : void
Update indexed data when a product related term (taxonomy & attribute) is saved.
index_on_csv_import()  : void
Index products when they're added via csv import.
is_wp_insert_post()  : mixed
We're hijacking wp_insert_post_parent Prevent our set_object_terms() hook from firing within wp_insert_post
register()  : void
Register hooks into the WP and WC lifecycle.
save_post()  : void
Update the index when a post is saved.
set_object_terms()  : void
Support for manual taxonomy associations.
update_attribute_filters()  : void
Update attribute filters when an attribute is modified.

Properties

$is_saving

Is wp_insert_post running?

public bool $is_saving = false

Methods

__construct()

Get things started.

public __construct() : void
Return values
void

create_attribute_filter()

When a new attribute has been added check if an "all" attribute exists, if it does - create the child filter.

public create_attribute_filter(int $id, array<string|int, mixed> $data) : void
Parameters
$id : int

Added attribute ID.

$data : array<string|int, mixed>

Attribute data.

Return values
void

delete_attribute_filter()

Delete the related attribute filter when an attribute is removed.

public delete_attribute_filter(int $id, string $name, string $taxonomy) : void
Parameters
$id : int

Attribute ID.

$name : string

Attribute name.

$taxonomy : string

Attribute taxonomy name.

Return values
void

delete_post()

Delete indexed data when a post is deleted.

public delete_post(string $post_id) : void
Parameters
$post_id : string
Return values
void

delete_term()

Cleanup term related data from the index, when the term is deleted.

public delete_term(string $term_id, string $tt_id, string $taxonomy) : void
Parameters
$term_id : string
$tt_id : string
$taxonomy : string
Return values
void

edit_term()

Update indexed data when a product related term (taxonomy & attribute) is saved.

public edit_term(string $term_id, string $tt_id, string $taxonomy) : void
Parameters
$term_id : string
$tt_id : string
$taxonomy : string
Return values
void

index_on_csv_import()

Index products when they're added via csv import.

public index_on_csv_import(object $item, array<string|int, mixed> $data) : void
Parameters
$item : object

Product instance.

$data : array<string|int, mixed>
Return values
void

is_wp_insert_post()

We're hijacking wp_insert_post_parent Prevent our set_object_terms() hook from firing within wp_insert_post

public is_wp_insert_post(string $post_parent) : mixed
Parameters
$post_parent : string
Return values
mixed

register()

Register hooks into the WP and WC lifecycle.

public register() : void
Return values
void

save_post()

Update the index when a post is saved.

public save_post(string $post_id) : void
Parameters
$post_id : string
Return values
void

set_object_terms()

Support for manual taxonomy associations.

public set_object_terms(string|int $object_id) : void
Parameters
$object_id : string|int
Return values
void

update_attribute_filters()

Update attribute filters when an attribute is modified.

public update_attribute_filters(int $id, array<string|int, mixed> $data, string $old_slug) : void
Parameters
$id : int

Attribute ID

$data : array<string|int, mixed>

Attribute data

$old_slug : string

Previous attribute slug

Return values
void

Search results