Created
October 17, 2019 21:33
-
-
Save lgedeon/9b42731e8bccbaca1e49c7e93eb37159 to your computer and use it in GitHub Desktop.
Stop publish if too many/few words.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('submit', '#post', function() { | |
const coreWordCounter = new window.wp.utils.WordCounter(); | |
const $mtSeoTitle = $( '#mt_seo_title' ); | |
const mtWordCount = coreWordCounter.count( $mtSeoTitle.val() ); | |
if ( 18 < mtWordCount ) { | |
alert( 'SEO Error: The title in your SEO Pack cannot exceed 18 words when included in Google News. Please try again.' ); | |
$( this ).find( 'input[type="submit"]' ).removeClass( 'disabled' ) | |
.end().find( '.spinner' ).hide(); | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment