| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | * Plugin Name: AdminPad |
| 4 | 4 | * Plugin URI: https://wordpress.org/plugins/adminpad/ |
| 5 | 5 | * Description: Simple note taker for WP site administrators only. |
| 6 | 6 | * Author: Iftekhar Bhuiyan |
| 7 | - * Version: 2.6 | |
| 7 | + * Version: 2.7.1 | |
| 8 | 8 | * Author URI: https://profiles.wordpress.org/iftekharbhuiyan/ |
| 9 | 9 | * License: GPLv2 or later |
| 10 | 10 | * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 11 | 11 | * Text Domain: adminpad |
| @@ -24,38 +24,41 @@ | ||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // display form and save |
| 27 | 27 | function bsft_adminpad_form() { |
| 28 | - $content = htmlspecialchars_decode(get_option('adminpad_content')); | |
| 29 | - $data = empty($content) ? '' : $content; | |
| 30 | 28 | // submission check |
| 31 | - if (isset($_POST['adminpad_save']) && isset($_POST['adminpad_nonce']) && wp_verify_nonce($_POST['adminpad_nonce'], basename(__FILE__))) { | |
| 32 | - $note = stripslashes_deep(htmlspecialchars($_POST['adminpad_content'])); | |
| 33 | - if (get_option('adminpad_content') !== false) { | |
| 34 | - update_option('adminpad_content', $note); | |
| 35 | - } else { | |
| 36 | - add_option('adminpad_content', $note); | |
| 29 | + if (isset($_POST['adminpad_submit']) && check_admin_referer('adminpad_nonce_action', 'adminpad_nonce' ) ) { | |
| 30 | + if (isset($_POST['adminpad_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['adminpad_nonce'])), 'adminpad_nonce_action')) { | |
| 31 | + if (isset($_POST['adminpad_content']) && !empty($_POST['adminpad_content'])) { | |
| 32 | + $note = wp_kses_post(wp_unslash($_POST['adminpad_content'])); | |
| 33 | + // add or update | |
| 34 | + if (get_option('adminpad_content') !== false) { | |
| 35 | + update_option('adminpad_content', $note); | |
| 36 | + } else { | |
| 37 | + add_option('adminpad_content', $note); | |
| 38 | + } | |
| 39 | + } | |
| 37 | 40 | } |
| 38 | - echo '<meta http-equiv="refresh" content="0">'; | |
| 39 | - } else { | |
| 40 | - echo '<form action="'.admin_url('index.php').'" method="POST">'; | |
| 41 | - echo '<input type="hidden" id="adminpad_nonce" name="adminpad_nonce" value="'.wp_create_nonce(basename(__FILE__)).'">'; | |
| 42 | - echo '<div id="adminpad-content" class="textarea-wrap">'; | |
| 43 | - wp_editor( | |
| 44 | - $data, | |
| 45 | - 'adminpad_content_id', | |
| 46 | - array( | |
| 47 | - 'textarea_name' => 'adminpad_content', | |
| 48 | - 'media_buttons' => true, | |
| 49 | - 'quicktag' => false | |
| 50 | - ) | |
| 51 | - ); | |
| 52 | - echo '</div>'; | |
| 53 | - echo '<p style="margin-bottom:0;">'; | |
| 54 | - echo '<input type="hidden" name="adminpad_save" id="adminpad_save" value="true">'; | |
| 55 | - echo '<button type="submit" class="button button-primary">Save Note</button>'; | |
| 56 | - echo '</p></form>'; | |
| 57 | 41 | } |
| 42 | + // adminpad content | |
| 43 | + $content = htmlspecialchars_decode(get_option('adminpad_content')); | |
| 44 | + $data = empty($content) ? '' : $content; | |
| 45 | + // content form | |
| 46 | + echo '<form action="'.esc_url(admin_url('index.php')).'" method="POST">'; | |
| 47 | + echo '<div style="margin-bottom: 10px;">'; | |
| 48 | + wp_editor( | |
| 49 | + $data, | |
| 50 | + 'adminpad_content_id', | |
| 51 | + array( | |
| 52 | + 'textarea_name' => 'adminpad_content', | |
| 53 | + 'media_buttons' => true, | |
| 54 | + 'quicktag' => false | |
| 55 | + ) | |
| 56 | + ); | |
| 57 | + echo '</div>'; | |
| 58 | + submit_button('Save Note', 'primary', 'adminpad_submit'); | |
| 59 | + wp_nonce_field('adminpad_nonce_action', 'adminpad_nonce'); | |
| 60 | + echo '</form>'; | |
| 58 | 61 | } |
| 59 | 62 | |
| 60 | 63 | // uninstalling adminpad |
| 61 | 64 | function bsft_adminpad_uninstall() { |