Skip to content

Commit

Permalink
Make the number the back link.
Browse files Browse the repository at this point in the history
  • Loading branch information
kebbet committed Sep 24, 2021
1 parent 4f285bc commit a636244
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion kebbet-shortcode-footnote.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Kebbet plugins - Shortcode for footnotes
* Plugin URI: https://github.com/kebbet/kebbet-shortcode-footnotes
* Description: Adds a shortcode that creates footnotes in the content and a footnote list at the end of the_content.
* Version: 20210922.1
* Version: 20210924.1
* Author: Erik Betshammar
* Author URI: https://verkan.se
* Text Domain kebbet-shortcode-footnotes
Expand Down
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Use like this `[fn]The footnote content[/fn]`. Automatic numbering without any o
- `kebbet_shortcode_footnote_list_title` Modify the list header.
- `kebbet_shortcode_footnote_list_title_tag` Change the title tag (header level) for the list.
- `kebbet_shortcode_footnote_list_back_link` Enable or disable link back to source.
- `kebbet_shortcode_footnote_list_back_symbol` Change the symbol in the back link.
- `kebbet_shortcode_footnote_list_wrap_class` Modify the wrapper class for the list section.

## Author
Expand Down
6 changes: 4 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: footnote,footnotes
Requires at least: 5.8
Tested up to: 5.8.1
Requires PHP: 7.0
Stable tag: 20210922.1
Stable tag: 20210924.1
License: ?

Adds a shortcode that creates footnotes in the_content and a footnote list at the end of the_content.
Expand All @@ -23,10 +23,12 @@ Use like this `[fn]The footnote content[/fn]`. Automatic numbering without any o
* `kebbet_shortcode_footnote_list_title` Modify the list header.
* `kebbet_shortcode_footnote_list_title_tag` Change the title tag (header level) for the list.
* `kebbet_shortcode_footnote_list_back_link` Enable or disable link back to source.
* `kebbet_shortcode_footnote_list_back_symbol` Change the symbol in the back link.
* `kebbet_shortcode_footnote_list_wrap_class` Modify the wrapper class for the list section.

== Changelog ==
= 20210924.1 =
* Makes the list number a back link.

= 20210922.1 =
* Separation of logics.

Expand Down
9 changes: 5 additions & 4 deletions src/listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function display( $content ) {
$title = apply_filters( 'kebbet_shortcode_footnote_list_title', __( 'Footnotes', 'kebbet-shortcode-footnotes' ) );
$title_tag = apply_filters( 'kebbet_shortcode_footnote_list_title_tag', 'h3' );
$wrap_class = apply_filters( 'kebbet_shortcode_footnote_list_wrap_class', 'footnotes-wrap' );
$back_symbol = apply_filters( 'kebbet_shortcode_footnote_list_back_symbol', '↑' );

if ( is_admin() ) {
return $content;
Expand All @@ -36,14 +35,16 @@ function display( $content ) {

foreach ( $notes_content as $note_number => $footnote_content ) {
$footnote_content = \kebbet\footnotes\helpers\strip_paragraph( $footnote_content );
$footnote_content = '<span>' . $footnote_content . '</span>';
$reference = \kebbet\footnotes\helpers\link_id( $note_number, true, false );

if ( true === \kebbet\footnotes\settings\back_link() ) {
$source_link = \kebbet\footnotes\helpers\link_id( $note_number, false, true );
$footnote_content = '<a href="' . esc_url( $source_link ) . '">' . esc_attr( $back_symbol ) . '</a> ' . $footnote_content;
$source_link = \kebbet\footnotes\helpers\link_id( $note_number, false, true );
$wrap_class .= ' back-links';
$footnote_content = '<a class="back-link" href="' . esc_url( $source_link ) . '">' . esc_attr( $note_number ) . '</a> ' . $footnote_content;
}

$notes_list .= '<li id="' . esc_attr( $reference ) . '"><span>' . $footnote_content . '</span></li>';
$notes_list .= '<li id="' . esc_attr( $reference ) . '">' . $footnote_content . '</li>';
}

$list_content = '<div class="' . esc_attr( $wrap_class ) . '">';
Expand Down

0 comments on commit a636244

Please sign in to comment.