Closed Jebble closed 7 years ago
Can you post a screenshot of the error you get in the console.
Do you get any errors when you have disabled the yoast capabilities but the metabox isn't installed?
Yes, the same error shows up without Meta Box
Can you test with the 3.2 release to see if you get the same error?
Im having the same issue, the cloning feature for Metabox.io doesnt work with Yoast Activated and receive the same JS error... https://github.com/rilwis/meta-box/issues/854#issuecomment-218219935
@terw-dan I tested this issue https://github.com/Yoast/wordpress-seo/issues/4161#issuecomment-218220681 with the latest release of Yoast SEO and that issue is still there.
just letting you know... for me it i was disabling the yoast meta box on the post type i was using with meta-box. This is the issue for me. if i add back the the seo meta box the error goes away
function prefix_remove_meta_box() { remove_meta_box( 'wpseo_meta', 'gnl_clients', 'normal' ); } add_action( 'add_meta_boxes', 'prefix_remove_meta_box', 100000 );
@joeporterme that is indeed a work-around, but I'm not using the Yoast plugin to just disable it where I want to use it ;)
I was getting this error when I was removing the wpseo_meta box via the remove_meta_box function.
Once I switched to removing it via the GUI it resolved the issue. Very frustrating.
What's the status on this?
For me this filter caused the issue:
add_filter('wpseo_always_register_metaboxes_on_admin', '__return_true');
Experiencing the same issue. Any updates?
Same issue, with a admin account, it works, with an author account, the JS of metabox failed and makes other things bug like a co author plugin that use AJAX request I guess, and an option panel of a theme. So please fix this issue.
Hi, same problem here. Basically, the JS shouldn't be loaded if the SEO metabox is disabled. Thx
Hi @terw-dan! Any news of this ticket? Seems that we're several people to deal with this issue. Thanks
UP!
For now I'll just leave the Yoast metabox everywhere but it'd be really handy if this issue could be resolved.
Same problem here. It's an issue for every plugin that wants to create a custom post type but does not want to include the yoast metabox. The bug is still there in 4.4.
I am also removing my Yoast meta box for roles below Admin, and I solved the issue described in this thread by using the following code to deregister the offending scripts:
function remove_yoast_metabox() {
remove_meta_box( 'wpseo_meta', 'post', 'normal' );
}
function remove_yoast_metabox_dependencies() {
wp_deregister_script( 'yoast-seo-post-scraper' );
wp_deregister_script( 'yoast-seo-term-scraper' );
wp_deregister_script( 'yoast-seo-featured-image' );
}
if ( ! current_user_can( 'manage_options' ) ) {
add_action( 'add_meta_boxes', 'remove_yoast_metabox', 11 );
add_action( 'admin_enqueue_scripts', 'remove_yoast_metabox_dependencies', 11 );
}
Well temporarily I fixed the issue using following codes: Hope it might help you guys:
Its somewhat similar to @dancriel but with a little bit of custom post check validation :)
function remove_yoast_metabox_scripts() { wp_deregister_script('yoast-seo-post-scraper'); wp_deregister_script('yoast-seo-term-scraper'); wp_deregister_script('yoast-seo-featured-image'); }
function remove_yoast_metabox() { remove_meta_box('wpseo_meta', 'notification', 'normal');
if ('notification' == get_post_type()) {
add_action('admin_enqueue_scripts', 'remove_yoast_metabox_scripts', 11);
}
}
add_action('add_meta_boxes', 'remove_yoast_metabox', 11);
Thanks for the workaround @dancriel, while waiting for a fix.
In my case, removing the metabox for the CPT was causing the issues.
remove_meta_box( 'wpseo_meta', 'sala', 'normal' );
Once i re-enabled it, it started working as expected again. Actually, i'm trying to find an adaptable solution config, ty a lot for pointing the problem though.
version 5.2 - the bug is still there. workaround from @dancriel worked for me.
I am not sure if it is relevant, but I managed to solve the same bug on Woocomerce Tabs with Yoast 5.4.2. Besides removing the widget with @dancriel code, you could also remove the Yoast plugin from the dashboard under "Title and Metas" settings. That worked for me.
Yoast SEO 5.4+ has improved error handling for pages where the metabox is removed on. This should resolve any errors regarding "The snippet preview requires a valid target element".
Closing this issue in that regard, if another problem still exists regarding removing metaboxes, please create a new issue and mention this one.
Yoast SEO generates a JS console error when there is no element to put the snippet in. This happens when you're on a user account that has no access to the SEO tools in the capabilities settings.
Because of this all JS loaded after Yoast breaks.
What did you expect to happen?
I expected to upload images to a custom meta box on an account that has no Yoast capabilities
What happened instead?
I got a JS error "The snippet preview requires a valid target element" ignoring all JS after Yoast not showing the image field
How can we reproduce this behavior?
Can you provide a link to a page which shows this issue? No, it happens in admin
Technical info