• Problem.

    When running WP-CLI commands with the gutenverse-form plugin enabled, two fatal errors occurred:

    1. Error 1Class "Gutenverse\Framework\Style_Generator" not found
    2. Error 2Undefined constant "Gutenverse\Framework\GUTENVERSE_FRAMEWORK_URL_PATH"

    Root Cause

    The gutenverse-form plugin bundles its own copy of the Gutenverse Framework but was not properly initializing it before trying to use framework classes. The plugin’s main loader only registered the autoloader for Gutenverse_Form\ namespaced classes, leaving the Gutenverse\Framework\ classes inaccessible.

    Solution

    File 1: autoload.php

    Added framework bootstrap initialization at the beginning of the autoloader:

    <?php
    // Load framework bootstrap to ensure framework classes are available
    require_once dirname( FILE ) . '/framework/bootstrap.php';

    File 2: bootstrap.php

    Added the missing GUTENVERSE_FRAMEWORK_URL_PATH constant definition to the constants section:

    <?php
    defined( 'GUTENVERSE_FRAMEWORK_URL_PATH' ) || define( 'GUTENVERSE_FRAMEWORK_URL_PATH', plugins_url( 'gutenverse-form' ) . '/lib/framework' );

    This constant was being used throughout the framework’s Asset class (and other classes) to build paths to CSS, JavaScript, and image assets.

    Why This Works

    1. By requiring the framework’s bootstrap file early, we ensure the framework’s autoloader is registered before any code tries to instantiate framework classes
    2. By defining GUTENVERSE_FRAMEWORK_URL_PATH, all framework classes that reference this constant will have a valid value, allowing assets to be properly located and loaded

    These changes ensure the framework is fully initialized and all necessary constants are available before the gutenverse-form plugin’s initialization classes try to use them.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support putra1arya

    (@putra1arya)

    Hi,
    Thank you for providing the solution.

    We’ll review it and proceed with implementing it in our plugin. If we have any questions during the process, we’ll let you know.

    Hi,

    Thank you very much for your response and for sharing the solution. We truly appreciate it.

    To proceed with the implementation and ensure we apply the most appropriate solution, we may need to replicate the issue on our end. This will help us gain a clearer and more comprehensive understanding of the situation.

    To assist us further, could you please share the following details?

    • The list of plugins that are currently active
    • The WordPress version you are using
    • The PHP version you are using
    • An example of the WP-CLI command you are attempting to run

    Thank you for your cooperation. We look forward to your response so we can assist you further.

    Thread Starter dimsal

    (@dimsal)

    List plugins:

    +----------------------------------------------+----------+--------+----------+----------------+-------------+
    | name | status | update | version | update_version | auto_update |
    +----------------------------------------------+----------+--------+----------+----------------+-------------+
    | accessibility-onetap | inactive | none | 2.8.0 | | off |
    | admin-site-enhancements | active | none | 8.2.2 | | off |
    | compressx | active | none | 0.9.33 | | off |
    | depicter | inactive | none | 4.7.0 | | off |
    | duplicate-menu | active | none | 0.2.3 | | off |
    | envato-market | active | none | 2.0.12 | | off |
    | greenshift-animation-and-page-builder-blocks | active | none | 12.5.7 | | off |
    | gutenverse | active | none | 3.4.3 | | off |
    | gutenverse-companion | active | none | 2.0.2 | | off |
    | gutenverse-form | active | none | 2.4.3 | | off |
    | gutenverse-news | active | none | 3.1.0 | | off |
    | capability-manager-enhanced | active | none | 2.23.0 | | off |
    | seo-by-rank-math | active | none | 1.0.261 | | off |
    | simple-cloudflare-turnstile | active | none | 1.36.1 | | off |
    | revslider | inactive | none | 6.7.40 | | off |
    | smart-slider-3 | inactive | none | 3.5.1.31 | | off |
    | splide-carousel | active | none | 1.7.0 | | off |
    | suremails | active | none | 1.9.1 | | off |
    | svg-support | active | none | 2.5.14 | | off |
    | user-role-editor | inactive | none | 4.64.6 | | off |
    | view-transitions | active | none | 1.1.2 | | off |
    +----------------------------------------------+----------+--------+----------+----------------+-------------+

    WordPress version 6.9

    PHP version 8.2

    WP-CLI command example: wp plugin list –allow-root

    tresnasaputra

    (@tresnasaputra)

    Thank you very much for your response and for providing the details. We’re sorry that we haven’t been able to reproduce the issue on our side.

    However, we have implemented a special fix for cases when the plugin is loaded via the CLI, which should ensure that the framework loads correctly in all situations. This fix will be included in the upcoming update.

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.