Documentation

Parser
in package

Searches and replaces the footnotes and generates the reference container.

Tags
since
1.5.0
since
2.8.0

Rename class from Footnotes_Task to Parser.

Table of Contents

$allow_love_me  : bool
Flag if the display of 'LOVE FOOTNOTES' is allowed on the current public page.
$end_tag  : string|int
Footnote delimiter end short code.
$end_tag_regex  : string|null
Footnote delimiter end short code in RegEx format.
$footnote_link_slug  : string
The footnote slug.
$footnotes  : array<string|int, mixed>
Contains all footnotes found in the searched content.
$hard_links_enabled  : bool
Hard links for AMP compatibility.
$link_close_tag  : string
The closing tag.
$link_open_tag  : string
The opening tag.
$link_span  : string
The span element name.
$mirror_tooltip_text  : bool
Whether to mirror the tooltip text in the reference container.
$post_container_id_compound  : string
Contains the concatenated fragment ID base.
$post_id  : int
Autoload a.k.a. infinite scroll, or archive view.
$prefix  : string
Prefix for the Footnote html element ID.
$reference_container_id  : int
Multiple reference containers in content and widgets.
$referrer_link_slug  : string
The referrer slug.
$scroll_offset  : int
Scroll offset.
$start_tag  : string|int
Footnote delimiter start short code.
$start_tag_regex  : string|null
Footnote delimiter start short code in RegEx format.
$syntax_error_flag  : bool
Footnote delimiter syntax validation enabled.
$tooltip_shortcode  : string
The tooltip delimiter shortcode.
$tooltip_shortcode_length  : int
The tooltip delimiter shortcode length.
$link_ids_separator  : string
The slug and identifier separator.
$settings  : Settings
The plugin settings object.
__construct()  : mixed
Initialize the class and set its properties.
exec()  : string
Replaces all footnotes that occur in the given content.
footnotes_in_content()  : string
Replaces footnotes in the content of the current page/post.
footnotes_in_excerpt()  : string
Processes existing excerpt or replaces it with a new one generated on the basis of the post.
footnotes_in_title()  : string
Replaces footnotes in the post/page title.
footnotes_in_widget_text()  : string
Replaces footnotes in the content of the current widget.
footnotes_in_widget_title()  : string
Replaces footnotes in the widget title.
footnotes_output_footer()  : void
Displays the 'LOVE FOOTNOTES' slug if enabled.
footnotes_output_head()  : void
Outputs the custom css to the header of the public page.
generate_excerpt()  : string
Generates excerpt on the basis of the post.
generate_excerpt_with_footnotes()  : string
Generates excerpt with footnotes on the basis of the post.
reference_container()  : string
Generates the reference container.
register_hooks()  : void
Register WordPress hooks to replace Footnotes in the content of a public page.
search()  : string
Replaces all footnotes in the given content and appends them to the static property.
unify_delimiters()  : string
Brings the delimiters and unifies their various HTML escapement schemas.

Properties

$allow_love_me

Flag if the display of 'LOVE FOOTNOTES' is allowed on the current public page.

public static bool $allow_love_me = true
Tags
since
1.5.0

$end_tag

Footnote delimiter end short code.

public static string|int $end_tag = ''
Tags
since
1.5.0
since
2.6.2

Move from constant to class property.

$end_tag_regex

Footnote delimiter end short code in RegEx format.

public static string|null $end_tag_regex = ''
Tags
since
2.4.0
since
2.6.2

Move from global constant to class property.

The footnote slug.

public static string $footnote_link_slug = 'f'
Tags
since
2.3.0

$footnotes

Contains all footnotes found in the searched content.

public static array<string|int, mixed> $footnotes = array()
Tags
since
1.5.0

Hard links for AMP compatibility.

public static bool $hard_links_enabled = false

A property because used both in search() and reference_container().

Tags
since
2.0.0

The closing tag.

public static string $link_close_tag = ''
Tags
since
2.3.0
todo

Remove.

The opening tag.

public static string $link_open_tag = ''
Tags
since
2.3.0
todo

Remove.

The span element name.

public static string $link_span = 'span'
Tags
since
2.3.0
todo

Remove.

$mirror_tooltip_text

Whether to mirror the tooltip text in the reference container.

public static bool $mirror_tooltip_text = false
Tags
since
2.5.2

$post_container_id_compound

Contains the concatenated fragment ID base.

public static string $post_container_id_compound = ''
Tags
since
2.3.0

$post_id

Autoload a.k.a. infinite scroll, or archive view.

public static int $post_id = 0

As multiple posts are appended to each other, functions and fragment IDs must be disambiguated. post ID to make everything unique wrt infinite scroll and archive view.

Tags
since
2.0.6

$prefix

Prefix for the Footnote html element ID.

public static string $prefix = ''
Tags
since
1.5.8

$reference_container_id

Multiple reference containers in content and widgets.

public static int $reference_container_id = 1

This ID disambiguates multiple reference containers in a page as they may occur when the widget_text hook is active and the page is built with Elementor and has an accordion or similar toggle sections.

Incremented every time after a reference container is inserted.

Tags
since
2.2.9

The referrer slug.

public static string $referrer_link_slug = 'r'
Tags
since
2.3.0

$scroll_offset

Scroll offset.

public static int $scroll_offset = 34

Websites may use high fixed headers not contracting at scroll. Scroll offset may now need to get into inline CSS. Hence it needs to be loaded twice, because priority levels may not match.

Tags
since
2.1.4

$start_tag

Footnote delimiter start short code.

public static string|int $start_tag = ''
Tags
since
1.5.0
since
2.6.2

Move from constant to class property.

$start_tag_regex

Footnote delimiter start short code in RegEx format.

public static string|null $start_tag_regex = ''
Tags
since
2.4.0
since
2.6.2

Move from global constant to class property.

$syntax_error_flag

Footnote delimiter syntax validation enabled.

public static bool $syntax_error_flag = true

The algorithm first checks for balanced footnote opening and closing tag short codes. The first encountered error triggers the display of a warning below the post title.

Unbalanced short codes have caused significant trouble because they are hard to detect. Any compiler or other tool reports syntax errors in the first place. Footnotes' exception is considered a design flaw, and the feature is released as a bug fix after overdue 2.3.0 released in urgency to provide AMP compat before 2021.

Tags
since
2.4.0

$tooltip_shortcode

The tooltip delimiter shortcode.

public static string $tooltip_shortcode = '[[/tooltip]]'
Tags
since
2.5.2

$tooltip_shortcode_length

The tooltip delimiter shortcode length.

public static int $tooltip_shortcode_length = 12
Tags
since
2.5.2

The slug and identifier separator.

private static string $link_ids_separator = '+'
Tags
since
2.3.0

$settings

The plugin settings object.

private Settings $settings
Tags
access

private

since
2.8.0

Methods

__construct()

Initialize the class and set its properties.

public __construct(Settings $settings) : mixed
Parameters
$settings : Settings
Tags
since
2.8.0
todo

Reorganise dependencies.

todo

Move call to register_hooks() to General.

Return values
mixed

exec()

Replaces all footnotes that occur in the given content.

public exec(string $content[, bool $output_references = false ][, bool $hide_footnotes_text = false ]) : string
Parameters
$content : string

Any string that may contain footnotes to be replaced.

$output_references : bool = false

Appends the Reference Container to the output if set to true, default true.

$hide_footnotes_text : bool = false

Hide footnotes found in the string.

Tags
since
1.5.0
Return values
string

footnotes_in_content()

Replaces footnotes in the content of the current page/post.

public footnotes_in_content(string $content) : string
Parameters
$content : string

Page/Post content.

Tags
since
1.5.0
Return values
string

$content Content with replaced footnotes.

footnotes_in_excerpt()

Processes existing excerpt or replaces it with a new one generated on the basis of the post.

public footnotes_in_excerpt(string $excerpt) : string

The input was already the processed excerpt, no more footnotes to search. But issue #65 brought up that manual excerpts can include processable footnotes. Default 'manual' is fallback and is backwards-compatible with the initial setup.

Parameters
$excerpt : string

Excerpt content.

Tags
since
1.5.0
Return values
string

$excerpt Processed or new excerpt.

footnotes_in_title()

Replaces footnotes in the post/page title.

public footnotes_in_title(string $content) : string
Parameters
$content : string

Title.

Tags
since
1.5.0
Return values
string

$content Title with replaced footnotes.

footnotes_in_widget_text()

Replaces footnotes in the content of the current widget.

public footnotes_in_widget_text(string $content) : string
Parameters
$content : string

Widget content.

Tags
since
1.5.0
Return values
string

$content Content with replaced footnotes.

footnotes_in_widget_title()

Replaces footnotes in the widget title.

public footnotes_in_widget_title(string $content) : string
Parameters
$content : string

Widget content.

Tags
since
1.5.0
Return values
string

$content Content with replaced footnotes.

Displays the 'LOVE FOOTNOTES' slug if enabled.

public footnotes_output_footer() : void
Tags
since
1.5.0
Return values
void

footnotes_output_head()

Outputs the custom css to the header of the public page.

public footnotes_output_head() : void
Tags
since
1.5.0
todo

Refactor to enqueue stylesheets properly in General.

Return values
void

generate_excerpt_with_footnotes()

Generates excerpt with footnotes on the basis of the post.

public generate_excerpt_with_footnotes(string $content) : string

Does not apply full WordPress excerpt processing.

Parameters
$content : string

The post.

Tags
see
self::generate_excerpt()

Uses information and some code from Advanced Excerpt.

link
https://wordpress.org/plugins/advanced-excerpt/
since
2.6.3
Return values
string

$content An excerpt of the post.

reference_container()

Generates the reference container.

public reference_container() : string
Tags
since
1.5.0
Return values
string

register_hooks()

Register WordPress hooks to replace Footnotes in the content of a public page.

public register_hooks() : void
Tags
since
1.5.0
since
1.5.4

Add support for @see 'the_post' hook.

since
2.0.5

Enable all hooks by default.

since
2.1.0

Remove @see 'the_post' support.

todo

Move to General.

Return values
void

Replaces all footnotes in the given content and appends them to the static property.

public search(string $content, bool $hide_footnotes_text) : string
Parameters
$content : string

Any content to be parsed for footnotes.

$hide_footnotes_text : bool

Hide footnotes found in the string.

Tags
since
1.5.0
todo

Refactor to parse DOM rather than using RegEx.

todo

Decompose.

Return values
string

unify_delimiters()

Brings the delimiters and unifies their various HTML escapement schemas.

public unify_delimiters(string $content) : string

While the Classic Editor (visual mode) escapes both pointy brackets, the Block Editor enforces balanced escapement only in code editor mode when the opening tag is already escaped. In visual mode, the Block Editor does not escape the greater-than sign.

Parameters
$content : string

The footnote, including delimiters.

Tags
since
2.1.14
Return values
string

Search results