Recent

Lazy_Load_Module class Pro only

Lazy_Load_Module

Replaces popular posts lists with a signed placeholder that is rendered via REST when it approaches the viewport.

Namespace: WebberZone\Top_Ten\Pro
Since: 4.4.0
Source: includes/class-lazy-load-module.php line 24

Methods

__construct()

Constructor.

Since: 4.4.0
Line: 56

public function __construct(  );

maybe_lazy_load()

Replaces an eligible list with its lazy-load placeholder.

Since: 4.4.0
Line: 73

public function maybe_lazy_load( $pre, $args, $post ): string|null;
TypeNameDescription
string|null$prePre-rendered output.
array$argsDisplay arguments.
\WP_Post|null$postCurrent post.

Returns: string|null — Placeholder or original value.

should_lazy_load()

Whether a list should be lazy loaded.

Since: 4.4.0
Line: 91

public function should_lazy_load( array $args ): bool;
TypeNameDescription
array$argsDisplay arguments.

Returns: bool — Whether lazy loading is active.

lazy_load_placeholder()

Generates the placeholder and queues the loader script.

Since: 4.4.0
Line: 110

public function lazy_load_placeholder( array $args, $post ): string;
TypeNameDescription
array$argsDisplay arguments.
\WP_Post|null$postCurrent post.

Returns: string — Placeholder HTML, or an empty string to render inline.

enqueue_script()

Registers and queues the lazy-load frontend script.

Since: 4.4.0
Line: 210

public function enqueue_script(  );

register_html_route()

Registers the endpoint that returns rendered popular-post HTML.

Since: 4.4.0
Line: 229

public function register_html_route(  );

get_items_html()

Returns the rendered list HTML.

Since: 4.4.0
Line: 253

public function get_items_html( $request ): \WP_REST_Response;
TypeNameDescription
\WP_REST_Request$requestREST request.

Returns: \WP_REST_Response — REST response.