-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
108 lines (89 loc) · 3.61 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/*
Plugin Name: Maintenance Checklist
Plugin URI: http://www.thewpvalet.com/plugins/Maintenance-Checklist
Description: To help keep your WordPress site running on it's best, you need to be sure to keep it maintained. Maintenance Checklist provides you a checklist and reminders of maintenance tasks to keep your WordPress website running at its peak.
Version: 1.0
Author: Eric Hoanshelt
Author URI: http://erichoanshelt.me
License: GPL2
*/
include('includes/functions.php');
include('includes/admin_dashboard.php');
include('includes/screen-meta-links.php');
//Runs that when plugin is activated
//Sets array to default options
function wpv_maintenance_activation(){
if(!get_option('wpv_maintenance_tracking')){
$wpv_maintenance_options = array(
'backup' => array(
'ID' => 'backup',
'name' => 'Backup',
'value' => 'false',
'increment' => 'd',
'date_completed'=> date('Y-m-d')),
'spam-trash-comments' => array(
'ID' => 'spam-trash-comments',
'name' => 'Spam & Trash Comment Removal',
'value' => 'false',
'increment' => 'm',
'date_completed'=> date('Y-m-d')),
'post-revisions' => array(
'ID' => 'post-revisions',
'name' => 'Post Revision Removal',
'value' => 'false',
'increment' => 'm',
'date_completed'=> date('Y-m-d')),
'db-optimize' => array(
'ID' => 'db-optimize',
'name' => 'Database Optimization',
'value' => 'false',
'increment' => 'm',
'date_completed'=> date('Y-m-d')),
'malware-scan' => array(
'ID' => 'malware-scan',
'name' => 'Malware Scan',
'value' => 'false',
'increment' => 'm',
'date_completed'=> date('Y-m-d')));
update_option('wpv_maintenance_tracking', $wpv_maintenance_options);
}
}
register_activation_hook(__FILE__, 'wpv_maintenance_activation');
function wpv_style_method() {
wp_register_style('wpv-plugin-style',plugins_url('maintenance-checklist/style/maintenance-checklist-style.css'));
wp_enqueue_style('wpv-plugin-style');
}
add_action('admin_init', 'wpv_style_method');
function add_screen_meta(){
echo "<script type='text/javascript'>jQuery(document).ready(function(){
jQuery('#screen-meta').append('<div id=\"maintenance-checklist\" class=\"hidden\">" . wpv_notify_admin() . "</div>');})</script>";
}
add_action('admin_head', 'add_screen_meta');
//Notification Handler for admin
function wpv_notify_admin(){
$maintenance_values = wpv_get_maintenance_values();
$comma_separated = implode(",", $maintenance_values);
$wpv_maintenance_message;
if(wpv_check_for_false_values()){
foreach($maintenance_values as $value){
if($value['value'] == 'false'){
$wpv_maintenance_message .='<p>' . $value['name'] . ' needs to be completed.</p>';
}
}
$wpv_maintenance_message .= '<p>Once you completed the task, go to Settings > <a href="options-general.php?page=maintenance-checklist">Maintenance Checklist</a> and check it off!</p>';
}else{
$wpv_maintenance_message .= '<p>All maintenance tasks have been completed! Go to Settings > <a href="options-general.php?page=maintenance-checklist">Maintenance Checklist</a> and start feeling good!</p>';
}
wpv_check_time_for_maintenance();
return $wpv_maintenance_message;
}
//Simple example. Adds a screen meta link to example.com
//to the main Dashboard page.
add_screen_meta_link(
'wpv-maintenance-checklist', //Link ID. Should be unique.
'Maintenance CheckList', //Link text.
'#maintenance-checklist', //URL
array('index.php','edit.php','edit-comments.php','link-manager.php', 'upload.php', 'themes.php','options-general.php', 'tools.php', 'users.php', 'plugins.php') //Where to show the link.
);
?>