Plugin Directory

Changeset 3433887


Ignore:
Timestamp:
01/06/2026 07:49:29 PM (6 weeks ago)
Author:
MrViSiOn
Message:

Fix: Preserve premium plugin/theme updates when refreshing cache v1.0.55

Location:
multi-connect/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • multi-connect/trunk/includes/class-multi-connect-api.php

    r3433883 r3433887  
    613613        require_once MULTICONNECT_PLUGIN_ABSPATH . 'wp-admin/includes/update.php';
    614614
     615        // Guardar actualizaciones de plugins/temas premium antes de limpiar cache.
     616        // Los plugins premium (WPCode Pro, etc.) inyectan sus actualizaciones via hooks
     617        // que pueden no ejecutarse correctamente en contexto REST API.
     618        $existing_plugins = get_site_transient( 'update_plugins' );
     619        $existing_themes  = get_site_transient( 'update_themes' );
     620
     621        // Identificar plugins premium (los que no están en wordpress.org).
     622        $premium_plugin_updates = array();
     623        if ( $existing_plugins && ! empty( $existing_plugins->response ) ) {
     624            foreach ( $existing_plugins->response as $plugin_file => $plugin_data ) {
     625                $plugin_data = (object) $plugin_data;
     626                // Los plugins de wordpress.org tienen id con formato "w.org/plugins/slug".
     627                $is_wporg = isset( $plugin_data->id ) && strpos( $plugin_data->id, 'w.org/plugins/' ) !== false;
     628                if ( ! $is_wporg ) {
     629                    $premium_plugin_updates[ $plugin_file ] = $plugin_data;
     630                }
     631            }
     632        }
     633
     634        // Identificar temas premium.
     635        $premium_theme_updates = array();
     636        if ( $existing_themes && ! empty( $existing_themes->response ) ) {
     637            foreach ( $existing_themes->response as $theme_slug => $theme_data ) {
     638                $theme_data = (array) $theme_data;
     639                // Los temas de wordpress.org tienen theme en el array.
     640                $is_wporg = isset( $theme_data['theme'] ) && ! empty( $theme_data['url'] ) && strpos( $theme_data['url'], 'wordpress.org' ) !== false;
     641                if ( ! $is_wporg ) {
     642                    $premium_theme_updates[ $theme_slug ] = $theme_data;
     643                }
     644            }
     645        }
     646
    615647        // Forzar la verificación de actualizaciones.
    616648        delete_site_transient( 'update_core' );
     
    619651        delete_site_transient( 'available_translations' );
    620652
    621         // Limpiar la caché de actualizaciones
     653        // Limpiar la caché de actualizaciones.
    622654        wp_clean_update_cache();
    623655
    624         // Forzar la verificación de actualizaciones con tiempo actual
     656        // Forzar la verificación de actualizaciones con tiempo actual.
    625657        wp_version_check( array(), true );
    626658        wp_update_plugins();
    627659        wp_update_themes();
     660
     661        // Restaurar actualizaciones de plugins premium al transient.
     662        if ( ! empty( $premium_plugin_updates ) ) {
     663            $plugins = get_site_transient( 'update_plugins' );
     664            if ( $plugins ) {
     665                foreach ( $premium_plugin_updates as $plugin_file => $plugin_data ) {
     666                    $plugins->response[ $plugin_file ] = $plugin_data;
     667                }
     668                set_site_transient( 'update_plugins', $plugins );
     669            }
     670        }
     671
     672        // Restaurar actualizaciones de temas premium al transient.
     673        if ( ! empty( $premium_theme_updates ) ) {
     674            $themes = get_site_transient( 'update_themes' );
     675            if ( $themes ) {
     676                foreach ( $premium_theme_updates as $theme_slug => $theme_data ) {
     677                    $themes->response[ $theme_slug ] = $theme_data;
     678                }
     679                set_site_transient( 'update_themes', $themes );
     680            }
     681        }
    628682
    629683        $updates = array(
     
    646700        // Verificar actualizaciones de plugins.
    647701        get_plugin_updates();
    648 
    649         // Obtener el transient actual y forzar que los plugins premium agreguen sus actualizaciones.
    650702        $plugins = get_site_transient( 'update_plugins' );
    651         if ( $plugins ) {
    652             // Aplicar el filtro con el transient real para que plugins premium puedan inyectar sus actualizaciones.
    653             try {
    654                 $plugins = apply_filters( 'pre_set_site_transient_update_plugins', $plugins, 'update_plugins' );
    655             } catch ( Throwable $e ) {
    656                 // Si hay error, continuar con el transient original.
    657             }
    658         }
    659703        if ( $plugins && ! empty( $plugins->response ) ) {
    660704            foreach ( $plugins->response as $plugin_file => $plugin_data ) {
     
    672716        // Verificar actualizaciones de temas.
    673717        get_theme_updates();
    674 
    675         // Obtener el transient actual y forzar que los temas premium agreguen sus actualizaciones.
    676718        $themes = get_site_transient( 'update_themes' );
    677         if ( $themes ) {
    678             // Aplicar el filtro con el transient real para que temas premium puedan inyectar sus actualizaciones.
    679             try {
    680                 $themes = apply_filters( 'pre_set_site_transient_update_themes', $themes, 'update_themes' );
    681             } catch ( Throwable $e ) {
    682                 // Si hay error, continuar con el transient original.
    683             }
    684         }
    685719        if ( $themes && ! empty( $themes->response ) ) {
    686720            foreach ( $themes->response as $theme_slug => $theme_data ) {
  • multi-connect/trunk/multi-connect.php

    r3433883 r3433887  
    44 * Plugin URI: https://multi-wp.com
    55 * Description: Connect your WordPress site with Multi-WP for centralized management and updates.
    6  * Version: 1.0.54
     6 * Version: 1.0.55
    77 * Requires at least: 5.8
    88 * Requires PHP: 7.4
  • multi-connect/trunk/readme.txt

    r3433883 r3433887  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.54
     7Stable tag: 1.0.55
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4444
    4545== Changelog ==
     46
     47= 1.0.55 =
     48* Fixed: Premium plugins and themes updates preserved when refreshing update cache (WPCode Pro, Elementor Pro, etc.)
    4649
    4750= 1.0.54 =
Note: See TracChangeset for help on using the changeset viewer.