Skip to content

Commit

Permalink
fix to reloading logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AsyncAlchemist committed May 20, 2024
1 parent 3513c18 commit a166b73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cache-everything.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* Plugin Name: Cache Everything
* Plugin URI: https://github.com/AsyncAlchemist
* Description: A simple plugin to cache everything in Wordpress.
* Version: 0.28
* Version: 0.29
* Author: Taylor Selden
* Author URI: https://github.com/AsyncAlchemist
*/
define('CACHE_EVERYTHING_JS_URL', 'wp-content/plugins/cache-everything/js');
define('CACHE_EVERYTHING_CSS_URL', 'wp-content/plugins/cache-everything/css');
define('CACHE_EVERYTHING_VERSION', '0.28');
define('CACHE_EVERYTHING_VERSION', '0.29');

require_once(plugin_dir_path(__FILE__) . 'handle-js-request.php');
require_once(plugin_dir_path(__FILE__) . 'handle-css-request.php');
Expand Down
8 changes: 4 additions & 4 deletions public/js/cache-everything.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ function isUser() {
function rewriteLinksOrReloadForAdmin() {
const isEditorActive = document.querySelector('.elementor-editor-active') !== null;
const isWpAdminBarPresent = document.getElementById('wpadminbar') !== null;
const isInAdminPanel = window.location.href.includes('/wp-admin/') || window.location.href.includes('elementor');
debugPrint(`Checking admin role and page conditions for cachebuster application. Admin: ${isRole('administrator')}, WP Admin: ${isInAdminPanel}, Editor Active: ${isEditorActive}, WP Admin Bar Present: ${isWpAdminBarPresent}`);

debugPrint(`Checking admin role and page conditions for cachebuster application. Admin: ${isRole('administrator')}, WP Admin: ${window.location.href.includes('/wp-admin/')}, Editor Active: ${isEditorActive}, WP Admin Bar Present: ${isWpAdminBarPresent}`);

if (isRole('administrator') && !window.location.href.includes('/wp-admin/') && !isEditorActive) {
if (isRole('administrator') && !isInAdminPanel && !isEditorActive) {
const currentUrl = window.location.href;
const hasQueryParams = currentUrl.includes('?');
const hasCachebuster = currentUrl.includes('cachebuster=');
const hasCachebuster = currentUrl.includes('cachebuster');

if (!isWpAdminBarPresent && !hasCachebuster) {
// Reload the current page with a cachebuster if the wp-admin bar is not present and no cachebuster exists
Expand Down

0 comments on commit a166b73

Please sign in to comment.