Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WillBontrager

    (@willbontrager)

    The only way I’ve been able to duplicate the issue is with these two steps:

    1.
    Paste the PHP code into the post or page with the Text tab, not the Visual tab. This tells WordPress to save the code as is, not to convert special characters into HTML entities.

    2.
    Then, use the Visual tab to make an edit. When the visual tab is used, WordPress does convert special characters into HTML entities. And this includes the PHP code that was earlier pasted in with the Text tab.

    I’ve been wracking my brain trying to come up with a solution that prevents WordPress from converting special characters between the [insert_php]…[/insert_php] tags. It’s software, so there’s gotta be a way. I just need to figure it out.

    Will

    Thread Starter denisseattle

    (@denisseattle)

    Yes, when Visual opens by default, the brackets in php are altered before you can switch to Text. Your plugin allows some php syntax to be inserted, but not all.

    The Visual editor leaves html tags but changes other brackets. Maybe it could be amended to classify certain strings, ->, like html tags?

    Incorporate an option to force WP to open by default in Text, or certain pages as Text?

    Copy code when a page is opened for editing, and add a “fix” button to paste it back unaltered?

    Recommend an alternative visual editor that behaves better?

    Plugin Author WillBontrager

    (@willbontrager)

    Ah, thanks for those suggestions. It gave me an idea.

    I don’t have access to the Visual editor.

    Would you test something for me, please?

    Let’s try this:

    <insert_php
    echo (1<2) ? 'yes' : 'no';
    >

    And also this:

    <insert_php
    code="
    echo (1<2) ? 'yes' : 'no';
    ">

    It’s not code that will run, just a test of character conversion.

    If the Visual editor will leave either of those less-than angle brackets as a character instead of converting it into an HTML entity, then I have something I may be able to work with.

    Thank you!

    Will

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘embedded php code breaks’ is closed to new replies.