PHP Code Widget
Samuel Wood (Otto)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.
That error means that your PHP code is incorrect or otherwise broken.
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.
So, if it says that you have an error on line 27, I assure you, the problem is yours. Please don’t email me about that error.
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.
Excellent, awesome // incredible plug in!!
By dglite on July 25, 2022
Perfect
By holby on June 21, 2020
much better solutions
By Pexle Chris (pexlechris) on June 6, 2020
Very useful
By Nester (Hobbyits) on February 3, 2020
Awesome Plugin
By Xaib Aslam (lahorimela) on September 20, 2019
Выполняет свою задачу
By kotyarashop on September 5, 2019
Perfect
By frankpc on February 6, 2019
Unfrieking Unfreikingbelievable !!!
By nick6352683 on October 10, 2017
Cool widget
By vietnamsales on September 3, 2016
Exactly what I was loking for!
I was trying to move a login php to my sidebar by coding it, when I found this plugin:
It 's simple and efficient. Great job!
Unprofessional
By wafwaf on September 3, 2016
Programmer is not serious about this product. Refused to update the plugin even though WordPress.org still gives a warning it has not been tested with the current version of WordPress. Unprofessional.
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.
2.3
- Changed the call to WP_Widget to use the PHP 5 __construct() method. Ref: https://make.wordpress.org/core/2015/07/02/deprecating-php4-style-constructors-in-wordpress-4-3/
2.2
- Translation fixes for WP 3.7
- Remove donation link
2.1
- Fixed broken wpautop filter. Checkbox on widget works now.
2.0
- Changed widget to use new Class methods for creating widget. This simplifies the widget and should eliminate any problems with it losing code or disappearing from sidebars and so forth.
Reviews
4.7 out of 5 stars
- Version: 2.4
- Last updated: 2 years ago
- Active installations: 100K
- WordPress version: 2.8
- Tested up to: 5.9.10
- PHP version: false