Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Created January 16, 2012 18:43
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexkingorg/1622265 to your computer and use it in GitHub Desktop.
Save alexkingorg/1622265 to your computer and use it in GitHub Desktop.
Character counter for WordPress editor
<?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