updated plugin `Companion Auto Update` version 3.8.2

This commit is contained in:
KawaiiPunk 2021-07-25 23:24:59 +00:00 committed by Gitium
parent e80e4be44b
commit d7964b08bd
7 changed files with 3556 additions and 3482 deletions

View File

@ -26,11 +26,11 @@ if( isset( $_POST['submit'] ) ) {
$table_name = $wpdb->prefix . "auto_updates";
// Auto updater
if( isset( $_POST['plugins'] ) ) $plugins = sanitize_text_field( $_POST['plugins'] ); else $plugins = '';
if( isset( $_POST['themes'] ) ) $themes = sanitize_text_field( $_POST['themes'] ); else $themes = '';
if( isset( $_POST['minor'] ) ) $minor = sanitize_text_field( $_POST['minor'] ); else $minor = '';
if( isset( $_POST['major'] ) ) $major = sanitize_text_field( $_POST['major'] ); else $major = '';
if( isset( $_POST['translations'] ) ) $translations = sanitize_text_field( $_POST['translations'] ); else $translations = '';
$plugins = isset( $_POST['plugins'] ) ? sanitize_text_field( $_POST['plugins'] ) : '';
$themes = isset( $_POST['themes'] ) ? sanitize_text_field( $_POST['themes'] ) : '';
$minor = isset( $_POST['minor'] ) ? sanitize_text_field( $_POST['minor'] ) : '';
$major = isset( $_POST['major'] ) ? sanitize_text_field( $_POST['major'] ) : '';
$translations = isset( $_POST['translations'] ) ? sanitize_text_field( $_POST['translations'] ) : '';
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'plugins'", $plugins ) );
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'themes'", $themes ) );
@ -39,12 +39,13 @@ if( isset( $_POST['submit'] ) ) {
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'translations'", $translations ) );
// Emails
if( isset( $_POST['cau_send'] ) ) $send = sanitize_text_field( $_POST['cau_send'] ); else $send = '';
if( isset( $_POST['cau_send_update'] ) ) $sendupdate = sanitize_text_field( $_POST['cau_send_update'] ); else $sendupdate = '';
if( isset( $_POST['cau_send_outdated'] ) ) $sendoutdated = sanitize_text_field( $_POST['cau_send_outdated'] ); else $sendoutdated = '';
if( isset( $_POST['wpemails'] ) ) $wpemails = sanitize_text_field( $_POST['wpemails'] ); else $wpemails = '';
if( isset( $_POST['cau_email'] ) ) $email = sanitize_text_field( $_POST['cau_email'] );
if( isset( $_POST['html_or_text'] ) ) $html_or_text = sanitize_text_field( $_POST['html_or_text'] );
$send = isset( $_POST['cau_send'] ) ? sanitize_text_field( $_POST['cau_send'] ) : '';
$sendupdate = isset( $_POST['cau_send_update'] ) ? sanitize_text_field( $_POST['cau_send_update'] ) : '';
$sendoutdated = isset( $_POST['cau_send_outdated'] ) ? sanitize_text_field( $_POST['cau_send_outdated'] ) : '';
$wpemails = isset( $_POST['wpemails'] ) ? sanitize_text_field( $_POST['wpemails'] ) : '';
$email = isset( $_POST['cau_email'] ) ? sanitize_text_field( $_POST['cau_email'] ) : '';
$html_or_text = isset( $_POST['html_or_text'] ) ? sanitize_text_field( $_POST['html_or_text'] ) : 'html';
$dbupdateemails = isset( $_POST['dbupdateemails'] ) ? sanitize_text_field( $_POST['dbupdateemails'] ) : '';
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'email'", $email ) );
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'send'", $send ) );
@ -52,18 +53,21 @@ if( isset( $_POST['submit'] ) ) {
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'sendoutdated'", $sendoutdated ) );
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'wpemails'", $wpemails ) );
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'html_or_text'", $html_or_text ) );
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'dbupdateemails'", $dbupdateemails ) );
// Advanced
if( isset( $_POST['allow_editor'] ) ) $allow_editor = sanitize_text_field( $_POST['allow_editor'] ); else $allow_editor = '';
if( isset( $_POST['allow_author'] ) ) $allow_author = sanitize_text_field( $_POST['allow_author'] ); else $allow_author = '';
if( isset( $_POST['advanced_info_emails'] ) ) $advanced_info_emails = sanitize_text_field( $_POST['advanced_info_emails'] ); else $advanced_info_emails = '';
$allow_editor = isset( $_POST['allow_editor'] ) ? sanitize_text_field( $_POST['allow_editor'] ) : '';
$allow_author = isset( $_POST['allow_author'] ) ? sanitize_text_field( $_POST['allow_author'] ) : '';
$advanced_info_emails = isset( $_POST['advanced_info_emails'] ) ? sanitize_text_field( $_POST['advanced_info_emails'] ) : '';
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'allow_editor'", $allow_editor ) );
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'allow_author'", $allow_author ) );
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'advanced_info_emails'", $advanced_info_emails ) );
// Delay
if( isset( $_POST['update_delay'] ) ) $update_delay = sanitize_text_field( $_POST['update_delay'] ); else $update_delay = '';
if( isset( $_POST['update_delay_days'] ) ) $update_delay_days = sanitize_text_field( $_POST['update_delay_days'] ); else $update_delay_days = '';
$update_delay = isset( $_POST['update_delay'] ) ? sanitize_text_field( $_POST['update_delay'] ) : '';
$update_delay_days = isset( $_POST['update_delay_days'] ) ? sanitize_text_field( $_POST['update_delay_days'] ) : '';
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'update_delay'", $update_delay ) );
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = %s WHERE name = 'update_delay_days'", $update_delay_days ) );
@ -76,6 +80,7 @@ if( isset( $_POST['submit'] ) ) {
$schedule_mail = sanitize_text_field( $_POST['update_notifications'] );
$outdated_notifier = sanitize_text_field( $_POST['outdated_notifier'] );
$html_or_text = sanitize_text_field( $_POST['html_or_text'] );
$dbupdateemails = sanitize_text_field( $_POST['dbupdateemails'] );
// First clear schedules
wp_clear_scheduled_hook('wp_update_plugins');
@ -208,14 +213,8 @@ if( isset( $_GET['welcome'] ) ) {
</div>';
}
$plugin_schedule = wp_get_schedule( 'wp_update_plugins' );
$theme_schedule = wp_get_schedule( 'wp_update_themes' );
$core_schedule = wp_get_schedule( 'wp_version_check' );
$schedule_mail = wp_get_schedule( 'cau_set_schedule_mail' );
$outdated_notifier = wp_get_schedule( 'cau_outdated_notifier' );
$cs_hooks_p = wp_get_schedule( 'cau_custom_hooks_plugins' );
$cs_hooks_t = wp_get_schedule( 'cau_custom_hooks_themes' );
$availableIntervals = cau_wp_get_schedules();
?>
@ -287,7 +286,7 @@ $availableIntervals = cau_wp_get_schedules();
</td>
</tr>
<tr>
<th scope="row"><?php _e( 'Outdated software', 'companion-auto-update' );?></th>
<th scope="row"><?php _e( 'Check for outdated software', 'companion-auto-update' );?></th>
<td>
<p>
<input id="cau_send_outdated" name="cau_send_outdated" type="checkbox" <?php if( cau_get_db_value( 'sendoutdated' ) == 'on' ) { echo 'checked'; } ?> />
@ -341,6 +340,15 @@ $availableIntervals = cau_wp_get_schedules();
</p>
</td>
</tr>
<tr>
<th scope="row"><?php _e( 'Database update required', 'companion-auto-update' );?></th>
<td>
<p>
<input id="dbupdateemails" name="dbupdateemails" type="checkbox" <?php if( cau_get_db_value( 'dbupdateemails' ) == 'on' ) { echo 'checked'; } ?> />
<label for="dbupdateemails"><?php _e( 'Sometimes we\'ll need your help updating our database version to the latest version, check this box to allow us to send you an email about this.', 'companion-auto-update' ); ?></label>
</p>
</td>
</tr>
</table>
</div>
@ -410,6 +418,8 @@ $availableIntervals = cau_wp_get_schedules();
</div>
<p></p>
<div class="welcome-column">
<h4><?php _e( 'Update notifications', 'companion-auto-update' );?></h4>
@ -459,7 +469,11 @@ $availableIntervals = cau_wp_get_schedules();
</div>
<?php wp_nonce_field( 'cau_save_settings' ); ?>
<div class="cau_save_button">
<?php submit_button(); ?>
</div>
<div class="cau_save_button__space"></div>
</form>

View File

@ -113,6 +113,26 @@ select.schedule_interval {
max-width: 90%;
width: 225px;
}
.cau_save_button {
background: #FFF;
box-sizing: border-box;
padding: 0 25px;
position: fixed;
width: 100%;
right: 0;
bottom: 0;
margin-left: -25px;
z-index: 1001;
box-shadow: 0 -8px 16px 0 rgb(85 93 102 / 30%);
}
.cau_save_button p.submit {
display: block;
text-align: right;
font-weight: bold;
}
.cau_save_button__space {
height: 75px;
}
/* Overwrite core UI */
/*.cau_content input[type="checkbox"]:checked::before {

View File

@ -14,6 +14,11 @@ function cau_check_updates_mail() {
cau_plugin_updated(); // Check for updated plugins
}
// Notify of required db update
if( cau_get_db_value( 'dbupdateemails' ) == 'on' ) {
cau_notify_outofdate_db();
}
}
// Notify of out of date software
@ -229,6 +234,8 @@ function cau_list_plugin_updates() {
if( $config->onoroff != 'on' ) {
require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
if ( !function_exists( 'get_plugin_updates' ) ) require_once ABSPATH . 'wp-admin/includes/update.php';
$plugins = get_plugin_updates();
if ( !empty( $plugins ) ) {
@ -478,3 +485,28 @@ function cau_plugin_updated() {
}
}
function cau_notify_outofdate_db() {
// Check if cau_get_db_value() function exists.
if ( !function_exists( 'cau_get_db_value' ) ) require_once( plugin_dir_path( __FILE__ ) . 'cau_function.php' );
// Database requires an update
if ( cau_incorrectDatabaseVersion() ) {
// Set up mail
$subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'We need your help with something', 'companion-auto-update' );
$message = __( 'Hi there! We need your help updating the database of Companion Auto Update to the latest version. No rush, old features will continue to work but some new features might not work until you update the database.', 'companion-auto-update' );
// Send to all addresses
foreach ( cau_set_email() as $key => $value ) {
foreach ( $value as $k => $v ) {
wp_mail( $v, $subject, $message );
}
break;
}
}
}

View File

@ -1373,7 +1373,7 @@ function cau_delayed_updates__formated() {
// Add "put on hold" timestamp to the database if it hasn't been set yet
function cau_hold_updates() {
require_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
if ( !function_exists( 'get_plugin_updates' ) ) require_once ABSPATH . 'wp-admin/includes/update.php';
$plugins = get_plugin_updates();
if ( !empty( $plugins ) ) {

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.8.0
* Version: 3.8.2
* Author: Papin Schipper
* Author URI: http://codeermeneer.nl/
* Contributors: papin
@ -79,7 +79,7 @@ function cau_donateUrl() {
// Database version
function cau_db_version() {
return '3.7.2';
return '3.8.1';
}
function cau_database_creation() {
@ -168,6 +168,7 @@ function cau_install_data() {
// Stuff
if( !cau_check_if_exists( 'html_or_text' ) ) $wpdb->insert( $table_name, array( 'name' => 'html_or_text', 'onoroff' => 'html' ) );
if( !cau_check_if_exists( 'dbupdateemails' ) ) $wpdb->insert( $table_name, array( 'name' => 'dbupdateemails', 'onoroff' => '' ) );
// Advanced
if( !cau_check_if_exists( 'allow_administrator' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_administrator', 'onoroff' => 'on' ) );

View File

@ -3,9 +3,9 @@ Contributors: Papin, qweb
Donate link: https://www.paypal.me/dakel/10/
Tags: auto, automatic, background, update, updates, updating, automatic updates, automatic background updates, easy update, wordpress update, theme update, plugin update, up-to-date, security, update latest version, update core, update wp, update wp core, major updates, minor updates, update to new version, update core, update plugin, update plugins, update plugins automatically, update theme, plugin, theme, advance, control, mail, notifations, enable
Requires at least: 3.6.0
Tested up to: 5.6
Tested up to: 5.7
Requires PHP: 5.1
Stable tag: 3.8.0
Stable tag: 3.8.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -81,7 +81,14 @@ So obviously, some of you wondered what the difference would be between the defa
== Changelog ==
= 3.8.0 (January 14, 2020) =
= 3.8.2 (July 1, 2021) =
* Fix: Error: Call to undefined function get_plugin_updates()
= 3.8.1 (June 4, 2021) =
* New: Be notified when we need your help updating to a new database version [Feature Request](https://wordpress.org/support/topic/feature-request-839/)
* Tweak: Made some under the hood performance improvements
= 3.8.0 (January 14, 2021) =
* New: Better handling of plugins with an unknown WP version
* New: More intervals for notifications
* Fix: Call to undefined function errors