updated plugin Companion Auto Update version 3.8.0

This commit is contained in:
2021-01-17 21:29:01 +00:00
committed by Gitium
parent 8a03c72181
commit 93745b9ce4
7 changed files with 264 additions and 224 deletions

View File

@ -3,7 +3,7 @@
* Plugin Name: Companion Auto Update
* Plugin URI: http://codeermeneer.nl/portfolio/companion-auto-update/
* Description: This plugin auto updates all plugins, all themes and the wordpress core.
* Version: 3.7.1.1
* Version: 3.8.0
* Author: Papin Schipper
* Author URI: http://codeermeneer.nl/
* Contributors: papin
@ -37,12 +37,14 @@ function cau_install( $network_wide ) {
} else {
cau_database_creation();
}
if (! wp_next_scheduled ( 'cau_set_schedule_mail' )) wp_schedule_event( time(), 'daily', 'cau_set_schedule_mail'); // Set schedule for mail etc.
if (! wp_next_scheduled ( 'cau_set_schedule_mail' )) wp_schedule_event( time(), 'daily', 'cau_set_schedule_mail'); // Set schedule for basic notifcations
if (! wp_next_scheduled ( 'cau_custom_hooks_plugins' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_plugins'); // Run custom hooks on plugin updates
if (! wp_next_scheduled ( 'cau_custom_hooks_themes' )) wp_schedule_event( time(), 'daily', 'cau_custom_hooks_themes'); // Run custom hooks on theme updates
if (! wp_next_scheduled ( 'cau_log_updater' )) wp_schedule_event( ( time() - 1800 ), 'daily', 'cau_log_updater'); // Keep the log up to date
if (! wp_next_scheduled ( 'cau_outdated_notifier' )) wp_schedule_event( time(), 'daily', 'cau_outdated_notifier'); // Set schedule for basic notifcations
}
add_action( 'cau_set_schedule_mail', 'cau_check_updates_mail' );
add_action( 'cau_outdated_notifier', 'cau_outdated_notifier_mail' );
add_action( 'wp_update_plugins', 'cau_run_custom_hooks_p' );
add_action( 'wp_update_themes', 'cau_run_custom_hooks_t' );
add_action( 'wp_version_check', 'cau_run_custom_hooks_c' );
@ -77,25 +79,28 @@ function cau_donateUrl() {
// Database version
function cau_db_version() {
return '3.7.0';
return '3.7.2';
}
function cau_database_creation() {
global $wpdb;
// Plugin db info
$cau_db_version = cau_db_version();
$autoupdates = $wpdb->prefix."auto_updates";
$updateLog = $wpdb->prefix."update_log";
// Create db table
// WordPress db info
$charset_collate = $wpdb->get_charset_collate();
// DB table creation queries
$sql = "CREATE TABLE $autoupdates (
id INT(9) NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
onoroff TEXT NOT NULL,
UNIQUE KEY id (id)
)";
) $charset_collate;";
// Create second db table
$sql2 = "CREATE TABLE $updateLog (
id INT(9) NOT NULL AUTO_INCREMENT,
slug VARCHAR(255) NOT NULL,
@ -104,8 +109,9 @@ function cau_database_creation() {
method VARCHAR(10) NOT NULL,
put_on_hold VARCHAR(100) DEFAULT '0',
UNIQUE KEY id (id)
)";
) $charset_collate;";
// Create DB tables
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
dbDelta( $sql2 );
@ -202,11 +208,28 @@ register_deactivation_hook( __FILE__, 'cau_remove' );
// Update
function cau_update_db_check() {
$cau_db_version = cau_db_version();
if ( get_site_option( 'cau_db_version' ) != $cau_db_version ) {
cau_database_creation();
// In 3.7.2 we've added $wpdb->get_charset_collate
if( get_site_option( 'cau_db_version' ) < '3.7.2' ) {
global $wpdb;
$autoupdates = $wpdb->prefix."auto_updates";
$updateLog = $wpdb->prefix."update_log";
$db_charset = constant( 'DB_CHARSET' );
$wpdb->query( "ALTER TABLE $autoupdates CONVERT TO CHARACTER SET $db_charset" );
$wpdb->query( "ALTER TABLE $updateLog CONVERT TO CHARACTER SET $db_charset" );
}
update_option( "cau_db_version", $cau_db_version );
}
}
add_action( 'upgrader_process_complete', 'cau_update_db_check' );