Parser
in package
Searches and replaces the footnotes and generates the reference container.
Tags
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
$end_tag
Footnote delimiter end short code.
public
static string|int
$end_tag
= ''
Tags
$end_tag_regex
Footnote delimiter end short code in RegEx format.
public
static string|null
$end_tag_regex
= ''
Tags
$footnote_link_slug
The footnote slug.
public
static string
$footnote_link_slug
= 'f'
Tags
$footnotes
Contains all footnotes found in the searched content.
public
static array<string|int, mixed>
$footnotes
= array()
Tags
$hard_links_enabled
Hard links for AMP compatibility.
public
static bool
$hard_links_enabled
= false
A property because used both in search() and reference_container().
Tags
$link_close_tag
The closing tag.
public
static string
$link_close_tag
= ''
Tags
$link_open_tag
The opening tag.
public
static string
$link_open_tag
= ''
Tags
$link_span
The span element name.
public
static string
$link_span
= 'span'
Tags
$mirror_tooltip_text
Whether to mirror the tooltip text in the reference container.
public
static bool
$mirror_tooltip_text
= false
Tags
$post_container_id_compound
Contains the concatenated fragment ID base.
public
static string
$post_container_id_compound
= ''
Tags
$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
$prefix
Prefix for the Footnote html element ID.
public
static string
$prefix
= ''
Tags
$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
$referrer_link_slug
The referrer slug.
public
static string
$referrer_link_slug
= 'r'
Tags
$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
$start_tag
Footnote delimiter start short code.
public
static string|int
$start_tag
= ''
Tags
$start_tag_regex
Footnote delimiter start short code in RegEx format.
public
static string|null
$start_tag_regex
= ''
Tags
$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
$tooltip_shortcode
The tooltip delimiter shortcode.
public
static string
$tooltip_shortcode
= '[[/tooltip]]'
Tags
$tooltip_shortcode_length
The tooltip delimiter shortcode length.
public
static int
$tooltip_shortcode_length
= 12
Tags
$link_ids_separator
The slug and identifier separator.
private
static string
$link_ids_separator
= '+'
Tags
$settings
The plugin settings object.
private
Settings
$settings
Tags
Methods
__construct()
Initialize the class and set its properties.
public
__construct(Settings $settings) : mixed
Parameters
- $settings : Settings
Tags
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
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
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
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
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
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
Return values
string —$content Content with replaced footnotes.
footnotes_output_footer()
Displays the 'LOVE FOOTNOTES' slug if enabled.
public
footnotes_output_footer() : void
Tags
Return values
void —footnotes_output_head()
Outputs the custom css to the header of the public page.
public
footnotes_output_head() : void
Tags
Return values
void —generate_excerpt()
Generates excerpt on the basis of the post.
public
generate_excerpt(string $content) : string
Applies full WordPress excerpt processing.
Parameters
- $content : string
-
The post.
Tags
Return values
string —$content An excerpt of the post.
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
Return values
string —$content An excerpt of the post.
reference_container()
Generates the reference container.
public
reference_container() : string
Tags
Return values
string —register_hooks()
Register WordPress hooks to replace Footnotes in the content of a public page.
public
register_hooks() : void
Tags
Return values
void —search()
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
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.