WordPress.org

Ready to get started?Download WordPress

Forums

Preserved HTML Editor Markup
[resolved] FAQ? Does this plugin actually disable wpautop? (20 posts)

  1. dandv
    Member
    Posted 1 year ago #

    The question is important because a number of other plugins are affected by wpautop and shortcodes combinations. Pods Framework is one, see https://github.com/pods-framework/pods/issues/271

    http://wordpress.org/extend/plugins/preserved-html-editor-markup/

  2. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @dandv - Yep, it's 100% disabled. There are actually two versions of wpautop, one in php and one in JavaScript. My plugin will disable both of them which is how I support switching between Visual and HTML tabs.

    And though my plugin offers the option to inject Paragraph tags, it does it in a much more intelligent way that shouldn't cause the issue reported in the github ticket you referenced.

    But I'm not bug proof so if there is a compatibility issue with the Pods framework let me know and I'll do what I can to fix it. I've added your question to the FAQ in version 1.3.

    Thanks!
    -Marcus

  3. Scott Kingsley Clark
    Member
    Posted 1 year ago #

    I'm also listening if you notice anything I need to be aware of in regards to the Pods Framework.

  4. dandv
    Member
    Posted 1 year ago #

    Well, even though the plugin is enabled, <p> tags are still inserted.

    I have the following code in the HTML editor of a page:

    <p>We plan to be located ... Map below:</p>

    <div id="mapdiv"></div>
    <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
    <script>
    map = new OpenLayers.Map("mapdiv");
    map.addLayer(new OpenLayers.Layer.OSM());

    //Set start centrepoint and zoom
    var lonLat = new OpenLayers.LonLat( -122.4000, 37.5050 )
    .transform(
    new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
    map.getProjectionObject() // to Spherical Mercator Projection
    );
    var zoom=10;
    map.setCenter (lonLat, zoom);

    </script>

    <p>One would hope the location above would work...

    ...but if you look at the page source, you'll see <p> tags inserted where linebreaks used to be in the <script> section.

    Maybe this is actually (currently) intended behavior, but it certainly breaks scripts.

    There are actually <p> and br tags where there were no linebreaks at all:

    <div id="mapdiv"></div>
    <p> <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
    <script>

    I just want the "HTML" tab in the page editor to be raw HTML. No "smart" paragraph or line break crap; those should be reserved for the Visual editor.

    How can I do this?

  5. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @dandv - That's interesting because your code works for me. I edited a new page, pasted your code in (I added a closing P tag where the elipsis were) updated and viewed the page source. Here is what I got:


    <article>
    <p>We plan to be located … Map below:</p>

    <div id="mapdiv"></div>
    <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
    <script>
    map = new OpenLayers.Map("mapdiv");
    map.addLayer(new OpenLayers.Layer.OSM());

    //Set start centrepoint and zoom
    var lonLat = new OpenLayers.LonLat( -122.4000, 37.5050 )
    .transform(
    new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
    map.getProjectionObject() // to Spherical Mercator Projection
    );
    var zoom=10;
    map.setCenter (lonLat, zoom);

    </script>

    <p>One would hope the location above would work</p>
    </article>

    No P tags, other than those that were specified. I tested this on a clean wordpress install v 3.4.1. Is there something in your theme or other plugins that could be injecting them?

    It did however expose a bug I have in the tab switch logic where the browser is injecting a CDATA block definition and my plugin is not correctly handling the transition back to HTML.

    I'll be honest and say that I didn't intend for this plugin to preserve script blocks, just html markup. But I'm pleased to see that it works in addition to allowing for inline scripts and styles.

    But I'm definitely interested in fixing whatever is causing your installation to break so if you don't mind answering the following I'd appreciate it:

    1. What version of WP?
    1. What other plugins are installed?
    1. What's the full html source you are trying to use? (you might need to email it to me if it's a lot, but invalid markup can cause a lot of problems.)

    You might also want to try using the code block I tested with to make sure it wasn't specific to code after the elipsis.

    Thanks!
    -Marcus

  6. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @dandv - Also, is the pods framework open source or available for me to trial? It's quite possible they implement their own wpautop hooks that I'm not capable of disabling via a plugin. A download link to that would be great if it's available.

  7. Scott Kingsley Clark
    Member
    Posted 1 year ago #

    We don't implement any wpautop hooks in any form as part of our core functionality. We don't use the_content filter either.

  8. Scott Kingsley Clark
    Member
    Posted 1 year ago #

    Sorry, forgot to mention - The Pods Framework is a freely available open source project: http://podsframework.org/

    It's on GitHub, and we have a new major version coming out too.

    1.x Stable: https://github.com/pods-framework/pods/tree/master

    2.0 Beta: https://github.com/pods-framework/pods/tree/2.0

  9. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    Ah, I see, so Scott, you develop the pods framework. Ok, well I'll setup the framework on a staging site and try out my plugin. I'll let you know what I find. Thanks for the links.

  10. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    The good news is that I can reproduce the problem with the PODS plugin activated. The bad news is I don't have time to fix it today. I'll see if I can work on it before the week is up, but that's rapidly closing in. I should definitely have some time on Labor day so hopefully you can hang on till then :D

    Thanks,
    Marcus

  11. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @Scott - So my ability to reproduce the problem was a result of a unicode character in the pasted output when I copied my code sample from above. The elipsis caused malformed html and the browser showed closing p tags. So, with proper html and Pods enabled, the system still worked for me.

    The only piece from PODS I didn't test was when an editor is embedded into a pod. Firstly, I don't know enough about pods on how to view that pod, or inject it, or really anything. However I can say that it loads its own editor when a Paragraph Text column is used. And it does setup a client-side wpautop and tweaks the editor to reformat the source markup.

    @dandv - So if the markup is being munged I would attribute it to the following issues:

    1. The markup itself isn't well formed. I'm assuming the wordpress support site truncated your code snippet or you did, but you do have an elipsis at the end of the code sample and no closing P tag. I recommend using the w3c validator to test the code sample.

    2. There is a different plugin causing a conflict with my plugin, which I'm also happy to investigate, if you don't mind testing each one, one at a time.

    3. You are trying to enter that code into an editor instantiated by Pods, yet because it's a different instance of the editor, I'm not able to correct the markup. If this was the case I recommend trying to paste that markup into a regular page or post, and see if it works for you.

    @Scott, if you can fill in some details on where that editor is accessible from I can try to confirm #3.

    I still need to fix the issue related to switching between editors causing a garbled output on switch back to html, but that's a lower priority since the code block does work if you don't switch. So I'll have an update sometime this weekend.

  12. Scott Kingsley Clark
    Member
    Posted 1 year ago #

    We use the wp_editor for TinyMCE instances:

    http://codex.wordpress.org/Function_Reference/wp_editor

    What can we do to support your JS hooks if we call wp_editor separately from the main editor?

    @dandv I thought you said this issue existed in your main content editor, were you saying that it was happening in a TinyMCE field that Pods created?

  13. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @Scott, are you sure about using the built in editor? It looks like the pods code overwrites the global $wp_editor with the WP_Pre_33_Editor class in pods\ui\wp-editor.php. If that's only loaded for the editor in Pods, and @dandv was having an issue in the main content editor, then there's nothing for you to do. I'll need more info from him, since I could use both together.

    Otherwise, I'm not quite sure what it would take to fix the custom editor in wp-editor.php. It should really just need the calls to wpautop removed. But I'm not even sure if my js logic is loaded with that custom editor and that would also be necessary, so my best suggestion would be to use the default editor. If there is something you need the default editor to do in that class, I might be able to help you there. But it looks like you were just trying to get the latest features before 3.3 was released maybe? The code comments and readme file seem to indicated so.

    Thanks!
    -Marcus

  14. Scott Kingsley Clark
    Member
    Posted 1 year ago #

    WP_Pre_33_Editor is only called for WP versions prior to 3.3, it's actually the standalone source directly from azaozz, the same person who merged that code into WP 3.3 -- If he's running WP 3.3+ then it's calling wp_editor directly.

    Will have to see what @dandv says to help us further figure this out.

  15. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    Hmm, I'm still not sure about that. I see checks for $wp_version around the plupload logic, but the inclusion of WP_Pre_33_Editor happens every time. I followed the call stack, and it seems that it is instantiated from the pods_ui_manage calls in manage_content.php. I'm not sure at what point in the callstack that code is executed (mostly because I only perused the source code,) but if it's after tiny_mce_before_init or admin_init then it would undo my fixes.

  16. Scott Kingsley Clark
    Member
    Posted 1 year ago #

    I double checked the code and WP_Pre_33_Editor is included, I'm going to push it inside of the wp_editor function check. It runs wp_editor if the function exists.

    As for the point that it runs, we currently call wp_editor() as needed, on the field it's used on itself. Is there anything you suggest to further support your hooks? We pretty much have the flexibility to do whatever you need, but based on how the forms are setup to run, we don't know what fields / forms will appear until the form is called, which is after admin_init.

  17. dandv
    Member
    Posted 1 year ago #

    Hi guys,

    I need to look into this in more detail when I have a bit more time, but for now I can say that,

    • the initial issue, with the missing opening p tag, happend in the Pods editor
    • the issue with extra p/br tags inserted in script tags happened in the WordPress page editor

    In the meantime I looked at the code for wpautop (its use of variables like $pee and $tinkle didn't impress me), and it appears that it tries to leave script tags alone. So there may be some interaction with another plugin. I don't have an obvious possible culprit right now, because of the 8 plugins that are active, none should mess with the post content much: AddThis Follow Widget, Broken Link Checker, Dynamic Widgets, Google XML Sitemap, MailChimp Widget, Pods CMS Framework, and WP Slim Stat + its Dashboard widgets.

    For now I've just nixed wpautop by having it just return $pee;. I never liked the idea of my input being second-guessed anyway.

  18. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @dandv - Definitely let me know what you find, but with my plugin installed and activated wpautop should not be running. As another recommendation I suggest that you also disable the visual tab or the javascript version of wpautop. Othwerise it will still corrupt your markup if you click on the visual tab.

    I'm sorry my plugin didn't work for you. It is quite strange considering your plugin installation. I'm assuming you're using the latest version of wordpress?

    And yeah, the $pee var names are a bit unprofessional, but the codebase is full of code that doesn't meet WP coding standards, well past the tipping point to bother.

    If you get a chance to email me the full code sample you were trying to use I'd definitely like to add it to my test cases.

    Thanks,
    Marcus

  19. MarcusPope
    Member
    Plugin Author

    Posted 1 year ago #

    @Scott - I see the problem with execution sequence, but I'm not 100% sure if that's a problem when wp_editor isn't updated with a new class. I'm not sure that it's fine either, so I'll just need to run some code and debug the callstack.

    If the demo video's for pods will get me to a point where I can setup a configuration described by @dandv then I'll watch that and get a test case going. If you think a step by step guide from you would be a faster route then something like that, even if just scratch notes, would be great.

    I'm going to add this to my personal support site as a todo and probably manage it there as new feature development. Due to my daughter's arrival date being in a couple weeks this might not be resolved as quickly as I would prefer.

    I'll do what I can to either open up those hooks or just change my patching execution sequence to be much later in the chain. The later would have a better impact on third party plugins where authors aren't necessarily willing or able to update their plugins.

    Thanks,
    Marcus

  20. Scott Kingsley Clark
    Member
    Posted 1 year ago #

    I'm available on gchat and skype if you need me, info is posted at http://scottkclark.com/

    Otherwise feel free to e-mail me and we'll go through it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic