updated plugin `Companion Auto Update` version 3.8.3

This commit is contained in:
KawaiiPunk 2021-12-20 13:41:55 +00:00 committed by Gitium
parent a3fd251a0c
commit 132b46b78f
10 changed files with 2776 additions and 2733 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
<?php <?php
if( isset( $_GET['filter'] ) ) { if( isset( $_GET['filter'] ) ) {
$filter = $_GET['filter']; $filter = $_GET['filter'];
} else { } else {
$filter = 'all'; $filter = 'all';
} }
?> ?>
<ul class="subsubsub"> <ul class="subsubsub">
<li><a <?php if( $filter == 'all' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=all' ); ?>'><?php _e( 'View full changelog', 'companion-auto-update' ); ?></a></li> | <li><a <?php if( $filter == 'all' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=all' ); ?>'><?php _e( 'View full changelog', 'companion-auto-update' ); ?></a></li> |
<li><a <?php if( $filter == 'plugins' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=plugins' ); ?>'><?php _e( 'Plugins', 'companion-auto-update' ); ?></a></li> | <li><a <?php if( $filter == 'plugins' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=plugins' ); ?>'><?php _e( 'Plugins', 'companion-auto-update' ); ?></a></li> |
<li><a <?php if( $filter == 'themes' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=themes' ); ?>'><?php _e( 'Themes', 'companion-auto-update' ); ?></a></li> | <li><a <?php if( $filter == 'themes' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=themes' ); ?>'><?php _e( 'Themes', 'companion-auto-update' ); ?></a></li> |
<li><a <?php if( $filter == 'translations' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=translations' ); ?>'><?php _e( 'Translations', 'companion-auto-update' ); ?></a></li> <li><a <?php if( $filter == 'translations' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'log&filter=translations' ); ?>'><?php _e( 'Translations', 'companion-auto-update' ); ?></a></li>
</ul> </ul>
<div class='cau_spacing'></div> <div class='cau_spacing'></div>
<?php <?php
cau_fetch_log( 'all', 'table' ); cau_fetch_log( 'all', 'table' );

View File

@ -1,185 +1,185 @@
<?php <?php
// Get selected filter type // Get selected filter type
if( isset( $_GET['filter'] ) ) { if( isset( $_GET['filter'] ) ) {
$filter = sanitize_key( $_GET['filter'] ); $filter = sanitize_key( $_GET['filter'] );
} else { } else {
$filter = 'plugins'; $filter = 'plugins';
} }
// Select correct database row // Select correct database row
switch ( $filter ) { switch ( $filter ) {
case 'themes': case 'themes':
$db_table = 'notUpdateListTh'; $db_table = 'notUpdateListTh';
$filter_name = __( 'Themes', 'companion-auto-update' ); $filter_name = __( 'Themes', 'companion-auto-update' );
$filterFunction = wp_get_themes(); $filterFunction = wp_get_themes();
break; break;
case 'plugins': case 'plugins':
$db_table = 'notUpdateList'; $db_table = 'notUpdateList';
$filter_name = __( 'Plugins', 'companion-auto-update' ); $filter_name = __( 'Plugins', 'companion-auto-update' );
$filterFunction = get_plugins(); $filterFunction = get_plugins();
break; break;
default: default:
$db_table = 'notUpdateList'; $db_table = 'notUpdateList';
$filter_name = __( 'Plugins', 'companion-auto-update' ); $filter_name = __( 'Plugins', 'companion-auto-update' );
$filterFunction = get_plugins(); $filterFunction = get_plugins();
break; break;
} }
?> ?>
<ul class="subsubsub"> <ul class="subsubsub">
<li><a <?php if( $filter == 'plugins' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'pluginlist&filter=plugins' ); ?>'><?php _e( 'Plugins', 'companion-auto-update' ); ?></a></li> | <li><a <?php if( $filter == 'plugins' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'pluginlist&filter=plugins' ); ?>'><?php _e( 'Plugins', 'companion-auto-update' ); ?></a></li> |
<li><a <?php if( $filter == 'themes' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'pluginlist&filter=themes' ); ?>'><?php _e( 'Themes', 'companion-auto-update' ); ?></a></li> <li><a <?php if( $filter == 'themes' ) { echo "class='current'"; } ?> href='<?php echo cau_url( 'pluginlist&filter=themes' ); ?>'><?php _e( 'Themes', 'companion-auto-update' ); ?></a></li>
</ul> </ul>
<div style='clear: both;'></div> <div style='clear: both;'></div>
<?php if( $filter == 'themes' ) { ?> <?php if( $filter == 'themes' ) { ?>
<div id="message" class="cau"> <div id="message" class="cau">
We've had to (temporarily) disable the theme filter because it was causing issues on some installations. We'll try to get it working again in a future update. We've had to (temporarily) disable the theme filter because it was causing issues on some installations. We'll try to get it working again in a future update.
</div> </div>
<?php } ?> <?php } ?>
<p><?php echo sprintf( esc_html__( 'Prevent certain %s from updating automatically. %s that you select here will be skipped by Companion Auto Update and will require manual updating.', 'companion-auto-update' ), strtolower( $filter_name ), $filter_name ); ?></p> <p><?php echo sprintf( esc_html__( 'Prevent certain %s from updating automatically. %s that you select here will be skipped by Companion Auto Update and will require manual updating.', 'companion-auto-update' ), strtolower( $filter_name ), $filter_name ); ?></p>
<?php <?php
global $wpdb; global $wpdb;
$table_name = $wpdb->prefix."auto_updates"; $table_name = $wpdb->prefix."auto_updates";
// Save list // Save list
if( isset( $_POST['submit'] ) ) { if( isset( $_POST['submit'] ) ) {
check_admin_referer( 'cau_save_pluginlist' ); check_admin_referer( 'cau_save_pluginlist' );
$noUpdateList = ''; $noUpdateList = '';
$i = 0; $i = 0;
$noUpdateCount = 0; $noUpdateCount = 0;
if( isset( $_POST['post'] ) ) { if( isset( $_POST['post'] ) ) {
$noUpdateCount = count( $_POST['post'] ); $noUpdateCount = count( $_POST['post'] );
} }
if( $noUpdateCount > 0 ) { if( $noUpdateCount > 0 ) {
foreach ( $_POST['post'] as $key ) { foreach ( $_POST['post'] as $key ) {
$noUpdateList .= sanitize_text_field( $key ); $noUpdateList .= sanitize_text_field( $key );
$i++; $i++;
if( $i != $noUpdateCount ) $noUpdateList .= ', '; if( $i != $noUpdateCount ) $noUpdateList .= ', ';
} }
} }
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = '%s' WHERE name = '%s'", $noUpdateList, $db_table ) ); $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = '%s' WHERE name = '%s'", $noUpdateList, $db_table ) );
echo '<div id="message" class="updated"><p><b>'.__( 'Succes', 'companion-auto-update' ).' &ndash;</b> '.sprintf( esc_html__( '%1$s %2$s have been added to the no-update-list', 'companion-auto-update' ), $noUpdateCount, strtolower( $filter_name ) ).'.</p></div>'; echo '<div id="message" class="updated"><p><b>'.__( 'Succes', 'companion-auto-update' ).' &ndash;</b> '.sprintf( esc_html__( '%1$s %2$s have been added to the no-update-list', 'companion-auto-update' ), $noUpdateCount, strtolower( $filter_name ) ).'.</p></div>';
} }
// Reset list // Reset list
if( isset( $_POST['reset'] ) ) { if( isset( $_POST['reset'] ) ) {
check_admin_referer( 'cau_save_pluginlist' ); check_admin_referer( 'cau_save_pluginlist' );
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = '%s' WHERE name = %s", "", $db_table ) ); $wpdb->query( $wpdb->prepare( "UPDATE $table_name SET onoroff = '%s' WHERE name = %s", "", $db_table ) );
echo '<div id="message" class="updated"><p><b>'.__( 'Succes', 'companion-auto-update' ).' &ndash;</b> '.sprintf( esc_html__( 'The no-update-list has been reset, all %s will be auto-updated from now on', 'companion-auto-update' ), strtolower( $filter_name ) ).'.</p></div>'; echo '<div id="message" class="updated"><p><b>'.__( 'Succes', 'companion-auto-update' ).' &ndash;</b> '.sprintf( esc_html__( 'The no-update-list has been reset, all %s will be auto-updated from now on', 'companion-auto-update' ), strtolower( $filter_name ) ).'.</p></div>';
} }
?> ?>
<form method="POST"> <form method="POST">
<div class='pluginListButtons'> <div class='pluginListButtons'>
<?php submit_button(); ?> <?php submit_button(); ?>
<input type='submit' name='reset' id='reset' class='button button-alt' value='<?php _e( "Reset list", "companion-auto-update" ); ?>'> <input type='submit' name='reset' id='reset' class='button button-alt' value='<?php _e( "Reset list", "companion-auto-update" ); ?>'>
</div> </div>
<table class="wp-list-table widefat autoupdate striped"> <table class="wp-list-table widefat autoupdate striped">
<thead> <thead>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<th class="head-plugin"><strong><?php _e( 'Name', 'companion-auto-update' ); ?></strong></th> <th class="head-plugin"><strong><?php _e( 'Name', 'companion-auto-update' ); ?></strong></th>
<th class="head-status"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th> <th class="head-status"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th>
<th class="head-description"><strong><?php _e( 'Description' ); ?></strong></th> <th class="head-description"><strong><?php _e( 'Description' ); ?></strong></th>
</tr> </tr>
</thead> </thead>
<tbody id="the-list"> <tbody id="the-list">
<?php <?php
foreach ( $filterFunction as $key => $value ) { foreach ( $filterFunction as $key => $value ) {
$slug = $key; $slug = $key;
$explosion = explode( '/', $slug ); $explosion = explode( '/', $slug );
$actualSlug = array_shift( $explosion ); $actualSlug = array_shift( $explosion );
$slug_hash = md5( $slug[0] ); $slug_hash = md5( $slug[0] );
if( $filter == 'themes' ) { if( $filter == 'themes' ) {
$theme = wp_get_theme( $actualSlug ); $theme = wp_get_theme( $actualSlug );
$name = $theme->get( 'Name' ); $name = $theme->get( 'Name' );
$description = $theme->get( 'Description' ); $description = $theme->get( 'Description' );
} else { } else {
foreach ( $value as $k => $v ) { foreach ( $value as $k => $v ) {
if( $k == "Name" ) $name = $v; if( $k == "Name" ) $name = $v;
if( $k == "Description" ) $description = $v; if( $k == "Description" ) $description = $v;
} }
} }
if( in_array( $actualSlug, donotupdatelist( $filter ) ) ) { if( in_array( $actualSlug, donotupdatelist( $filter ) ) ) {
$class = 'inactive'; $class = 'inactive';
$checked = 'CHECKED'; $checked = 'CHECKED';
$statusicon = 'no'; $statusicon = 'no';
$statusName = 'disabled'; $statusName = 'disabled';
} else { } else {
$class = 'active'; $class = 'active';
$checked = ''; $checked = '';
$statusicon = 'yes'; $statusicon = 'yes';
$statusName = 'enabled'; $statusName = 'enabled';
} }
echo '<tr id="post-'.$slug_hash.'" class="'.$class.'"> echo '<tr id="post-'.$slug_hash.'" class="'.$class.'">
<th class="check-column"> <th class="check-column">
<label class="screen-reader-text" for="cb-select-'.$slug_hash.'">Select '. $name .'</label> <label class="screen-reader-text" for="cb-select-'.$slug_hash.'">Select '. $name .'</label>
<input id="cb-select-'.$slug_hash.'" type="checkbox" name="post[]" value="'.$actualSlug.'" '.$checked.' ><label></label> <input id="cb-select-'.$slug_hash.'" type="checkbox" name="post[]" value="'.$actualSlug.'" '.$checked.' ><label></label>
<div class="locked-indicator"></div> <div class="locked-indicator"></div>
</th> </th>
<td class="column-name"> <td class="column-name">
<p style="margin-bottom: 0px;"><strong>'. $name .'</strong></p> <p style="margin-bottom: 0px;"><strong>'. $name .'</strong></p>
<small class="description" style="opacity: 0.5; margin-bottom: 3px;">'.$actualSlug.'</small> <small class="description" style="opacity: 0.5; margin-bottom: 3px;">'.$actualSlug.'</small>
</td> </td>
<td class="cau_hide_on_mobile column-status"> <td class="cau_hide_on_mobile column-status">
<p><span class="nowrap">'.__( 'Auto Updater', 'companion-auto-update' ).': <span class="cau_'.$statusName.'"><span class="dashicons dashicons-'.$statusicon.'"></span></span></span></p> <p><span class="nowrap">'.__( 'Auto Updater', 'companion-auto-update' ).': <span class="cau_'.$statusName.'"><span class="dashicons dashicons-'.$statusicon.'"></span></span></span></p>
</td> </td>
<td class="cau_hide_on_mobile column-description"> <td class="cau_hide_on_mobile column-description">
<p>'.$description.'</p> <p>'.$description.'</p>
</td> </td>
</tr>'; </tr>';
} }
?> ?>
</tbody> </tbody>
</table> </table>
<?php wp_nonce_field( 'cau_save_pluginlist' ); ?> <?php wp_nonce_field( 'cau_save_pluginlist' ); ?>
<div class='pluginListButtons'> <div class='pluginListButtons'>
<?php submit_button(); ?> <?php submit_button(); ?>
<input type='submit' name='reset' id='reset' class='button button-alt' value='<?php _e( "Reset list", "companion-auto-update" ); ?>'> <input type='submit' name='reset' id='reset' class='button button-alt' value='<?php _e( "Reset list", "companion-auto-update" ); ?>'>
</div> </div>
</form> </form>

View File

@ -1,2 +1,2 @@
<?php <?php
// Currently working on this // Currently working on this

View File

@ -1,405 +1,405 @@
<?php <?php
// Update the database // Update the database
if( isset( $_GET['run'] ) && $_GET['run'] == 'db_update' ) { if( isset( $_GET['run'] ) && $_GET['run'] == 'db_update' ) {
cau_manual_update(); cau_manual_update();
echo '<div id="message" class="updated"><p><b>'.__( 'Database update completed' ).'</b></p></div>'; echo '<div id="message" class="updated"><p><b>'.__( 'Database update completed' ).'</b></p></div>';
} }
if( isset( $_GET['run'] ) && $_GET['run'] == 'db_info_update' ) { if( isset( $_GET['run'] ) && $_GET['run'] == 'db_info_update' ) {
cau_savePluginInformation(); cau_savePluginInformation();
echo '<div id="message" class="updated"><p><b>'.__( 'Database information update completed' ).'</b></p></div>'; echo '<div id="message" class="updated"><p><b>'.__( 'Database information update completed' ).'</b></p></div>';
} }
if( isset( $_GET['ignore_report'] ) ) { if( isset( $_GET['ignore_report'] ) ) {
$report_to_ignore = sanitize_text_field( $_GET['ignore_report'] ); $report_to_ignore = sanitize_text_field( $_GET['ignore_report'] );
$allowedValues = array( 'seo', 'cron' ); $allowedValues = array( 'seo', 'cron' );
if( !in_array( $report_to_ignore, $allowedValues ) ) { if( !in_array( $report_to_ignore, $allowedValues ) ) {
wp_die( 'Trying to cheat eh?' ); wp_die( 'Trying to cheat eh?' );
} else { } else {
global $wpdb; global $wpdb;
$table_name = $wpdb->prefix . "auto_updates"; $table_name = $wpdb->prefix . "auto_updates";
$wpdb->query( $wpdb->prepare( "UPDATE {$table_name} SET onoroff = %s WHERE name = 'ignore_$report_to_ignore'", 'yes' ) ); $wpdb->query( $wpdb->prepare( "UPDATE {$table_name} SET onoroff = %s WHERE name = 'ignore_$report_to_ignore'", 'yes' ) );
$__ignored = __( 'This report will now be ignored', 'companion-auto-update' ); $__ignored = __( 'This report will now be ignored', 'companion-auto-update' );
echo "<div id='message' class='updated'><p><b>$__ignored</b></p></div>"; echo "<div id='message' class='updated'><p><b>$__ignored</b></p></div>";
} }
} }
// Variables // Variables
$dateFormat = get_option( 'date_format' ); $dateFormat = get_option( 'date_format' );
$dateFormat .= ' '.get_option( 'time_format' ); $dateFormat .= ' '.get_option( 'time_format' );
global $wpdb; global $wpdb;
$table_name = $wpdb->prefix . "auto_updates"; $table_name = $wpdb->prefix . "auto_updates";
$schedules = wp_get_schedules(); $schedules = wp_get_schedules();
$interval_names = cau_wp_get_schedules(); $interval_names = cau_wp_get_schedules();
?> ?>
<div class="cau_status_page"> <div class="cau_status_page">
<table class="cau_status_list widefat striped"> <table class="cau_status_list widefat striped">
<thead> <thead>
<tr> <tr>
<th class="cau_status_name"><strong><?php _e( 'Auto Updater', 'companion-auto-update' ); ?></strong></th> <th class="cau_status_name"><strong><?php _e( 'Auto Updater', 'companion-auto-update' ); ?></strong></th>
<th class="cau_status_active_state"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th> <th class="cau_status_active_state"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th>
<th class="cau_status_interval"><strong><?php _e( 'Interval', 'companion-auto-update' ); ?></strong></th> <th class="cau_status_interval"><strong><?php _e( 'Interval', 'companion-auto-update' ); ?></strong></th>
<th class="cau_status_next"><strong><?php _e( 'Next', 'companion-auto-update' ); ?></strong></th> <th class="cau_status_next"><strong><?php _e( 'Next', 'companion-auto-update' ); ?></strong></th>
</tr> </tr>
</thead> </thead>
<tbody id="the-list"> <tbody id="the-list">
<?php <?php
$auto_updaters = array( $auto_updaters = array(
'plugins' => __( 'Plugins', 'companion-auto-update' ), 'plugins' => __( 'Plugins', 'companion-auto-update' ),
'themes' => __( 'Themes', 'companion-auto-update' ), 'themes' => __( 'Themes', 'companion-auto-update' ),
'minor' => __( 'Core (Minor)', 'companion-auto-update' ), 'minor' => __( 'Core (Minor)', 'companion-auto-update' ),
'major' => __( 'Core (Major)', 'companion-auto-update' ) 'major' => __( 'Core (Major)', 'companion-auto-update' )
); );
$eventNames = array( $eventNames = array(
'plugins' => 'wp_update_plugins', 'plugins' => 'wp_update_plugins',
'themes' => 'wp_update_themes', 'themes' => 'wp_update_themes',
'minor' => 'wp_version_check', 'minor' => 'wp_version_check',
'major' => 'wp_version_check' 'major' => 'wp_version_check'
); );
foreach ( $auto_updaters as $key => $value ) { foreach ( $auto_updaters as $key => $value ) {
if( cau_get_db_value( $key ) == 'on' ) { if( cau_get_db_value( $key ) == 'on' ) {
$__status = 'enabled'; $__status = 'enabled';
$__icon = 'yes-alt'; $__icon = 'yes-alt';
$__text = __( 'Enabled', 'companion-auto-update' ); $__text = __( 'Enabled', 'companion-auto-update' );
$__interval = $interval_names[wp_get_schedule( $eventNames[$key] )]; $__interval = $interval_names[wp_get_schedule( $eventNames[$key] )];
$__next = date_i18n( $dateFormat, wp_next_scheduled( $eventNames[$key] ) ); $__next = date_i18n( $dateFormat, wp_next_scheduled( $eventNames[$key] ) );
} else { } else {
$__status = 'disabled'; $__status = 'disabled';
$__icon = 'marker'; $__icon = 'marker';
$__text = __( 'Disabled', 'companion-auto-update' ); $__text = __( 'Disabled', 'companion-auto-update' );
$__interval = '&dash;'; $__interval = '&dash;';
$__next = '&dash;'; $__next = '&dash;';
} }
$__nxt = __( 'Next', 'companion-auto-update' ); $__nxt = __( 'Next', 'companion-auto-update' );
echo "<tr> echo "<tr>
<td class='cau_status_name'>$value</td> <td class='cau_status_name'>$value</td>
<td class='cau_status_active_state'><span class='cau_$__status'><span class='dashicons dashicons-$__icon'></span> $__text</span></td> <td class='cau_status_active_state'><span class='cau_$__status'><span class='dashicons dashicons-$__icon'></span> $__text</span></td>
<td class='cau_status_interval'>$__interval</td> <td class='cau_status_interval'>$__interval</td>
<td class='cau_status_next'><span class='cau_mobile_prefix'>$__nxt: </span>$__next</td> <td class='cau_status_next'><span class='cau_mobile_prefix'>$__nxt: </span>$__next</td>
</tr>"; </tr>";
} }
?> ?>
</tbody> </tbody>
</table> </table>
<table class="cau_status_list widefat striped"> <table class="cau_status_list widefat striped">
<thead> <thead>
<tr> <tr>
<th class="cau_status_name"><strong><?php _e( 'Email Notifications', 'companion-auto-update' ); ?></strong></th> <th class="cau_status_name"><strong><?php _e( 'Email Notifications', 'companion-auto-update' ); ?></strong></th>
<th class="cau_status_active_state"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th> <th class="cau_status_active_state"><strong><?php _e( 'Status', 'companion-auto-update' ); ?></strong></th>
<th class="cau_status_interval"><strong><?php _e( 'Interval', 'companion-auto-update' ); ?></strong></th> <th class="cau_status_interval"><strong><?php _e( 'Interval', 'companion-auto-update' ); ?></strong></th>
<th class="cau_status_next"><strong><?php _e( 'Next', 'companion-auto-update' ); ?></strong></th> <th class="cau_status_next"><strong><?php _e( 'Next', 'companion-auto-update' ); ?></strong></th>
</tr> </tr>
</thead> </thead>
<tbody id="the-list"> <tbody id="the-list">
<?php <?php
$other_events = array( $other_events = array(
'send' => __( 'Update available', 'companion-auto-update' ), 'send' => __( 'Update available', 'companion-auto-update' ),
'sendupdate' => __( 'Successful update', 'companion-auto-update' ), 'sendupdate' => __( 'Successful update', 'companion-auto-update' ),
'wpemails' => __( 'Core notifications', 'companion-auto-update' ) 'wpemails' => __( 'Core notifications', 'companion-auto-update' )
); );
$other_eventNames = array( $other_eventNames = array(
'send' => 'cau_set_schedule_mail', 'send' => 'cau_set_schedule_mail',
'sendupdate' => 'cau_set_schedule_mail', 'sendupdate' => 'cau_set_schedule_mail',
'wpemails' => 'cau_set_schedule_mail', 'wpemails' => 'cau_set_schedule_mail',
); );
foreach ( $other_events as $key => $value ) { foreach ( $other_events as $key => $value ) {
if( cau_get_db_value( $key ) == 'on' ) { if( cau_get_db_value( $key ) == 'on' ) {
$__status = 'enabled'; $__status = 'enabled';
$__icon = 'yes-alt'; $__icon = 'yes-alt';
$__text = __( 'Enabled', 'companion-auto-update' ); $__text = __( 'Enabled', 'companion-auto-update' );
$__interval = $interval_names[wp_get_schedule( $other_eventNames[$key] )]; $__interval = $interval_names[wp_get_schedule( $other_eventNames[$key] )];
$__next = date_i18n( $dateFormat, wp_next_scheduled( $other_eventNames[$key] ) ); $__next = date_i18n( $dateFormat, wp_next_scheduled( $other_eventNames[$key] ) );
} else { } else {
$__status = 'warning'; $__status = 'warning';
$__icon = 'marker'; $__icon = 'marker';
$__text = __( 'Disabled', 'companion-auto-update' ); $__text = __( 'Disabled', 'companion-auto-update' );
$__interval = '&dash;'; $__interval = '&dash;';
$__next = '&dash;'; $__next = '&dash;';
} }
$__nxt = __( 'Next', 'companion-auto-update' ); $__nxt = __( 'Next', 'companion-auto-update' );
echo "<tr> echo "<tr>
<td class='cau_status_name'>$value</td> <td class='cau_status_name'>$value</td>
<td class='cau_status_active_state'><span class='cau_$__status'><span class='dashicons dashicons-$__icon'></span> $__text</span></td> <td class='cau_status_active_state'><span class='cau_$__status'><span class='dashicons dashicons-$__icon'></span> $__text</span></td>
<td class='cau_status_interval'>$__interval</td> <td class='cau_status_interval'>$__interval</td>
<td class='cau_status_next'><span class='cau_mobile_prefix'>$__nxt: </span>$__next</td> <td class='cau_status_next'><span class='cau_mobile_prefix'>$__nxt: </span>$__next</td>
</tr>"; </tr>";
} }
?> ?>
</tbody> </tbody>
</table> </table>
<table class="cau_status_list widefat striped cau_status_warnings"> <table class="cau_status_list widefat striped cau_status_warnings">
<thead> <thead>
<tr> <tr>
<th class="cau_plugin_issue_name" colspan="4"><strong><?php _e( 'Status' ); ?></strong></th> <th class="cau_plugin_issue_name" colspan="4"><strong><?php _e( 'Status' ); ?></strong></th>
</tr> </tr>
</thead> </thead>
<tbody id="the-list"> <tbody id="the-list">
<tr> <tr>
<td><?php _e( 'Auto updates', 'companion-auto-update' ); ?></td> <td><?php _e( 'Auto updates', 'companion-auto-update' ); ?></td>
<?php if ( checkAutomaticUpdaterDisabled() ) { ?> <?php if ( checkAutomaticUpdaterDisabled() ) { ?>
<td class="cau_status_active_state"><span class='cau_disabled'><span class="dashicons dashicons-no"></span> <?php _e( 'All automatic updates are disabled', 'companion-auto-update' ); ?></span></td> <td class="cau_status_active_state"><span class='cau_disabled'><span class="dashicons dashicons-no"></span> <?php _e( 'All automatic updates are disabled', 'companion-auto-update' ); ?></span></td>
<td> <td>
<form method="POST"> <form method="POST">
<?php wp_nonce_field( 'cau_fixit' ); ?> <?php wp_nonce_field( 'cau_fixit' ); ?>
<button type="submit" name="fixit" class="button button-primary"><?php _e( 'Fix it', 'companion-auto-update' ); ?></button> <button type="submit" name="fixit" class="button button-primary"><?php _e( 'Fix it', 'companion-auto-update' ); ?></button>
<a href="https://codeermeneer.nl/documentation/known-issues-fixes/#updates_disabled" target="_blank" class="button"><?php _e( 'How to fix this', 'companion-auto-update' ); ?></a> <a href="https://codeermeneer.nl/documentation/known-issues-fixes/#updates_disabled" target="_blank" class="button"><?php _e( 'How to fix this', 'companion-auto-update' ); ?></a>
</form> </form>
</td> </td>
<?php } else { ?> <?php } else { ?>
<td class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td> <td class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td>
<td></td> <td></td>
<?php } ?> <?php } ?>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td><?php _e( 'Connection with WordPress.org', 'companion-auto-update' ); ?></td> <td><?php _e( 'Connection with WordPress.org', 'companion-auto-update' ); ?></td>
<?php if( wp_http_supports( array( 'ssl' ) ) == '1' ) { <?php if( wp_http_supports( array( 'ssl' ) ) == '1' ) {
$__text = __( 'No issues detected', 'companion-auto-update' ); $__text = __( 'No issues detected', 'companion-auto-update' );
echo "<td colspan='3' class='cau_status_active_state'><span class='cau_enabled'><span class='dashicons dashicons-yes-alt'></span> $__text</span></td>"; echo "<td colspan='3' class='cau_status_active_state'><span class='cau_enabled'><span class='dashicons dashicons-yes-alt'></span> $__text</span></td>";
} else { } else {
$__text = __( 'Disabled', 'companion-auto-update' ); $__text = __( 'Disabled', 'companion-auto-update' );
echo "<td colspan='3' class='cau_status_active_state'><span class='cau_disabled'><span class='dashicons dashicons-no'></span> $__text</span></td>"; echo "<td colspan='3' class='cau_status_active_state'><span class='cau_disabled'><span class='dashicons dashicons-no'></span> $__text</span></td>";
} ?> } ?>
</tr> </tr>
<tr <?php if( cau_get_db_value( 'ignore_seo' ) == 'yes' ) { echo "class='report_hidden'"; } ?> > <tr <?php if( cau_get_db_value( 'ignore_seo' ) == 'yes' ) { echo "class='report_hidden'"; } ?> >
<td><?php _e( 'Search Engine Visibility', 'companion-auto-update' ); ?></td> <td><?php _e( 'Search Engine Visibility', 'companion-auto-update' ); ?></td>
<?php if( get_option( 'blog_public' ) == 0 ) { ?> <?php if( get_option( 'blog_public' ) == 0 ) { ?>
<td colspan="2" class="cau_status_active_state"> <td colspan="2" class="cau_status_active_state">
<span class='cau_warning'><span class="dashicons dashicons-warning"></span></span> <span class='cau_warning'><span class="dashicons dashicons-warning"></span></span>
<?php _e( 'Youve chosen to discourage Search Engines from indexing your site. Auto-updating works best on sites with more traffic, consider enabling indexing for your site.', 'companion-auto-update' ); ?> <?php _e( 'Youve chosen to discourage Search Engines from indexing your site. Auto-updating works best on sites with more traffic, consider enabling indexing for your site.', 'companion-auto-update' ); ?>
</td> </td>
<td> <td>
<a href="<?php echo admin_url( 'options-reading.php' ); ?>" class="button"><?php _e( 'Fix it', 'companion-auto-update' ); ?></a> <a href="<?php echo admin_url( 'options-reading.php' ); ?>" class="button"><?php _e( 'Fix it', 'companion-auto-update' ); ?></a>
<a href="<?php echo cau_url( 'status' ); ?>&ignore_report=seo" class="button button-alt"><?php _e( 'Ignore this report', 'companion-auto-update' ); ?></a> <a href="<?php echo cau_url( 'status' ); ?>&ignore_report=seo" class="button button-alt"><?php _e( 'Ignore this report', 'companion-auto-update' ); ?></a>
</td> </td>
<?php } else { ?> <?php } else { ?>
<td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td> <td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td>
<?php } ?> <?php } ?>
</tr> </tr>
<tr <?php if( cau_get_db_value( 'ignore_cron' ) == 'yes' ) { echo "class='report_hidden'"; } ?> > <tr <?php if( cau_get_db_value( 'ignore_cron' ) == 'yes' ) { echo "class='report_hidden'"; } ?> >
<td><?php _e( 'Cronjobs', 'companion-auto-update' ); ?></td> <td><?php _e( 'Cronjobs', 'companion-auto-update' ); ?></td>
<?php if( checkCronjobsDisabled() ) { ?> <?php if( checkCronjobsDisabled() ) { ?>
<td class="cau_status_active_state"><span class='cau_warning'><span class="dashicons dashicons-warning"></span> <?php _e( 'Disabled', 'companion-auto-update' ); ?></span></td> <td class="cau_status_active_state"><span class='cau_warning'><span class="dashicons dashicons-warning"></span> <?php _e( 'Disabled', 'companion-auto-update' ); ?></span></td>
<td><code>DISABLE_WP_CRON true</code></td> <td><code>DISABLE_WP_CRON true</code></td>
<td> <td>
<a href="https://codeermeneer.nl/contact/" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a> <a href="https://codeermeneer.nl/contact/" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a>
<a href="<?php echo cau_url( 'status' ); ?>&ignore_report=cron" class="button button-alt"><?php _e( 'Ignore this report', 'companion-auto-update' ); ?></a> <a href="<?php echo cau_url( 'status' ); ?>&ignore_report=cron" class="button button-alt"><?php _e( 'Ignore this report', 'companion-auto-update' ); ?></a>
</td> </td>
<?php } else { ?> <?php } else { ?>
<td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td> <td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected', 'companion-auto-update' ); ?></span></td>
<?php } ?> <?php } ?>
</tr> </tr>
<tr> <tr>
<td>wp_version_check</td> <td>wp_version_check</td>
<?php if ( !has_filter( 'wp_version_check', 'wp_version_check' ) ) { ?> <?php if ( !has_filter( 'wp_version_check', 'wp_version_check' ) ) { ?>
<td colspan="2" class="cau_status_active_state"><span class='cau_disabled'><span class="dashicons dashicons-no"></span> <?php _e( 'A plugin has prevented updates by disabling wp_version_check', 'companion-auto-update' ); ?></span></td> <td colspan="2" class="cau_status_active_state"><span class='cau_disabled'><span class="dashicons dashicons-no"></span> <?php _e( 'A plugin has prevented updates by disabling wp_version_check', 'companion-auto-update' ); ?></span></td>
<td><a href="https://codeermeneer.nl/contact/" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a></td> <td><a href="https://codeermeneer.nl/contact/" class="button"><?php _e( 'Contact for support', 'companion-auto-update' ); ?></a></td>
<?php } else { ?> <?php } else { ?>
<td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected' , 'companion-auto-update' ); ?></span></td> <td colspan="3" class="cau_status_active_state"><span class='cau_enabled'><span class="dashicons dashicons-yes-alt"></span> <?php _e( 'No issues detected' , 'companion-auto-update' ); ?></span></td>
<?php } ?> <?php } ?>
</tr> </tr>
<tr> <tr>
<td>VCS</td> <td>VCS</td>
<td colspan="3" class="cau_status_active_state"><span class='cau_<?php echo cau_test_is_vcs_checkout( ABSPATH )['status']; ?>'><span class="dashicons dashicons-<?php echo cau_test_is_vcs_checkout( ABSPATH )['icon']; ?>"></span> <?php echo cau_test_is_vcs_checkout( ABSPATH )['description']; ?></span></td> <td colspan="3" class="cau_status_active_state"><span class='cau_<?php echo cau_test_is_vcs_checkout( ABSPATH )['status']; ?>'><span class="dashicons dashicons-<?php echo cau_test_is_vcs_checkout( ABSPATH )['icon']; ?>"></span> <?php echo cau_test_is_vcs_checkout( ABSPATH )['description']; ?></span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table class="autoupdate cau_status_list widefat striped cau_status_warnings"> <table class="autoupdate cau_status_list widefat striped cau_status_warnings">
<thead> <thead>
<tr> <tr>
<th colspan="4"><strong><?php _e( 'Systeminfo', 'companion-auto-update' ); ?></strong></th> <th colspan="4"><strong><?php _e( 'Systeminfo', 'companion-auto-update' ); ?></strong></th>
</tr> </tr>
</thead> </thead>
<tbody id="the-list"> <tbody id="the-list">
<tr> <tr>
<td>WordPress</td> <td>WordPress</td>
<td><?php echo get_bloginfo( 'version' ); ?></td> <td><?php echo get_bloginfo( 'version' ); ?></td>
<td></td> <td></td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>PHP</td> <td>PHP</td>
<td><?php echo phpversion(); ?></td> <td><?php echo phpversion(); ?></td>
<td></td> <td></td>
<td></td> <td></td>
</tr> </tr>
<tr <?php if( cau_incorrectDatabaseVersion() ) { echo "class='inactive'"; } ?>> <tr <?php if( cau_incorrectDatabaseVersion() ) { echo "class='inactive'"; } ?>>
<td>Database</td> <td>Database</td>
<td><?php echo get_option( "cau_db_version" ); ?> <code>(Latest: <?php echo cau_db_version(); ?>)</code></td> <td><?php echo get_option( "cau_db_version" ); ?> <code>(Latest: <?php echo cau_db_version(); ?>)</code></td>
<td></td> <td></td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td class="cau_status_name"><?php _e( 'Timezone' ); ?></td> <td class="cau_status_name"><?php _e( 'Timezone' ); ?></td>
<td class="cau_status_active_state"><?php echo cau_get_proper_timezone(); ?> (GMT <?php echo get_option('gmt_offset'); ?>) - <?php echo date_default_timezone_get(); ?></td> <td class="cau_status_active_state"><?php echo cau_get_proper_timezone(); ?> (GMT <?php echo get_option('gmt_offset'); ?>) - <?php echo date_default_timezone_get(); ?></td>
<td></td> <td></td>
<td></td> <td></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<?php <?php
// If has incomptable plugins // If has incomptable plugins
if( cau_incompatiblePlugins() ) { ?> if( cau_incompatiblePlugins() ) { ?>
<table class="cau_status_list no_column_width widefat striped cau_status_warnings"> <table class="cau_status_list no_column_width widefat striped cau_status_warnings">
<thead> <thead>
<tr> <tr>
<th class="cau_plugin_issue_name" colspan="4"><strong><?php _e( 'Possible plugin issues', 'companion-auto-update' ); ?></strong></th> <th class="cau_plugin_issue_name" colspan="4"><strong><?php _e( 'Possible plugin issues', 'companion-auto-update' ); ?></strong></th>
</tr> </tr>
</thead> </thead>
<tbody id="the-list"> <tbody id="the-list">
<?php <?php
foreach ( cau_incompatiblePluginlist() as $key => $value ) { foreach ( cau_incompatiblePluginlist() as $key => $value ) {
if( is_plugin_active( $key ) ) { if( is_plugin_active( $key ) ) {
echo '<tr> echo '<tr>
<td class="cau_plugin_issue_name"><strong>'.$key.'</strong></td> <td class="cau_plugin_issue_name"><strong>'.$key.'</strong></td>
<td colspan="2" class="cau_plugin_issue_explain">'.$value.'</td> <td colspan="2" class="cau_plugin_issue_explain">'.$value.'</td>
<td class="cau_plugin_issue_fixit"><a href="https://codeermeneer.nl/documentation/known-issues-fixes/#plugins" target="_blank" class="button">'.__( 'How to fix this', 'companion-auto-update' ).'</a></td> <td class="cau_plugin_issue_fixit"><a href="https://codeermeneer.nl/documentation/known-issues-fixes/#plugins" target="_blank" class="button">'.__( 'How to fix this', 'companion-auto-update' ).'</a></td>
</tr>'; </tr>';
} }
} }
?> ?>
</tbody> </tbody>
</table> </table>
<?php } ?> <?php } ?>
<table class="autoupdate cau_status_list widefat striped cau_status_warnings"> <table class="autoupdate cau_status_list widefat striped cau_status_warnings">
<thead> <thead>
<tr> <tr>
<th><strong><?php _e( 'Advanced info', 'companion-auto-update' ); ?></strong> &dash; <?php _e( 'For when you need our help fixing an issue.', 'companion-auto-update' ); ?></th> <th><strong><?php _e( 'Advanced info', 'companion-auto-update' ); ?></strong> &dash; <?php _e( 'For when you need our help fixing an issue.', 'companion-auto-update' ); ?></th>
</tr> </tr>
</thead> </thead>
<tbody id="the-list"> <tbody id="the-list">
<tr> <tr>
<td> <td>
<div class='button button-primary toggle_advanced_button'><?php _e( 'Toggle', 'companion-auto-update' ); ?></div> <div class='button button-primary toggle_advanced_button'><?php _e( 'Toggle', 'companion-auto-update' ); ?></div>
<div class='toggle_advanced_content' style='display: none;'> <div class='toggle_advanced_content' style='display: none;'>
<?php <?php
global $wpdb; global $wpdb;
$autoupdates = $wpdb->prefix."auto_updates"; $autoupdates = $wpdb->prefix."auto_updates";
$cau_configs = $wpdb->get_results( "SELECT * FROM $autoupdates" ); $cau_configs = $wpdb->get_results( "SELECT * FROM $autoupdates" );
array_push( $cau_configs, "WordPress: ".get_bloginfo( 'version' ) ); array_push( $cau_configs, "WordPress: ".get_bloginfo( 'version' ) );
array_push( $cau_configs, "PHP: ".phpversion() ); array_push( $cau_configs, "PHP: ".phpversion() );
array_push( $cau_configs, "DB: ".get_option( "cau_db_version" ).' / '.cau_db_version() ); array_push( $cau_configs, "DB: ".get_option( "cau_db_version" ).' / '.cau_db_version() );
echo "<textarea style='width: 100%; height: 750px;'>"; echo "<textarea style='width: 100%; height: 750px;'>";
print_r( $cau_configs ); print_r( $cau_configs );
echo "</textarea>"; echo "</textarea>";
?> ?>
</div> </div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<script>jQuery( '.toggle_advanced_button' ).click( function() { jQuery( '.toggle_advanced_content' ).toggle(); });</script> <script>jQuery( '.toggle_advanced_button' ).click( function() { jQuery( '.toggle_advanced_content' ).toggle(); });</script>
</div> </div>
<?php <?php
// Remove the line // Remove the line
if( isset( $_POST['fixit'] ) ) { if( isset( $_POST['fixit'] ) ) {
check_admin_referer( 'cau_fixit' ); check_admin_referer( 'cau_fixit' );
cau_removeErrorLine(); cau_removeErrorLine();
} }
// Get wp-config location // Get wp-config location
function cau_configFile() { function cau_configFile() {
// Config file // Config file
if ( file_exists( ABSPATH . 'wp-config.php') ) { if ( file_exists( ABSPATH . 'wp-config.php') ) {
$conFile = ABSPATH . 'wp-config.php'; $conFile = ABSPATH . 'wp-config.php';
} else { } else {
$conFile = dirname(ABSPATH) . '/wp-config.php'; $conFile = dirname(ABSPATH) . '/wp-config.php';
} }
return $conFile; return $conFile;
} }
// Change the AUTOMATIC_UPDATER_DISABLED line // Change the AUTOMATIC_UPDATER_DISABLED line
function cau_removeErrorLine() { function cau_removeErrorLine() {
// Config file // Config file
$conFile = cau_configFile(); $conFile = cau_configFile();
// Lines to check and replace // Lines to check and replace
$revLine = "define('AUTOMATIC_UPDATER_DISABLED', false);"; // We could just remove the line, but replacing it will be safer $revLine = "define('AUTOMATIC_UPDATER_DISABLED', false);"; // We could just remove the line, but replacing it will be safer
$posibleLines = array( "define( 'AUTOMATIC_UPDATER_DISABLED', true );", "define( 'AUTOMATIC_UPDATER_DISABLED', minor );" ); // The two base options $posibleLines = array( "define( 'AUTOMATIC_UPDATER_DISABLED', true );", "define( 'AUTOMATIC_UPDATER_DISABLED', minor );" ); // The two base options
foreach ( $posibleLines as $value ) array_push( $posibleLines, strtolower( $value ) ); // Support lowercase variants foreach ( $posibleLines as $value ) array_push( $posibleLines, strtolower( $value ) ); // Support lowercase variants
foreach ( $posibleLines as $value ) array_push( $posibleLines, str_replace( ' ', '', $value ) ); // For variants without spaces foreach ( $posibleLines as $value ) array_push( $posibleLines, str_replace( ' ', '', $value ) ); // For variants without spaces
$melding = __( "We couldn't fix the error for you. Please contact us for further support", 'companion-auto-update' ).'.'; $melding = __( "We couldn't fix the error for you. Please contact us for further support", 'companion-auto-update' ).'.';
$meldingS = 'error'; $meldingS = 'error';
// Check for each string if it exists // Check for each string if it exists
foreach ( $posibleLines as $key => $string ) { foreach ( $posibleLines as $key => $string ) {
if( strpos( file_get_contents( $conFile ), $string ) !== false) { if( strpos( file_get_contents( $conFile ), $string ) !== false) {
$contents = file_get_contents( $conFile ); $contents = file_get_contents( $conFile );
$contents = str_replace( $string, $revLine, $contents ); $contents = str_replace( $string, $revLine, $contents );
file_put_contents( $conFile, $contents ); file_put_contents( $conFile, $contents );
$melding = __( "We've fixed the error for you", 'companion-auto-update' ).' :)'; $melding = __( "We've fixed the error for you", 'companion-auto-update' ).' :)';
$meldingS = 'updated'; $meldingS = 'updated';
} }
} }
echo "<div id='message' class='$meldingS'><p><strong>$melding</strong></p></div>"; echo "<div id='message' class='$meldingS'><p><strong>$melding</strong></p></div>";
} }
?> ?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1026,6 +1026,10 @@ function cau_list_outdated() {
if ( ! function_exists( 'get_plugins' ) ) { if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php'; require_once ABSPATH . 'wp-admin/includes/plugin.php';
} }
if( !function_exists( 'plugins_api' ) ) {
require_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
}
foreach ( get_plugins() as $key => $value) { foreach ( get_plugins() as $key => $value) {
@ -1037,17 +1041,24 @@ function cau_list_outdated() {
foreach ( $value as $k => $v ) if( $k == "Name" ) $name = $v; foreach ( $value as $k => $v ) if( $k == "Name" ) $name = $v;
// Get plugins tested up to version // Get plugins tested up to version
if( !function_exists( 'plugins_api' ) ) require_once( ABSPATH.'wp-admin/includes/plugin-install.php' ); $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $actualSlug ), 'tested' => true ) );
$api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $actualSlug ) ) );
// Version compare // Version compare
$tested_version = substr( $api->tested, 0, 3 ); // Format version number $tested_version = substr( $api->tested, 0, 3 ); // Format version number
$current_version = substr( get_bloginfo( 'version' ), 0, 3 ); // Format version number
$version_difference = ($current_version - $tested_version); // Get the difference
// $tested_wp = ( empty( $api->tested ) || cau_version_compare( get_bloginfo( 'version' ), $api->tested, '<' ) );
if( $version_difference >= '0.3' ) { // Check if "tested up to" version number is set
$outdatedList[$name] = substr( $api->tested, 0, 3 ); if( $tested_version != '' ) {
$current_version = substr( get_bloginfo( 'version' ), 0, 3 ); // Format version number
$version_difference = ( (int)$current_version - (int)$tested_version ); // Get the difference
// $tested_wp = ( empty( $api->tested ) || cau_version_compare( get_bloginfo( 'version' ), $api->tested, '<' ) );
if( $version_difference >= '0.3' ) {
$outdatedList[$name] = substr( $api->tested, 0, 3 );
}
} else {
$outdatedList[$name] = ''; // We'll catch this when sending the e-mail
} }
} }

View File

@ -1,466 +1,467 @@
<?php <?php
/* /*
* Plugin Name: Companion Auto Update * Plugin Name: Companion Auto Update
* Plugin URI: http://codeermeneer.nl/portfolio/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. * Description: This plugin auto updates all plugins, all themes and the wordpress core.
* Version: 3.8.2 * Version: 3.8.3
* Author: Papin Schipper * Author: Papin Schipper
* Author URI: http://codeermeneer.nl/ * Author URI: http://codeermeneer.nl/
* Contributors: papin * Contributors: papin
* License: GPLv2 or later * License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html * License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: companion-auto-update * Text Domain: companion-auto-update
* Domain Path: /languages/ * Domain Path: /languages/
*/ */
// Disable direct access // Disable direct access
defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
// Load translations // Load translations
function cau_init() { function cau_init() {
load_plugin_textdomain( 'companion-auto-update', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); // Load language files (for backwards compat mostly) load_plugin_textdomain( 'companion-auto-update', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); // Load language files (for backwards compat mostly)
add_filter( 'plugins_auto_update_enabled', '__return_false' ); // Turn off default WP5.5 plugin update features to avoid confusion add_filter( 'plugins_auto_update_enabled', '__return_false' ); // Turn off default WP5.5 plugin update features to avoid confusion
add_filter( 'themes_auto_update_enabled', '__return_false' ); // Turn off default WP5.5 theme update features to avoid confusion add_filter( 'themes_auto_update_enabled', '__return_false' ); // Turn off default WP5.5 theme update features to avoid confusion
} }
add_action( 'init', 'cau_init' ); add_action( 'init', 'cau_init' );
// Set up the database and required schedules // Set up the database and required schedules
function cau_install( $network_wide ) { function cau_install( $network_wide ) {
if ( is_multisite() && $network_wide ) { if ( is_multisite() && $network_wide ) {
global $wpdb; global $wpdb;
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
foreach ( $blog_ids as $blog_id ) { foreach ( $blog_ids as $blog_id ) {
switch_to_blog( $blog_id ); switch_to_blog( $blog_id );
cau_database_creation(); cau_database_creation();
restore_current_blog(); restore_current_blog();
} }
} else { } else {
cau_database_creation(); cau_database_creation();
} }
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_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_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_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_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 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_set_schedule_mail', 'cau_check_updates_mail' );
add_action( 'cau_outdated_notifier', 'cau_outdated_notifier_mail' ); add_action( 'cau_outdated_notifier', 'cau_outdated_notifier_mail' );
add_action( 'wp_update_plugins', 'cau_run_custom_hooks_p' ); add_action( 'wp_update_plugins', 'cau_run_custom_hooks_p' );
add_action( 'wp_update_themes', 'cau_run_custom_hooks_t' ); add_action( 'wp_update_themes', 'cau_run_custom_hooks_t' );
add_action( 'wp_version_check', 'cau_run_custom_hooks_c' ); add_action( 'wp_version_check', 'cau_run_custom_hooks_c' );
// Hourly event to keep the log up to date // Hourly event to keep the log up to date
function cau_keep_log_uptodate() { function cau_keep_log_uptodate() {
cau_savePluginInformation(); // Check for new plugins and themes cau_savePluginInformation(); // Check for new plugins and themes
cau_check_delayed(); // Check for plugin delays cau_check_delayed(); // Check for plugin delays
} }
add_action( 'cau_log_updater', 'cau_keep_log_uptodate' ); add_action( 'cau_log_updater', 'cau_keep_log_uptodate' );
// Redirect to welcome screen on activation of plugin // Redirect to welcome screen on activation of plugin
function cau_pluginActivateWelcome() { function cau_pluginActivateWelcome() {
add_option( 'cau_redirectToWelcomeScreen', true ); add_option( 'cau_redirectToWelcomeScreen', true );
} }
register_activation_hook(__FILE__, 'cau_pluginActivateWelcome'); register_activation_hook(__FILE__, 'cau_pluginActivateWelcome');
function cau_pluginRedirectWelcomeScreen() { function cau_pluginRedirectWelcomeScreen() {
if ( get_option( 'cau_redirectToWelcomeScreen', false ) ) { if ( get_option( 'cau_redirectToWelcomeScreen', false ) ) {
delete_option( 'cau_redirectToWelcomeScreen' ); delete_option( 'cau_redirectToWelcomeScreen' );
if( !isset( $_GET['activate-multi'] ) ) { if( !isset( $_GET['activate-multi'] ) ) {
wp_redirect( admin_url( cau_menloc().'?page=cau-settings&welcome=1' ) ); wp_redirect( admin_url( cau_menloc().'?page=cau-settings&welcome=1' ) );
} }
} }
} }
add_action( 'admin_init', 'cau_pluginRedirectWelcomeScreen' ); add_action( 'admin_init', 'cau_pluginRedirectWelcomeScreen' );
// Donate url // Donate url
function cau_donateUrl() { function cau_donateUrl() {
return 'https://www.paypal.me/dakel/10/'; return 'https://www.paypal.me/dakel/10/';
} }
// Database version // Database version
function cau_db_version() { function cau_db_version() {
return '3.8.1'; return '3.8.3';
} }
function cau_database_creation() { function cau_database_creation() {
global $wpdb; global $wpdb;
// Plugin db info // Plugin db info
$cau_db_version = cau_db_version(); $cau_db_version = cau_db_version();
$autoupdates = $wpdb->prefix."auto_updates"; $autoupdates = $wpdb->prefix."auto_updates";
$updateLog = $wpdb->prefix."update_log"; $updateLog = $wpdb->prefix."update_log";
// WordPress db info // WordPress db info
$charset_collate = $wpdb->get_charset_collate(); $charset_collate = $wpdb->get_charset_collate();
// DB table creation queries // DB table creation queries
$sql = "CREATE TABLE $autoupdates ( $sql = "CREATE TABLE $autoupdates (
id INT(9) NOT NULL AUTO_INCREMENT, id INT(9) NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,
onoroff TEXT NOT NULL, onoroff TEXT NOT NULL,
UNIQUE KEY id (id) UNIQUE KEY id (id)
) $charset_collate;"; ) $charset_collate;";
$sql2 = "CREATE TABLE $updateLog ( $sql2 = "CREATE TABLE $updateLog (
id INT(9) NOT NULL AUTO_INCREMENT, id INT(9) NOT NULL AUTO_INCREMENT,
slug VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL,
oldVersion VARCHAR(10) NOT NULL, oldVersion VARCHAR(10) NOT NULL,
newVersion VARCHAR(10) NOT NULL, newVersion VARCHAR(10) NOT NULL,
method VARCHAR(10) NOT NULL, method VARCHAR(10) NOT NULL,
put_on_hold VARCHAR(100) DEFAULT '0', put_on_hold VARCHAR(100) DEFAULT '0',
UNIQUE KEY id (id) UNIQUE KEY id (id)
) $charset_collate;"; ) $charset_collate;";
// Create DB tables // Create DB tables
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql ); dbDelta( $sql );
dbDelta( $sql2 ); dbDelta( $sql2 );
// Database version // Database version
add_option( "cau_db_version", "$cau_db_version" ); add_option( "cau_db_version", "$cau_db_version" );
// Insert data // Insert data
cau_install_data(); cau_install_data();
} }
// Check if database table exists before creating // Check if database table exists before creating
function cau_check_if_exists( $whattocheck, $id = 'name', $db_table = 'auto_updates' ) { function cau_check_if_exists( $whattocheck, $id = 'name', $db_table = 'auto_updates' ) {
global $wpdb; global $wpdb;
$table_name = $wpdb->prefix.$db_table; $table_name = $wpdb->prefix.$db_table;
$rows = $wpdb->get_col( "SELECT COUNT(*) as num_rows FROM {$table_name} WHERE {$id} = '{$whattocheck}'" ); $rows = $wpdb->get_col( "SELECT COUNT(*) as num_rows FROM {$table_name} WHERE {$id} = '{$whattocheck}'" );
$check = $rows[0]; $check = $rows[0];
if( $check > 0 ) { if( $check > 0 ) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
// Insert date into database // Insert date into database
function cau_install_data() { function cau_install_data() {
global $wpdb; global $wpdb;
$table_name = $wpdb->prefix . "auto_updates"; $table_name = $wpdb->prefix . "auto_updates";
$toemail = get_option('admin_email'); $toemail = get_option('admin_email');
// Update configs // Update configs
if( !cau_check_if_exists( 'plugins' ) ) $wpdb->insert( $table_name, array( 'name' => 'plugins', 'onoroff' => 'on' ) ); if( !cau_check_if_exists( 'plugins' ) ) $wpdb->insert( $table_name, array( 'name' => 'plugins', 'onoroff' => 'on' ) );
if( !cau_check_if_exists( 'themes' ) ) $wpdb->insert( $table_name, array( 'name' => 'themes', 'onoroff' => 'on' ) ); if( !cau_check_if_exists( 'themes' ) ) $wpdb->insert( $table_name, array( 'name' => 'themes', 'onoroff' => 'on' ) );
if( !cau_check_if_exists( 'minor' ) ) $wpdb->insert( $table_name, array( 'name' => 'minor', 'onoroff' => 'on' ) ); if( !cau_check_if_exists( 'minor' ) ) $wpdb->insert( $table_name, array( 'name' => 'minor', 'onoroff' => 'on' ) );
if( !cau_check_if_exists( 'major' ) ) $wpdb->insert( $table_name, array( 'name' => 'major', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'major' ) ) $wpdb->insert( $table_name, array( 'name' => 'major', 'onoroff' => '' ) );
// Email configs // Email configs
if( !cau_check_if_exists( 'email' ) ) $wpdb->insert( $table_name, array( 'name' => 'email', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'email' ) ) $wpdb->insert( $table_name, array( 'name' => 'email', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'send' ) ) $wpdb->insert( $table_name, array( 'name' => 'send', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'send' ) ) $wpdb->insert( $table_name, array( 'name' => 'send', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'sendupdate' ) ) $wpdb->insert( $table_name, array( 'name' => 'sendupdate', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'sendupdate' ) ) $wpdb->insert( $table_name, array( 'name' => 'sendupdate', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'sendoutdated' ) ) $wpdb->insert( $table_name, array( 'name' => 'sendoutdated', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'sendoutdated' ) ) $wpdb->insert( $table_name, array( 'name' => 'sendoutdated', 'onoroff' => '' ) );
// Advanced // Advanced
if( !cau_check_if_exists( 'notUpdateList' ) ) $wpdb->insert( $table_name, array( 'name' => 'notUpdateList', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'notUpdateList' ) ) $wpdb->insert( $table_name, array( 'name' => 'notUpdateList', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'translations' ) ) $wpdb->insert( $table_name, array( 'name' => 'translations', 'onoroff' => 'on' ) ); if( !cau_check_if_exists( 'translations' ) ) $wpdb->insert( $table_name, array( 'name' => 'translations', 'onoroff' => 'on' ) );
if( !cau_check_if_exists( 'wpemails' ) ) $wpdb->insert( $table_name, array( 'name' => 'wpemails', 'onoroff' => 'on' ) ); if( !cau_check_if_exists( 'wpemails' ) ) $wpdb->insert( $table_name, array( 'name' => 'wpemails', 'onoroff' => 'on' ) );
if( !cau_check_if_exists( 'notUpdateListTh' ) ) $wpdb->insert( $table_name, array( 'name' => 'notUpdateListTh', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'notUpdateListTh' ) ) $wpdb->insert( $table_name, array( 'name' => 'notUpdateListTh', 'onoroff' => '' ) );
// Stuff // 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( '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' => '' ) ); if( !cau_check_if_exists( 'dbupdateemails' ) ) $wpdb->insert( $table_name, array( 'name' => 'dbupdateemails', 'onoroff' => '' ) );
// Advanced // Advanced
if( !cau_check_if_exists( 'allow_administrator' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_administrator', 'onoroff' => 'on' ) ); if( !cau_check_if_exists( 'allow_administrator' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_administrator', 'onoroff' => 'on' ) );
if( !cau_check_if_exists( 'allow_editor' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_editor', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'allow_editor' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_editor', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'allow_author' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_author', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'allow_author' ) ) $wpdb->insert( $table_name, array( 'name' => 'allow_author', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'ignore_seo' ) ) $wpdb->insert( $table_name, array( 'name' => 'ignore_seo', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'ignore_seo' ) ) $wpdb->insert( $table_name, array( 'name' => 'ignore_seo', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'ignore_cron' ) ) $wpdb->insert( $table_name, array( 'name' => 'ignore_cron', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'ignore_cron' ) ) $wpdb->insert( $table_name, array( 'name' => 'ignore_cron', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'advanced_info_emails' ) ) $wpdb->insert( $table_name, array( 'name' => 'advanced_info_emails', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'advanced_info_emails' ) ) $wpdb->insert( $table_name, array( 'name' => 'advanced_info_emails', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'update_delay' ) ) $wpdb->insert( $table_name, array( 'name' => 'update_delay', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'update_delay' ) ) $wpdb->insert( $table_name, array( 'name' => 'update_delay', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'update_delay_days' ) ) $wpdb->insert( $table_name, array( 'name' => 'update_delay_days', 'onoroff' => '' ) ); if( !cau_check_if_exists( 'update_delay_days' ) ) $wpdb->insert( $table_name, array( 'name' => 'update_delay_days', 'onoroff' => '' ) );
if( !cau_check_if_exists( 'plugin_links_emails' ) ) $wpdb->insert( $table_name, array( 'name' => 'plugin_links_emails', 'onoroff' => '' ) );
}
register_activation_hook( __FILE__, 'cau_install' ); }
register_activation_hook( __FILE__, 'cau_install' );
// Clear everything on deactivation
function cau_remove() { // Clear everything on deactivation
function cau_remove() {
// Delete tables
global $wpdb; // Delete tables
$autoupdates = $wpdb->prefix."auto_updates"; global $wpdb;
$updateLog = $wpdb->prefix."update_log"; $autoupdates = $wpdb->prefix."auto_updates";
$wpdb->query( "DROP TABLE IF EXISTS $autoupdates" ); $updateLog = $wpdb->prefix."update_log";
$wpdb->query( "DROP TABLE IF EXISTS $updateLog" ); $wpdb->query( "DROP TABLE IF EXISTS $autoupdates" );
$wpdb->query( "DROP TABLE IF EXISTS $updateLog" );
// Clear schedules
wp_clear_scheduled_hook( 'cau_set_schedule_mail' ); // Clear schedules
wp_clear_scheduled_hook( 'cau_custom_hooks_plugins' ); wp_clear_scheduled_hook( 'cau_set_schedule_mail' );
wp_clear_scheduled_hook( 'cau_custom_hooks_themes' ); wp_clear_scheduled_hook( 'cau_custom_hooks_plugins' );
wp_clear_scheduled_hook( 'cau_log_updater' ); wp_clear_scheduled_hook( 'cau_custom_hooks_themes' );
wp_clear_scheduled_hook( 'cau_log_updater' );
// Restore WordPress default update functionality
add_filter( 'plugins_auto_update_enabled', '__return_true' ); // Restore WordPress default update functionality
add_filter( 'themes_auto_update_enabled', '__return_true' ); add_filter( 'plugins_auto_update_enabled', '__return_true' );
add_filter( 'auto_plugin_update_send_email', '__return_true' ); add_filter( 'themes_auto_update_enabled', '__return_true' );
add_filter( 'auto_theme_update_send_email', '__return_true' ); add_filter( 'auto_plugin_update_send_email', '__return_true' );
} add_filter( 'auto_theme_update_send_email', '__return_true' );
register_deactivation_hook( __FILE__, 'cau_remove' ); }
register_deactivation_hook( __FILE__, 'cau_remove' );
// Update
function cau_update_db_check() { // Update
function cau_update_db_check() {
$cau_db_version = cau_db_version();
$cau_db_version = cau_db_version();
if ( get_site_option( 'cau_db_version' ) != $cau_db_version ) {
if ( get_site_option( 'cau_db_version' ) != $cau_db_version ) {
cau_database_creation();
cau_database_creation();
// In 3.7.2 we've added $wpdb->get_charset_collate
if( get_site_option( 'cau_db_version' ) < '3.7.2' ) { // 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"; global $wpdb;
$updateLog = $wpdb->prefix."update_log"; $autoupdates = $wpdb->prefix."auto_updates";
$db_charset = constant( 'DB_CHARSET' ); $updateLog = $wpdb->prefix."update_log";
$wpdb->query( "ALTER TABLE $autoupdates CONVERT TO CHARACTER SET $db_charset" ); $db_charset = constant( 'DB_CHARSET' );
$wpdb->query( "ALTER TABLE $updateLog CONVERT TO CHARACTER SET $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 );
} update_option( "cau_db_version", $cau_db_version );
}
}
add_action( 'upgrader_process_complete', 'cau_update_db_check' ); }
add_action( 'upgrader_process_complete', 'cau_update_db_check' );
// Manual update
function cau_manual_update() { // Manual update
cau_update_db_check(); function cau_manual_update() {
} cau_update_db_check();
}
// Load custom functions
require_once( plugin_dir_path( __FILE__ ) . 'cau_functions.php' ); // Load custom functions
require_once( plugin_dir_path( __FILE__ ) . 'cau_functions.php' );
// Add plugin to menu
function register_cau_menu_page() { // Add plugin to menu
if( cau_allowed_user_rights() ) add_submenu_page( cau_menloc() , __( 'Auto Updater', 'companion-auto-update' ), __( 'Auto Updater', 'companion-auto-update' ), 'manage_options', 'cau-settings', 'cau_frontend' ); function register_cau_menu_page() {
} if( cau_allowed_user_rights() ) add_submenu_page( cau_menloc() , __( 'Auto Updater', 'companion-auto-update' ), __( 'Auto Updater', 'companion-auto-update' ), 'manage_options', 'cau-settings', 'cau_frontend' );
add_action( 'admin_menu', 'register_cau_menu_page' ); }
add_action( 'admin_menu', 'register_cau_menu_page' );
// Settings page
function cau_frontend() { ?> // Settings page
function cau_frontend() { ?>
<div class='wrap cau_content_wrap cau_content'>
<div class='wrap cau_content_wrap cau_content'>
<h1 class="wp-heading-inline"><?php _e( 'Companion Auto Update', 'companion-auto-update' ); ?></h1>
<h1 class="wp-heading-inline"><?php _e( 'Companion Auto Update', 'companion-auto-update' ); ?></h1>
<hr class="wp-header-end">
<hr class="wp-header-end">
<?php
<?php
// Make sure the correct timezone is used
date_default_timezone_set( cau_get_proper_timezone() ); // Make sure the correct timezone is used
date_default_timezone_set( cau_get_proper_timezone() );
// Allow only access to these pages
$allowedPages = array( // Allow only access to these pages
'dashboard' => __( 'Dashboard' ), $allowedPages = array(
'pluginlist' => __( 'Update filter', 'companion-auto-update' ), 'dashboard' => __( 'Dashboard' ),
'log' => __( 'Update log', 'companion-auto-update' ), 'pluginlist' => __( 'Update filter', 'companion-auto-update' ),
'status' => __( 'Status', 'companion-auto-update' ), 'log' => __( 'Update log', 'companion-auto-update' ),
); 'status' => __( 'Status', 'companion-auto-update' ),
);
// Show subtabs
echo "<h2 class='nav-tab-wrapper wp-clearfix'>"; // Show subtabs
foreach ( $allowedPages as $page => $title ) { echo "<h2 class='nav-tab-wrapper wp-clearfix'>";
echo "<a href='".cau_url( $page )."' id='tab-".$page."' class='nav-tab "._active_tab( $page )."'>".$title; foreach ( $allowedPages as $page => $title ) {
if( $page == 'status' ) { echo "<a href='".cau_url( $page )."' id='tab-".$page."' class='nav-tab "._active_tab( $page )."'>".$title;
if( cau_pluginHasIssues() ) { if( $page == 'status' ) {
echo "<span class='cau_melding level-".cau_pluginIssueLevels()."'></span>"; if( cau_pluginHasIssues() ) {
} else { echo "<span class='cau_melding level-".cau_pluginIssueLevels()."'></span>";
echo "<span class='cau_melding level-okay'></span>"; } else {
} echo "<span class='cau_melding level-okay'></span>";
} }
echo "</a>"; }
} echo "</a>";
echo "</h2>"; }
echo "</h2>";
// Show page content
if( !isset( $_GET['tab'] ) ) { // Show page content
$requestedPage = 'dashboard'; if( !isset( $_GET['tab'] ) ) {
echo "<script>jQuery('#tab-dashboard').addClass('nav-tab-active');</script>"; // Set active tab class $requestedPage = 'dashboard';
} else { echo "<script>jQuery('#tab-dashboard').addClass('nav-tab-active');</script>"; // Set active tab class
$requestedPage = sanitize_key( $_GET['tab'] ); } else {
} $requestedPage = sanitize_key( $_GET['tab'] );
}
if( array_key_exists( $requestedPage, $allowedPages ) ) {
require_once( plugin_dir_path( __FILE__ ) . 'admin/'.$requestedPage.'.php' ); if( array_key_exists( $requestedPage, $allowedPages ) ) {
} else { require_once( plugin_dir_path( __FILE__ ) . 'admin/'.$requestedPage.'.php' );
wp_die( 'You\'re not allowed to view <strong>'.$requestedPage.'</strong>.' ); } else {
} wp_die( 'You\'re not allowed to view <strong>'.$requestedPage.'</strong>.' );
}
?>
?>
</div>
</div>
<?php }
<?php }
// Add a widget to the dashboard.
function cau_add_widget() { // Add a widget to the dashboard.
if ( cau_allowed_user_rights() ) wp_add_dashboard_widget( 'cau-update-log', __('Update log', 'companion-auto-update'), 'cau_widget' ); function cau_add_widget() {
} if ( cau_allowed_user_rights() ) wp_add_dashboard_widget( 'cau-update-log', __('Update log', 'companion-auto-update'), 'cau_widget' );
add_action( 'wp_dashboard_setup', 'cau_add_widget' ); }
add_action( 'wp_dashboard_setup', 'cau_add_widget' );
function cau_widget() {
function cau_widget() {
echo '<style>table.autoupdatewidget { border: 0px solid transparent; border-bottom: 1px solid #EEEEEE; margin: 0 -12px; width: calc(100% + 24px); } table.autoupdatewidget tr td { border-top: 1px solid #EEEEEE; padding: 9px 12px 5px 12px; background: #FAFAFA; } .cau_divide { display: inline-block; color: #E7E0DF; padding: 0 2px; } </style>';
echo '<p>'.__('Below are the last 7 updates ran on this site. Includes plugins and themes, both automatically updated and manually updated.', 'companion-auto-update').'</p>'; echo '<style>table.autoupdatewidget { border: 0px solid transparent; border-bottom: 1px solid #EEEEEE; margin: 0 -12px; width: calc(100% + 24px); } table.autoupdatewidget tr td { border-top: 1px solid #EEEEEE; padding: 9px 12px 5px 12px; background: #FAFAFA; } .cau_divide { display: inline-block; color: #E7E0DF; padding: 0 2px; } </style>';
cau_fetch_log( '7' ); echo '<p>'.__('Below are the last 7 updates ran on this site. Includes plugins and themes, both automatically updated and manually updated.', 'companion-auto-update').'</p>';
echo '<p> cau_fetch_log( '7' );
<a href="'.cau_url( 'log' ).'">'.__('View full changelog', 'companion-auto-update').'</a> echo '<p>
<span class="cau_divide">|</span> <a href="'.cau_url( 'log' ).'">'.__('View full changelog', 'companion-auto-update').'</a>
<a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a> <span class="cau_divide">|</span>
</p>'; <a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>
</p>';
}
}
// Load admin styles
function load_cau_global_styles( $hook ) { // Load admin styles
function load_cau_global_styles( $hook ) {
// Plugin scripts
wp_enqueue_style( 'cau_admin_styles', plugins_url( 'backend/style.css' , __FILE__ ) ); // Plugin scripts
wp_enqueue_style( 'cau_admin_styles', plugins_url( 'backend/style.css' , __FILE__ ) );
// Check for issues
wp_enqueue_style( 'cau_warning_styles', plugins_url( 'backend/warningbar.css' , __FILE__ ) ); // Check for issues
wp_enqueue_style( 'cau_warning_styles', plugins_url( 'backend/warningbar.css' , __FILE__ ) );
}
add_action( 'admin_enqueue_scripts', 'load_cau_global_styles', 99 ); }
add_action( 'admin_enqueue_scripts', 'load_cau_global_styles', 99 );
// Load admin styles
function load_cau_page_styles( $hook ) { // Load admin styles
function load_cau_page_styles( $hook ) {
// Only load on plugins' pages
if( $hook != 'tools_page_cau-settings' && $hook != 'index_page_cau-settings' ) return; // Only load on plugins' pages
if( $hook != 'tools_page_cau-settings' && $hook != 'index_page_cau-settings' ) return;
// WordPress scripts we need
wp_enqueue_style( 'thickbox' ); // WordPress scripts we need
wp_enqueue_script( 'thickbox' ); wp_enqueue_style( 'thickbox' );
wp_enqueue_script( 'plugin-install' ); wp_enqueue_script( 'thickbox' );
wp_enqueue_script( 'plugin-install' );
}
add_action( 'admin_enqueue_scripts', 'load_cau_page_styles', 100 ); }
add_action( 'admin_enqueue_scripts', 'load_cau_page_styles', 100 );
// Send e-mails
require_once( plugin_dir_path( __FILE__ ) . 'cau_emails.php' ); // Send e-mails
require_once( plugin_dir_path( __FILE__ ) . 'cau_emails.php' );
// Add settings link on plugin page
function cau_settings_link( $links ) { // Add settings link on plugin page
function cau_settings_link( $links ) {
$settings_link = '<a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>';
$settings_link2 = '<a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update">'.__( 'Help us translate', 'companion-auto-update' ).'</a>'; $settings_link = '<a href="'.cau_url( 'dashboard' ).'">'.__( 'Settings' ).'</a>';
$settings_link3 = '<a href="'.cau_donateUrl().'">'.__( 'Donate to help development', 'companion-auto-update' ).'</a>'; $settings_link2 = '<a href="https://translate.wordpress.org/projects/wp-plugins/companion-auto-update">'.__( 'Help us translate', 'companion-auto-update' ).'</a>';
$settings_link3 = '<a href="'.cau_donateUrl().'">'.__( 'Donate to help development', 'companion-auto-update' ).'</a>';
array_unshift( $links, $settings_link2 );
array_unshift( $links, $settings_link3 ); array_unshift( $links, $settings_link2 );
if( cau_allowed_user_rights() ) array_unshift( $links, $settings_link ); array_unshift( $links, $settings_link3 );
if( cau_allowed_user_rights() ) array_unshift( $links, $settings_link );
return $links;
return $links;
}
$plugin = plugin_basename(__FILE__); }
add_filter( "plugin_action_links_$plugin", "cau_settings_link" ); $plugin = plugin_basename(__FILE__);
add_filter( "plugin_action_links_$plugin", "cau_settings_link" );
// Auto Update Class
class CAU_auto_update { // Auto Update Class
class CAU_auto_update {
public function __construct() {
public function __construct() {
// Enable Update filters
add_action( 'plugins_loaded', array( &$this, 'CAU_auto_update_filters' ), 1 ); // Enable Update filters
add_action( 'plugins_loaded', array( &$this, 'CAU_auto_update_filters' ), 1 );
}
}
public function CAU_auto_update_filters() {
public function CAU_auto_update_filters() {
global $wpdb;
$table_name = $wpdb->prefix . "auto_updates"; global $wpdb;
$table_name = $wpdb->prefix . "auto_updates";
// Disable WP emails
add_filter( 'auto_plugin_update_send_email', '__return_false' ); // Plugin updates // Disable WP emails
add_filter( 'auto_theme_update_send_email', '__return_false' ); // Theme updates add_filter( 'auto_plugin_update_send_email', '__return_false' ); // Plugin updates
add_filter( 'auto_theme_update_send_email', '__return_false' ); // Theme updates
// Enable for major updates
$configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'major'"); // Enable for major updates
foreach ( $configs as $config ) { $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'major'");
if( $config->onoroff == 'on' ) add_filter( 'allow_major_auto_core_updates', '__return_true', 1 ); // Turn on foreach ( $configs as $config ) {
else add_filter( 'allow_major_auto_core_updates', '__return_false', 1 ); // Turn off if( $config->onoroff == 'on' ) add_filter( 'allow_major_auto_core_updates', '__return_true', 1 ); // Turn on
} else add_filter( 'allow_major_auto_core_updates', '__return_false', 1 ); // Turn off
}
// Enable for minor updates
$configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'minor'"); // Enable for minor updates
foreach ( $configs as $config ) { $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'minor'");
if( $config->onoroff == 'on' ) add_filter( 'allow_minor_auto_core_updates', '__return_true', 1 ); // Turn on foreach ( $configs as $config ) {
else add_filter( 'allow_minor_auto_core_updates', '__return_false', 1 ); // Turn off if( $config->onoroff == 'on' ) add_filter( 'allow_minor_auto_core_updates', '__return_true', 1 ); // Turn on
} else add_filter( 'allow_minor_auto_core_updates', '__return_false', 1 ); // Turn off
}
// Enable for plugins
$configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'plugins'"); // Enable for plugins
foreach ( $configs as $config ) { $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'plugins'");
if( $config->onoroff == 'on' ) add_filter( 'auto_update_plugin', 'cau_dontUpdatePlugins', 10, 2 ); // Turn on foreach ( $configs as $config ) {
else add_filter( 'auto_update_plugin', '__return_false', 1 ); // Turn off if( $config->onoroff == 'on' ) add_filter( 'auto_update_plugin', 'cau_dontUpdatePlugins', 10, 2 ); // Turn on
} else add_filter( 'auto_update_plugin', '__return_false', 1 ); // Turn off
}
// Enable for themes
$configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'themes'"); // Enable for themes
foreach ( $configs as $config ) { $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'themes'");
if( $config->onoroff == 'on' ) add_filter( 'auto_update_theme', '__return_true' ); // Turn on foreach ( $configs as $config ) {
else add_filter( 'auto_update_theme', '__return_false', 1 ); // Turn off if( $config->onoroff == 'on' ) add_filter( 'auto_update_theme', '__return_true' ); // Turn on
} else add_filter( 'auto_update_theme', '__return_false', 1 ); // Turn off
}
// Enable for translation files
$configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'translations'"); // Enable for translation files
foreach ( $configs as $config ) { $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'translations'");
if( $config->onoroff == 'on' ) add_filter( 'auto_update_translation', '__return_true', 1 ); // Turn on foreach ( $configs as $config ) {
else add_filter( 'auto_update_translation', '__return_false', 1 ); // Turn off if( $config->onoroff == 'on' ) add_filter( 'auto_update_translation', '__return_true', 1 ); // Turn on
} else add_filter( 'auto_update_translation', '__return_false', 1 ); // Turn off
}
// WP Email Config
$configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'wpemails'"); // WP Email Config
foreach ( $configs as $config ) { $configs = $wpdb->get_results( "SELECT * FROM {$table_name} WHERE name = 'wpemails'");
if( $config->onoroff == 'on' ) { foreach ( $configs as $config ) {
add_filter( 'auto_core_update_send_email', '__return_true' ); // Core updates if( $config->onoroff == 'on' ) {
} else { add_filter( 'auto_core_update_send_email', '__return_true' ); // Core updates
add_filter( 'auto_core_update_send_email', '__return_false' ); // Core updates } else {
} add_filter( 'auto_core_update_send_email', '__return_false' ); // Core updates
} }
}
}
}
}
new CAU_auto_update(); }
new CAU_auto_update();
// Check for issues
function cau_checkForIssues( $admin_bar ) { // Check for issues
function cau_checkForIssues( $admin_bar ) {
if( cau_pluginHasIssues() && is_admin() ) {
if( cau_pluginHasIssues() && is_admin() ) {
if( cau_pluginIssueLevels() == 'high' ) {
$cauWaningBarTitle = __( 'Companion Auto Update ran into a critical error. View the status log for more info.', 'companion-auto-update' ); if( cau_pluginIssueLevels() == 'high' ) {
$cauWaningBarTitle = __( 'Companion Auto Update ran into a critical error. View the status log for more info.', 'companion-auto-update' );
$admin_bar->add_menu( array(
'id' => 'cau-has-issues', $admin_bar->add_menu( array(
'title' => '<span class="ab-icon"></span><span class="cau-level-'.cau_pluginIssueLevels().'">'.cau_pluginIssueCount().'</span>', 'id' => 'cau-has-issues',
'href' => cau_url( 'status' ), 'title' => '<span class="ab-icon"></span><span class="cau-level-'.cau_pluginIssueLevels().'">'.cau_pluginIssueCount().'</span>',
'meta' => array( 'href' => cau_url( 'status' ),
'target' => '_self', 'meta' => array(
'title' => $cauWaningBarTitle, 'target' => '_self',
), 'title' => $cauWaningBarTitle,
)); ),
));
}
}
}
}
}
add_action( 'admin_bar_menu', 'cau_checkForIssues', 150 ); }
add_action( 'admin_bar_menu', 'cau_checkForIssues', 150 );

View File

@ -3,9 +3,9 @@ Contributors: Papin, qweb
Donate link: https://www.paypal.me/dakel/10/ 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 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 Requires at least: 3.6.0
Tested up to: 5.7 Tested up to: 5.9
Requires PHP: 5.1 Requires PHP: 5.1
Stable tag: 3.8.2 Stable tag: 3.8.3
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -81,6 +81,11 @@ So obviously, some of you wondered what the difference would be between the defa
== Changelog == == Changelog ==
= 3.8.3 (December 9, 2021) =
* New: Plugin update e-mails now have an option to link to a few important pages
* Fix: Error: Undefined index: dbupdateemails
* Fix: Error: A non-numeric value encountered
= 3.8.2 (July 1, 2021) = = 3.8.2 (July 1, 2021) =
* Fix: Error: Call to undefined function get_plugin_updates() * Fix: Error: Call to undefined function get_plugin_updates()