Created
April 12, 2014 22:03
-
-
Save ovizii/10559062 to your computer and use it in GitHub Desktop.
Character count for content/excerpt
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
/* letter counter */ | |
add_action( 'admin_head-post.php', 'letter_count_js')); | |
add_action( 'admin_head-post-new.php', 'letter_count_js' )); | |
public function letter_count_js(){ echo '<script>jQuery(document).ready(function(){ jQuery("#postexcerpt .handlediv").after("<input type=\'text\' value=\'0\' maxlength=\'3\' size=\'3\' id=\'excerpt_counter\' readonly=\'\' style=\'background:#fff; position:absolute;top:0.2em;right:2em; color:#666;\'>"); jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); jQuery("#excerpt").keyup( function() {jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); }); jQuery("#wp-word-count").after("<td id=\'wp-character-count\'>Character count: <span class=\'character-count\'>0</span></td>"); jQuery("#wp-character-count .character-count").html(jQuery("#wp-content-wrap .wp-editor-area").val().length); jQuery("#wp-content-wrap .wp-editor-area").keyup( function() {jQuery("#wp-character-count .character-count").html(jQuery("#wp-content-wrap .wp-editor-area").val().length); }); });</script>'; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment