Note: The ExecPHP widget does not work in the upcoming WordPress 2.5. Therefore, if you upgrade to 2.5, you will need to install the updated version of this widget. It can be found here, now and forever more: http://wordpress.org/extend/plugins/php-code-widget/
A new plugin for Wordpress came out that’s kinda cool. It’s called Widgets, and the general idea of it is to make the sidebars on your blog a bit more configurable, a bit more easily.
So, I decided to spend an hour or so converting my sidebars to Widgets so I could manage them a bit simpler. Editing PHP code is easy but time consuming, while dragging stuff and dropping it to rearrange the blog, well, that’s quick and easy.
Few things I learned:
- The Widgets Plugin does not like Windows. Since I run this site on a Windows box (edit: I did then, I don’t anymore, and anyway, they have fixed this problem since then), it needed some tweaking to make it work. For those who want to know, the problem is in the sidebar_admin_setup() function in widgets.php. More info on this problem is in the comments of this post.
- Text boxes are extremely useful when converting from your existing customized webpage to a widgets based one, as you can simply cut and paste chunks of HTML into them and voila, you’ve got a sidebar widget. However, there’s not a lot of text widgets available. If you need more text widgets, you will need to edit these functions: widget_text_setup(), widget_text_page(), and widget_text_register(). As it turned out, I didn’t need but 4 text widgets because:
- Despite how useful text boxes were for a quick migration, they were not enough.
So, I ended up writing two plugins of my own.
The first one is a Google AdSense plugin. You can download it here: gadsense.zip. It’s exactly the same as the Text widgets, but with (very) minor tweaks specifically for inserting Google Ads in the sidebars. Also, it shows a name of “Google AdSense” in the widgets panel, which is nice. Like the Text widget, you can have more than 1 of them, but unlike the Text widget, you can only have 4 of them, since Google’s TOS only allows 3 ads and 1 link block on a page.
The next one is also like the Text plugin, however it will also let you put PHP code into the text and have it actually work. Here’s the download: execphp.zip. Like the Text plugin, you can have up to 9 of them (more if you want to tweak the code). Note that any PHP code you put into the widget MUST be surrounded by <?php and ?> tags, just like writing PHP normally. Also note that this is isn’t exactly safe, as it’s just doing an eval() on whatever you put in there, so you have complete and full access, as does anybody else who can get to your admin screen. Still, it’s very useful.
Both of those are plugins. Just drop them in the widgets folder under the plugins folder, and activate them on the plugins screen. Then the widgets will be available for you to use on the widgets screen.
Hope these help somebody. They sure helped me. ![]()
hi, i just wanted to download exephp.zip. the link seems to be broken??
can you send me the zipfile to me email adress? would be sooo great!!!!!!!
thanks kris
The link has been fixed. Sorry, I’ve had hosting issues lately.
Awesome!! That execphp was just what I was looking for! You rock!
[...] When I got home, I noticed that Text Link Ads has sold three more links for me! These guys are on a roll. I wonder how long it will take them to sell all eight spots? Thanks to a Victor at City Guide for pointing me to the ExecPHP plugins. This plugin allows you to run PHP codes inside the Wordpress Sidebar Widget. I used the new plugin to run the Text Link Ads code inside my sidebar. The links were under the 468 Google ad before. It looks much better now, [...]
[...] When I got home, I noticed that Text Link Ads has sold three more links for me! These guys are on a roll. I wonder how long it will take them to sell all eight spots? Thanks to a Victor at City Guide for pointing me to the ExecPHP plugins. This plugin allows you to run PHP codes inside the Wordpress Sidebar Widget. I used the new plugin to run the Text Link Ads code inside my sidebar. The links were under the 468 Google ad before. It looks much better now, [...]
Nice plugin. Worked just perfectly; and much more flexible than some of the others.
[...] I’m using Otto’s Google Adsense widget, it’s working very well. [...]
I’m having trouble with what should be quite simple — the plug-in is downloaded and it resides in the proper directory, but it won’t show in the list of available plug-ins. Help?
-rob.
Never mind the above; for whatever reason, the problem vanished after re-downloading, replacing the file, trashing the cache, and reloading the page.
-rob.
When I paste my adsense script in the adsense widget and click save changes, on re-opening the text disappears!
Should I do something to encode/escape the HTML tags?
Thanks a lot. nice pair. Downloaded, installed, using
[...] Next, I’ve installed the Show Top Commenters plugin as promised. It is quite customizable and easily done. By putting the php code into a new blank widget via Executable PHP widget by Otto instead of in my sidebar through an edit client and then have to upload via FTP, I can customize the plugin right in my WordPress Presentation tab and save from there. Easy-peasy. [...]
execphp is a great little plugin! You can see the Categories block I created with it on my left sidebar at potluck.com — it shows only the top level items, no subcategories, just what I’d wanted.
I wonder, though — on the “Potluck Creative Arts” page and all its subpages, I’d love for an image to show up *instead* of the Category block. I tried this:
“;
} else {
echo “Categories” . wp_list_cats(’sort_column=ID&children=0&list=1&hide_empty=0′) . “”;
} ?>
…and I got close. The image shows up correctly on the appropriate pages instead of the category block. However, on all other pages/posts, the category block goes crazy — instead of showing up the way it does right now on the site, the “Categories” heading appears at the very bottom, below all the category items, and each category item is formatted as if it were its own little sidebar block, with the graphic outline. Looks terrible! Any idea what I could do, or is that just too much a general php/CSS question for me to ask here w/r/t to the execphp plugin?
I realized that the code I’d put in my last comment didn’t come through in tact. In any case, I suspect it’s beside the point. The real question may be this: Would it be possible to alter the execphp widget so that it included conditionality? E.g., in addition to the title and code boxes that currently exist, there could be another box at top which allowed the option of attaching conditional code. If left blank, the widget would function as it does now. If filled it, the conditions would be assessed, and only if true woud the box then be added, again just as it works now, but if the conditions proved false, then no box would be added to the sidebar at all. This would probably solve everything I need, and it would open up a world of possibility for this widget’s usage!
[...] This Plugin allows you to run PHP codes inside the Sidebar Widget. I had to install this Plugin because the Feature Sites for Text Link Ads (aff) and the Top Commentators requires a PHP call and by itself, the Sidebar Widget doesn’t execute PHP codes. Grab the Plugin here. [...]
Hi,
When I insert some PHP code into the widget and hit update/save, all the code dissapears! So it’s not working. Any ideas on what may be causing this? I am using WP 2.1 and on WP Mu.
Thanks for the Adsense widget! It’s exactly what I’ve been looking for. Now it’s up and running. Thanks again.
This widget works great.. thank you so much!
[...] updgrading to a newer version of this theme, I added the execPHP plugin to able to execute php commands from my sidebar widgets. Without it, I would have a tough [...]
[...] Every time I play a song it’s recorded by a little bug on my computer trained to ship the titles to my last.fm profile page. The data is harvested there by a Wordpress widget created by a guy named Jonathan and then published here using another widget by a guy named Otto. [...]
[…] I had to install this Plugin because the Feature Sites for Text Link Ads (aff) and the Top Commentators requires a PHP call and by itself, the Sidebar Widget doesn’t execute PHP codes. Working fine. Thank’s […]
[...] After more googling, I found out that the STA plugin does run on widgets, if you installed the executable PHP for Text widgets [...]
[...] PHP widget
This is great. Thank you very much.
[...] Executable PHP Widget enables you to run PHP codes with the SideBar Widgets plugin. [...]
[...] find a solution; I tried a few different widgets but none of which seemed to work.
[...] need to get the PHP Widget Plugin and activate it.
[...] will also execute php code. If you have plans to monetize your blog, then be sure to grab the Executable PHP Widget because I am sure you will need [...]
[...] Our base installation for Openads is complete.
[...] While I was playing with the code and confirming that I am not a programmer, I realized that I wanted some of the widgets to go away when people look at a post. I came across Otto’s page and installed the Executable PHP Widget. [...]
[...] a dica encontrada tenho que instalar o plugin executável PHP para textos widgets para o encaixe funcionar, feito subi o plugin para wp-content/plugins/widgets, (claro terá [...]
[...] the plain text widget that comes pre-installed with the Sidebar Widgets plugin, the Executable PHP Widget allows you to write your own custom PHP code and load it into your sidebar with ease. Currently, [...]
[...] plugin’ qui permet d’insérer facilement la liste dans la sidebar : execphp ! Ce petit plugin’ permet d’insérer du code php exécutable dans la sidebar,
Just what I was looking for. I just updated my theme to a widget based, and had to move all my custom menu. Thanks, and keep up the good work.
[...] ???????Fun with Widgets » Nothing to see here?execphp.zip [...]
Thank you.
[...] Executable PHP widget [...]
The download links no longer work
James: Fixed.
I’m new to WordPress, how do I exactly put my AdSense code into my sidebar using gadsense.php?. I know basic PHP and HTML, but I do not know WordPress Plug in API. I’ve also activated widgets plug in successfully.
I cant express enough thanks for this wonderful widget, it has made my life very easy, thank you so much.
[...] Executable PHP Widget [Download] – Aggiunge fino a 9 widgets ai Sidebar Widgets nei quali è possibile inserire codice PHP eseguibile. [...]
Every time I try to put the php code on it using your widget it says: The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
No matter when I try it. It says that EVERY time.
if you could please email me if you know what’s wrong, i would really appreciate it. (the-musicinmyheadAThotmail.com)
thanks
[...] php tags in your widgetized sidebar. If you want to install plugin code in a widget, you need an Exec-PHP widget to enable PHP scripts to run in the widget. (If you are manually editing your sidebar.php file, you [...]
[...] plugins that require PHP coding, you’ll want to add Executable PHP widget by Otto. Both of these should be added to your plugins>widgets directory on your [...]
[...] Executable PHP widget [...]
I’m new to WordPress, how do I exactly put my AdSense code into my sidebar using gadsense.php?. I know basic PHP and HTML, but I do not know WordPress Plug in API. I’ve also activated widgets plug in successfully.
Martin: You put the php file into the wp-content/plugins folder. Then you go to the plugins screen and activate the plugin. Finally, you go to the widgets screen, and you’ll have a new widget available for dragging and dropping into the sidebar. When you configure it, it’ll have a textbox for pasting the adsense code into.
[...] Execphp A wonderful little plugin that lets you put php code on your widgets in the sidebar. Heaven-sent! [...]
Hi Otto,
I think I’m having an problem with execphp, but I’m not sure if it’s that or the plugins I’m using. The two
I’m having issues with are “Popularity Contest” and “Top Commentators” - both use php code to call them.
would you mind taking a look at this thread over at wordpress support to see if you have any insight for me?
http://wordpress.org/support/t.....;id=116715
thanks so much!
Otto, Thank you so much for coming over to wordpress/support to help me with my question. Your answer worked perfectly. I’ll put it here too in case anyone is having trouble with Top Commentators or Popularity Contest formatting.
Here was Otto’s response:
You need to edit that widget and add and around the function call that you’re making. Why? Because the html it’s creating has each link inside of an li tag, but you don’t have a list around those for the li tags to make sense.
Just edit the widget and change this:
to this:
Thanks again!
Oops here the advice from Otto
You need to edit that widget and add and around the function call that you’re making. Why? Because the html it’s creating has each link inside of an li tag, but you don’t have a list around those for the li tags to make sense.
Just edit the widget and change this:
// //
to this:
//
//
forgot to put in the backslashes. The backslashes are like quotation marks around the code. They are not part of the answer.
OK. That didn’t work either. Here’s the link if anyone needs it:
http://wordpress.org/support/t.....ost-557660
[...] Algunas de las funcionalidades que le he agregado al blog requieren insertar código PHP en la barra lateral y para no estar tocando los archivos la configuro vía widgets, con Executable PHP widget puedes ejecutar varios bloques de código y organizarlos fácilmente en tu barra lateral. Puedes ampliar la información sobre este plugin aquí. [...]
[...] widget will not execute PHP code, so you have to do it the old fashioned way. Unless you use the execphp plugin, which enables you to
I’m having trouble using this plugin with WP 2.2. Whenever I have more than one of these widgets in use at one time, the contents of the first to be evaluated are copied to every other instance of the widget.
Hmm…Samsarin’s PHP widget seems to have the same bizarre problem.
Look at http://trac.wordpress.org/ticket/4275
[...] the hard coded search form and above the widget test when I discovered my new favorite widget, the Executable PHP widget, while reading Aaron Brazell’s 10 Things You Should Know About Wordpress 2.2. It was also in [...]
Thanks.
[...] recognized the magnitude of the problem. It wasn’t just the tag cloud. It was the Executable PHP Widget. Sure enough, all of the PHP widgets were showing the Top 10 Daily [...]
There’s a fix for Wordpress 2.2 that will correct this problem:
Download this file: widgets.php.
Replace your /wp-includes/widgets.php with this file. Problem solved for the moment.
I’ll have a fix to the widget itself that should allow it to work with anything sometime tonight.
[...] bis dato noch kein Workaround für King-Text. Nach langem suchen habe ich dann endlich das ExecPHP-Widget gefunden. Jenes funktioniert bei mir problemlos mit PHP-Code in der Sidebar, meine doofe Tagwolke [...]
[...] 2.2 might be a good idea. The only trouble that I noticed with the new version is if you use ‘Otto’s execphp plugin‘ or other similar plugins to enable php in your blog’s sidebars you’ll need to [...]
thanks..
i really dont understand about php
so with this widget its easy
just copy paste..lol
[...] Visit [...]
[...] Widget plugin that was very useful is the Executable PHP widget found here . It works like a Text widget, but it will allow you to use PHP code as [...]
[...] Another problem, if your plugins aren’t widgetized then what do you do? I had to use this plugin(execphp). [...]
[...] mit WordPress 2.2 arbeitet, und die Widgets auch für PHP-Code nutzen möchte, wird das Executable PHP widget-Plugin mögen. Doch gibt es einen Bug, der es nicht ermöglicht mehr als 1 Widget zu laden, jedes weitere [...]
[...] am using the Executable PHP Code
Executable PHP widget seems to screw the sidebar up in IE 7. No problem in Firefox. Using WordPress 2.2. Makes the bottom half of the sidebar move to the opposite side and not lined up. Using default theme.
Here is the code I put in the widget
‘ . __(’Pages’) . ” ); ?>
Steven: The PHP widget is basically identical to the Text widget. It cannot “screw up” anything by itself.
It’s certainly possible for the code you use to do something like that though. So I’d suggest changing your code.
Well… duh!
Nevermind, I deleted and reloaded the plugin and it works as advertised.
Getting this error:
Parse error: syntax error, unexpected T_STRING in /home/.dino/chutney/makingchutney.com/wp-content/plugins/execphp.php(24) : eval()'d code on line 1sry - this is the whole code, removed the php tags at start and end to get it in the post…
wp_list_pages(’exclude=44,45,46,48,50,51,52,53&title_li=’ . __(’Pages’) . ” );
@chutney: Something is wrong with the PHP code you put into the widget. That’s what causes that error.
@rogilvie: I can’t tell you what’s wrong with your code, exactly. The widget itself doesn’t modify anything or produce any real output of its own. If it’s breaking the page, it’s your code that is doing it, somehow.
[...] Executable PHP widget by OttoLike the Text widget, but it will take PHP code as well. Up to 9 instances of this widget may exist. Heavily derived from the Text widget code included with the widget plugin by Automattic, Inc. [...]
[...] widget qui permet d’afficher du php, qui s’est pour finir très bien réglé après une modification d’un fichier dans [...]
that is so amazing plugin to wordpress and me
Thank u so much,? am so funny
Thx a lot for the solution with the execphp. I use it for my latest Pixelpost photograph to be displayed in WP.
Best wishes!!
Jens
[...] ??????????Fun with Widgets??????????????????????????????????????????????????????? WordPress ??? Widgets ???? PHP Code? [...]
[...] you’ll see it on my left bar. At least if you are not coming here directly. With the help of Otto’s PHP widget plugin, I put some PHP code on a [...]
[...] Wordpress 2.2 to 2.2.1 went smoothly for me. However, I had to go back to the original version of ExecPHP. I had mod the codes in order for ExecPHP to work with 2.2. Since 2.2.1 addressed that bug, my [...]
[...] plugin had to be undone. This modification was posted on John’s blog and the plugin can be re-downloaded from the original [...]
[...] plugin has not been widgetized so if you use widgets on your sidebar, you’ll need Otto’s ExecPHP or something like [...]
I have the problem with Wordpress 2.2 and understand that I need to update my widgets.php as per link at the top of this page. Will this effect my current widgets settings?
Wordpress 2.2.1 works with the ExecPHP widget as is, no changes required.
And no, you will not lose any settings by updating the widget.
[...] Executable PHP Widget [...]
[...] PHP widgets running under the Execute PHP widget disappeared. According to Otto, the author, this was a known issue in WordPress 2.2, that should be resolved by [...]
Tried it on my test site, which has 2.2.1 installed, and got a message along the lines of “you don’t have permission to edit (or access?) widget.php file on this server …”
Smells like I need to fool with my file permissions but not sure what setting to assign. Currently have set to write by me only.
Bruce: What are you talking about? It’s a plugin. Drop it anywhere in the plugins folder, activate the plugin. You don’t need to edit any widgets.php file or anything like that.
All the files in the Wordpress directory must have at least 444 permissions, most likely, but that’s normal for Wordpress.
Otto, not attempting to edit the widget file. That’s what’s odd. I just add the PHP widget to my sidebar, put some code in it, and get the following message
You don’t have permission to access /keenstuff/kltestblog/wp-admin/widgets.php on this server.
The code I put in is simple
Recent Posts
“>