development 2.1.1d7 fixed dead links

git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@2418754 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
pewgeuges 2020-11-14 21:40:09 +00:00
parent 478e21a284
commit 37ae1474ed
8 changed files with 207 additions and 97 deletions

View file

@ -151,7 +151,7 @@ class MCI_Footnotes {
'mci-footnotes-css-public',
plugins_url('../css/public.css', __FILE__),
'',
'2.1.1d6'
'2.1.1d7'
);
}

View file

@ -8,13 +8,14 @@
*
* Edited for v2.0.0 and following.
*
* Edited for v2.0.5: Autoload / infinite scroll support added thanks to code from
* 2.0.5: Autoload / infinite scroll support added thanks to code from
* @docteurfitness <https://wordpress.org/support/topic/auto-load-post-compatibility-update/>
*
* Edited for v2.0.9: DISABLED the_post HOOK 2020-11-08T1839+0100
* Edited for v2.1.0: Promoted the 'Continue reading' button from localization to customization 2020-11-08T2146+0100
* 2.0.9: DISABLED the_post HOOK 2020-11-08T1839+0100
* 2.1.0: promoted the 'Continue reading' button from localization to customization 2020-11-08T2146+0100
* 2.1.1: combining identical footnotes: fixed dead links 2020-11-14T2233+0100
*
* Last modified 2020-11-08T2146+0100
* Last modified 2020-11-14T2233+0100
*/
// If called directly, abort:
@ -341,8 +342,8 @@ class MCI_Footnotes_Task {
public function search($p_str_Content, $p_bool_ConvertHtmlChars, $p_bool_HideFootnotesText) {
// post ID to make everything unique wrt infinite scroll and archive view
global $l_int_PostID;
$l_int_PostID = get_the_id();
global $l_int_PostId;
$l_int_PostId = get_the_id();
// contains the index for the next footnote on this page
$l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1;
@ -407,7 +408,7 @@ class MCI_Footnotes_Task {
// display the footnote as mouse-over box
if (!$p_bool_HideFootnotesText) {
$l_str_Index = MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
$l_int_Index = MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
// display only an excerpt of the footnotes text if enabled
$l_str_ExcerptText = $l_str_FootnoteText;
@ -419,17 +420,17 @@ class MCI_Footnotes_Task {
if (is_int($l_int_MaxLength) && strlen($l_str_DummyText) > $l_int_MaxLength) {
$l_str_ExcerptText = substr($l_str_DummyText, 0, $l_int_MaxLength);
$l_str_ExcerptText = substr($l_str_ExcerptText, 0, strrpos($l_str_ExcerptText, ' '));
$l_str_ExcerptText .= '&nbsp;&#x2026; ' . '<span class="footnote_tooltip_continue" onclick="footnote_moveToAnchor_' . $l_int_PostID . '(\'footnote_plugin_reference_' . $l_int_PostID . '_' . $l_str_Index . '\');">' . MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL) . '</span>';
$l_str_ExcerptText .= '&nbsp;&#x2026; ' . '<span class="footnote_tooltip_continue" onclick="footnote_moveToAnchor_' . $l_int_PostId . '(\'footnote_plugin_reference_' . $l_int_PostId . '_' . $l_int_Index . '\');">' . MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL) . '</span>';
}
}
// fill the footnotes template templates/public/footnote.html
// fill in 'templates/public/footnote.html':
$l_obj_Template->replace(
array(
"post_id" => $l_int_PostID,
"id" => $l_str_Index,
"post_id" => $l_int_PostId,
"id" => $l_int_Index,
"before" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE),
"index" => $l_str_Index,
"index" => $l_int_Index,
"after" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER),
"text" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED)) ? $l_str_ExcerptText : "",
)
@ -442,11 +443,11 @@ class MCI_Footnotes_Task {
$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));
// fill in the tooltip template templates/public/tooltip.html
// fill in 'templates/public/tooltip.html':
$l_obj_TemplateTooltip->replace(
array(
"post_id" => $l_int_PostID,
"id" => $l_str_Index,
"post_id" => $l_int_PostId,
"id" => $l_int_Index,
"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,
@ -483,16 +484,24 @@ class MCI_Footnotes_Task {
* @author Stefan Herndler
* @since 1.5.0
* @return string
*
* Edited for 2.0.6: fixed line breaking behavior in footnote # clusters
* Edited for 2.1.1: fixed fragment IDs and backlinks with combine identical turned on 2020-11-14T1808+0100
*/
public function ReferenceContainer() {
// post ID to make everything unique wrt infinite scroll and archive view
global $l_int_PostID;
$l_int_PostID = get_the_id();
// post ID to make everything unique wrt infinite scroll and archive view:
global $l_int_PostId;
$l_int_PostId = get_the_id();
// no footnotes has been replaced on this page
if (empty(self::$a_arr_Footnotes)) {
return "";
}
// FOOTNOTE INDEX BACKLINK SYMBOL
// 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
@ -505,79 +514,162 @@ class MCI_Footnotes_Task {
$l_str_Arrow = $l_str_ArrowUserDefined;
}
// load template file
$l_str_Body = "";
// REFERENCE CONTAINER TABLE ROW TEMPLATE LOAD
// line breaks for source readability:
$l_str_Body = "\r\n\r\n";
// When combine identical is turned on, another template is needed:
if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) {
// In the combined template, identifiers only are clickable.
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body-combi");
} else {
// In the standard template the whole cell is clickable.
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body");
}
// FILL IN THE TEMPLATE
// loop through all footnotes found in the page
for ($l_str_Index = 0; $l_str_Index < count(self::$a_arr_Footnotes); $l_str_Index++) {
for ($l_int_Index = 0; $l_int_Index < count(self::$a_arr_Footnotes); $l_int_Index++) {
// TEXT COLUMN
// get footnote text
$l_str_FootnoteText = self::$a_arr_Footnotes[$l_str_Index];
$l_str_FootnoteText = self::$a_arr_Footnotes[$l_int_Index];
// if footnote is empty, get to the next one
// With combine identical turned on, identicals will be deleted and are skipped:
if (empty($l_str_FootnoteText)) {
continue;
}
// INDEX COLUMN WITH ONE BACKLINK PER TABLE ROW
// Standard behavior appropriate for combine identical TURNED OFF
// generate content of footnote index cell
$l_str_FirstFootnoteIndex = ($l_str_Index + 1);
$l_int_FirstFootnoteIndex = ($l_int_Index + 1);
// wrap each index # in a white-space:nowrap span
$l_str_FootnoteArrowIndex = '<span class="footnote_index_item">';
// wrap the arrow in a @media print { display:hidden } span
$l_str_FootnoteArrowIndex .= '<span class="footnote_index_arrow">' . $l_str_Arrow . '&#x200A;</span>';
// get the index:
$l_str_FootnoteArrowIndex .= MCI_Footnotes_Convert::Index(($l_str_Index + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
// wrap the arrow in a @media print { display:hidden } span (re-used below):
$l_str_FootnoteArrow = '<span class="footnote_index_arrow">';
$l_str_FootnoteArrow .= $l_str_Arrow . '&#x200A;</span>';
// and add it:
$l_str_FootnoteArrowIndex .= $l_str_FootnoteArrow;
// get the footnote index string and
// keep supporting legacy index placeholder:
$l_str_FootnoteIndex = MCI_Footnotes_Convert::Index(($l_str_Index + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
$l_str_FootnoteIndex = MCI_Footnotes_Convert::Index(($l_int_Index + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
// check if it isn't the last footnote in the array
if ($l_str_FirstFootnoteIndex < count(self::$a_arr_Footnotes) && MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) {
// add the footnote index string to arrow-index string:
// (span closing tag is added after the if statement)
$l_str_FootnoteArrowIndex .= $l_str_FootnoteIndex;
// get all footnotes that I haven't passed yet
for ($l_str_CheckIndex = $l_str_FirstFootnoteIndex; $l_str_CheckIndex < count(self::$a_arr_Footnotes); $l_str_CheckIndex++) {
// check if a further footnote is the same as the actual one
if ($l_str_FootnoteText == self::$a_arr_Footnotes[$l_str_CheckIndex]) {
// set the further footnote as empty so it won't be displayed later
self::$a_arr_Footnotes[$l_str_CheckIndex] = "";
// SUPPORT FOR COMBINE IDENTICAL: COMPOSING ENUMERATED BACKLINKS
// add the footnote index to the actual index
$l_str_FootnoteArrowIndex .= ',</span> <span class="footnote_index_item">' . MCI_Footnotes_Convert::Index(($l_str_CheckIndex + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
$l_str_FootnoteIndex .= ', ' . MCI_Footnotes_Convert::Index(($l_str_CheckIndex + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
// NOW FIRST START from zero again, because the above is useless for
// enumerating backlinks. The dedicated template uses a new placeholder:
$l_str_FootnoteId = $l_str_FootnoteIndex;
$l_str_FootnoteBacklinks = '<a id="footnote_plugin_reference_';
$l_str_FootnoteBacklinks .= $l_int_PostId;
$l_str_FootnoteBacklinks .= "_$l_str_FootnoteId";
$l_str_FootnoteBacklinks .= '" class="footnote_backlink" ';
$l_str_FootnoteBacklinks .= 'onclick="footnote_moveToAnchor_' . $l_int_PostId;
$l_str_FootnoteBacklinks .= "('footnote_plugin_tooltip_$l_int_PostId";
$l_str_FootnoteBacklinks .= "_$l_str_FootnoteId');\">";
$l_str_FootnoteBacklinks .= $l_str_FootnoteArrow;
$l_str_FootnoteBacklinks .= $l_str_FootnoteId . '</a>';
// If this is the only footnote with that text, were done.
// CHECK IF COMBINE IDENTICAL IS TURNED ON, and
// check if it isn't the last footnote in the array:
if ($l_int_FirstFootnoteIndex < count(self::$a_arr_Footnotes) && MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) {
// 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++) {
// check if a further footnote is the same as the actual one:
if ($l_str_FootnoteText == self::$a_arr_Footnotes[$l_int_CheckIndex]) {
// if so, set the further footnote as empty so it won't be displayed later:
self::$a_arr_Footnotes[$l_int_CheckIndex] = "";
// HERE GOES THE FRAGMENT IDENTIFIER AND THE BACKLINK TOO:
// add the footnote index to the actual index:
// 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));
// keep on composing the backlinks enumeration:
$l_str_FootnoteBacklinks .= ', <a id="footnote_plugin_reference_';
$l_str_FootnoteBacklinks .= $l_int_PostId;
$l_str_FootnoteBacklinks .= "_$l_str_FootnoteId";
$l_str_FootnoteBacklinks .= '" class="footnote_backlink" ';
$l_str_FootnoteBacklinks .= 'onclick="footnote_moveToAnchor_' . $l_int_PostId;
$l_str_FootnoteBacklinks .= "('footnote_plugin_tooltip_$l_int_PostId";
$l_str_FootnoteBacklinks .= "_$l_str_FootnoteId');\">";
$l_str_FootnoteBacklinks .= $l_str_FootnoteArrow;
$l_str_FootnoteBacklinks .= $l_str_FootnoteId . '</a>';
// below is not used:
$l_str_FootnoteArrowIndex .= ',</span> <span class="footnote_index_item">' . MCI_Footnotes_Convert::Index(($l_int_CheckIndex + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
// this legacy neither:
$l_str_FootnoteIndex .= ', ' . MCI_Footnotes_Convert::Index(($l_int_CheckIndex + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
}
}
}
// close the outer span FOR WHEN COMBINE IDENTICAL IS TURNED OFF:
$l_str_FootnoteArrowIndex .= '</span>';
// replace all placeholders in the template templates/public/reference-container-body.html
// The individual arrow and index placeholders are for backcompat
// replace all placeholders in 'templates/public/reference-container-body.html'
// or in 'templates/public/reference-container-body-combi.html'
// The individual arrow and index placeholders are for backcompat.
$l_obj_Template->replace(
array(
"post_id" => $l_int_PostID,
"id" => MCI_Footnotes_Convert::Index($l_str_FirstFootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)),
"arrow-index" => $l_str_FootnoteArrowIndex,
// placeholder used in all templates:
"text" => $l_str_FootnoteText,
// Legacy placeholders:
// used in standard layout W/O COMBINED FOOTNOTES:
"post_id" => $l_int_PostId,
"id" => MCI_Footnotes_Convert::Index($l_int_FirstFootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)),
"arrow-index" => $l_str_FootnoteArrowIndex,
// used in standard layout WITH COMBINED IDENTICALS TURNED ON:
"backlinks" => $l_str_FootnoteBacklinks,
// Legacy placeholders for use in legacy layout templates:
"arrow" => $l_str_Arrow,
"index" => $l_str_FootnoteIndex,
)
);
// extra line breaks for page source legibility:
$footnote_item_temp = $l_obj_Template->getContent();
$footnote_item_temp .= "\r\n\r\n";
$l_str_Body .= $footnote_item_temp;
$l_str_Body .= $l_obj_Template->getContent();
$l_str_Body .= "\r\n\r\n";
$l_obj_Template->reload();
}
// load template file templates/public/reference-container.html
// load 'templates/public/reference-container.html':
$l_obj_TemplateContainer = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container");
$l_obj_TemplateContainer->replace(
array(
"post_id" => $l_int_PostID,
"post_id" => $l_int_PostId,
"label" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME),
"button-style" => !MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE)) ? 'display: none;' : '',
"style" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE)) ? 'display: none;' : '',

View file

@ -4,9 +4,9 @@
* Created-Date: 15.05.14
* Created-Time: 16:21
* Since: 1.0
* Version: 2.1.1d6
* Version: 2.1.1d7
*
* Last modified: 2020-11-13T1746+0100
* Last modified: 2020-11-14T2229+0100
*/
@ -192,37 +192,42 @@ footnotes
reference-container-body.html
*/
.footnote_plugin_index,
.footnote_plugin_index_combi,
.footnote_plugin_text {
border:none !important;
text-align: left !important;
vertical-align: top !important;
padding: 10px 6px 5px 0 !important;
}
.footnote_backlink,
.footnote_backlink:link,
.footnote_plugin_link,
.footnote_plugin_link:link,
.main-content .footnote_backlink,
.main-content .footnote_backlink:link,
.main-content .footnote_plugin_link,
.main-content .footnote_plugin_link:link {
text-decoration: none !important;
border-bottom: none !important;
}
.footnote_backlink:hover,
.footnote_plugin_index:hover,
.footnote_plugin_text a:hover {
text-decoration: underline !important;
}
.footnote_plugin_index {
cursor: pointer;
overflow-wrap: unset;
word-wrap: unset;
word-wrap: normal !important;
word-break: unset;
word-break: keep-all !important;
max-width: 140px;
width: 2em; /*auto-extending column to fit widest*/
overflow: hidden;
}
.footnote_backlink,
.footnote_index_item {
white-space: nowrap;
}
.footnote_backlink {
cursor: pointer;
}
.footnote_plugin_text {
width: unset; /*unset width of text column to fix site issues*/
}

View file

@ -4,9 +4,9 @@
* Created-Date: 15.05.14
* Created-Time: 16:21
* Since: 1.0
* Version: 2.1.1d6
* Version: 2.1.1d7
*
* Last modified: 2020-11-13T1748+0100
* Last modified: 2020-11-14T2228+0100
*/

View file

@ -4,7 +4,7 @@
Plugin URI: https://wordpress.org/plugins/footnotes/
Description: time to bring footnotes to your website! footnotes are known from offline publishing and everybody takes them for granted when reading a magazine.
Author: Mark Cheret
Version: 2.1.1d6
Version: 2.1.1d7
Author URI: http://cheret.de/plugins/footnotes-2/
Text Domain: footnotes
Domain Path: /languages

View file

@ -80,8 +80,12 @@ Visit this swift write-up from a **footnotes** user by the name of **Southwest**
== Changelog ==
= 2.1.1d7 =
- Bugfix: Combining identical footnotes: fixed dead links
= 2.1.1d6 =
- Bugfix: UI: Tooltips: fixed line breaking for URLs by allowing to break long URLs anywhere
- Bugfix: UI: Tooltips: fixed line breaking for hyperlinked URLs in Unicode-non-compliant user agents
- Update: Libraries: completed minification of jQuery Tools
= 2.1.1d5 =
- Add: UI: Tooltips: Alternative implementation: added CSS animation
@ -98,7 +102,7 @@ Visit this swift write-up from a **footnotes** user by the name of **Southwest**
= 2.1.1d1 =
- Bugfix: Libraries: jQuery UI: load in header not in footer in case it matters for fixing tooltips
- Bugfix: Layout: Ref container: Footnote numbers: disabled bottom border for theme compatibility
- Bugfix: Layout: Ref container: Footnote number links: disabled bottom border for theme compatibility
= 2.1.1d0
- Bugfix: Libraries: jQuery UI: switched to third party to look whether it can fix a broken tooltip display 2020-11-07T1604+0100/2020-11-08T2242+0100
@ -122,7 +126,7 @@ Visit this swift write-up from a **footnotes** user by the name of **Southwest**
= 2.0.6 =
- Update: Autoload / infinite scroll support thanks to @docteurfitness <https://wordpress.org/support/topic/auto-load-post-compatibility-update/>
- Bugfix: Layout: Footnote referrers: deleted vertical align tweaks, for cross-theme and user agent compatibility
- Bugfix: Layout: Reference container: fixed line break behavior in footnote # clusters
- Bugfix: Layout: Reference container: fixed line breaking behavior in footnote # clusters
- Bugfix: Layout: Reference container: auto-extending column to fit widest, to fix display with short note texts
- Bugfix: Layout: Reference container: IDs: slightly increased left padding
- Bugfix: Translations: fixed spelling error and erroneously changed word in en_GB and en_US

View file

@ -0,0 +1,8 @@
<tr>
<td
class="footnote_plugin_index_combi"
>[[backlinks]]</td>
<td
class="footnote_plugin_text"
>[[text]]</td>
</tr>

View file

@ -3,6 +3,7 @@
id="footnote_plugin_reference_[[post_id]]_[[id]]"
class="footnote_plugin_index"
onclick="footnote_moveToAnchor_[[post_id]]('footnote_plugin_tooltip_[[post_id]]_[[id]]');"
style="cursor: pointer;"
><a
class="footnote_plugin_link"
>[[arrow-index]]</a