prefix . 'devat_Adnotes';
if($wpdb->get_var("SHOW TABLES LIKE '" . $table_name ."'") != $table_name) {
$sql = "CREATE TABLE $table_name (
task_id bigint(20) not null auto_increment,
notes text not null default '',
unique key id(task_id)
);";
$results = $wpdb->query($sql);
// Add initial data
$sql = "INSERT INTO `$table_name` (notes) VALUES ('An easy day, nothing to do')";
$results = $wpdb->query($sql);
}
}
// --------------------------------------------------------------------
// Adds the ToDo page under Manage
// --------------------------------------------------------------------
function todo_addpages() {
add_management_page('Manage your admin notes ', 'Admin Notes', 8, 'adnotes', array('devat', 'todo_addoption'));
}
// --------------------------------------------------------------------
// Responsible for rendering the Admin Notes page under Manage
// --------------------------------------------------------------------
function todo_addoption()
{
global $otd_message;
global $wpdb;
if (!empty($otd_message)){
$donegood = '
';
}
$table_name = $wpdb->prefix . 'devat_Adnotes';
$adminNotes = $wpdb->get_var("SELECT notes FROM $table_name WHERE task_id=1");
$output_html = $donegood . '';
echo $output_html;
}
}
// --------------------------------------------------------------------
// Called when user clicks activate in the plugin menu
// --------------------------------------------------------------------
if (isset($_GET['activate']) && $_GET['activate'] == 'true') {
if (defined('WPINC') && strpos($_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME']) > 0) {
add_action('init', array('devat', 'todo_install'));
}
}
// --------------------------------------------------------------------
// Insert the mt_add_pages() sink into the plugin hook list for 'admin_menu'
// --------------------------------------------------------------------
add_action('admin_menu', array('devat', 'todo_addpages'));
// --------------------------------------------------------------------
// Add Admin Notes To Dashboard
// --------------------------------------------------------------------
add_action('activity_box_end', 'devat_get_todo');
// --------------------------------------------------------------------
// Handle post requests
// --------------------------------------------------------------------
$name = $_POST["operation"];
if('update' == $name) {
global $otd_message;
global $wpdb;
$table_name = $wpdb->prefix . 'devat_Adnotes';
$wpdb->query("UPDATE $table_name SET notes='" . $wpdb->escape($_POST['notes']) . "'");
$otd_message = "Admin Notes Updated";
}
// --------------------------------------------------------------------
// Echo To DashBoard
// --------------------------------------------------------------------
function devat_get_todo()
{
global $wpdb;
$table_name = $wpdb->prefix . 'devat_Adnotes';
$adminNotes = $wpdb->get_var("SELECT notes FROM $table_name WHERE task_id=1");
echo 'Admin Notes
' . $adminNotes;
}
?>