Plugin Directory

Changeset 835324


Ignore:
Timestamp:
01/09/2014 07:05:20 AM (12 years ago)
Author:
setzer
Message:

1.4 to trunk

Location:
side-matter
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • side-matter

    • Property svn:ignore set to
      .DS_Store
  • side-matter/trunk/css/side-matter-admin.css

    r770431 r835324  
    11/*
    22side-matter-admin.css
    3 Version 1.3
     3Version 1.4
    44
    55Plugin: Side Matter
     
    1010
    1111.side-matter-preview {
    12     display: inline-block;
    1312    background: #eee;
    1413    border: 1px solid #bbb;
    1514    border-radius: 2px;
    16     box-shadow: inset rgba(0,0,0,0.15) 1px 1px 1px;
     15    padding: 1.25em 2em;
     16    width: 32em;
    1717    -webkit-touch-callout: none;
    1818    -webkit-user-select: none;
     
    2828
    2929.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;
    4132}
    4233
    4334.side-matter-preview-main {
    44     vertical-align: top;
    45     display: inline-block;
    46     padding-right: 5em;
    4735    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;
    4842}
    4943
    5044.side-matter-preview-side {
    51     vertical-align: top;
    52     display: inline-block;
    5345    width: 10em;
     46    float: left;
     47    font-size: small;
    5448}
    5549
    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 {
    6351    position: relative;
    6452    top: -0.5em;
     
    6654    font-size: 0.75em;
    6755    line-height: 0;
     56}
     57
     58.side-matter-preview-clear {
     59    clear: both;
    6860}
    6961
     
    7567    color: #333;
    7668}
     69
     70.note-adjust-dir {
     71    margin-left: 8px;
     72}
  • side-matter/trunk/css/side-matter.css

    r770431 r835324  
    11/*
    22side-matter.css
    3 Version 1.3
     3Version 1.4
    44
    55Plugin: Side Matter
     
    1010
    1111/*
    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, 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/>.
     12A 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/>.
    1313
    14 The below is default Side Matter CSS. These rules have low specificity, and are easily superseded by theme or user CSS.
     14The below is default Side Matter CSS. These rules have low specificity, and are easily superseded by theme or user style settings.
    1515*/
    1616
    17 a.side-matter-ref:link,
    18 a.side-matter-ref:visited,
    19 a.side-matter-ref:hover,
    20 a.side-matter-ref:active {
     17a.side-matter:link,
     18a.side-matter:visited,
     19a.side-matter:hover,
     20a.side-matter:active {
    2121    text-decoration: none;
    2222}
  • side-matter/trunk/js/side-matter-admin.js

    r770431 r835324  
    11/*
    22side-matter-admin.js
    3 Version 1.3
     3Version 1.4
    44
    55Plugin: Side Matter
     
    3535$(document).ready(function() { // Assign initial values, position note in preview field, and load color pickers
    3636
     37    if ($('.side-matter-use-effects').prop('checked')) $('.side-matter-preview-list').css('opacity', 0);
     38
    3739    fieldIsDark = 0;
    3840    figureColor = $('.side-matter-figure-color').val();
    3941    textColor = $('.side-matter-text-color').val();
    40 
    41     placeNote();
    4242
    4343    $('.side-matter-figure-color').wpColorPicker(figureOptions);
     
    5151    }
    5252
     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);
    5358});
    5459
     
    6570var figureOptions = {
    6671    change: function(event, ui) {
    67         $('.side-matter-preview-ref,.side-matter-preview-note').css('color', ui.color.toString());
    68     },
    69     palettes: false
     72        $('.side-matter-preview-ref,.side-matter-preview-note').css('color', ui.color.toString());
     73    },
     74    palettes: false
    7075};
    7176
    7277var textOptions = {
    7378    change: function(event, ui) {
    74         $('.side-matter-preview-text').css('color', ui.color.toString());
    75     },
    76     palettes: false
     79        $('.side-matter-preview-text').css('color', ui.color.toString());
     80    },
     81    palettes: false
    7782};
    7883
     
    107112
    108113$('.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()]);
    110115    $('.side-matter-preview-note').css('listStyleType', $(this).val());
     116    placeNote();
    111117});
    112118
     
    117123});
    118124
     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
    119133})(jQuery);
  • side-matter/trunk/js/side-matter.js

    r770431 r835324  
    11/*
    22side-matter.js
    3 Version 1.3
     3Version 1.4
    44
    55Plugin: Side Matter
     
    3636
    3737$(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
    3939    if (useEffects == 1) $('ol.' + htmlClass + '-list').fadeTo(360, 1);
    4040});
  • side-matter/trunk/readme.txt

    r800230 r835324  
    33Tags: 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
    44Requires at least: 3.0
    5 Tested up to: 3.7.1
     5Tested up to: 3.8
    66Stable tag: 1.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
    10 Turns footnotes into sidenotes, magically positioning each note in the sidebar next to its corresponding reference in the text.
     10Turns footnotes into sidenotes, magically aligning each note in the sidebar next to its corresponding reference in the text.
    1111
    1212== Description ==
    1313
    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.
     14Side 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.
    1515
    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:
     16To use, place the Side Matter widget in your sidebar, then enclose sidenote text in a page or post using the `[ref]` shortcode, like so:
    1917
    2018    Here's the text to annotate.[ref]Note text goes here.[/ref]
    2119
     20To change default settings, use the Side Matter options page linked under the Appearance menu on your admin screen.
     21
    2222== Installation ==
    2323
    24 1. Upload the directory `side-matter` to `/wp-content/plugins`.
     241. Upload the `side-matter` directory to `/wp-content/plugins`.
    25252. Activate Side Matter using the Plugins screen.
    26263. 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]`
     274. Use the `[ref]` shortcode to generate notes in posts and pages, like so: `[ref]Note text goes here.[/ref]`
    2828
    29 To change the plugin's default settings, use the Side Matter options menu on your Reading Settings screen.
     29To change default settings, use the Side Matter options page linked under the Appearance menu on your admin screen.
    3030
    31 For information on changing the appearance of Side Matter elements using CSS, see [Other Notes](http://wordpress.org/extend/plugins/side-matter/other_notes/).
     31For information on changing the appearance of Side Matter elements with CSS, see [Other Notes](http://wordpress.org/extend/plugins/side-matter/other_notes/).
    3232
    3333== Frequently Asked Questions ==
    3434
    35 = Where is Side Matter's options menu? =
     35= Where is the options menu? =
    3636
    37 You can find the options menu on your Reading Settings screen.
     37As 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.
    3838
    3939= My notes don't appear. =
    4040
    41 Some themes are one-column by design and do not include a sidebar. Without a sidebar, Side Matter has no place to generate your notes. Make sure that your theme includes a sidebar and that you've placed the Side Matter widget within that sidebar.
     41Many 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.
    4242
    4343= My notes just sit at the top of the sidebar. =
    4444
    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.
     45This 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.
    4646
    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).)
     47Theme 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).)
    4848
    4949= Why doesn't the plugin work with my theme? =
    5050
    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 to consult your theme's developer.
     51Not 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.
    5252
    5353= My notes appear at a vertical offset. =
    5454
    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.
     55Some 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.
    6456
    6557= Can sidenotes be displayed without using the widget? =
     
    7365== Screenshots ==
    7466
    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.
     671. Side Matter in action.
    7668
    77 2. Change default settings using Side Matter's options menu on the Reading Settings screen.
     692. Default settings may be changed using Side Matter's options menu.
    7870
    7971== 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]`.
    8078
    8179= 1.3 =
     
    143141== Upgrade Notice ==
    144142
    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 =
     144As of this release, Side Matter's options menu has been moved from the Reading Settings screen to its own page under the Appearance menu.
    147145
    148146== Styling Side Matter with CSS ==
    149147
    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/).)
     148Changing 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.)
    151149
    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:
     150Side 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:
    155151
    156152    .side-matter {
    157153        color: blue;
    158154        font-family: serif;
    159         font-size: 12px;
    160155    }
    161156
    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 red and sidenote text in black:
     157Notes 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:
    163158
    164159    a.side-matter-ref, ol.side-matter-list {
    165         color: red;
     160        color: green;
    166161    }
    167162   
     
    170165    }
    171166
    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 
    178167= List of Class Selectors =
    179 Here is a complete list of Side Matter element class selectors and their uses:
     168Here is a full list of Side Matter class selectors and their uses:
    180169
    181170* `a.side-matter-ref` selects the link elements that enclose in-text reference numerals. Use this class to modify the links' colors, underline, etc.
    182171* `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.
    183172* `.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 all list numerals.
     173* `ol.side-matter-list` selects the `ol` (ordered list) element that encloses notes in the sidebar, including list numerals.
    185174* `li.side-matter-note` selects sidenote `li` (list item) elements, including each note's numeral.
    186175* `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.
    187176
    188 WordPress further wraps each note paragraph in a tag of its own, but these `p` elements cannot be selected directly using the `side-matter` class. Instead, select them indirectly, e.g. `div.side-matter-text > p`.
     177Each 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`.
    189178
    190179= 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.
     180Side 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.
    192181
    193182The first rule removes underlines from reference numeral links:
    194183
    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 {
    199188        text-decoration: none;
    200189    }
    201190
    202 The second rule specifies a consistent cross-browser, cross-theme appearance for superscript figures:
     191The second rule specifies a consistent cross-browser, cross-theme format for superscript figures:
    203192   
    204193    sup.side-matter-sup {
  • side-matter/trunk/side-matter.php

    r770431 r835324  
    33Plugin Name: Side Matter
    44Plugin 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.3
     5Description: Turns footnotes into sidenotes, magically aligning each note in the sidebar next to its corresponding reference in the text.
     6Version: 1.4
    77Author: Christopher Setzer
    88Author URI: http://christophersetzer.com
     
    1313
    1414/*
    15 Copyright (C) 2013  Christopher Setzer
     15Copyright (C) 2014  Christopher Setzer
    1616
    1717This program is free software; you can redistribute it and/or
     
    3030*/
    3131
    32 $side_matter_admin = new Side_Matter_Admin;
    3332$side_matter = new Side_Matter;
    3433
    35 class Side_Matter_Admin {
     34class Side_Matter {
     35
     36    public $version;
    3637
    3738    public $defaults;
    3839    public $options;
    39     public $version;
    40 
    41     public function __construct() { // Set up defaults, register actions
     40   
     41    public $notes;
     42
     43    public function __construct() {
    4244
    4345        add_action( 'admin_init', array( &$this, 'load_textdomain' ) ); // Load text domain 'side-matter' for localization
    4446        add_action( 'admin_init', array( &$this, 'build_settings_section' ) ); // Assemble settings section
     47        add_action( 'admin_menu', array( &$this, 'admin_add_settings_page' ) );
    4548        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, 'add_quicktag' ) ); // Load quicktag script for post/page HTML editor
     49        add_action( 'admin_print_footer_scripts', array( &$this, 'admin_add_quicktag' ) ); // Load quicktag script for post/page HTML editor
    4750        add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( &$this, 'add_plugins_link' ) ); // Link options menu from Plugins screen
    4851
     
    5154
    5255        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
    5358
    5459        $this->defaults = array( // Set option defaults
     
    7378            );
    7479        $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 plugin
     80        $this->version = (string) '1.4'; // Current version of plugin
    7681
    7782    }
     
    8287    }
    8388
     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
    84106    public function build_settings_section() { // Assemble Side Matter options menu
    85107
    86108        $section = 'side_matter_section';
    87         $page = 'reading';
     109        $page = 'side-matter';
    88110        $callback = array( &$this, 'build_field' );
    89111        $fields = array(
     
    108130                'label_for' => 'side-matter-figure-style',
    109131                'styles' => array(
     132                    'none' => __( 'None', 'side-matter' ),
    110133                    'decimal' => __( 'Decimal: 1, 2, 3, 4, 5, 6, …', 'side-matter' ),
    111134                    'lower-alpha' => __( 'Latin: a, b, c, d, e, f, …', 'side-matter' ),
     
    116139                    'hebrew' => _x( 'Hebrew: ו ,ה ,ד ,ג ,ב ,א, …', 'Note RTL text reversal of Hebrew characters', 'side-matter' ), // Comma placement is due to RTL text reversal of Hebrew characters
    117140                    'hiragana' => __( 'Hiragana: あ, い, う, え, お, か, …', 'side-matter' ),
    118                     'hiragana-iroha' => __( 'Hiragana (Iroha): い, ろ, は, に, ほ, へ, …' ),
     141                    'hiragana-iroha' => __( 'Hiragana—Iroha: い, ろ, は, に, ほ, へ, …' ),
    119142                    'katakana' => __( 'Katakana: ア, イ, ウ, エ, オ, カ, …', 'side-matter' ),
    120                     'katakana-iroha' => __( 'Katakana (Iroha): イ, ロ, ハ, ニ, ホ, ヘ, …', 'side-matter' ),
    121                     'none' => __( 'None', 'side-matter' )
     143                    'katakana-iroha' => __( 'Katakana—Iroha: イ, ロ, ハ, ニ, ホ, ヘ, …', 'side-matter' )
    122144                    )
    123145                ),
     
    125147                'id' => 'is_responsive',
    126148                'title' => __( 'Responsive Positioning', 'side-matter' ),
    127                 'label' => __( 'Responsively position notes when window is resized or zoomed', 'side-matter' ),
     149                'label' => __( 'Responsively position notes when viewport is resized or zoomed', 'side-matter' ),
    128150                'label_for' => 'side-matter-is-responsive'
    129151                ),
     
    138160                'title' => __( 'Adjust vertical offset of notes by', 'side-matter' ),
    139161                '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'
    144163                ),
    145164            'pages_active' => array(
    146165                'id' => 'pages_active',
    147166                'title' => __( 'Display Side Matter notes on', 'side-matter' ),
     167                'label_for' => 'side-matter-pages-active',
    148168                'pages' => array(
    149169                    'front' => __( 'Front page', 'side-matter' ),
     
    155175            );
    156176
    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 );
    158178        foreach ( $fields as $option => $param ) { // Loop through settings field values and send them, one at a time, to build_field()
    159179            extract( $fields[ $option ] );
     
    165185
    166186    public function build_section_heading() {
    167         return; // Don't build section heading
     187        return; // Don't build a section heading
    168188    }
    169189
     
    185205                    <div class='side-matter-preview-content'>
    186206                        <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.<sup 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.
    188208                        </div>
    189209                        <div class='side-matter-preview-side'>
     
    191211                                <li class='side-matter-preview-note' style='list-style-type: <?php echo $figure_style; ?>;'>
    192212                                    <div class='side-matter-preview-text'>
    193                                         Velit esse cillum dolore eu fugiat nulla pariatur.
     213                                        Velit esse cillum dolore eu fugiat nulla.
    194214                                    </div>
    195215                                </li>
    196216                            </ol>
     217                        </div>
     218                        <div class='side-matter-preview-clear'>
     219                            <!-- empty -->
    197220                        </div>
    198221                    </div>
     
    233256                break;
    234257            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>
    240261                <?php
    241262                break;
     
    272293        $options['is_responsive'] = ( ! isset( $input['is_responsive'] ) ) ? (int) 0 : (int) $input['is_responsive'];
    273294        $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
    275302        foreach ( $defaults['pages_active'] as $page => $setting ) {
    276303            $options['pages_active'][ $page ] = ( ! isset( $input['pages_active'][ $page ] ) ) ? (int) 0 : (int) $input['pages_active'][ $page ];
     
    284311    }
    285312
    286     public function add_quicktag() {
     313    public function admin_add_quicktag() { // Add shortcode quicktag button to post editor menu
    287314        if ( wp_script_is( 'quicktags' ) ) {
    288315            ?>
    289316            <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 );
    291318            </script>
    292319            <?php
     
    295322
    296323    public function admin_enqueue( $hook ) { // Enqueue script and stylesheet for Side Matter options menu
    297         if ( 'options-reading.php' != $hook ) {
    298             return;
    299         }
    300324        global $wp_version;
    301325        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 higher
     326        if ( version_compare( $wp_version, 3.5, 'ge' ) ) { // Only enqueue Iris color picker style and dependency if WP version is 3.5 or higher
    303327            wp_enqueue_style( 'wp-color-picker' );
    304328            wp_enqueue_script( 'side-matter-admin-js', plugins_url( 'js/side-matter-admin.js', __FILE__ ), array( 'wp-color-picker' ), $this->version, true );
     
    308332    }
    309333
    310     public function add_plugins_link( $actions ) { // Link to Side Matter's options menu from Plugins screen
    311         $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' );
    312336        $settings_string = __( 'Settings', 'side-matter' );
    313337        $array = array( 'settings' => "<a href='{$url}'>{$settings_string}</a>" );
     
    315339    }
    316340
    317     public function shortcode( $atts, $content = null ) { // Send shortcode 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()
    318342        global $side_matter;
     343        if ( ! strpos( $content, '[ref]' ) === false ) { // Prevent chaos caused by [ref] within [ref]
     344            $content = str_replace( '[ref]', '&#91;ref&#93;', $content );
     345        }
     346        $content = do_shortcode( $content ); // Do a second pass for shortcodes within note text, like [video]
    319347        if ( ! $side_matter->check_page() ) { // Only return figure on this page if permitted by user settings
    320348            return '';
     
    326354    }
    327355
    328     public function enqueue() { // Load JS and CSS components; embed variables in script
     356    public function enqueue() { // Load JS and CSS components; embed user pref variables in script
    329357        global $side_matter;
    330358        if ( ! $side_matter->check_page() ) {
     
    346374    }
    347375
    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(
    361398            '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 ),
    362399            '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 ),
     
    370407            '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 )
    371408            );
    372     }
    373 
    374     public function check_page() { // Check whether to display Side Matter elements on current page based on user settings
    375         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 format
    390409
    391410        switch ( $style ) {
     411            case 'none':
     412                return '';
     413                break;
    392414            case 'armenian':
    393415            case 'georgian':
    394416            case 'hebrew':
    395417            case 'lower-roman':
    396                 return $this->get_additive( $note_id, $this->figures[ $style ] );
     418                return $this->get_additive( $note_id, $figures[ $style ] );
    397419                break;
    398420            case 'hiragana':
     
    402424            case 'lower-alpha':
    403425            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 ] );
    408427                break;
    409428            case 'decimal':
     
    460479        $note_text = $this->notes[ $note_id ];
    461480
    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
    464486
    465487        $figure_color_style = ( $user_colors['colors_enabled'] ) ? ' style="color: ' . $user_colors['colors']['figure_color'] . '"' : '';
     
    480502        static $lists_count = 0; // Keep static count of Side Matter lists in case of multiple widget instances
    481503
    482         if ( ! $this->check_page() || empty ( $this->notes ) ) {
     504        if ( ! $this->check_page() || ! $this->has_notes() ) {
    483505            return;
    484506        } else {
    485507
    486508            $options = $this->options;
    487             $figures = $this->figures;
    488509
    489510            extract( $options );
     
    493514            $figure_color_style = "color: {$figure_color};";
    494515            $text_color_style = "color: {$text_color};";
     516            $link_style_attr = ( $options['user_colors']['colors_enabled'] ) ? " style='{$figure_color_style}'" : '';
    495517
    496518            $lists_count++; // Add this list to count
     
    532554
    533555        global $side_matter;
    534         if ( ! $side_matter->check_page() || empty ( $side_matter->notes ) ) {
     556        if ( ! $side_matter->check_page() || ! $side_matter->has_notes() ) {
    535557            return;
    536558        } else {
    537             global $side_matter_admin;
    538             $class = $side_matter_admin->options['html_class'];
     559            $class = $side_matter->options['html_class'];
    539560            echo $before_widget;
    540561            echo $before_title . $title . $after_title;
     
    554575        <?php
    555576
    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>' );
    558579
    559580    }
  • side-matter/trunk/uninstall.php

    r770477 r835324  
    22/*
    33uninstall.php
    4 Version 1.3
     4Version 1.4
    55
    66Plugin: Side Matter
     
    1515
    1616delete_option( 'side_matter_options' ); // Remove database field side_matter_options on plugin deletion
    17 delete_option( 'widget_side-matter' ); // Remove widget options on plugin deletion
     17delete_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.