Version 2.2.3 - Improved folder structure and organization

This commit is contained in:
2025-04-14 22:56:11 +01:00
parent 3b7f4e49a4
commit fdf2860c10
4 changed files with 7 additions and 268 deletions

View File

@ -7,6 +7,7 @@ This directory contains workflow documentation for AI assistants working with th
- **bug-fixing.md**: Guidelines for identifying and fixing bugs in the codebase
- **code-review.md**: Standards and procedures for reviewing code changes
- **feature-development.md**: Process for developing new features
- **folder-structure.md**: Documentation of the plugin's folder structure and naming conventions
- **local-env-vars.md**: Local development environment paths and URLs
- **release-process.md**: Steps for preparing and publishing new releases

View File

@ -1,95 +0,0 @@
<?php
/**
* Admin Functionality
*
* @package WPALLSTARS\FixPluginDoesNotExistNotices
*/
namespace WPALLSTARS\FixPluginDoesNotExistNotices;
/**
* Admin Class
*
* Handles admin-specific functionality.
*/
class Admin {
/**
* Core instance
*
* @var Core
*/
private $core;
/**
* Constructor
*
* @param Core $core Core instance.
*/
public function __construct($core) {
$this->core = $core;
// Enqueue admin scripts and styles
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_assets'));
}
/**
* Enqueue scripts and styles needed for the admin area.
*
* @param string $hook_suffix The current admin page hook.
* @return void
*/
public function enqueue_admin_assets($hook_suffix) {
// Only load on the plugins page
if ('plugins.php' !== $hook_suffix) {
return;
}
// Version fix script is no longer needed after refactoring
// Commented out for testing
/*
wp_enqueue_script(
'fpden-version-fix',
FPDEN_PLUGIN_URL . 'admin/js/version-fix.js',
array('jquery', 'thickbox'),
FPDEN_VERSION,
true // Load in footer
);
*/
// Get invalid plugins to decide if other assets are needed
$invalid_plugins = $this->core->get_invalid_plugins();
if (empty($invalid_plugins)) {
return; // No missing plugins, no need for the special notice JS/CSS
}
wp_enqueue_style(
'fpden-admin-styles',
FPDEN_PLUGIN_URL . 'admin/css/admin-styles.css',
array(),
FPDEN_VERSION
);
wp_enqueue_script(
'fpden-admin-scripts',
FPDEN_PLUGIN_URL . 'admin/js/admin-scripts.js',
array('jquery'), // Add dependencies if needed, e.g., jQuery
FPDEN_VERSION,
true // Load in footer
);
// 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', 'wp-fix-plugin-does-not-exist-notices'),
'pluginMissing' => esc_html__('File Missing', 'wp-fix-plugin-does-not-exist-notices'),
'removeNotice' => esc_html__('Remove Notice', 'wp-fix-plugin-does-not-exist-notices'),
),
'version' => FPDEN_VERSION, // Add version for the plugin details fix script
)
);
}
}

View File

@ -1,167 +0,0 @@
<?php
/**
* Modal Functionality
*
* @package WPALLSTARS\FixPluginDoesNotExistNotices
*/
namespace WPALLSTARS\FixPluginDoesNotExistNotices;
/**
* Modal Class
*
* Handles the update source selector modal.
*/
class Modal {
/**
* Constructor
*/
public function __construct() {
// Add filter for plugin action links to add our update source selector
add_filter('plugin_action_links_' . plugin_basename(FPDEN_PLUGIN_DIR . 'wp-fix-plugin-does-not-exist-notices.php'), array($this, 'add_update_source_link'));
// Add AJAX handler for saving update source
add_action('wp_ajax_fpden_save_update_source', array($this, 'save_update_source'));
// Add the update source modal to admin footer
add_action('admin_footer', array($this, 'add_update_source_modal'));
}
/**
* Add the "Update Source" link to plugin action links
*
* @param array $links Array of plugin action links
* @return array Modified array of plugin action links
*/
public function add_update_source_link($links) {
if (!current_user_can('manage_options')) {
return $links;
}
// Get current update source
$current_source = get_option('fpden_update_source', 'auto');
// Add a badge to show the current source
$badge_class = 'fpden-source-badge ' . $current_source;
$badge_text = ucfirst($current_source);
if ($current_source === 'auto') {
$badge_text = 'Auto';
} elseif ($current_source === 'wordpress.org') {
$badge_text = 'WP.org';
}
// Add the link with the badge
$update_source_link = '<a href="#" class="fpden-update-source-toggle">Update Source <span class="' . $badge_class . '">' . $badge_text . '</span></a>';
$links[] = $update_source_link;
return $links;
}
/**
* Add the update source modal to the admin footer
*/
public function add_update_source_modal() {
if (!is_admin() || !current_user_can('manage_options')) {
return;
}
// Only show on plugins page
$screen = get_current_screen();
if (!$screen || $screen->id !== 'plugins') {
return;
}
// Get current source
$current_source = get_option('fpden_update_source', 'auto');
// Enqueue the CSS and JS
wp_enqueue_style(
'fpden-update-source-selector',
FPDEN_PLUGIN_URL . 'admin/css/update-source-selector.css',
array(),
FPDEN_VERSION
);
wp_enqueue_script(
'fpden-update-source-selector',
FPDEN_PLUGIN_URL . 'admin/js/update-source-selector.js',
array('jquery'),
FPDEN_VERSION,
true
);
// Add nonce to the existing fpdenData object or create it if it doesn't exist
$nonce = wp_create_nonce('fpden_update_source');
wp_localize_script(
'fpden-update-source-selector',
'fpdenData',
array(
'updateSourceNonce' => $nonce,
)
);
// Modal HTML
?>
<div id="fpden-update-source-modal">
<a href="#" class="fpden-close-modal" aria-label="Close modal">×</a>
<h2>Choose Update Source</h2>
<p>Select where you want to receive plugin updates from:</p>
<form id="fpden-update-source-form">
<label>
<input type="radio" name="update_source" value="wordpress.org" <?php checked($current_source, 'wordpress.org'); ?>>
<a href="https://wordpress.org/plugins/wp-fix-plugin-does-not-exist-notices/" target="_blank" rel="noopener noreferrer">WordPress.org</a>
<span class="fpden-source-description">Updates from the official WordPress.org plugin repository. Has a version update delay, to allow for the WP.org policy review and approval process. Best for unmonitored auto-updates.</span>
</label>
<label>
<input type="radio" name="update_source" value="github" <?php checked($current_source, 'github'); ?>>
<a href="https://github.com/wpallstars/wp-fix-plugin-does-not-exist-notices" target="_blank" rel="noopener noreferrer">GitHub</a>
<span class="fpden-source-description">Update directly from the GitHub repo main branch for the latest stable release. Git Updater plugin must be installed & active. Best for monitored updates, where the latest features and fixes are required as soon as they are merged into the main branch.</span>
</label>
<label>
<input type="radio" name="update_source" value="gitea" <?php checked($current_source, 'gitea'); ?>>
<a href="https://gitea.wpallstars.com/wpallstars/wp-fix-plugin-does-not-exist-notices" target="_blank" rel="noopener noreferrer">Gitea</a>
<span class="fpden-source-description">Update directly from the Gitea repo main branch for the latest stable release. Git Updater plugin must be installed & active. Best for monitored updates, where the latest features and fixes are required as soon as they are merged into the main branch, and independence from big-tech.</span>
</label>
<div class="fpden-submit-container">
<button type="submit" class="button button-primary">Save</button>
</div>
</form>
</div>
<?php
}
/**
* Handle AJAX request to save update source
*/
public function save_update_source() {
// Check nonce
check_ajax_referer('fpden_update_source', 'nonce');
// Check permissions
if (!current_user_can('manage_options')) {
wp_send_json_error('Permission denied');
}
// Get and sanitize source
$source = isset($_POST['source']) ? sanitize_text_field($_POST['source']) : '';
// Validate source
$valid_sources = ['wordpress.org', 'github', 'gitea'];
if (!in_array($source, $valid_sources)) {
$source = ''; // Empty means use auto-detection
}
// Save option
update_option('fpden_update_source', $source);
// Clear update cache
delete_site_transient('update_plugins');
wp_send_json_success();
}
}

View File

@ -52,7 +52,7 @@ class Plugin {
/**
* Admin functionality instance
*
* @var Admin
* @var Admin\Admin
*/
private $admin;
@ -110,9 +110,9 @@ class Plugin {
}
// Load required files
require_once $this->plugin_dir . 'includes/Core.php';
require_once $this->plugin_dir . 'includes/Admin.php';
require_once $this->plugin_dir . 'includes/Modal.php';
require_once $this->plugin_dir . 'includes/core.php';
require_once $this->plugin_dir . 'admin/lib/admin.php';
require_once $this->plugin_dir . 'admin/lib/modal.php';
}
/**
@ -125,7 +125,7 @@ class Plugin {
$this->core = new Core();
// Initialize admin functionality
$this->admin = new Admin($this->core);
$this->admin = new Admin\Admin($this->core);
// Initialize Git Updater fixes
$this->init_git_updater_fixes();
@ -136,7 +136,7 @@ class Plugin {
}
// Initialize the modal for update source selection
new Modal();
new Admin\Modal();
}
/**