2016-06-29 12:54:05 +00:00
< ? php
/**
* Includes the core function of the Plugin - Search and Replace the Footnotes .
*
* @ filesource
* @ author Stefan Herndler
* @ since 1.5 . 0
2020-11-12 18:17:28 +00:00
*
*
2021-01-26 17:01:53 +00:00
* @ lastmodified 2021 - 01 - 26 T0752 + 0100
2021-01-03 20:03:51 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.0 . 0
* @ edit 2.0 . 5 Reference container : fix relative position through priority level , thanks to @ june01 @ imeson bug reports , thanks to @ spaceling code contribution
* @ edit 2.0 . 6 Infinite scroll : debug autoload by adding post ID , thanks to @ docteurfitness code contribution
* @ edit 2.0 . 9 REMOVE the_post HOOK 2020 - 11 - 08 T1839 + 0100
* @ edit 2.1 . 0 Tooltips : Read - on button : Label : configurable instead of localizable
* @ edit 2.1 . 1 Combining identical footnotes : fix dead links and ensure referrer - backlink bijectivity , thanks to @ happyches bug report
* @ edit 2.1 . 1 Reference container : fix start pages by making its display optional , thanks to @ dragon013 bug report
* @ edit 2.1 . 1 Referrers : new setting for vertical align : superscript ( default ) or baseline ( optional ), thanks to @ cwbayer bug report
* @ edit 2.1 . 1 Reference container : option to restore 3 - column layout ( combining identicals turned off )
* @ edit 2.1 . 1 Reference container : option to append symbol ( prepended by default ) ( combining identicals turned off )
* @ edit 2.1 . 1 Dashboard : priority level setting for the_content hook , thanks to @ imeson bug report
* @ edit 2.1 . 2 Dashboard : priority level settings for all other hooks , thanks to @ nikelaos bug report
2020-11-12 18:17:28 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.1 . 4 fix line wrapping of URLs based on pattern , not link element 2020 - 11 - 25 T0837 + 0100
* @ edit 2.1 . 4 fix issues with link elements by making them optional 2020 - 11 - 26 T1051 + 0100
* @ edit 2.1 . 4 support appending arrow when combining identicals is on 2020 - 11 - 26 T1633 + 0100
* @ edit 2.1 . 4 disable or select backlink separator and terminator 2020 - 11 - 28 T1048 + 0100
* @ edit 2.1 . 4 optional line breaks to stack enumerated backlinks 2020 - 11 - 28 T1049 + 0100
* @ edit 2.1 . 4 ref container column width and tooltip font size settings 2020 - 12 - 03 T0954 + 0100
* @ edit 2.1 . 4 scroll offset and duration settings 2020 - 12 - 05 T0538 + 0100
* @ edit 2.1 . 4 tooltip display duration settings 2020 - 12 - 06 T1320 + 0100
2020-12-18 16:31:09 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.1 . 5 URL wrap : exclude image source too , thanks to @ bjrnet21
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / 2 - 1 - 4 - breaks - on - my - site - images - dont - show /
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.1 . 6 option to disable URL line wrapping 2020 - 12 - 09 T1606 + 0100
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.1 . 6 add catch - all exclusion to fix URL line wrapping , thanks to @ a223123131 2020 - 12 - 09 T1921 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / broken - layout - starting - version - 2 - 1 - 4 /
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 0 support for custom position shortcode for reference container , thanks to @ hamshe 2020 - 12 - 13 T2058 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / reference - container - in - elementor /
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 3 custom CSS from new setting in header after legacy 2020 - 12 - 15 T1128 + 0100
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 5 connect alternative tooltips to position and timing settings 2020 - 12 - 18 T1113 + 0100
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 5 delete unused position shortcode when ref container in widget or footer , thanks to @ hamshe 2020 - 12 - 18 T1437 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / reference - container - in - elementor / #post-13784126
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 5 options for label element and label bottom border , thanks to @ markhillyer 2020 - 12 - 18 T1447 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / how - do - i - eliminate - the - horizontal - line - beneath - the - reference - container - heading /
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 6 URL wrap : make the quotation mark optional in the exclusion regex , thanks to @ spiralofhope2 2020 - 12 - 23 T0409 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / two - links - now - breaks - footnotes - with - blogtext /
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 7 revert that change in the exclusion regex , thanks to @ rjl20 , @ spaceling , @ friedrichnorth , @ bernardzit 2020 - 12 - 23 T1046 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / two - links - now - breaks - footnotes - with - blogtext /
* @ link https :// wordpress . org / support / topic / footnotes - dont - show - after - update - to - 2 - 2 - 6 /
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 8 URL wrap : correct lookbehind by duplicating it with and without quotation mark class 2 0 2 0 - 1 2 - 2 3 T1108 + 0100
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 9 URL wrap : account for RFC 2396 allowed characters in parameter names 2020 - 12 - 24 T1956 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// stackoverflow . com / questions / 814700 / http - url - allowed - characters - in - parameter - names
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 9 Reference containers , widget_text hook : support for multiple containers in a page , thanks to @ justbecuz bug report
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / reset - footnotes - to - 1 / #post-13662830
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 9 URL wrap : exclude URLs also where the equals sign is preceded by an entity or character reference 2020 - 12 - 25 T1251 + 0100
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 10 URL wrap : support also file transfer protocol URLs 2020 - 12 - 25 T2220 + 0100
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.2 . 10 Reference container : add option for table borders to revert 2.0 . 0 / 2.0 . 1 change made on user request , thanks to @ noobishh 2020 - 12 - 25 T2304 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / borders - 25 /
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.3 . 0 Reference container : convert top padding to margin and make it a setting , thanks to @ hamshe bug report
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / reference - container - in - elementor / #post-13786635
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.3 . 0 optional hard links in referrers and backlinks for AMP compatibility , thanks to @ psykonevro bug report , thanks to @ martinneumannat code contribution
* @ edit 2.3 . 0 swap Custom CSS migration Boolean from 'migration complete' to 'show legacy' 2020 - 12 - 27 T1243 + 0100
* @ edit 2.4 . 0 syntax validation for balanced footnote start and end tags 2021 - 01 - 01 T0227 + 0100
* @ edit 2.4 . 0 initialize scroll offset variable to 34 as a more robust default , thanks to @ lukashuggenberg 2021 - 01 - 04 T0504 + 0100
* @ edit 2.4 . 0 set empty reference container label to NNBSP to make it more robust , thanks to @ lukashuggenberg 2021 - 01 - 04 T0504 + 0100
* @ edit 2.4 . 0 Performance : optimize template load and process according to settings , thanks to @ misfist code contribution
* @ edit 2.4 . 0 initialize hard link address as empty to fix undefined variable bug , thanks to @ a223123131 2021 - 01 - 04 T1622 + 0100
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.5 . 0 Shortcode syntax validation : exclude certain cases involving scripts , thanks to @ andreasra 2021 - 01 - 07 T0824 + 0100
* @ edit 2.5 . 0 Shortcode syntax validation : complete message with hint about setting , thanks to @ andreasra
* @ edit 2.5 . 0 Shortcode syntax validation : limit length of quoted string to 300 characters , thanks to @ andreasra
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / warning - unbalanced - footnote - start - tag - short - code - before /
2021-01-14 22:56:43 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.5 . 0 Hooks : support footnotes on category pages , thanks to @ vitaefit bug report , thanks to @ misfist code contribution
* @ edit 2.5 . 1 Hooks : support footnotes in Popup Maker popups , thanks to @ squatcher bug report
2021-01-23 00:25:35 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.5 . 2 Tooltips : ability to display dedicated content , thanks to @ jbj2199 bug report
2021-01-23 00:41:23 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.5 . 3 URL wrap : exclude URL pattern as folder name in Wayback Machine URL , thanks to @ rumperuu bug report
2016-06-29 12:54:05 +00:00
*/
2020-11-01 05:41:22 +00:00
2020-10-27 11:56:49 +00:00
// If called directly, abort:
defined ( 'ABSPATH' ) or die ;
2016-06-29 12:54:05 +00:00
/**
* Looks for Footnotes short codes and replaces them . Also displays the Reference Container .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
*/
class MCI_Footnotes_Task {
2020-12-31 11:45:10 +00:00
/**
* PROPERTIES
*/
2020-10-27 11:56:49 +00:00
/**
* Contains all footnotes found on current public page .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ var array
*/
public static $a_arr_Footnotes = array ();
2016-06-29 12:54:05 +00:00
2020-10-27 11:56:49 +00:00
/**
* Flag if the display of 'LOVE FOOTNOTES' is allowed on the current public page .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ var bool
*/
public static $a_bool_AllowLoveMe = true ;
2016-06-29 12:54:05 +00:00
2020-10-27 11:56:49 +00:00
/**
* Prefix for the Footnote html element ID .
*
* @ author Stefan Herndler
* @ since 1.5 . 8
* @ var string
*/
public static $a_str_Prefix = " " ;
2016-06-29 12:54:05 +00:00
2020-12-25 15:14:43 +00:00
/**
2021-01-26 17:01:53 +00:00
* INFINITE SCROLL / AUTOLOAD OR ARCHIVE VIEW
2020-12-25 15:14:43 +00:00
*
2021-01-23 00:25:35 +00:00
* debug autoload / infinite scroll by adding post ID , thanks to @ docteurfitness code contribution
2021-01-26 17:01:53 +00:00
* @ since 2.0 . 6
*
* As multiple posts are appended to each other , functions and fragment IDs must be disambiguated .
2020-12-25 15:14:43 +00:00
*
2021-01-23 00:25:35 +00:00
* @ contributor @ docteurfitness
2021-01-26 17:01:53 +00:00
* @ reporter @ docteurfitness
*
* @ source https :// wordpress . org / support / topic / auto - load - post - compatibility - update / #post-13618833
* @ bugreport https :// wordpress . org / support / topic / auto - load - post - compatibility - update /
*
2020-12-25 15:14:43 +00:00
* @ var int
*
* post ID to make everything unique wrt infinite scroll and archive view :
*/
2021-01-23 00:25:35 +00:00
public static $a_int_PostId = 0 ;
2020-12-25 15:14:43 +00:00
/**
2021-01-26 17:01:53 +00:00
* MULTIPLE REFERENCE CONTAINERS IN CONTENT AND WIDGETS
2020-12-25 15:14:43 +00:00
*
2021-01-26 17:01:53 +00:00
* Reference containers , widget_text hook : support for multiple containers in a page , thanks to @ justbecuz bug report
2020-12-25 15:14:43 +00:00
* @ since 2.2 . 9
2021-01-23 00:25:35 +00:00
* @ datestamp 2020 - 12 - 25 T0338 + 0100
*
2021-01-26 17:01:53 +00:00
* @ reporter @ justbecuz
*
* @ bugreport https :// wordpress . org / support / topic / reset - footnotes - to - 1 /
* @ bugreport https :// wordpress . org / support / topic / reset - footnotes - to - 1 / #post-13662830
*
* @ var int incremented each time after a reference container is inserted
*
* 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 .
2020-12-25 15:14:43 +00:00
*/
2021-01-23 00:25:35 +00:00
public static $a_int_ReferenceContainerId = 1 ;
2020-12-25 15:14:43 +00:00
2021-01-04 15:51:57 +00:00
/**
2021-01-19 23:45:34 +00:00
* TEMPLATE PROCESS OPTIMIZATION
*
2021-01-26 17:01:53 +00:00
* Performance : optimize template load and process according to settings , thanks to @ misfist code contribution
* @ since 2.4 . 0
* @ datestamp 2021 - 01 - 04 T1355 + 0100
2021-01-04 15:51:57 +00:00
*
* @ author Patrizia Lutz @ misfist
*
2021-01-26 17:01:53 +00:00
* @ source https :// wordpress . org / support / topic / template - override - filter / #post-13864301
* @ link https :// github . com / misfist / footnotes / releases / tag / 2.4 . 0 d3 repository
* @ link https :// github . com / misfist / footnotes / compare / 2.4 . 0 % E2 % 80 % A62 . 4.0 d3 diff
*
* @ var bool from DB
*
* Streamline process depending on tooltip enabled status
* Load tooltip inline script only if jQuery tooltips are enabled
2021-01-04 15:51:57 +00:00
*/
2021-01-23 00:25:35 +00:00
public static $a_bool_TooltipsEnabled = false ;
public static $a_bool_AlternativeTooltipsEnabled = false ;
2021-01-04 15:51:57 +00:00
2020-12-31 11:45:10 +00:00
/**
2021-01-19 23:45:34 +00:00
* HARD LINKS FOR AMP
2020-12-31 11:45:10 +00:00
*
* Optional hard links in referrers and backlinks for AMP compatibility
*
2021-01-23 00:25:35 +00:00
* @ thanksto @ martinneumannat code contribution
* @ link https :// wordpress . org / support / topic / making - it - amp - compatible /
* @ thanksto @ psykonevro bug report
* @ link https :// wordpress . org / support / topic / footnotes - is - not - amp - compatible /
2020-12-31 11:45:10 +00:00
* @ since 2.3 . 0
* @ var bool | str | int
2021-01-23 00:25:35 +00:00
*/
public static $a_bool_HardLinksEnable = false ;
public static $a_str_ReferrerLinkSlug = 'r' ;
public static $a_str_FootnoteLinkSlug = 'f' ;
public static $a_str_LinkIdsSeparator = '+' ;
public static $a_str_PostContainerIdCompound = '' ;
/**
* SCROLL OFFSET
*
* Optional hard links in referrers and backlinks for AMP compatibility
*
* By accident , this variable may not be updated with settings storage .
* Websites may use high fixed headers not contracting at scroll .
* Scroll offset may now need to get into inline CSS .
* Hence initialize scroll offset to a safety default value 34 right here .
2021-01-04 15:51:57 +00:00
*
2021-01-23 00:25:35 +00:00
* @ since 2.4 . 0
* @ datestamp 2021 - 01 - 03 T2055 + 0100
2020-12-31 11:45:10 +00:00
*/
2021-01-23 00:25:35 +00:00
public static $a_int_ScrollOffset = 34 ;
2020-12-31 11:45:10 +00:00
/**
* OPTIONAL LINK ELEMENT FOR FOOTNOTE REFERRERS AND BACKLINKS
*
* STYLING :
* Link color is preferred for referrers and backlinks .
* Setting a global link color is a common feature in WordPress themes .
* CSS does not support identifiers for link colors ( color : link | hover | active | visited )
* These are only supported as pseudo - classes of the link element .
* Hence the link element must be present for styling purposes .
* But styling these elements with the link color is not universally preferred .
* If not , the very presence of the link elements may need to be avoided .
*
* FUNCTIONALITY :
* Although widely used for that purpose , hyperlinks are disliked for footnote linking .
* Browsers may need to be prevented from logging these clicks in the browsing history ,
* as logging compromises the usability of the 'return to previous' button in browsers .
* For that purpose , and for scroll animation , this linking is performed by JavaScript .
*
* Link elements also raise further concerns , so that their useless proliferation needs
* to be mitigated . By contrast , due to an insufficiency in the CSS standard , real link
* elements are required to get the link color , as opposed to named colors on the basis
* of the already supported pseudo - classes : link , : hover , : active and : visited that can
* still not be used in color names .
*
2021-01-23 00:25:35 +00:00
* @ since 2.0 . 0 add the link elements with hard links
*
* @ since 2.0 . 4 remove the hard links on user request
* @ link https :// wordpress . org / support / topic / hyperlinked - footnotes - creating - excessive - back - history /
*
* link elements optional for styling purposes
* @ since 2.1 . 4
* @ datestamp 2020 - 11 - 25 T1306 + 0100
*
* this variable keeps its default value if hard links are enabled
* @ since 2.3 . 0
* @ datestamp 2020 - 12 - 30 T2313 + 0100
2020-12-31 11:45:10 +00:00
*
* @ var str
*/
2021-01-23 00:25:35 +00:00
public static $a_str_LinkSpan = 'span' ;
public static $a_str_LinkOpenTag = '' ;
public static $a_str_LinkCloseTag = '' ;
2020-12-31 11:45:10 +00:00
2021-01-19 23:45:34 +00:00
/**
* DEDICATED TOOLTIP TEXT
*
2021-01-23 00:25:35 +00:00
* The ability to display dedicated content , thanks to @ jbj2199 bug report
*
2021-01-19 23:45:34 +00:00
* Tooltips can display another content than the footnote entry
* in the reference container . The trigger is a shortcode in
* the footnote text separating the tooltip text from the note .
*
2021-01-23 00:25:35 +00:00
* @ thanksto @ jbj2199 bug report
* @ link https :// wordpress . org / support / topic / change - tooltip - text /
* @ since 2.5 . 2
* @ datestamp 2021 - 01 - 19 T2223 + 0100
2021-01-19 23:45:34 +00:00
*/
2021-01-23 00:25:35 +00:00
public static $a_bool_MirrorTooltipText = false ;
2021-01-19 23:45:34 +00:00
public static $a_str_TooltipShortcode = '[[/tooltip]]' ;
public static $a_int_TooltipShortcodeLength = 12 ;
2021-01-01 05:52:49 +00:00
/**
* SYNTAX VALIDATION
*
* This part of 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 and cancellation of further parsing .
*
* 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.
*
2021-01-03 20:03:51 +00:00
* @ since 2.4 . 0
2021-01-01 05:52:49 +00:00
* @ var bool
*/
2021-01-23 00:25:35 +00:00
public static $a_bool_SyntaxErrorFlag = true ;
2021-01-01 05:52:49 +00:00
2020-12-31 11:45:10 +00:00
/**
* METHODS
*/
2020-10-27 11:56:49 +00:00
/**
* Register WordPress Hooks to replace Footnotes in the content of a public page .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
2020-11-12 18:17:28 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.0 . 5 Reference container : fix relative position through priority level , thanks to @ june01 @ imeson bug reports , thanks to @ spaceling code contribution
* @ edit 2.0 . 6 Priority level back to PHP_INT_MAX ( ref container positioning not this plugin’ s responsibility )
* @ edit 2.0 . 7 Set priority level back to 10 assuming it is unproblematic 2020 - 11 - 06 T1344 + 0100
* @ edit 2.0 . 8 Priority level back to PHP_INT_MAX ( need to get in touch with other plugins )
* @ edit 2.0 . 9 removed the_post hook after its default enabling caused multiple issues
* @ edit 2.1 . 1 Dashboard : priority level setting for the_content hook , thanks to @ imeson bug report
* @ edit 2.1 . 2 Dashboard : priority level settings for all other hooks , thanks to @ nikelaos bug report
2021-02-02 04:40:41 +00:00
* @ edit 2.5 . 0 Hooks : support footnotes on category pages , thanks to @ vitaefit bug report , thanks to @ misfist code contribution
* @ edit 2.5 . 1 Hooks : support footnotes in Popup Maker popups , thanks to @ squatcher bug report
2020-10-27 11:56:49 +00:00
*/
public function registerHooks () {
2020-11-20 05:40:03 +00:00
2021-01-26 17:01:53 +00:00
/**
* PRIORITY LEVELS
*
* Reference container : fix relative position through priority level , thanks to @ june01 @ imeson bug reports , thanks to @ spaceling code contribution
* @ since 2.0 . 5
* @ datestamp 2020 - 11 - 02 T0330 + 0100
*
* @ contributor @ spaceling
* @ source https :// wordpress . org / support / topic / change - the - position - 5 / #post-13608594
*
* @ reporter @ june01
* @ bugreport https :// wordpress . org / support / topic / change - the - position - 5 /
*
* @ reporter @ imeson
* @ bugreport https :// wordpress . org / support / topic / change - the - position - 5 / #post-13538345
*
* Dashboard : priority level setting for the_content hook , thanks to @ imeson bug report
* @ since 2.1 . 1
* @ datestamp 2020 - 11 - 17 T0254 + 0100
*
* @ reporter @ imeson
* @ bugreport https :// wordpress . org / support / topic / change - the - position - 5 / #post-13538345
*
* Dashboard : priority level settings for all other hooks , thanks to @ nikelaos bug report
* @ since 2.1 . 2
* @ datestamp 2020 - 11 - 19 T1849 + 0100
*
* @ reporter @ nikelaos
* @ bugreport https :// wordpress . org / support / topic / doesnt - work - any - more - 11 / #post-13676705
*
* @ link https :// codex . wordpress . org / Plugin_API / #Hook_in_your_Filter
*
2021-02-02 04:40:41 +00:00
* Setting the_content priority to 10 instead of PHP_INT_MAX i . e . 9223372036854775807
2021-01-26 17:01:53 +00:00
* makes the footnotes reference container display beneath the post and above other
* features added by other plugins , e . g . related post lists and social buttons .
*
* For YARPP to display related posts below the Footnotes reference container ,
* priority needs to be at least 1200.
*
* PHP_INT_MAX cannot be reset by leaving the number box empty . because browsers
* ( WebKit ) don’ t allow it , so we must resort to - 1.
*
*/
2020-11-20 05:40:03 +00:00
// get values from settings:
$p_int_TheTitlePriority = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL ));
$p_int_TheContentPriority = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL ));
$p_int_TheExcerptPriority = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL ));
$p_int_WidgetTitlePriority = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL ));
$p_int_WidgetTextPriority = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL ));
// PHP_INT_MAX can be set by -1:
$p_int_TheTitlePriority = ( $p_int_TheTitlePriority == - 1 ) ? PHP_INT_MAX : $p_int_TheTitlePriority ;
$p_int_TheContentPriority = ( $p_int_TheContentPriority == - 1 ) ? PHP_INT_MAX : $p_int_TheContentPriority ;
$p_int_TheExcerptPriority = ( $p_int_TheExcerptPriority == - 1 ) ? PHP_INT_MAX : $p_int_TheExcerptPriority ;
$p_int_WidgetTitlePriority = ( $p_int_WidgetTitlePriority == - 1 ) ? PHP_INT_MAX : $p_int_WidgetTitlePriority ;
$p_int_WidgetTextPriority = ( $p_int_WidgetTextPriority == - 1 ) ? PHP_INT_MAX : $p_int_WidgetTextPriority ;
2020-10-27 11:56:49 +00:00
// append custom css to the header
2020-11-06 14:20:33 +00:00
add_filter ( 'wp_head' , array ( $this , " wp_head " ), PHP_INT_MAX );
2016-06-29 12:54:05 +00:00
2020-10-27 11:56:49 +00:00
// append the love and share me slug to the footer
2020-11-06 14:20:33 +00:00
add_filter ( 'wp_footer' , array ( $this , " wp_footer " ), PHP_INT_MAX );
2016-06-29 12:54:05 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_EXPERT_LOOKUP_THE_TITLE ))) {
2020-11-20 05:40:03 +00:00
add_filter ( 'the_title' , array ( $this , " the_title " ), $p_int_TheTitlePriority );
}
2021-01-26 17:01:53 +00:00
// configurable priority level for reference container relative positioning; default 98:
2016-06-29 12:54:05 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_EXPERT_LOOKUP_THE_CONTENT ))) {
2021-01-18 20:35:16 +00:00
add_filter ( 'the_content' , array ( $this , " the_content " ), $p_int_TheContentPriority );
2021-01-26 17:01:53 +00:00
/**
* HOOK FOR CATEGORY PAGES
*
* Hooks : support footnotes on category pages , thanks to @ vitaefit bug report , thanks to @ misfist code contribution
* @ since 2.5 . 0
2021-02-02 04:40:41 +00:00
* @ datestamp 2021 - 01 - 05 T1402 + 0100
2021-01-26 17:01:53 +00:00
*
* @ reporter @ vitaefit
* @ bugreport https :// wordpress . org / support / topic / footnote - doesntwork - on - category - page /
*
* @ contributor @ misfist
* @ source https :// wordpress . org / support / topic / footnote - doesntwork - on - category - page / #post-13864859
*
* Category pages can have rich HTML content in a term description with article status .
* For this to happen , WordPress’ built - in partial HTML blocker needs to be disabled .
* @ link https :// docs . woocommerce . com / document / allow - html - in - term - category - tag - descriptions /
*/
2021-01-18 20:35:16 +00:00
add_filter ( 'term_description' , array ( $this , " the_content " ), $p_int_TheContentPriority );
2021-01-26 17:01:53 +00:00
/**
* HOOK FOR POPUP MAKER POPUPS
*
* Hooks : support footnotes in Popup Maker popups , thanks to @ squatcher bug report
* @ since 2.5 . 1
* @ datestamp 2021 - 01 - 18 T2038 + 0100
*
* @ reporter @ squatcher
* @ bugreport https :// wordpress . org / support / topic / footnotes - use - in - popup - maker /
*/
2021-01-18 20:09:43 +00:00
add_filter ( 'pum_popup_content' , array ( $this , " the_content " ), $p_int_TheContentPriority );
2020-11-19 20:34:45 +00:00
}
2020-11-20 05:40:03 +00:00
2016-06-29 12:54:05 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_EXPERT_LOOKUP_THE_EXCERPT ))) {
2020-11-20 05:40:03 +00:00
add_filter ( 'the_excerpt' , array ( $this , " the_excerpt " ), $p_int_TheExcerptPriority );
2016-06-29 12:54:05 +00:00
}
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_EXPERT_LOOKUP_WIDGET_TITLE ))) {
2020-11-20 05:40:03 +00:00
add_filter ( 'widget_title' , array ( $this , " widget_title " ), $p_int_WidgetTitlePriority );
2016-06-29 12:54:05 +00:00
}
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_EXPERT_LOOKUP_WIDGET_TEXT ))) {
2020-11-20 05:40:03 +00:00
add_filter ( 'widget_text' , array ( $this , " widget_text " ), $p_int_WidgetTextPriority );
2020-11-19 20:34:45 +00:00
}
2020-11-20 05:40:03 +00:00
2021-01-26 17:01:53 +00:00
/**
* THE the_post HOOK
*
* support the_post hook in response to user request for custom post types
* @ since 1.5 . 4
* @ accountable @ aricura
* @ link https :// wordpress . org / support / topic / doesnt - work - in - custon - post - types / #post-5339110
*
* remove the_post hook after its default enabling caused multiple issues
* @ edit 2.0 . 9
* @ accountable @ pewgeuges
* @ datestamp 2020 - 11 - 08 T1839 + 0100
* @ link https :// wordpress . org / support / topic / change - the - position - 5 / page / 2 / #post-13630114
* @ link https :// wordpress . org / support / topic / footnotes - appearing - in - header / #post-13630303
* @ link https :// wordpress . org / support / topic / footnotes - appearing - in - header / page / 2 / #post-13630799
* @ link https :// wordpress . org / support / topic / no - footnotes - anymore / #post-13813233
*/
2020-11-20 05:40:03 +00:00
2016-06-29 12:54:05 +00:00
// reset stored footnotes when displaying the header
self :: $a_arr_Footnotes = array ();
self :: $a_bool_AllowLoveMe = true ;
2020-10-27 11:56:49 +00:00
}
2016-06-29 12:54:05 +00:00
2020-10-27 11:56:49 +00:00
/**
* Outputs the custom css to the header of the public page .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
2020-12-18 16:31:09 +00:00
*
2021-01-23 00:25:35 +00:00
* @ edited
*
* @ since 2.1 . 1 Reference container : fix start pages by making its display optional , thanks to @ dragon013 bug report
2020-12-23 10:12:06 +00:00
* @ since 2.1 . 1 option to hide ref container from start page
* @ since 2.1 . 1 script for alternative tooltips
* @ since 2.1 . 3 raise settings priority to override theme style sheets
* @ since 2.1 . 4 tootip font size and backlink column width settings
* @ since 2.2 . 5 options for label element and label bottom border , thanks to @ markhillyer 2020 - 12 - 18 T1447 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / how - do - i - eliminate - the - horizontal - line - beneath - the - reference - container - heading /
2020-12-31 11:45:10 +00:00
* @ since 2.3 . 0 Reference container : convert top padding to margin and make it a setting , thanks to @ hamshe
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / reference - container - in - elementor / #post-13786635
2020-10-27 11:56:49 +00:00
*/
public function wp_head () {
2020-12-03 07:55:27 +00:00
2020-12-25 15:14:43 +00:00
// insert start tag without switching out of PHP:
2020-12-18 16:31:09 +00:00
echo " \r \n <style type= \" text/css \" media= \" all \" > \r \n " ;
2021-01-23 00:25:35 +00:00
/**
* REF CONTAINER DISPLAY ON HOME PAGE
*
* Reference container : fix start pages by making its display optional
* @ thanksto @ dragon013 bug report
* @ link https :// wordpress . org / support / topic / possible - to - hide - it - from - start - page /
* @ since 2.1 . 1
*/
2020-12-18 16:31:09 +00:00
if ( ! MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_REFERENCE_CONTAINER_START_PAGE_ENABLE ))) {
echo " .home .footnotes_reference_container { display: none; } \r \n " ;
2020-12-19 06:18:56 +00:00
}
2020-12-31 11:45:10 +00:00
// ref container top and bottom margins:
$l_int_ReferenceContainerTopMargin = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_REFERENCE_CONTAINER_TOP_MARGIN ));
$l_int_ReferenceContainerBottomMargin = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_REFERENCE_CONTAINER_BOTTOM_MARGIN ));
echo " .footnotes_reference_container { margin-top: " ;
echo empty ( $l_int_ReferenceContainerTopMargin ) ? '0' : $l_int_ReferenceContainerTopMargin ;
echo " px !important; margin-bottom: " ;
echo empty ( $l_int_ReferenceContainerBottomMargin ) ? '0' : $l_int_ReferenceContainerBottomMargin ;
echo " px !important;} \r \n " ;
2020-12-19 06:18:56 +00:00
// ref container label bottom border:
2020-12-18 16:31:09 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER ))) {
echo " .footnote_container_prepare > " ;
2020-12-19 06:18:56 +00:00
echo MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT );
2020-12-18 16:31:09 +00:00
echo " { border-bottom: 1px solid #aaaaaa !important;} \r \n " ;
2020-12-19 06:18:56 +00:00
}
2020-12-18 16:31:09 +00:00
2021-01-03 20:03:51 +00:00
// ref container table row borders:
2020-12-25 23:00:23 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_REFERENCE_CONTAINER_ROW_BORDERS_ENABLE ))) {
echo " .footnotes_table, .footnotes_plugin_reference_row { " ;
echo " border: 1px solid #060606; " ;
echo " !important;} \r \n " ;
2021-01-03 20:03:51 +00:00
// adapt left padding to the presence of a border:
echo " .footnote_plugin_index, .footnote_plugin_index_combi { " ;
echo " padding-left: 6px !important} \r \n " ;
2020-12-25 23:00:23 +00:00
}
2020-12-18 16:31:09 +00:00
// ref container first column width and max-width:
$l_bool_ColumnWidthEnabled = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_BACKLINKS_COLUMN_WIDTH_ENABLED ));
$l_bool_ColumnMaxWidthEnabled = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_BACKLINKS_COLUMN_MAX_WIDTH_ENABLED ));
2020-12-03 07:55:27 +00:00
2020-12-18 16:31:09 +00:00
if ( $l_bool_ColumnWidthEnabled || $l_bool_ColumnMaxWidthEnabled ) {
echo " .footnote-reference-container { table-layout: fixed; } " ;
echo " .footnote_plugin_index, .footnote_plugin_index_combi { " ;
2020-12-03 07:55:27 +00:00
2020-12-18 16:31:09 +00:00
if ( $l_bool_ColumnWidthEnabled ) {
2020-12-03 07:55:27 +00:00
2020-12-18 16:31:09 +00:00
$l_int_ColumnWidthScalar = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_BACKLINKS_COLUMN_WIDTH_SCALAR );
$l_str_ColumnWidthUnit = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_BACKLINKS_COLUMN_WIDTH_UNIT );
2020-12-03 07:55:27 +00:00
2020-12-18 16:31:09 +00:00
if ( ! empty ( $l_int_ColumnWidthScalar )) {
if ( $l_str_ColumnWidthUnit == '%' ) {
if ( $l_int_ColumnWidthScalar > 100 ) {
$l_int_ColumnWidthScalar = 100 ;
}
}
} else {
$l_int_ColumnWidthScalar = 0 ;
}
2020-12-03 07:55:27 +00:00
2020-12-18 16:31:09 +00:00
echo " width: $l_int_ColumnWidthScalar $l_str_ColumnWidthUnit !important; " ;
}
2020-12-03 07:55:27 +00:00
2020-12-18 16:31:09 +00:00
if ( $l_bool_ColumnMaxWidthEnabled ) {
2020-12-03 17:38:14 +00:00
2020-12-18 16:31:09 +00:00
$l_int_ColumnMaxWidthScalar = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_BACKLINKS_COLUMN_MAX_WIDTH_SCALAR );
$l_str_ColumnMaxWidthUnit = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_BACKLINKS_COLUMN_MAX_WIDTH_UNIT );
2020-12-03 07:55:27 +00:00
2020-12-18 16:31:09 +00:00
if ( ! empty ( $l_int_ColumnMaxWidthScalar )) {
if ( $l_str_ColumnMaxWidthUnit == '%' ) {
if ( $l_int_ColumnMaxWidthScalar > 100 ) {
$l_int_ColumnMaxWidthScalar = 100 ;
}
}
} else {
$l_int_ColumnMaxWidthScalar = 0 ;
2020-12-03 07:55:27 +00:00
}
2020-12-18 16:31:09 +00:00
echo " max-width: $l_int_ColumnMaxWidthScalar $l_str_ColumnMaxWidthUnit !important; " ;
2020-11-16 20:57:15 +00:00
2020-12-03 07:55:27 +00:00
}
2020-12-18 16:31:09 +00:00
echo " } \r \n " ;
}
2020-12-03 07:55:27 +00:00
2020-12-31 11:45:10 +00:00
// hard links scroll offset:
2021-01-23 00:25:35 +00:00
self :: $a_bool_HardLinksEnable = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_FOOTNOTES_HARD_LINKS_ENABLE ));
self :: $a_int_ScrollOffset = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_SCROLL_OFFSET ));
if ( self :: $a_bool_HardLinksEnable ) {
2020-12-31 11:45:10 +00:00
echo " .footnote_referrer_anchor, .footnote_item_anchor { bottom: " ;
2021-01-23 00:25:35 +00:00
echo self :: $a_int_ScrollOffset ;
2020-12-31 11:45:10 +00:00
echo " vh;} \r \n " ;
}
2020-12-18 16:31:09 +00:00
// tooltips:
2021-01-23 00:25:35 +00:00
self :: $a_bool_TooltipsEnabled = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED ));
self :: $a_bool_AlternativeTooltipsEnabled = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE ));
2020-12-03 07:55:27 +00:00
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_TooltipsEnabled ) {
2020-11-16 20:57:15 +00:00
2020-11-11 20:49:44 +00:00
echo '.footnote_tooltip {' ;
2020-12-03 07:55:27 +00:00
2020-12-18 16:31:09 +00:00
// tooltip appearance:
// font size:
2020-12-03 07:55:27 +00:00
echo ' font-size: ' ;
2020-12-18 16:31:09 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_MOUSE_OVER_BOX_FONT_SIZE_ENABLED ))) {
echo MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_FLO_MOUSE_OVER_BOX_FONT_SIZE_SCALAR );
echo MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_MOUSE_OVER_BOX_FONT_SIZE_UNIT );
2020-12-03 07:55:27 +00:00
} else {
echo 'inherit' ;
}
echo ' !important;' ;
2020-12-18 16:31:09 +00:00
// text color:
$l_str_Color = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_MOUSE_OVER_BOX_COLOR );
2016-06-29 12:54:05 +00:00
if ( ! empty ( $l_str_Color )) {
2020-11-24 09:22:27 +00:00
printf ( " color: %s !important; " , $l_str_Color );
2016-06-29 12:54:05 +00:00
}
2020-12-18 16:31:09 +00:00
// background color:
$l_str_Background = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND );
2016-06-29 12:54:05 +00:00
if ( ! empty ( $l_str_Background )) {
2020-11-24 09:22:27 +00:00
printf ( " background-color: %s !important; " , $l_str_Background );
2016-06-29 12:54:05 +00:00
}
2020-12-18 16:31:09 +00:00
// border width:
$l_int_BorderWidth = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH );
2016-06-29 12:54:05 +00:00
if ( ! empty ( $l_int_BorderWidth ) && intval ( $l_int_BorderWidth ) > 0 ) {
2020-11-24 09:22:27 +00:00
printf ( " border-width: %dpx !important; border-style: solid !important; " , $l_int_BorderWidth );
2016-06-29 12:54:05 +00:00
}
2020-12-18 16:31:09 +00:00
// border color:
$l_str_BorderColor = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR );
2016-06-29 12:54:05 +00:00
if ( ! empty ( $l_str_BorderColor )) {
2020-11-24 09:22:27 +00:00
printf ( " border-color: %s !important; " , $l_str_BorderColor );
2016-06-29 12:54:05 +00:00
}
2020-12-18 16:31:09 +00:00
// corner radius:
$l_int_BorderRadius = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS );
2016-06-29 12:54:05 +00:00
if ( ! empty ( $l_int_BorderRadius ) && intval ( $l_int_BorderRadius ) > 0 ) {
2020-11-24 09:22:27 +00:00
printf ( " border-radius: %dpx !important; " , $l_int_BorderRadius );
2016-06-29 12:54:05 +00:00
}
2020-12-18 16:31:09 +00:00
// shadow color:
$l_str_BoxShadowColor = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR );
2016-06-29 12:54:05 +00:00
if ( ! empty ( $l_str_BoxShadowColor )) {
printf ( " -webkit-box-shadow: 2px 2px 11px %s; " , $l_str_BoxShadowColor );
printf ( " -moz-box-shadow: 2px 2px 11px %s; " , $l_str_BoxShadowColor );
printf ( " box-shadow: 2px 2px 11px %s; " , $l_str_BoxShadowColor );
}
2020-12-18 16:31:09 +00:00
// alternative tooltips:
2021-01-23 00:25:35 +00:00
if ( ! self :: $a_bool_AlternativeTooltipsEnabled ) {
2020-12-18 16:31:09 +00:00
// tooltip position:
$l_int_MaxWidth = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH );
if ( ! empty ( $l_int_MaxWidth ) && intval ( $l_int_MaxWidth ) > 0 ) {
printf ( " max-width: %dpx !important; " , $l_int_MaxWidth );
}
echo " } \r \n " ;
} else {
echo " } \r \n " ;
// position:
echo " .footnote_tooltip.position { " ;
echo " width: " . intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH )) . 'px;' ;
$l_str_AlternativePosition = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION );
$l_int_OffsetX = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X ));
if ( $l_str_AlternativePosition == 'top left' || $l_str_AlternativePosition == 'bottom left' ) {
echo ' right: ' . ( ! empty ( $l_int_OffsetX ) ? $l_int_OffsetX : 0 ) . 'px;' ;
} else {
echo ' left: ' . ( ! empty ( $l_int_OffsetX ) ? $l_int_OffsetX : 0 ) . 'px;' ;
}
$l_int_OffsetY = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y ));
if ( $l_str_AlternativePosition == 'top left' || $l_str_AlternativePosition == 'top right' ) {
echo ' bottom: ' . ( ! empty ( $l_int_OffsetY ) ? $l_int_OffsetY : 0 ) . 'px;' ;
} else {
echo ' top: ' . ( ! empty ( $l_int_OffsetY ) ? $l_int_OffsetY : 0 ) . 'px;' ;
}
echo " } \r \n " ;
// timing:
// jQuery tooltip timing is in templates/public/tooltip.html, filled in after line 690 below.
echo ' .footnote_tooltip.shown {' ;
$l_int_FadeInDelay = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY ));
$l_int_FadeInDuration = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION ));
$l_int_FadeInDelay = ! empty ( $l_int_FadeInDelay ) ? $l_int_FadeInDelay : '0' ;
$l_int_FadeInDuration = ! empty ( $l_int_FadeInDuration ) ? $l_int_FadeInDuration : '0' ;
echo " transition-delay: $l_int_FadeInDelay " . 'ms;' ;
echo " transition-duration: $l_int_FadeInDuration " . 'ms;' ;
echo '} .footnote_tooltip.hidden {' ;
$l_int_FadeOutDelay = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY ));
$l_int_FadeOutDuration = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION ));
$l_int_FadeOutDelay = ! empty ( $l_int_FadeOutDelay ) ? $l_int_FadeOutDelay : '0' ;
$l_int_FadeOutDuration = ! empty ( $l_int_FadeOutDuration ) ? $l_int_FadeOutDuration : '0' ;
echo " transition-delay: $l_int_FadeOutDelay " . 'ms;' ;
echo " transition-duration: $l_int_FadeOutDuration " . 'ms;' ;
echo " } \r \n " ;
2020-12-16 12:06:11 +00:00
}
2020-12-18 16:31:09 +00:00
}
// set custom CSS to override settings, not conversely:
2020-12-31 11:45:10 +00:00
// Legacy Custom CSS is used until it’ s set to disappear after dashboard tab migration:
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_CUSTOM_CSS_LEGACY_ENABLE ))) {
2020-12-18 16:31:09 +00:00
echo MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_CUSTOM_CSS );
}
echo MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_CUSTOM_CSS_NEW );
2020-12-25 15:14:43 +00:00
// insert end tag without switching out of PHP:
2020-12-18 16:31:09 +00:00
echo " \r \n </style> \r \n " ;
// alternative tooltip script printed formatted not minified:
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_AlternativeTooltipsEnabled ) {
2020-12-18 16:31:09 +00:00
?>
< script content = " text/javascript " >
function footnoteTooltipShow ( footnoteTooltipId ) {
document . getElementById ( footnoteTooltipId ) . classList . remove ( 'hidden' );
document . getElementById ( footnoteTooltipId ) . classList . add ( 'shown' );
}
function footnoteTooltipHide ( footnoteTooltipId ) {
document . getElementById ( footnoteTooltipId ) . classList . remove ( 'shown' );
document . getElementById ( footnoteTooltipId ) . classList . add ( 'hidden' );
}
</ script >
< ? php
2020-11-11 20:49:44 +00:00
};
2020-10-27 11:56:49 +00:00
}
2016-06-29 12:54:05 +00:00
2020-10-27 11:56:49 +00:00
/**
* Displays the 'LOVE FOOTNOTES' slug if enabled .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
2020-12-13 20:11:25 +00:00
*
2020-12-12 21:07:24 +00:00
* Edited :
* @ since 2.2 . 0 more options 2020 - 12 - 11 T0506 + 0100
2020-10-27 11:56:49 +00:00
*/
public function wp_footer () {
2016-06-29 12:54:05 +00:00
if ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_REFERENCE_CONTAINER_POSITION ) == " footer " ) {
echo $this -> ReferenceContainer ();
}
2020-10-27 11:56:49 +00:00
// get setting for love and share this plugin
$l_str_LoveMeIndex = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_LOVE );
// check if the admin allows to add a link to the footer
if ( empty ( $l_str_LoveMeIndex ) || strtolower ( $l_str_LoveMeIndex ) == " no " || ! self :: $a_bool_AllowLoveMe ) {
return ;
}
// set a hyperlink to the word "footnotes" in the Love slug
2020-12-12 21:07:24 +00:00
$l_str_LinkedName = sprintf ( '<a href="https://wordpress.org/plugins/footnotes/" target="_blank" style="text-decoration:none;">%s</a>' , MCI_Footnotes_Config :: C_STR_PLUGIN_PUBLIC_NAME );
2020-10-27 11:56:49 +00:00
// get random love me text
if ( strtolower ( $l_str_LoveMeIndex ) == " random " ) {
2020-12-12 21:07:24 +00:00
$l_str_LoveMeIndex = " text- " . rand ( 1 , 7 );
2020-10-27 11:56:49 +00:00
}
switch ( $l_str_LoveMeIndex ) {
2020-12-12 21:07:24 +00:00
// options named wrt backcompat, simplest is default:
case " text-1 " : $l_str_LoveMeText = sprintf ( __ ( 'I %2$s %1$s' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ), $l_str_LinkedName , MCI_Footnotes_Config :: C_STR_LOVE_SYMBOL ); break ;
case " text-2 " : $l_str_LoveMeText = sprintf ( __ ( 'This website uses the awesome %s plugin.' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ), $l_str_LinkedName ); break ;
case " text-4 " : $l_str_LoveMeText = sprintf ( '%s %s' , $l_str_LinkedName , MCI_Footnotes_Config :: C_STR_LOVE_SYMBOL ); break ;
case " text-5 " : $l_str_LoveMeText = sprintf ( '%s %s' , MCI_Footnotes_Config :: C_STR_LOVE_SYMBOL , $l_str_LinkedName ); break ;
case " text-6 " : $l_str_LoveMeText = sprintf ( __ ( 'This website uses %s.' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ), $l_str_LinkedName ); break ;
case " text-7 " : $l_str_LoveMeText = sprintf ( __ ( 'This website uses the %s plugin.' , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ), $l_str_LinkedName ); break ;
case " text-3 " : default : $l_str_LoveMeText = sprintf ( '%s' , $l_str_LinkedName ); break ;
2020-10-27 11:56:49 +00:00
}
echo sprintf ( '<div style="text-align:center; color:#acacac;">%s</div>' , $l_str_LoveMeText );
}
2016-06-29 12:54:05 +00:00
/**
* Replaces footnotes in the post / page title .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ param string $p_str_Content Widget content .
* @ return string Content with replaced footnotes .
*/
public function the_title ( $p_str_Content ) {
// appends the reference container if set to "post_end"
return $this -> exec ( $p_str_Content , false );
}
2020-10-27 11:56:49 +00:00
/**
* Replaces footnotes in the content of the current page / post .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ param string $p_str_Content Page / Post content .
* @ return string Content with replaced footnotes .
*/
public function the_content ( $p_str_Content ) {
// appends the reference container if set to "post_end"
return $this -> exec ( $p_str_Content , MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_REFERENCE_CONTAINER_POSITION ) == " post_end " ? true : false );
}
2016-06-29 12:54:05 +00:00
2020-10-27 11:56:49 +00:00
/**
* Replaces footnotes in the excerpt of the current page / post .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ param string $p_str_Content Page / Post content .
* @ return string Content with replaced footnotes .
*/
public function the_excerpt ( $p_str_Content ) {
return $this -> exec ( $p_str_Content , false , ! MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_FOOTNOTES_IN_EXCERPT )));
}
2016-06-29 12:54:05 +00:00
/**
* Replaces footnotes in the widget title .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ param string $p_str_Content Widget content .
* @ return string Content with replaced footnotes .
*/
public function widget_title ( $p_str_Content ) {
// appends the reference container if set to "post_end"
return $this -> exec ( $p_str_Content , false );
}
2020-10-27 11:56:49 +00:00
/**
* Replaces footnotes in the content of the current widget .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ param string $p_str_Content Widget content .
* @ return string Content with replaced footnotes .
*/
public function widget_text ( $p_str_Content ) {
// appends the reference container if set to "post_end"
return $this -> exec ( $p_str_Content , MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_REFERENCE_CONTAINER_POSITION ) == " post_end " ? true : false );
}
2016-06-29 12:54:05 +00:00
/**
* Replaces footnotes in each Content var of the current Post object .
*
* @ author Stefan Herndler
* @ since 1.5 . 4
* @ param array | WP_Post $p_mixed_Posts
*/
2020-11-09 19:09:54 +00:00
public function the_post ( & $p_mixed_Posts ) {
// single WP_Post object received
if ( ! is_array ( $p_mixed_Posts )) {
$p_mixed_Posts = $this -> replacePostObject ( $p_mixed_Posts );
return ;
}
// array of WP_Post objects received
for ( $l_int_Index = 0 ; $l_int_Index < count ( $p_mixed_Posts ); $l_int_Index ++ ) {
$p_mixed_Posts [ $l_int_Index ] = $this -> replacePostObject ( $p_mixed_Posts [ $l_int_Index ]);
}
}
2016-06-29 12:54:05 +00:00
/**
* Replace all Footnotes in a WP_Post object .
*
* @ author Stefan Herndler
* @ since 1.5 . 6
* @ param WP_Post $p_obj_Post
* @ return WP_Post
*/
private function replacePostObject ( $p_obj_Post ) {
//MCI_Footnotes_Convert::debug($p_obj_Post);
$p_obj_Post -> post_content = $this -> exec ( $p_obj_Post -> post_content );
$p_obj_Post -> post_content_filtered = $this -> exec ( $p_obj_Post -> post_content_filtered );
$p_obj_Post -> post_excerpt = $this -> exec ( $p_obj_Post -> post_excerpt );
return $p_obj_Post ;
}
2020-10-27 11:56:49 +00:00
/**
* Replaces all footnotes that occur in the given content .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ param string $p_str_Content Any string that may contain footnotes to be replaced .
* @ param bool $p_bool_OutputReferences Appends the Reference Container to the output if set to true , default true .
* @ param bool $p_bool_HideFootnotesText Hide footnotes found in the string .
* @ return string
2020-12-18 16:31:09 +00:00
*
* Edited :
* @ since 2.2 . 0 insert reference container at shortcode , thanks to @ hamshe 2020 - 12 - 13 T2057 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / reference - container - in - elementor /
2020-12-19 06:18:56 +00:00
*
2020-12-18 16:31:09 +00:00
* @ since 2.2 . 5 delete unused position shortcode , when position is widget or footer , thanks to @ hamshe 2020 - 12 - 18 T1434 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / reference - container - in - elementor / #post-13784126
2020-10-27 11:56:49 +00:00
*/
public function exec ( $p_str_Content , $p_bool_OutputReferences = false , $p_bool_HideFootnotesText = false ) {
2020-12-25 15:14:43 +00:00
2020-10-27 11:56:49 +00:00
// replace all footnotes in the content, settings are converted to html characters
$p_str_Content = $this -> search ( $p_str_Content , true , $p_bool_HideFootnotesText );
// replace all footnotes in the content, settings are NOT converted to html characters
$p_str_Content = $this -> search ( $p_str_Content , false , $p_bool_HideFootnotesText );
2020-12-25 15:14:43 +00:00
// append the reference container or insert at shortcode:
2020-12-13 20:11:25 +00:00
$l_str_ReferenceContainerPositionShortcode = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_REFERENCE_CONTAINER_POSITION_SHORTCODE );
2021-01-19 23:45:34 +00:00
if ( empty ( $l_str_ReferenceContainerPositionShortcode ) ) {
$l_str_ReferenceContainerPositionShortcode = '[[references]]' ;
}
2020-12-13 20:11:25 +00:00
2021-01-19 23:45:34 +00:00
if ( $p_bool_OutputReferences ) {
2020-12-18 16:31:09 +00:00
2021-01-19 23:45:34 +00:00
if ( strpos ( $p_str_Content , $l_str_ReferenceContainerPositionShortcode ) !== false ) {
2020-12-13 20:11:25 +00:00
$p_str_Content = str_replace ( $l_str_ReferenceContainerPositionShortcode , $this -> ReferenceContainer (), $p_str_Content );
} else {
$p_str_Content .= $this -> ReferenceContainer ();
}
2020-12-25 15:14:43 +00:00
// increment the container ID:
2021-01-23 00:25:35 +00:00
self :: $a_int_ReferenceContainerId ++ ;
2020-10-27 11:56:49 +00:00
}
2016-06-29 12:54:05 +00:00
2020-12-18 16:31:09 +00:00
// delete position shortcode should any remain e.g. when ref container is in footer, thanks to @hamshe:
$p_str_Content = str_replace ( $l_str_ReferenceContainerPositionShortcode , '' , $p_str_Content );
2020-10-27 11:56:49 +00:00
// take a look if the LOVE ME slug should NOT be displayed on this page/post, remove the short code if found
if ( strpos ( $p_str_Content , MCI_Footnotes_Config :: C_STR_NO_LOVE_SLUG ) !== false ) {
self :: $a_bool_AllowLoveMe = false ;
$p_str_Content = str_replace ( MCI_Footnotes_Config :: C_STR_NO_LOVE_SLUG , " " , $p_str_Content );
}
2020-12-25 15:14:43 +00:00
// return the content with replaced footnotes and optional reference container appended:
2020-10-27 11:56:49 +00:00
return $p_str_Content ;
}
2016-06-29 12:54:05 +00:00
2020-10-27 11:56:49 +00:00
/**
* Replaces all footnotes in the given content and appends them to the static property .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ param string $p_str_Content Content to be searched for footnotes .
* @ param bool $p_bool_ConvertHtmlChars html encode settings , default true .
* @ param bool $p_bool_HideFootnotesText Hide footnotes found in the string .
* @ return string
2020-12-25 23:00:23 +00:00
*
2020-12-25 15:14:43 +00:00
* Edited since 2.0 . 0
2021-01-04 15:51:57 +00:00
*
2021-01-03 20:03:51 +00:00
* @ since 2.4 . 0 footnote shortcode syntax validation
2021-01-07 21:21:29 +00:00
* @ since 2.5 . 0 Shortcode syntax validation : exclude certain cases involving scripts , thanks to @ andreasra 2021 - 01 - 07 T0824 + 0100
* @ since 2.5 . 0 Shortcode syntax validation : complete message with hint about setting , thanks to @ andreasra
* @ since 2.5 . 0 Shortcode syntax validation : limit length of quoted string to 300 characters , thanks to @ andreasra
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / warning - unbalanced - footnote - start - tag - short - code - before /
2020-10-27 11:56:49 +00:00
*/
public function search ( $p_str_Content , $p_bool_ConvertHtmlChars , $p_bool_HideFootnotesText ) {
2020-11-14 21:40:09 +00:00
2020-11-13 16:54:31 +00:00
// post ID to make everything unique wrt infinite scroll and archive view
2021-01-23 00:25:35 +00:00
self :: $a_int_PostId = get_the_id ();
2020-11-14 21:40:09 +00:00
2020-10-27 11:56:49 +00:00
// contains the index for the next footnote on this page
2020-11-14 21:40:09 +00:00
$l_int_FootnoteIndex = count ( self :: $a_arr_Footnotes ) + 1 ;
2021-01-14 22:56:43 +00:00
2020-10-27 11:56:49 +00:00
// contains the starting position for the lookup of a footnote
2020-11-14 21:40:09 +00:00
$l_int_PosStart = 0 ;
2020-10-27 11:56:49 +00:00
// get start and end tag for the footnotes short code
$l_str_StartingTag = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_SHORT_CODE_START );
$l_str_EndingTag = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_SHORT_CODE_END );
if ( $l_str_StartingTag == " userdefined " || $l_str_EndingTag == " userdefined " ) {
$l_str_StartingTag = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED );
$l_str_EndingTag = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED );
}
// decode html special chars
if ( $p_bool_ConvertHtmlChars ) {
$l_str_StartingTag = htmlspecialchars ( $l_str_StartingTag );
$l_str_EndingTag = htmlspecialchars ( $l_str_EndingTag );
}
2021-01-01 05:52:49 +00:00
2020-10-27 11:56:49 +00:00
// if footnotes short code is empty, return the content without changes
if ( empty ( $l_str_StartingTag ) || empty ( $l_str_EndingTag )) {
return $p_str_Content ;
}
2016-06-29 12:54:05 +00:00
2021-01-01 05:52:49 +00:00
// if footnotes short codes are unbalanced, and syntax validation is not disabled,
// return content with prepended warning:
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE ))) {
2021-01-07 21:21:29 +00:00
// convert the shortcodes to regex syntax conformant:
2021-01-01 05:52:49 +00:00
$l_str_StartTagRegex = preg_replace ( '#([\(\)\{\}\[\]\*\.\?\!])#' , '\\\\$1' , $l_str_StartingTag );
$l_str_EndTagRegex = preg_replace ( '#([\(\)\{\}\[\]\*\.\?\!])#' , '\\\\$1' , $l_str_EndingTag );
2021-01-07 21:21:29 +00:00
// apply different regex depending on whether start shortcode is double/triple opening parenthesis:
if ( $l_str_StartingTag == '((' || $l_str_StartingTag == '(((' ) {
// this prevents from catching a script containing e.g. a double opening parenthesis:
$l_str_ValidationRegex = '#' . $l_str_StartTagRegex . '(((?!' . $l_str_EndTagRegex . ')[^\{\}])*?)(' . $l_str_StartTagRegex . '|$)#s' ;
} else {
// catch all only if the start shortcode is not double/triple opening parenthesis, i.e. is unlikely to occur in scripts:
$l_str_ValidationRegex = '#' . $l_str_StartTagRegex . '(((?!' . $l_str_EndTagRegex . ').)*?)(' . $l_str_StartTagRegex . '|$)#s' ;
}
// check syntax and get error locations:
2021-01-01 05:52:49 +00:00
preg_match ( $l_str_ValidationRegex , $p_str_Content , $p_arr_ErrorLocation );
if ( empty ( $p_arr_ErrorLocation ) ) {
2021-01-23 00:25:35 +00:00
self :: $a_bool_SyntaxErrorFlag = false ;
2021-01-01 05:52:49 +00:00
}
// prevent generating and inserting the warning multiple times:
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_SyntaxErrorFlag ) {
2021-01-01 05:52:49 +00:00
2021-01-07 21:21:29 +00:00
// get plain text string for error location:
$l_str_ErrorSpotString = strip_tags ( $p_arr_ErrorLocation [ 1 ] );
// limit string length to 300 characters:
if ( strlen ( $l_str_ErrorSpotString ) > 300 ) {
$l_str_ErrorSpotString = substr ( $l_str_ErrorSpotString , 0 , 299 ) . '…' ;
}
// compose warning box:
2021-01-01 05:52:49 +00:00
$l_str_SyntaxErrorWarning = '<div class="footnotes_validation_error"><p>' ;
2021-01-07 21:21:29 +00:00
$l_str_SyntaxErrorWarning .= __ ( " WARNING: unbalanced footnote start tag short code found. " , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME );
$l_str_SyntaxErrorWarning .= '</p><p>' ;
// syntax validation setting in the dashboard under the General settings tab:
$l_str_SyntaxErrorWarning .= sprintf ( __ ( " If this warning is irrelevant, please disable the syntax validation feature in the dashboard under %s > %s > %s. " , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ), __ ( " General settings " , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ), __ ( " Footnote start and end short codes " , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ), __ ( " Check for balanced shortcodes " , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME ) );
$l_str_SyntaxErrorWarning .= '</p><p>' ;
$l_str_SyntaxErrorWarning .= __ ( " Unbalanced start tag short code found before: " , MCI_Footnotes_Config :: C_STR_PLUGIN_NAME );
2021-01-01 05:52:49 +00:00
$l_str_SyntaxErrorWarning .= '</p><p>“' ;
$l_str_SyntaxErrorWarning .= $l_str_ErrorSpotString ;
$l_str_SyntaxErrorWarning .= '”</p></div>' ;
2021-01-07 21:21:29 +00:00
// prepend the warning box to the content:
2021-01-01 05:52:49 +00:00
$p_str_Content = $l_str_SyntaxErrorWarning . $p_str_Content ;
2021-01-07 21:21:29 +00:00
// checked, set flag to false to prevent duplicate warning:
2021-01-23 00:25:35 +00:00
self :: $a_bool_SyntaxErrorFlag = false ;
2021-01-01 05:52:49 +00:00
return $p_str_Content ;
}
}
// load referrer templates if footnotes text not hidden:
2020-10-27 11:56:49 +00:00
if ( ! $p_bool_HideFootnotesText ) {
2021-01-04 15:51:57 +00:00
// load footnote referrer template file:
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_AlternativeTooltipsEnabled ) {
2020-11-11 20:49:44 +00:00
$l_obj_Template = new MCI_Footnotes_Template ( MCI_Footnotes_Template :: C_STR_PUBLIC , " footnote-alternative " );
} else {
$l_obj_Template = new MCI_Footnotes_Template ( MCI_Footnotes_Template :: C_STR_PUBLIC , " footnote " );
}
2021-01-04 15:51:57 +00:00
2021-01-26 17:01:53 +00:00
// call again for robustness when priority levels don’ t match any longer:
self :: $a_bool_TooltipsEnabled = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED ));
self :: $a_bool_AlternativeTooltipsEnabled = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE ));
2021-01-04 15:51:57 +00:00
// load tooltip inline script if jQuery tooltips are enabled:
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_TooltipsEnabled && ! self :: $a_bool_AlternativeTooltipsEnabled ) {
2021-01-04 15:51:57 +00:00
$l_obj_TemplateTooltip = new MCI_Footnotes_Template ( MCI_Footnotes_Template :: C_STR_PUBLIC , " tooltip " );
}
2020-10-27 11:56:49 +00:00
} else {
$l_obj_Template = null ;
$l_obj_TemplateTooltip = null ;
}
2016-06-29 12:54:05 +00:00
2020-10-27 11:56:49 +00:00
// search footnotes short codes in the content
do {
2020-12-25 15:14:43 +00:00
// get first occurrence of the footnote start tag short code:
2021-01-26 17:01:53 +00:00
$i_int_LenContent = strlen ( $p_str_Content );
if ( $l_int_PosStart > $i_int_LenContent ) $l_int_PosStart = $i_int_LenContent ;
2020-10-27 11:56:49 +00:00
$l_int_PosStart = strpos ( $p_str_Content , $l_str_StartingTag , $l_int_PosStart );
// no short code found, stop here
if ( $l_int_PosStart === false ) {
break ;
}
2020-12-25 15:14:43 +00:00
// get first occurrence of the footnote end tag short code:
2020-10-27 11:56:49 +00:00
$l_int_PosEnd = strpos ( $p_str_Content , $l_str_EndingTag , $l_int_PosStart );
// no short code found, stop here
if ( $l_int_PosEnd === false ) {
break ;
}
// calculate the length of the footnote
2020-11-14 21:40:09 +00:00
$l_int_Length = $l_int_PosEnd - $l_int_PosStart ;
2020-10-27 11:56:49 +00:00
// get footnote text
2020-11-14 21:40:09 +00:00
$l_str_FootnoteText = substr ( $p_str_Content , $l_int_PosStart + strlen ( $l_str_StartingTag ), $l_int_Length - strlen ( $l_str_StartingTag ));
2021-01-19 23:45:34 +00:00
// get tooltip text if present:
self :: $a_str_TooltipShortcode = '[[/tooltip]]' ; // grab from DB
self :: $a_int_TooltipShortcodeLength = strlen ( self :: $a_str_TooltipShortcode );
2021-01-23 00:25:35 +00:00
$l_int_TooltipTextLength = strpos ( $l_str_FootnoteText , self :: $a_str_TooltipShortcode );
$l_bool_HasTooltipText = $l_int_TooltipTextLength === false ? false : true ;
if ( $l_bool_HasTooltipText ) {
$l_str_TooltipText = substr ( $l_str_FootnoteText , 0 , $l_int_TooltipTextLength );
2021-01-19 23:45:34 +00:00
} else {
$l_str_TooltipText = '' ;
}
2020-12-25 15:14:43 +00:00
2020-12-23 03:34:51 +00:00
/**
* URL line wrap
2020-12-25 15:14:43 +00:00
*
2020-12-23 03:34:51 +00:00
* Fix line wrapping of URLs ( hyperlinked or not ) based on pattern , not link element ,
* to prevent them from hanging out of the tooltip in non - Unicode - compliant user agents .
* @ see public . css
2020-12-25 15:14:43 +00:00
*
2020-12-23 03:34:51 +00:00
* spare however values of the href and the src arguments !
* @ since 2.1 . 5 exclude image source too , thanks to @ bjrnet21
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / 2 - 1 - 4 - breaks - on - my - site - images - dont - show /
2020-12-25 15:14:43 +00:00
*
2020-12-23 03:34:51 +00:00
* Even ARIA labels may take a URL as value , so use \w = [ \ ' " ] as a catch-all 2020-12-10T1005+0100
* @ since 2.1 . 6 add catch - all exclusion to fix URL line wrapping , thanks to @ a223123131 2020 - 12 - 09 T1921 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / broken - layout - starting - version - 2 - 1 - 4 /
2020-12-25 15:14:43 +00:00
*
2020-12-23 03:34:51 +00:00
* @ since 2.1 . 6 option to disable URL line wrapping 2020 - 12 - 09 T1606 + 0100
2020-12-25 15:14:43 +00:00
*
2020-12-23 03:34:51 +00:00
* URLs may be a query string in a URL :
* @ since 2.2 . 6 make the quotation mark optional in the exclusion regex , thanks to @ spiralofhope2 2020 - 12 - 23 T0409 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / two - links - now - breaks - footnotes - with - blogtext /
2021-01-23 00:41:23 +00:00
*
2020-12-25 15:14:43 +00:00
* @ since 2.2 . 7 revert that change in the exclusion regex , thanks to @ rjl20 , @ spaceling , @ friedrichnorth , @ bernardzit 2020 - 12 - 23 T1046 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / two - links - now - breaks - footnotes - with - blogtext /
2021-01-23 00:41:23 +00:00
*
2021-01-23 00:25:35 +00:00
* @ link https :// wordpress . org / support / topic / footnotes - dont - show - after - update - to - 2 - 2 - 6 /
2020-12-25 15:14:43 +00:00
* @ since 2.2 . 8 correct lookbehind by duplicating it with and without quotation mark class 2 0 2 0 - 1 2 - 2 3 T1107 + 0100
2020-12-31 11:45:10 +00:00
*
2020-12-25 15:14:43 +00:00
* @ since 2.2 . 9 account for RFC 2396 allowed characters in parameter names 2020 - 12 - 24 T1956 + 0100
2021-01-23 00:25:35 +00:00
* @ link https :// stackoverflow . com / questions / 814700 / http - url - allowed - characters - in - parameter - names
2021-01-23 00:41:23 +00:00
*
2020-12-25 15:14:43 +00:00
* @ since 2.2 . 9 exclude URLs also where the equals sign is preceded by an entity or character reference 2020 - 12 - 25 T1234 + 0100
2020-12-31 11:45:10 +00:00
*
2020-12-25 23:00:23 +00:00
* @ since 2.2 . 10 support also file transfer protocol URLs 2020 - 12 - 25 T2220 + 0100
2021-01-23 00:41:23 +00:00
*
* URL pattern may be part of a Wayback Machine URL
* @ thanksto @ rumperuu bug report
* @ link https :// wordpress . org / support / topic / line - wrap - href - regex - bug /
* @ since 2.5 . 3
* exclude protocols with prepended slash hinting it’ s in a Wayback Machine URL
2020-12-23 03:34:51 +00:00
*/
2020-12-10 12:29:50 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_FOOTNOTE_URL_WRAP_ENABLED ))) {
2021-01-23 00:25:35 +00:00
$l_str_FootnoteText = preg_replace ( '#(?<![-\w\.!~\*\'\(\);]=[\'"])(?<![-\w\.!~\*\'\(\);]=)(?<!/)((ht|f)tps?://[^\\s<]+)#' , '<span class="footnote_url_wrap">$1</span>' , $l_str_FootnoteText );
2020-12-10 12:29:50 +00:00
}
2020-11-25 07:47:45 +00:00
2020-10-27 11:56:49 +00:00
// Text to be displayed instead of the footnote
2020-11-14 21:40:09 +00:00
$l_str_FootnoteReplaceText = " " ;
2020-12-31 11:45:10 +00:00
// whether hard links are enabled; relevant also below in ReferenceContainer():
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_HardLinksEnable ) {
2020-12-31 11:45:10 +00:00
// get the configurable parts:
2021-01-23 00:25:35 +00:00
self :: $a_str_ReferrerLinkSlug = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_REFERRER_FRAGMENT_ID_SLUG );
self :: $a_str_FootnoteLinkSlug = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTE_FRAGMENT_ID_SLUG );
self :: $a_str_LinkIdsSeparator = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_HARD_LINK_IDS_SEPARATOR );
2020-12-31 11:45:10 +00:00
// streamline ID concatenation:
2021-01-23 00:25:35 +00:00
self :: $a_str_PostContainerIdCompound = self :: $a_str_LinkIdsSeparator ;
self :: $a_str_PostContainerIdCompound .= self :: $a_int_PostId ;
self :: $a_str_PostContainerIdCompound .= self :: $a_str_LinkIdsSeparator ;
self :: $a_str_PostContainerIdCompound .= self :: $a_int_ReferenceContainerId ;
self :: $a_str_PostContainerIdCompound .= self :: $a_str_LinkIdsSeparator ;
2020-12-31 11:45:10 +00:00
}
2020-11-16 20:57:15 +00:00
// display the footnote referrers and the tooltips:
2020-10-27 11:56:49 +00:00
if ( ! $p_bool_HideFootnotesText ) {
2020-11-14 21:40:09 +00:00
$l_int_Index = MCI_Footnotes_Convert :: Index ( $l_int_FootnoteIndex , MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_COUNTER_STYLE ));
2016-06-29 12:54:05 +00:00
2020-12-25 15:14:43 +00:00
// display only a truncated footnote text if option enabled:
2016-06-29 12:54:05 +00:00
$l_bool_EnableExcerpt = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED ));
2020-11-14 21:40:09 +00:00
$l_int_MaxLength = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH ));
2021-01-04 15:51:57 +00:00
// define excerpt text as footnote text by default:
$l_str_ExcerptText = $l_str_FootnoteText ;
2021-01-23 00:25:35 +00:00
/**
* TOOLTIP TRUNCATION
*
2021-01-26 17:01:53 +00:00
* If the option is enabled , the tooltip text is truncated based on character count .
* This is equivalent to the WordPress default excerpt generation , i . e . without a
* custom excerpt and without a delimiter . But WordPress does word count , usually 55.
2021-01-23 00:25:35 +00:00
*
2021-01-26 17:01:53 +00:00
* Tooltips : Read - on button : Label : configurable instead of localizable
2021-01-23 00:25:35 +00:00
* @ since 2.1 . 0
* @ datestamp 2020 - 11 - 08 T2146 + 0100
2021-01-26 17:01:53 +00:00
* @ thanksto @ rovanov
* @ triggeredby https :// wordpress . org / support / topic / offset - x - axis - and - offset - y - axis - does - not - working /
* ( The feature was not requested but it fixes an apparent design flaw of the plugin
* appearing when looking at a longer tooltip on the web page linked from this topic . )
2021-01-23 00:25:35 +00:00
*/
if ( self :: $a_bool_TooltipsEnabled && $l_bool_EnableExcerpt ) {
2016-06-29 12:54:05 +00:00
$l_str_DummyText = strip_tags ( $l_str_FootnoteText );
if ( is_int ( $l_int_MaxLength ) && strlen ( $l_str_DummyText ) > $l_int_MaxLength ) {
2020-11-16 20:57:15 +00:00
$l_str_ExcerptText = substr ( $l_str_DummyText , 0 , $l_int_MaxLength );
$l_str_ExcerptText = substr ( $l_str_ExcerptText , 0 , strrpos ( $l_str_ExcerptText , ' ' ));
2020-12-31 11:45:10 +00:00
$l_str_ExcerptText .= ' … <' ;
2021-01-23 00:25:35 +00:00
$l_str_ExcerptText .= self :: $a_bool_HardLinksEnable ? 'a' : 'span' ;
2020-12-31 11:45:10 +00:00
$l_str_ExcerptText .= ' class="footnote_tooltip_continue" ' ;
2021-01-23 00:25:35 +00:00
$l_str_ExcerptText .= 'onclick="footnote_moveToAnchor_' . self :: $a_int_PostId ;
$l_str_ExcerptText .= '_' . self :: $a_int_ReferenceContainerId ;
$l_str_ExcerptText .= '(\'footnote_plugin_reference_' . self :: $a_int_PostId ;
$l_str_ExcerptText .= '_' . self :: $a_int_ReferenceContainerId ;
2020-12-31 11:45:10 +00:00
$l_str_ExcerptText .= " _ $l_int_Index '); \" " ;
// if enabled, add the hard link fragment ID:
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_HardLinksEnable ) {
2020-12-31 11:45:10 +00:00
$l_str_ExcerptText .= ' href="#' ;
2021-01-23 00:25:35 +00:00
$l_str_ExcerptText .= self :: $a_str_FootnoteLinkSlug ;
$l_str_ExcerptText .= self :: $a_str_PostContainerIdCompound ;
2020-12-31 11:45:10 +00:00
$l_str_ExcerptText .= $l_int_Index ;
$l_str_ExcerptText .= '"' ;
}
$l_str_ExcerptText .= '>' ;
2020-11-16 20:57:15 +00:00
$l_str_ExcerptText .= MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_TOOLTIP_READON_LABEL );
2021-01-23 00:25:35 +00:00
$l_str_ExcerptText .= self :: $a_bool_HardLinksEnable ? '</a>' : '</span>' ;
2016-06-29 12:54:05 +00:00
}
}
2021-01-23 00:25:35 +00:00
/**
2021-01-26 17:01:53 +00:00
* REFERRERS ELEMENT SUPERSCRIPT OR BASELINE
2021-01-23 00:25:35 +00:00
*
2021-01-26 17:01:53 +00:00
* Referrers : new setting for vertical align : superscript ( default ) or baseline ( optional ), thanks to @ cwbayer bug report
2021-01-23 00:25:35 +00:00
* @ since 2.1 . 1
*
2021-01-26 17:01:53 +00:00
* @ reporter @ cwbayer
* @ bugreport https :// wordpress . org / support / topic / footnote - number - in - text - superscript - disrupts - leading /
*
2021-01-23 00:25:35 +00:00
* define the HTML element to use for the referrers :
*/
2020-11-17 02:14:21 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS ))) {
2020-12-31 11:45:10 +00:00
2020-11-25 23:40:45 +00:00
$l_str_SupSpan = 'sup' ;
2020-12-31 11:45:10 +00:00
2020-11-16 20:57:15 +00:00
} else {
2020-12-31 11:45:10 +00:00
2020-11-25 23:40:45 +00:00
$l_str_SupSpan = 'span' ;
2020-11-16 20:57:15 +00:00
}
2020-12-31 11:45:10 +00:00
// whether hard links are enabled; relevant also below in ReferenceContainer():
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_HardLinksEnable ) {
2020-12-31 11:45:10 +00:00
2021-01-23 00:25:35 +00:00
self :: $a_str_LinkSpan = 'a' ;
self :: $a_str_LinkCloseTag = '</a>' ;
// self::$a_str_LinkOpenTag will be defined as needed
2020-12-31 11:45:10 +00:00
// compose hyperlink address (leading space is in template):
$l_str_FootnoteLinkArgument = 'href="#' ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteLinkArgument .= self :: $a_str_FootnoteLinkSlug ;
$l_str_FootnoteLinkArgument .= self :: $a_str_PostContainerIdCompound ;
2020-12-31 11:45:10 +00:00
$l_str_FootnoteLinkArgument .= $l_int_Index ;
$l_str_FootnoteLinkArgument .= '" class="footnote_hard_link"' ;
// compose offset anchor, an empty span child of empty span
// to prevent browsers from drawing tall dotted rectangles:
$l_str_ReferrerAnchorElement = '<span class="footnote_referrer_base"><span id="' ;
2021-01-23 00:25:35 +00:00
$l_str_ReferrerAnchorElement .= self :: $a_str_ReferrerLinkSlug ;
$l_str_ReferrerAnchorElement .= self :: $a_str_PostContainerIdCompound ;
2020-12-31 11:45:10 +00:00
$l_str_ReferrerAnchorElement .= $l_int_Index ;
$l_str_ReferrerAnchorElement .= '" class="footnote_referrer_anchor"></span></span>' ;
} else {
// no hyperlink nor offset anchor needed:
$l_str_FootnoteLinkArgument = '' ;
$l_str_ReferrerAnchorElement = '' ;
// whether the link element is used nevertheless for styling:
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_LINK_ELEMENT_ENABLED )) ) {
2020-11-26 09:54:41 +00:00
2021-01-23 00:25:35 +00:00
self :: $a_str_LinkSpan = 'a' ;
self :: $a_str_LinkOpenTag = '<a>' ;
self :: $a_str_LinkCloseTag = '</a>' ;
2020-12-31 11:45:10 +00:00
}
}
2020-11-26 09:54:41 +00:00
2021-01-19 23:45:34 +00:00
// determine tooltip content:
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_TooltipsEnabled ) {
$l_str_TooltipContent = $l_bool_HasTooltipText ? $l_str_TooltipText : $l_str_ExcerptText ;
2021-01-19 23:45:34 +00:00
} else {
$l_str_TooltipContent = '' ;
}
2020-11-14 21:40:09 +00:00
// fill in 'templates/public/footnote.html':
2020-10-27 11:56:49 +00:00
$l_obj_Template -> replace (
array (
2021-01-23 00:25:35 +00:00
" link-span " => self :: $a_str_LinkSpan ,
" post_id " => self :: $a_int_PostId ,
" container_id " => self :: $a_int_ReferenceContainerId ,
2020-12-31 11:45:10 +00:00
" note_id " => $l_int_Index ,
" hard-link " => $l_str_FootnoteLinkArgument ,
" sup-span " => $l_str_SupSpan ,
" before " => MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_STYLING_BEFORE ),
" index " => $l_int_Index ,
" after " => MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_STYLING_AFTER ),
" anchor-element " => $l_str_ReferrerAnchorElement ,
2021-01-19 23:45:34 +00:00
" text " => $l_str_TooltipContent ,
2020-10-27 11:56:49 +00:00
)
);
$l_str_FootnoteReplaceText = $l_obj_Template -> getContent ();
2020-11-12 18:17:28 +00:00
2020-10-27 11:56:49 +00:00
// reset the template
$l_obj_Template -> reload ();
2020-12-31 11:45:10 +00:00
2021-01-04 15:51:57 +00:00
// if standard tooltips are enabled but alternative are not:
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_TooltipsEnabled && ! self :: $a_bool_AlternativeTooltipsEnabled ) {
2021-01-04 15:51:57 +00:00
2020-12-25 15:14:43 +00:00
$l_int_OffsetY = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y ));
$l_int_OffsetX = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X ));
2020-12-06 12:46:45 +00:00
$l_int_FadeInDelay = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_MOUSE_OVER_BOX_FADE_IN_DELAY ));
$l_int_FadeInDuration = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_MOUSE_OVER_BOX_FADE_IN_DURATION ));
$l_int_FadeOutDelay = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_MOUSE_OVER_BOX_FADE_OUT_DELAY ));
$l_int_FadeOutDuration = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_MOUSE_OVER_BOX_FADE_OUT_DURATION ));
2020-11-12 18:17:28 +00:00
2020-11-14 21:40:09 +00:00
// fill in 'templates/public/tooltip.html':
2020-10-27 11:56:49 +00:00
$l_obj_TemplateTooltip -> replace (
array (
2021-01-23 00:25:35 +00:00
" post_id " => self :: $a_int_PostId ,
" container_id " => self :: $a_int_ReferenceContainerId ,
2020-12-25 15:14:43 +00:00
" note_id " => $l_int_Index ,
2020-12-06 12:46:45 +00:00
" position " => MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_MOUSE_OVER_BOX_POSITION ),
" offset-y " => ! empty ( $l_int_OffsetY ) ? $l_int_OffsetY : 0 ,
" offset-x " => ! empty ( $l_int_OffsetX ) ? $l_int_OffsetX : 0 ,
" fade-in-delay " => ! empty ( $l_int_FadeInDelay ) ? $l_int_FadeInDelay : 0 ,
" fade-in-duration " => ! empty ( $l_int_FadeInDuration ) ? $l_int_FadeInDuration : 0 ,
" fade-out-delay " => ! empty ( $l_int_FadeOutDelay ) ? $l_int_FadeOutDelay : 0 ,
" fade-out-duration " => ! empty ( $l_int_FadeOutDuration ) ? $l_int_FadeOutDuration : 0 ,
2020-10-27 11:56:49 +00:00
)
);
2020-12-06 12:46:45 +00:00
$l_str_FootnoteReplaceText .= $l_obj_TemplateTooltip -> getContent ();
2020-10-27 11:56:49 +00:00
$l_obj_TemplateTooltip -> reload ();
}
}
// replace the footnote with the template
2020-11-14 21:40:09 +00:00
$p_str_Content = substr_replace ( $p_str_Content , $l_str_FootnoteReplaceText , $l_int_PosStart , $l_int_Length + strlen ( $l_str_EndingTag ));
2020-10-27 11:56:49 +00:00
// add footnote only if not empty
if ( ! empty ( $l_str_FootnoteText )) {
// set footnote to the output box at the end
self :: $a_arr_Footnotes [] = $l_str_FootnoteText ;
// increase footnote index
$l_int_FootnoteIndex ++ ;
}
// add offset to the new starting position
$l_int_PosStart += $l_int_Length + strlen ( $l_str_EndingTag );
$l_int_PosStart = $l_int_Length + strlen ( $l_str_FootnoteReplaceText );
} while ( true );
2016-06-29 12:54:05 +00:00
2020-10-27 11:56:49 +00:00
// return content
return $p_str_Content ;
}
2016-06-29 12:54:05 +00:00
2020-10-27 11:56:49 +00:00
/**
* Generates the reference container .
*
* @ author Stefan Herndler
* @ since 1.5 . 0
* @ return string
2020-11-14 21:40:09 +00:00
*
2021-01-26 17:01:53 +00:00
* @ edit 2.0 . 6 fix line breaking behavior in footnote number clusters
* @ edit 2.1 . 1 fix fragment IDs and backlinks with combine identical turned on 2020 - 11 - 14 T1808 + 0100
2020-10-27 11:56:49 +00:00
*/
public function ReferenceContainer () {
2020-11-14 21:40:09 +00:00
2020-11-25 23:40:45 +00:00
// no footnotes have been replaced on this page:
2020-10-27 11:56:49 +00:00
if ( empty ( self :: $a_arr_Footnotes )) {
return " " ;
}
2020-11-14 21:40:09 +00:00
2020-11-28 09:58:23 +00:00
/**
* FOOTNOTE INDEX BACKLINK SYMBOL
*
2020-12-25 15:14:43 +00:00
* @ since 2.0 . 0 removed backlink symbol along with column 2 of the reference container
* @ since 2.0 . 3 prepended an arrow on user request
* @ since 2.0 . 4 restored the arrow select & symbol input setting
2020-12-31 11:45:10 +00:00
* @ since 2.1 . 1 made the symbol optional instead of configuring it to invisible
2020-11-28 09:58:23 +00:00
*/
2020-11-17 02:14:21 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE ))) {
2020-11-16 20:57:15 +00:00
// get html arrow
$l_str_Arrow = MCI_Footnotes_Convert :: getArrow ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_HYPERLINK_ARROW ));
// set html arrow to the first one if invalid index defined
if ( is_array ( $l_str_Arrow )) {
$l_str_Arrow = MCI_Footnotes_Convert :: getArrow ( 0 );
}
// get user defined arrow
$l_str_ArrowUserDefined = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_HYPERLINK_ARROW_USER_DEFINED );
if ( ! empty ( $l_str_ArrowUserDefined )) {
$l_str_Arrow = $l_str_ArrowUserDefined ;
}
// wrap the arrow in a @media print { display:hidden } span:
$l_str_FootnoteArrow = '<span class="footnote_index_arrow">' ;
$l_str_FootnoteArrow .= $l_str_Arrow . '</span>' ;
} else {
2020-11-25 23:40:45 +00:00
// if it is not, set arrow to empty:
2020-11-28 09:58:23 +00:00
$l_str_Arrow = '' ;
$l_str_FootnoteArrow = '' ;
2020-11-16 20:57:15 +00:00
2020-10-27 11:56:49 +00:00
}
2016-06-29 12:54:05 +00:00
2020-11-14 21:40:09 +00:00
2020-11-28 09:58:23 +00:00
/**
2020-11-30 06:17:43 +00:00
* BACKLINK SEPARATOR
2020-11-28 09:58:23 +00:00
*
2020-11-30 06:17:43 +00:00
* Initially a comma was appended in this algorithm for enumerations .
* The comma in enumerations is not generally preferred .
2020-12-31 11:45:10 +00:00
* @ since 2.1 . 4 the separator is optional , has options , and is configurable :
2020-11-28 09:58:23 +00:00
*/
2020-12-25 23:00:23 +00:00
2020-11-30 06:17:43 +00:00
// check if it is even enabled:
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_BACKLINKS_SEPARATOR_ENABLED ))) {
2020-12-25 23:00:23 +00:00
2020-12-31 11:45:10 +00:00
// if so, check if it is freely configured:
2020-11-30 06:17:43 +00:00
$l_str_Separator = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_BACKLINKS_SEPARATOR_CUSTOM );
2020-12-25 23:00:23 +00:00
2020-11-30 06:17:43 +00:00
if ( empty ( $l_str_Separator )) {
2020-12-25 23:00:23 +00:00
2020-11-30 06:17:43 +00:00
// if it is not, check which option is on:
$l_str_SeparatorOption = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_BACKLINKS_SEPARATOR_OPTION );
switch ( $l_str_SeparatorOption ) {
case 'comma' : $l_str_Separator = ',' ; break ;
case 'semicolon' : $l_str_Separator = ';' ; break ;
case 'en_dash' : $l_str_Separator = ' –' ; break ;
}
}
2020-12-25 23:00:23 +00:00
2020-11-30 06:17:43 +00:00
} else {
2020-12-25 23:00:23 +00:00
2020-11-30 06:17:43 +00:00
$l_str_Separator = '' ;
2020-11-28 09:58:23 +00:00
}
2020-11-30 06:17:43 +00:00
/**
* BACKLINK TERMINATOR
*
* Initially a dot was appended in the table row template .
* @ since 2.0 . 6 a dot after footnote numbers is discarded as not localizable ;
* making it optional was envisaged .
2020-12-31 11:45:10 +00:00
* @ since 2.1 . 4 the terminator is optional , has options , and is configurable :
2020-11-30 06:17:43 +00:00
*/
2020-12-25 23:00:23 +00:00
2020-11-30 06:17:43 +00:00
// check if it is even enabled:
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_BACKLINKS_TERMINATOR_ENABLED ))) {
2020-12-25 23:00:23 +00:00
2020-12-31 11:45:10 +00:00
// if so, check if it is input-configured:
2020-11-30 06:17:43 +00:00
$l_str_Terminator = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_BACKLINKS_TERMINATOR_CUSTOM );
2020-12-25 23:00:23 +00:00
2020-11-30 06:17:43 +00:00
if ( empty ( $l_str_Terminator )) {
2020-12-25 23:00:23 +00:00
2020-11-30 06:17:43 +00:00
// if it is not, check which option is on:
$l_str_TerminatorOption = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_BACKLINKS_TERMINATOR_OPTION );
switch ( $l_str_TerminatorOption ) {
case 'period' : $l_str_Terminator = '.' ; break ;
case 'parenthesis' : $l_str_Terminator = ')' ; break ;
case 'colon' : $l_str_Terminator = ':' ; break ;
}
}
2020-12-25 23:00:23 +00:00
2020-11-30 06:17:43 +00:00
} else {
2020-12-25 23:00:23 +00:00
2020-11-28 09:58:23 +00:00
$l_str_Terminator = '' ;
}
2020-11-14 21:40:09 +00:00
2020-11-28 09:58:23 +00:00
/**
* LINE BREAKS
*
* The backlinks of combined footnotes are generally preferred in an enumeration .
* But when few footnotes are identical , stacking the items in list form is better .
* Variable number length and proportional character width require explicit line breaks .
* Otherwise , an ordinary space character offering a line break opportunity is inserted .
*/
$l_str_LineBreak = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_BACKLINKS_LINE_BREAKS_ENABLED )) ? '<br />' : ' ' ;
/**
2020-11-30 06:17:43 +00:00
* For maintenance and support , table rows in the reference container should be
2020-11-28 09:58:23 +00:00
* separated by an empty line . So we add these line breaks for source readability .
* Before the first table row ( breaks between rows are ~ 200 lines below ) :
*/
2020-11-14 21:40:09 +00:00
$l_str_Body = " \r \n \r \n " ;
2020-11-16 20:57:15 +00:00
2020-11-28 09:58:23 +00:00
2021-01-26 17:01:53 +00:00
/**
* REFERENCE CONTAINER TABLE ROW TEMPLATE LOAD
*
* Reference container : option to restore 3 - column layout ( combining identicals turned off )
* @ since 2.1 . 1
* @ datestamp 2020 - 11 - 16 T2024 + 0100
*/
2020-11-28 09:58:23 +00:00
2020-11-26 17:15:21 +00:00
// when combining identical footnotes is turned on, another template is needed:
2020-11-14 21:40:09 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_COMBINE_IDENTICAL_FOOTNOTES ))) {
2020-11-26 17:15:21 +00:00
// the combining template allows for backlink clusters and supports cell clicking for single notes:
2020-11-14 21:40:09 +00:00
$l_obj_Template = new MCI_Footnotes_Template ( MCI_Footnotes_Template :: C_STR_PUBLIC , " reference-container-body-combi " );
2020-11-16 20:57:15 +00:00
2020-11-14 21:40:09 +00:00
} else {
2020-11-16 20:57:15 +00:00
2020-11-26 17:15:21 +00:00
// when 3-column layout is turned on (only available if combining is turned off):
2020-11-17 02:14:21 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE ))) {
2020-11-16 20:57:15 +00:00
$l_obj_Template = new MCI_Footnotes_Template ( MCI_Footnotes_Template :: C_STR_PUBLIC , " reference-container-body-3column " );
} else {
2020-11-26 17:15:21 +00:00
// when switch symbol and index is turned on, and combining and 3-columns are off:
2020-11-17 02:14:21 +00:00
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH ))) {
2020-11-16 20:57:15 +00:00
$l_obj_Template = new MCI_Footnotes_Template ( MCI_Footnotes_Template :: C_STR_PUBLIC , " reference-container-body-switch " );
} else {
// default is the standard template:
$l_obj_Template = new MCI_Footnotes_Template ( MCI_Footnotes_Template :: C_STR_PUBLIC , " reference-container-body " );
}
}
2020-11-14 21:40:09 +00:00
}
2021-01-26 17:01:53 +00:00
/**
* SWITCH BACKLINK SYMBOL AND FOOTNOTE NUMBER
*
* Reference container : option to append symbol ( prepended by default ) ( combining identicals turned off )
* @ since 2.1 . 1
* @ datestamp 2020 - 11 - 16 T2024 + 0100
*/
2020-12-31 11:45:10 +00:00
$l_bool_SymbolSwitch = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH ));
2020-11-26 17:15:21 +00:00
2020-11-14 21:40:09 +00:00
// FILL IN THE TEMPLATE
2020-10-27 11:56:49 +00:00
// loop through all footnotes found in the page
2020-11-14 21:40:09 +00:00
for ( $l_int_Index = 0 ; $l_int_Index < count ( self :: $a_arr_Footnotes ); $l_int_Index ++ ) {
// TEXT COLUMN
2020-10-27 11:56:49 +00:00
// get footnote text
2020-11-14 21:40:09 +00:00
$l_str_FootnoteText = self :: $a_arr_Footnotes [ $l_int_Index ];
2021-01-19 23:45:34 +00:00
// if footnote is empty, go to the next one;
// With combine identicals turned on, identicals will be deleted and are skipped:
2020-10-27 11:56:49 +00:00
if ( empty ( $l_str_FootnoteText )) {
continue ;
}
2020-11-14 21:40:09 +00:00
2020-11-05 18:00:18 +00:00
// generate content of footnote index cell
2020-11-14 21:40:09 +00:00
$l_int_FirstFootnoteIndex = ( $l_int_Index + 1 );
// get the footnote index string and
2020-11-12 18:17:28 +00:00
// keep supporting legacy index placeholder:
2020-12-31 11:45:10 +00:00
$l_str_FootnoteId = MCI_Footnotes_Convert :: Index (( $l_int_Index + 1 ), MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_COUNTER_STYLE ));
// INDEX COLUMN WITH ONE BACKLINK PER TABLE ROW
// if enabled, and for the case the footnote is single, compose hard link:
2021-01-07 21:21:29 +00:00
// define variable as empty for the reference container if not enabled:
$l_str_HardLinkAddress = '' ;
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_HardLinksEnable ) {
2020-12-31 11:45:10 +00:00
// compose fragment ID anchor with offset, for use in reference container, an
// empty span child of empty span to avoid tall dotted rectangles in browser:
$l_str_FootnoteAnchorElement = '<span class="footnote_item_base"><span id="' ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteAnchorElement .= self :: $a_str_FootnoteLinkSlug ;
$l_str_FootnoteAnchorElement .= self :: $a_str_PostContainerIdCompound ;
2020-12-31 11:45:10 +00:00
$l_str_FootnoteAnchorElement .= $l_str_FootnoteId ;
$l_str_FootnoteAnchorElement .= '" class="footnote_item_anchor"></span></span>' ;
2020-11-14 21:40:09 +00:00
2020-12-31 11:45:10 +00:00
// compose optional hard link address:
$l_str_HardLinkAddress = ' href="#' ;
2021-01-23 00:25:35 +00:00
$l_str_HardLinkAddress .= self :: $a_str_ReferrerLinkSlug ;
$l_str_HardLinkAddress .= self :: $a_str_PostContainerIdCompound ;
2020-12-31 11:45:10 +00:00
$l_str_HardLinkAddress .= $l_str_FootnoteId . '"' ;
// compose optional opening link tag with optional hard link, mandatory for instance:
2021-01-23 00:25:35 +00:00
self :: $a_str_LinkOpenTag = '<a' . $l_str_HardLinkAddress ;
self :: $a_str_LinkOpenTag = ' class="footnote_hard_back_link">' ;
2020-12-31 11:45:10 +00:00
} else {
// define as empty, too:
$l_str_FootnoteAnchorElement = '' ;
}
2020-11-14 21:40:09 +00:00
2021-01-23 00:25:35 +00:00
/**
* SUPPORT FOR COMBINING IDENTICALS : COMPOSE ENUMERATED BACKLINKS
*
* Combining identical footnotes : fix dead links and ensure referrer - backlink bijectivity
* @ thanksto @ happyches bug report
* @ link https :// wordpress . org / support / topic / custom - css - for - jumbled - references /
* @ since 2.1 . 1
* @ datestamp 2020 - 11 - 14 T2233 + 0100
*
* Prepare to have single footnotes , where the click event and
* optional hard link need to be set to cover the table cell ,
* for better usability and UX .
*/
2020-12-31 11:45:10 +00:00
// set a flag to check for the combined status of a footnote item:
$l_bool_FlagCombined = false ;
2020-11-14 21:40:09 +00:00
2020-12-31 11:45:10 +00:00
// set otherwise unused variables as empty to avoid screwing up the placeholder array:
$l_str_BacklinkEvent = '' ;
$l_str_FootnoteBacklinks = '' ;
$l_str_FootnoteReference = '' ;
if ( MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_COMBINE_IDENTICAL_FOOTNOTES ))) {
// ID, optional hard link address, and class:
2021-01-23 00:25:35 +00:00
$l_str_FootnoteReference = '<' . self :: $a_str_LinkSpan ;
2020-11-25 23:40:45 +00:00
$l_str_FootnoteReference .= ' id="footnote_plugin_reference_' ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteReference .= self :: $a_int_PostId ;
$l_str_FootnoteReference .= '_' . self :: $a_int_ReferenceContainerId ;
2020-11-24 09:22:27 +00:00
$l_str_FootnoteReference .= " _ $l_str_FootnoteId\ " " ;
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_HardLinksEnable ) {
2020-12-31 11:45:10 +00:00
$l_str_FootnoteReference .= ' href="#' ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteReference .= self :: $a_str_ReferrerLinkSlug ;
$l_str_FootnoteReference .= self :: $a_str_PostContainerIdCompound ;
2020-12-31 11:45:10 +00:00
$l_str_FootnoteReference .= $l_str_FootnoteId . '"' ;
}
2020-11-24 09:22:27 +00:00
$l_str_FootnoteReference .= ' class="footnote_backlink"' ;
2020-12-31 11:45:10 +00:00
// the click event goes in the table cell if footnote remains single:
2020-12-25 15:14:43 +00:00
$l_str_BacklinkEvent = ' onclick="footnote_moveToAnchor_' ;
2021-01-23 00:25:35 +00:00
$l_str_BacklinkEvent .= self :: $a_int_PostId ;
$l_str_BacklinkEvent .= '_' . self :: $a_int_ReferenceContainerId ;
2020-12-25 15:14:43 +00:00
$l_str_BacklinkEvent .= " ('footnote_plugin_tooltip_ " ;
2021-01-23 00:25:35 +00:00
$l_str_BacklinkEvent .= self :: $a_int_PostId ;
$l_str_BacklinkEvent .= '_' . self :: $a_int_ReferenceContainerId ;
2020-11-24 09:22:27 +00:00
$l_str_BacklinkEvent .= " _ $l_str_FootnoteId '); \" " ;
2020-11-14 21:40:09 +00:00
2020-12-31 11:45:10 +00:00
2020-11-24 09:22:27 +00:00
// the dedicated template enumerating backlinks uses another variable:
$l_str_FootnoteBacklinks = $l_str_FootnoteReference ;
2020-12-31 11:45:10 +00:00
// append the click event right to the backlink item for enumerations;
// else it goes in the table cell:
$l_str_FootnoteBacklinks .= $l_str_BacklinkEvent . '>' ;
$l_str_FootnoteReference .= '>' ;
// append the optional offset anchor for hard links:
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_HardLinksEnable ) {
2020-12-31 11:45:10 +00:00
$l_str_FootnoteReference .= $l_str_FootnoteAnchorElement ;
$l_str_FootnoteBacklinks .= $l_str_FootnoteAnchorElement ;
}
2020-11-24 09:22:27 +00:00
2020-12-03 17:38:14 +00:00
// continue both single note and notes cluster, depending on switch option status:
2020-11-26 17:15:21 +00:00
if ( $l_bool_SymbolSwitch ) {
2020-11-14 21:40:09 +00:00
2020-12-31 11:45:10 +00:00
$l_str_FootnoteReference .= " $l_str_FootnoteId $l_str_FootnoteArrow " ;
$l_str_FootnoteBacklinks .= " $l_str_FootnoteId $l_str_FootnoteArrow " ;
2020-11-26 17:15:21 +00:00
} else {
2020-12-31 11:45:10 +00:00
$l_str_FootnoteReference .= " $l_str_FootnoteArrow $l_str_FootnoteId " ;
$l_str_FootnoteBacklinks .= " $l_str_FootnoteArrow $l_str_FootnoteId " ;
2020-11-26 17:15:21 +00:00
}
2020-11-14 21:40:09 +00:00
2020-12-31 11:45:10 +00:00
// If that is the only footnote with this text, we’ re almost done.
2020-11-14 21:40:09 +00:00
2020-12-03 17:38:14 +00:00
// check if it isn't the last footnote in the array:
if ( $l_int_FirstFootnoteIndex < count ( self :: $a_arr_Footnotes )) {
2020-11-14 21:40:09 +00:00
2020-12-03 17:38:14 +00:00
// get all footnotes that haven't passed yet:
for ( $l_int_CheckIndex = $l_int_FirstFootnoteIndex ; $l_int_CheckIndex < count ( self :: $a_arr_Footnotes ); $l_int_CheckIndex ++ ) {
2020-11-14 21:40:09 +00:00
2020-12-03 17:38:14 +00:00
// check if a further footnote is the same as the actual one:
if ( $l_str_FootnoteText == self :: $a_arr_Footnotes [ $l_int_CheckIndex ]) {
2020-11-14 21:40:09 +00:00
2020-12-03 17:38:14 +00:00
// if so, set the further footnote as empty so it won't be displayed later:
self :: $a_arr_Footnotes [ $l_int_CheckIndex ] = " " ;
2020-11-24 09:22:27 +00:00
2020-12-31 11:45:10 +00:00
// set the flag to true for the combined status:
$l_bool_FlagCombined = true ;
2020-11-14 21:40:09 +00:00
2020-12-03 17:38:14 +00:00
// update the footnote ID:
$l_str_FootnoteId = MCI_Footnotes_Convert :: Index (( $l_int_CheckIndex + 1 ), MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_COUNTER_STYLE ));
2020-11-14 21:40:09 +00:00
2020-12-03 17:38:14 +00:00
// resume composing the backlinks enumeration:
2020-12-31 11:45:10 +00:00
$l_str_FootnoteBacklinks .= " $l_str_Separator </ " ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteBacklinks .= self :: $a_str_LinkSpan . '>' ;
2020-12-31 11:45:10 +00:00
$l_str_FootnoteBacklinks .= $l_str_LineBreak ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteBacklinks .= '<' . self :: $a_str_LinkSpan ;
2020-12-03 17:38:14 +00:00
$l_str_FootnoteBacklinks .= ' id="footnote_plugin_reference_' ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteBacklinks .= self :: $a_int_PostId ;
$l_str_FootnoteBacklinks .= '_' . self :: $a_int_ReferenceContainerId ;
2020-12-31 11:45:10 +00:00
$l_str_FootnoteBacklinks .= " _ $l_str_FootnoteId\ " " ;
// insert the optional hard link address:
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_HardLinksEnable ) {
2020-12-31 11:45:10 +00:00
$l_str_FootnoteBacklinks .= ' href="#' ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteBacklinks .= self :: $a_str_ReferrerLinkSlug ;
$l_str_FootnoteBacklinks .= self :: $a_str_PostContainerIdCompound ;
2020-12-31 11:45:10 +00:00
$l_str_FootnoteBacklinks .= $l_str_FootnoteId . '"' ;
}
$l_str_FootnoteBacklinks .= ' class="footnote_backlink"' ;
$l_str_FootnoteBacklinks .= ' onclick="footnote_moveToAnchor_' ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteBacklinks .= self :: $a_int_PostId ;
$l_str_FootnoteBacklinks .= '_' . self :: $a_int_ReferenceContainerId ;
2020-12-25 15:14:43 +00:00
$l_str_FootnoteBacklinks .= " ('footnote_plugin_tooltip_ " ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteBacklinks .= self :: $a_int_PostId ;
$l_str_FootnoteBacklinks .= '_' . self :: $a_int_ReferenceContainerId ;
2020-12-03 17:38:14 +00:00
$l_str_FootnoteBacklinks .= " _ $l_str_FootnoteId '); \" > " ;
2020-12-31 11:45:10 +00:00
// append the offset anchor for optional hard links:
2021-01-23 00:25:35 +00:00
if ( self :: $a_bool_HardLinksEnable ) {
2020-12-31 11:45:10 +00:00
$l_str_FootnoteBacklinks .= '<span class="footnote_item_base"><span id="' ;
2021-01-23 00:25:35 +00:00
$l_str_FootnoteBacklinks .= self :: $a_str_FootnoteLinkSlug ;
$l_str_FootnoteBacklinks .= self :: $a_str_PostContainerIdCompound ;
2020-12-31 11:45:10 +00:00
$l_str_FootnoteBacklinks .= $l_str_FootnoteId ;
$l_str_FootnoteBacklinks .= '" class="footnote_item_anchor"></span></span>' ;
}
2020-12-03 17:38:14 +00:00
$l_str_FootnoteBacklinks .= $l_bool_SymbolSwitch ? '' : $l_str_FootnoteArrow ;
$l_str_FootnoteBacklinks .= $l_str_FootnoteId ;
$l_str_FootnoteBacklinks .= $l_bool_SymbolSwitch ? $l_str_FootnoteArrow : '' ;
2020-11-14 21:40:09 +00:00
2020-12-03 17:38:14 +00:00
}
2020-10-27 11:56:49 +00:00
}
}
2020-12-03 17:38:14 +00:00
2020-12-31 11:45:10 +00:00
// append terminator and end tag:
2021-01-23 00:25:35 +00:00
$l_str_FootnoteReference .= $l_str_Terminator . '</' . self :: $a_str_LinkSpan . '>' ;
$l_str_FootnoteBacklinks .= $l_str_Terminator . '</' . self :: $a_str_LinkSpan . '>' ;
2020-12-03 17:38:14 +00:00
2020-10-27 11:56:49 +00:00
}
2020-11-12 18:17:28 +00:00
2020-12-06 22:07:52 +00:00
// line wrapping of URLs already fixed, see above
2020-11-26 09:54:41 +00:00
2021-01-19 23:45:34 +00:00
// get reference container item text if tooltip text goes separate:
2021-01-23 00:25:35 +00:00
$l_int_TooltipTextLength = strpos ( $l_str_FootnoteText , self :: $a_str_TooltipShortcode );
$l_bool_HasTooltipText = $l_int_TooltipTextLength === false ? false : true ;
if ( $l_bool_HasTooltipText ) {
$l_str_NotTooltipText = substr ( $l_str_FootnoteText , ( $l_int_TooltipTextLength + self :: $a_int_TooltipShortcodeLength ) );
self :: $a_bool_MirrorTooltipText = false ; // grab from settings!
if ( self :: $a_bool_MirrorTooltipText ) {
$l_str_TooltipText = substr ( $l_str_FootnoteText , 0 , $l_int_TooltipTextLength );
$l_str_ReferenceTextIntroducer = ' ' ; // grab from settings!
$l_str_ReferenceText = $l_str_TooltipText . $l_str_ReferenceTextIntroducer . $l_str_NotTooltipText ;
} else {
$l_str_ReferenceText = $l_str_NotTooltipText ;
}
2021-01-19 23:45:34 +00:00
} else {
$l_str_ReferenceText = $l_str_FootnoteText ;
}
2020-11-14 21:40:09 +00:00
// replace all placeholders in 'templates/public/reference-container-body.html'
// or in 'templates/public/reference-container-body-combi.html'
2020-11-24 09:22:27 +00:00
// or in 'templates/public/reference-container-body-3column.html'
// or in 'templates/public/reference-container-body-switch.html'
2020-10-27 11:56:49 +00:00
$l_obj_Template -> replace (
array (
2020-12-31 11:45:10 +00:00
2020-11-14 21:40:09 +00:00
// placeholder used in all templates:
2021-01-19 23:45:34 +00:00
" text " => $l_str_ReferenceText ,
2020-11-14 21:40:09 +00:00
// used in standard layout W/O COMBINED FOOTNOTES:
2021-01-23 00:25:35 +00:00
" post_id " => self :: $a_int_PostId ,
" container_id " => self :: $a_int_ReferenceContainerId ,
2020-12-31 11:45:10 +00:00
" note_id " => MCI_Footnotes_Convert :: Index ( $l_int_FirstFootnoteIndex , MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_FOOTNOTES_COUNTER_STYLE )),
2021-01-23 00:25:35 +00:00
" link-start " => self :: $a_str_LinkOpenTag ,
" link-end " => self :: $a_str_LinkCloseTag ,
" link-span " => self :: $a_str_LinkSpan ,
2020-12-31 11:45:10 +00:00
" terminator " => $l_str_Terminator ,
" anchor-element " => $l_str_FootnoteAnchorElement ,
" hard-link " => $l_str_HardLinkAddress ,
2020-11-14 21:40:09 +00:00
// used in standard layout WITH COMBINED IDENTICALS TURNED ON:
2020-12-31 11:45:10 +00:00
" pointer " => $l_bool_FlagCombined ? '' : ' pointer' ,
" event " => $l_bool_FlagCombined ? '' : $l_str_BacklinkEvent ,
" backlinks " => $l_bool_FlagCombined ? $l_str_FootnoteBacklinks : $l_str_FootnoteReference ,
2020-11-14 21:40:09 +00:00
// Legacy placeholders for use in legacy layout templates:
2020-12-31 11:45:10 +00:00
" arrow " => $l_str_FootnoteArrow ,
" index " => $l_str_FootnoteId ,
2020-10-27 11:56:49 +00:00
)
);
2020-11-14 21:40:09 +00:00
$l_str_Body .= $l_obj_Template -> getContent ();
2020-11-16 20:57:15 +00:00
2020-11-25 23:40:45 +00:00
// extra line breaks for page source readability:
2020-11-14 21:40:09 +00:00
$l_str_Body .= " \r \n \r \n " ;
2020-10-27 11:56:49 +00:00
$l_obj_Template -> reload ();
2020-11-14 21:40:09 +00:00
2020-10-27 11:56:49 +00:00
}
2016-06-29 12:54:05 +00:00
2021-01-26 17:01:53 +00:00
// call again for robustness when priority levels don’ t match any longer:
self :: $a_int_ScrollOffset = intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_SCROLL_OFFSET ));
2020-12-18 16:31:09 +00:00
// streamline:
$l_bool_CollapseDefault = MCI_Footnotes_Convert :: toBool ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_BOOL_REFERENCE_CONTAINER_COLLAPSE ));
2020-12-19 06:18:56 +00:00
2021-01-04 15:51:57 +00:00
// prevent empty from being less robust:
$l_str_ReferenceContainerLabel = MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_REFERENCE_CONTAINER_NAME );
2020-11-14 21:40:09 +00:00
// load 'templates/public/reference-container.html':
2020-10-27 11:56:49 +00:00
$l_obj_TemplateContainer = new MCI_Footnotes_Template ( MCI_Footnotes_Template :: C_STR_PUBLIC , " reference-container " );
$l_obj_TemplateContainer -> replace (
array (
2021-01-23 00:25:35 +00:00
" post_id " => self :: $a_int_PostId ,
" container_id " => self :: $a_int_ReferenceContainerId ,
2020-12-18 16:31:09 +00:00
" element " => MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_STR_REFERENCE_CONTAINER_LABEL_ELEMENT ),
2021-01-04 15:51:57 +00:00
" name " => empty ( $l_str_ReferenceContainerLabel ) ? ' ' : $l_str_ReferenceContainerLabel ,
2020-12-18 16:31:09 +00:00
" button-style " => ! $l_bool_CollapseDefault ? 'display: none;' : '' ,
" style " => $l_bool_CollapseDefault ? 'display: none;' : '' ,
2020-12-05 04:48:09 +00:00
" content " => $l_str_Body ,
2021-01-23 00:25:35 +00:00
" scroll-offset " => ( self :: $a_int_ScrollOffset / 100 ),
2020-12-18 16:31:09 +00:00
" scroll-duration " => intval ( MCI_Footnotes_Settings :: instance () -> get ( MCI_Footnotes_Settings :: C_INT_FOOTNOTES_SCROLL_DURATION )),
2020-10-27 11:56:49 +00:00
)
);
// free all found footnotes if reference container will be displayed
self :: $a_arr_Footnotes = array ();
2020-11-12 18:17:28 +00:00
2020-10-27 11:56:49 +00:00
return $l_obj_TemplateContainer -> getContent ();
}
2016-06-29 12:54:05 +00:00
}