(Go: >> BACK << -|- >> HOME <<)

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing script dependency wpcf7-admin-taggenerator in block editor #4

Open
lukasbesch opened this issue Jan 20, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@lukasbesch
Copy link
lukasbesch commented Jan 20, 2023

cf7-blocks-integrate is missing the dependency wpcf7-admin-taggenerator which leads to the following error in the console (both in regular and isolated block editor):

Uncaught TypeError: Cannot set properties of undefined (setting 'insert')
    at cf7-blocks-integrate.js?ver=080408f486f493f8b1e7:1:513
(anonymous) @ cf7-blocks-integrate.js?ver=080408f486f493f8b1e7:1
load (async)
(anonymous) @ cf7-blocks-integrate.js?ver=080408f486f493f8b1e7:1

WordPress: 6.1.1
Contact Form 7: 5.7.2
CF7 Blocks: 1.0.1
PHP: 8.0

Temporary fixed with this snippet:

add_action('init', function () {
    wp_append_dependencies_to_script('cf7-blocks-integrate', [ 'wpcf7-admin-taggenerator' ]);
}, 11);

/**
 * Add $deps (script handles) to the array of dependencies for $handle
 * @see http://wordpress.stackexchange.com/questions/100709/add-a-script-as-a-dependency-to-a-registered-script
 *
 * @param string $handle Script handle for which you want to add a dependency
 * @param string $deps    Script handle - the dependencies you wish to add
 */
function wp_append_dependencies_to_script( $handle, $deps ) {
    global $wp_scripts;

    $script = $wp_scripts->query( $handle, 'registered' );
    if ( ! $script ) {
        return false;
    }

    foreach ( (array) $deps as $dep ) {
        if ( ! in_array( $dep, $script->deps, true ) ) {
            $script->deps[] = $dep;
        }
    }

    return true;
}

Awesome plugin by the way, is there any chance to edit the forms directly in the regular block editor in the future?

@ZafarKamal123 ZafarKamal123 added the bug Something isn't working label Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants