PluginProbe
Easy Footnotes / 1.0.5
Easy Footnotes v1.0.5
trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.2 All 32 releases
← All changes | easy-footnotes.php +17 -5 1.0.41.0.5 View file →
@@ -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) {