Wordpress-seo: Conflict between Yoast SEO and VC Grid Builder

Created on 7 Dec 2016  路  12Comments  路  Source: Yoast/wordpress-seo

What did you expect to happen?

We don't expect javascript errors.

What happened instead?

When I open JS console, I see error:
_ReferenceError: wpseoPostScraperL10n is not defined_

How can we reproduce this behavior?

Install WP core
Install Visual Composer, Yoast SEO plugins

Can you provide a link to a page which shows this issue?
Go to WP dashboard, Visual Composer -> Grid Builder. Try to add new grid template

Technical info

  • WordPress version: 4.7
  • Theme Twenty Sixteen 1.3
  • Yoast SEO version: 3.9
  • Visual Composer version: 5.0.1
compatibility Visual Composer

Most helpful comment

function enqueueJs should be:

public function enqueueJs() {
        if ( wp_script_is( 'yoast-seo-post-scraper' ) ) {
                wp_enqueue_script( 'vc_vendor_yoast_js', vc_asset_url( 'js/vendors/yoast.js' ), array( 'yoast-seo-post-scraper' ), WPB_VC_VERSION, true );
        }
}

All 12 comments

@TukuTuru Can you confirm procedure? I just reproduced issue on my test server. It's possible source of issue https://wordpress.org/support/topic/grid-builder-visual-composer-conflict/

It seems that issue is related to Visual Composer

file: include/classes/vendors/plugins/class-vc-vendor-yoast_seo.php

/**
 * @since 4.4
 */
public function enqueueJs() {
        wp_enqueue_script( 'vc_vendor_yoast_js', vc_asset_url( 'js/vendors/yoast.js' ), array( 'yoast-seo-post-scraper' ), WPB_VC_VERSION, true );
}

This function loads post-scraper even if yoast doesn't show meta box.

function enqueueJs should be:

public function enqueueJs() {
        if ( wp_script_is( 'yoast-seo-post-scraper' ) ) {
                wp_enqueue_script( 'vc_vendor_yoast_js', vc_asset_url( 'js/vendors/yoast.js' ), array( 'yoast-seo-post-scraper' ), WPB_VC_VERSION, true );
        }
}

@stodorovic props I tested your suggested edit and all issues are gone automatically with it.
means, also using Types VC-Grid Editor is back on duty.

For me, this here can be closed as this is neither a types nor a YOAST issue

Thanks for your hard commitment here.

I will inform our Compatibility team about your work here, so either you or us we can inform WPBakery - or both, doesn't hurt at all :)

@terw-dan It's related to #5983 We confirmed that VC is loading yoast-seo-post-scraper when Yoast SEO metabox is hidden. Can you look in include/classes/vendors/plugins/class-vc-vendor-yoast_seo.php (Visual composer)?
I tried to fix it with previous snippet, but I'm not sure that works as should. I tested a bit and it works (posts, pages, grid builder). Anyway, we have to contact WPBakery.

@stodorovic
-I also tested the improved function and everything seems to be working great.

-Did anyone report this error to WPBakery?
(I do not have support, because I use Visual Composer with purchased theme)

-Thank you for your time

I'm afraid about order of wp_enqueue functions. It seems that Yoast enqueue scripts before VC and it's fine. If VC function enqueueJs is called before Yoast enqueue then VC doesn't load vc_vendor_yoast_js and it's new issue.
It's reason why asking everyone to test snippet editor on pages, posts,...

Anyway, it's VC issue. I tried to report indirectly (I'm maintaining couple websites where are installed themes with bundled VC)

Great troubleshooting effort @stodorovic - hopefully WPBakery can sort it out, and then we can close 5941 as well.

Please inform the customer of conversation # 173878 when this conversation has been closed.

We are going to solve the JavaScript error being a problem, but it is clear that this specific issue can and should be resolved in the VC plugin.

Closing this issue for that reason.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

szepeviktor picture szepeviktor  路  6Comments

danieltj27 picture danieltj27  路  6Comments

tholu picture tholu  路  3Comments

garretthyder picture garretthyder  路  5Comments

Pcosta88 picture Pcosta88  路  6Comments