Created
January 16, 2012 18:43
-
-
Save alexkingorg/1622265 to your computer and use it in GitHub Desktop.
Character counter for WordPress editor
This file contains 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
<?php | |
// handy if you write status posts and send them to Twitter | |
function akv3_editor_char_count() { | |
?> | |
<script type="text/javascript"> | |
(function($) { | |
wpCharCount = function(txt) { | |
$('.char-count').html("" + txt.length); | |
}; | |
$(document).ready(function() { | |
$('#wp-word-count').append('<br />Char count: <span class="char-count">0</span>'); | |
}).bind( 'wpcountwords', function(e, txt) { | |
wpCharCount(txt); | |
}); | |
$('#content').bind('keyup', function() { | |
wpCharCount($('#content').val()); | |
}); | |
}(jQuery)); | |
</script> | |
<?php | |
} | |
add_action('dbx_post_sidebar', 'akv3_editor_char_count'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment