Changeset 741424
- Timestamp:
- 07/16/2013 03:51:02 AM (13 years ago)
- Location:
- side-matter
- Files:
-
- 7 added
- 5 edited
-
assets/screenshot-1.png (modified) (previous)
-
assets/screenshot-2.png (modified) (previous)
-
trunk/css2 (added)
-
trunk/css2/side-matter-admin.css (added)
-
trunk/css2/side-matter.css (added)
-
trunk/js2 (added)
-
trunk/js2/side-matter-admin.js (added)
-
trunk/js2/side-matter.js (added)
-
trunk/languages (added)
-
trunk/readme.txt (modified) (12 diffs)
-
trunk/side-matter.php (modified) (24 diffs)
-
trunk/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
side-matter/trunk/readme.txt
r711140 r741424 1 1 === Side Matter === 2 2 Contributors: setzer 3 Tags: footnote, footnotes, endnote, endnotes, sidenote, sidenotes, annotation, annotations, citation, citations, shortcode, widget3 Tags: academic, annotation, annotations, bibliography, bibliographic, citation, citations, cite, commentary, endnote, endnotes, footnote, footnotes, note, notes, reference, references, scholar, shortcode, side, sidebar, sidenote, sidenotes, widget 4 4 Requires at least: 3.0 5 5 Tested up to: 3.6 … … 12 12 == Description == 13 13 14 Side Matter turns your footnotes into sidenotes, magically aligning each note in the sidebar next to its corresponding reference in the text. The plugin's easy-to-use shortcode and widget make it a lightweight, visually elegant tool for annotating your posts and pages.15 16 Like margin notes in a printed text, sidenotes are well-suited for citations, digressions, cross-references, and commentary. The visual effect is similar to that used for annotations by Grantland and other websites.14 Side Matter turns your footnotes into sidenotes, magically aligning each note in the sidebar next to its corresponding reference in the text. The plugin's easy-to-use shortcode and widget make it a lightweight, visually distinctive tool for scholars, editors, and writers of all kinds. 15 16 Sidenotes have long been used in printed works to incorporate citations, digressions, and remarks into the flow of a text. They work equally well on the Web; unlike hyperlinked footnotes, sidenotes don't require the user to click away from the main content of an page to follow up on a particular reference. 17 17 18 18 Side Matter includes an options menu for toggling settings, as well as a set of built-in classes for [styling with CSS](http://wordpress.org/extend/plugins/side-matter/other_notes/). It works well with many popular base themes, including Twenty Twelve, Twenty Ten, Responsive, and Toolbox. … … 39 39 = Where is Side Matter's options menu? = 40 40 41 The options menu can be foundon your Reading Settings screen.41 You can find the options menu on your Reading Settings screen. 42 42 43 43 = Does Side Matter work with responsive layouts? = 44 44 45 Yes. The plugin includes an option, turned off by default, to enable sidenote re-positioning upon resize/zoom in responsive themes. Enable this feature using the Responsive Positioning control in Side Matter's options menu. (It's best to leave this feature disabled if your theme is not responsive.)45 Yes. The plugin includes an option, turned off by default, to responsively re-position sidenotes upon window resize or zoom. Enable this function using the Responsive Positioning control in Side Matter's options menu. 46 46 47 47 = My notes just sit at the top of the sidebar. = 48 48 49 Your theme may not be linking `side-matter.js`, the script that aligns Side Matter notes. Check the page source to see if `side-matter.js` has been linked; if not, the problem may lie with your theme. In order to properly enqueue the script and other Side Matter assets, theme templates must include calls to [`wp_head`](http://codex.wordpress.org/Function_Reference/wp_head) and [`wp_footer`](http://codex.wordpress.org/Function_Reference/wp_footer).49 Your theme may not be linking `side-matter.js`, the script that aligns sidenotes. Check the page source to see if `side-matter.js` has been linked; if not, the plugin may not be compatible with your theme. 50 50 51 51 = My notes appear at a regular vertical offset from their proper position. = 52 52 53 Some themes idiosyncratically display notes at an offset from their corresponding references in the text. Side Matter's options menu, on the Reading Settings screen, includes a field for arbitrarily adjusting your notes' vertical position.53 Some themes idiosyncratically display notes 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. 54 54 55 55 = Why doesn't the plugin work with some themes? = 56 56 57 Not all themes are built to support the grafting-on of a substantial layout component like Side Matter. While the plugin works well with most base themes featuring a sidebar (including Twenty Twelve, Twenty Ten, Responsive, and Toolbox), it isn't guaranteed to display notes perfectly within all layouts. In many cases, a little tinkering with note offset or CSS will fix the problem. If you have ongoing questions about implementing sidenotes within a particular theme, though, your best resource may bethe theme author.57 Not all themes are built to readily absorb a new layout component like Side Matter. The plugin works well with most base themes that incorporate a conventional sidebar, but it isn't guaranteed to display notes perfectly within all layouts. Tinkering with note offset or CSS will fix most problems; in other cases, it's best to consult the theme author. 58 58 59 59 = Can sidenotes be displayed without using the widget? = 60 60 61 Yes. Use the custom action `side_matter_list_notes` in your sidebar template :61 Yes. Use the custom action `side_matter_list_notes` in your sidebar template, as seen below: 62 62 63 63 <?php … … 65 65 ?> 66 66 67 This action generates a list of Side Matter notes without wrapping them in the widget `div`. If incorporating Side Matter into a custom theme, note that your templates must include calls to [`wp_head`](http://codex.wordpress.org/Function_Reference/wp_head) and [`wp_footer`](http://codex.wordpress.org/Function_Reference/wp_footer) to properly enable the plugin. 67 = Some numeral formats (such as Armenian or Greek) don't display properly in my browser. = 68 69 Browser support for the CSS `armenian`, `georgian`, `hebrew`, and `lower-greek` list styles varies. ([See Web Platform Docs](http://docs.webplatform.org/wiki/css/properties/list-style-type) for a list.) Decimal, Latin, and Roman numerals enjoy broader support. 68 70 69 71 == Screenshots == … … 74 76 75 77 == Changelog == 78 79 = 1.0 = 80 * Added support for Armenian, Georgian, Greek, and Hebrew numeral formats. 81 * Fixed two IE-specific bugs related to list numeral and `title` attribute display. 82 * Numbered classes have been removed. 83 * Plugin is now localization-ready. 76 84 77 85 = 0.9 = 78 86 * Added a preview field to the options menu. 79 * Added an option to display reference figures in alphabet and Roman numeral formats.87 * Added an option to display reference figures in Latin alphabet and Roman numeral formats. 80 88 * Added an option to set inline colors for Side Matter elements. 81 * Reference numeral linktags have been given a `title` attribute for accessibility.89 * Reference numeral `a` tags have been given a `title` attribute for accessibility. 82 90 * Removed deprecated element classes `side-matter-ol` and `side-matter-li`. Numbered classes, e.g. `side-matter-sup-6`, are now deprecated. 83 * Responsive positioning and fade effects are now turned off by default .91 * Responsive positioning and fade effects are now turned off by default to spare inexperienced users the script load. 84 92 * Side Matter's options menu is now linked from its entry on the Installed Plugins screen. 85 93 … … 114 122 == Upgrade Notice == 115 123 124 = 1.0 = 125 This update fixes a few IE-specific bugs and also features several important additions, including new numeral formats and localization support. 126 116 127 = 0.9 = 117 128 This update adds a number of features, including alternate numeral formats and a color picker for Side Matter elements. Users who have modified `side-matter.css` are advised to make a backup copy before updating. … … 131 142 == Styling Side Matter with CSS == 132 143 133 As of version 0.9, Side Matter's options menu includes a color picker for rendering notes and figures in custom colors. Altering the appearance of Side Matter elements beyond this requires some tinkering with Cascading Style Sheets (CSS). This guide assumes some basic familiarity with CSS; beginning users may wish to start with a [CSS tutorial](http://www.htmldog.com/guides/css/beginner/). 134 135 The easiest way to add custom styles to your site is to use a plugin that houses your custom CSS in the WordPress database, preserving it even when Side Matter (or your theme) is updated. [Jetpack Custom CSS](http://wordpress.org/extend/plugins/jetpack/) is a good example. 136 137 Side Matter comes with a set of built-in classes that make it easy to customize the appearance of sidenote and reference elements using [class selectors](http://www.htmldog.com/guides/css/intermediate/classid/). For example, all Side Matter elements may be styled at once using the class `side-matter`. The following rule will instruct browsers to render all Side Matter content (reference numerals, sidenote numerals, and sidenote text) in blue: 144 As of version 0.9, Side Matter's options menu includes a color picker for rendering notes and figures in custom colors. Altering the appearance of Side Matter elements beyond this requires some tinkering with Cascading Style Sheets (CSS). This guide assumes some familiarity with CSS; if you're a beginner, start with a [tutorial](http://www.htmldog.com/guides/css/beginner/). 145 146 The simplest way to add custom styles to your site is to employ a plugin that houses your custom CSS in the WordPress database, thus preserving it even if Side Matter (or your theme) is updated. [Jetpack Custom CSS](http://wordpress.org/extend/plugins/jetpack/) is a good example. 147 148 (Note that inline color styles set in the Side Matter options menu will generally override any custom styles you set elsewhere. If you're planning to use a custom stylesheet as described here, be sure to disable custom colors in the options menu.) 149 150 Side Matter comes with a set of built-in classes that make it easy to customize the appearance of sidenote and reference elements using [class selectors](http://www.htmldog.com/guides/css/intermediate/classid/). For example, all Side Matter elements may be styled at once using the class `side-matter`. The following rule will render all Side Matter content (reference numerals, sidenote numerals, and sidenote text) in blue: 138 151 139 152 .side-matter { … … 141 154 } 142 155 143 Notes and references may be styled with greater precision using element-specific class selectors. The following rules will render reference and list numerals in red while leaving sidenote text black :156 Notes and references may be styled with greater precision using element-specific class selectors. The following rules will render reference and list numerals in red while leaving sidenote text black (see [Screenshots](http://wordpress.org/extend/plugins/side-matter/screenshots/) for a similar example): 144 157 145 158 a.side-matter-ref, ol.side-matter-list { … … 151 164 } 152 165 153 In some cases, your custom CSS may fail to take effect because the theme CSS carriesgreater [specificity](http://www.htmldog.com/guides/css/intermediate/specificity/). There are ways around this. For example, if you can't modify the color of superscript reference links because your theme's rules have greater specificity, try overriding the theme stylesheet via nesting or an ID selector:166 In some cases, your custom CSS may fail to take effect because the theme CSS has a greater [specificity](http://www.htmldog.com/guides/css/intermediate/specificity/). There are ways around this. For example, if you can't modify the color of superscript reference links because your theme's rules have greater specificity, try overriding the theme stylesheet via nesting or an ID selector: 154 167 155 168 .entry-content > p > a.side-matter.side-matter-ref { … … 169 182 A full list of included class and ID selectors may be found below. 170 183 184 = List of Class Selectors = 185 Here is a complete list of Side Matter element class selectors and their uses: 186 187 * `a.side-matter-ref` selects the `a` link tags that enclose in-text reference numerals. Use this class to modify the links' colors, underline, etc. Target a specific reference link using its ID selector (e.g. `#ref-5`). 188 * `sup.side-matter-sup` selects the `sup` (superscript) tags that enclose in-text reference numerals. Use this class to modify the numerals' typographic properties, such as size, offset, and font. 189 * `div.side-matter-widget` selects the `div` element that encloses the Side Matter widget. 190 * `ol.side-matter-list` selects the `ol` (ordered list) element that encloses notes in the sidebar, including note numeral figures. 191 * `li.side-matter-note` selects individual sidenote `li` (list item) elements. Target a specific note using the note's ID selector (e.g. `#note-6`). 192 * `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 sidenote numerals. 193 * WordPress further wraps each note paragraph in a `p` tag. Because they are generated outside Side Matter, these `p` elements cannot be selected directly using the `side-matter` class. Instead, target them using a [child selector](http://www.htmldog.com/guides/css/advanced/selectors/), e.g. `div.side-matter-text > p`. 194 171 195 = Default CSS = 172 Note that inline color styles set in the Side Matter options menu will generally override any style rules you set in a custom CSS plugin or elsewhere. If modifying an element's `color` property with CSS, make sure to first disable custom colors in the options menu.173 174 Side Matter also sets a few rules by default in the stylesheet `side-matter.css`. These may be readily superseded by your theme stylesheet or custom CSS. 196 Side Matter sets a few default rules by way of the stylesheet `side-matter.css`. These may be readily superseded by your theme stylesheet or custom CSS. 197 198 The first rule removes underlines from reference numeral links: 175 199 176 200 a.side-matter-ref:link, … … 180 204 text-decoration: none; 181 205 } 206 207 The second rule specifies a consistent cross-theme appearance for superscript figures: 182 208 183 209 sup.side-matter-sup { … … 188 214 line-height: 0; 189 215 } 190 191 The above rules remove underlines from reference links (`text-decoration: none`) and specify a consistent, cross-theme appearance for superscript figures.192 193 = List of Class Selectors =194 Here is a complete list of Side Matter element class selectors and their uses:195 196 * `a.side-matter-ref` selects the `a` link tags that enclose in-text reference numerals. Use this class to modify the links' colors, underline, etc. Target a specific reference link using its ID selector (e.g. `#ref-5`).197 * `sup.side-matter-sup` selects the `sup` (superscript) tags that enclose in-text reference numerals. Use this class to modify the numeral figures' typographic properties, such as size, offset, and typeface.198 * `div.side-matter-widget` selects the `div` element that encloses the Side Matter widget.199 * `ol.side-matter-list` selects the `ol` (ordered list) element that encloses notes in the sidebar, including note numeral figures.200 * `li.side-matter-note` selects individual sidenote `li` (list item) elements. Target a specific note using the note's ID selector (e.g. `#note-6`).201 * `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 sidenote numerals.202 * WordPress further wraps each note paragraph in a `p` tag. Because they are generated outside Side Matter, these `p` elements cannot be selected directly using the `side-matter` class. Instead, target them using a [child selector](http://www.htmldog.com/guides/css/advanced/selectors/), e.g. `div.side-matter-text > p`. -
side-matter/trunk/side-matter.php
r710765 r741424 4 4 Plugin URI: http://wordpress.org/extend/plugins/side-matter/ 5 5 Description: Turns your footnotes into sidenotes, magically positioning each note in the sidebar next to its corresponding reference in the text. 6 Version: 0.9 6 Text Domain: side-matter 7 Version: 1.0 7 8 Author: Christopher Setzer 8 9 Author URI: http://christophersetzer.com 9 License: GPLv2 10 License: GPLv2 or later 10 11 */ 11 12 … … 39 40 public function __construct() { // Set up defaults, register actions 40 41 42 add_action( 'admin_init', array( &$this, 'load_textdomain' ) ); 41 43 add_action( 'admin_init', array( &$this, 'build_settings_section' ) ); // Assemble settings section 42 44 add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue' ) ); // Load script and CSS for options menu … … 45 47 add_shortcode( 'ref', array( &$this, 'shortcode' ) ); // Register shortcode 46 48 add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue' ) ); // Load script and CSS; embed variables in script 49 47 50 add_action( 'widgets_init', array( &$this, 'add_widget' ) ); // Register widget-loading function 48 51 … … 68 71 ); 69 72 $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 70 $this->version = 0.9; // Current version of plugin 71 72 } 73 74 public function admin_enqueue( $hook ) { // Enqueue script and stylesheet for Side Matter options menu 75 76 if ( 'options-reading.php' != $hook ) return; 77 78 global $wp_version; 79 80 wp_enqueue_style( 'side-matter-admin', plugins_url( 'css/side-matter-admin.css', __FILE__ ), null, $this->version, 'screen' ); 81 82 if ( version_compare( $wp_version, 3.5, 'gt' ) ) { // Only enqueue color picker style and dependency if WP version is 3.5 or higher 83 wp_enqueue_style( 'wp-color-picker' ); 84 wp_enqueue_script( 'side-matter-admin-js', plugins_url( 'js/side-matter-admin.js', __FILE__ ), array( 'wp-color-picker' ), $this->version, true ); 85 } else { 86 wp_enqueue_script( 'side-matter-admin-js', plugins_url( 'js/side-matter-admin.js', __FILE__ ), false, $this->version, true ); 87 } 88 73 $this->version = '1.0'; // Current version of plugin 74 75 } 76 77 public function load_textdomain() { 78 $dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/'; 79 load_plugin_textdomain( 'side-matter', false, $dir ); 89 80 } 90 81 … … 97 88 'preview_field' => array( 98 89 'id' => 'preview_field', 99 'title' => 'Preview', 100 'description' => "The preview field incorporates only styles set below, and does not reflect your site's theme.", 90 'title' => __( 'Preview', 'side-matter' ), 101 91 'label_for' => 'preview_field' 102 92 ), 103 93 'user_colors' => array( 104 94 'id' => 'user_colors', 105 'title' => 'Colors',106 'label' => 'Use custom colors for Side Matter elements',95 'title' => __( 'Colors', 'side-matter' ), 96 'label' => __( 'Use custom colors for Side Matter elements', 'side-matter' ), 107 97 'label_for' => 'colors_enabled', 108 98 'colors' => array( 109 'figure_color' => 'Numeral figures',110 'text_color' => 'Note text'99 'figure_color' => __( 'Reference numerals', 'side-matter' ), 100 'text_color' => __( 'Note text', 'side-matter' ) 111 101 ) 112 102 ), 113 103 'figure_style' => array( 114 104 'id' => 'figure_style', 115 'title' => 'Display reference numerals as',105 'title' => __( 'Display numeral figures as', 'side-matter' ), 116 106 'styles' => array( 117 'decimal' => 'Decimal: 1, 2, 3, 4, 5, 6, …', 118 'lower-alpha' => 'Latin: a, b, c, d, e, f, …', 119 'lower-roman' => 'Roman: i, ii, iii, iv, v, vi, …' 107 'decimal' => __( 'Decimal: 1, 2, 3, 4, 5, 6, …', 'side-matter' ), 108 'lower-alpha' => __( 'Latin: a, b, c, d, e, f, …', 'side-matter' ), 109 'lower-roman' => __( 'Roman: i, ii, iii, iv, v, vi, …', 'side-matter' ), 110 'armenian' => __( 'Armenian: Ա, Բ, Գ, Դ, Ե, Զ, …', 'side-matter' ), 111 'georgian' => __( 'Georgian: ა, ბ, გ, დ, ე, ვ, …', 'side-matter' ), 112 'lower-greek' => __( 'Greek: α, β, γ, δ, ε, ζ, …', 'side-matter' ), 113 'hebrew' => __( 'Hebrew: ו ,ה ,ד ,ג ,ב ,א, …', 'side-matter' ), // Comma weirdness is due to RTL text reversal 114 'none' => __( 'None', 'side-matter' ) 120 115 ) 121 116 ), 122 117 'is_responsive' => array( 123 118 'id' => 'is_responsive', 124 'title' => 'Responsive Positioning',125 'label' => 'Responsively position notes when window is resized or zoomed',119 'title' => __( 'Responsive Positioning', 'side-matter' ), 120 'label' => __( 'Responsively position notes when window is resized or zoomed', 'side-matter' ), 126 121 'label_for' => 'is_responsive', 127 122 ), 128 123 'use_effects' => array( 129 124 'id' => 'use_effects', 130 'title' => 'Fade Effects',131 'label' => 'Use smoothing fade effects when displaying or positioning notes',125 'title' => __( 'Fade Effects', 'side-matter' ), 126 'label' => __( 'Use fade effects when displaying notes', 'side-matter' ), 132 127 'label_for' => 'use_effects' 133 128 ), 134 129 'note_adjust' => array( 135 130 'id' => 'note_adjust', 136 'title' => 'Adjust vertical offset of notes by',137 ' description' => 'A positive value will push notes up; a negative value will push them down.',138 ' label' => 'px',131 'title' => __( 'Adjust vertical offset of notes by', 'side-matter' ), 132 'label' => __( 'px', 'side-matter' ), 133 'description' => __( 'A positive offset will push notes up; a negative offset will push them down.', 'side-matter' ), 139 134 'label_for' => 'note_adjust', 140 135 'max' => '9999', … … 143 138 'pages_active' => array( 144 139 'id' => 'pages_active', 145 'title' => 'Display Side Matter notes on', 146 'description' => 'These conditions may override one another in some cases, as when a static page is set as your front page.', 140 'title' => __( 'Display Side Matter notes on', 'side-matter' ), 147 141 'pages' => array( 148 'front' => 'Front page',149 'home' => 'Posts page',150 'post' => 'Single posts',151 'page' => 'Single pages'142 'front' => __( 'Front page', 'side-matter' ), 143 'home' => __( 'Posts page', 'side-matter' ), 144 'post' => __( 'Posts', 'side-matter' ), 145 'page' => __( 'Pages', 'side-matter' ) 152 146 ) 153 147 ) 154 148 ); 155 149 156 add_settings_section( $section, 'Side Matter', array( &$this, 'build_section_heading'), $page );150 add_settings_section( $section, __( 'Side Matter', 'side-matter' ), array( &$this, 'build_section_heading' ), $page ); 157 151 foreach ( $fields as $option => $param ) { // Loop through settings field values and send them, one at a time, to build_field() 158 152 extract ( $fields[ $option ] ); … … 164 158 165 159 public function build_section_heading() { 166 echo '<p>Use the following options to change the appearance and functionality of Side Matter references and notes.</p>';160 return; 167 161 } 168 162 … … 172 166 173 167 $options = $this->options; 168 $figure_style = $options['figure_style']; 174 169 $options['preview_field'] = null; 175 170 $state = $options[ $id ]; … … 178 173 case 'preview_field': 179 174 global $side_matter; 180 $figure = $side_matter->get_figure( 1 ); 181 $type = $side_matter->get_attr( 'type' ); 175 $figure = $side_matter->get_figure( 1, $options['figure_style'] ); 182 176 ?> 183 177 <div class='side-matter-field' tabindex='0'> 184 178 <div class='side-matter-content'> 185 179 <div class='side-matter-main'> 186 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<sup class='side-matter-ref'><?php echo $side_matter->get_figure( 1 ) ?></sup> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.180 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<sup class='side-matter-ref'><?php echo $side_matter->get_figure( 1, $figure_style ) ?></sup> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 187 181 </div> 188 182 <div class='side-matter-side'> 189 183 <ol class='side-matter-list'> 190 <li class='side-matter-note' <?php echo $type ?>>184 <li class='side-matter-note' style='list-style-type: <?php echo $figure_style ?>;'> 191 185 <div class='side-matter-text'> 192 186 Velit esse cillum dolore eu fugiat nulla pariatur. … … 197 191 </div> 198 192 </div> 199 <p class='description'>200 <?php echo wptexturize( $description ) ?>201 </p>202 193 <?php 203 194 break; … … 205 196 ?> 206 197 <fieldset> 207 <label><input id='colors_enabled' type='checkbox' name='side_matter_options[<?php echo $id ?>][colors_enabled]' value='1' <?php checked( 1, $state['colors_enabled'] ) ?> /> <?php echo $label ?></label> 208 <ul class='user_colors'> 209 <?php 210 foreach ( $colors as $color => $color_label ) { 198 <label><input id='colors_enabled' type='checkbox' name='side_matter_options[<?php echo $id ?>][colors_enabled]' value='1' <?php checked( 1, $state['colors_enabled'] ) ?> /> <?php echo $label ?></label> 199 <ul class='user_colors'> 200 <?php 201 foreach ( $colors as $color => $color_label ) { 202 ?> 203 <li> 204 <label><?php echo $color_label ?>:<br> 205 <input class='color-input <?php echo $color ?>' type='text' name='side_matter_options[<?php echo $id ?>][colors][<?php echo $color ?>]' maxlength='7' data-default-color='<?php echo $this->defaults['user_colors']['colors'][ $color ] ?>' value='<?php echo $state['colors'][ $color ] ?>' /></label> 206 </li> 207 <?php 208 } 211 209 ?> 212 <li> 213 <label><?php echo $color_label ?>:<br> 214 <input class='color-input <?php echo $color ?>' type='text' name='side_matter_options[<?php echo $id ?>][colors][<?php echo $color ?>]' maxlength='7' data-default-color='<?php echo $this->defaults['user_colors']['colors'][ $color ] ?>' value='<?php echo $state['colors'][ $color ] ?>' /></label> 215 </li> 210 </ul> 211 </fieldset> 212 <?php 213 break; 214 case 'figure_style': 215 ?> 216 <select name='side_matter_options[<?php echo $id ?>]' id='<?php echo $id ?>'> 217 <?php 218 foreach ( $styles as $style => $style_title ) { 219 ?> 220 <option value='<?php echo $style ?>' <?php selected( $style, $state ) ?>><?php echo $style_title ?></option> 216 221 <?php 217 222 } 218 223 ?> 219 </ul> 220 </fieldset> 221 <?php 222 break; 223 case 'figure_style': 224 foreach ( $styles as $style => $style_label ) { 225 ?> 226 <label><input id='<?php echo $style ?>' type='radio' name='side_matter_options[<?php echo $id ?>]' value='<?php echo $style ?>' <?php checked( $style, $state ) ?>/> <?php echo $style_label ?></label><br> 227 <?php 228 } 224 </select> 225 <?php 229 226 break; 230 227 case 'note_adjust': 231 228 ?> 232 229 <label><input id='<?php echo $id ?>' 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> 233 <p class='description'><?php echo $description ?></p> 230 <p class='description'> 231 <?php echo $description ?> 232 </p> 234 233 <?php 235 234 break; … … 246 245 <?php 247 246 } 248 ?>249 <p class='description'><?php echo $description ?></p>250 <?php251 247 break; 252 248 } … … 259 255 $options = $this->options; 260 256 261 $options['user_colors']['colors_enabled'] = ( ! isset( $input['user_colors']['colors_enabled'] ) ) ? 0 :$input['user_colors']['colors_enabled'];257 $options['user_colors']['colors_enabled'] = ( ! isset( $input['user_colors']['colors_enabled'] ) ) ? (int) 0 : (int) $input['user_colors']['colors_enabled']; 262 258 foreach ( $defaults['user_colors']['colors'] as $color => $code ) { // Validate 3- or 6-character hex color code input 263 259 $input_code = $input['user_colors']['colors'][ $color ]; … … 267 263 } 268 264 $options['figure_style'] = ( ! isset( $input['figure_style'] ) ) ? $defaults['figure_style'] : $input['figure_style']; 269 $options['is_responsive'] = ( ! isset( $input['is_responsive'] ) ) ? 0 :$input['is_responsive'];270 $options['use_effects'] = ( ! isset( $input['use_effects'] ) ) ? 0 :$input['use_effects'];271 $options['note_adjust'] = ( ! isset( $input['note_adjust'] ) ) ? $defaults['note_adjust'] :intval( $input['note_adjust'] );265 $options['is_responsive'] = ( ! isset( $input['is_responsive'] ) ) ? (int) 0 : (int) $input['is_responsive']; 266 $options['use_effects'] = ( ! isset( $input['use_effects'] ) ) ? (int) 0 : (int) $input['use_effects']; 267 $options['note_adjust'] = ( ! isset( $input['note_adjust'] ) ) ? (int) $defaults['note_adjust'] : (int) intval( $input['note_adjust'] ); 272 268 foreach ( $defaults['pages_active'] as $page => $setting ) { 273 $options['pages_active'][ $page ] = ( ! isset( $input['pages_active'][ $page ] ) ) ? 0 : $input['pages_active'][ $page ]; 274 } 269 $options['pages_active'][ $page ] = ( ! isset( $input['pages_active'][ $page ] ) ) ? (int) 0 : (int) $input['pages_active'][ $page ]; 270 } 271 272 if ( isset( $options['note_buffer'] ) ) unset( $options['note_buffer'] ); // Remove deprecated 'note_buffer' 273 if ( isset( $options['html_class'] ) ) unset( $options['html_class'] ); // Don't write 'html_class' to DB 274 275 275 return $options; 276 277 } 278 279 public function admin_enqueue( $hook ) { // Enqueue script and stylesheet for Side Matter options menu 280 281 if ( 'options-reading.php' != $hook ) return; 282 283 global $wp_version; 284 285 wp_enqueue_style( 'side-matter-admin', plugins_url( 'css/side-matter-admin.css', __FILE__ ), null, $this->version, 'screen' ); 286 287 if ( version_compare( $wp_version, 3.5, 'ge' ) ) { // Only enqueue color picker style and dependency if WP version is 3.5 or higher 288 wp_enqueue_style( 'wp-color-picker' ); 289 wp_enqueue_script( 'side-matter-admin-js', plugins_url( 'js/side-matter-admin.js', __FILE__ ), array( 'wp-color-picker' ), $this->version, true ); 290 } else { 291 wp_enqueue_script( 'side-matter-admin-js', plugins_url( 'js/side-matter-admin.js', __FILE__ ), false, $this->version, true ); 292 } 276 293 277 294 } … … 279 296 public function add_plugins_link( $actions ) { // Link to Side Matter's options menu from Plugins screen 280 297 $url = admin_url( 'options-reading.php' ); 281 $array = array( 'settings' => "<a href='{$url}'>Settings</a>" ); 298 $settings_string = __( 'Settings', 'side-matter' ); 299 $array = array( 'settings' => "<a href='{$url}'>{$settings_string}</a>" ); 282 300 return array_merge( $array, $actions ); 283 301 } 284 302 285 public function shortcode( $atts, $content = null ) { // Send shortcode content to add_note(), and return formatted reference figure via print_ref()303 public function shortcode( $atts, $content = null ) { // Send shortcode content to add_note(), and return formatted reference figure via format_ref() 286 304 global $side_matter; 287 305 if ( ! $side_matter->check_page() ) { // Only return figure on this page if permitted by user settings … … 289 307 } else { 290 308 $note_id = $side_matter->add_note( $content ); // add_note() returns number of this note 291 $ref = $side_matter-> print_ref( $note_id ); // Get formatted reference figure from print_ref()309 $ref = $side_matter->format_ref( $note_id ); // Get formatted reference figure from format_ref() 292 310 return $ref; 293 311 } … … 306 324 'html_class' => __( $this->options['html_class'] ) 307 325 ) ); 308 wp_enqueue_style( 'side-matter', plugins_url( 'css/side-matter.css', __FILE__ ), null, $this->version , 'screen');326 wp_enqueue_style( 'side-matter', plugins_url( 'css/side-matter.css', __FILE__ ), null, $this->version ); 309 327 } 310 328 } … … 318 336 class Side_Matter { 319 337 338 public $options = array(); 320 339 public $notes = array(); 340 public $figures = array(); 321 341 322 342 public function __construct() { // Register custom action 'side_matter_list_notes' for use in widget or elsewhere 343 global $side_matter_admin; 323 344 add_action( 'side_matter_list_notes', array( &$this, 'list_notes' ) ); 345 $this->options = $side_matter_admin->options; 346 $this->figures = array( 347 '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 ), 348 '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 ), 349 'hebrew' => array( 'ת' => 400, 'ש' => 300, 'ר' => 200, 'ק' => 100, 'צ' => 90, 'פ' => 80, 'ע' => 70, 'ס' => 60, 'נ' => 50, 'מ' => 40, 'ל' => 30, 'כ' => 20, 'יט' => 19, 'יח' => 18, 'יז' => 17, 'טז' => 16, 'טו' => 15, 'י' => 10, 'ט' => 9, 'ח' => 8, 'ז' => 7, 'ו' => 6, 'ה' => 5, 'ד' => 4, 'ג' => 3, 'ב' => 2, 'א' => 1 ), 350 'lower-alpha' => array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ), 351 'lower-greek' => array( 'α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω' ), 352 '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 ) 353 ); 324 354 } 325 355 326 356 public function check_page() { // Check whether to display Side Matter elements on current page based on user settings 327 global $side_matter_admin; 328 extract( $side_matter_admin->options['pages_active'], EXTR_SKIP ); 357 extract( $this->options['pages_active'], EXTR_SKIP ); 329 358 $check_pages = array( 330 359 ( is_front_page() && $front ), … … 340 369 } 341 370 342 public function get_attr( $attr ) { // Generate inline style and type attributes for HTML tags 343 global $side_matter_admin; 344 $options = $side_matter_admin->options; 345 switch ( $attr ) { 346 case 'figure_color': 347 case 'text_color': 348 if ( ! $options['user_colors']['colors_enabled'] ) { 349 return; 350 } else { 351 $output = ' style="color: ' . $options['user_colors']['colors'][ $attr ] . '"'; 352 return $output; 353 } 354 break; 355 case 'type': 356 $type = array( 357 'decimal' => '1', 358 'lower-alpha' => 'a', 359 'lower-roman' => 'i' 360 ); 361 $value = $type[ $options['figure_style'] ]; 362 return " type='{$value}'"; 363 break; 364 default: 365 return; 366 break; 367 } 368 } 369 370 public function add_note( $content ) { // Add current note's content to array $notes and return its number 371 if ( count( $this->notes ) == 0 ) { 372 $this->notes[1] = $content; 373 } else { 374 $this->notes[] = $content; 375 } 376 $note_id = count( $this->notes ); 377 return $note_id; 378 } 379 380 public function print_ref( $note_id ) { // Obtain reference figure from get_figure() and add HTML markup 381 382 global $side_matter_admin; 383 384 $options = $side_matter_admin->options; 385 $class = $options['html_class']; 386 $figure_color = $options['user_colors']['colors']['figure_color']; 387 $ref_figure = $this->get_figure( $note_id ); 388 $note_text = $this->notes[ $note_id ]; 389 $title_text = esc_attr( strip_tags( str_replace( "\n", ' ', $note_text ) ) ); // Strip note of tags and line breaks for use in title attribute 390 $title_attr = " title='Note {$note_id}. {$title_text}'"; 391 $style_attr = $this->get_attr( 'figure_color' ); 392 393 $ref_output = "<a id='ref-{$note_id}' class='{$class} {$class}-ref {$class}-ref-{$note_id}' href='#note-{$note_id}'{$title_attr}{$style_attr}><sup class='{$class} {$class}-sup {$class}-sup-{$note_id}'>{$ref_figure}</sup></a>"; 394 return $ref_output; 395 396 } 397 398 public function get_figure( $note_id ) { // Convert note number to alternate figure format based on user settings 399 global $side_matter_admin; 400 switch ( $side_matter_admin->options['figure_style'] ) { 371 public function get_figure( $note_id, $style ) { // Convert numeral to alternate format 372 373 $figures = $this->figures; 374 375 switch ( $style ) { 376 case 'armenian': 377 case 'georgian': 378 case 'hebrew': 379 case 'lower-roman': 380 return $this->get_additive( $note_id, $figures[ $style ] ); 381 break; 382 case 'lower-greek': 401 383 case 'lower-alpha': 402 return $this->get_ latin( $note_id);403 break; 404 case ' lower-roman':405 return $this->get_roman( $note_id );384 return $this->get_alpha( $note_id, $figures[ $style ] ); 385 break; 386 case 'none': 387 return ''; 406 388 break; 407 389 case 'decimal': … … 410 392 break; 411 393 } 412 } 413 414 public function get_latin( $note_id ) { // Convert number to Latin alphabetical figure 415 $latin = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' );416 $count = count( $ latin);394 395 } 396 397 public function get_alpha( $note_id, $set ) { // Convert note number to alphabetic numeral 398 $count = count( $set ); 417 399 $value = $note_id--; 418 400 $figure = ''; … … 420 402 $value--; 421 403 $index = ( $value % $count ); 422 $figure = $ latin[ $index ] . $figure;404 $figure = $set[ $index ] . $figure; 423 405 $value = floor( $value / $count ); 424 406 } … … 426 408 } 427 409 428 public function get_roman( $note_id ) { // Convert number to Roman numeral figure 429 $roman = array( 430 'm' => 1000, 431 'cm' => 900, 432 'd' => 500, 433 'cd' => 400, 434 'c' => 100, 435 'xc' => 90, 436 'l' => 50, 437 'xl' => 40, 438 'x' => 10, 439 'ix' => 9, 440 'v' => 5, 441 'iv' => 4, 442 'i' => 1 443 ); 410 public function get_additive( $note_id, $set ) { // Convert note number to additive numeral 444 411 $value = $note_id--; 445 412 $figure = ''; 446 413 while ( $value > 0 ) { 447 $weight = reset( $ roman);448 $key = key( $ roman);449 unset( $ roman[ $key ] );414 $weight = reset( $set ); 415 $key = key( $set ); 416 unset( $set[ $key ] ); 450 417 $length = floor( $value / $weight ); 451 418 $figure .= str_repeat( $key, $length ); 452 $value = $value -( $weight * $length );419 $value -= ( $weight * $length ); 453 420 } 454 421 return $figure; 455 422 } 456 423 457 public function list_notes() { // Generate HTML-formatted ordered list of Side Matter notes 458 424 public function add_note( $content ) { // Add current note's content to array $notes and return its number 425 if ( count( $this->notes ) == 0 ) { 426 $this->notes[1] = $content; 427 } else { 428 $this->notes[] = $content; 429 } 430 $note_id = count( $this->notes ); 431 return $note_id; 432 } 433 434 public function format_ref( $note_id ) { // Obtain reference figure from get_figure() and add HTML markup 435 436 global $is_IE; 437 438 $options = $this->options; 439 extract( $options ); 440 441 $ref_figure = ( $figure_style != 'decimal' ) ? $this->get_figure( $note_id, $figure_style ) : $note_id; 442 443 $note_text = $this->notes[ $note_id ]; 444 445 $title_text = esc_attr( strip_tags( str_replace( array( "\n", "\r" ), ' ', $note_text ) ) ); // Strip note of tags and line breaks for use in title attribute 446 447 $a_title = ( ! $is_IE ) ? " title='{$title_text}'" : ''; 448 $sup_title = ( ! $is_IE ) ? '' : "title='{$title_text}'"; // Workaround for IE bug wherein links containing an inline child element do not display title attribute on hover (uses sup tag instead) 449 450 $figure_color_style = ( $user_colors['colors_enabled'] ) ? ' style="color: ' . $user_colors['colors']['figure_color'] . '"' : ''; 451 452 $open_sup = "<sup class='{$html_class} {$html_class}-sup'{$sup_title}>"; 453 $close_sup = '</sup>'; 454 if ( $options['figure_style'] == 'none' ) { // Don't print sup tag if figure_style setting is 'none' 455 $open_sup = $close_sup = $ref_figure = ''; 456 } 457 458 $ref_output = "<a id='ref-{$note_id}' class='{$html_class} {$html_class}-ref' href='#note-{$note_id}'{$a_title}{$figure_color_style}>{$open_sup}{$ref_figure}{$close_sup}</a>"; 459 return $ref_output; 460 461 } 462 463 public function list_notes() { // Print HTML-formatted list of Side Matter notes 459 464 if ( ! $this->check_page() ) { 460 465 return; 461 466 } else { 462 467 463 global $side_matter_admin; 464 $options = $side_matter_admin->options; 465 468 $options = $this->options; 469 $figures = $this->figures; 470 471 extract( $options ); 466 472 extract( $options['user_colors']['colors'] ); 467 473 468 $class = $options['html_class']; 469 $style = $options['figure_style']; 470 $figure_color_attr = $this->get_attr( 'figure_color' ); 471 $text_color_attr = $this->get_attr( 'text_color' ); 472 $type_attr = $this->get_attr( 'type' ); 474 $list_style_type = "list-style-type: {$figure_style};"; 475 $figure_color_style = "color: {$figure_color};"; 476 $text_color_style = "color: {$text_color};"; 473 477 474 478 ?> 475 <ol class='<?php echo $ class ?> <?php echo $class ?>-list'<?php echo $figure_color_attr ?>>479 <ol class='<?php echo $html_class ?> <?php echo $html_class ?>-list' style='<?php echo $list_style_type ?><?php if ( $options['user_colors']['colors_enabled'] ) echo ' ' . $figure_color_style ?>'> 476 480 <?php 477 481 foreach ( $this->notes as $note_id => $note_text ) { 478 $note_text = wpautop( $note_text ); // Re-enclose notes in paragraph tags to fix any shortcode-caused weirdness 479 ?> 480 <li id='note-<?php echo $note_id ?>' class='<?php echo $class ?> <?php echo $class ?>-note <?php echo $class ?>-note-<?php echo $note_id ?>'<?php echo $type_attr ?>><div class='<?php echo $class ?> <?php echo $class ?>-text <?php echo $class ?>-text-<?php echo $note_id ?>'<?php echo $text_color_attr ?>><?php echo $note_text ?></div></li> 482 $note_text = wpautop( $note_text ); // Re-enclose notes in paragraph tags to fix tags broken by shortcode 483 ?> 484 <li id='note-<?php echo $note_id ?>' class='<?php echo $html_class ?> <?php echo $html_class ?>-note'> 485 <div class='<?php echo $html_class ?> <?php echo $html_class ?>-text'<?php if ( $options['user_colors']['colors_enabled'] ) echo " style='{$text_color_style}'" ?>> 486 <?php echo $note_text ?> 487 </div> 488 </li> 481 489 <?php 482 490 } … … 494 502 495 503 public function __construct() { // Register widget name and description 496 parent::__construct( 'side-matter', __( 'Side Matter' ), array( 'description' => __( 'Display Side Matter notes in an ordered list' ) ) );504 parent::__construct( 'side-matter', __( 'Side Matter', 'side-matter' ), array( 'description' => __( 'Display Side Matter notes in an ordered list', 'side-matter' ) ) ); 497 505 } 498 506 … … 511 519 512 520 public function form( $instance ) { // Widget admin panel 513 ?> 514 Modify Side Matter's default settings using the options menu on your <a href='<?php echo admin_url( 'options-reading.php' ) ?>'>Reading Settings</a> screen. 515 <?php 521 $options_url = admin_url( 'options-reading.php' ); 522 printf( __( 'Modify default settings using the options menu on your %1$sReading Settings%2$s screen.', 'side-matter' ), "<a href='{$options_url}'>", '</a>' ); 516 523 } 517 524 -
side-matter/trunk/uninstall.php
r710765 r741424 2 2 /* 3 3 uninstall.php 4 Version 0.94 Version 1.0 5 5 6 6 Plugin: Side Matter
Note: See TracChangeset
for help on using the changeset viewer.