init(); // Initialize backup manager if (class_exists('ACMT_Backup_Manager')) { new ACMT_Backup_Manager(); } // Initialize review notice if (class_exists('ACMT_Review_Notice')) { new ACMT_Review_Notice(); } } function acmt_enqueue_admin_styles() { wp_enqueue_style('acmt-review-notice', ACMT_URL . 'assets/css/review-notice.css', array(), '2.0.1'); } add_action( 'plugins_loaded', 'acmt_init' ); add_action('admin_enqueue_scripts', 'acmt_enqueue_admin_styles'); // Activation Hook - Create Database Tables register_activation_hook( __FILE__, 'acmt_activate' ); function acmt_activate() { global $wpdb; $charset_collate = $wpdb->get_charset_collate(); // Create logs table $logs_table = $wpdb->prefix . 'acmt_logs'; $logs_sql = "CREATE TABLE $logs_table ( 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;"; // Create backups table $backups_table = $wpdb->prefix . 'acmt_backups'; $backups_sql = "CREATE TABLE $backups_table ( id mediumint(9) NOT NULL AUTO_INCREMENT, backup_id varchar(100) NOT NULL UNIQUE, backup_type varchar(20) NOT NULL DEFAULT 'manual', cleanup_type varchar(100) DEFAULT '', file_size bigint(20) NOT NULL DEFAULT 0, created_on datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, status varchar(20) NOT NULL DEFAULT 'completed', PRIMARY KEY (id), KEY created_on (created_on) ) $charset_collate;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta( $logs_sql ); dbDelta( $backups_sql ); // Error handling if ( $wpdb->get_var( "SHOW TABLES LIKE '{$logs_table}'" ) != $logs_table ) { //phpcs:ignore wp_die( esc_html__( 'Failed to create logs table for Advanced Clean Master plugin.', 'advanced-clean-master' ) ); } if ( $wpdb->get_var( "SHOW TABLES LIKE '{$backups_table}'" ) != $backups_table ) { //phpcs:ignore wp_die( esc_html__( 'Failed to create backups table for Advanced Clean Master plugin.', 'advanced-clean-master' ) ); } // Set default options add_option( 'acmt_auto_backup_enabled', 1 ); add_option( 'acmt_backup_retention_days', 30 ); } // 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' ); }