| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Easy Footnotes |
| 4 | 4 | * Plugin URI: http://jasonyingling.me/easy-footnotes-wordpress/ |
| 5 | 5 | * Description: Easily add footnotes to your posts with a simple shortcode. |
| 6 | - * Version: 1.0.4 | |
| 6 | + * Version: 1.0.5 | |
| 7 | 7 | * Author: Jason Yingling |
| 8 | 8 | * Author URI: http://jasonyingling.me |
| 9 | 9 | * License: GPL2 |
| 10 | 10 | */ |
| @@ -29,8 +29,9 @@ | ||
| 29 | 29 | |
| 30 | 30 | // Add label option using add_option if it does not already exist |
| 31 | 31 | public $footnotes = array(); |
| 32 | 32 | public $footnoteCount = 0; |
| 33 | + public $prevPost; | |
| 33 | 34 | |
| 34 | 35 | public function __construct() { |
| 35 | 36 | add_shortcode( 'note', array($this, 'easy_footnote_shortcode') ); |
| 36 | 37 | add_filter('the_content', array($this, 'easy_footnote_after_content'), 999); |
| @@ -55,13 +56,18 @@ | ||
| 55 | 56 | |
| 56 | 57 | extract (shortcode_atts(array( |
| 57 | 58 | ), $atts)); |
| 58 | 59 | |
| 59 | - $this->easy_footnote_count($this->footnoteCount); | |
| 60 | + $this->easy_footnote_count($this->footnoteCount, get_the_ID()); | |
| 60 | 61 | $this->easy_footnote_content($content); |
| 61 | 62 | |
| 62 | - $footnoteContent = "<span id='easy-footnote-".$this->footnoteCount."' class='easy-footnote-margin-adjust'></span><span class='easy-footnote'><a href='#easy-footnote-bottom-".$this->footnoteCount."' title='$content'><sup>$this->footnoteCount</sup></a></span>"; | |
| 63 | + if (is_singular() && is_main_query()) { | |
| 64 | + $footnoteLink = '#easy-footnote-bottom-'.$this->footnoteCount; | |
| 65 | + } else { | |
| 66 | + $footnoteLink = get_permalink(get_the_ID()).'#easy-footnote-bottom-'.$this->footnoteCount; | |
| 67 | + } | |
| 63 | 68 | |
| 69 | + $footnoteContent = "<span id='easy-footnote-".$this->footnoteCount."' class='easy-footnote-margin-adjust'></span><span class='easy-footnote'><a href='".$footnoteLink."' title='$content'><sup>$this->footnoteCount</sup></a></span>"; | |
| 64 | 70 | |
| 65 | 71 | return $footnoteContent; |
| 66 | 72 | } |
| 67 | 73 | |
| @@ -70,9 +76,15 @@ | ||
| 70 | 76 | |
| 71 | 77 | return $this->footnotes; |
| 72 | 78 | } |
| 73 | 79 | |
| 74 | - public function easy_footnote_count($count) { | |
| 80 | + public function easy_footnote_count($count, $currentPost) { | |
| 81 | + if ($this->prevPost != $currentPost) { | |
| 82 | + $count = 0; | |
| 83 | + } | |
| 84 | + | |
| 85 | + $this->prevPost = $currentPost; | |
| 86 | + | |
| 75 | 87 | $count++; |
| 76 | 88 | |
| 77 | 89 | $this->footnoteCount = $count; |
| 78 | 90 | |
| @@ -80,9 +92,9 @@ | ||
| 80 | 92 | } |
| 81 | 93 | |
| 82 | 94 | // Calculate reading time by running it through the_content |
| 83 | 95 | public function easy_footnote_after_content($content) { |
| 84 | - if (is_single()) { | |
| 96 | + if (is_singular() && is_main_query()) { | |
| 85 | 97 | $footnotesInsert = $this->footnotes; |
| 86 | 98 | global $footnoteCopy; |
| 87 | 99 | |
| 88 | 100 | foreach ($footnotesInsert as $count => $footnote) { |