Monthly Archives: December 2009

Multi Widgets

Creating Multi Widgets just got easier.

There are some good sites which explain this with some example code. Some good examples are available at: http://wpengineer.com/wordpress-built-a-widget/ If you do want to try out the example on that page you’ll need to do a couple of things.

Create a new folder under your ../wp-content/plugins .
Create a new file to save it in.
Add the Plugin Header – The example on the page doesn’t show one – it’s an example!
Add a registration function to keep things happy. What is there won’t work – or it didn’t work for me so needed this addition.

Now this example code worked after I performed the changes above ( Yes I am going to describe them in a moment!) . As it is an example – you are going to have to make some decisions on what you are going to call it etc.
Step 1.

Now as this is an example of a Multi Widget – I created a folder called multi-1 ( when I’m experimenting/Developing – I always put my plug-in code in Folders ).
Step 2.

Next is to copy and paste the sample code into a file – again I called this multi-1.php and this lives in the previously created folder with the same name.
Step 3.

Add in the following Plugin Header – Remember this is an example bit of code we are just seeing what it does…So some of the info doesn’t matter. The one that does is the Plugin Name.

Plugin Name: Multi -1
Plugin URI: http://www.somewhere.com
Description: Example of a Multi Widget
Version: 0.1
Author: Multi-1
Author URI: http://www.somewhere.com

The important line here is Plugin Name: Multi -1 as this is what you are going to see in your Plugin page – the plugin name called Mutli-1 – so you can find it to activate it. That always helps.
Step 4.

Add the additional registration code. This is a snippet of the original code from the example.

} And this is the code with the added function.

add_action(‘widgets_init’, ‘My_RSS_Widget_init’);
function My_RSS_Widget_init () { 
 register_widget(‘My_RSS_Widget’);
} 

Again this is just one way to achieve this...

The bit we changed is...

add_action('widgets_init', 'My_RSS_Widget_init');
function My_RSS_Widget_init () {
 register_widget('My_RSS_Widget');
}

So after you've done all that, you can go into your Plugins panel and activate the plugin called Multi-1 . Then go into Appearance -> Widgets and install a few instances of Multi-1. One thing I did check was the table - wp-options - to see what the new entries were. This new wp_widget class takes care of the creating and destroying of each widgets values. Which if I were to do this the old way.. I'd have to write the code to achieve the same thing. This is where this Class really shines. So now I ( and you ) can get busy creating multi widgets and not worry about all the "housekeeping" code.
Just remember...

This new class only works with WordPress 2.8 and above. Can't say it works in the upcoming WordPress 3 as it's not around yet... Everyone should be running the latest versions of WordPress anyway so if they want to use your new Multi Widget - they'll have no excuses not too! Ok, I think that covers most of it.. If not, please leave a comment and I'll get back to you on it. What I have described here is exactly what I have done and it works a treat. So it's a very good "framework" to build upon. Have fun!

Thanks for your support in 2009

On behalf of myself and the rest of the team here at AWT,  I’d like to thank you for your support during the year.

It’s been a slow start in getting this website up and running. As you can imagine, there is a lot of information out there regarding WordPress and it takes time to learn it and then provide that information here for you. The aim is to make this a central location that will reference as much of the information “out there” as we can and add our own explanations to make things clearer when required.

And not  forgetting our contributors who help provide the content and keep me under control, a big thank you to you.

I’m out looking  for more contributors… If you are interested, just drop me an email.

Last but not least, to all those individuals and companies that have given so much information and guidance on their own websites, a big thank you. It’s the combined efforts of many that makes the internet the Rich information resource that it is.

If you have a “WordPress” related site, please drop me an email and I’ll get you and your site included on here. “Sounds like another plugin is needed..A Resource review Page.”

So again, have yourself a very Happy 2010 and we look forward in providing you with more great information and helping you get the most out of your WordPress Experience.

Cheers

Tim Brownlaw and the AWT Team.

Moving a WordPress Site to another server

Moving an already installed WordPress site to another server can seem a daunting task. This requires moving all Files and the Database from the old account to the new account.

Domain Name remains the same

If you are moving the site onto a different server and using the same domain name, then it’s a simple matter to export(backup) the site files and the Database and import them onto the new server. Made much easier if the hosting account has Cpanel.

Moving to a different URL

If the installed version is living on a domain that is different to the one it’s being moved too, then it gets a little more complicated.

WordPress Stores absolute URL’s inside the Database itself so if you change the sites URL, things won’t match up.

There is an easy solution.

The team over at Justcoded.com have come up with a little script that performs all the necessary changes for you. You can read more about that, and get the script from

http://justcoded.com/article/wordpress-tips-moving-site-to-another-server/.

I’ve not yet tried it, but I  will because I’ll soon be moving some of my development sites I have installed on my onto some of my hosting accounts. Plus I’m sure some of my students will want to do the same thing at some stage.

Thanks to the “JustCoded” Team for providing this and some other useful tips on their site.

(I’m not affiliated with JustCoded – I just like what they have done. So if you do get to use them for any projects, I don’t get anything in return.)

Is wp_register_widget_control being deprecated?

I’m reading here and there on a few WordPress Codex pages that this function along with it’s mates is going to go the way of the Dodo bird. That’s my interpretation and not a quote.

While that’s fine, the replacement functions – in this case -  register_widget_control,  do not seem to  have the same functionality!

Which makes me wonder… Is there some undocumented way to achieve the same things using these “recommended” functions? Are they frowned upon?

This was noted in a blog I was reading regarding creating Multiple Widgets which also noted that the WordPress Widgets API has a heading for this with a few words but nothing more…

And here I am quoting from http://codex.wordpress.org/Plugins/WordPress_Widgets_Api#Widgets_-_One_or_many

Widgets – One or many

Widgets can be coded so that they can exist one time or they can exist multiple times. WordPress is doing the work for you to instantiate your Widget multiple times if you follow some rules.

And those rules are…… lots of white space on a webpage. Hmm, I must need new glasses or get some fancy filter for my LCD to show “Secret WP Stuff”!

So do I use the ‘wp’ versions and be able to achieve what I want, or do I follow the recommendations and just say “Sorry, I can’t do anything useful like I want to”?

Well, I’m up for the challenge and as long as these “not recommended” functions are there,  I’ll use them. It’s certainly vague, at best, as to what the WordPress Coders have in mind!

The worst thing that can happen is everything breaks! Hmm , I’ve never experienced that before!

Let’s see if  I can get my head around this Multi Widget stuff!

Of course there are other ways to “Skin an animal” – preferrably not a cat!

Addition: I’ve just found that in the resources on the wordpress codex page is the link to the site I’ve been referring to.

You can also Check out the party they had Dec 2009.

Update

Well I have found the reason! The reason is that from WordPress 2.8 and beyond,  multi widget functionality has been implemented using a new class called WP_Widget.

This is explained in the post – Mulit-Widgets

Cheers

Tim

WordPress 2.9 is available.

18th December 2009, WordPress 2.9 has been unleashed upon the world.

It wasn’t that long ago that I was installing WordPress 2.7 on my sites. Which I might add, was when I was woken from my WordPress Slumber.

I think the last time I had used WordPress was way back when version 2.3.1 was around. What a difference a few versions make. WordPress 2.7 was magic. The admin panel was simplified and it all just worked.

Then along came 2.8 and now 2.9 is amongst us. One thing this shows is there is a lot of serious work going on. The gang are madly working away on 2.9.1 to correct some issues which is a very good sign.

Those issues being the breaking of the PHP Curl extensions. Read more at http://wordpress.org/development/2009/12/wordpress-2-9-1-beta-1/. Again they are busy resolving that issue plus a few minor ones.

I’ve been having a bit of cruise around the internet to see what others think of WP 2.9 and there are some interesting sites on the subject.

This one in particular – 10 Things You Need To Know About WordPress 2.9 is a very good review on the new features in WP 2.9. It’s well worth a read.

I know that it’s been at least since 2.7 that everything could be done from the admin panel ( correct me if acai berry purchase I am wrong).

So you can easily install new Themes and Plugins from the comfort of your sites dashboard (wp-admin). So you could easily just start off from scratch and get your themes and plug-ins you need quick smart without having to work too hard. The only danger is all the new themes and plug-ins you’ll come across each time as new ones are being added all the time.

So if you do have at least 2.7 (again I could be wrong) upgrading is now a breeze! I’ve still got a few sites with the “OLD” Dashboard which I’ll have to upgrade the painful way. Well I’m hoping it’s not, and get everything up to speed.

WordPress is certainly coming into it’s own and you can’t really call it a blogging script anymore. It can do whatever you want, just about, and what it can’t do – yet, you can make it do it. Well, hopefully I’ll get my tutorial sources up on this site to show you how.

Have a Happy New Year. Not many sleeps to go now.

Cheers

Tim

Admin text editor issue

There is an issue with the Administrators Text Editor used for typing away just like I am here.

The acai berry cheap problem is when you switch from HTML view to the Visual View, three (3) div tags appear at the end of the entry.
This causes the page to break out in a real mess and requires switching back to HTML view and deleting these div tags.

Adding the Author’s Biography to their posts.

Now that I’m getting a few fellow WordPressers contributing to this site, it’s only fair that I let them bask in their glory but displaying their BIO information on the page.

Instead of me re writing what is already there… Here is the link to the site I found this on.

acai berry buy target=”_blank”>http://outthinkgroup.com/2009/01/16/wordpress-tip-how-to-add-author-biography-information-to-your-posts/

I’m just about to implement this myself…

Ok that wasn’t too painful at all.

Basically you can copy the CSS on the site and paste that in your themes Style Sheet. Although it is a good idea to check that the class for .author_bio doesn’t already exist.  It’s a good habit to check these things – never assume.

Next, take the snippet of HTML with the WP tags and paste that into your single.php file. The site clearly explains where to put it.

If you get stuck – ask in the comments.

Now I have to go and update my BIO so it shows something useful.

Added check!

This is where we could add in something to make this a little more useful. That being the case where the author doesn’t have a BIO entry.  It’s probably best to show nothing or put in some witty comment to help remind them they had best put something in there. But that’ll happen later when I get a moment. For now it’s on my todo list.

Calendar

I like the simplicity and functionality of the Calendar plugin from Kieran O’Shea. Out of the box it was a bit hard to read for my aging eyes though. I wanted the calendar on its own “Page” but with my fixed-width 2 column theme it appeared “squashed”.

I decided to make a template for the calendar page removing the side bar. As I have navigation in the header this still left my visitors a way back to any of my main pages. The result was much easier to read. A few tweaks to font sizing and colors to match it to my theme and it worked out fine.

I was able to set up recurring events and single events quite quickly. One feature I will look for in the future is the ability to temporarily “exclude” a date from the recurring schedule on a one-time basis to meet “real life” situations when things may be cancelled that day.

As all the events I set up begin with the new year it can be viewed here American Legion Post 79 after Jan 1, 2010 as it is currently saved as a draft page.

Overall I’m very pleased with this plugin.

Give it a go if you need a calendar.

Lou

CodeBanter AR Plugin

?>
Now that text, should be contained within the light gray area, but as you can see, the description text is stepping out of bounds. Anyway, let’s see what we can do to fix this.

The best place to start when “investigating” these situations is to work backwards. So let’s see what the generated code is. You can do that by right clicking on the page and selecting the “View Source” option then pick on some keyword to help locate it.

This is what we get…

It is quite busy for a simple form with lots of tables etc. While I could whinge about it not being a CSS layout, the short story is “Well it works…”

Ok, what can we see?

No dead people around, so it’s not any of those… but there are three css class instances being used.

The Plugin.

This is Codebanters Aweber/Getresponse Subscription form Plugin available from http://www.codebanter.com/projects/. It might be something you find useful, but of course there are other ways to implement a subscription form. It seems though that it doesn’t quite like my site.

Now I’m not out to rubbish this plug-in. The fact that it’s broken on my site is probably due to my “not having” or” having” done something. So we are just looking at it from an instructional point of view. I’m fixing it so I might as well write about it too!

Don’t go busting out of my page.

As you may have noticed, the little newsletter subscription box up at the top right is “breaking out” off the page. For a Website on Advanced Worpress Tutorials, this doesn’t look good.
So let’s take a look and see what the problem is.

What’s the problem?

In a nutshell…. this is…. (I’m just firing up “The GIMP” to take a screen shot.)

codebanter_pagebreakout

CodeBanter Breaking out of the page

Keep in Touch!

So we have, dbx-box widget_recent_entries, dbx-handle and dbx-content.

Now, I wonder if they are defined anywhere? One rule of thumb is to wrap any thing that’s going to appear as a widget in the themes default settings. I know this firsthand from just having written my first plug-in ( to be documented later..). But this is also intended to be placed on a page/post so these styles have been included to allow you to change it’s appearance. Which is great if you know CSS!

So hunting through the files it appears that we have to define these styles ourselves. Which means adding some CSS to our themes CSS file.
That isn’t a bad thing, it’s just a bit of extra work we have to do and in fairness, most AR forms require some tweaking.

So let’s tweak!

After having a deep look at this I found two things..

  1. The long word of “AdvancedWordpressTutorials” exceeded the allowed width causing the breakout. So that just required the breaking up of the word by putting in spaces.
  2. The default style of the heading is dull and boring, so I defined an entry for .dbx-handle by adding it to the bottom of my theme’s style.css file. (described below)
 .dbx-handle {
color:red;
text-align:center;
font-weight:bold;
}

Summary

Hopefully this has shed a little light on how to find out why things break and how to fix them. This is not very detailed, mainly due to my solving and writing at the same time ( well now it’s documented ).