WordPress: abilitare l'editor TinyMCE sul riassunto dei post

Se vogliamo usare elementi HTML nel riassunto dei post di WordPress, possiamo abilitare l'editor TinyMCE sul campo del riassunto.

WordPress di Gabriele Romanato

L'editor di WordPress viene gestito dal plugin JavaScript TinyMCE. Possiamo estendere l'uso di questo plugin anche al campo del riassunto. Vediamo come fare.

Aggiungete il seguente codice al file functions.php:


<?php
function tinymce_excerpt_js(){ ?>
<script type="text/javascript">
        jQuery(document).ready( tinymce_excerpt );
            function tinymce_excerpt() {
                jQuery("#excerpt").addClass("mceEditor");
                tinyMCE.execCommand("mceAddControl", false, "excerpt");
            }
</script>
<?php }
add_action( 'admin_head-post.php', 'tinymce_excerpt_js');
add_action( 'admin_head-post-new.php', 'tinymce_excerpt_js');
function tinymce_css(){ ?>
<style type='text/css'>
            #postexcerpt .inside{margin:0;padding:0;background:#fff;}
            #postexcerpt .inside p{padding:0px 0px 5px 10px;}
            #postexcerpt #excerpteditorcontainer { border-style: solid; padding: 0; }
</style>
<?php }
add_action( 'admin_head-post.php', 'tinymce_css');
add_action( 'admin_head-post-new.php', 'tinymce_css');
?>

Commenti