Type to search.

#585 by installs

PHP Code Widget

by Samuel Wood (Otto)Version 2.4

Like the Text widget, but also allows working PHP code to be inserted.

Active installs
70,000+
#585 of 1,000
Downloads, all time
1M
1,002,122
Downloads, 30 days
1.8K
529 in the last 7
Rating
4.7 / 5
61 reviews
Last updated
5 years ago
Mar 30, 2022
Version
2.4
8 releases

Upkeep and compatibility

Last updatedMarch 30, 2022Not updated for over a year
Tested up toWordPress 5.9.20Older than WordPress 7.1.4, the current release
Needs WordPress2.8 or newer
Needs PHPNot stated
First publishedMarch 20, 2008
Support, last two monthsNo threads opened

Reviews

4.7 / 5 from 61 reviews

Reviews by star rating
5 stars52
4 stars5
3 stars1
2 stars0
1 star3

Downloads, last 30 days

Low 23 a dayHigh 172 a day

What the author says it does

The normal Text widget allows you to insert arbitrary Text and/or HTML code. This allows that too, but also parses any PHP code in the text widget and executes it.

This can make it easier to migrate to a widget-based theme. However, this plugin should not be used long term, as anybody with access to edit the widgets on your site will be able to execute arbitrary PHP code.

All PHP code must be enclosed in the standard php opening and closing tags ( <?php and ?> ) for it to be recognized and executed.

Only users with the unfiltered_html role will be allowed to insert unfiltered HTML. This includes PHP code, so users without admin or editor permissions will not be able to use this to execute code, even if they have widget editing permissions.

The opening of the plugin's own description. The full text, installation notes and changelog are on its WordPress.org page.

Questions the author answers

There’s some kind of error on line 27!

That error means that your PHP code is incorrect or otherwise broken.

But my code is fine!

No, it’s not. Really.

This widget has no real errors in it, it’s about the simplest widget one can possibly make. Any errors coming out of the “execphp.php” file are errors in code you put into one of the widgets. The reason that it shows the error being in the execphp.php file is because that is where your widget’s code is actually being run.

I have code that works normally in a template but doesn’t work when in the widget?

Code in a template runs in the global context. Code in the widget will run in a function context. Make sure that you declare any global variables as global before attempting to use them.

Latest changelog entry

2.4

  • After much demand, made it stop throwing a warning in PHP 8. Please consider ceasing usage of this widget on modern sites. Switch to block based themes, or use purpose specific plugins to solve your needs instead of storing PHP code in the database.

Screenshots

From WordPress.org.

Tagged

Plugins that share its tags

#32 by installs

Code Snippets

by Code Snippets Pro

Manage custom WordPress code in one dashboard. Create PHP and HTML snippets, preview code, track snippet totals and reuse code across sites.

Installs
1+ million
Rating
4.7 (510)
Updated
10 days ago

#163 by installs

Blocksy Companion

by Creative Themes

The official companion plugin for Blocksy theme, packed with starter sites, extra features, and integrations.

Installs
300,000+
Rating
4.7 (93)
Updated
2 days ago

#234 by installs

Black Studio TinyMCE Widget

by Black Studio

The visual editor widget for WordPress.

Installs
200,000+
Rating
4.8 (191)
Updated
2 months ago

#268 by installs

PHP Compatibility Checker

by WP Engine

Make sure your plugins and themes are compatible with newer PHP versions.

Installs
200,000+
Rating
2.7 (131)
Updated
3 months ago

Where this page's numbers come from

Read from the WordPress.org plugin API on , when WordPress 7.1.4 was the current release. WordPress.org rounds active installs into buckets. These are the directory's figures, not my verdict, and I haven't tested this plugin.