Skip to content

Instantly share code, notes, and snippets.

@peterwilsoncc
Created March 14, 2015 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterwilsoncc/09308af2765897a8a5f7 to your computer and use it in GitHub Desktop.
Save peterwilsoncc/09308af2765897a8a5f7 to your computer and use it in GitHub Desktop.
Fixing the JS error in WP SEO.
diff --git a/content/plugins/wordpress-seo/js/wp-seo-metabox.js b/content/plugins/wordpress-seo/js/wp-seo-metabox.js
index ecbbf24..62a6a46 100644
--- a/content/plugins/wordpress-seo/js/wp-seo-metabox.js
+++ b/content/plugins/wordpress-seo/js/wp-seo-metabox.js
@@ -282,12 +282,12 @@ function yst_updateDesc() {
snippet.find('.desc span.content').html('');
yst_testFocusKw();
- if (tinyMCE.get('excerpt') !== null) {
+ if ( window.tinyMCE && tinyMCE.get('excerpt') !== null) {
desc = tinyMCE.get('excerpt').getContent();
desc = yst_clean(desc);
}
- if ( tinyMCE.get('content') !== null && desc.length === 0) {
+ if ( window.tinyMCE && tinyMCE.get('content') !== null && desc.length === 0) {
desc = tinyMCE.get('content').getContent();
desc = yst_clean(desc);
@@ -465,11 +465,11 @@ jQuery(document).ready(function () {
yst_updateSnippet();
// Adding events to content and excerpt
- if( tinyMCE.get( 'content' ) !== null ) {
+ if( window.tinyMCE && tinyMCE.get( 'content' ) !== null ) {
tinyMCE.get( 'content' ).on( 'blur', yst_updateDesc );
}
- if( tinyMCE.get( 'excerpt' ) !== null ) {
+ if( window.tinyMCE && tinyMCE.get( 'excerpt' ) !== null ) {
tinyMCE.get( 'excerpt' ).on( 'blur', yst_updateDesc );
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment