Created
November 15, 2013 13:57
-
-
Save pepebe/7484664 to your computer and use it in GitHub Desktop.
Remove p around modx tags used inside a tinymce rte field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| plugin to remove p arround modx tags in tinymce | |
| author: breezer | |
| event: OnParseDocument | |
| */ | |
| $eventName = $modx->event->name; | |
| switch ($eventName) | |
| { | |
| //case 'OnParseDocument': | |
| case 'OnWebPagePrerender': | |
| //case 'OnLoadWebDocument': | |
| $replace = array( | |
| '<p>[[!' => '[[!' | |
| ,']]</p>' => ']]' | |
| ,'<p>[[*' => '[[*' | |
| ,']]</p>' => ']]' | |
| ,'<p>[[#' => '[[#' | |
| ,']]</p>' => ']]' | |
| ,'<p>[[$' => '[[$' | |
| ,']]</p>' => ']]' | |
| //,'<p>' => '<div>' | |
| //,'</p>' => '</div>' | |
| ,'<p><div' => '<div' | |
| ,'</div></p>' => '</div>' | |
| ); | |
| $content = $modx->resource->_output; // get a reference to the output | |
| $newContent = str_replace( | |
| array_keys($replace) | |
| ,array_values($replace) | |
| ,$content | |
| ); | |
| $modx->resource->_output = $newContent; | |
| break; | |
| default: | |
| break; | |
| } | |
| return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment