From c00bef482c012ea38c195d7d5857c9033a105061 Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Sun, 13 Apr 2025 04:47:24 +0100 Subject: [PATCH] Version 2.0.13: Fixed critical error with Git Updater integration and cleaned up codebase --- assets/js/plugin-details-fix.js | 74 --------------- assets/js/version-fix.js | 75 ++++++++++++++++ clear-transients.php | 109 ----------------------- gu-branch-fix.php | 87 ------------------ readme.txt | 8 +- wp-fix-plugin-does-not-exist-notices.php | 93 ++++++++++++++++--- 6 files changed, 165 insertions(+), 281 deletions(-) delete mode 100644 assets/js/plugin-details-fix.js create mode 100644 assets/js/version-fix.js delete mode 100644 clear-transients.php delete mode 100644 gu-branch-fix.php diff --git a/assets/js/plugin-details-fix.js b/assets/js/plugin-details-fix.js deleted file mode 100644 index b7da7b9..0000000 --- a/assets/js/plugin-details-fix.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Fix Plugin Details Popup - * - * This script directly modifies the plugin details popup to show the correct version - * when the popup is opened for our plugin. - */ -(function($) { - 'use strict'; - - // Current plugin version - this should match the version in the main plugin file - const CURRENT_VERSION = '2.0.10'; - - // Plugin slugs to check for - const OUR_SLUGS = ['wp-fix-plugin-does-not-exist-notices', 'fix-plugin-does-not-exist-notices']; - - // Wait for the document to be ready - $(document).ready(function() { - // Listen for the thickbox to open (WordPress uses thickbox for plugin details) - $(document).on('tb_init', function() { - // Check if we're on the plugins page - if (window.location.href.indexOf('plugins.php') === -1) { - return; - } - - // Set a timeout to allow the thickbox content to load - setTimeout(function() { - // Get the thickbox content - const $thickbox = $('#TB_window'); - if (!$thickbox.length) return; - - // Get the plugin slug from the URL - const tbUrl = $('#TB_iframeContent').attr('src'); - if (!tbUrl) return; - - // Extract the plugin slug from the URL - const slugMatch = tbUrl.match(/plugin=([^&]+)/); - if (!slugMatch || !slugMatch[1]) return; - - const pluginSlug = decodeURIComponent(slugMatch[1]); - - // Check if this is our plugin - if (OUR_SLUGS.indexOf(pluginSlug) !== -1) { - console.log('Fixing plugin details for: ' + pluginSlug); - - // Find the version element in the thickbox - const $iframe = $('#TB_iframeContent'); - if (!$iframe.length) return; - - // Wait for iframe to load - $iframe.on('load', function() { - const iframeDoc = this.contentDocument || this.contentWindow.document; - - // Find the version element - const $versionElement = $(iframeDoc).find('.plugin-version-author-uri'); - if (!$versionElement.length) return; - - // Update the version text - const versionText = $versionElement.text(); - const newVersionText = versionText.replace(/Version: [0-9.]+/, 'Version: ' + CURRENT_VERSION); - $versionElement.text(newVersionText); - - // Also update the version in the header if it exists - const $versionHeader = $(iframeDoc).find('h2:contains("Version:")'); - if ($versionHeader.length) { - $versionHeader.text('Version: ' + CURRENT_VERSION); - } - - console.log('Plugin details updated to version: ' + CURRENT_VERSION); - }); - } - }, 500); // Wait 500ms for the thickbox to load - }); - }); -})(jQuery); diff --git a/assets/js/version-fix.js b/assets/js/version-fix.js new file mode 100644 index 0000000..0c0c6d2 --- /dev/null +++ b/assets/js/version-fix.js @@ -0,0 +1,75 @@ +/** + * Fix Plugin Version Display + * + * This script directly modifies the plugin details popup to show the correct version + * when the popup is opened for our plugin. + */ +(function($) { + 'use strict'; + + // Current plugin version - this should match the version in the main plugin file + const CURRENT_VERSION = '2.0.13'; + + // Plugin slugs to check for + const OUR_SLUGS = ['wp-fix-plugin-does-not-exist-notices', 'fix-plugin-does-not-exist-notices']; + + // Function to fix the version in the plugin details popup + function fixPluginDetailsVersion() { + // Check if we're on the plugins page + if (window.location.href.indexOf('plugins.php') === -1) { + return; + } + + // Wait for the thickbox to be initialized + $(document).on('tb_init', function() { + // Set a timeout to allow the thickbox content to load + setTimeout(function() { + // Get the thickbox iframe + const $iframe = $('#TB_iframeContent'); + if (!$iframe.length) return; + + // Wait for iframe to load + $iframe.on('load', function() { + try { + const iframeDoc = this.contentDocument || this.contentWindow.document; + + // Get the plugin title from the iframe + const $title = $(iframeDoc).find('h2.plugin-title'); + if (!$title.length) return; + + // Check if this is our plugin + const titleText = $title.text(); + if (titleText.indexOf('Fix \'Plugin file does not exist\' Notices') !== -1) { + console.log('Found our plugin in the details popup, fixing version...'); + + // Find the version element + const $version = $(iframeDoc).find('.plugin-version-author-uri'); + if ($version.length) { + // Update the version text + const versionText = $version.text(); + const newVersionText = versionText.replace(/Version: [0-9.]+|Version: 0\.0\.0/, 'Version: ' + CURRENT_VERSION); + $version.text(newVersionText); + console.log('Updated version to: ' + CURRENT_VERSION); + } + + // Also update the version in the header if it exists + const $versionHeader = $(iframeDoc).find('.wrap h2:contains("Version:")'); + if ($versionHeader.length) { + $versionHeader.text('Version: ' + CURRENT_VERSION); + console.log('Updated version header to: ' + CURRENT_VERSION); + } + } + } catch (e) { + console.error('Error updating plugin version:', e); + } + }); + }, 500); + }); + } + + // Initialize when the document is ready + $(document).ready(function() { + fixPluginDetailsVersion(); + }); + +})(jQuery); diff --git a/clear-transients.php b/clear-transients.php deleted file mode 100644 index 6e80684..0000000 --- a/clear-transients.php +++ /dev/null @@ -1,109 +0,0 @@ -query($wpdb->prepare( - "DELETE FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s", - '%' . $wpdb->esc_like('_transient_' . $slug) . '%', - '%' . $wpdb->esc_like('_transient_timeout_' . $slug) . '%' - )); - - // Delete site transients too (for multisite) - if (is_multisite()) { - $wpdb->query($wpdb->prepare( - "DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE %s OR meta_key LIKE %s", - '%' . $wpdb->esc_like('_site_transient_' . $slug) . '%', - '%' . $wpdb->esc_like('_site_transient_timeout_' . $slug) . '%' - )); - } - } - - // Clear all plugin API transients - $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '%_transient_plugins_api_%'"); - $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '%_transient_timeout_plugins_api_%'"); - $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '%_transient_plugin_information_%'"); - $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '%_transient_timeout_plugin_information_%'"); - - // Clear site transients too (for multisite) - if (is_multisite()) { - $wpdb->query("DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE '%_site_transient_plugins_api_%'"); - $wpdb->query("DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE '%_site_transient_timeout_plugins_api_%'"); - $wpdb->query("DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE '%_site_transient_plugin_information_%'"); - $wpdb->query("DELETE FROM $wpdb->sitemeta WHERE meta_key LIKE '%_site_transient_timeout_plugin_information_%'"); - } - - // Clear update cache - delete_site_transient('update_plugins'); - delete_site_transient('update_themes'); - delete_site_transient('update_core'); - delete_site_transient('plugin_information'); - - // Clear plugin update counts - delete_transient('plugin_updates_count'); - delete_site_transient('plugin_updates_count'); - - // Clear plugin slugs cache - delete_transient('plugin_slugs'); - delete_site_transient('plugin_slugs'); - - // Force refresh of plugin update information - if (function_exists('wp_clean_plugins_cache')) { - wp_clean_plugins_cache(true); - } - - // Clear object cache - if (function_exists('wp_cache_flush')) { - wp_cache_flush(); - } - - // Add admin notice - add_action('admin_notices', 'plugin_transients_cleared_notice'); -} - -/** - * Display admin notice - */ -function plugin_transients_cleared_notice() { - ?> -
Plugin Transients Cleared: All plugin transients have been cleared from the database.
-