WordPress Widget: King Text (+php) (+html)
"Another Text Widget? Why the hell would i need that?"
Well read on and it might convince you.
Features

Version 0.69 NEW Features
- Randomize Widget Content. Split the content with the <!–more–> Tag and it will shuffle the text or php code inside.
- Remote Version checking
- Option for using the Javascript Slide Open/Close function
- Where NOT to show. Select Side Area where the widget is not be shown on (i.e. everywhere but Home) this can be combined with the show in category
- changed the license type
Version 0.63:
- 20 Text Boxes
- set HTML before/after seperatly for each Widget OR takes widget before/after HTML from functions.php if left empty
- Menu in which Website Area to show the Widget on. New Options are:
- show on Home / Search / Archive or 404 page
- show on all or special single Page. You can set the id or slug of the Page where to show
- show on all or special single Article You can set the id or slug of the Article where to show
- show on all or special Category Listing You can set the id of the Category where to show
- Show if inside a special Category. If in list List or on single Article
You find all Options explained in the WordPress Codex in Conditional Tags make sure to definitly read this if you are using those Options!
– new ajax menu
Version 0.5
- Choose whether to have php or just html in the widget. With php in the widget you can for example use any WordPress call. So if you are missing any WordPress or Plugin functions in widgets insert them there.
- choose in which category the widget shall appear
- 4 html fields to custmize html before/after widget and title
- based on the king widget framework
- Fully localizable with gettext Translation (German Translation included)
Screenshot
German and English Admin Screens (Version 0.6+ foldable menu, updated screens are comming)
Comming Features
- Randomly show box Content devided by <!–more–> Tag like in AdRotator. so you also rotate php code or anything else
- Option to show widget to a specific Role -> use wordpress capabilities (I will give this a priority if someone asks/pays for it)
- set initial JS Open or Close State + JS Open/Close Time
- make use of is_home / is_single or other conditional tags -> what do you think?
- What else would you like to see? Please comment!
Install
Of course you should have wordpress widgets installed and activated. If not, you can find the download and install instructions over at automattic.com
- Copy king_text.php into your plugins widget folder -> where your widgets.php is !!!
- Copy the King Widget Framework in /king-includes into /plugins if you have not already another King Widget installed
- activate in Pluginarea.
- Drag the King Text Widget on one of your sidebars and play with the options.
Usage
Show Content Randomly
- insert the <!–more–> tag between you text or php content
Use JS Slide Open/Close
- Hint: When used together with Random Content the Javascript does not instantly recognize the new height of the box. After toggling it the height is ok.
Here are the steps to be taken. If you don´t understand those you can simply forget about this function
1. Go into the new King Framework Options Panel and activate the "Insert Sliding Javascript to Head"
2. go to the text widget html options and activate "Use Sliding Box"
3. The difficult part:
You have to fill the custom html options fields(or use this inside the textbox). The Box needs to be wrapped in a collappsible elemet(div/li/p) with aspecial ID and you have to give the click event to some element. Since this can vary with your blogtemplate i left this up to you.
Standart Options which should work with the default Template: (please check the " when copy/paste)
HTML Before Widget: <li>
HTML before widget Title: <h2 onClick="textslide1.toggle();" ><li>
HTML after widget Title: </h2><div id="text1">
HTML after widget: </div></li>
When you have multiple Boxes you just have to adapt the numbers in textslide1.toggle -> textslide2.toggle and of course the id text1 -> text2
Upgrade
For Version 0.69 you also need to get the changed King Widget Framework which is now available separate.
After upgrading your framework just replace king-test.php with the new one. Your textboxes content should remain unchanged.
Download
Version 0.69
king-text_0.69.zip (05.07.2006 01:13)
don´t forget to get the king-widget framework Version 0.68 or greater.
Version 0.63
king-text_0.63.zip (09.05.2006 16:13)
Please don´t hesitate to give me a feedback if this is usefull or if you think you found a bug!
Have fun!
Georg Leciejewski
WordPress Widget: King Text (+php) (+html)
You can follow all the replies to this entry through the comments feed.
WordPress Widget: King Text (+php) (+html)
- By on 05.07.2009 at 15:38
- By on 05.09.2008 at 14:46
- By on 06.01.2008 at 12:43
- By on 23.08.2007 at 10:41
- By on 16.07.2007 at 1:12
- By on 15.07.2007 at 15:54
- By on 31.05.2007 at 2:46
- By on 18.05.2007 at 11:18
- By on 17.05.2007 at 4:12
- By on 17.05.2007 at 0:44
- By on 17.05.2007 at 0:41
- By on 01.04.2007 at 20:48
- By on 16.03.2007 at 8:12
- By on 11.03.2007 at 18:46
- By on 08.12.2006 at 11:53
- By on 05.12.2006 at 1:19
- By on 28.11.2006 at 0:08
- By on 27.11.2006 at 19:49
- By on 19.11.2006 at 14:10
- By on 13.11.2006 at 2:25
- By on 25.07.2006 at 3:55
- By on 08.06.2006 at 22:57
- By on 04.06.2006 at 23:58




sorry the code completely disappeared.
I’ll try again:
I tried inserting a lot of spaces, hopefully it works this time here in the coment
hello,
I have just tried to display a certain php code with this widget. I insert the code, check the php check box, update, and when I check again the widget teh php code disappeares…
here is one example I am trying to get to display:
I introduced some spaces in the php code so that it gets not filtered, after saving the widget settings, I open them again and the php code has disappeared….
can you help please?
Exelente trabajp XD.
hallo schorsch.
ich habe 10 Text Widgets und und zeige diese auf verschiedenen Seiten an.
nun habe ich zwei Seiten wo ich 2 gleiche Text Widgets anzeigen möchte, in der Beschreibung steht das ich die Seiten ID’s getrennt mit Komma angeben kann, leider funkioniert das nicht.
hast du einen Tipp für mich?
mfg, leo
Great set of widgets, thank you.
I sent an email out, unsure if it made it over, so my question:
I’m trying to get a text widget (actually any widget using the framework) to display *only* in the catagory page it’s linked to. However, if posts are in more than one catagory, there are issues.
Take my weblog, for example. I have one King Text Widget trying to stay in page of catagory 3 (Second Life), but if the top post in the Main (is_home) page is also catagory 3 it shows there too. This also goes for the other catagory pages where the top post in the sequence is also catagory 3.
If this is a WordPress limitation I’ll just give up, but I hope not. I’m using 2.0.4 btw.
Thanks,
–TSK
Answering my wn question
nickname; ?>’s
I am trying to put the nickname of the currently displayed author page into the widget.
Is this possible? What is the php I would use? Tried a bunch of stuff and failed – help appreciated!
Awesome widget. Thank you so much!
As per comment # 23… I too would like to see the dropdown list as checkboxes and re-programmed to allow for more precise placement of where I want my boxes.
Let us know when you create such magic!!!
Take care.
Okay thanks! I use Firefox at home, but at work we are only allowed to use IE, so I’ll just have to be resigned to re-checking that PHP box if I do anything at work. Thanks again!
Hey Valerie,
first of all, it’s not me who did this widget, it’s Schorsch, I’m just a fellower like you. But to answer your problem, you have to open the widget admin in Firefox, not in Internet Explorer. Schorsch tried to fix it for hours and it didn’t work. So you have to open it in Firefox, which is anyway much better than IE. Try it out for yourself.
Have a great day
Alex
Alex, thank you so much for these great widgets. They solved a lot of problems I was having getting my site to work the way I wanted to. I didn’t list it here, because it’s not ready for public view yet. The Text widget works great for plugging in non-widget plugins in an easy, quick way. Thanks again!
One quick comment – on the Text Widgets, the only problem I have had is that if I open the widget in my control panel to check something or change something, whether I make any changes or not, the “Use PHP in Text” box always automatically unchecks itself, which effectively breaks the plugin I’ve put there until I realize what happened and fix it.
You might consider setting that to stay checked (if it was previously checked), rather than always defaulting back to unchecked, if possible.
But, that’s a minor item. Just wanted to say thanks a bunch! Really appreciate your work!
Vielen Dank Schorsch, klappt jetzt wunderbar.
Alex
Hallo Schorsch, sorry das ich dich schon wieder nerve. Ich habe in der Sidebar ein Textwidget meiner Top 3 eingefuegt und auch die Funktion “Used Slide Open Box” aktiviert. Ich habe auch den noetigen html Code eingefuegt. Leider funktioniert es nicht. Beim Login Widget funzt es ohne Probleme, hoffe du kannst mir da weiterhelfen.
Vielen Dank im Voraus
Alex
Versuchs mal mit der css eigenschaft margin-bottom.
damit kann man einen abstand der boxen erzeugen. Ansonsten tuen es auch paar breaks -> br
hallo Schorsch,
wie kann ich eine Extrazeile zwischen den einzelnen Widgets machen. die Widgets, ob Login Widget oder Textwidgets, die ich von dir einsetze sind immer gleich untereinander angesetzt. Waere super wenn ich zwischen den einzelnen widgets eine Leerzeile einfuegen kann. Ich habs schon im Widget mit / vor und nach dem widget probiert, aber nichts funzt.
waere fuer ein Beispiel sehr dankbar.
Ach ja, nur zur Info, auf deiner Seite wo du alle Widgets Symbole als Uebersicht aufgelistet hast, hast du das TextWidget Symbol garnicht dabei.
Alex
Unfortunately, it was Firefox that was giving me problems and I had to resort to IE to make things work at all. But, as I mentioned, it was probabably something on my end (laptop, session management, site caching?) since it has been a non-repeating problem so far.
Regards,
Rich.
BlogRodent
please try to use Firefox since the bug you had seems to come from IE.
Thanks for your quick reply, and for taking the time to look into it. For some reason, today everything worked beautifully. When I left my comment I could only manage the Widgets using IE, as well, and King Text was acting oddly. However, since then, I’ve flushed my WordPress cache, reinstalled a few plugins, flushed my FireFox cache, and generally restarted everything. So, today, when it works beautifully, I conclude the problem was probably client-side.
Thanks, again, for looking into this. I’m delighted to use KingText. It’s a great, useful tool. The exact kind of thing the WordPress developers should’ve put in, but didn’t.
Regards,
Rich
BlogRodent
@rich
i checked the code again and did some testing but could not locate a problem.
Maybe you can try to disable some other widgets to make sure it comes from the king text.
Hi, what a great set of widges, and King Text serves my needs very nicely.
Only one problem … when I check the box to allow PHP, close the widget screen, and click to save my PHP-enhanced text box, everything works fine. But, then, when I add more widgets or update some other widget, the King Text seems to revert back to disabled PHP. Things mysteriously disappear on my weblog.
Any ideas what could be the problem? At the time I write this I am not behind a firewall, and it’s not a caching issue.
Regards,
Rich
BlogRodent
Danke für den Input, führ es mir mal zu gemüte und vielleicht gibt es das dann ja bald!
Gengo kann ich nur empfehlen. Sehr gut (wie der King Text
.
Alternativ kann man das mit den Textblöcken für die Sidebar auch mit Gengo lösen, weil es eine Funktion für zweisprachige Textblöcke gibt. Allerdings wäre das wahrscheinlich mit King Text ein bisschen komfortabler zu verwalten gewesen, deshalb fragte ich.
Muss ich in dem Fall halt auf die Widget-Lösung verzichten. Na, macht nix.
@Roland:
ja wirklich ein spezialfall, der aber wichtig ist. ich habe leider bisher noch keine multilang site mit wp wegen fehlender funktionalität der verfügbaren plugins gebaut. bin eher auf der schiene zwei wp´s dafür zu nutzen.
Um dir eine passende Antwort geben zu können müsste ich mir gengo tiefer ansehen. Die info´s über die Seitenbereiche findest du im WordPress Codex unter “conditional Tags” ausführlich erklärt.
habe
leider gerade kein projekt was in diese richtung geht. Wenn du eine spezielle implementierung erwerben willst, kann ich dir aber durchaus zur hand gehen
Großartiges Ding.
Ich habe jetzt einen Spezialfall, und zwar verwende ich Gengo, ein Plugin, womit man zweisprachige Seiten betreiben kann. Der URL wird dann jeweils für jede Version ein “?language=Ländercode” angefügt. Sehr praktisch.
Jetzt würde ich gerne für die Startseite in der Sidebar einmal einen deutschen Text und einmal einen englischen Text haben, der je nach URL in der korrekten Sprache angegeben (also bei URL language=de ->deutscher Text und entsprechend beim Englischen).
In den Optionen von King-Text gibt es ja die Option
Spezieller Bereich und dann “Bereich ID/URL/Titel”. Ich hoffte, wenn ich dort den obigen URL-Teil eingebe, dann wird der King-Textblock tatsächlich nur dort angezeigt, klappt aber nicht.
Gibts da vielleicht eine Möglichkeit, die Dir einfiele?
Merci im voraus.
I look forward to the “rotator” function — of course, I’m not complaining, either. The King family of widgets is fantastic already!
@donzacharias:
Sorry i don´t have a quick answer on that. (maybe try setting global $wpdb; before using it)
I´m bussy proggin a remote version check for all of my king widgets.
Maybe you should take some internal wp call to get the authors (check codex)and than populate the dropdown with that.
What i take from your problem is that i might implement an author/Date dropdown in my King Search Widget.
sorry for the junk code… that second section should read
<code><?php foreach ($authorsArchives as $authorArchiveLink): ?>
<option value=”<?php echo $authorArchiveLink->user_nicename; ?>”><?php echo $authorArchiveLink->display_name; ?></option>
<?php endforeach; ?></code>
thanks again
Hi, thanks for making such a useful plugin! I’m having trouble using the results of a custom select query inside a King Text widget. Here is the page:
http://wp.sacrag.com/
the area in question is the error in the second SELECT in the right column. The following PHP is in the HEAD:
$authorsArchives = $wpdb->get_results("SELECT * FROM $wpdb->users");and then the following PHP is used in a King Text widget:
`
user_nicename; ?>">display_name; ?>
and you see what that does on the above link. I’m guessing it has something to do with the scope of $wpdb but I don’t really understand how to fix that. Can anybody help?
Thanks!
@Nimue:
na gegen so einen weiblichen Sonderwunsch habe ich nichts einzuwenden
ich habe bereits versucht ein widget so umzubauen, es aber nicht hinbekommen (ist damn tricky).
Dafür habe ich gestern einen Schalter gebaut welcher die Anzeige “überall ausser in XY” erlaubt. XY kann dann eine der bekannten auswahlmöglichkeiten unter “wo anzeigen?” sein.
..krasse Mondphase
besteht eigentlich die möglichkeit, das widget so umzustricken, daß zb. die anzeige auf
home
archiv der category 3
allen einzelseiten der category 3
möglich ist?
Beispiel: http://www.spiegelland.de.hm
der mondkalender soll auf der Startseite in der kategorie “Jahresrad” (http://www.sternengarten.info/fauna/?cat=48) und bei bei der artikelansicht (http://www.sternengarten.info/fauna/?p=160) in dieser kategorie angezeigt werden.
Das gleiche wäre beim king catgories widget nötig.
ja… ich weiß… frauen und sonderwünsche …
Thanks for a great plugin! It is one of the most useful plugins I am using. It is hard a at work on http://www.xeep.net.
Instead of 1) in #22, I want to make the following suggestion.
Use checkboxes insted of a dropdown list for areas where the wisget should be shown.
One should be able to select multiple areas where the widget can be displayed rather than restriciting it to a single area.
This would be a great feature in almost all king widgets! Thanks a lot
I have 2 feature requests!
1) is NOT in the following areas
– can be useful to show some text on all pages but the home page!
2) Add is_author to the list of areas.
Great plugins! Thanks a lot!
I’ve installed all files correctly but king-text doesn’t show up in the widgets menue.
It should be possible, but you have to check that for yourself. I haven´t had a chance to look into hemmingway.
it only depends on how you define your sidebars in the templates.
I’m using the hemingway theme, that incorporates blocks rather than widgets… (discussion board @ discuss.warspire.com )
Is it possible to incorporate king text etc.. into this?
Chris
you can use the before/after widget and title text fields under the HTML Options.
just insert a break or some other html.
Hi guys,
how I can place the title of text widget and the text on different rows? (I use your king text widget and put in it the UTW cloud). You can look what I mean on my blog.mobilet.ru – the very bottom widget on sidebar. There “Теги” is Titie, and cloud is php text.
whoops… i jumped here from wp widegtes page – i missed out on installing king framework!!!
Chris
help please??
Warning: require_once(D:\webworld\bantryyouth\bantryyouth.net\www\wordpress/wp-content/
plugins/king-includes/library/king_widget_functions.php) [function.require-once]: failed to open stream: No such file or directory in D:\webworld\bantryyouth\bantryyouth.net\www\wordpress\wp-content\plugins\widgets\king-text.php on line 360
thanx 4 the feedback, i had some probs with the defaults too, so this morning i recoded the widgets html fields so that they would use the presets from the functions.php (like the original widgets) if left empty.
Anyway, because the text widget is so versatile i took the defaults switch out.
But concerning the other widgets:
I might take the html fields out of my default setting switch, so that they are left empty when the defaults are choosen.
With such i can concetrate on the other default settings and will revise them too.
Please check out the new text widget version 0.63 + framework
I ran into a small problem with King Text.
The widget does not seem to populate many parameters with defaults. In particular, default WIDGET HTML code is simply blanked rather than being filled with default values. I’ve been able to work around this by manually inserting the values. The widget code assigns actually assigns these defaults initially, but never populates the form so that when the form is updated, the resulting fields are blank, and do not contain the default data.
I don’t have King Categories loaded now, but I think there’s a default location that triggers display that is supposed to be index.php that suffers the same fate.
Neither of these are serious problems, but I had to scratch my head a few times trying to figure out why the “default” values never showed up, and I have to manually enter everything rather than modifying a default when I use the widget. OTOH, these widgets allow me to do things I couldn’t do with any other widget, so I still gladly use them.
Really a great plugin, and greatly expands the versatility of widgets.
I’d like to give some users access to these, but I’m unwilling to give them the capability to use php in scripts unless I know that they know what they’re doing.
So, it would be nice to have a feature to set a minimum level for including php in any widget. Just a thought for the future.
In any event this is a really nice effort that is very much appreciated.
@Bob
This is not the problem of my widget:
you are missing the widgets plugin, or did not put the king-text.php in the same directory as the widgets.php (the widgets plugin)
i have this problem with king text:
Warning: widget_king_text_register(widgets.php): failed to open stream: No such file or directory in /var/www/sdb/8/9/moax/MOA/wp-content/plugins/king-text.php on line 281
Warning: widget_king_text_register(): Failed opening ‘widgets.php’ for inclusion (include_path=’/var/www/sdb/8/9/moax/include:.’) in /var/www/sdb/8/9/moax/MOA/wp-content/plugins/king-text.php on line 281
Here comes the brave knight …
1. you have to have the widgets plugin by Automattic installed first!
2. put my widgets into the folder you have your widgets in. (most likley plugins/widgets/..)
3. Put the Kings framework folder into plugins/king-includes
The king widgets in your case can´t find the widget.php wich belong to the widget plugin.
Oh my god, king plz help:
Warning: widget_king_categories_register(widgets.php): failed to open stream: No such file or directory in /home/../../../wp-content/plugins/king-categories.php on line 471
thanks for the feedback:
1. yeah i´ve thinking about that. Since the boxes are indentified by the name, kind of tricky. but actually a must.
2. no problem, i will increase it in the next version to 20!
Suggestion:
1.show customed title bit king text1 text2…,etc.
2.number of text box can be over 10.
Thanks, it is a good plugin~