From 41676ea716b086277ce70e59f72cefcf5fc6b957 Mon Sep 17 00:00:00 2001 From: pewgeuges Date: Thu, 18 Mar 2021 18:00:42 +0000 Subject: [PATCH] 2.5.6d7 added 4 missing templates for AMP compat. git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@2498893 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- class/task.php | 132 +++++++++++------- footnotes.php | 6 +- readme.txt | 2 +- templates/public/amp-footnote-expand.html | 2 +- .../amp-reference-container-body-3column.html | 46 ++++++ .../amp-reference-container-body-combi.html | 37 +++++ .../amp-reference-container-body-switch.html | 44 ++++++ .../public/amp-reference-container-body.html | 38 +++++ templates/public/footnote.html | 2 +- templates/public/js-reference-container.html | 10 +- .../reference-container-body-3column.html | 2 + .../reference-container-body-switch.html | 2 + .../public/reference-container-body.html | 4 +- templates/public/reference-container.html | 4 + 14 files changed, 272 insertions(+), 59 deletions(-) create mode 100644 templates/public/amp-reference-container-body-3column.html create mode 100644 templates/public/amp-reference-container-body-combi.html create mode 100644 templates/public/amp-reference-container-body-switch.html create mode 100755 templates/public/amp-reference-container-body.html diff --git a/class/task.php b/class/task.php index b49196d..5d0ea7b 100644 --- a/class/task.php +++ b/class/task.php @@ -198,7 +198,7 @@ class MCI_Footnotes_Task { * @since 2.3.0 * @var bool */ - public static $a_bool_hard_links_enable = false; + public static $a_bool_hard_links_enabled = false; /** * The referrer slug. @@ -301,7 +301,7 @@ class MCI_Footnotes_Task { * Yet styling these elements with the link color is not universally preferred, so that * the very presence of these link elements may need to be avoided. * - * @see self::$a_bool_hard_links_enable + * @see self::$a_bool_hard_links_enabled * * Used both in search() and reference_container(), these need to be class variables. */ @@ -774,15 +774,15 @@ class MCI_Footnotes_Task { * * @since 2.5.6 hard links are always enabled when the alternative reference container is. */ - self::$a_bool_hard_links_enable = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_HARD_LINKS_ENABLE ) ); + self::$a_bool_hard_links_enabled = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_HARD_LINKS_ENABLE ) ); - // Correct hard links enabled status depending on alternative reference container enabled status. - if ( 'jquery' !== MCI_Footnotes::$a_str_script_mode ) { - self::$a_bool_hard_links_enable = true; + // Correct hard links enabled status depending on AMP compatible or alternative reference container enabled status. + if ( MCI_Footnotes::$a_bool_amp_enabled || 'jquery' !== MCI_Footnotes::$a_str_script_mode ) { + self::$a_bool_hard_links_enabled = true; } self::$a_int_scroll_offset = intval( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_INT_FOOTNOTES_SCROLL_OFFSET ) ); - if ( self::$a_bool_hard_links_enable ) { + if ( self::$a_bool_hard_links_enabled ) { echo '.footnote_referrer_anchor, .footnote_item_anchor {bottom: '; echo self::$a_int_scroll_offset; echo "vh;}\r\n"; @@ -902,7 +902,7 @@ class MCI_Footnotes_Task { */ $l_int_alternative_tooltip_width = intval( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_INT_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH ) ); echo '.footnote_tooltip.position {'; - echo ' width: ' . $l_int_alternative_tooltip_width . 'px;'; + echo ' width: max-content; '; // Set also as max-width wrt short tooltip shrinking. echo ' max-width: ' . $l_int_alternative_tooltip_width . 'px;'; @@ -1406,9 +1406,13 @@ class MCI_Footnotes_Task { } } - /** + /* * Load footnote referrer template file. */ + + // Set to null in case anyone is not needed. + $l_obj_template = null; + $l_obj_template_tooltip = null; // On the condition that the footnote text is not hidden. if ( ! $p_bool_hide_footnotes_text ) { @@ -1424,32 +1428,25 @@ class MCI_Footnotes_Task { } else { - // Load 'templates/public/amp-footnote-expand.html'. + // Load 'templates/public/amp-footnote.html'. $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'amp-footnote' ); } } elseif ( MCI_Footnotes::$a_bool_alternative_tooltips_enabled ) { - // Load 'templates/public/amp-footnote-expand.html'. + // Load 'templates/public/footnote-alternative.html'. $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'footnote-alternative' ); + // Else jQuery tooltips are enabled. } else { - // Load 'templates/public/amp-footnote-expand.html'. + // Load 'templates/public/footnote.html'. $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'footnote' ); - } - - // Load tooltip inline script if jQuery tooltips are enabled. - if ( MCI_Footnotes::$a_bool_tooltips_enabled && ! MCI_Footnotes::$a_bool_alternative_tooltips_enabled ) { - + // Load tooltip inline script. $l_obj_template_tooltip = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'tooltip' ); } - } else { - - $l_obj_template = null; - $l_obj_template_tooltip = null; } // Search footnotes short codes in the content. @@ -1634,7 +1631,7 @@ class MCI_Footnotes_Task { $l_str_footnote_replace_text = ''; // Whether hard links are enabled. - if ( self::$a_bool_hard_links_enable ) { + if ( self::$a_bool_hard_links_enabled ) { // Get the configurable parts. self::$a_str_referrer_link_slug = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERRER_FRAGMENT_ID_SLUG ); @@ -1683,7 +1680,7 @@ class MCI_Footnotes_Task { $l_str_excerpt_text = substr( $l_str_dummy_text, 0, $l_int_max_length ); $l_str_excerpt_text = substr( $l_str_excerpt_text, 0, strrpos( $l_str_excerpt_text, ' ' ) ); $l_str_excerpt_text .= ' … <'; - $l_str_excerpt_text .= self::$a_bool_hard_links_enable ? 'a' : 'span'; + $l_str_excerpt_text .= self::$a_bool_hard_links_enabled ? 'a' : 'span'; $l_str_excerpt_text .= ' class="footnote_tooltip_continue" '; $l_str_excerpt_text .= 'onclick="footnote_move_to_anchor_' . self::$a_int_post_id; $l_str_excerpt_text .= '_' . self::$a_int_reference_container_id; @@ -1692,7 +1689,7 @@ class MCI_Footnotes_Task { $l_str_excerpt_text .= "_$l_int_index');\""; // If enabled, add the hard link fragment ID. - if ( self::$a_bool_hard_links_enable ) { + if ( self::$a_bool_hard_links_enabled ) { $l_str_excerpt_text .= ' href="#'; $l_str_excerpt_text .= self::$a_str_footnote_link_slug; @@ -1716,7 +1713,7 @@ class MCI_Footnotes_Task { */ $l_str_excerpt_text .= MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL ); - $l_str_excerpt_text .= self::$a_bool_hard_links_enable ? '' : ''; + $l_str_excerpt_text .= self::$a_bool_hard_links_enabled ? '' : ''; } } @@ -1742,7 +1739,7 @@ class MCI_Footnotes_Task { } // Whether hard links are enabled. - if ( self::$a_bool_hard_links_enable ) { + if ( self::$a_bool_hard_links_enabled ) { self::$a_str_link_span = 'a'; self::$a_str_link_close_tag = ''; @@ -1837,8 +1834,8 @@ class MCI_Footnotes_Task { // Reset the template. $l_obj_template->reload(); - // If standard tooltips are enabled but alternative are not. - if ( MCI_Footnotes::$a_bool_tooltips_enabled && ! MCI_Footnotes::$a_bool_alternative_tooltips_enabled ) { + // If standard tooltips are enabled but neither AMP nor alternative are. + if ( MCI_Footnotes::$a_bool_tooltips_enabled && ! MCI_Footnotes::$a_bool_amp_enabled && ! MCI_Footnotes::$a_bool_alternative_tooltips_enabled ) { $l_int_offset_y = intval( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y ) ); $l_int_offset_x = intval( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X ) ); @@ -2086,29 +2083,64 @@ class MCI_Footnotes_Task { * @since 2.1.1 * @date 2020-11-16T2024+0100 */ - - // When combining identical footnotes is turned on, another template is needed. - if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_COMBINE_IDENTICAL_FOOTNOTES ) ) ) { - // The combining template allows for backlink clusters and supports cell clicking for single notes. - $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'reference-container-body-combi' ); - - } else { - - // When 3-column layout is turned on (only available if combining is turned off). - if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE ) ) ) { - $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'reference-container-body-3column' ); + $l_bool_combine_identical_footnotes = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_COMBINE_IDENTICAL_FOOTNOTES ) ); + + // AMP compatibility requires a full set of AMP compatible table row templates. + if ( MCI_Footnotes::$a_bool_amp_enabled ) { + + // When combining identical footnotes is turned on, another template is needed. + if ( $l_bool_combine_identical_footnotes ) { + + // The combining template allows for backlink clusters and supports cell clicking for single notes. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'amp-reference-container-body-combi' ); } else { - // When switch symbol and index is turned on, and combining and 3-columns are off. - if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH ) ) ) { - $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'reference-container-body-switch' ); + // When 3-column layout is turned on (only available if combining is turned off). + if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE ) ) ) { + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'amp-reference-container-body-3column' ); } else { - // Default is the standard template. - $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'reference-container-body' ); + // When switch symbol and index is turned on, and combining and 3-columns are off. + if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH ) ) ) { + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'amp-reference-container-body-switch' ); + } else { + + // Default is the standard template. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'amp-reference-container-body' ); + + } + } + } + + } else { + + // When combining identical footnotes is turned on, another template is needed. + if ( $l_bool_combine_identical_footnotes ) { + + // The combining template allows for backlink clusters and supports cell clicking for single notes. + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'reference-container-body-combi' ); + + } else { + + // When 3-column layout is turned on (only available if combining is turned off). + if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE ) ) ) { + $l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_PUBLIC, 'reference-container-body-3column' ); + + } else { + + // When switch symbol and index is turned on, and combining and 3-columns are off. + if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH ) ) ) { + $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' ); + + } } } } @@ -2160,7 +2192,7 @@ class MCI_Footnotes_Task { // Define anyway. $l_str_hard_link_address = ''; - if ( self::$a_bool_hard_links_enable ) { + if ( self::$a_bool_hard_links_enabled ) { /** * Use-Backbutton-Hint tooltip, optional and configurable. @@ -2233,7 +2265,7 @@ class MCI_Footnotes_Task { $l_str_footnote_backlinks = ''; $l_str_footnote_reference = ''; - if ( MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_COMBINE_IDENTICAL_FOOTNOTES ) ) ) { + if ( $l_bool_combine_identical_footnotes ) { // ID, optional hard link address, and class. $l_str_footnote_reference = '<' . self::$a_str_link_span; @@ -2241,7 +2273,7 @@ class MCI_Footnotes_Task { $l_str_footnote_reference .= self::$a_int_post_id; $l_str_footnote_reference .= '_' . self::$a_int_reference_container_id; $l_str_footnote_reference .= "_$l_str_footnote_id\""; - if ( self::$a_bool_hard_links_enable ) { + if ( self::$a_bool_hard_links_enabled ) { $l_str_footnote_reference .= ' href="#'; $l_str_footnote_reference .= self::$a_str_referrer_link_slug; $l_str_footnote_reference .= self::$a_str_post_container_id_compound; @@ -2268,7 +2300,7 @@ class MCI_Footnotes_Task { $l_str_footnote_reference .= '>'; // Append the optional offset anchor for hard links. - if ( self::$a_bool_hard_links_enable ) { + if ( self::$a_bool_hard_links_enabled ) { $l_str_footnote_reference .= $l_str_footnote_anchor_element; $l_str_footnote_backlinks .= $l_str_footnote_anchor_element; } @@ -2318,7 +2350,7 @@ class MCI_Footnotes_Task { $l_str_footnote_backlinks .= "_$l_str_footnote_id\""; // Insert the optional hard link address. - if ( self::$a_bool_hard_links_enable ) { + if ( self::$a_bool_hard_links_enabled ) { $l_str_footnote_backlinks .= ' href="#'; $l_str_footnote_backlinks .= self::$a_str_referrer_link_slug; $l_str_footnote_backlinks .= self::$a_str_post_container_id_compound; @@ -2336,7 +2368,7 @@ class MCI_Footnotes_Task { $l_str_footnote_backlinks .= "_$l_str_footnote_id');\">"; // Append the offset anchor for optional hard links. - if ( self::$a_bool_hard_links_enable ) { + if ( self::$a_bool_hard_links_enabled ) { $l_str_footnote_backlinks .= '<[[sup-span]] id="footnote_plugin_tooltip_[[post_id]]_[[container_id]]_[[note_id]]" class="footnote_plugin_tooltip_text" diff --git a/templates/public/amp-reference-container-body-3column.html b/templates/public/amp-reference-container-body-3column.html new file mode 100644 index 0000000..ae7098a --- /dev/null +++ b/templates/public/amp-reference-container-body-3column.html @@ -0,0 +1,46 @@ + + + <[[link-span]] + role="button" + tabindex="0" + id="footnote_plugin_reference_[[post_id]]_[[container_id]]_[[note_id]]" + class="footnote_index" + [[hard-link]] + >[[index]][[terminator]][[anchor-element]] + <[[link-span]] + class="footnote_backlink" + [[hard-link]] + >[[arrow]] + [[text]] + diff --git a/templates/public/amp-reference-container-body-combi.html b/templates/public/amp-reference-container-body-combi.html new file mode 100644 index 0000000..dd49dd0 --- /dev/null +++ b/templates/public/amp-reference-container-body-combi.html @@ -0,0 +1,37 @@ + + + [[backlinks]] + [[text]] + diff --git a/templates/public/amp-reference-container-body-switch.html b/templates/public/amp-reference-container-body-switch.html new file mode 100644 index 0000000..ccc0953 --- /dev/null +++ b/templates/public/amp-reference-container-body-switch.html @@ -0,0 +1,44 @@ + + + <[[link-span]] + role="button" + tabindex="0" + class="footnote_plugin_link" + [[hard-link]] + >[[index]][[terminator]][[arrow]][[anchor-element]] + [[text]] + diff --git a/templates/public/amp-reference-container-body.html b/templates/public/amp-reference-container-body.html new file mode 100755 index 0000000..cee797f --- /dev/null +++ b/templates/public/amp-reference-container-body.html @@ -0,0 +1,38 @@ + + + <[[link-span]] + role="button" + tabindex="0" + class="footnote_plugin_link" + [[hard-link]] + >[[arrow]][[index]][[terminator]][[anchor-element]] + [[text]] + diff --git a/templates/public/footnote.html b/templates/public/footnote.html index 931402e..86e7744 100755 --- a/templates/public/footnote.html +++ b/templates/public/footnote.html @@ -3,7 +3,7 @@ */?> --> <[[link-span]] role="button" tabindex="0" diff --git a/templates/public/js-reference-container.html b/templates/public/js-reference-container.html index 4db51c5..242284e 100644 --- a/templates/public/js-reference-container.html +++ b/templates/public/js-reference-container.html @@ -47,12 +47,16 @@ id="footnotes_container_label_expand_[[post_id]]_[[container_id]]" class="footnote_reference_container_label pointer" onclick="footnote_expand_reference_container_[[post_id]]_[[container_id]]();" - >[[name]][[name]][+]<[[link-span]] + role="button" + tabindex="0" id="footnote_plugin_reference_[[post_id]]_[[container_id]]_[[note_id]]" class="footnote_index" onclick="footnote_moveToAnchor_[[post_id]]_[[container_id]]('footnote_plugin_tooltip_[[post_id]]_[[container_id]]_[[note_id]]');" diff --git a/templates/public/reference-container-body-switch.html b/templates/public/reference-container-body-switch.html index c1bcdb3..6a65fd7 100644 --- a/templates/public/reference-container-body-switch.html +++ b/templates/public/reference-container-body-switch.html @@ -30,6 +30,8 @@ class="footnote_plugin_index pointer" onclick="footnote_moveToAnchor_[[post_id]]_[[container_id]]('footnote_plugin_tooltip_[[post_id]]_[[container_id]]_[[note_id]]');" ><[[link-span]] + role="button" + tabindex="0" class="footnote_plugin_link" [[hard-link]] >[[index]][[terminator]][[arrow]] <[[link-span]] + role="button" + tabindex="0" class="footnote_plugin_link" [[hard-link]] >[[arrow]][[index]][[terminator]][[name]][+