Footnotes_Parser
Searches and replaces the footnotes and generates the reference container.
Tags
Table of Contents
- $a_arr_footnotes : array<string|int, string>
- Contains all footnotes found in the searched content.
- $a_bool_allow_love_me : bool
- Flag if the display of 'LOVE FOOTNOTES' is allowed on the current public page.
- $a_bool_hard_links_enabled : bool
- Hard links for AMP compatibility.
- $a_bool_mirror_tooltip_text : bool
- Whether to mirror the tooltip text in the reference container.
- $a_bool_syntax_error_flag : bool
- Footnote delimiter syntax validation enabled.
- $a_int_post_id : int
- Autoload a.k.a. infinite scroll, or archive view.
- $a_int_reference_container_id : int
- Multiple reference containers in content and widgets.
- $a_int_scroll_offset : int
- Scroll offset.
- $a_int_tooltip_shortcode_length : int
- The tooltip delimiter shortcode length.
- $a_str_end_tag : string
- Footnote delimiter end short code.
- $a_str_end_tag_regex : string
- Footnote delimiter end short code in RegEx format.
- $a_str_footnote_link_slug : string
- The footnote slug.
- $a_str_link_close_tag : string
- The closing tag.
- $a_str_link_open_tag : string
- The opening tag.
- $a_str_link_span : string
- The span element name.
- $a_str_post_container_id_compound : string
- Contains the concatenated fragment ID base.
- $a_str_prefix : string
- Prefix for the Footnote html element ID.
- $a_str_referrer_link_slug : string
- The referrer slug.
- $a_str_start_tag : string
- Footnote delimiter start short code.
- $a_str_start_tag_regex : string
- Footnote delimiter start short code in RegEx format.
- $a_str_tooltip_shortcode : string
- The tooltip delimiter shortcode.
- $a_str_link_ids_separator : string
- The slug and identifier separator.
- __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() : mixed
- Displays the 'LOVE FOOTNOTES' slug if enabled.
- footnotes_output_head() : mixed
- 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() : mixed
- 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() : mixed
- Brings the delimiters and unifies their various HTML escapement schemas.
Properties
$a_arr_footnotes
Contains all footnotes found in the searched content.
public
static array<string|int, string>
$a_arr_footnotes
= array()
Tags
$a_bool_allow_love_me
Flag if the display of 'LOVE FOOTNOTES' is allowed on the current public page.
public
static bool
$a_bool_allow_love_me
= rue
Tags
$a_bool_hard_links_enabled
Hard links for AMP compatibility.
public
static bool
$a_bool_hard_links_enabled
= alse
A property because used both in search() and reference_container().
Tags
$a_bool_mirror_tooltip_text
Whether to mirror the tooltip text in the reference container.
public
static bool
$a_bool_mirror_tooltip_text
= alse
Tags
$a_bool_syntax_error_flag
Footnote delimiter syntax validation enabled.
public
static bool
$a_bool_syntax_error_flag
= rue
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
$a_int_post_id
Autoload a.k.a. infinite scroll, or archive view.
public
static int
$a_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
$a_int_reference_container_id
Multiple reference containers in content and widgets.
public
static int
$a_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.
Tags
$a_int_scroll_offset
Scroll offset.
public
static int
$a_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
$a_int_tooltip_shortcode_length
The tooltip delimiter shortcode length.
public
static int
$a_int_tooltip_shortcode_length
= 12
Tags
$a_str_end_tag
Footnote delimiter end short code.
public
static string
$a_str_end_tag
= ''
Tags
$a_str_end_tag_regex
Footnote delimiter end short code in RegEx format.
public
static string
$a_str_end_tag_regex
= ''
Tags
$a_str_footnote_link_slug
The footnote slug.
public
static string
$a_str_footnote_link_slug
= 'f'
Tags
$a_str_link_close_tag
The closing tag.
public
static string
$a_str_link_close_tag
= ''
Tags
$a_str_link_open_tag
The opening tag.
public
static string
$a_str_link_open_tag
= ''
Tags
$a_str_link_span
The span element name.
public
static string
$a_str_link_span
= 'span'
Tags
$a_str_post_container_id_compound
Contains the concatenated fragment ID base.
public
static string
$a_str_post_container_id_compound
= ''
Tags
$a_str_prefix
Prefix for the Footnote html element ID.
public
static string
$a_str_prefix
= ''
Tags
$a_str_referrer_link_slug
The referrer slug.
public
static string
$a_str_referrer_link_slug
= 'r'
Tags
$a_str_start_tag
Footnote delimiter start short code.
public
static string
$a_str_start_tag
= ''
Tags
$a_str_start_tag_regex
Footnote delimiter start short code in RegEx format.
public
static string
$a_str_start_tag_regex
= ''
Tags
$a_str_tooltip_shortcode
The tooltip delimiter shortcode.
public
static string
$a_str_tooltip_shortcode
= '[[/tooltip]]'
Tags
$a_str_link_ids_separator
The slug and identifier separator.
private
static string
$a_str_link_ids_separator
= '+'
Tags
Methods
__construct()
Initialize the class and set its properties.
public
__construct() : mixed
Tags
Return values
mixed —exec()
Replaces all footnotes that occur in the given content.
public
exec(string $p_str_content[, bool $p_bool_output_references = false ][, bool $p_bool_hide_footnotes_text = false ]) : string
Parameters
- $p_str_content : string
-
Any string that may contain footnotes to be replaced.
- $p_bool_output_references : bool = false
-
Appends the Reference Container to the output if set to true, default true.
- $p_bool_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 $p_str_content) : string
Parameters
- $p_str_content : string
-
Page/Post content.
Tags
Return values
string —$p_str_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 $p_str_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
- $p_str_excerpt : string
-
Excerpt content.
Tags
Return values
string —$p_str_excerpt Processed or new excerpt.
footnotes_in_title()
Replaces footnotes in the post/page title.
public
footnotes_in_title(string $p_str_content) : string
Parameters
- $p_str_content : string
-
Title.
Tags
Return values
string —$p_str_content Title with replaced footnotes.
footnotes_in_widget_text()
Replaces footnotes in the content of the current widget.
public
footnotes_in_widget_text(string $p_str_content) : string
Parameters
- $p_str_content : string
-
Widget content.
Tags
Return values
string —$p_str_content Content with replaced footnotes.
footnotes_in_widget_title()
Replaces footnotes in the widget title.
public
footnotes_in_widget_title(string $p_str_content) : string
Parameters
- $p_str_content : string
-
Widget content.
Tags
Return values
string —$p_str_content Content with replaced footnotes.
footnotes_output_footer()
Displays the 'LOVE FOOTNOTES' slug if enabled.
public
footnotes_output_footer() : mixed
Tags
Return values
mixed —footnotes_output_head()
Outputs the custom css to the header of the public page.
public
footnotes_output_head() : mixed
Tags
Return values
mixed —generate_excerpt()
Generates excerpt on the basis of the post.
public
generate_excerpt(string $p_str_content) : string
Applies full WordPress excerpt processing.
Parameters
- $p_str_content : string
-
The post.
Tags
Return values
string —$p_str_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 $p_str_content) : string
Does not apply full WordPress excerpt processing.
Parameters
- $p_str_content : string
-
The post.
Tags
Return values
string —$p_str_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() : mixed
Tags
Return values
mixed —search()
Replaces all footnotes in the given content and appends them to the static property.
public
search(string $p_str_content, bool $p_bool_hide_footnotes_text) : string
Parameters
- $p_str_content : string
-
Any content to be parsed for footnotes.
- $p_bool_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 $p_str_content) : mixed
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
- $p_str_content : string
-
The footnote, including delimiters.