• BlackStar

    (@blackstar1991)


    I tested my plugin by this plugin but get massage for ->

    ERROR WordPress.WP.EnqueuedResources.NonEnqueuedScriptScripts must be registered/enqueued via wp_enqueue_script()

    I added scripts like

    ....
    public function init(): void {

    add_filter( 'script_loader_tag', [ $this, 'add_module_type_attribute' ], 10, 3 );
    }

    public function add_module_type_attribute( $tag, $handle, $src ) {
    $module_handles = [
    'za-timeline-elementor',
    'za-timeline-gutenberg',
    ];
    if ( in_array( $handle, $module_handles, true ) ) {
    if ( false !== strpos( $tag, 'type="module"' ) ) {
    return $tag;
    }
    return '<script type="module" src="' . esc_url( $src ) . '"></script>';
    }
    return $tag;
    }
    ....

    But plugin thinking that it’s a problem…

    But when I use options like ->

    $elementor_adapter = $base_path . 'adapters/elementor-adapter.js';
    if ( file_exists( $elementor_adapter ) ) {
    $ver = $use_filemtime ? filemtime( $elementor_adapter ) : $ver_base;

    // set dependency: if preview helper is registered, include it; otherwise no dependency
    $deps = [];
    if ( wp_script_is( 'za-elementor-media-preview', 'registered' ) ) {
    $deps[] = 'za-elementor-media-preview';
    }

    wp_register_script(
    'za-timeline-elementor',
    $base_url . 'adapters/elementor-adapter.js',
    $deps,
    $ver,
    true
    );
    wp_script_add_data( 'za-timeline-elementor', 'type', 'module' );
    }

    wp_script_add_data( ”, ‘type’, ‘module’ ); It does not work correctly without this fallback. I have the same troubles ->https://stackoverflow.com/questions/58931144/enqueue-javascript-with-type-module

The topic ‘The plugin does not allow scripts that set the module as a post type. Why ?’ is closed to new replies.