Add php to the text widget

Posted on 11th September, 2013 390 Comments

This is a real beaut of a snippet and deservedly belongs a place in the “Must Have Snippets” hall of fame.

Basically all this does it allow you to add and then process php inside the text widget, which means that you won’t need to use a plugin!

Add this to your functions.php:

/**
 * Allow the use of PHP in the text widget
 */
add_filter('widget_text','execute_php',100);
function execute_php($html){
     if(strpos($html,"<"."?php")!==false){
          ob_start();
          eval("?".">".$html);
          $html=ob_get_contents();
          ob_end_clean();
     }
     return $html;
}

Then when you add your text widget you’ll be able to do things like this!

<img src="<?php bloginfo('template_directory'); ?>/images/image-source.php" alt="loading images straight from " />

Original post found at www.emanueleferonato.com

Comments

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]

JamesVen

21st, Oct, 20

spot tests a means, the Patient of Strange Path men’s. [url=https://ciamedusa.com/]cheap cialis[/url] Continually the punch where I satin is rampageous

JamesVen

21st, Oct, 20

contain never had a woman half (lifestyle to a spinal). [url=https://ciamedusa.com/#]buying cialis online[/url] Tjgjjt coemus generic for cialis cialis 5 mg

JamesVen

25th, Oct, 20

Exchange for others, they can be serious and tetracycline to. [url=https://ciamedusa.com/#]cialis[/url] Ljvhay qaxrgz price for cialis tadalafil cost

RobertBAR

01st, Nov, 20

erectile pills from canada [url=http://erectiledysfunctionpillscvs.com/#]best erectile dysfunction drug[/url] erectile chambers

RobertBAR

06th, Nov, 20

is erectile dysfunction a va disability [url=http://erectiledysfunctionpillscvs.com/#]cheapest ed drugs[/url] erectile dysfunction when trying to conceive

Tietty

29th, Nov, 20

Healthcare continues to be an important, but divisive political topic. Not surprisingly, 41 percent of suitable voters said healthcare was their critical put in the mid-term elections in 2018.order generic cialis In 2008, when the ACA became law, only 46 percent of voters supported individual payer healthcare. That number has grown significantly to 59 percent approval in anciently 2018.[url=http://my-canadianpharmacyonline.com]online viagra prescription[/url] While Medicare-for-all legislation is unthinkable to pass both the Bordello and Senate in its progress form, there is a budge in community opinion with a dynamic more than half in the present circumstances in favor.

seniors insurance

08th, Dec, 20

[url=https://bslifeinsurance.com/]affordable life insurance for seniors over 60[/url] [url=https://xtlifeinsurance.com/]best term life insurance companies[/url]

BiSeetteWag

13th, Dec, 20

[url=https://cialsagen.com/]tadalafil online uk[/url]

BigSeetteWag

15th, Dec, 20

[url=https://cialinic.com/]cialis price from canada[/url]

DigSeetteWag

17th, Dec, 20

[url=https://viagrraver.com/]viagra with dapoxetine generic usa[/url]

BigSeetteWag

18th, Dec, 20

[url=https://cial20mg.online/]buy cialis pharmacy[/url]

RigSeetteWag

21st, Dec, 20

[url=https://ciaaliss.com/]tadalafil without prescription canada[/url]

Tietty

21st, Dec, 20

Healthcare continues to be an important, but divisive political topic. Not surprisingly, 41 percent of suitable voters said healthcare was their indicator put in the mid-term elections in 2018.generic cialis online In 2008, when the ACA became law, barely 46 percent of voters supported individual payer healthcare. That number has grown significantly to 59 percent authorization in anciently 2018.[url=http://my-canadianpharmacyonline.com]canadian pharmacy online[/url] While Medicare-for-all legislation is unfit to pass both the House and Senate in its current manifestation, there is a switch manage in obvious notion with a dynamic the greater part now in favor.

GigSeetteWag

23rd, Dec, 20

[url=https://cialislex.com/]buy tadalafil us[/url]

SigSeetteWag

26th, Dec, 20

[url=https://viagratru.com/]can you take viagra daily[/url]

SiaSeetteWag

28th, Dec, 20

[url=http://viapdp.com/]viagra side effects blood pressure[/url]

SibSeetteWag

30th, Dec, 20

[url=http://advadisk.com/]advair diskus india[/url]

Abraham Novitske

30th, Dec, 20

I’m gone to inform my little brother, that he should also pay a quick visit this web site on regular basis to get updated from most up-to-date news update.|

SicSeetteWag

01st, Jan, 21

[url=https://sildrx.com/]vietnamese viagra[/url]

SidSeetteWag

03rd, Jan, 21

[url=https://clomidweb.com/]clomid 50mg[/url]

Cary Racano

03rd, Jan, 21

Hello mates, its fantastic paragraph concerning teachingand fully defined, keep it up all the time.|

SieSeetteWag

05th, Jan, 21

[url=http://cealis1.com/]best canadian cialis[/url]

hey

05th, Jan, 21

Taxi moto line
128 Rue la Boétie
75008 Paris
+33 6 51 612 712  

Taxi moto paris

I am genuinely thankful to the holder of this web site who has
shared this wonderful piece of writing at here.

SieSeetteWag

09th, Jan, 21

[url=http://oralkamagjelly.com/]best alternatives to kamagra[/url]

windows activator key

20th, Jan, 21

Hi there to all, the contents present at this web site are genuinely amazing for people experience, well, keep up the nice work fellows.|

Mollyjax

22nd, Jan, 21

где купить электронную сигарету [url=https://hqd.wiki/kak-otlichit-hqd-poddelku-ot-originala/]эйкьюди как отличить паль от оригинала[/url]
——
электронная сигарета в больших вязьмах [url=https://hqd.wiki/kak-otlichit-hqd-poddelku-ot-originala/]как отличить паленый эйкьюди от оригинала[/url]

KbbtBoth

27th, Jan, 21

buy cialis uk no prescription canada pharmaceuticals cialis ireland [url=https://xz-pharmacyonline.com]canadian pharmacy kingcanadian viagra[/url] ’

Lu Hean

27th, Jan, 21

Thanks for ones marvelous posting! I certainly enjoyed reading it, you can be a great author.I will make certain to bookmark your blog and will come back sometime soon. I want to encourage that you continue your great writing, have a nice evening!

beAppasiomose

28th, Jan, 21

[url=https://cialinic.com/ ]cialis 20 mg price[/url]

cheap flights

31st, Jan, 21

It’s an amazing post in favor of all the internet users; they
will take benefit from it I am sure.

cheap flights

01st, Feb, 21

Attractive section of content. I just stumbled upon your web
site and in accession capital to assert that I acquire actually enjoyed account your blog posts.

Anyway I’ll be subscribing to your augment and even I
achievement you access consistently fast.

cheap flights

02nd, Feb, 21

It’s very easy to find out any matter on net as compared to textbooks, as I found this article at this website.

tinyurl.com

03rd, Feb, 21

Hi there, I discovered your website by means of Google whilst searching for a related matter,
your web site came up, it looks good. I’ve bookmarked it
in my google bookmarks.
Hello there, simply turned into aware of your blog via
Google, and found that it’s truly informative. I’m gonna be
careful for brussels. I’ll appreciate if you continue this in future.
Lots of other people will probably be benefited out
of your writing. Cheers!

FionaScova

08th, Feb, 21

вообще-то, скачать бесплатное приложение музмо [url=https://soundvor.me/mp3/%D0%B7%D0%B0%D1%80%D1%83%D0%B1%D0%B5%D0%B6%D0%BD%D1%8B%D0%B5+%D1%85%D0%B8%D1%82%D1%8B+80+%D1%85+90+%D1%85]зарубежные хиты 80-90[/url]

Mareenakep

09th, Feb, 21

между нами, музмо ру бесплатно скачать 90 [url=https://soundvor.me]скачать музыку бесплатно на телефон[/url]

beAppasiomose

09th, Feb, 21

[url=https://cial20mg.online/ ]cialis 50 mg tablets[/url]

Mareenakep

09th, Feb, 21

с моей точки зрения, скачать музыку бесплатно muzmo [url=https://soundvor.me/mp3/%D0%BE%D1%87%D0%B5%D0%BD%D1%8C+%D0%B3%D1%80%D1%83%D1%81%D1%82%D0%BD%D0%B0%D1%8F+%D0%BC%D0%B5%D0%BB%D0%BE%D0%B4%D0%B8%D1%8F]грустная мелодия[/url]

http://tinyurl.com/yxj7muk2

12th, Feb, 21

My partner and I absolutely love your blog and find a lot of your post’s to be what precisely I’m looking for.
Does one offer guest writers to write content for you? I wouldn’t mind writing a post or elaborating on many of the subjects you write in relation to here.

Again, awesome blog!

Richardduaky

18th, Feb, 21

Спасибо за пост
_________________
[URL=https://ua.onlinebestrealmoneygames.xyz/bezdepozitnyy-bonusy-v-kazino-v-ukraine/]Бездепозитный бонусы в казино в украине[/URL]

Richardduaky

18th, Feb, 21

Спасидо, +
_________________
[URL=https://ua.onlinebestrealmoneygames.xyz/dzhoy-kazino-v-ukraine/]Джой казино в украине[/URL]

Richardduaky

19th, Feb, 21

Спасибо за пост
_________________
казино х украина. [URL=https://ua.onlinebestrealmoneygames.xyz/vipnetgame-kazino-ukraina/]Vipnetgame казино украина[/URL]. ігрові автомати слоти безплатно.

Ariadeepes

19th, Feb, 21

как видно, шансон скачать бесплатно новинки 2020 музмо [url=https://muzloman.me/music/modern%20talking%20cheri%20cheri%20lady%20remix]ремикс шери шери леди[/url]

Timothy Janisch

01st, Mar, 21

Thank you, I’ve recently been searching for facts about this subject for ages and yours is the best I’ve located so far.

Leave a Comment

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]