file separato per i contacaratteri

This commit is contained in:
ulaulaman 2018-02-11 17:44:41 +01:00 committed by GitHub
parent b8b7a5724a
commit f7eb1fe320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 45 additions and 0 deletions

45
incl/conta.php Normal file
View File

@ -0,0 +1,45 @@
<?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');