Using WP 4.0. I thought that the html5 schema was supposed to be turned on by default. That would mean that clicking the B (Bold) button would generate a <b>
tag, rather than a <strong>
tag (which has a different semantic meaning). The same question goes for clicking the I button to get an <i>
tag instead of <em>
. How can I get the editor to do this?
3 Answers
Here’s what I came up with. So far it doesn’t seem to have broken anything:
add_filter('tiny_mce_before_init', 'modify_formats');
function modify_formats($settings){
$formats = array(
'bold' => array('inline' => 'b'),
'italic' => array('inline' => 'i')
);
$settings['formats'] = json_encode( $formats );
return $settings;
}
One could easily have used plus a class here, but given the changes in the spec under html5, and seem acceptable for most situations. (I don’t think that the case to transform these from presentational to structural tags is terribly persuasive, but probably not worth arguing about at this point). Anyone who wants and should probably add the necessary buttons and apply them in the appropriate places.