Plugin Directory

Changeset 590703

08/27/12 00:39:16 (5 years ago)

updated js include to use cachebuster. added support for inline js and css. updated docs with kudos to ppl who supported the latest fixes. added some questions to the faq

3 edited


  • preserved-html-editor-markup/trunk/admin.js

    r586992 r590703  
    203203        return false; 
    204204    }; 
     206    function fix_intra_tag_content(needle, haystack, placeholder, correct) { 
     207        //This will encode intra tag & intra quote content to prevent TinyMCE escaping 
     208        var repeat = true; 
     210        //look for needle (improperly encoded strings) in haystack (content inside valid html tags) 
     211        var regescape = new RegExp("(<[^>]*)(" + needle + ")([^>]*>)", "g"); 
     212        while (repeat) { 
     213            //replace with a placeholder value because replacing with the correct value would prevent downstream replacements 
     214            newstack = haystack.replace(regescape, "$1" + placeholder + "$3"); 
     215            //repeat process until transformations stop 
     216            if (newstack == haystack) repeat = false; 
     217            haystack = newstack; 
     218        } 
     220        //finally replace placeholder values with correct value (proper, unencoded strings); 
     221        if (correct) { 
     222            var regfix = new RegExp(placeholder, "g"); 
     223            return haystack.replace(regfix, correct); 
     224        } 
     225        else { 
     226            //<, > will need to be replaced after all other replacements 
     227            return haystack; 
     228        } 
     229    } 
    206231    //on dom load 
    227252            //Now we replace all those temporary html comments with spaces and newlines 
    228253            o.data = o.unfiltered.replace(/<\!--mep-nl-->/g, "\r\n").replace(/<\!--mep-tab-->/g, "    "); 
     255            //Fix broken >, <, &, etc symbols when they exist inside quote marks inside tag elements 
     256            o.data = fix_intra_tag_content("&amp;", o.data, "{-mep-amp}", "&"); 
     257            o.data = fix_intra_tag_content("&gt;", o.data, "{-mep-gts}"); 
     258            o.data = fix_intra_tag_content("&lt;", o.data, "{-mep-lts}"); 
     259            o.data = fix_intra_tag_content("&#8221;", o.data, "{-mep-dbl-quote}", '"');  
     260            o.data = fix_intra_tag_content("&#8243;", o.data, "{-mep-dbl-quote}", '"');  
     261            o.data = o.data.replace(/{-mep-gts}/g, '>'); 
     262            o.data = o.data.replace(/{-mep-lts}/g, '<'); 
    230264            //And finally remove the code tag hack from the markup 
    281315            //finally: restore the whitespace back in pre & code tags 
    282316            o.data = o.data.replace(/<mep-preserve-nl>/g, "\n").replace(/<mep-preserve-tab>/g, "\t").replace(/<mep-preserve-space>/g, " "); 
     318            //BUGFIX: add space between quotes and closing tags 
     319            o.data = o.data.replace(/"\/>/g, '" />'); 
    283320        }); 
    284321    }); 
  • preserved-html-editor-markup/trunk/readme.txt

    r586992 r590703  
    1515It also supports HTML5 Block Anchor tags, something that is currently not supported in WP even via any existing plugins. 
    17 With version 1.2, you now have a little more control over how content is created.  And most of the previous caveats to using this plugin are now resolved. 
     17With version 1.3 you can now use inline CSS and JavaScript in the HTML editor and everything should be preserved.  To be clear, this applies to tags only, like `onclick` events and style definitions - not script blocks themselves.  To enable this feature you must disable the `wptexturize` and `convert_chars` filters by adding the following code to your theme's `functions.php`: 
     19    remove_filter("the_content", "wptexturize"); 
     20    remove_filter("the_content", "convert_chars"); 
     22This new feature is pretty experimental at the moment.  I tried to make it compatible with wptexturize but that proved close to impossible without duplicating a lot of core code in my plugin.  It's also not compatible with TinyMCE Advanced when the "stop removing p and br tags" setting is enabled. 
     23I've tested it on a variety of code samples and I'm pleased with the results but if you find any content that isn't preserved just open a support ticket and I should be able to fix it. 
     25Since version 1.2, you now have a little more control over how content is created.  And most of the previous caveats to using this plugin are now resolved. 
    1927  1. You can now choose whether to use BR tags OR P tags for newlines.  Even better you can use both, where one return key press injects a BR tag, and two return key presses will wrap a Paragraph tag.  This is great for being able to wrap headers at specific break points all while enjoying the semantic perks of paragraphs. 
    5462This is a tough one.  Not only do I have no idea why they're being trumped, but I also have a daughter that will be born pretty soon :D, and a project at work that is about to get hectic :(  I'll try to fix it when I can but if you have the skills to help debug the help would be greatly appreciated. 
     64= Does this plugin actually disable wpautop? = 
     66Yes.  And unlike virtually every other "disable wpautop" plugin this one will actually disable the client-side version of wpautop that runs when you switch between the Visual and HTML tabs. Even when using the P Tag mode or hybrid mode, wpautop is disabled and custom code is being used to inject paragraphs a little more intelligently. 
    5668= What exactly do the "Fix Posts" or "Fix XXX" buttons do to my content? = 
    7486== Changelog == 
     87= 1.3 = 
     88* Added support for inline JavaScript and CSS, as long as the wptexturize and convert_chars filters are disabled. (Thanks to ViennaMex for pointed out the problem.) 
     89* Added cache-buster for this plugin's JavaScript includes to prevent upgrade issues seen in version 1.2 (Thanks to dreamdancerdesign, peterdub & abbyj for troubleshooting support.) 
     90* Special thanks to dreamdancerdesign for providing a live testing server - above and beyond. 
    7691= 1.2 = 
    7792* Added support for user-specified newline behavior per post type 
  • preserved-html-editor-markup/trunk/sb_preserved_markup.php

    r586992 r590703  
    88Author: Marcus E. Pope, marcuspope 
    99Author URI: http://www.marcuspope.com 
    10 Version: 1.2 
     10Version: 1.3 
    1212Copyright 2011 Marcus E. Pope (email : me@marcuspope.com) 
    5656        //replace all closing html tags with temp placeholders so texturize doesn't turn them into endash's 
    5757        $s = preg_replace("/-->/m", "-mep-temp-closing-comment-tag->", $s); 
    5959        //now let wptexturize do its work 
     60        //NOTICE: this function is highly volatile - it will alter intra-tag strings which is a terrible approach 
    6061        $s = wptexturize($s); 
    190191            //finish up with functions that WP normally calls on the_editor_content 
    191             $c = convert_chars($c); 
     192            if (has_filter('the_content', 'convert_chars')) { 
     193                $c = convert_chars($c); 
     194            } 
    192195            $c = htmlspecialchars($c, ENT_NOQUOTES); 
    193196            $c = apply_filters('richedit_pre', $c); 
    299302        /* fix WP html editor on client side */ 
    300         //TODO: this does not work with symlinks (https://bugs.php.net/bug.php?id=46260). 
     303        //TODO: __FILE__ does not work with symlinks (https://bugs.php.net/bug.php?id=46260). 
    301304        //      Create a filter for overriding so I don't have to copy this plugin from 
    302         //      the svn repo to my own hg/git repos  
    303         wp_enqueue_script('emc2-pm-admin-js', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__))."admin.js"); 
     305        //      the svn repo to my own hg/git repos 
     306        $plugin_data = get_plugin_data(__FILE__); 
     307        $cachebuster = $plugin_data['Version']; 
     309        wp_enqueue_script('emc2-pm-admin-js', WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__))."admin.js?v=".$cachebuster); 
    304310        //wp_enqueue_script('emc2-pm-admin-js', WP_PLUGIN_URL.'/sb_preserved_markup/admin.js'); 
Note: See TracChangeset for help on using the changeset viewer.