Looking for a widget to display PHP code

General Discussion 3 posts 2 voices

  1. I know there are plenty of those around but most of them only offer the most basic features. Until now I used Otto’s => https://wordpress.org/plugins/php-code-widget/

    but what I am really missing is the option to hide the widget Title if the widget is empty.

    I then remembered that someone had shared some code with me, probably on this very forum which he called a discreet text widget which shows nothing unless there is content in the widget => https://gist.github.com/ovizii/3891aff7c1db38b96349

    so I was wondering if there is a widget like this but for PHP code, if Otto’s plugin could easily be extended or if the text widget could be extended to run PHP?

    Or maybe someone else has a better solution?

  2. I don’t know of any widgets like that. I don’t see any way of extending Otto’s widget or the basic text widget to do that either. This is simply because the content is handled after the title is output.

    I’d just recommend forking Ott’s PHP Code Widget plugin and adding your changes to that. It’s really a simple plugin that’s not going to change much over time.

  3. Thanks, it was worth a shot to see if anyone had seen anything like that.