Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion aaa-option-optimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@
function aaa_option_optimizer_activation() {
global $wpdb;

// Create the custom table.
// Create the custom tables.
Progress_Planner\OptionOptimizer\Database::create_table();
Progress_Planner\OptionOptimizer\Database::create_quarantine_table();

// Schedule the daily quarantine cleanup event.
if ( ! wp_next_scheduled( 'aaa_option_optimizer_quarantine_cleanup' ) ) {
wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', 'aaa_option_optimizer_quarantine_cleanup' );
}

$autoload_values = \wp_autoload_values_to_autoload();
$placeholders = implode( ',', array_fill( 0, count( $autoload_values ), '%s' ) );
Expand Down Expand Up @@ -73,6 +79,12 @@ function aaa_option_optimizer_activation() {
function aaa_option_optimizer_deactivation() {
$aaa_option_value = get_option( 'option_optimizer' );
update_option( 'option_optimizer', $aaa_option_value, false );

// Unschedule the quarantine cleanup event.
$timestamp = wp_next_scheduled( 'aaa_option_optimizer_quarantine_cleanup' );
if ( $timestamp ) {
wp_unschedule_event( $timestamp, 'aaa_option_optimizer_quarantine_cleanup' );
}
}

/**
Expand All @@ -92,6 +104,16 @@ function aaa_option_optimizer_maybe_upgrade() {
if ( ! Progress_Planner\OptionOptimizer\Database::table_exists() ) {
Progress_Planner\OptionOptimizer\Database::create_table();
}

// Check if quarantine table exists, create if not.
if ( ! Progress_Planner\OptionOptimizer\Database::quarantine_table_exists() ) {
Progress_Planner\OptionOptimizer\Database::create_quarantine_table();
}

// Ensure cleanup event is scheduled (covers installs that predate this feature).
if ( ! wp_next_scheduled( 'aaa_option_optimizer_quarantine_cleanup' ) ) {
wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', 'aaa_option_optimizer_quarantine_cleanup' );
}
}
add_action( 'plugins_loaded', 'aaa_option_optimizer_maybe_upgrade' );

Expand Down
4 changes: 3 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
.aaa_option_table .actions .button {
margin-right: 10px;
}
.aaa_option_table .actions > .button:last-child {
margin-right: 0;
}
.aaa_option_table select {
max-width: 20% !important;
}
Expand All @@ -27,7 +30,6 @@
max-width: 200px !important;
}
.aaa_option_table .actions .button-delete, .aaa-option-optimizer-reset .button-delete {
margin-right: 0;
color: #a00;
border-color: #a00;
}
Expand Down
Loading
Loading