-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadvanced-clean-master.php
77 lines (65 loc) · 2.46 KB
/
advanced-clean-master.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
<?php
/*
Plugin Name: Advanced Clean Master
Description: A plugin to clean and optimize your WordPress site by removing drafts, trashed posts, orphaned media, and more.
Version: 1.0.5
Author: SH Sajal Chowdhury
Author URI: https://easywptools.com
Requires at least: 5.4
Requires PHP: 7.2
Text Domain: advanced-clean-master
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit( esc_html__( 'Direct access is not allowed.', 'advanced-clean-master' ) );
}
// Define plugin constants
define( 'ACMT_PATH', plugin_dir_path( __FILE__ ) );
define( 'ACMT_URL', plugin_dir_url( __FILE__ ) );
// Include required files
require_once ACMT_PATH . 'includes/class-cleanup-tool.php';
require_once ACMT_PATH . 'includes/class-review-notice.php';
// Initialize the plugin
function acmt_init() {
// Initialize main plugin
$plugin = new ACMT_Cleanup();
$plugin->init();
// Initialize review notice
if (class_exists('ACMT_Review_Notice')) {
new ACMT_Review_Notice();
}
// Enqueue review notice styles
add_action('admin_enqueue_scripts', 'acmt_enqueue_admin_styles');
}
function acmt_enqueue_admin_styles() {
wp_enqueue_style('acmt-review-notice', ACMT_URL . 'assets/css/review-notice.css', array(), '1.0.0');
}
add_action( 'plugins_loaded', 'acmt_init' );
// Activation Hook - Create Logs Table
register_activation_hook( __FILE__, 'acmt_activate' );
function acmt_activate() {
global $wpdb;
$table_name = $wpdb->prefix . 'acmt_logs'; // Shortened table prefix
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
cleanup_type varchar(100) NOT NULL,
cleaned_count int(11) NOT NULL,
cleaned_on datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $sql );
// Error handling
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) != $table_name ) { //phpcs:ignore
wp_die( esc_html__( 'Failed to create database table for Advanced Clean Master plugin.', 'advanced-clean-master' ) );
}
}
// Deactivation Hook - Clear Scheduled Events
register_deactivation_hook( __FILE__, 'acmt_deactivate' );
function acmt_deactivate() {
wp_clear_scheduled_hook( 'acmt_daily_event' );
wp_clear_scheduled_hook( 'acmt_weekly_event' );
}