I had always wanted to try my hands at writing a WordPress plugin but with the vast variety of plugins available, there appears to be little need for yet another plugin developer. Until I saw the list of wanted plugins by Lorelle. I decided to pick on the easiest plugin – Blog Status Announcement or Alert.
Feature List
- easily switch on and off through Admin Options
- display message without editing theme files (above 1st post or through widget)
- display different message to different roles/users
- timer to switch on and off announcement (only in WP 2.1 and above)
- works on WP 2.0-2.7
Screenshot

Installation
1. Upload plugin folder and activate plugin
2. Go to Admin Panel > Options > Genki Announcement.
Announcement Status
- Show above first post (requires the_post() function in theme, most themes should have this)
- Show in Widget (requires Widgets Plugin)
- Show where I insert the <?php genki_announcement ?> template function (requires editing of theme)
Message
- Single message for all roles/users
- Different message for different roles/users (enter message into respective field)
Date to switch on & off announcement
- Format = YYYY-MM-DD hh:mm e.g 2007-08-18 13:59
- Leave blank to turn off announcement manually
- This feature only works in WordPress 2.1
Upgrade
1. Deactivate plugin
2. Remove genki_announcement.php file.
3. Upload genki_announcement folder to the plugins directory
4. Activate plugin
Changelog
Version 1.1
- Display above first post
- Display using widget
- Timer to switch off
- Display different message to different roles/users
- Remove css styling using .genki_announce class
Version 1.2
- Option to set border and background color of frame
- Preview of announcement message
- timer to switch on announcement (only in WP 2.1 and above)
- Gettext-able by Masayan
- Japanese translation by Masayan
Version 1.3
- tinymce added
- Turkish translation by Baris Unver
- French translation by Marie
- display announcement only once when using the option “Show above first post”. announcement may still show up in the wrong place but should increase the chance of this option working.
Version 1.4
- tinymce removed
- Fix: Different Message for Different Users/Roles feature
License
This plugin is released under the Creative Commons GNU GPL.
Download
Tips & Tricks
When I use the “Show Above First Post” option, the announcement appear in more than 1 place. How can I fix it?
When using this option, the announcement will show whenever The_Loop is called. One example is the Recent Posts widget. No solution for this yet. You can workaround this by using the “Show Where I insert the < ?php genki_announcement ?>..” and manually insert the function into your theme.
[For version 1.2 and below]I’m using the plugin in WPMU where security concerns are paramaount. I do not want my users to post javascript in the announcement box. How can I disable javascript?
In line 60, look for
stripslashes(get_option('genki_announcement_msgsubscribers'))
and replace with
apply_filters('comment_text', stripslashes(get_option('genki_announcement_msgsubscribers')))
Repeat for line 61-72, taking note the slight difference in genki_announcement_xxxxxx.
[For version 1.3]I want to be able to insert javascript into the announcement? How?
Go to line 282, and insert 2 additional lines of code (in bold) as below
height : "150",
extended_valid_elements :"script[charset|defer|language|src|type],noscript[class|dir<ltr?rtl|id|lang|style|title]",
entities : ""
});
Need Help?
Much as I want to provide free support, there are only 24 hours a day.
So if you need a chunk of my time, I’m available for hire.
What's Next?
»» Subscribe to Feed
» Leave a Comment
Related Posts:
» WP Plugin Update: Genki Announcement 1.2
» WP Plugin Update: Genki Announcement 1.1
» Localization of WP Plugin: Genki Announcement
» Newer Post: Facelift for My Blog
« Previous Post: OneNews feature update














hi, very nice idea. would it be hard to implement, let’s say five announcements with using different classes?
It will be easy if it’s the same announcement but 5 different announcements.. hmm.. beyond me for now. Unless I do hardcoding which isn’t the proper way
Thanks Genki. I was going to code up something just like this, but you saved me the trouble
Peace.
Glad to be of help
This is fabulous. Thank you.
I sure wish there was a way to make this work without interaction and editing with the WordPress Theme, like in a Widget or somehow hooked into the area above the first post, inside the header, or top of the sidebar. Widget might be easier.
That would make it easier for the people intimidated by editing their template files.
Still, this is fabulous. I’m going to test drive it and I’ll report back in. You are a star!
WOW! Thanks Ericulous! We’re gonna try this out.
We were trying a Sticky posting thing, but this allows little less work. Easier = better.
I hope I can give you some donation love once we get our adsense in!
Eric N.
Hello. Plug-in of “Announcement” of you is wonderful. Setting is also easy and is working in “WP 2.1.2″ perfectly. I am displaying “Announcement” on the page of the profile. Is because I want to use for Announcement to the member. There is wish to the future. This “Announcement” With one plug-in, the different message by the member’s permission can be displayed. For example, displays the message to the subscripter only on the subscripter. The message to Auther displays the message to Auther. In addition, the display to the guest is the display with the side bar. I think that applied width will spread considerably if such a thing can be performed. This is the one idea. Please take care about your health from now on, and get the wonderful success.
Eric N: glad you find it useful
Lorelle & ysjack: can’t promise everything will make it through but will do my best
Thanks for the follow up on Lorelle’s “list of wanted plugin”, its a useful plugin and thank you for your time and hard work.
Great plug in, or at least it sounds perfect for what we are trying. But I am having an issue with where to place the code. Ive tried all over in the theme Main Index file and it will not show up on the blog. Where exactly would I place it to put it right above the first post..
Thanks in advance… We are new to this and have stayed away from changing the actual code but we would LOVE to have this feature on our site.. any help would be great
Benoy: Thanks for the encouragement. I should also thank Lorelle for getting me started on Wp plugins
LoadingReality: look for the “if (have_posts())” and insert it before the php code.
Hey Eric, might want to add a feature that disables the announcement .. maybe a time thing. announcements aren’t too useful after a certain amount of time, and manually change it back takes a little bit of effort, but one way to get around this is to add a time field, which gets checked (wp-cron?) and disables the comment after the time passes…
just an idea!
eric
On my to-do list
Absolutely wonderful plugin =)
One quick question/suggestion, anyway to set the announcement to display above the first post on ONLY the main index.php (doesn’t matter if it displays on page 2 etc. but I don’t want it showing up at the top of individual pages)?
Sorry, not trying to spam you =) Figured out how to do what I asked for in the above comment.
Thanks for the great plugin!
Great detective work
Eric,
This is EXACTLY what I was looking for! Your a genius! Thanks for your time and effort with this plugin.
FYI it works on my K2 enabled 2.1.2 wordpress site. I installed it and set up a custom yellow POST-IT! look using the HTML options you allowed for (genius again!)
My only comment would be to include the access to the ANNOUCEMENT plugin UNDER the “WRITING” section instead of under the “OPTIONS” section, it makes more sense, to me at least, and would be easier to access.
I’m going to leave an annoucment up for the next couple of days in case anyone wants to see it in action.
J. Pisano ~MUSicTECHnology.net
http://www.mustech.ent
Ugh.. Left the wrong line. If you want to see it it’s here: http://www.mustech.net
Sorry!
Thanks for setting up the demo
I think I will leave it under Options as that’s the default place most users will look for after they install a new plugin. However moving it is not a problem.
Just change the code line no. 20 from
add_options_page('Genki Announcement', 'Genki Announcement', 8, __FILE__, 'genki_announcement_manage');to
add_submenu_page('post-new.php', 'Genki Announcement', 'Genki_Announcement', 8, __FILE__, 'genki_announcement_manage' );Genkisan,
Thanks, I appreciate it. Worked like a “charm”
Joe
It seems like everyone can get this to work except me!
I do appreciated the effort a lot, but is it really compatible with WP 2.1.2?
It’s driving me nuts.
SF
Hi Scudfish, more details will be good. Any error message? Or it just doesn’t show?
hi, friend. i did a test at home with wp 2.1.3. Works like a charm. But, when i did it on a real server with wp 2.1, i had problem on mac/IE 5.2. at the top my header, something shows like:
genki_announcement.php$mBIl
it is written there on the browser. any idea to fix it? thanks
again. thank you, thank you, thank you
love, light n laughter
oya, even worse on mac opera 6.3. it shows weird lines at the top header. something like:
?genki_announcement.php?????????????????????????????????????????????????????????????+??????????J?$???mBIN??????????????????l???????????????????????????????????????????????????????????????????????????????????????
your help is very much appreciated to make it crossplatforms. thanks
Just installed opera 0.92. Also did a test at http://browsershots.org. I can’t duplicate the error on my side so rather difficult for me to debug. More info will be good.
What are the settings and msg in the announcement options page? Are they the same settings at home?
Mind providing a link to your blog?
hi genki, thanks for quick reply. it’s just a testing site, not official yet, so i’am afraid i can’t give you a link yet. unless you google around of course.
it’s fine this morning. but just in case this happens to anyone, this is only triggered when you work between windows and mac.
i copied genki_announcement.php from mac into a flash disk, edited home on windows, moved it back to mac and edited there, and finally uploaded to server thru windows. and that other windows was stupidly infected by trojan. phew, ain’t that crazy work haha?
then those weird things happened. it messed the front and back end windows. to the extent, it even disabled some admin functions, like visual editor and more brought the site down. i rechecked the file from admin console, there i can see the problem. those weird characters are printed just before
Oops.. looks like comment got cut off. But I assume everything’s fine now
Hi,
I like your plug-in. How about allowing the user to define a style for a box in which the announcement appears. Eg I am upgrading something and want to let visitors know what to expect. In this case i would like the announcement to maybe have a red background and a red border around the announcement. Furthermore, how about using tinymce for the announcement field(s) to make editing easier.
Just some ideas
Cheers
Martin
I love the idea of this plugin but have one thing I don’t like. I use wordpress widgets and have the recent post widget activated. When I use this announcements plugin, the recent post widget also displays the text from the announcement. Is there anyway to not have it displayed in this widget? You can see an example of what I am talking about at http://www.bigskyfans.com
Thanks
hi martin, i think you ask too much, right genki:)?
to style the announcement you can simply hack the sidebar or any place where it appears with, e.g.:
there you have what you want. if you use widget instead, you have to style your widget thru functions.php, for instance, to deploy the same style.
good luck
gausarts
martin: good suggestion. will note them down for version 1.2 but no promise
chris: yea, this happen when the_post() is called multiple times. I dun have a solution right now (will keep looking). Meanwhile you can use the “Show where I insert the <?php genki_announcement() ?> template function” option.
Then insert <?php genki_announcement() ?>
after
<div id=”content” class=”narrowcolumn”>
in index.php
gausarts: still manageable
So I definitely have no problem with allowing HTML, but is Javascript and the like also allowed?
The reason I ask is because I need to know if this is usable on an WPMU installation, where the security concerns are paramaount.
You are right suleiman, javascript is allowed. You may wish to hack the plugin to restrict tags like those of comment text.
line 45:
echo stripslashes(get_option('genki_announcement_msg'));replace with
echo apply_filters('comment_text', stripslashes(get_option('genki_announcement_msg')));Repeat for line 51-63, taking note the slight difference in genki_announcement_xxxxxx.
Great plugin! I have implemented the template function and applied a style box including an icon.
However, when I turn the announcement off, a blank box displays on my page. What do I need to change in order to eliminate the blank box?
MJ, place your css styles in the plugin’s message
e.g
<style type=”text/css”>
.msgbox {
border:1px solid #f00;
}
</style>
<div class=”msgbox”>
message of the day
</div>
Thanks Genkisan. I will do that but I was thinking more of a conditional statement around the template function. Just don’t know enough about PHP myself to do so.
Oh.. the php way
I assume you are using the “Show where I insert the function tag” option.
<?php if (get_option(‘genki_announcement_location’) == 3) { ?>
<div class="mystyle">
<?php genki_announcement() ?>
</div>
<?php } ?>
Thanks for the code. Works great!
Terrific plugin, you did a great job on it.
Here’s what I’d love to see:
1) Preview window
2) Multiple announcements
3) Being able to set an start display time in addition to the currently available end display time
4) This would be killer: being able to set an announcement based on referrer
Item 1 & 3 should be doable
For item 4, you mean to based the announcement on bots?
Love this plugin! Unfortunately, it killed my theme.
The index page side bars are smooshed and moved around. Even after deactivating and fiddling… the index page is still messed up and I can’t figure our how it happened. Other than that, I like the concept.
You using the “Show above first post” option? Try the other options like “Show where I insert the …” option.
Teşekkürler güzel eklenti.(thanks beautiful plugin)
How about support for TinyMCE, so you can format your announcement without having to mess with HTML?
Peace,
Gene
Sorry, that feature din make it through this round.
I’ll be patient for the next version
Peace,
Gene
This rocks. You rock. Thank you for sharing and helping people out. I send you a virtual beer
Drowns myself in virtual beer
Hello Genkisan,
Does this plugin work with WP 2.6? Or do we need to wait for the new version?
Yes, it should work in 2.6
Hey thanks for this awesome plugin. I was looking for the right plugin to meet my expectation, and now my search ends here. I had to edit the php file to add my css, and removing the border since there was no other way of doing this in the admin settings (unless, I’ve missed it altogether??). It works for me, so I’m happy with it.
I salute to people like, who sacrifice and contribute their own time, to help out the community.
You are too kind, for your time.
Thanks a billion.
CHEERS
Thanks.
Thanks Genki! Works great in WP 2.7 Beta 2
Sorry for the double post! A feature request: Using cookies to find if user is a first-timer (and show a greeting/welcome message + option to subscribe to our RSS feed) or if he is regular viewer (and show a ‘welcome back’ message).
The plugin below might be more suitable.
http://richardkmiller.com/wordpress-plugin-what-would-seth-godin-do
Thanks, this was perfect for what I needed, simple and straightforward homepage announcement section.
I used the function tag insert. The one thing I did was go into the plugin file and remove the entire DIV tag that surrounds the inserted content. It was getting in the way. I found it easier to include all markup in the announcement box.
Maybe you could have the hardcoded DIV tag switchable, so there’s an option from the control panel for either a 100% clean insert, or a more friendly one where you can set stuff like border and background from the WP admin.
Anyhow, thanks!
很不错的插件,支持下!
http://www.90606.cn
Teşekkürler güzel eklenti.(thanks beautiful plugin)
Great widget…i will use it in my site
Thanks Genki. I was going to code up something just like this, but you saved me the trouble
Peace.
Nice plugin!
I will give it a try !
Is there a way to hyperlink the announcement?
Just use the normal html code e.g <a href="http://test.com">link</a>
hi, thanks for the plugin – works great. Only thing what troubles me is that it doesn’t seem to give the editor role access to the admin side. Any way to achieve this?
try changing the number ’8′ to ’5′ in genki_announcement.php line 35. More info on user levels.
add_options_page(__('Genki Announcement','genki_announce'), __('Genki Announcement','genki_announce'), 8
perfect! thank a lot.
i tried this plugin, works well with chrome but wont show up in firefox. i just see the widget title and a line. no announcement at all. any help?
thanks