eduinafbackupcode/eduinafoldcode/php/conta.php

46 lines
1.5 KiB
PHP

<?php
#contacaratteri
# Excerpt/Riassunto
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>Numero caratteri: </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;\">caratteri.</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');
# Content/Contenuto
function content_char_count() {
?>
<script type="text/javascript">
(function($) {
wpCharCount = function(txt) {
$('.char-count').html("" + txt.length);
};
$(document).ready(function() {
$('#wp-word-count').append('<br />Numero caratteri: <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', 'content_char_count');