[wp-hackers] TinyMCE and centered aligning

Alex Günsche ag.ml2008 at zirona.com
Tue Apr 22 20:42:49 GMT 2008


On Tue, 2008-04-22 at 13:29 -0700, Andrew Ozz wrote:
> The easiest hack would be to add:
> 
> content = content.replace(/<p style="text-align: center;">/g, '<p 
> align="center">');
> 
> just above "// Pretty it up for the source editor" in wp-admin/js/editor.js.
> 
> If you need it to stick after upgrading WordPress, you'll need to make a 
> small plugin for TinyMCE to do that when saving.

Even better (IMHO) would be a server-side solution that filters the
output; this way, it will be correct in the database, and you can turn
it off:

<?php
add_filter('the_content', 'classic_align');

function classic_align($content)
{
	return str_replace(
		'<p style="text-align: center;">',
		'<p align="center">',
		$content
	);
}
?>

(Save as plugin or in theme's functions.php. You can also build in a
condition to make it only happen for the aggregator.)

HTH

Alex

-- 
Alex Günsche, Zirona OpenSource-Consulting
Blogs: http://www.zirona.com/ | http://www.regularimpressions.net
*** Want to test the shiny new release of InstantUpgrade? ***
http://www.zirona.com/blog/software/instantupgrade-10-beta/



More information about the wp-hackers mailing list