Tkt_Template_Builder_Public

The public-facing functionality of the plugin.

Description

Defines the plugin name, version, and two hooks to enqueue the public-facing stylesheet and JavaScript. As you add hooks and methods, update this description.

Tags
author

Beda Schmid beda@tukutoi.com

Table of Contents

$plugin_name  : string
The ID of this plugin.
$plugin_prefix  : string
The unique prefix of this plugin.
$version  : string
The version of this plugin.
__construct()  : mixed
Initialize the class and set its properties.
add_special_tags_to_wp_kses()  : mixed
This is a Filter callback.
apply_content_template()  : mixed
Apply Content Template.
get_template_id()  : mixed
This is a Filter callback.
get_template_settings()  : mixed
This is a Filter callback.
include_template()  : mixed
Include Custom Template.
remove_special_tags_from_wp_kses()  : mixed
This is a Filter callback.
unset_wp_kses_tags()  : mixed
This is a Filter callback.
get_available_content_templates()  : mixed
Get Available Templates.
get_available_templates()  : mixed
Get Available Templates.
load_template()  : mixed
Load the TukuToi Template.

Properties

$plugin_prefix

The unique prefix of this plugin.

private string $plugin_prefix
Description

The string used to uniquely prefix technical functions of this plugin.

Tags
since
0.0.1
access

private

Methods

__construct()

Initialize the class and set its properties.

public __construct(string $plugin_name, string $plugin_prefix, string $version) : mixed
Parameters
$plugin_name
(string) The name of the plugin.
$plugin_prefix
(string) The unique prefix of this plugin.
$version
(string) The version of this plugin.
Tags
since
0.0.1
Return
(mixed)

add_special_tags_to_wp_kses()

This is a Filter callback.

public add_special_tags_to_wp_kses(array<string|int, mixed> $allowed_html_tags, string $context) : mixed
Description

We have to add some special HTML Tags that are needed mostly when displaying headers.

Parameters
$allowed_html_tags
(array<string|int, mixed>) Array of allowed tags in wp_kses.
$context
(string) Context of wp_kses (default in this case).
Return
(mixed)

apply_content_template()

Apply Content Template.

public apply_content_template(mixed $content) : mixed
Description

Let's do some trickery with filters. Preamble: We add this filter apply_content_template to the content late, at priority 999. This because we want to overwrite any possible template output of the_content with the user's custom template.

However, to parse the_content properly (ShortCodes, style, etc) we have to re-apply the_content filter. If we do that, we end in an infinite loop, because we add the apply_content_template filter to the_content, which will hook apply_content_template, and then inside itself, applying the_content filter, which in turn re-adds apply_content_template, which in turn reapplies the_content, and in turn re-adds apply_content_template.... you get it.

Maximum level of nested reached will be the result. In other words, a timeout/fatal.

To resolve this we:

  • add_filter apply_content_template to the_content hook
  • remove_filter apply_content_template filter from the_content while apply_content_template executes
  • apply the_content filter on the Post Content inside apply_content_template
  • add_filter apply_content_template back to the_content hook
  • return the Post Content.
Parameters
$content
(mixed) The Post Content.
Tags
since
1.3.0
Return
(mixed)

get_template_id()

This is a Filter callback.

public get_template_id(int $template_id) : mixed
Description

It allows to set the Template ID in $this->include_template() We then get these settings with: $template_id = apply_filters( 'tkt_template_id', 0 );

Parameters
$template_id
(int) The Template ID to load. Default: array(). Accepts: valid Settings array.
Tags
see
Partials
Return
(mixed)

get_template_settings()

This is a Filter callback.

public get_template_settings(int $template_id) : mixed
Description

It allows to set the Template settings in $this->include_template() We then get these settings with: $template_id = apply_filters( 'tkt_template_settings', array() );

Parameters
$template_id
(int) The Template ID to load. Default: array(). Accepts: valid Settings array.
Tags
see
Partials
Return
(mixed)

include_template()

Include Custom Template.

public include_template(string $template) : mixed
Parameters
$template
(string) The Template path loaded.
Tags
since
0.0.1
Return
(mixed)

remove_special_tags_from_wp_kses()

This is a Filter callback.

public remove_special_tags_from_wp_kses(mixed $content) : mixed
Description

We have to remove some special HTML Tags that where needed mostly when displaying headers.

Parameters
$content
(mixed) The Content - do NOTHING with it here.
Return
(mixed)

unset_wp_kses_tags()

This is a Filter callback.

public unset_wp_kses_tags(array<string|int, mixed> $allowed_html_tags, string $context) : mixed
Description

We have to remove some special HTML Tags that where needed mostly when displaying headers.

Parameters
$allowed_html_tags
(array<string|int, mixed>) Array of allowed tags in wp_kses.
$context
(string) Context of wp_kses (default in this case).
Return
(mixed)

Search results