added empty cache on restart debug option

This commit is contained in:
Harald Milz 2019-04-08 13:53:45 +02:00
parent f2cd7d8a85
commit 40d411388b
2 changed files with 23 additions and 10 deletions

View file

@ -110,8 +110,8 @@ function gcal_geocoding_section_text() {
?>
<p><b>Um Termine auf der Karte zu sehen, ist es nötig, die Orte zu geocoden, d.h. </br>
deren geografische Länge und Breite herauszufinden. Dafür sind mehrere </br>
Verfahren wählbar:</b>
</p>
Verfahren wählbar. </br>
</b></p>
<?php
}
@ -154,7 +154,11 @@ function gcal_geocoding_setting_string() {
function gcal_debugging_section_text() {
?>
<p><b>Debugging aktivieren (landet in ${APACHE_LOG_DIR}/error.log).</b></p>
<p><b>Debugging aktivieren (landet in ${APACHE_LOG_DIR}/error.log).</br>
Um die Performance zu verbessern, werden gefundene Geocoding-Daten zwischengespeichert. </br>
Zu Debugging-Zwecken kann der Zwischenspeicher (Cache) beim Neustart des Plugins gelöscht </br>
werden, um ein neues Geocoding aller Event-Lokationen zu erzwingen. </br>
</b></p>
<?php
}
@ -163,9 +167,10 @@ function gcal_debugging_section_text() {
function gcal_debugging_setting_string($args) {
$options = get_option('gcal_options');
// example from https://code.tutsplus.com/tutorials/the-wordpress-settings-api-part-8-validation-sanitisation-and-input-i--wp-25361
echo '<input type="checkbox" id="gcal_debugging" name="gcal_options[gcal_debugging]" value="1"' . checked( 1, $options['gcal_debugging'], false ) . '>';
echo '<input type="checkbox" id="gcal_debugging" name="gcal_options[gcal_debugging]" value="1"' . checked( 1, $options['gcal_debugging'], false ) . '> Debug-Logging aktivieren </br>';
// actual logging is done by gcal_error_log()
}
// Cache reset on restart
echo '<input type="checkbox" id="gcal_reset_cache" name="gcal_options[gcal_reset_cache]" value="1"' . checked( 1, $options['gcal_reset_cache'], false ) . '> Geocoding-Cache bei Neustart des Plugins löschen </br>';}

View file

@ -83,7 +83,15 @@ function gcal_import_activate()
if ( ! wp_next_scheduled( 'gcal_import_worker_hook' ) ) {
wp_schedule_event( time(), 'gcal_interval', 'gcal_import_worker_hook' );
}
error_log ("INFO gcal_import activated");
gcal_error_log ("INFO: gcal_import activated");
// empty geocode cache if option is set.
$options = get_option('gcal_options');
if ( isset ( $options['gcal_reset_cache'] ) && '1' == $options['gcal_reset_cache'] ) {
$wpdb->query("DELETE IGNORE FROM $table WHERE 1=1");
gcal_error_log ("INFO: emptied geocoding cache");
}
}
register_activation_hook( __FILE__, 'gcal_import_activate' );
@ -100,7 +108,7 @@ function gcal_import_deactivate()
{
// clean up! Many plugins forget the housekeeping when deactivating.
wp_clear_scheduled_hook('gcal_import_worker_hook');
error_log ("INFO: gcal_import deactivated");
gcal_error_log ("INFO: gcal_import deactivated");
}
register_deactivation_hook( __FILE__, 'gcal_import_deactivate' );
@ -116,7 +124,7 @@ register_deactivation_hook( __FILE__, 'gcal_import_deactivate' );
function gcal_import_uninstall()
{
// clean up! Many plugins forget the housekeeping when uninstalling.
error_log ("INFO: uninstalling gcal_import");
gcal_error_log ("INFO: uninstalling gcal_import");
// can we uninstall without deactivating first?
// gcal_import_deactivate;
global $wpdb;
@ -138,8 +146,8 @@ register_uninstall_hook( __FILE__, 'gcal_import_uninstall' );
function gcal_error_log($args) {
$options = get_option('gcal_options');
if ( isset ( gcal_options['gcal_debugging'] ) && '1' == gcal_options['gcal_debugging'] ) {
error_log ( $args );
if ( isset ( $options['gcal_debugging'] ) && '1' == $options['gcal_debugging'] ) {
error_log ( "GCal: $args" );
}
}