Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator t-p

    (@t-p)

    Have you tried code in the “text” tab, instead of “visual” tab?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Please don’t post in the Alpha/Beta forum unless you’re actually testing the alpha/beta version of WordPress (not a plugin or a theme). Also, once WordPress has released a version, it’s not appropriate to post in alpha/beta and you should post in the How To & Troublshooting forum:

    https://www.ads-software.com/support/forum/how-to-and-troubleshooting

    This post has been moved out for you.

    And sadly this is not just you ?? I find the same issue because the widget now uses TinyMCE to save things.

    https://core.trac.www.ads-software.com/ticket/40951 – It’s been problematic for many people. I’m using a classic text widget to get ‘around’ it.

    Thread Starter RockyMtnHi

    (@rockymtnhi)

    Thanks for moving it @ipstenu, and @t-p yes, I am using the text tab.

    After all these years I am really stunned that WordPress doesn’t support php coding out of the box. Joomla and Drupal accommodate it, but not WordPress. To use php code in widgets I had to use a plugin or code a hack in the functions.php. At one point the plugin that I used for the widgets failed and was no longer supported, so I am now using the functions.php option.

    The same problem exists in the main body content. I have to use a plugin to execute php code within the main content.

    It would be ideal if the WordPress developers would just allow us to execute php code in the main content and widgets by using the normal php delineators:
    <?php code here; ?>

    I hate to think what would happen if the plugin I’m currently using to execute code in the main content area (Inline PHP) falls to the wayside. It hasn’t been updated for many years and I rely on it heavily. I would normally not use a plugin that old, but I have been using it for years and it is still working.

    The problem now is that if you so much as view the code in the main content area, and now the text widget, in the Visual tab then it changes the code and you have to go back to the text tab and change it. Then, after you save it in the text tab, the code that you see is the wrong code, even though it has saved the correct code. If you just save again it is broken.

    I don’t understand the logic of changing any code, period, by changing from Text to Visual tabs. It just doesn’t make sense to me. I consider it a bug that hasn’t been fixed, and it has been that way forever with WordPress. As much as I love WordPress (I’m writing a book WordPress Websites for Business), this is a frustrating scenario, and it just got worse with the new text widget.

    That’s why I posted originally in the other forum. I want to flag this as a bug.

    Hope it is fixed sometime soon. Till then, my employees are pulling their hair out because they aren’t developers, so I have to go in and fix these issues myself.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Posting in alpha/beta means it’s a bug in the NEW alpha/beta, though. And we already have tickets about how the new Text Widget eats HTML so even if it was a bug in the alpha/beta version, we’d close your ticket because it’s a known one.

    I know, it’s semantics ??

    Anyway.

    You’re right, WordPress doesn’t support (nor does it like) people using PHP code in widgets. And there’s a reason: Most people don’t know what they’re doing and will paste in dangerous code.

    I don’t understand the logic of changing any code, period, by changing from Text to Visual tabs.

    The reason is that we’re using TinyMCE, and just like when you’re switching between text and visual tabs in the post editor, doing so tells TinyMCE “Process these so you can display them.” And it’s in that moment that code gets changed, because TinyMCE thinks it knows better.

    Is that right? No! But that’s been the ‘way of the world’ for a very long time in WordPress land. It’s a known ‘quirk.’ So that’s WHY it happened now when it didn’t used to.

    By the way, the other thing to worry about with using code in text widgets is that if a NON admin saves them, then wp_kses() is applied, and you may lose iframes/JS anyway. Plus in Multisite mode, only the Super Admin can save code like that. That’s why we STRONGLY recommend you switch to either coding real widgets or using shortcodes to output whatever the PHP is. I use that for google ads as [googleads size="responsive"] or a widget with drop down selections. It’s more coding on my end to be sure, but it stops my fellow editors from shooting the site in the foot when one of us is asleep at the switch.

    Nothing is more deadly than an admin who typos!

    Thread Starter RockyMtnHi

    (@rockymtnhi)

    @ipstenu I appreciate your response, the stories behind it all and the ramifications of different logins. Guess a decision was made many moons ago to just live with the Tiny MCE ‘quirk’. I still don’t agree with that as being acceptable, but I do see your point of using shortcodes.

    I have created some shortcodes already, and will continue to use them. Looks like this is the preferred way, so I’ll use this solution going forward.

    Thanks again.

    All the best

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Code in Text Widgets gets Changed/Deleted’ is closed to new replies.