PluginProbe
AdminPad / 2.6
AdminPad v2.6
2.7.1 trunk 2.6 2.7
adminpad / adminpad.php

adminpad.php in AdminPad 2.6, at adminpad.php

72 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: AdminPad
4 * Plugin URI: https://wordpress.org/plugins/adminpad/
5 * Description: Simple note taker for WP site administrators only.
6 * Author: Iftekhar Bhuiyan
7 * Version: 2.6
8 * Author URI: https://profiles.wordpress.org/iftekharbhuiyan/
9 * License: GPLv2 or later
10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: adminpad
12 */
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 if (is_admin()) {
18
19 // register widget
20 function bsft_adminpad_widget() {
21 if (current_user_can('activate_plugins')) {
22 wp_add_dashboard_widget('adminpad', 'AdminPad', 'bsft_adminpad_form');
23 }
24 }
25
26 // display form and save
27 function bsft_adminpad_form() {
28 $content = htmlspecialchars_decode(get_option('adminpad_content'));
29 $data = empty($content) ? '' : $content;
30 // 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);
37 }
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 }
58 }
59
60 // uninstalling adminpad
61 function bsft_adminpad_uninstall() {
62 if (current_user_can('activate_plugins')) {
63 delete_option('adminpad_content');
64 }
65 }
66
67 // let's hook
68 add_action('wp_dashboard_setup', 'bsft_adminpad_widget');
69 register_uninstall_hook( __FILE__, 'bsft_adminpad_uninstall');
70
71 }
72 ?>