diff -uNr a/mp-wp/manifest b/mp-wp/manifest --- a/mp-wp/manifest 52ca7411d3f3a06cd9ba81db190ad147d74702f8033b36f259cf8a59f62fd30d72a1dfde3b286519575694ed43a513ab1a317fb01b0868bc3ba82a3521d5e934 +++ b/mp-wp/manifest ccc02bf85864743a8406d21f78329bf98d638fde7b544773ac9ddc15a51c10e0edf00bbc3e44e390962530f8dc988ab865445a72e9ec419072b4793e3f3f9fcc @@ -1 +1,2 @@ 526913 mp-wp_genesis hanbot The historical MP-WP: WordPress with better antispam, SVG-enated images, and very basic themes, with a view towards minimalizing Mullenweg & Co.'s crud. +558366 mp-wp_add-footnotes-and-textselectionjs billymg Add the footnotes and text selection features to mp-wp as seen on Trilema and other republican blogs diff -uNr a/mp-wp/wp-content/plugins/footnotes.php b/mp-wp/wp-content/plugins/footnotes.php --- a/mp-wp/wp-content/plugins/footnotes.php false +++ b/mp-wp/wp-content/plugins/footnotes.php 8e2449d4ac26ea05f080cec9d025ef8a8585221ee30da439b37ff1578d084e1c63cbe3f89e3d6868c19d0fa9f73a9af99b444251e7a854f6c87e316628d94859 @@ -0,0 +1,346 @@ +styles = array( + 'decimal' => '1,2...10', + 'decimal-leading-zero' => '01, 02...10', + 'lower-alpha' => 'a,b...j', + 'upper-alpha' => 'A,B...J', + 'lower-roman' => 'i,ii...x', + 'upper-roman' => 'I,II...X', + 'symbol' => 'Symbol' + ); + + // Define default options + $this->default_options = array('superscript'=>true, + 'pre_backlink'=>' [', + 'backlink'=>'↩', + 'post_backlink'=>']', + 'pre_identifier'=>'', + 'list_style_type'=>'decimal', + 'list_style_symbol'=>'†', + 'post_identifier'=>'', + 'pre_footnotes'=>'', + 'post_footnotes'=>'', + 'style_rules'=>'ol.footnotes{font-size:0.8em; color:#666666;}', + 'no_display_home'=>false, + 'no_display_archive'=>false, + 'no_display_date'=>false, + 'no_display_category'=>false, + 'no_display_search'=>false, + 'no_display_feed'=>false, + 'combine_identical_notes'=>false, + 'priority'=>11, + 'version'=>WP_FOOTNOTES_VERSION); + + // Get the current settings or setup some defaults if needed + if (!$this->current_options = get_option('swas_footnote_options')){ + $this->current_options = $this->default_options; + update_option('swas_footnote_options', $this->current_options); + } else { + // Set any unset options + if ($this->current_options['version'] != WP_FOOTNOTES_VERSION) { + foreach ($this->default_options as $key => $value) { + if (!isset($this->current_options[$key])) { + $this->current_options[$key] = $value; + } + } + $this->current_options['version'] = WP_FOOTNOTES_VERSION; + update_option('swas_footnote_options', $this->current_options); + } + } + +/* + if (!empty($_POST['save_options'])){ + $footnotes_options['superscript'] = (array_key_exists('superscript', $_POST)) ? true : false; + $footnotes_options['pre_backlink'] = $_POST['pre_backlink']; + $footnotes_options['backlink'] = $_POST['backlink']; + $footnotes_options['post_backlink'] = $_POST['post_backlink']; + $footnotes_options['pre_identifier'] = $_POST['pre_identifier']; + $footnotes_options['list_style_type'] = $_POST['list_style_type']; + $footnotes_options['post_identifier'] = $_POST['post_identifier']; + $footnotes_options['list_style_symbol'] = $_POST['list_style_symbol']; + $footnotes_options['pre_footnotes'] = stripslashes($_POST['pre_footnotes']); + $footnotes_options['post_footnotes'] = stripslashes($_POST['post_footnotes']); + $footnotes_options['style_rules'] = stripslashes($_POST['style_rules']); + $footnotes_options['no_display_home'] = (array_key_exists('no_display_home', $_POST)) ? true : false; + $footnotes_options['no_display_archive'] = (array_key_exists('no_display_archive', $_POST)) ? true : false; + $footnotes_options['no_display_date'] = (array_key_exists('no_display_date', $_POST)) ? true : false; + $footnotes_options['no_display_category'] = (array_key_exists('no_display_category', $_POST)) ? true : false; + $footnotes_options['no_display_search'] = (array_key_exists('no_display_search', $_POST)) ? true : false; + $footnotes_options['no_display_feed'] = (array_key_exists('no_display_feed', $_POST)) ? true : false; + $footnotes_options['combine_identical_notes'] = (array_key_exists('combine_identical_notes', $_POST)) ? true : false; + $footnotes_options['priority'] = $_POST['priority']; + update_option('swas_footnote_options', $footnotes_options); + }elseif(!empty($_POST['reset_options'])){ + update_option('swas_footnote_options', ''); + update_option('swas_footnote_options', $this->default_options); + } +*/ + + // Hook me up + add_action('the_content', array($this, 'process'), $this->current_options['priority']); + add_action('admin_menu', array($this, 'add_options_page')); // Insert the Admin panel. + add_action('wp_head', array($this, 'insert_styles')); + } + + /** + * Searches the text and extracts footnotes. + * Adds the identifier links and creats footnotes list. + * @param $data string The content of the post. + * @return string The new content with footnotes generated. + */ + function process($data) { + global $post; + + // Check for and setup the starting number + $start_number = (preg_match("||",$data,$start_number_array)==1) ? $start_number_array[1] : 1; + + // Regex extraction of all footnotes (or return if there are none) + if (!preg_match_all("/(".preg_quote(WP_FOOTNOTES_OPEN)."|)(.*)(".preg_quote(WP_FOOTNOTES_CLOSE)."|<\/footnote>)/Us", $data, $identifiers, PREG_SET_ORDER)) { + return $data; + } + + // Check whether we are displaying them or not + $display = true; + if ($this->current_options['no_display_home'] && is_home()) $display = false; + if ($this->current_options['no_display_archive'] && is_archive()) $display = false; + if ($this->current_options['no_display_date'] && is_date()) $display = false; + if ($this->current_options['no_display_category'] && is_category()) $display = false; + if ($this->current_options['no_display_search'] && is_search()) $display = false; + if ($this->current_options['no_display_feed'] && is_feed()) $display = false; + + $footnotes = array(); + + // Check if this post is using a different list style to the settings + if ( array_key_exists(get_post_meta($post->ID, 'footnote_style', true), $this->styles) ) { + $style = get_post_meta($post->ID, 'footnote_style', true); + } else { + $style = $this->current_options['list_style_type']; + } + + // Create 'em + for ($i=0; $icurrent_options['combine_identical_notes']){ + for ($j=0; $j $value) { + $id_id = "identifier_".$key."_".$post->ID; + $id_num = ($style == 'decimal') ? $value['use_footnote']+$start_number : $this->convert_num($value['use_footnote']+$start_number, $style, count($footnotes)); + $id_href = ( ($use_full_link) ? get_permalink($post->ID) : '' ) . "#footnote_".$value['use_footnote']."_".$post->ID; + +// $id_title = str_replace('"', """, htmlentities(strip_tags($value['text']), ENT_QUOTES, 'UTF-8')); + + $id_title = str_replace('"', '`', strip_tags($value['text'])); + $id_replace = $this->current_options['pre_identifier'].''.$id_num.''.$this->current_options['post_identifier']; + if ($this->current_options['superscript']) $id_replace = ''.$id_replace.''; + if ($display) $data = substr_replace($data, $id_replace, strpos($data,$value[0]),strlen($value[0])); + else $data = substr_replace($data, '', strpos($data,$value[0]),strlen($value[0])); + } + + // Display footnotes + if ($display) { + $start = ($start_number != 1) ? 'start="'.$start_number.'" ' : ''; + $data = $data.$this->current_options['pre_footnotes']; + + $data = $data . '
    '; + foreach ($footnotes as $key => $value) { + $data = $data.'
  1. current_options['list_style_type']) { + $data = $data . ' style="list-style-type:' . $style . ';"'; + } + $data = $data . '>'; + if ($style == 'symbol') { + $data = $data . '' . $this->convert_num($key+$start_number, $style, count($footnotes)) . ' '; + } + $data = $data.$value['text']; + if (!is_feed()){ + foreach($value['identifiers'] as $identifier){ + $data = $data.$this->current_options['pre_backlink'].''.$this->current_options['backlink'].''.$this->current_options['post_backlink']; + } + } + $data = $data . '
  2. '; + } + $data = $data . '
' . $this->current_options['post_footnotes']; + } + return $data; + } + + /** + * Really insert the options page. + */ + function footnotes_options_page() { + $this->current_options = get_option('swas_footnote_options'); + foreach ($this->current_options as $key=>$setting) { + $new_setting[$key] = htmlentities($setting); + } + $this->current_options = $new_setting; + unset($new_setting); + include (dirname(__FILE__) . '/options.php'); + } + + /** + * Insert the options page into the admin area. + */ + function add_options_page() { + // Add a new menu under Options: + add_options_page('Footnotes', 'Footnotes', 8, __FILE__, array($this, 'footnotes_options_page')); + } + + function upgrade_post($data){ + $data = str_replace('',WP_FOOTNOTES_OPEN,$data); + $data = str_replace('',WP_FOOTNOTES_CLOSE,$data); + return $data; + } + + function insert_styles(){ + ?> + + roman($num, 'lower'); + case 'upper-roman' : + return $this->roman($num); + case 'lower-alpha' : + return $this->alpha($num, 'lower'); + case 'upper-alpha' : + return $this->alpha($num); + case 'symbol' : + $sym = ''; + for ($i = 0; $i<$num; $i++) { + $sym .= $this->current_options['list_style_symbol']; + } + return $sym; + } + } + + + /** + * Convert to a roman numeral. + * + * Thanks to Indi.in.the.Wired for the improved algorithm. + * http://plugins.trac.wordpress.org/ticket/1177 + * + * @param int $num The number to convert. + * @param string $case Upper or lower case. + * @return string The roman numeral + */ + function roman($num, $case= 'upper'){ + $num = (int) $num; + $conversion = array('M'=>1000, 'CM'=>900, 'D'=>500, 'CD'=>400, 'C'=>100, 'XC'=>90, 'L'=>50, 'XL'=>40, 'X'=>10, 'IX'=>9, 'V'=>5, 'IV'=>4, 'I'=>1); + $roman = ''; + + foreach ($conversion as $r => $d){ + $roman .= str_repeat($r, (int)($num / $d)); + $num %= $d; + } + + return ($case == 'lower') ? strtolower($roman) : $roman; + } + + function alpha($num, $case='upper'){ + $j = 1; + for ($i = 'A'; $i <= 'ZZ'; $i++){ + if ($j == $num){ + if ($case == 'lower') + return strtolower($i); + else + return $i; + } + $j++; + } + } +} diff -uNr a/mp-wp/wp-content/themes/default/footer.php b/mp-wp/wp-content/themes/default/footer.php --- a/mp-wp/wp-content/themes/default/footer.php c69c39dca4bf002d3325d81f9d9cb4fd613ab63e062a8075f2dd1480f2b6945ad324c5960aa976aba2dad2340c91cbfde7422723a4c578be897fbb58beeda5c8 +++ b/mp-wp/wp-content/themes/default/footer.php f73f685a504e7d9267eae21fe6186e83a7a640e732e3c765d65c63fd8704d485b4ae1487cec8889a5394eb36a505f5e2a278ed8a708a92d0499998470b3b167f @@ -22,5 +22,6 @@ + diff -uNr a/mp-wp/wp-content/themes/default/page.php b/mp-wp/wp-content/themes/default/page.php --- a/mp-wp/wp-content/themes/default/page.php 3cf20c61002a157b855962c2354bba641dd4e373bb0ed31a598ad28a56d927191c453c8d8679ff179c0d8d9043838f7c168dcbd9af67c0eaff832b7e21b166b7 +++ b/mp-wp/wp-content/themes/default/page.php 662fa8de62b303463ec65e384051b4eeb2d8ba2328859979b800c2d1f0b885f6b1bedbee756355fd13e68ce0f5e491f229bb2184f0fed9cb92f328f5a5661631 @@ -9,15 +9,16 @@
-
-

-
- Read the rest of this page »

'); ?> - - '

Pages: ', 'after' => '

', 'next_or_number' => 'number')); ?> + +
+

+
+ Read the rest of this page »

'); ?> + '

Pages: ', 'after' => '

', 'next_or_number' => 'number')); ?> +
-
+ ', '

'); ?>
diff -uNr a/mp-wp/wp-content/themes/default/selection-magic.php b/mp-wp/wp-content/themes/default/selection-magic.php --- a/mp-wp/wp-content/themes/default/selection-magic.php false +++ b/mp-wp/wp-content/themes/default/selection-magic.php 01e83a62726bef4232415b4841942427f31063ac2ddfbab0048d5f5b63da00ec2eccacf3fc30cc71997e304969960f5774037e1245e1f0c4e9853d7d3b6450e7 @@ -0,0 +1,135 @@ + diff -uNr a/mp-wp/wp-content/themes/default/single.php b/mp-wp/wp-content/themes/default/single.php --- a/mp-wp/wp-content/themes/default/single.php c71110f12fde3ff9fb14d3e30ed6dc689c1e726e8b02847626a97b9718186a11ae9b84b63df5dd00ef0fca8a55f44c50afdc0341a1125c3720b839f14189eead +++ b/mp-wp/wp-content/themes/default/single.php 20f607b36bc9e82f8481aedccc77fd7029c86340e5f617020f5d6f5eca1c57580fcd749907338f40395eb2eb2160fe3534a0fa6466acaeeacb0123bb96cc5e62 @@ -16,49 +16,51 @@
-
id="post-"> -

+ +
id="post-"> +

+ +
+ Read the rest of this entry »

'); ?> + + '

Pages: ', 'after' => '

', 'next_or_number' => 'number')); ?> + Tags: ', ', ', '

'); ?> + +
- Read the rest of this entry »

'); ?> + - '

Pages: ', 'after' => '

', 'next_or_number' => 'number')); ?> - Tags: ', ', ', '

'); ?> - - +
+

+
-
+