WordPress Development: Adding Settings to Default Settings Pages

Published on Apr 16, 2009   //  Development, WordPress
Off

WordPress Development

Previously we have gone over adding your own settings page and menu items. However, what if you just have a couple of options that hardly warrant a dedicated settings page? If your plugin’s options are relevant to one of the default WordPress settings pages, then it’s possible to add your own options to them.

We can accomplish this in one of two ways. If you have more than one option, you can first create a section to house all these options. If you have just one (or maybe two) options, you can just add the fields. We’ll start out by taking a look at the add_settings_section() function, which will allow us to add a section to a settings page.

[code='php']add_settings_section( $id, $title, $callback, $page );[/code]

  • $id – Unique id for your section (don’t use any spaces)
  • $title – The title of your section
  • $callback – A function that will be run at the beginning of the section. Echo what you want to be there (such as a description of the settings)
  • $page – The settings page this section will be going on (possible options include general, writing, reading, etc)

We’ll now look at the function for adding fields to the settings page. For this we use the add_settings_field() function.

[code='php']add_settings_field( $id, $title, $callback, $page, $section = 'default' );[/code]

  • $id – A unique id for this field
  • $title – The title of your option
  • $callback – The function that will echo out the input field for this option
  • $page – The settings page you want this option to appear on (eg. general, writing etc)
  • $section – If you’ve setup your own section, name the id of it here, otherwise use default

Once we have our fields done, we need to register our options. We do this so that WordPress will handle updating the option in the database once the user presses submit. For this we’ll use the register_setting() function.

[code='php']register_setting( $option_group, $option );[/code]

  • $option_group – A group for all your options. Give it a unique name, no spaces.
  • $option – The name of the input for your option.

These functions will need to be hooked into the admin_init hook. Let’s take a look at a quick example where we add an option to the General settings page.

[code='php']function banana_service_init() {
add_settings_field( 'banana_service_key', 'Your Banana Service API Key', 'banana_service_key_form', 'general', 'default' );
register_setting( 'banana_service', 'banana_service_key' );
}
add_action( 'admin_init', 'banana_service_init' );
function banana_service_key_form() {
echo '
';
}[/code]

There you have it, an option field added to the General settings page.

Apollo Server Issues

Published on Apr 15, 2009   //  Network Issues
Off

Data Center

Once the planned maintenance by the data center was completed we noticed that there was a problem with the Apollo server. The server is currently being worked on and we will update this post with more details as we have them.

There is a staff member on site who will be working on the issue until it is fixed.

We appreciate your patience and understanding.

UPDATE 16/04/2009 2:30 AM : Hard Drive was found to be dead. New drive installed, Os reloaded and cPanel is at 10% install. Next step is to restore accounts from our backups. ETA 12 hours.

UPDATE 16/04/2009 10:25 AM: Backup restores are about 50% done. We are seeing some backups that were corrupted so restoring from older backups. If you have more recent files we suggest you update them through FTP. ETA 2 hours.

Everything PHP: GET

Published on Apr 15, 2009   //  Development
Off

Everything PHP

At some point during your daily web surfing, you may notice some strange characters in URL you’re visiting. Characters such as ?, & and =. The most common place you’ll see these “attributes” are during a Google search. This is another method of passing data between files.

This method is called GET and uses parameters in the URL to pass data. This makes it less secure than POST, which is why POST is generally used for registration and login forms. Although GET is less secure, there’s no reason to avoid it in cases where security isn’t an issue (passing search terms for example). A rule of thumb for choosing whether to use GET or POST, is that GET is for retrieving data, while POST is for sending/writing data.

Another advantage of GET is its ability to be able to linked to. This makes it perfect for search queries, statistical tracking and small options (such as YouTube’s loop URL parameter).

GET requests are setup easily. It’s basically the parameter, followed by an equals sign, followed by the parameter’s value. The first parameter is preceded by a ? and additional parameters are separated by an &.

GET parameters can be accessed via the $_GET superglobal. Like the $_POST superglobal, this is an associative array of the GET parameters (the key is the parameter name, while the value is the parameters name). Because you can’t guarantee that any of the GET parameters will be in the URL (it is easily modifiable by the user after all), you should always check if they’re set, using isset().

When using the GET method with a form, the parameter names will be the names of the input fields. You can see a (simple) example of GET here

WordPress Wednesday: Nofollow for Tags and Categories

Published on Apr 15, 2009   //  WordPress
Off

The task of search engine optimization is dynamic and multi-faceted. There are many different tactics that you can employ to improve your rankings in the search engines. Many bloggers are already familiar with the “nofollow” attribute that prevents the “leaking” of your “link juice.” Yes, these are all technical terms.

When considering the “nofollow” attribute for links, most people only consider outbound links. They may choose to use “nofollow” on some of the links that they have pointing toward external sites, but it is also important to consider your inbound and internal links as well.

Rather than allowing your category and archive pages to receive largely unnecessary search engine power, it is better to keep that “link juice” pointing toward your core content and homepage. While you could certainly add the “nofollow” attribute manually each time you link to a category or archive page, using a simpe plugin is a lot more convenient.

The aptly named Noindex/Nofollow Links WordPress plug-in does exactly this. It will automatically add the “nofollow” attribute to any link on your website that points toward an archive, tag, or category page. From the settings, you can choose whether or not to add the “noindex” and/or “nofollow” attributes to these kinds of links.

For more information and to download the Noindex/Nofollow Links plugin, check out the official page on WordPress.org.

Tazzu Technology Networking Event

Published on Apr 14, 2009   //  Events
Off

What’s a Tazzu? If you have anything to do with tech in Vancouver then you have come across Tazzu. If not then Tazzu is a community setup to help tech companies network both online and face to face. The members are either a business or employees that are in the tech industry in some form or other.

If you have never been to a Tazzu event mark this one down on your calendar. The topics are always fun and food great when Tazzu is involved.

When is the event happening?
Wednesday, April 22, 2009 6:00 PM - 9:00 PM

Where is it happening?
The Black Frog108 Cambie Street – Vancouver

Registration
To register for this event you need to post here.

Business 101: Short-Term Loss, Long-Term Gain

Published on Apr 14, 2009   //  Business Topics
Off

This recession is exerting its effects on a number of different industries, and the pet supply industry is no exception. I remember hearing a story a while ago about how PetCetera was working to liquidate a lot of its inventory, because the company simply did not have enough cashflow coming through to pay its bills and to deal with its creditors. According to the story, this clearance sale would result in some products being sold at up to 70& off.

I’m not entirely sure how much truth there is to PetCetera’s situation, but this is probably a strategy that is for the best for the long-term viability of the company. From what I’ve heard, by putting out this sale and cutting deep into its profit margin, the pet supply store is able to generate some cash flow and this added liquidity is exactly what it needs to ride out this economic storm. Without the infusion of cash, the company may have to lay off many employees, cut expenses elsewhere, and possibly even file for bankruptcy protection.

As you look to your business and how it is going to survive the downturn in the current economy, you may have to consider the strategy of suffering a short-term loss in order to better your chances at a long-term gain and success. You may take on the same strategy of PetCetera, for example, if your short-term concern is related to issues of liquidity. If your short-term concerns are of a different nature, however, a 70% off sale may not be the best strategy, even if it result in added business. If each sale is below-cost, you’re looking at a negative proposition.

Has your company been adversely affected by the recession? What tactics have you employed to ensure the long-term viability of your business?

Page 6 of 11« First...45678...Last »