Changeset 422017
- Timestamp:
- 08/11/2011 06:38:06 AM (15 years ago)
- Location:
- fd-footnotes/trunk
- Files:
-
- 3 added
- 2 edited
-
fdfootnotes.js (added)
-
fdfootnotes.php (modified) (4 diffs)
-
languages (added)
-
languages/fdfootnotes.pot (added)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fd-footnotes/trunk/fdfootnotes.php
r372708 r422017 5 5 Description: Elegant and easy to use footnotes 6 6 Author: John Watson 7 Version: 1. 217 Version: 1.3 8 8 Author URI: http://flagrantdisregard.com 9 9 … … 27 27 */ 28 28 29 define('FDFOOTNOTE_TEXTDOMAIN', 'fdfootnote'); 30 31 if (function_exists('load_plugin_textdomain')) { 32 load_plugin_textdomain(FDFOOTNOTE_TEXTDOMAIN, false, dirname(plugin_basename(__FILE__)).'/languages' ); 33 } 34 35 add_action('admin_menu', 'fdfootnote_config_page'); 36 add_action('wp_enqueue_scripts', 'fdfootnote_enqueue_scripts'); 37 38 function fdfootnote_enqueue_scripts() { 39 if (is_admin()) return; 40 41 wp_enqueue_script('jquery'); 42 43 wp_register_script('fdfootnote_script', get_bloginfo('wpurl').'/'.PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)).'/fdfootnotes.js', array(), '1.3'); 44 wp_enqueue_script('fdfootnote_script'); 45 } 46 47 function fdfootnote_config_page() { 48 global $wpdb; 49 if ( function_exists('add_submenu_page') ) 50 add_submenu_page('options-general.php', 51 __('Footnotes', FDFOOTNOTE_TEXTDOMAIN), 52 __('Footnotes', FDFOOTNOTE_TEXTDOMAIN), 53 'manage_options', __FILE__, 'fdfootnote_conf'); 54 } 55 56 function fdfootnote_conf() { 57 $options = get_option('fdfootnote'); 58 59 if (!isset($options['fdfootnote_collapse'])) $options['fdfootnote_collapse'] = 0; 60 61 $updated = false; 62 if ( isset($_POST['submit']) ) { 63 check_admin_referer('fdfootnote', 'fdfootnote-admin'); 64 65 if (isset($_POST['fdfootnote_collapse'])) { 66 $options['fdfootnote_collapse'] = 1; 67 } else { 68 $options['fdfootnote_collapse'] = 0; 69 } 70 71 if (isset($_POST['fdfootnote_single'])) { 72 $options['fdfootnote_single'] = 1; 73 } else { 74 $options['fdfootnote_single'] = 0; 75 } 76 77 update_option('fdfootnote', $options); 78 79 $updated = true; 80 } 81 ?> 82 <div class="wrap"> 83 <?php 84 if ($updated) { 85 echo "<div id='message' class='updated fade'><p>"; 86 _e('Configuration updated.', FDFOOTNOTE_TEXTDOMAIN); 87 echo "</p></div>"; 88 } 89 ?> 90 <h2><?php _e('Footnotes Configuration', FDFOOTNOTE_TEXTDOMAIN); ?></h2> 91 <form action="" method="post" id="fdfootnote-conf"> 92 93 <p> 94 <input id="fdfootnote_single" name="fdfootnote_single" type="checkbox" value="1"<?php if ($options['fdfootnote_single']==1) echo ' checked'; ?> /> 95 <label for="fdfootnote_single"><?php _e('Only show footnotes on single post/page', FDFOOTNOTE_TEXTDOMAIN); ?></label> 96 </p> 97 98 <p> 99 <input id="fdfootnote_collapse" name="fdfootnote_collapse" type="checkbox" value="1"<?php if ($options['fdfootnote_collapse']==1) echo ' checked'; ?> /> 100 <label for="fdfootnote_collapse"><?php _e('Collapse footnotes until clicked', FDFOOTNOTE_TEXTDOMAIN); ?></label> 101 </p> 102 103 <p class="submit" style="text-align: left"><?php wp_nonce_field('fdfootnote', 'fdfootnote-admin'); ?><input type="submit" name="submit" value="<?php _e('Save', FDFOOTNOTE_TEXTDOMAIN); ?> »" /></p> 104 </form> 105 </div> 106 <?php 107 } 108 29 109 // Converts footnote markup into actual footnotes 30 110 function fdfootnote_convert($content) { 111 $options = get_option('fdfootnote'); 112 $collapse = 0; 113 $single = 0; 114 $linksingle = false; 115 if (isset($options['fdfootnote_collapse'])) $collapse = $options['fdfootnote_collapse']; 116 if (isset($options['fdfootnote_single'])) $single = $options['fdfootnote_single']; 117 if (!is_page() && !is_single() && $single) $linksingle = true; 118 31 119 $post_id = get_the_ID(); 32 120 … … 38 126 $notes[$n] = $note; 39 127 40 $content = str_replace($fn, "<sup class='footnote'><a href='#fn-$post_id-$n' id='fnref-$post_id-$n'>$n</a></sup>", $content); 128 if ($linksingle) $singleurl = get_permalink(); 129 130 $content = str_replace($fn, "<sup class='footnote'><a href='$singleurl#fn-$post_id-$n' id='fnref-$post_id-$n' onclick='return fdfootnote_show($post_id)'>$n</a></sup>", $content); 41 131 $n++; 42 132 } … … 48 138 // ***************************************************************************************************** 49 139 50 $content .= "<div class='footnotes'>"; 51 $content .= "<div class='footnotedivider'></div>"; 52 $content .= "<ol>"; 53 for($i=1; $i<$n; $i++) { 54 $content .= "<li id='fn-$post_id-$i'>$notes[$i] <span class='footnotereverse'><a href='#fnref-$post_id-$i'>↩</a></span></li>"; 140 if (!$linksingle) { 141 $content .= "<div class='footnotes' id='footnotes-$post_id'>"; 142 $content .= "<div class='footnotedivider'></div>"; 143 144 if ($collapse) { 145 $content .= "<a href='#' onclick='return fdfootnote_togglevisible($post_id)' class='footnotetoggle'>"; 146 $content .= "<span class='footnoteshow'>".sprintf(_n('Show %d footnote', 'Show %d footnotes', $n-1, FDFOOTNOTE_TEXTDOMAIN), $n-1)."</span>"; 147 $content .= "</a>"; 148 149 $content .= "<ol style='display: none'>"; 150 } else { 151 $content .= "<ol>"; 152 } 153 for($i=1; $i<$n; $i++) { 154 $content .= "<li id='fn-$post_id-$i'>$notes[$i] <span class='footnotereverse'><a href='#fnref-$post_id-$i'>↩</a></span></li>"; 155 } 156 $content .= "</ol>"; 157 $content .= "</div>"; 55 158 } 56 $content .= "</ol>";57 $content .= "</div>";58 159 } 59 160 -
fd-footnotes/trunk/readme.txt
r372708 r422017 4 4 Tags: posts, writing, editing, footnotes, endnotes, formatting 5 5 Requires at least: 2.0 6 Tested up to: 3. 1.16 Tested up to: 3.2.1 7 7 Stable tag: trunk 8 8 … … 32 32 *Note:* Do not include square brackets [] inside the footnotes themselves. 33 33 34 *Note:* Footnote numbers don ’t need to be unique but it is recommended,34 *Note:* Footnote numbers don't need to be unique but it is recommended, 35 35 especially if the text is identical for multiple footnotes. If you have 36 36 multiple footnotes with the exact same text and number then you’ll get weird … … 39 39 == Installation == 40 40 41 1. Copy fdfootnotes.phpinto wp-content/plugins41 1. Copy the fd-footnotes directory into wp-content/plugins 42 42 1. Activate the plugin through the 'Plugins' menu in WordPress 43 43 … … 48 48 == Changelog == 49 49 50 = 1.3 = 51 * Added option for collapsing footnotes into a single line until manually 52 expanded. 53 * Added option to only show footnotes when viewing a single post/page. 54 * Added translation files. Send .po translation files to me for inclusion 55 in future releasse. Thanks. 56 50 57 = 1.21 = 51 58 * Fixed problem where sometimes WordPress would not correctly add the closing
Note: See TracChangeset
for help on using the changeset viewer.