Plugin Directory

Changeset 3242780


Ignore:
Timestamp:
02/18/2025 04:50:46 PM (14 months ago)
Author:
mosparo
Message:

Fixed the initialization for the Divi Theme and Builder Plugin

Location:
mosparo-integration
Files:
7 edited
57 copied

Legend:

Unmodified
Added
Removed
  • mosparo-integration/tags/1.13.1/mosparo-integration.php

    r3241441 r3242780  
    1515 * Author URI:        https://mosparo.io/
    1616 * License:           MIT
    17  * Version:           1.13.0
     17 * Version:           1.13.1
    1818 * Text Domain:       mosparo-integration
    1919 * Domain Path:       /languages
     
    4343add_action('plugins_loaded', 'mosparoIntegrationInitialize', 1);
    4444
     45function mosparoIntegrationInitializeLate()
     46{
     47    // This second round is to initialize the modules that depend on a Theme instead of a plugin.
     48    $moduleHelper = ModuleHelper::getInstance();
     49    $moduleHelper->initializeActiveModules(plugin_dir_path(__FILE__), plugin_dir_url(__FILE__));
     50}
     51add_action('after_setup_theme', 'mosparoIntegrationInitializeLate', 1000);
     52
    4553function mosparoIntegrationInitializeTextDomain()
    4654{
  • mosparo-integration/tags/1.13.1/readme.txt

    r3241441 r3242780  
    55Tested up to: 6.7.2
    66Requires PHP: 7.4
    7 Stable tag: 1.13.0
     7Stable tag: 1.13.1
    88License: MIT
    99
     
    105105== Changelog ==
    106106
     107= 1.13.1 =
     108*Release Date: 17th February 2025*
     109
     110* [Bugfix] Fixed the initialization method for the Divi Theme. Before, the module was only compatible with the Divi Builder plugin.
     111
    107112= 1.13.0 =
    108113*Release Date: 16th February 2025*
  • mosparo-integration/tags/1.13.1/src/MosparoIntegration/Helper/ModuleHelper.php

    r3241441 r3242780  
    8585        foreach (self::getAvailableModules() as $moduleClass) {
    8686            $module = new $moduleClass();
     87
     88            // We ignore already initialized modules. This is important for the second scan after setup theme.
     89            if (isset($this->activeModules[$module->getKey()])) {
     90                continue;
     91            }
     92
    8793            if ($configHelper->isModuleActive($module->getKey())) {
    8894                $configHelper->loadModuleConfiguration($module);
     
    9096                if ($module->canInitialize()) {
    9197                    $module->initializeModule($pluginDirectoryPath, $pluginDirectoryUrl);
     98
     99                    $this->activeModules[$module->getKey()] = $module;
    92100                }
    93 
    94                 $this->activeModules[$module->getKey()] = $module;
    95101            }
    96102        }
  • mosparo-integration/tags/1.13.1/src/MosparoIntegration/Module/Divi/DiviModule.php

    r3241441 r3242780  
    2020    public function canInitialize()
    2121    {
    22         return class_exists('ET_Builder_Plugin');
     22        return defined('ET_CORE') && ET_CORE;
    2323    }
    2424
  • mosparo-integration/tags/1.13.1/src/MosparoIntegration/Module/Divi/MosparoSpamServiceProvider.php

    r3241441 r3242780  
    116116
    117117            wp_styles()->registered['divi-builder-dynamic-critical']->extra['after'][0] = $cssContent;
     118        } else if (isset(wp_styles()->registered['divi-dynamic-critical']->extra['after'][0])) {
     119            $cssContent = wp_styles()->registered['divi-dynamic-critical']->extra['after'][0];
     120
     121            $cssContent = str_replace('p.et_pb_contact_field{', 'p.et_pb_contact_field, div.et_pb_contact_field{', $cssContent);
     122            $cssContent = str_replace('.et_pb_contact_field *', '.et_pb_contact_field *:not([class*="mosparo"]):not([id*="mosparo"])', $cssContent);
     123
     124            wp_styles()->registered['divi-dynamic-critical']->extra['after'][0] = $cssContent;
    118125        }
    119126    }
  • mosparo-integration/trunk/mosparo-integration.php

    r3241441 r3242780  
    1515 * Author URI:        https://mosparo.io/
    1616 * License:           MIT
    17  * Version:           1.13.0
     17 * Version:           1.13.1
    1818 * Text Domain:       mosparo-integration
    1919 * Domain Path:       /languages
     
    4343add_action('plugins_loaded', 'mosparoIntegrationInitialize', 1);
    4444
     45function mosparoIntegrationInitializeLate()
     46{
     47    // This second round is to initialize the modules that depend on a Theme instead of a plugin.
     48    $moduleHelper = ModuleHelper::getInstance();
     49    $moduleHelper->initializeActiveModules(plugin_dir_path(__FILE__), plugin_dir_url(__FILE__));
     50}
     51add_action('after_setup_theme', 'mosparoIntegrationInitializeLate', 1000);
     52
    4553function mosparoIntegrationInitializeTextDomain()
    4654{
  • mosparo-integration/trunk/readme.txt

    r3241441 r3242780  
    55Tested up to: 6.7.2
    66Requires PHP: 7.4
    7 Stable tag: 1.13.0
     7Stable tag: 1.13.1
    88License: MIT
    99
     
    105105== Changelog ==
    106106
     107= 1.13.1 =
     108*Release Date: 17th February 2025*
     109
     110* [Bugfix] Fixed the initialization method for the Divi Theme. Before, the module was only compatible with the Divi Builder plugin.
     111
    107112= 1.13.0 =
    108113*Release Date: 16th February 2025*
  • mosparo-integration/trunk/src/MosparoIntegration/Helper/ModuleHelper.php

    r3241441 r3242780  
    8585        foreach (self::getAvailableModules() as $moduleClass) {
    8686            $module = new $moduleClass();
     87
     88            // We ignore already initialized modules. This is important for the second scan after setup theme.
     89            if (isset($this->activeModules[$module->getKey()])) {
     90                continue;
     91            }
     92
    8793            if ($configHelper->isModuleActive($module->getKey())) {
    8894                $configHelper->loadModuleConfiguration($module);
     
    9096                if ($module->canInitialize()) {
    9197                    $module->initializeModule($pluginDirectoryPath, $pluginDirectoryUrl);
     98
     99                    $this->activeModules[$module->getKey()] = $module;
    92100                }
    93 
    94                 $this->activeModules[$module->getKey()] = $module;
    95101            }
    96102        }
  • mosparo-integration/trunk/src/MosparoIntegration/Module/Divi/DiviModule.php

    r3241441 r3242780  
    2020    public function canInitialize()
    2121    {
    22         return class_exists('ET_Builder_Plugin');
     22        return defined('ET_CORE') && ET_CORE;
    2323    }
    2424
  • mosparo-integration/trunk/src/MosparoIntegration/Module/Divi/MosparoSpamServiceProvider.php

    r3241441 r3242780  
    116116
    117117            wp_styles()->registered['divi-builder-dynamic-critical']->extra['after'][0] = $cssContent;
     118        } else if (isset(wp_styles()->registered['divi-dynamic-critical']->extra['after'][0])) {
     119            $cssContent = wp_styles()->registered['divi-dynamic-critical']->extra['after'][0];
     120
     121            $cssContent = str_replace('p.et_pb_contact_field{', 'p.et_pb_contact_field, div.et_pb_contact_field{', $cssContent);
     122            $cssContent = str_replace('.et_pb_contact_field *', '.et_pb_contact_field *:not([class*="mosparo"]):not([id*="mosparo"])', $cssContent);
     123
     124            wp_styles()->registered['divi-dynamic-critical']->extra['after'][0] = $cssContent;
    118125        }
    119126    }
Note: See TracChangeset for help on using the changeset viewer.