PluginProbe
AdminPad / trunk
AdminPad vtrunk
2.7.1 trunk 2.6 2.7
adminpad / adminpad.php

adminpad.php in AdminPad trunk, at adminpad.php

75 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.7.1
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 // submission check
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 }
40 }
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>';
61 }
62
63 // uninstalling adminpad
64 function bsft_adminpad_uninstall() {
65 if (current_user_can('activate_plugins')) {
66 delete_option('adminpad_content');
67 }
68 }
69
70 // let's hook
71 add_action('wp_dashboard_setup', 'bsft_adminpad_widget');
72 register_uninstall_hook( __FILE__, 'bsft_adminpad_uninstall');
73
74 }
75 ?>