Sometimes when working with metaboxes, you don’t want a full WYSIWYG but do want some basic formatting, like <strong>
and line breaks.
Use the following filters to make *this* into <strong>this</strong>
and | into <br />
<?php
/**
* Strong Markdown
*
*/
function ea_strong_markdown( $text ) {
$strong_character = '*';
if( 2 == substr_count( $text, $strong_character ) ) {
$text = substr_replace( $text, '<strong>', strpos( $text, $strong_character ), strlen( $strong_character ) );
$text = substr_replace( $text, '</strong>', strrpos( $text, $strong_character ), strlen( $strong_character ) );
}
return $text;
}
/**
* Line Break Markdown
*
*/
function ea_br_markdown( $text ) {
$br_character = '|';
$text = str_replace( $br_character, '<br />', $text );
return $text;
}