Plugin Directory

Changeset 1505160


Ignore:
Timestamp:
09/29/2016 02:15:43 PM (10 years ago)
Author:
ardmark
Message:

Version 1.01

Location:
responsive-sticky-notes/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • responsive-sticky-notes/trunk/admin/admin.php

    r1430436 r1505160  
    2929*/
    3030function responsivestickynotes_admin_init(){
    31     register_setting( 'plugin_options_group', 'plugin_options', 'plugin_options_validate' );
    32     add_settings_section('plugin_main', 'Main Settings', 'plugin_section_text', 'plugin');
    33     add_settings_field('plugin_text_string', 'Plugin Text Input', 'plugin_setting_string', 'plugin', 'plugin_main');
     31    register_setting( 'responsivestickynotes_options_group', 'responsivestickynotes_options', 'responsivestickynotes_options_validate' );
     32    add_settings_section('responsivestickynotes_main', 'Main Settings', 'responsivestickynotes_section_text', 'responsivestickynotes');
     33    add_settings_field('responsivestickynotes_text_string', 'responsivestickynotes Text Input', 'responsivestickynotes_setting_string', 'responsivestickynotes', 'responsivestickynotes_main');
    3434    //responsivestickynotes_setupDB();
    3535   
     
    432432}
    433433
    434 function plugin_section_text() {
     434function responsivestickynotes_section_text() {
    435435    echo '<p>Main description of this section here.</p>';
    436436}
    437 function plugin_setting_string() {
    438     $options = get_option('plugin_options');
    439     echo "<input id='plugin_text_string' name='plugin_options[text_string]' size='40' type='text' value='{$options['text_string']}' />";
    440 }
    441 
    442 
    443 
    444 
    445 
    446 function plugin_options_validate($plugin_options) {
     437function responsivestickynotes_setting_string() {
     438    $options = get_option('responsivestickynotes_options');
     439    echo "<input id='responsivestickynotes_text_string' name='responsivestickynotes_options[text_string]' size='40' type='text' value='{$options['text_string']}' />";
     440}
     441
     442
     443
     444
     445
     446function responsivestickynotes_options_validate($plugin_options) {
    447447    echo "validated!";
    448448    wp_die();
     
    454454    $listTable = new responsivestickynotes_List_Table();
    455455    //Fetch, prepare, sort, and filter our data...
    456 
     456    ?>
     457
     458<?php
     459    //checkbox in just a few lines of code... how easy is that
     460    $showalways = get_option('responsive-sticky-notes_showalways', 1);
     461    if (isset($_REQUEST['showalways_submit'])) {
     462        $showalways = isset($_REQUEST['showalways']) && $_REQUEST['showalways']=='on' ? 1 : 0;
     463        update_option('responsive-sticky-notes_showalways', $showalways);
     464    }
     465    ?>
     466    <form method="post" action="<?php echo esc_url( add_query_arg( array('page' => 'responsive-sticky-notes'), menu_page_url( 'responsivestickynotes', false ) ) ); ?>">
     467    <table><tr><td>Show notes when not logged in: <input type="checkbox" name="showalways" <?php checked( 0 != $showalways ); ?> /></td><td><?php submit_button('Apply',"submit","showalways_submit"); ?></td></tr></table>
     468       
     469        <?php
    457470    $action = null;
    458471    if (isset($_REQUEST['action'])) {
     
    462475
    463476        ?>
    464                          <div class="wrap">
     477                <div class="wrap">
    465478                 <div id="icon-edit" class="icon32"></div>
    466 
    467479                <h1><?php echo esc_html( __( 'Sticky Notes - help', 'responsive-sticky-notes' ) );?></h1>
    468480                <div style="height: 10px"></div>
     
    473485<p>This plugin lets you add 'sticky' notes to any post or non-admin page. The notes are attached to HTML elements within the page, so are ideal for text annotations or to add extra information to images, etc., and will move with responsive layout changes so they never vanish off the edge of the screen. 
    474486</p>
    475     <p>Sticky notes can be added to any post or non-admin page. To add a note, leave the admin area and go to the page you want to add a note to. Then click the 'Add Sticky Note' button in the top admin bar, and move the cursor over the page. As you move the cursor, page elements are highlighted with an outline. Click again to add a note at this position.</p>
     487<p>Sticky notes can be added to any post or non-admin page. To add a note, leave the admin area and go to the page you want to add a note to. Then click the 'Add Sticky Note' button in the top admin bar, and move the cursor over the page. As you move the cursor, page elements are highlighted with an outline. Click again to add a note at this position.</p>
    476488<p>Notes are attached to the beginning of a page element, i.e. at the top left corner of a &ltp&gt;, &ltdiv&gt;, etc. A note can be attached to anything on a page.</p>
    477489<p>Once you have added a note, click it to open it. Then type text as required - it is saved as you type.
  • responsive-sticky-notes/trunk/admin/class-wp-list-table-copy.php

    r1430436 r1505160  
    163163        if ( empty( $this->modes ) ) {
    164164            $this->modes = array(
    165                 'list'    => __( 'List View', 'sticky-notes' ),
    166                 'excerpt' => __( 'Excerpt View', 'sticky-notes' )
     165                'list'    => __( 'List View', 'responsive-sticky-notes' ),
     166                'excerpt' => __( 'Excerpt View', 'responsive-sticky-notes' )
    167167            );
    168168        }
     
    465465        echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
    466466        echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
    467         echo '<option value="-1">' . __( 'Bulk Actions', 'sticky-notes' ) . "</option>\n";
     467        echo '<option value="-1">' . __( 'Bulk Actions', 'responsive-sticky-notes' ) . "</option>\n";
    468468
    469469        foreach ( $this->_actions as $name => $title ) {
     
    475475        echo "</select>\n";
    476476
    477         submit_button( __( 'Apply', 'sticky-notes' ), 'action', '', false, array( 'id' => "doaction$two" ) );
     477        submit_button( __( 'Apply', 'responsive-sticky-notes' ), 'action', '', false, array( 'id' => "doaction$two" ) );
    478478        echo "\n";
    479479    }
     
    525525        $out .= '</div>';
    526526
    527         $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'sticky-notes' ) . '</span></button>';
     527        $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'responsive-sticky-notes' ) . '</span></button>';
    528528
    529529        return $out;
     
    603603                esc_attr( $arc_row->year . $month ),
    604604                /* translators: 1: month name, 2: 4-digit year */
    605                 sprintf( __( '%1$s %2$d', 'sticky-notes' ), $wp_locale->get_month( $month ), $year )
     605                sprintf( __( '%1$s %2$d', 'responsive-sticky-notes' ), $wp_locale->get_month( $month ), $year )
    606606            );
    607607        }
     
    662662        if ( ! $approved_comments && ! $pending_comments ) {
    663663            printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
    664                 __( 'No comments', 'sticky-notes' )
     664                __( 'No comments', 'responsive-sticky-notes' )
    665665            );
    666666        // Approved comments have different display depending on some conditions.
     
    674674            printf( '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
    675675                $approved_comments_number,
    676                 $pending_comments ? __( 'No approved comments', 'sticky-notes' ) : __( 'No comments', 'sticky-notes' )
     676                $pending_comments ? __( 'No approved comments', 'responsive-sticky-notes' ) : __( 'No comments', 'responsive-sticky-notes' )
    677677            );
    678678        }
     
    799799            $page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    800800                esc_url( remove_query_arg( 'paged', $current_url ) ),
    801                 __( 'First page', 'sticky-notes' ),
     801                __( 'First page', 'responsive-sticky-notes' ),
    802802                '&laquo;'
    803803            );
     
    809809            $page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    810810                esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
    811                 __( 'Previous page', 'sticky-notes' ),
     811                __( 'Previous page', 'responsive-sticky-notes' ),
    812812                '&lsaquo;'
    813813            );
     
    816816        if ( 'bottom' === $which ) {
    817817            $html_current_page  = $current;
    818             $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'sticky-notes' ) . '</span><span id="table-paging" class="paging-input">';
     818            $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'responsive-sticky-notes' ) . '</span><span id="table-paging" class="paging-input">';
    819819        } else {
    820820            $html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
    821                 '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'sticky-notes' ) . '</label>',
     821                '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'responsive-sticky-notes' ) . '</label>',
    822822                $current,
    823823                strlen( $total_pages )
     
    832832            $page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    833833                esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
    834                 __( 'Next page', 'sticky-notes' ),
     834                __( 'Next page', 'responsive-sticky-notes' ),
    835835                '&rsaquo;'
    836836            );
     
    842842            $page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
    843843                esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
    844                 __( 'Last page', 'sticky-notes' ),
     844                __( 'Last page', 'responsive-sticky-notes' ),
    845845                '&raquo;'
    846846            );
     
    10701070        if ( ! empty( $columns['cb'] ) ) {
    10711071            static $cb_counter = 1;
    1072             $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'sticky-notes' ) . '</label>'
     1072            $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'responsive-sticky-notes' ) . '</label>'
    10731073                . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
    10741074            $cb_counter++;
     
    13251325     */
    13261326    protected function handle_row_actions( $item, $column_name, $primary ) {
    1327         return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'sticky-notes' ) . '</span></button>' : '';
     1327        return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'responsive-sticky-notes' ) . '</span></button>' : '';
    13281328    }
    13291329
  • responsive-sticky-notes/trunk/includes.php

    r1430436 r1505160  
    1111    require_once('admin/admin.php');
    1212
     13
    1314}
    1415
  • responsive-sticky-notes/trunk/js/sticky-notes-note.js

    r1430436 r1505160  
    3030        this.id='responsive-sticky-notes-' + this.postId;
    3131        this.elementChain = responsivestickynotes_obj.stripTrailingHash(this.elementChain);
    32         console.log(this.elementChain)
    3332        this.obj = jQuery(this.elementChain);
    3433        responsivestickynotes_obj.highestZ++;
  • responsive-sticky-notes/trunk/js/sticky-notes-single.js

    r1430436 r1505160  
    289289            s = classList[i] + s;
    290290
    291             console.log(s);
    292291            if (i==classList.length) {
    293292                prevS = s;
     
    352351        var note = new responsivestickynote(elementChain,tooltip, text, postId, admin_url, bgcol, col);
    353352
    354     },
    355     updateElementChain: function(id, elementChain) {
    356         var data = {
    357                 'action': 'responsivestickynotes_update_elementchain',
    358                 'security': responsivestickynotes_vars.postNoteNonce,
    359                 'id':id,
    360                 'elementchain':elementChain
    361             };
    362    
    363             jQuery.ajax({
    364                 url: ajaxurl,
    365                 data: data,
    366                 error: function() {
    367                     console.log("error updating elementchain (1)")
    368                     note.hasChanged = true;
    369                      setTimeout(function() {
    370                          note.checkForChanges();
    371                      },1000);
    372                 },
    373                 success: function(data) {
    374                     if (data=="error") {
    375                         console.log("error updating elementchain: "+ note.numeridId)
    376                     }
    377                 },
    378                 method: 'POST'
    379             });
    380353    },
    381354    removeNote: function(id) {
     
    579552                error: function(e) {
    580553                //  error - remove note
    581                     responsivestickynotes_obj.removeNote(nextId);
    582554                    console.log("no id from server (error function) - removing note")
    583555                },
     
    585557                    if (data==="error") {
    586558                        //error - remove note
    587                         responsivestickynotes_obj.removeNote(nextId);
    588559                        console.log("no id from server (error message returned) - removing note")
    589560                    }
     
    607578//instantiate
    608579var responsivestickynotes_obj = new responsivestickynotes_object();
    609 jQuery(window).on("load", function() {
     580jQuery(document).ready(function() {
    610581    responsivestickynotes_obj.init();
    611582});
  • responsive-sticky-notes/trunk/readme.txt

    r1495156 r1505160  
    5656Notes are specific to the page they are created on, and cannot currently be shared between posts or pages
    5757
     58= Can notes be shown to anyone or just logged-in users =
     59
     60There is an option to 'Show notes when not logged in' on the admin page
     61
    5862== Changelog ==
    5963
     
    6569* AJAX error will not automatically delete a note
    6670* Option added to allow notes to be hidden from non-admin users
     71= 1.01 =
     72* Fixed bug where user without edit priviledges could add a note (briefly)
    6773
  • responsive-sticky-notes/trunk/responsive-sticky-notes.php

    r1430436 r1505160  
    33Plugin Name: Responsive Sticky Notes
    44Plugin URI: http://www.nantinet.com/
    5 Description: Responsive sticky notes which can be added to posts and pages
    6 Version: 0.1
     5Description: Easily add 'sticky' notes which move with responsive layout changes
     6Version: 1.0
    77Author: Richard Mark Watton
    88Author URI: http://www.nantinet.com
    99Text Domain: responsive-sticky-notes
    10 Version: 1.0
    1110License: GPLv2 or later
    1211*/
     
    4746
    4847//ACTIONS
     48
    4949add_action( 'wp_enqueue_scripts', 'responsivestickynotes_loadscripts' );
    50 add_action( 'wp_head','responsivestickynotes_ajaxurl');
    51 add_action( 'init', 'responsivestickynotes_create_posttype');
    52 
    53 if (!is_admin())
    54     add_action('admin_bar_menu', 'responsivestickynotes_add_admin_button', 999);
    55 
    5650
    5751function responsivestickynotes_loadscripts()
    5852{
     53    $loadNotes = false;
     54    $showalways = get_option('responsive-sticky-notes_showalways',1); //default is to show always, in case of upgrade
    5955
    60     wp_register_script( 'todo_notes_note', plugins_url( '/js/sticky-notes-note.js', __FILE__ ), array( 'jquery'), false, true );
    61     wp_register_script( 'todo_notes_single', plugins_url( '/js/sticky-notes-single.js', __FILE__ ), array( 'todo_notes_note'), false, true );
    62     wp_enqueue_script( 'todo_notes_note' );
    63     wp_enqueue_script( 'todo_notes_single' );   
     56    if ($showalways != 0) $loadNotes = true;
     57    else {
     58        $current_user = wp_get_current_user();
     59        $loadNotes = RESPONSIVESTICKYNOTES_note::can_edit();
     60    }
    6461
    65     wp_localize_script( 'todo_notes_note', 'responsivestickynotes_vars', array(
    66             //nonce will be available as MyAjax.[nonce name] in javascript
    67             'postNoteNonce' => wp_create_nonce( 'myajax-post-note-nonce' ),
    68             'pageId' => get_the_ID(),
    69             'nextId' => RESPONSIVESTICKYNOTES_note::get_next_ID(),
    70             'close' => __('Close', 'responsive-sticky-notes'),
    71             'more' => __('More', 'responsive-sticky-notes'),
    72             'menu' => __('Menu', 'responsive-sticky-notes'),
    73             'bin_note' => __('Bin note', 'responsive-sticky-notes'),
    74             'set_note_color' => __('Set note color', 'responsive-sticky-notes'),
    75             'untitled_note' => __('Untitled note', 'responsive-sticky-notes'),
    76             'delete_this_note' => __('Delete this note?', 'responsive-sticky-notes')
    77     )
    78     );
    79     wp_enqueue_style( 'responsivestickynotes_styles',  plugins_url('/css/responsive-sticky-notes.css', __FILE__ ) );
     62    if ($loadNotes==true) {
     63
     64        add_action( 'wp_head','responsivestickynotes_ajaxurl');
     65        add_action( 'init', 'responsivestickynotes_create_posttype');
     66       
     67        if (!is_admin()&&RESPONSIVESTICKYNOTES_note::can_edit())
     68            add_action('admin_bar_menu', 'responsivestickynotes_add_admin_button', 998);
     69   
     70
     71        wp_register_script( 'todo_notes_note', plugins_url( '/js/sticky-notes-note.js', __FILE__ ), array( 'jquery'), false, true );
     72        wp_register_script( 'todo_notes_single', plugins_url( '/js/sticky-notes-single.js', __FILE__ ), array( 'todo_notes_note'), false, true );
     73        wp_enqueue_script( 'todo_notes_note' );
     74        wp_enqueue_script( 'todo_notes_single' );   
     75   
     76        wp_localize_script( 'todo_notes_note', 'responsivestickynotes_vars', array(
     77                //nonce will be available as MyAjax.[nonce name] in javascript
     78                'postNoteNonce' => wp_create_nonce( 'myajax-post-note-nonce' ),
     79                'pageId' => get_the_ID(),
     80                'nextId' => RESPONSIVESTICKYNOTES_note::get_next_ID(),
     81                'close' => __('Close', 'responsive-sticky-notes'),
     82                'more' => __('More', 'responsive-sticky-notes'),
     83                'menu' => __('Menu', 'responsive-sticky-notes'),
     84                'bin_note' => __('Bin note', 'responsive-sticky-notes'),
     85                'set_note_color' => __('Set note color', 'responsive-sticky-notes'),
     86                'untitled_note' => __('Untitled note', 'responsive-sticky-notes'),
     87                'delete_this_note' => __('Delete this note?', 'responsive-sticky-notes')
     88        )
     89        );
     90        wp_enqueue_style( 'responsivestickynotes_styles',  plugins_url('/css/responsive-sticky-notes.css', __FILE__ ) );
     91    }
    8092}
    8193
Note: See TracChangeset for help on using the changeset viewer.