Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* COUNT TITLE CHARACTER
- --------------------------------------------------*/
- function lvdny_title_count()
- {
- $screen = get_current_screen();
- if( $screen->post_type != "post")
- return;
- echo '<script>'
- . 'jQuery(document).ready(function()'
- . '{'
- . 'jQuery("#titlewrap").append("<div id=\"lvdny_alert_char_title\"></div>");'
- . 'jQuery("#title").keyup( function()'
- . '{'
- . 'lvdny_update_lenght_title();'
- . '});'
- . 'function lvdny_update_lenght_title() {'
- . 'var lvdny_char_count = jQuery("#title").val().length;'
- . 'jQuery("#lvdny_alert_char_title").text("Caratteri usati: " + lvdny_char_count + " – di 55");'
- . 'if( lvdny_char_count > 55 ) {'
- . 'if( !jQuery("#lvdny_alert_char_title").hasClass("lvdny_alert_char_max") ) {'
- . 'jQuery("#lvdny_alert_char_title").addClass("lvdny_alert_char_max");'
- . '}'
- . '} else {'
- . 'if( jQuery("#lvdny_alert_char_title").hasClass("lvdny_alert_char_max") ) {'
- . 'jQuery("#lvdny_alert_char_title").removeClass("lvdny_alert_char_max");'
- . '}'
- . '}'
- . '};'
- . 'lvdny_update_lenght_title();'
- . '});'
- . '</script>'
- . '<style>'
- . '#lvdny_alert_char_title{ padding-bottom:10px; text-align: right; }'
- . '</style>';
- }
- add_action( 'admin_footer-post.php', 'lvdny_title_count');
- add_action( 'admin_footer-post-new.php', 'lvdny_title_count');
- /* COUNT SUBTITLE CHARACTER
- --------------------------------------------------*/
- function lvdny_subtitle_count()
- {
- $screen = get_current_screen();
- if( $screen->post_type != "post")
- return;
- echo '<script>'
- . 'jQuery(document).ready(function()'
- . '{'
- . 'jQuery("#jnews_post_subtitle").append("<div id=\"lvdny_alert_char_subtitle\"></div>");'
- . 'jQuery("#jnews_post_subtitle>input").keyup( function()'
- . '{'
- . 'lvdny_update_lenght_subtitle();'
- . '});'
- . 'function lvdny_update_lenght_subtitle() {'
- . 'var lvdny_char_count = jQuery("#jnews_post_subtitle>input").val().length;'
- . 'jQuery("#lvdny_alert_char_subtitle").text("Caratteri usati: " + lvdny_char_count + " – di 80");'
- . 'if( lvdny_char_count > 80 ) {'
- . 'if( !jQuery("#lvdny_alert_char_subtitle").hasClass("lvdny_alert_char_max") ) {'
- . 'jQuery("#lvdny_alert_char_subtitle").addClass("lvdny_alert_char_max");'
- . '}'
- . '} else {'
- . 'if( jQuery("#lvdny_alert_char_subtitle").hasClass("lvdny_alert_char_max") ) {'
- . 'jQuery("#lvdny_alert_char_subtitle").removeClass("lvdny_alert_char_max");'
- . '}'
- . '}'
- . '};'
- . 'lvdny_update_lenght_subtitle();'
- . '});'
- . '</script>'
- . '<style>'
- . '.pxl_sottotitolo .acf-label{ position:relative }'
- . '#lvdny_alert_char_subtitle{ position:absolute; right: 0px; top:0px; }'
- . '</style>';
- }
- add_action( 'admin_footer-post.php', 'lvdny_subtitle_count');
- add_action( 'admin_footer-post-new.php', 'lvdny_subtitle_count');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement