diff --git a/bibleget-io.php b/bibleget-io.php index eaeb557..f9efabf 100644 --- a/bibleget-io.php +++ b/bibleget-io.php @@ -1,7 +1,7 @@ options + WHERE `option_name` LIKE '%transient_%".TRANSIENT_PREFIX."%' + "; + //We shouldn't have to do a $wpdb->prepare here because there is no kind of user input anywhere + if($wpdb->query( $sql ) !== false){ + echo 'cacheflushed'; + } + else{ + echo 'cacheNotFlushed'; + } + wp_die(); +} + +add_action('wp_ajax_flush_bible_quotes_cache', 'flushBibleQuotesCache'); + function searchByKeyword(){ $keyword = $_POST['keyword']; $version = $_POST['version']; diff --git a/css/admin.css b/css/admin.css index 1185426..93001f7 100644 --- a/css/admin.css +++ b/css/admin.css @@ -72,6 +72,30 @@ form input[type=color] { left: 0; } +#bibleget-settings-contents .flexcontainer { + display: flex; + justify-content: space-evenly; + padding: 15px; + margin: 15px; + border: 1px solid lightgray; + border-radius: 6px; +} + +#bibleget-settings-contents .flexcontainer .flexitem { + flex-grow: 1; + margin: 15px; + border-right: 1px solid gray; +} + +#bibleget-settings-contents .flexcontainer .flexitem:last-child { + border-right: 0px; +} + +#bibleget-settings-contents .flexcontainer .flexitem button { + display: block; + margin: 0px auto; +} + #bibleget_ajax_spinner { position: absolute; background-color: rgba(0, 0, 0, 0.7); @@ -180,3 +204,9 @@ form input[type=color] { #biblegetForceRefreshGFapiResults:hover,#biblegetGFapiKeyRetest:hover { text-decoration: underline; } + +#versionselect { + overflow-y: hidden; + max-width: 100%; + width: 30em; +} diff --git a/js/admin.js b/js/admin.js index 43fc7a2..1bf7a74 100644 --- a/js/admin.js +++ b/js/admin.js @@ -81,6 +81,48 @@ jQuery(document).ready(function($) { }); }); + jQuery('#bibleget-cache-flush-btn').on('click', function(){ + jQuery.ajax({ + type: 'POST', + url: bibleGetOptionsFromServer.ajax_url, + data: { action: 'flush_bible_quotes_cache' }, + beforeSend : function() { + jQuery('#bibleget_ajax_spinner').show(); + }, + complete : function() { + jQuery('#bibleget_ajax_spinner').hide(); + }, + success : function(returndata) { + if (returndata == 'cacheflushed') { + jQuery( + "#bibleget-settings-notification") + .append( + 'Bible quotes cache emptied successfully') + .fadeIn("slow"); + } else { + jQuery("#bibleget-settings-notification").append( + 'There was an error while attempting to flush the Bible quotes cache... Perhaps try again?') + .fadeIn("slow"); + } + jQuery(".bibleget-settings-notification-dismiss") + .click(function() { + jQuery("#bibleget-settings-notification").fadeOut("slow"); + }); + + }, + error: function(xhr, ajaxOptions, thrownError){ + jQuery("#bibleget-settings-notification") + .fadeIn("slow") + .append('Emptying of Bible quotes cache was not successful... ERROR: ' + xhr.responseText); + jQuery(".bibleget-settings-notification-dismiss") + .click(function() { + jQuery("#bibleget-settings-notification").fadeOut("slow"); + }); + + } + }); + }); + if(typeof gfontsBatch !== 'undefined' && typeof gfontsBatch === 'object' && gfontsBatch.hasOwnProperty('job') && gfontsBatch.job.hasOwnProperty('gfontsPreviewJob') && gfontsBatch.job.gfontsPreviewJob === true && gfontsBatch.job.hasOwnProperty('gfontsWeblist') && typeof gfontsBatch.job.gfontsWeblist == 'object' && gfontsBatch.job.gfontsWeblist.hasOwnProperty('items') ){ //console.log('We have a gfontsPreviewJob to do! gfontsBatch: '); //console.log(gfontsBatch); diff --git a/options.php b/options.php index 71eb082..9c7bf5a 100644 --- a/options.php +++ b/options.php @@ -428,7 +428,7 @@ public function admin_print_scripts($hook) if ($this->gfontsAPIkeyCheckResult == "SUCCESS") { //We only want the transient to be set from the bibleget settings page, so we wait until now // instead of doing it in the gfontsAPIkeyCheck (which is called on any admin interface) - set_transient(TRANSIENT_PREFIX.md5($this->options['googlefontsapi_key']), $this->gfontsAPIkeyCheckResult, 90 * 24 * HOUR_IN_SECONDS); // 90 giorni + set_transient(md5($this->options['googlefontsapi_key']), $this->gfontsAPIkeyCheckResult, 90 * 24 * HOUR_IN_SECONDS); // 90 giorni $plugin_path = ""; // bibleGetWriteLog("about to initialize creation of admin page..."); @@ -543,8 +543,16 @@ public function create_admin_page() echo "