Forked from raewrites/excerpt-character-counter.php
Last active
August 29, 2015 14:17
-
-
Save juniovitorino/c4f11d92a28fcd6fefd2 to your computer and use it in GitHub Desktop.
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
function excerpt_count_js(){ | |
if ('page' != get_post_type()) { | |
echo '<script>jQuery(document).ready(function(){ | |
jQuery("#postexcerpt .handlediv").after("<div style=\"position:absolute;top:12px;right:34px;color:#666;\"><small>Excerpt length: </small><span id=\"excerpt_counter\"></span><span style=\"font-weight:bold; padding-left:7px;\">/ 500</span><small><span style=\"font-weight:bold; padding-left:7px;\">character(s).</span></small></div>"); | |
jQuery("span#excerpt_counter").text(jQuery("#excerpt").val().length); | |
jQuery("#excerpt").keyup( function() { | |
if(jQuery(this).val().length > 500){ | |
jQuery(this).val(jQuery(this).val().substr(0, 500)); | |
} | |
jQuery("span#excerpt_counter").text(jQuery("#excerpt").val().length); | |
}); | |
});</script>'; | |
} | |
} | |
add_action( 'admin_head-post.php', 'excerpt_count_js'); | |
add_action( 'admin_head-post-new.php', 'excerpt_count_js'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment