Plugin_Elementor implements Registerable, JsonSerializable

Handles the Elementor Pro integration.

Interfaces, Classes and Traits

Registerable
JsonSerializable

Table of Contents

INTEGRATION_PREFIX  = '_elementor'
Holds the prefix used for identifying the query.
$cache  : Query_Cache
Holds the query and filters cache handler.
$hookables  : array<string|int, mixed>
List of widgets & sections that we support.
$supported_widgets  : array<string|int, mixed>
Widgets we've added support to.
$found_widget  : bool
Cache whether we found our widgets or not.
$products_query_counter  : int
For some reason Elementor runs queries twice.
$products_query_offset  : int
Intercept the 2nd Elementor query query.
add_closing_wrapper()  : string
Add a closing wrapper around the elements containing our supported element.
add_template_class()  : void
Add custom classes to the elements wrapper if filtering is enabled onto our supported widgets.
assets()  : void
Enqueue the elementor specific assets.
cache_query()  : void
Cache the prefilled query so that it can then be used at a later point when sending back an ajax response.
catch_elementor_page()  : void
If this is an elementor page and one of our supported elements has been found:
disable_hider()  : void
Disable the hider wrapper.
disable_horizontal_elements()  : void
Disable the horizontal elements automatically attached.
disable_pagination_template_override()  : void
Disable our custom pagination template override.
disable_wp_query_wrapper()  : void
Disable the original query wrapper because elementor runs queries twice so the wrapper goes to the wrong place.
get_widgets_list()  : array<string|int, mixed>
Get the list of widgets being used on an elementor page.
init()  : void
Hook into WP & Elementor.
inject_template()  : void
Print the expected json response before headers are sent.
intercept()  : void
Intercept the search request, load the hooks and buffer the output.
jsonSerialize()  : array<string|int, mixed>
Prepare fallback json array.
pre_get_posts()  : void
Add support for filtering to the elementor queries.
register()  : void
Register the integration.
register_controls()  : void
Register custom controls for the widgets.
register_shortcode_controls()  : void
Register custom controls for the shortcode widget.
hook_into_widgets()  : void
Attach our controls to the Elementor widgets.
add_fallback_product_ids()  : void
Add list of ids of all products loaded.
add_fallback_total_products()  : void
Add count of total products as a hidden div.
add_fallback_url()  : void
Generate the queried term link which is used for firing ajax queries.
get_all_post_ids_from_query()  : array<string|int, mixed>
Get all the post ids from the current query.
get_template()  : mixed
Get the template associated with the current location.
has_location()  : bool
Check if the current page has a valid elementor template location.
maybe_force_enqueue_of_wpt_asset()  : bool
Force enqueue of the WPT asset if the shortcode widget is used.

Constants

INTEGRATION_PREFIX

Holds the prefix used for identifying the query.

public mixed INTEGRATION_PREFIX = '_elementor'

Properties

$hookables

List of widgets & sections that we support.

protected array<string|int, mixed> $hookables = ['section_content' => ['woocommerce-products', 'wc-archive-products']]

$supported_widgets

Widgets we've added support to.

protected array<string|int, mixed> $supported_widgets = []

$found_widget

Cache whether we found our widgets or not.

private bool $found_widget

$products_query_counter

For some reason Elementor runs queries twice.

private int $products_query_counter = 0

$products_query_offset

Intercept the 2nd Elementor query query.

private int $products_query_offset = 1

Methods

add_closing_wrapper()

Add a closing wrapper around the elements containing our supported element.

public add_closing_wrapper(string $content, object $widget) : string
Parameters
$content : string
$widget : object
Return values
string

add_template_class()

Add custom classes to the elements wrapper if filtering is enabled onto our supported widgets.

public add_template_class(object $widget) : void
Parameters
$widget : object

widget instance

Return values
void

assets()

Enqueue the elementor specific assets.

public assets() : void
Return values
void

cache_query()

Cache the prefilled query so that it can then be used at a later point when sending back an ajax response.

public cache_query(WP_Query $query, Collection $filters, string $orderby, array<string|int, mixed> $post_ids) : void
Parameters
$query : WP_Query
$filters : Collection
$orderby : string
$post_ids : array<string|int, mixed>
Return values
void

catch_elementor_page()

If this is an elementor page and one of our supported elements has been found:

public catch_elementor_page() : void
  • dequeue the default prefiller json so we can replace it.
  • disable our custom pagination template override.
Return values
void

disable_hider()

Disable the hider wrapper.

public disable_hider() : void
Return values
void

disable_horizontal_elements()

Disable the horizontal elements automatically attached.

public disable_horizontal_elements() : void
Return values
void

disable_pagination_template_override()

Disable our custom pagination template override.

public disable_pagination_template_override() : void
Return values
void

disable_wp_query_wrapper()

Disable the original query wrapper because elementor runs queries twice so the wrapper goes to the wrong place.

public disable_wp_query_wrapper() : void
Return values
void

get_widgets_list()

Get the list of widgets being used on an elementor page.

public get_widgets_list(string|int $page_id) : array<string|int, mixed>
Parameters
$page_id : string|int
Return values
array<string|int, mixed>

init()

Hook into WP & Elementor.

public init() : void
Return values
void

inject_template()

Print the expected json response before headers are sent.

public inject_template() : void
Return values
void

intercept()

Intercept the search request, load the hooks and buffer the output.

public intercept() : void
Return values
void

jsonSerialize()

Prepare fallback json array.

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

pre_get_posts()

Add support for filtering to the elementor queries.

public pre_get_posts(WP_Query $query) : void
Parameters
$query : WP_Query
Return values
void

register()

Register the integration.

public register() : void
Return values
void

register_controls()

Register custom controls for the widgets.

public register_controls(object $element, array<string|int, mixed> $args) : void
Parameters
$element : object

Elementor widget instance.

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

register_shortcode_controls()

Register custom controls for the shortcode widget.

public register_shortcode_controls(object $element, array<string|int, mixed> $args) : void

This is needed for those cases where multiple integrations are used and the automated detection fails.

Parameters
$element : object

Elementor widget instance.

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

hook_into_widgets()

Attach our controls to the Elementor widgets.

protected hook_into_widgets() : void
Return values
void

add_fallback_product_ids()

Add list of ids of all products loaded.

private add_fallback_product_ids(array<string|int, mixed> $ids) : void
Parameters
$ids : array<string|int, mixed>
Return values
void

add_fallback_total_products()

Add count of total products as a hidden div.

private add_fallback_total_products(array<string|int, mixed> $ids) : void
Parameters
$ids : array<string|int, mixed>
Return values
void

add_fallback_url()

Generate the queried term link which is used for firing ajax queries.

private add_fallback_url() : void
Return values
void

get_all_post_ids_from_query()

Get all the post ids from the current query.

private get_all_post_ids_from_query(WP_Query $wp_query) : array<string|int, mixed>
Parameters
$wp_query : WP_Query
Return values
array<string|int, mixed>

get_template()

Get the template associated with the current location.

private get_template([string $location = 'archive' ]) : mixed
Parameters
$location : string = 'archive'
Return values
mixed

has_location()

Check if the current page has a valid elementor template location.

private has_location([string $location = 'archive' ]) : bool
Parameters
$location : string = 'archive'
Return values
bool

maybe_force_enqueue_of_wpt_asset()

Force enqueue of the WPT asset if the shortcode widget is used.

private maybe_force_enqueue_of_wpt_asset(array<string|int, mixed> $widgets) : bool
Parameters
$widgets : array<string|int, mixed>
Return values
bool

Search results