Changeset 835324
- Timestamp:
- 01/09/2014 07:05:20 AM (12 years ago)
- Location:
- side-matter
- Files:
-
- 10 edited
-
. (modified) (1 prop)
-
assets/screenshot-1.png (modified) (previous)
-
assets/screenshot-2.png (modified) (previous)
-
trunk/css/side-matter-admin.css (modified) (5 diffs)
-
trunk/css/side-matter.css (modified) (2 diffs)
-
trunk/js/side-matter-admin.js (modified) (6 diffs)
-
trunk/js/side-matter.js (modified) (2 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/side-matter.php (modified) (29 diffs)
-
trunk/uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
side-matter
-
Property
svn:ignore
set to
.DS_Store
-
Property
svn:ignore
set to
-
side-matter/trunk/css/side-matter-admin.css
r770431 r835324 1 1 /* 2 2 side-matter-admin.css 3 Version 1. 33 Version 1.4 4 4 5 5 Plugin: Side Matter … … 10 10 11 11 .side-matter-preview { 12 display: inline-block;13 12 background: #eee; 14 13 border: 1px solid #bbb; 15 14 border-radius: 2px; 16 box-shadow: inset rgba(0,0,0,0.15) 1px 1px 1px; 15 padding: 1.25em 2em; 16 width: 32em; 17 17 -webkit-touch-callout: none; 18 18 -webkit-user-select: none; … … 28 28 29 29 .side-matter-preview-dark { 30 background-color: #444; 31 box-shadow: inset rgba(0,0,0,0.3) 1px 1px 5px; 32 } 33 34 .side-matter-preview-content { 35 padding: 1.25em 2em; 36 font-size: 1.1em; 37 } 38 39 .side-matter-preview-dark > .side-matter-preview-content { 40 color: #ccc; 30 background-color: #333; 31 color: #bbb; 41 32 } 42 33 43 34 .side-matter-preview-main { 44 vertical-align: top;45 display: inline-block;46 padding-right: 5em;47 35 width: 20em; 36 padding-right: 2em; 37 float: left; 38 } 39 40 .side-matter-preview-main, .side-matter-preview-side { 41 line-height: 1.6em; 48 42 } 49 43 50 44 .side-matter-preview-side { 51 vertical-align: top;52 display: inline-block;53 45 width: 10em; 46 float: left; 47 font-size: small; 54 48 } 55 49 56 .side-matter-preview-list, .side-matter-preview-note, .side-matter-preview-text { 57 font-size: inherit; 58 margin: 0; 59 padding: 0; 60 } 61 62 .side-matter-preview-ref { 50 .side-matter-preview-sup { 63 51 position: relative; 64 52 top: -0.5em; … … 66 54 font-size: 0.75em; 67 55 line-height: 0; 56 } 57 58 .side-matter-preview-clear { 59 clear: both; 68 60 } 69 61 … … 75 67 color: #333; 76 68 } 69 70 .note-adjust-dir { 71 margin-left: 8px; 72 } -
side-matter/trunk/css/side-matter.css
r770431 r835324 1 1 /* 2 2 side-matter.css 3 Version 1. 33 Version 1.4 4 4 5 5 Plugin: Side Matter … … 10 10 11 11 /* 12 Since version 0.9, Side Matter's options menu has featured a color picker for setting note text and figures in custom colors. For many users, this will obviate the need to modify element styles using `side-matter.css` or a custom CSS plugin. However, aguide to further styling Side Matter elements with CSS may be found in `readme.txt` and online at <http://wordpress.org/extend/plugins/side-matter/other_notes/>.12 A guide to further styling Side Matter elements with CSS may be found in `readme.txt` and online at <http://wordpress.org/extend/plugins/side-matter/other_notes/>. 13 13 14 The below is default Side Matter CSS. These rules have low specificity, and are easily superseded by theme or user CSS.14 The below is default Side Matter CSS. These rules have low specificity, and are easily superseded by theme or user style settings. 15 15 */ 16 16 17 a.side-matter -ref:link,18 a.side-matter -ref:visited,19 a.side-matter -ref:hover,20 a.side-matter -ref:active {17 a.side-matter:link, 18 a.side-matter:visited, 19 a.side-matter:hover, 20 a.side-matter:active { 21 21 text-decoration: none; 22 22 } -
side-matter/trunk/js/side-matter-admin.js
r770431 r835324 1 1 /* 2 2 side-matter-admin.js 3 Version 1. 33 Version 1.4 4 4 5 5 Plugin: Side Matter … … 35 35 $(document).ready(function() { // Assign initial values, position note in preview field, and load color pickers 36 36 37 if ($('.side-matter-use-effects').prop('checked')) $('.side-matter-preview-list').css('opacity', 0); 38 37 39 fieldIsDark = 0; 38 40 figureColor = $('.side-matter-figure-color').val(); 39 41 textColor = $('.side-matter-text-color').val(); 40 41 placeNote();42 42 43 43 $('.side-matter-figure-color').wpColorPicker(figureOptions); … … 51 51 } 52 52 53 }); 54 55 $(window).load(function() { 56 for (i = 1; i <= 2; i++) placeNote(); 57 if ($('.side-matter-use-effects').prop('checked')) $('.side-matter-preview-list').fadeTo(360, 1); 53 58 }); 54 59 … … 65 70 var figureOptions = { 66 71 change: function(event, ui) { 67 $('.side-matter-preview-ref,.side-matter-preview-note').css('color', ui.color.toString());68 },69 palettes: false72 $('.side-matter-preview-ref,.side-matter-preview-note').css('color', ui.color.toString()); 73 }, 74 palettes: false 70 75 }; 71 76 72 77 var textOptions = { 73 78 change: function(event, ui) { 74 $('.side-matter-preview-text').css('color', ui.color.toString());75 },76 palettes: false79 $('.side-matter-preview-text').css('color', ui.color.toString()); 80 }, 81 palettes: false 77 82 }; 78 83 … … 107 112 108 113 $('.side-matter-figure-style').change(function() { // When user selects a figure style, update preview field 109 $('.side-matter-preview- ref').text(figures[$(this).val()]);114 $('.side-matter-preview-sup').text(figures[$(this).val()]); 110 115 $('.side-matter-preview-note').css('listStyleType', $(this).val()); 116 placeNote(); 111 117 }); 112 118 … … 117 123 }); 118 124 125 $('label[for^="side-matter-pages-active"]').click(function() { 126 if ($('.side-matter-pages-active-front').prop('checked') && $('.side-matter-pages-active-home').prop('checked') && $('.side-matter-pages-active-page').prop('checked') && $('.side-matter-pages-active-post').prop('checked')) { 127 $('.side-matter-pages-active-front,.side-matter-pages-active-home,.side-matter-pages-active-post,.side-matter-pages-active-page').attr('checked', false); 128 } else { 129 $('.side-matter-pages-active-front,.side-matter-pages-active-home,.side-matter-pages-active-post,.side-matter-pages-active-page').attr('checked', true); 130 } 131 }); 132 119 133 })(jQuery); -
side-matter/trunk/js/side-matter.js
r770431 r835324 1 1 /* 2 2 side-matter.js 3 Version 1. 33 Version 1.4 4 4 5 5 Plugin: Side Matter … … 36 36 37 37 $(window).load(function() { // Position notes and fade in 38 for (i = 1; i <= 2; i++) placeNotes(); 38 for (i = 1; i <= 2; i++) placeNotes(); // Run loop twice to correct initial misplacements 39 39 if (useEffects == 1) $('ol.' + htmlClass + '-list').fadeTo(360, 1); 40 40 }); -
side-matter/trunk/readme.txt
r800230 r835324 3 3 Tags: academic, annotate, annotation, annotations, bibliography, bibliographic, citation, citations, cite, commentary, endnote, endnotes, footnote, footnotes, margin, marginal, matter, note, notes, ref, reference, references, scholar, scholarship, shortcode, side, sidebar, sidenote, sidenotes, widget 4 4 Requires at least: 3.0 5 Tested up to: 3. 7.15 Tested up to: 3.8 6 6 Stable tag: 1.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 Turns footnotes into sidenotes, magically positioning each note in the sidebar next to its corresponding reference in the text.10 Turns footnotes into sidenotes, magically aligning each note in the sidebar next to its corresponding reference in the text. 11 11 12 12 == Description == 13 13 14 Side Matter turns footnotes into sidenotes, magically aligning each note in the sidebar next to its corresponding reference in the text. Easily add citations, digressions, or editorial remarks to pages and posts with a simple shortcode and widget. Scholars, editors, and writers of all kinds will find the plugin of particular use.14 Side Matter turns footnotes into sidenotes, magically aligning each note in the sidebar next to its corresponding reference in the text. Unlike hyperlinked footnotes, sidenotes don't require jumping down the page to follow up on each reference; instead, they perch humbly and accessibly beside the material to which they refer. 15 15 16 Sidenotes have been used in printed texts for centuries, and are equally at home on the Web. Unlike hyperlinked footnotes, sidenotes do not require a jump down the page to look up each reference; instead, they perch humbly and accessibly beside the material to which they refer. 17 18 Side Matter includes an options menu as well as a set of built-in classes for [styling with CSS](http://wordpress.org/extend/plugins/side-matter/other_notes/). To use, place the Side Matter widget in your sidebar, then enclose sidenote text in a page or post using the `[ref]` shortcode, like so: 16 To use, place the Side Matter widget in your sidebar, then enclose sidenote text in a page or post using the `[ref]` shortcode, like so: 19 17 20 18 Here's the text to annotate.[ref]Note text goes here.[/ref] 21 19 20 To change default settings, use the Side Matter options page linked under the Appearance menu on your admin screen. 21 22 22 == Installation == 23 23 24 1. Upload the directory `side-matter`to `/wp-content/plugins`.24 1. Upload the `side-matter` directory to `/wp-content/plugins`. 25 25 2. Activate Side Matter using the Plugins screen. 26 26 3. Place the Side Matter widget in your sidebar using the Widgets screen. 27 4. Use the `[ref]` shortcode to generate sidenotes in posts and pages, like so: `[ref]Note text goes here.[/ref]`27 4. Use the `[ref]` shortcode to generate notes in posts and pages, like so: `[ref]Note text goes here.[/ref]` 28 28 29 To change the plugin's default settings, use the Side Matter options menu on your Reading Settingsscreen.29 To change default settings, use the Side Matter options page linked under the Appearance menu on your admin screen. 30 30 31 For information on changing the appearance of Side Matter elements usingCSS, see [Other Notes](http://wordpress.org/extend/plugins/side-matter/other_notes/).31 For information on changing the appearance of Side Matter elements with CSS, see [Other Notes](http://wordpress.org/extend/plugins/side-matter/other_notes/). 32 32 33 33 == Frequently Asked Questions == 34 34 35 = Where is Side Matter'soptions menu? =35 = Where is the options menu? = 36 36 37 You can find the options menu on your Reading Settingsscreen.37 As of version 1.4, the Side Matter options menu has its own settings page. It can be accessed from the Side Matter link under the Appearance menu on your admin screen. 38 38 39 39 = My notes don't appear. = 40 40 41 Some themes are one-column by design and do not include a sidebar. Without a sidebar, Side Matter has no place to generateyour notes. Make sure that your theme includes a sidebar and that you've placed the Side Matter widget within that sidebar.41 Many themes are one-column by design and do not include a sidebar. Without a sidebar, Side Matter has no place to put your notes. Make sure that your theme includes a sidebar and that you've placed the Side Matter widget within that sidebar. 42 42 43 43 = My notes just sit at the top of the sidebar. = 44 44 45 This usually occurs because of conflicts with your theme or another plugin. Caching/minification plugins are a common culprit; try adding `/wp-content/side-matter/js/side-matter.js` to your caching plugin's exclusion list if it is interfering with Side Matter.45 This usually happens because of a conflict with your theme or another plugin. Caching/minification plugins are a common culprit; try adding `/wp-content/side-matter/js/side-matter.js` to your caching plugin's exclusion list if it's interfering with sidenote display. 46 46 47 Theme conflicts can be difficult to pin down, but are most often caused by some idiosyncratic bit of theme CSS or JS. (For example, [Twenty Eleven](http://wordpress.org/themes/twentyeleven) can be made to work with Side Matter by changing [a few lines of CSS](http://wordpress.org/support/topic/sidenotes-not-aligning).)47 Theme conflicts can be difficult to pin down, but are most often caused by some idiosyncratic bit of theme CSS or JS. (For example, the theme [Twenty Eleven](http://wordpress.org/themes/twentyeleven) can be made to work with Side Matter by adding [a few lines of CSS](http://wordpress.org/support/topic/sidenotes-not-aligning).) 48 48 49 49 = Why doesn't the plugin work with my theme? = 50 50 51 Not all themes are built to incorporate a component like Side Matter. The plugin works well with most base themes that include a conventional sidebar, but it isn't guaranteed to display notes perfectly under all themes. A little tinkering with note offset or CSS will fix most problems; in other cases, it's best toconsult your theme's developer.51 Not all themes are built to incorporate a plugin like Side Matter. It works well with most base themes that include a sidebar, but it isn't guaranteed to display notes perfectly under all themes. A little tinkering with note offset or CSS will fix most problems; in other cases, consult your theme's developer. 52 52 53 53 = My notes appear at a vertical offset. = 54 54 55 Some themes mysteriously display sidenotes at an offset from their corresponding references in the text. As a workaround for this problem, Side Matter's options menu includes a field for arbitrarily adjusting your notes' vertical offset. 56 57 = Some list numerals don't display properly in all browsers. = 58 59 Browser support for some values of the CSS `list-style-type` property is mixed. (See the `list-style-type` documentation on [Web Platform Docs](http://docs.webplatform.org/wiki/css/properties/list-style-type#Compatibility_notes) for details.) Use Decimal, Latin, or Roman figures if this becomes a problem. 60 61 = Does Side Matter work with responsive layouts? = 62 63 Side Matter includes an option, turned off by default, to responsively re-position sidenotes upon viewport resize or zoom. You can enable this function using the Responsive Positioning control in Side Matter's options menu. 55 Some themes mysteriously cause sidenotes to appear at an offset from their corresponding references in the text. As a workaround for this problem, Side Matter's options menu includes a field for arbitrarily adjusting your notes' vertical offset. 64 56 65 57 = Can sidenotes be displayed without using the widget? = … … 73 65 == Screenshots == 74 66 75 1. Side Matter extracts note text with a shortcode, then magically places each note in the sidebar beside its corresponding reference in the text.67 1. Side Matter in action. 76 68 77 2. Change default settings using Side Matter's options menu on the Reading Settings screen.69 2. Default settings may be changed using Side Matter's options menu. 78 70 79 71 == Changelog == 72 73 = 1.4 = 74 * Fixed a plugin activation error reported under WP 3.8. 75 * Made improvements to options menu UI. 76 * Options menu has been moved from the Reading Settings screen. It now has its own settings page under the Appearance menu. 77 * Plugin now processes shortcodes enclosed within the `[ref]` shortcode, such as `[video]` or `[gallery]`. 80 78 81 79 = 1.3 = … … 143 141 == Upgrade Notice == 144 142 145 = 1. 3=146 Version 1.3 includes the option to add a title heading to the Side Matter widget, along with some fixes. This update will break CSS that uses the `div.side-matter-widget` class selector; use `.widget_side_matter` instead.143 = 1.4 = 144 As of this release, Side Matter's options menu has been moved from the Reading Settings screen to its own page under the Appearance menu. 147 145 148 146 == Styling Side Matter with CSS == 149 147 150 Side Matter's options menu allows you to render notes and figures in custom colors by way of the Iris color picker. Changing other aspects of Side Matter elements' appearance, such as indentation or line height, requires some tinkering with CSS. (This guide assumes some familiarity with CSS; if you're a beginner, consider first reading a [tutorial](http://www.htmldog.com/guides/css/beginner/).)148 Changing the appearance of Side Matter elements—for example, editing your notes' typeface or indentation—requires using CSS. The simplest way to go about this is to install a custom CSS plugin that will preserve your rules even when Side Matter or your theme is updated. ([Simple Custom CSS](http://wordpress.org/plugins/simple-custom-css/) is a good example.) 151 149 152 The simplest way to add custom CSS to your site is to employ a custom CSS plugin, which will preserve your changes even if Side Matter or your theme is updated. [Simple Custom CSS](http://wordpress.org/plugins/simple-custom-css/) or the [Jetpack](http://wordpress.org/extend/plugins/jetpack/) CSS module are some good examples. 153 154 Side Matter comes with a set of built-in classes that make it easy to change the appearance of sidenote and reference elements using [class selectors](http://www.htmldog.com/guides/css/intermediate/classid/). All Side Matter elements can be styled at once using the class `side-matter`. The following rule will render reference numerals and sidenotes in blue 12-pixel serif type: 150 Side Matter comes with a set of built-in class selectors. As an example, all sidenote and reference elements may be styled at once using the class `side-matter`. The following CSS will render all Side Matter elements in blue serif text: 155 151 156 152 .side-matter { 157 153 color: blue; 158 154 font-family: serif; 159 font-size: 12px;160 155 } 161 156 162 Notes and references may be styled with greater precision using element-specific class selectors. The following pair of rules will render reference and list numerals in redand sidenote text in black:157 Notes and figures may be formatted with greater precision using element-specific class selectors. For example, the following CSS will render reference and list numerals in green and sidenote text in black: 163 158 164 159 a.side-matter-ref, ol.side-matter-list { 165 color: red;160 color: green; 166 161 } 167 162 … … 170 165 } 171 166 172 In some cases, your CSS may fail to take effect because the theme CSS carries greater [specificity](http://www.htmldog.com/guides/css/intermediate/specificity/). There are ways around this, such as overriding the theme stylesheet's specificity via nesting:173 174 .entry-content > p > a.side-matter.side-matter-ref {175 color: red;176 }177 178 167 = List of Class Selectors = 179 Here is a complete list of Side Matter elementclass selectors and their uses:168 Here is a full list of Side Matter class selectors and their uses: 180 169 181 170 * `a.side-matter-ref` selects the link elements that enclose in-text reference numerals. Use this class to modify the links' colors, underline, etc. 182 171 * `sup.side-matter-sup` selects the `sup` (superscript) elements that enclose in-text reference numerals. Use this class to modify the numerals' typographic properties, such as size, offset, and font. 183 172 * `.widget_side_matter` (note the underscores) selects the widget container element, which may be an `aside` or a `div`. 184 * `ol.side-matter-list` selects the `ol` (ordered list) element that encloses notes in the sidebar, including alllist numerals.173 * `ol.side-matter-list` selects the `ol` (ordered list) element that encloses notes in the sidebar, including list numerals. 185 174 * `li.side-matter-note` selects sidenote `li` (list item) elements, including each note's numeral. 186 175 * `div.side-matter-text` selects the `div` elements that enclose sidenote text, but not sidenote list numerals. Use this to style sidenote text separately from numerals. 187 176 188 WordPress further wraps each note paragraph in a tag of its own, butthese `p` elements cannot be selected directly using the `side-matter` class. Instead, select them indirectly, e.g. `div.side-matter-text > p`.177 Each paragraph within a note is further wrapped in a `p` tag. However, as they're generated outside the plugin, these `p` elements cannot be selected directly using the `side-matter` class. Instead, select them indirectly, e.g. `div.side-matter-text > p`. 189 178 190 179 = Default CSS = 191 Side Matter sets a few basic rules by default in the included stylesheet `side-matter.css`. These rules will generally defer to your theme or custom stylesheets.180 Side Matter sets a few rules by default in the included stylesheet `side-matter.css`. These rules will generally defer to your theme stylesheet in the event of a conflict. 192 181 193 182 The first rule removes underlines from reference numeral links: 194 183 195 a.side-matter -ref:link,196 a.side-matter -ref:visited,197 a.side-matter -ref:hover,198 a.side-matter -ref:active {184 a.side-matter:link, 185 a.side-matter:visited, 186 a.side-matter:hover, 187 a.side-matter:active { 199 188 text-decoration: none; 200 189 } 201 190 202 The second rule specifies a consistent cross-browser, cross-theme appearancefor superscript figures:191 The second rule specifies a consistent cross-browser, cross-theme format for superscript figures: 203 192 204 193 sup.side-matter-sup { -
side-matter/trunk/side-matter.php
r770431 r835324 3 3 Plugin Name: Side Matter 4 4 Plugin URI: http://wordpress.org/extend/plugins/side-matter/ 5 Description: Turns footnotes into sidenotes, magically positioning each note in the sidebar next to its corresponding reference in the text.6 Version: 1. 35 Description: Turns footnotes into sidenotes, magically aligning each note in the sidebar next to its corresponding reference in the text. 6 Version: 1.4 7 7 Author: Christopher Setzer 8 8 Author URI: http://christophersetzer.com … … 13 13 14 14 /* 15 Copyright (C) 201 3Christopher Setzer15 Copyright (C) 2014 Christopher Setzer 16 16 17 17 This program is free software; you can redistribute it and/or … … 30 30 */ 31 31 32 $side_matter_admin = new Side_Matter_Admin;33 32 $side_matter = new Side_Matter; 34 33 35 class Side_Matter_Admin { 34 class Side_Matter { 35 36 public $version; 36 37 37 38 public $defaults; 38 39 public $options; 39 public $version; 40 41 public function __construct() { // Set up defaults, register actions 40 41 public $notes; 42 43 public function __construct() { 42 44 43 45 add_action( 'admin_init', array( &$this, 'load_textdomain' ) ); // Load text domain 'side-matter' for localization 44 46 add_action( 'admin_init', array( &$this, 'build_settings_section' ) ); // Assemble settings section 47 add_action( 'admin_menu', array( &$this, 'admin_add_settings_page' ) ); 45 48 add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue' ) ); // Load script and CSS for options menu 46 add_action( 'admin_print_footer_scripts', array( &$this, 'ad d_quicktag' ) ); // Load quicktag script for post/page HTML editor49 add_action( 'admin_print_footer_scripts', array( &$this, 'admin_add_quicktag' ) ); // Load quicktag script for post/page HTML editor 47 50 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( &$this, 'add_plugins_link' ) ); // Link options menu from Plugins screen 48 51 … … 51 54 52 55 add_action( 'widgets_init', array( &$this, 'add_widget' ) ); // Register widget-loading function 56 57 add_action( 'side_matter_list_notes', array( &$this, 'list_notes' ) ); // Register custom action 'side_matter_list_notes' for use in widget or elsewhere 53 58 54 59 $this->defaults = array( // Set option defaults … … 73 78 ); 74 79 $this->options = wp_parse_args( get_option( 'side_matter_options' ), $this->defaults ); // Get options from database and apply defaults in place of any that are not set 75 $this->version = '1.3'; // Current version of plugin80 $this->version = (string) '1.4'; // Current version of plugin 76 81 77 82 } … … 82 87 } 83 88 89 public function admin_add_settings_page() { 90 add_theme_page( __( 'Side Matter', 'side-matter' ), __( 'Side Matter', 'side-matter'), 'manage_options', 'side-matter', array( &$this, 'admin_build_settings_page' ) ); 91 } 92 93 public function admin_build_settings_page() { 94 ?> 95 <div class='wrap'> 96 <form method='post' action='options.php'> 97 <h2><?php _e( 'Side Matter', 'side-matter' ); ?></h2> 98 <?php settings_fields( 'side-matter' ); ?> 99 <?php do_settings_sections( 'side-matter' ); ?> 100 <?php submit_button(); ?> 101 </form> 102 </div> 103 <?php 104 } 105 84 106 public function build_settings_section() { // Assemble Side Matter options menu 85 107 86 108 $section = 'side_matter_section'; 87 $page = ' reading';109 $page = 'side-matter'; 88 110 $callback = array( &$this, 'build_field' ); 89 111 $fields = array( … … 108 130 'label_for' => 'side-matter-figure-style', 109 131 'styles' => array( 132 'none' => __( 'None', 'side-matter' ), 110 133 'decimal' => __( 'Decimal: 1, 2, 3, 4, 5, 6, …', 'side-matter' ), 111 134 'lower-alpha' => __( 'Latin: a, b, c, d, e, f, …', 'side-matter' ), … … 116 139 'hebrew' => _x( 'Hebrew: ו ,ה ,ד ,ג ,ב ,א, …', 'Note RTL text reversal of Hebrew characters', 'side-matter' ), // Comma placement is due to RTL text reversal of Hebrew characters 117 140 'hiragana' => __( 'Hiragana: あ, い, う, え, お, か, …', 'side-matter' ), 118 'hiragana-iroha' => __( 'Hiragana (Iroha): い, ろ, は, に, ほ, へ, …' ),141 'hiragana-iroha' => __( 'Hiragana—Iroha: い, ろ, は, に, ほ, へ, …' ), 119 142 'katakana' => __( 'Katakana: ア, イ, ウ, エ, オ, カ, …', 'side-matter' ), 120 'katakana-iroha' => __( 'Katakana (Iroha): イ, ロ, ハ, ニ, ホ, ヘ, …', 'side-matter' ), 121 'none' => __( 'None', 'side-matter' ) 143 'katakana-iroha' => __( 'Katakana—Iroha: イ, ロ, ハ, ニ, ホ, ヘ, …', 'side-matter' ) 122 144 ) 123 145 ), … … 125 147 'id' => 'is_responsive', 126 148 'title' => __( 'Responsive Positioning', 'side-matter' ), 127 'label' => __( 'Responsively position notes when windowis resized or zoomed', 'side-matter' ),149 'label' => __( 'Responsively position notes when viewport is resized or zoomed', 'side-matter' ), 128 150 'label_for' => 'side-matter-is-responsive' 129 151 ), … … 138 160 'title' => __( 'Adjust vertical offset of notes by', 'side-matter' ), 139 161 'label' => _x( 'px', 'Abbreviation for "pixels"', 'side-matter' ), 140 'description' => __( 'A positive offset will push notes up; a negative offset will push them down.', 'side-matter' ), 141 'label_for' => 'side-matter-note-adjust', 142 'max' => '9999', 143 'min' => '-9999' 162 'label_for' => 'side-matter-note-adjust' 144 163 ), 145 164 'pages_active' => array( 146 165 'id' => 'pages_active', 147 166 'title' => __( 'Display Side Matter notes on', 'side-matter' ), 167 'label_for' => 'side-matter-pages-active', 148 168 'pages' => array( 149 169 'front' => __( 'Front page', 'side-matter' ), … … 155 175 ); 156 176 157 add_settings_section( $section, __( 'Side Matter', 'side-matter' ), array( &$this, 'build_section_heading' ), $page );177 add_settings_section( $section, '', array( &$this, 'build_section_heading' ), $page ); 158 178 foreach ( $fields as $option => $param ) { // Loop through settings field values and send them, one at a time, to build_field() 159 179 extract( $fields[ $option ] ); … … 165 185 166 186 public function build_section_heading() { 167 return; // Don't build section heading187 return; // Don't build a section heading 168 188 } 169 189 … … 185 205 <div class='side-matter-preview-content'> 186 206 <div class='side-matter-preview-main'> 187 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor tincidunt ut labore et dolore nostrud.<s up class='side-matter-preview-ref'><?php echo $side_matter->get_figure( 1, $figure_style ); ?></sup> Ut enim ad minim veniam, quis ullamco laboris nisi ut aliquip ex ea consequat. Cras ante lacus, libero et commodo sit magna aliqua.207 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor tincidunt ut labore et dolore nostrud.<span class='side-matter-preview-ref'><sup class='side-matter-preview-sup'><?php echo $side_matter->get_figure( 1, $figure_style ); ?></sup></span> Ut enim ad minim veniam, quis ullamco laboris nisi ut aliquip ex ea consequat. Cras ante lacus, libero et commodo sit magna aliqua. 188 208 </div> 189 209 <div class='side-matter-preview-side'> … … 191 211 <li class='side-matter-preview-note' style='list-style-type: <?php echo $figure_style; ?>;'> 192 212 <div class='side-matter-preview-text'> 193 Velit esse cillum dolore eu fugiat nulla pariatur.213 Velit esse cillum dolore eu fugiat nulla. 194 214 </div> 195 215 </li> 196 216 </ol> 217 </div> 218 <div class='side-matter-preview-clear'> 219 <!-- empty --> 197 220 </div> 198 221 </div> … … 233 256 break; 234 257 case 'note_adjust': 235 ?> 236 <label><input id='<?php echo $label_for; ?>' class='<?php echo $label_for; ?>' type='number' name='side_matter_options[<?php echo $id; ?>]' value='<?php echo $state; ?>' step='1' max='<?php echo $max; ?>' min='<?php echo $min; ?>' class='small-text' /> <?php echo $label; ?></label> 237 <p class='description'> 238 <?php echo $description; ?> 239 </p> 258 $note_adjust_dir = ( $state >= 0 ) ? 'up' : 'down'; 259 ?> 260 <label><input id='<?php echo $label_for; ?>' class='<?php echo $label_for; ?> small-text' type='number' name='side_matter_options[<?php echo $id; ?>]' value='<?php echo abs( $state ); ?>' step='1' min='0' class='small-text' /> <?php echo $label; ?></label> <label class='note-adjust-dir'><input id='note_adjust_dir_up' type='radio' name='side_matter_options[note_adjust_dir]' value='up' <?php checked( 'up', $note_adjust_dir ); ?> /><?php _e( 'Up', 'side-matter' ); ?></label> <label class='note-adjust-dir'><input id='note_adjust_dir_down' type='radio' name='side_matter_options[note_adjust_dir]' value='down' <?php checked( 'down', $note_adjust_dir ); ?> /><?php _e( 'Down', 'side-matter' ); ?></label> 240 261 <?php 241 262 break; … … 272 293 $options['is_responsive'] = ( ! isset( $input['is_responsive'] ) ) ? (int) 0 : (int) $input['is_responsive']; 273 294 $options['use_effects'] = ( ! isset( $input['use_effects'] ) ) ? (int) 0 : (int) $input['use_effects']; 274 $options['note_adjust'] = ( ! isset( $input['note_adjust'] ) ) ? (int) $defaults['note_adjust'] : (int) intval( $input['note_adjust'] ); 295 296 if ( ! isset( $input['note_adjust'] ) ) { 297 $options['note_adjust'] = (int) $defaults['note_adjust']; 298 } else { 299 $options['note_adjust'] = ( $input['note_adjust_dir'] == 'down' ) ? ( 0 - $input['note_adjust'] ) : abs( $input['note_adjust'] ); 300 } 301 275 302 foreach ( $defaults['pages_active'] as $page => $setting ) { 276 303 $options['pages_active'][ $page ] = ( ! isset( $input['pages_active'][ $page ] ) ) ? (int) 0 : (int) $input['pages_active'][ $page ]; … … 284 311 } 285 312 286 public function ad d_quicktag() {313 public function admin_add_quicktag() { // Add shortcode quicktag button to post editor menu 287 314 if ( wp_script_is( 'quicktags' ) ) { 288 315 ?> 289 316 <script type='text/javascript'> 290 QTags.addButton( 'side_matter_ref', '[ref]', '[ref]', '[/ref]', null, 'Side Matter reference', 119 );317 QTags.addButton( 'side_matter_ref', 'ref', '[ref]', '[/ref]', null, 'Side Matter note', 119 ); 291 318 </script> 292 319 <?php … … 295 322 296 323 public function admin_enqueue( $hook ) { // Enqueue script and stylesheet for Side Matter options menu 297 if ( 'options-reading.php' != $hook ) {298 return;299 }300 324 global $wp_version; 301 325 wp_enqueue_style( 'side-matter-admin', plugins_url( 'css/side-matter-admin.css', __FILE__ ), null, $this->version, 'screen' ); 302 if ( version_compare( $wp_version, 3.5, 'ge' ) ) { // Only enqueue color picker style and dependency if WP version is 3.5 or higher326 if ( version_compare( $wp_version, 3.5, 'ge' ) ) { // Only enqueue Iris color picker style and dependency if WP version is 3.5 or higher 303 327 wp_enqueue_style( 'wp-color-picker' ); 304 328 wp_enqueue_script( 'side-matter-admin-js', plugins_url( 'js/side-matter-admin.js', __FILE__ ), array( 'wp-color-picker' ), $this->version, true ); … … 308 332 } 309 333 310 public function add_plugins_link( $actions ) { // Link to Side Matter'soptions menu from Plugins screen311 $url = admin_url( ' options-reading.php' );334 public function add_plugins_link( $actions ) { // Link to options menu from Plugins screen 335 $url = admin_url( 'themes.php?page=side-matter' ); 312 336 $settings_string = __( 'Settings', 'side-matter' ); 313 337 $array = array( 'settings' => "<a href='{$url}'>{$settings_string}</a>" ); … … 315 339 } 316 340 317 public function shortcode( $atts, $content = null ) { // Sendshortcode content to add_note(), and return formatted reference figure via format_ref()341 public function shortcode( $atts, $content = null ) { // Pass shortcode content to add_note(), and return formatted reference figure via format_ref() 318 342 global $side_matter; 343 if ( ! strpos( $content, '[ref]' ) === false ) { // Prevent chaos caused by [ref] within [ref] 344 $content = str_replace( '[ref]', '[ref]', $content ); 345 } 346 $content = do_shortcode( $content ); // Do a second pass for shortcodes within note text, like [video] 319 347 if ( ! $side_matter->check_page() ) { // Only return figure on this page if permitted by user settings 320 348 return ''; … … 326 354 } 327 355 328 public function enqueue() { // Load JS and CSS components; embed variables in script356 public function enqueue() { // Load JS and CSS components; embed user pref variables in script 329 357 global $side_matter; 330 358 if ( ! $side_matter->check_page() ) { … … 346 374 } 347 375 348 } 349 350 class Side_Matter { 351 352 public $options = array(); 353 public $notes = array(); 354 public $figures = array(); 355 356 public function __construct() { 357 global $side_matter_admin; 358 add_action( 'side_matter_list_notes', array( &$this, 'list_notes' ) ); // Register custom action 'side_matter_list_notes' for use in widget or elsewhere 359 $this->options = $side_matter_admin->options; 360 $this->figures = array( 376 public function check_page() { // Check whether the current page is selected for sidenote display on plugin options menu 377 extract( $this->options['pages_active'] ); 378 $check_pages = array( 379 ( is_front_page() && $front ), 380 ( is_home() && $home ), 381 ( is_single() && $post ), 382 ( is_page() && $page ) 383 ); 384 if ( in_array( 1, $check_pages ) ) { 385 return true; 386 } else { 387 return false; 388 } 389 } 390 391 public function has_notes() { // Return true if the current page contains notes 392 return ! empty ( $this->notes ); 393 } 394 395 public function get_figure( $note_id, $style ) { // Convert numeral to alternate format 396 397 $figures = array( 361 398 'armenian' => array( 'Ք' => 9000, 'Փ' => 8000, 'Ւ' => 7000, 'Ց' => 6000, 'Ր' => 5000, 'Տ' => 4000, 'Վ' => 3000, 'Ս' => 2000, 'Ռ' => 1000, 'Ջ' => 900, 'Պ' => 800, 'Չ' => 700, 'Ո' => 600, 'Շ' => 500, 'Ն' => 400, 'Յ' => 300, 'Մ' => 200, 'Ճ' => 100, 'Ղ' => 90, 'Ձ' => 80, 'Հ' => 70, 'Կ' => 60, 'Ծ' => 50, 'Խ' => 40, 'Լ' => 30, 'Ի' => 20, 'Ժ' => 10, 'Թ' => 9, 'Ը' => 8, 'Է' => 7, 'Զ' => 6, 'Ե' => 5, 'Դ' => 4, 'Գ' => 3, 'Բ' => 2, 'Ա' => 1 ), 362 399 'georgian' => array( 'ჵ' => 10000, 'ჰ' => 9000, 'ჯ' => 8000, 'ჴ' => 7000, 'ხ' => 6000, 'ჭ' => 5000, 'წ' => 4000, 'ძ' => 3000, 'ც' => 2000, 'ჩ' => 1000, 'შ' => 900, 'ყ' => 800, 'ღ' => 700, 'ქ' => 600, 'ფ' => 500, 'ჳ' => 400, 'ტ' => 300, 'ს' => 200, 'რ' => 100, 'ჟ' => 90, 'პ' => 80, 'ო' => 70, 'ჲ' => 60, 'ნ' => 50, 'მ' => 40, 'ლ' => 30, 'კ' => 20, 'ი' => 10, 'თ' => 9, 'ჱ' => 8, 'ზ' => 7, 'ვ' => 6, 'ე' => 5, 'დ' => 4, 'გ' => 3, 'ბ' => 2, 'ა' => 1 ), … … 370 407 'lower-roman' => 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 ) 371 408 ); 372 }373 374 public function check_page() { // Check whether to display Side Matter elements on current page based on user settings375 extract( $this->options['pages_active'] );376 $check_pages = array(377 ( is_front_page() && $front ),378 ( is_home() && $home ),379 ( is_single() && $post ),380 ( is_page() && $page )381 );382 if ( in_array( 1, $check_pages ) ) {383 return true;384 } else {385 return false;386 }387 }388 389 public function get_figure( $note_id, $style ) { // Convert numeral to alternate format390 409 391 410 switch ( $style ) { 411 case 'none': 412 return ''; 413 break; 392 414 case 'armenian': 393 415 case 'georgian': 394 416 case 'hebrew': 395 417 case 'lower-roman': 396 return $this->get_additive( $note_id, $ this->figures[ $style ] );418 return $this->get_additive( $note_id, $figures[ $style ] ); 397 419 break; 398 420 case 'hiragana': … … 402 424 case 'lower-alpha': 403 425 case 'lower-greek': 404 return $this->get_alpha( $note_id, $this->figures[ $style ] ); 405 break; 406 case 'none': 407 return ''; 426 return $this->get_alpha( $note_id, $figures[ $style ] ); 408 427 break; 409 428 case 'decimal': … … 460 479 $note_text = $this->notes[ $note_id ]; 461 480 462 $patterns = array( '/\n/', '/\r/', '/\s+/' ); 463 $title_text = esc_attr( strip_tags( preg_replace( $patterns, ' ', $note_text ) ) ); // Strip note of tags and line breaks for use in title attribute 481 $patterns = array( '/\n+/', '/\r+/', '/\s+/' ); 482 $title_text = preg_replace( $patterns, ' ', $note_text ); // Strip extraneous spaces and breaks from note text 483 $title_text = strip_tags( $title_text ); // Strip HTML tags from note text 484 $title_text = esc_attr( $title_text ); // Encodes <, >, &, ", and ' entities for use in title attribute 485 $title_text = trim( $title_text ); // Trim whitespace from either end of note 464 486 465 487 $figure_color_style = ( $user_colors['colors_enabled'] ) ? ' style="color: ' . $user_colors['colors']['figure_color'] . '"' : ''; … … 480 502 static $lists_count = 0; // Keep static count of Side Matter lists in case of multiple widget instances 481 503 482 if ( ! $this->check_page() || empty ( $this->notes) ) {504 if ( ! $this->check_page() || ! $this->has_notes() ) { 483 505 return; 484 506 } else { 485 507 486 508 $options = $this->options; 487 $figures = $this->figures;488 509 489 510 extract( $options ); … … 493 514 $figure_color_style = "color: {$figure_color};"; 494 515 $text_color_style = "color: {$text_color};"; 516 $link_style_attr = ( $options['user_colors']['colors_enabled'] ) ? " style='{$figure_color_style}'" : ''; 495 517 496 518 $lists_count++; // Add this list to count … … 532 554 533 555 global $side_matter; 534 if ( ! $side_matter->check_page() || empty ( $side_matter->notes) ) {556 if ( ! $side_matter->check_page() || ! $side_matter->has_notes() ) { 535 557 return; 536 558 } else { 537 global $side_matter_admin; 538 $class = $side_matter_admin->options['html_class']; 559 $class = $side_matter->options['html_class']; 539 560 echo $before_widget; 540 561 echo $before_title . $title . $after_title; … … 554 575 <?php 555 576 556 $options_url = admin_url( ' options-reading.php' );557 printf( __( '%sModify default settings using the options menu on your %sReading Settings%s screen.%s', 'side-matter' ), '<p>', "<a href='{$options_url}'>", '</a>', '</p>' );577 $options_url = admin_url( 'themes.php?page=side-matter' ); 578 printf( __( '%sModify default settings using Side Matter\'s %soptions menu%s.%s', 'side-matter' ), '<p>', "<a href='{$options_url}'>", '</a>', '</p>' ); 558 579 559 580 } -
side-matter/trunk/uninstall.php
r770477 r835324 2 2 /* 3 3 uninstall.php 4 Version 1. 34 Version 1.4 5 5 6 6 Plugin: Side Matter … … 15 15 16 16 delete_option( 'side_matter_options' ); // Remove database field side_matter_options on plugin deletion 17 delete_option( 'widget_side-matter' ); // Remove widget options on plugin deletion17 delete_option( 'widget_side-matter' ); // Remove database field for Side Matter widget settings on plugin deletion
Note: See TracChangeset
for help on using the changeset viewer.