Plugin Directory

Changeset 3395401


Ignore:
Timestamp:
11/13/2025 11:28:11 PM (5 months ago)
Author:
TCattd
Message:

1.7.2

Location:
fuerte-wp/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • fuerte-wp/trunk/README.txt

    r3395378 r3395401  
    22Contributors: tcattd
    33Tags: security, login, protection, admin, brute-force, GDPR, privacy, access-control, multisite
    4 Stable tag: 1.7.1
     4Stable tag: 1.7.2
    55Requires at least: 6.0
    66Tested up to: 6.9
  • fuerte-wp/trunk/fuerte-wp.php

    r3395378 r3395401  
    66 * Plugin URI:        https://github.com/EstebanForge/Fuerte-WP
    77 * Description:       Stronger WP. Limit access to critical WordPress areas, even other for admins.
    8  * Version:           1.7.1
     8 * Version:           1.7.2
    99 * Author:            Esteban Cuevas
    1010 * Author URI:        https://actitud.xyz
     
    3333 */
    3434define("FUERTEWP_PLUGIN_BASE", plugin_basename(__FILE__));
    35 define("FUERTEWP_VERSION", "1.7.0");
     35define("FUERTEWP_VERSION", "1.7.2");
    3636define("FUERTEWP_PATH", realpath(plugin_dir_path(__FILE__)) . "/");
    3737define("FUERTEWP_URL", trailingslashit(plugin_dir_url(__FILE__)));
     
    215215
    216216/**
     217 * Hook into plugin updates to clear configuration cache.
     218 * This ensures that the super users and other configuration are properly
     219 * refreshed when the plugin is updated.
     220 *
     221 * @since 1.7.1
     222 */
     223add_action('upgrader_process_complete', 'fuertewp_handle_plugin_update', 10, 2);
     224
     225function fuertewp_handle_plugin_update($upgrader_object, $options) {
     226    // Check if this is a plugin update and if it's our plugin
     227    if ($options['action'] === 'update' && $options['type'] === 'plugin') {
     228        if (isset($options['plugins'])) {
     229            foreach ($options['plugins'] as $plugin) {
     230                if ($plugin === plugin_basename(FUERTEWP_PLUGIN_BASE)) {
     231                    // This is our plugin being updated - clear the cache
     232                    require_once FUERTEWP_PATH . 'includes/class-fuerte-wp-activator.php';
     233                    Fuerte_Wp_Activator::handle_plugin_update();
     234                    break;
     235                }
     236            }
     237        }
     238    }
     239}
     240
     241/**
    217242 * htaccess security rules
    218243 */
  • fuerte-wp/trunk/includes/class-fuerte-wp-activator.php

    r3395378 r3395401  
    4141    public static function activate()
    4242    {
     43        // Check if this is a plugin update and clear cache if version changed
     44        self::handle_plugin_update();
     45
    4346        self::create_login_security_tables();
    4447        self::schedule_cron_jobs();
    4548        self::setup_initial_super_user();
    46         delete_transient('fuertewp_cache_config');
    4749    }
    4850
     
    157159        }
    158160    }
     161
     162    /**
     163     * Handle plugin updates and clear configuration cache when needed.
     164     *
     165     * @since 1.7.1
     166     */
     167    public static function handle_plugin_update()
     168    {
     169        $option_name = 'fuertewp_version';
     170        $current_version = defined('FUERTEWP_VERSION') ? FUERTEWP_VERSION : '1.0.0';
     171        $previous_version = get_option($option_name, '1.0.0');
     172
     173        // If version has changed, clear all relevant caches
     174        if ($previous_version !== $current_version) {
     175            // Clear the configuration cache
     176            delete_transient('fuertewp_cache_config');
     177
     178            // Clear the new simple config cache if class exists
     179            if (class_exists('Fuerte_Wp_Config')) {
     180                Fuerte_Wp_Config::invalidate_cache();
     181            }
     182
     183            // Clear any other plugin-related transients
     184            delete_transient('fuertewp_login_attempts_cache');
     185            delete_transient('fuertewp_ip_whitelist_cache');
     186
     187            // Update the stored version
     188            update_option($option_name, $current_version);
     189
     190            // Log the version update for debugging
     191            if (function_exists('Fuerte_Wp_Logger') && class_exists('Fuerte_Wp_Logger')) {
     192                $logger = new Fuerte_Wp_Logger();
     193                $logger->log("Plugin updated from {$previous_version} to {$current_version} - caches cleared");
     194            }
     195        }
     196    }
    159197}
  • fuerte-wp/trunk/includes/class-fuerte-wp-enforcer.php

    r3395378 r3395401  
    9292
    9393            if (!empty($file_config['super_users'])) {
    94                 // Import super users from file to database
    95                 $first_super_user = reset($file_config['super_users']);
    96                 carbon_set_theme_option('fuertewp_super_users', $first_super_user);
    97                 Fuerte_Wp_Logger::info('Super users imported from file: ' . $first_super_user);
     94                // Import super users from file to database as array to match multiselect field
     95                carbon_set_theme_option('fuertewp_super_users', $file_config['super_users']);
     96                Fuerte_Wp_Logger::info('Super users imported from file: ' . implode(', ', $file_config['super_users']));
    9897                return;
    9998            }
     
    103102        $current_user = wp_get_current_user();
    104103        if ($current_user && $current_user->ID > 0 && current_user_can('manage_options')) {
    105             // Store as string for backward compatibility
    106             carbon_set_theme_option('fuertewp_super_users', $current_user->user_email);
     104            // Store as array to match the multiselect field type
     105            carbon_set_theme_option('fuertewp_super_users', [$current_user->user_email]);
    107106
    108107            // Also set plugin status if not already set using Carbon Fields
     
    557556        if (function_exists('carbon_get_theme_option')) {
    558557            $options['fuertewp_status'] = carbon_get_theme_option('fuertewp_status');
    559             $options['super_users'] = carbon_get_theme_option('fuertewp_super_users');
     558            // Get super users from Carbon Fields (where self-healing stores them)
     559            $super_users = carbon_get_theme_option('fuertewp_super_users');
     560
     561            // Normalize to array format for consistency
     562            if (is_string($super_users) && !empty($super_users)) {
     563                $options['super_users'] = [$super_users];
     564            } elseif (is_array($super_users)) {
     565                $options['super_users'] = $super_users;
     566            } else {
     567                $options['super_users'] = [];
     568            }
    560569            $options['fuertewp_access_denied_message'] = carbon_get_theme_option('fuertewp_access_denied_message');
    561570            $options['fuertewp_recovery_email'] = carbon_get_theme_option('fuertewp_recovery_email');
Note: See TracChangeset for help on using the changeset viewer.