Plugin Directory

Changeset 3030188


Ignore:
Timestamp:
02/01/2024 03:30:59 PM (2 years ago)
Author:
arapps92
Message:

Version 1.3.1

Location:
dashboard-to-do-list
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • dashboard-to-do-list/trunk/admin/todo-widget.php

    r3030090 r3030188  
    33
    44if ( !function_exists( 'ardtdw_widgetsetup' ) ) {
    5 function ardtdw_widgetsetup() {
    6     if(get_option('ardtdw-checkbox-admineditor')) {
    7         if(current_user_can('administrator') || current_user_can('editor')) {
    8             wp_add_dashboard_widget('ardtdw', 'Website To-Do List', 'ardtdw_widget');
    9         }
    10     } else if(current_user_can('administrator')) {
    11         wp_add_dashboard_widget('ardtdw', 'Website To-Do List', 'ardtdw_widget');
     5    function ardtdw_widgetsetup() {
     6            if(current_user_can('administrator') || (current_user_can('editor') && get_option('ardtdw-checkbox-admineditor'))) {
     7                wp_add_dashboard_widget('ardtdw', 'Website To-Do List', 'ardtdw_widget');
     8            }
    129    }
    13 }
    14 add_action('wp_dashboard_setup', 'ardtdw_widgetsetup');
     10    add_action('wp_dashboard_setup', 'ardtdw_widgetsetup');
    1511}
    1612
    1713if ( !function_exists( 'ardtdw_widgetupdate' ) ) {
    18 function ardtdw_widgetupdate(){
    19     if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
    20         if( isset($_POST['ardtdw-save']) || wp_verify_nonce( $_POST['ardtdw_confirm'], 'ardtdw_update_list' ) ) {
    21             if(isset ($_POST['ardtdw-textarea'])) {
    22                 update_option(
    23                     'ardtdw-textarea',
    24                     wp_kses($_POST['ardtdw-textarea'],
    25                     array(
    26                     'a' => array(
    27                         'href' => array(),
    28                         'target' => array(),
    29                         'title' => array()
    30                     ),
    31                     'em' => array(),
    32                     'strong' => array(),
    33                     'b' => array(),
    34                     'u' => array(),
    35                     )
    36                 ),
    37                 '',
    38                 'yes'
    39             );
     14    function ardtdw_widgetupdate(){
     15        if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
     16            if( isset($_POST['ardtdw-save']) || wp_verify_nonce( $_POST['ardtdw_confirm'], 'ardtdw_update_list' ) ) {
     17                if(isset($_POST['ardtdw-textarea'])) {
     18                    update_option(
     19                        'ardtdw-textarea',
     20                        wp_kses($_POST['ardtdw-textarea'],
     21                        array(
     22                            'a' => array(
     23                                'href' => array(),
     24                                'target' => array(),
     25                                'title' => array()
     26                            ),
     27                            'em' => array(),
     28                            'strong' => array(),
     29                            'b' => array(),
     30                            'u' => array(),
     31                        )
     32                    ),
     33                    '',
     34                    'yes'
     35                );
    4036            }
    4137
    42             $ardtdw_checkbox = (isset($_POST['ardtdw-checkbox'])) ? $_POST['ardtdw-checkbox'] : '';
    43             $ardtdw_checkbox_editor = (isset($_POST['ardtdw-checkbox-editor'])) ? $_POST['ardtdw-checkbox-editor'] : '';
    44             $ardtdw_checkbox_admineditor = (isset($_POST['ardtdw-checkbox-admineditor'])) ? $_POST['ardtdw-checkbox-admineditor'] : '';
    45             $ardtdw_position = (isset($_POST['ardtdw-position'])) ? $_POST['ardtdw-position'] : '';
     38            if(current_user_can('administrator')) {
     39                $ardtdw_checkbox = (isset($_POST['ardtdw-checkbox'])) ? $_POST['ardtdw-checkbox'] : '';
     40                $ardtdw_checkbox_editor = (isset($_POST['ardtdw-checkbox-editor'])) ? $_POST['ardtdw-checkbox-editor'] : '';
     41                $ardtdw_checkbox_admineditor = (isset($_POST['ardtdw-checkbox-admineditor'])) ? $_POST['ardtdw-checkbox-admineditor'] : '';
     42                $ardtdw_position = (isset($_POST['ardtdw-position'])) ? $_POST['ardtdw-position'] : '';
    4643
    47             if ($ardtdw_checkbox || $ardtdw_checkbox_editor) {
    48                 if (empty($_POST['ardtdw-textarea'])) { ?>
    49                     <div class="ardtdw-message ardtdw-error">
    50                     <p><?php _e( 'You must have at least one to-do in your list to display it on the website!','dashboard-to-do-list'); ?></p>
    51                 </div>
    52                 <?php
    53                 $ardtdw_checkbox = '';
    54                 $ardtdw_checkbox_editor = '';
    55             } else { ?>
    56                 <div class="ardtdw-message ardtdw-updated">
    57                     <p><?php _e( 'To-Do list updated. List now shows on the website.','dashboard-to-do-list'); ?></p>
    58                 </div>
    59                 <?php
     44                if ($ardtdw_checkbox || $ardtdw_checkbox_editor) {
     45                    if (empty($_POST['ardtdw-textarea'])) { ?>
     46                        <div class="ardtdw-message ardtdw-error">
     47                            <p><?php _e( 'You must have at least one to-do in your list to display it on the website!','dashboard-to-do-list'); ?></p>
     48                        </div>
     49                        <?php
     50                        $ardtdw_checkbox = '';
     51                        $ardtdw_checkbox_editor = '';
     52                    } else { ?>
     53                        <div class="ardtdw-message ardtdw-updated">
     54                            <p><?php _e( 'To-Do list updated. List now shows on the website.','dashboard-to-do-list'); ?></p>
     55                        </div>
     56                        <?php
     57                    }
     58                } else { ?>
     59                    <div class="ardtdw-message ardtdw-updated">
     60                        <p><?php _e( 'To-Do list updated.','dashboard-to-do-list'); ?></p>
     61                    </div>
     62                    <?php
     63                }
     64
     65                update_option('ardtdw-checkbox', absint($ardtdw_checkbox));
     66                update_option('ardtdw-checkbox-editor', absint($ardtdw_checkbox_editor));
     67                update_option('ardtdw-checkbox-admineditor', absint($ardtdw_checkbox_admineditor));
     68                update_option('ardtdw-position', $ardtdw_position);
     69
     70            } else if(current_user_can('editor')) {
     71                if(isset($_POST['ardtdw-textarea'])) { ?>
     72                    <div class="ardtdw-message ardtdw-updated">
     73                        <p><?php _e( 'To-Do list updated.','dashboard-to-do-list'); ?></p>
     74                    </div>
     75                <?php }
    6076            }
    61         } else { ?>
    62             <div class="ardtdw-message ardtdw-updated">
    63                 <p><?php _e( 'To-Do list updated.','dashboard-to-do-list'); ?></p>
    64             </div>
    65             <?php
    66         }
    67 
    68             update_option('ardtdw-checkbox', absint($ardtdw_checkbox));
    69             update_option('ardtdw-checkbox-editor', absint($ardtdw_checkbox_editor));
    70             update_option('ardtdw-checkbox-admineditor', absint($ardtdw_checkbox_admineditor));
    71             update_option('ardtdw-position', $ardtdw_position);
    72 
    7377        }
    7478    }
     
    7781
    7882if ( !function_exists( 'ardtdw_widget' ) ) {
    79 function ardtdw_widget() {
    80     ardtdw_widgetupdate();
    81     $ardtdw_callbackURL = get_site_url();
    82     $ardtdw_TextArea = stripslashes(get_option('ardtdw-textarea'));
    83     $ardtdw_CheckBox = get_option('ardtdw-checkbox');
    84     $ardtdw_CheckBox_Editor = get_option('ardtdw-checkbox-editor');
    85     $ardtdw_CheckBox_adminEditor = get_option('ardtdw-checkbox-admineditor');
    86     $ardtdw_Position = get_option('ardtdw-position');
    87     $ardtdw_Position = (empty($ardtdw_Position) || $ardtdw_Position == '0' || $ardtdw_Position == '' || $ardtdw_Position == 'undefined' ) ? 'right' : get_option('ardtdw-position');
    88     ?>
    89     <form action='<?php echo $ardtdw_callbackURL ?>/wp-admin/index.php' method='post'>
     83    function ardtdw_widget() {
     84        ardtdw_widgetupdate();
     85        $ardtdw_callbackURL = get_site_url();
     86        $ardtdw_TextArea = stripslashes(get_option('ardtdw-textarea'));
     87        $ardtdw_CheckBox = get_option('ardtdw-checkbox');
     88        $ardtdw_CheckBox_Editor = get_option('ardtdw-checkbox-editor');
     89        $ardtdw_CheckBox_adminEditor = get_option('ardtdw-checkbox-admineditor');
     90        $ardtdw_Position = get_option('ardtdw-position');
     91        $ardtdw_Position = (empty($ardtdw_Position) || $ardtdw_Position == '0' || $ardtdw_Position == '' || $ardtdw_Position == 'undefined' ) ? 'right' : get_option('ardtdw-position');
     92        ?>
     93        <form action='<?php echo $ardtdw_callbackURL ?>/wp-admin/index.php' method='post'>
    9094
    91         <?php if(current_user_can('administrator')) { ?>
    92             <p><label for='ardtdw-checkbox-admineditor'><input name='ardtdw-checkbox-admineditor' type='checkbox' id='ardtdw-checkbox-admineditor' value='1' <?php checked( esc_html($ardtdw_CheckBox_adminEditor), true) ?> /><?php _e( 'Allow Editors to view and edit this To-Do list','dashboard-to-do-list'); ?></label></p>
    93         <?php } ?>
    94         <textarea name='ardtdw-textarea' id='ardtdw-textarea' rows='10'><?php echo esc_html($ardtdw_TextArea) ?></textarea><p/>
    95         <p class='field-comment'><?php _e( 'One to-do per line. Accepts the following HTML tags: a (href, title, target), em, strong, b, u.','dashboard-to-do-list'); ?></p>
    96         <?php if(current_user_can('administrator')) { ?>
    97             <p><label for='ardtdw-checkbox'><input name='ardtdw-checkbox' type='checkbox' id='ardtdw-checkbox' value='1' <?php checked( esc_html($ardtdw_CheckBox), true) ?> /><?php _e( 'Show list on website for Administrators','dashboard-to-do-list'); ?></label></p>
    98             <p><label for='ardtdw-checkbox-editor'><input name='ardtdw-checkbox-editor' type='checkbox' id='ardtdw-checkbox-editor' value='1' <?php checked( esc_html($ardtdw_CheckBox_Editor), true) ?> /><?php _e( 'Show list on website for Editors','dashboard-to-do-list'); ?></label></p>
    99         <p>
    100             <strong><?php _e( 'List Position:','dashboard-to-do-list'); ?></strong></br>
     95            <?php if(current_user_can('administrator')) { ?>
     96                <p><label for='ardtdw-checkbox-admineditor'><input name='ardtdw-checkbox-admineditor' type='checkbox' id='ardtdw-checkbox-admineditor' value='1' <?php checked( esc_html($ardtdw_CheckBox_adminEditor), true) ?> /><?php _e( 'Allow Editors to view and edit this To-Do list','dashboard-to-do-list'); ?></label></p>
     97            <?php } ?>
     98            <textarea name='ardtdw-textarea' id='ardtdw-textarea' rows='10'><?php echo esc_html($ardtdw_TextArea) ?></textarea><p/>
     99            <p class='field-comment'><?php _e( 'One to-do per line. Accepts the following HTML tags: a (href, title, target), em, strong, b, u.','dashboard-to-do-list'); ?></p>
     100            <?php if(current_user_can('administrator')) { ?>
     101                <p><label for='ardtdw-checkbox'><input name='ardtdw-checkbox' type='checkbox' id='ardtdw-checkbox' value='1' <?php checked( esc_html($ardtdw_CheckBox), true) ?> /><?php _e( 'Show list on website for Administrators','dashboard-to-do-list'); ?></label></p>
     102                <p><label for='ardtdw-checkbox-editor'><input name='ardtdw-checkbox-editor' type='checkbox' id='ardtdw-checkbox-editor' value='1' <?php checked( esc_html($ardtdw_CheckBox_Editor), true) ?> /><?php _e( 'Show list on website for Editors','dashboard-to-do-list'); ?></label></p>
     103                <p>
     104                    <strong><?php _e( 'List Position:','dashboard-to-do-list'); ?></strong></br>
    101105
    102             <label><input type="radio" name="ardtdw-position" value="left" <?php echo ($ardtdw_Position == 'left') ? 'checked' : ''; ?>> <?php _e( 'Left aligned', 'dashboard-to-do-list' ); ?></label>
    103             &nbsp;&nbsp;
    104             <label><input type="radio" name="ardtdw-position" value="right" <?php echo ($ardtdw_Position == 'right') ? 'checked' : ''; ?>> <?php _e( 'Right aligned', 'dashboard-to-do-list' ); ?></label>
    105         </p>
    106         <?php } ?>
    107         <input type='submit' value='<?php _e( 'Save','dashboard-to-do-list'); ?>' class='button-primary' name='ardtdw-save'>
    108         <?php wp_nonce_field( 'ardtdw_update_list', 'ardtdw_confirm' ); ?>
    109     </form>
    110     <?php
    111 }
     106                    <label><input type="radio" name="ardtdw-position" value="left" <?php echo ($ardtdw_Position == 'left') ? 'checked' : ''; ?>> <?php _e( 'Left aligned', 'dashboard-to-do-list' ); ?></label>
     107                    &nbsp;&nbsp;
     108                    <label><input type="radio" name="ardtdw-position" value="right" <?php echo ($ardtdw_Position == 'right') ? 'checked' : ''; ?>> <?php _e( 'Right aligned', 'dashboard-to-do-list' ); ?></label>
     109                </p>
     110            <?php } ?>
     111            <input type='submit' value='<?php _e( 'Save','dashboard-to-do-list'); ?>' class='button-primary' name='ardtdw-save'>
     112            <?php wp_nonce_field( 'ardtdw_update_list', 'ardtdw_confirm' ); ?>
     113        </form>
     114        <?php
     115    }
    112116}
    113117
    114     if (get_option('ardtdw-textarea')) {
    115         if ( !function_exists( 'ardtdw_widgethtml' ) ) {
    116             function ardtdw_widgethtml() {
    117                 if ((get_option('ardtdw-checkbox') && current_user_can('administrator'))
    118                 || (get_option('ardtdw-checkbox-editor') && current_user_can('editor'))) {
    119                     ardtdw_widget_html();
    120                 }
     118if (get_option('ardtdw-textarea')) {
     119    if ( !function_exists( 'ardtdw_widgethtml' ) ) {
     120        function ardtdw_widgethtml() {
     121            if ((get_option('ardtdw-checkbox') && current_user_can('administrator'))
     122            || (get_option('ardtdw-checkbox-editor') && current_user_can('editor'))) {
     123                ardtdw_widget_html();
    121124            }
    122     add_action('wp_footer', 'ardtdw_widgethtml');
     125        }
     126        add_action('wp_footer', 'ardtdw_widgethtml');
    123127    }
    124128}
  • dashboard-to-do-list/trunk/readme.txt

    r3030126 r3030188  
    66Tested up to: 6.4
    77Requires PHP: 5.6
    8 Stable version: 1.3.0
     8Stable version: 1.3.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4141
    4242== Screenshots ==
    43 1. Dashboard Widget
    44 2. To-Do list on the frontend
     431. Administrator's view of the Dashboard Website To-Do List Widget
     442. Editor's view of the Dashboard Website To-Do List Widget
     453. To-Do list on the frontend
     46
     47== Frequently Asked Questions ==
     48
     49= How do I use Dashboard To-Do List =
     50
     51Once Dashboard To-Do List is installed, simply go to the Admin Dashboard page and you'll see the Website To-Do List widget. Use the textbox to write your list, one to-do per line.
     52
     53= I need help with something else =
     54
     55If your question is not answered here, please create a new topic in the [WordPress support forum](https://wordpress.org/support/plugin/dashboard-to-do-list/).
    4556
    4657== Changelog ==
     58= 1.3.1 =
     59* Fixed capabilities bug when saving the widget if switching between user roles (thanks to chrslcy).
     60
    4761= 1.3.0 =
    4862* Fixed bug where any authenticated user (subscriber+) could modify the To-Do list widget
  • dashboard-to-do-list/trunk/tdlw.php

    r3030090 r3030188  
    33    Plugin Name: Dashboard To-Do List
    44    Description: Dashboard To-Do list widget with option to show as a floating list on your website.
    5     Version: 1.3.0
     5    Version: 1.3.1
    66    Author: Andrew Rapps
    77    Author URI: https://arwebdesign.co.uk
Note: See TracChangeset for help on using the changeset viewer.