From 322cada1330779556d9605ba8c10219b343086a7 Mon Sep 17 00:00:00 2001 From: Marcus Quinn <6428977+marcusquinn@users.noreply.github.com> Date: Fri, 11 Apr 2025 23:49:22 +0100 Subject: [PATCH] Add translation support and internationalization improvements --- CHANGELOG.md | 10 ++ fix-plugin-does-not-exist-notices.php | 50 ++++++-- .../fix-plugin-does-not-exist-notices.pot | 114 ++++++++++++++++++ readme.txt | 12 +- 4 files changed, 173 insertions(+), 13 deletions(-) create mode 100644 languages/fix-plugin-does-not-exist-notices.pot diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bc7fee..3dccf6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. +## [1.6.0] - 2024-05-15 +### Added +- Full translation support with POT file +- JavaScript localization for better multilingual support +- Plugin constants for improved code organization + +### Changed +- Updated code to follow WordPress internationalization best practices +- Improved asset loading with version constants + ## [1.5.0] - 2024-05-15 ### Added - Improved compatibility with WordPress 6.4 diff --git a/fix-plugin-does-not-exist-notices.php b/fix-plugin-does-not-exist-notices.php index c7f44ea..2253e7f 100644 --- a/fix-plugin-does-not-exist-notices.php +++ b/fix-plugin-does-not-exist-notices.php @@ -10,7 +10,7 @@ * @wordpress-plugin * Plugin Name: Fix 'Plugin file does not exist.' Notices * Description: Adds missing plugins to the plugins list with a "Remove Reference" link so you can permanently clean up invalid plugin entries and remove error notices. - * Version: 1.5.0 + * Version: 1.6.0 * Author: Marcus Quinn * Author URI: https://www.wpallstars.com * License: GPL-2.0+ @@ -39,6 +39,27 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } +// Define plugin constants +define( 'FPDEN_VERSION', '1.6.0' ); +define( 'FPDEN_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); +define( 'FPDEN_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); +define( 'FPDEN_PLUGIN_FILE', __FILE__ ); +define( 'FPDEN_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); + +/** + * Load plugin text domain. + * + * @return void + */ +function fpden_load_textdomain() { + load_plugin_textdomain( + 'fix-plugin-does-not-exist-notices', + false, + dirname( plugin_basename( __FILE__ ) ) . '/languages/' + ); +} +add_action( 'plugins_loaded', 'fpden_load_textdomain' ); + /** * Main class for the plugin. */ @@ -82,28 +103,33 @@ class Fix_Plugin_Does_Not_Exist_Notices { return; // No missing plugins, no need for the special notice JS/CSS. } - $plugin_url = plugin_dir_url( __FILE__ ); - wp_enqueue_style( 'fpden-admin-styles', - $plugin_url . 'assets/css/admin-styles.css', + FPDEN_PLUGIN_URL . 'assets/css/admin-styles.css', array(), - filemtime( plugin_dir_path( __FILE__ ) . 'assets/css/admin-styles.css' ) // Versioning based on file modification time. + FPDEN_VERSION ); wp_enqueue_script( 'fpden-admin-scripts', - $plugin_url . 'assets/js/admin-scripts.js', + FPDEN_PLUGIN_URL . 'assets/js/admin-scripts.js', array( 'jquery' ), // Add dependencies if needed, e.g., jQuery. - filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/admin-scripts.js' ), // Versioning. + FPDEN_VERSION, true // Load in footer. ); - // Optional: Pass localized data to script if needed. - // wp_localize_script('fpden-admin-scripts', 'fpdenData', array( - // 'ajax_url' => admin_url('admin-ajax.php'), - // 'nonce' => wp_create_nonce('fpden_ajax_nonce'), - // )); + // Add translation strings for JavaScript + wp_localize_script( + 'fpden-admin-scripts', + 'fpdenData', + array( + 'i18n' => array( + 'clickToScroll' => esc_html__( 'Click here to scroll to missing plugins', 'fix-plugin-does-not-exist-notices' ), + 'pluginMissing' => esc_html__( 'Plugin file missing', 'fix-plugin-does-not-exist-notices' ), + 'removeReference' => esc_html__( 'Remove Reference', 'fix-plugin-does-not-exist-notices' ), + ), + ) + ); } /** diff --git a/languages/fix-plugin-does-not-exist-notices.pot b/languages/fix-plugin-does-not-exist-notices.pot new file mode 100644 index 0000000..886d262 --- /dev/null +++ b/languages/fix-plugin-does-not-exist-notices.pot @@ -0,0 +1,114 @@ +# Copyright (C) 2024 Marcus Quinn +# This file is distributed under the GPL-2.0+. +msgid "" +msgstr "" +"Project-Id-Version: Fix 'Plugin file does not exist.' Notices 1.6.0\n" +"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/fix-plugin-does-not-exist-notices\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"POT-Creation-Date: 2024-05-15T12:00:00+00:00\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"X-Generator: WP-CLI 2.8.1\n" +"X-Domain: fix-plugin-does-not-exist-notices\n" + +#. Plugin Name of the plugin +msgid "Fix 'Plugin file does not exist.' Notices" +msgstr "" + +#. Plugin URI of the plugin +msgid "https://wordpress.org/plugins/fix-plugin-does-not-exist-notices/" +msgstr "" + +#. Description of the plugin +msgid "Adds missing plugins to the plugins list with a \"Remove Reference\" link so you can permanently clean up invalid plugin entries and remove error notices." +msgstr "" + +#. Author of the plugin +msgid "Marcus Quinn" +msgstr "" + +#. Author URI of the plugin +msgid "https://www.wpallstars.com" +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:127 +msgid "Click here to scroll to missing plugins" +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:128 +msgid "Plugin file missing" +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:129 +#: fix-plugin-does-not-exist-notices.php:205 +msgid "Remove Reference" +msgstr "" + +#. translators: %s: Path to wp-content/plugins +#: fix-plugin-does-not-exist-notices.php:161 +msgid "This plugin is still marked as \"Active\" in your database — but its folder and files can't be found in %s. Click \"Remove Reference\" to permanently remove it from your active plugins list and eliminate the error notice." +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:164 +msgid "N/A" +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:168 +msgid "Missing" +msgstr "" + +#. translators: %s: Plugin file path +#: fix-plugin-does-not-exist-notices.php:204 +msgid "Remove reference to missing plugin %s" +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:227 +msgid "You do not have sufficient permissions to perform this action." +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:233 +msgid "Invalid plugin specified." +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:308 +msgid "Plugin reference removed successfully." +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:316 +msgid "Failed to remove plugin reference. The plugin may already have been removed, or there was a database issue." +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:331 +msgid "Fix Plugin Does Not Exist Notices" +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:333 +msgid "Missing plugin files detected:" +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:334 +msgid "The plugins listed below with a" +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:335 +msgid "File Missing" +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:336 +msgid "tag no longer exist but are still referenced in your database." +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:339 +msgid "How to fix:" +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:340 +msgid "Click the \"Remove Reference\" link next to each missing plugin to safely remove it from your active plugins list." +msgstr "" + +#: fix-plugin-does-not-exist-notices.php:342 +msgid "This will clean up your database and remove the error notifications." +msgstr "" diff --git a/readme.txt b/readme.txt index 666d86f..6f162e9 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: plugins, missing plugins, cleanup, error fix, admin tools, plugin file doe Requires at least: 5.0 Tested up to: 6.4 Requires PHP: 7.0 -Stable tag: 1.5.0 +Stable tag: 1.6.0 License: GPL-2.0+ License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -89,6 +89,13 @@ Although this plugin consumes minimal disk space, and doesn't run unless you are == Changelog == += 1.6.0 = +* Added full translation support with POT file +* Added JavaScript localization for better multilingual support +* Added plugin constants for improved code organization +* Updated code to follow WordPress internationalization best practices +* Improved asset loading with version constants + = 1.5.0 = * Improved compatibility with WordPress 6.4 * Enhanced error detection for plugin references @@ -161,6 +168,9 @@ Although this plugin consumes minimal disk space, and doesn't run unless you are == Upgrade Notice == += 1.6.0 = +Added full translation support! The plugin can now be translated into any language. + = 1.5.0 = Improved compatibility with WordPress 6.4 and accessibility enhancements for screen readers!