Results 91 - 100 of about 12807 stories
CatsWhoCode on 16 January 2012, 9:03 am   Category: Blog

Text messaging with PHP using the TextMagic API

If for some reason, you need to send text messages to your clients cell phones, you should definitely have a look to TextMagic. They provide an easy API which allow you to send SMS to cell phones. Please note that the TextMagic service isn’t free.

The example below shows how easy it is to send a SMS to a cell phone using the TextMagic API:

// Include the TextMagic PHP lib
require('textmagic-sms-api-php/TextMagicAPI.php');

// Set the username and password information
$username = 'myusername';
$password = 'mypassword';

// Create a new instance of TM
$router = new TextMagicAPI(array(
	'username' => $username,
	'password' => $password
));

// Send a text message to '999-123-4567'
$result = $router->send('Wake up!', array(9991234567), true);

// result:  Result is: Array ( [messages] => Array ( [19896128] => 9991234567 ) [sent_text] => Wake up! [parts_count] => 1 )

Source: http://davidwalsh.name/php-text-messaging

Detect location by IP

Here is an useful code snippet to detect the location of a specific IP. The function below takes one IP as a parameter, and returns the location of the IP. If no location is found, UNKNOWN is returned.

function detect_city($ip) {

        $default = 'UNKNOWN';

        if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost')
            $ip = '8.8.8.8';

        $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)';

        $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip);
        $ch = curl_init();

        $curl_opt = array(
            CURLOPT_FOLLOWLOCATION  => 1,
            CURLOPT_HEADER      => 0,
            CURLOPT_RETURNTRANSFER  => 1,
            CURLOPT_USERAGENT   => $curlopt_useragent,
            CURLOPT_URL       => $url,
            CURLOPT_TIMEOUT         => 1,
            CURLOPT_REFERER         => 'http://' . $_SERVER['HTTP_HOST'],
        );

        curl_setopt_array($ch, $curl_opt);

        $content = curl_exec($ch);

        if (!is_null($curl_info)) {
            $curl_info = curl_getinfo($ch);
        }

        curl_close($ch);

        if ( preg_match('{<li>City : ([^<]*)</li>}i', $content, $regs) )  {
            $city = $regs[1];
        }
        if ( preg_match('{<li>State/Province : ([^<]*)</li>}i', $content, $regs) )  {
            $state = $regs[1];
        }

        if( $city!='' && $state!='' ){
          $location = $city . ', ' . $state;
          return $location;
        }else{
          return $default;
        }

    }

Source: http://snipplr.com/view/48386/detect-location-by-ip-city-state/

Display source code of any webpage

Want to be able to display the source code of any webpage, with line numbering? Here is a simple code snippet to do it. Just modify the url on line 2 at your convenience. Or even better, make a pretty function according to your needs.

<?php // display source code
$lines = file('http://google.com/');
foreach ($lines as $line_num => $line) {
	// loop thru each line and prepend line numbers
	echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
}

Source: http://perishablepress.com/code-snippets/#code-snippets_php

Check if server is HTTPS

Is my script running on a HTTPS server? Good question. This handy snippet can give you the answer. Nothing complicated at all!

if ($_SERVER['HTTPS'] != "on") {
	echo "This is not HTTPS";
}else{
	echo "This is HTTPS";
}

Source: http://snipplr.com/view/62373/check-if-url-is-https-in-php/

Display Facebook fans count in full text

Want to display how many Facebook fans do you have, in full text, on your blog? It’s very easy using the following snippet:

function fb_fan_count($facebook_name){
    // Example: https://graph.facebook.com/digimantra
    $data = json_decode(file_get_contents("https://graph.facebook.com/".$facebook_name));
    echo $data->likes;
}

Source: http://www.digimantra.com/

Determine the dominant color of an image

This code will be super useful for people managing images or photography website. With it, you can analyze any image and get its dominant color (R, G, or B).

$i = imagecreatefromjpeg("image.jpg");

for ($x=0;$x<imagesx($i);$x++) {
    for ($y=0;$y<imagesy($i);$y++) {
        $rgb = imagecolorat($i,$x,$y);
        $r   = ($rgb >> 16) & 0xFF;
        $g   = ($rgb >>  & 0xFF;
        $b   = $rgb & 0xFF;

        $rTotal += $r;
        $gTotal += $g;
        $bTotal += $b;
        $total++;
    }
}

$rAverage = round($rTotal/$total);
$gAverage = round($gTotal/$total);
$bAverage = round($bTotal/$total);

Source: http://forums.devnetwork.net/viewtopic.php?t=39594

Get info about your memory usage

In order to optimize your scripts, you may definitely want to know how many amount of RAM they use on your server. This snippet will check memory and then print initial, final and peak usages.

echo "Initial: ".memory_get_usage()." bytes \n";
/* prints
Initial: 361400 bytes
*/

// let's use up some memory
for ($i = 0; $i < 100000; $i++) {
	$array []= md5($i);
}

// let's remove half of the array
for ($i = 0; $i < 100000; $i++) {
	unset($array[$i]);
}

echo "Final: ".memory_get_usage()." bytes \n";
/* prints
Final: 885912 bytes
*/

echo "Peak: ".memory_get_peak_usage()." bytes \n";
/* prints
Peak: 13687072 bytes
*/

Source: http://net.tutsplus.com/tutorials/php/9-useful-php…

Compress data using gzcompress()

When working with strings, it is not rare that some are very long. Using the gzcompress() function, strings can be compressed. To uncompressed it, simply call the gzuncompress() function as demonstrated below:

$string =
"Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Nunc ut elit id mi ultricies
adipiscing. Nulla facilisi. Praesent pulvinar,
sapien vel feugiat vestibulum, nulla dui pretium orci,
non ultricies elit lacus quis ante. Lorem ipsum dolor
sit amet, consectetur adipiscing elit. Aliquam
pretium ullamcorper urna quis iaculis. Etiam ac massa
sed turpis tempor luctus. Curabitur sed nibh eu elit
mollis congue. Praesent ipsum diam, consectetur vitae
ornare a, aliquam a nunc. In id magna pellentesque
tellus posuere adipiscing. Sed non mi metus, at lacinia
augue. Sed magna nisi, ornare in mollis in, mollis
sed nunc. Etiam at justo in leo congue mollis.
Nullam in neque eget metus hendrerit scelerisque
eu non enim. Ut malesuada lacus eu nulla bibendum
id euismod urna sodales. ";

$compressed = gzcompress($string);

echo "Original size: ". strlen($string)."\n";
/* prints
Original size: 800
*/

echo "Compressed size: ". strlen($compressed)."\n";
/* prints
Compressed size: 418
*/

// getting it back
$original = gzuncompress($compressed);

Source: http://net.tutsplus.com/tutorials/php/9-useful-php…

Whois query using PHP

If you need to get the whois information for a specific domain, why not using PHP to do it? The following function take a domain name as a parameter, and then display the whois info related to the domain.

function whois_query($domain) {

    // fix the domain name:
    $domain = strtolower(trim($domain));
    $domain = preg_replace('/^http:\/\//i', '', $domain);
    $domain = preg_replace('/^www\./i', '', $domain);
    $domain = explode('/', $domain);
    $domain = trim($domain[0]);

    // split the TLD from domain name
    $_domain = explode('.', $domain);
    $lst = count($_domain)-1;
    $ext = $_domain[$lst];

    // You find resources and lists
    // like these on wikipedia:
    //
    // http://de.wikipedia.org/wiki/Whois
    //
    $servers = array(
        "biz" => "whois.neulevel.biz",
        "com" => "whois.internic.net",
        "us" => "whois.nic.us",
        "coop" => "whois.nic.coop",
        "info" => "whois.nic.info",
        "name" => "whois.nic.name",
        "net" => "whois.internic.net",
        "gov" => "whois.nic.gov",
        "edu" => "whois.internic.net",
        "mil" => "rs.internic.net",
        "int" => "whois.iana.org",
        "ac" => "whois.nic.ac",
        "ae" => "whois.uaenic.ae",
        "at" => "whois.ripe.net",
        "au" => "whois.aunic.net",
        "be" => "whois.dns.be",
        "bg" => "whois.ripe.net",
        "br" => "whois.registro.br",
        "bz" => "whois.belizenic.bz",
        "ca" => "whois.cira.ca",
        "cc" => "whois.nic.cc",
        "ch" => "whois.nic.ch",
        "cl" => "whois.nic.cl",
        "cn" => "whois.cnnic.net.cn",
        "cz" => "whois.nic.cz",
        "de" => "whois.nic.de",
        "fr" => "whois.nic.fr",
        "hu" => "whois.nic.hu",
        "ie" => "whois.domainregistry.ie",
        "il" => "whois.isoc.org.il",
        "in" => "whois.ncst.ernet.in",
        "ir" => "whois.nic.ir",
        "mc" => "whois.ripe.net",
        "to" => "whois.tonic.to",
        "tv" => "whois.tv",
        "ru" => "whois.ripn.net",
        "org" => "whois.pir.org",
        "aero" => "whois.information.aero",
        "nl" => "whois.domain-registry.nl"
    );

    if (!isset($servers[$ext])){
        die('Error: No matching nic server found!');
    }

    $nic_server = $servers[$ext];

    $output = '';

    // connect to whois server:
    if ($conn = fsockopen ($nic_server, 43)) {
        fputs($conn, $domain."\r\n");
        while(!feof($conn)) {
            $output .= fgets($conn,128);
        }
        fclose($conn);
    }
    else { die('Error: Could not connect to ' . $nic_server . '!'); }

    return $output;
}

Source: http://www.jonasjohn.de/snippets/php/whois-query.htm

Email PHP errors instead of displaying it

By default, most servers are set to display an error message when an error occured in one of your script. For security reasons, you may want to get an email with the error, instead of displaying it to the public.

<?php

// Our custom error handler
function nettuts_error_handler($number, $message, $file, $line, $vars){
	$email = "
		<p>An error ($number) occurred on line
		<strong>$line</strong> and in the <strong>file: $file.</strong>
		<p> $message </p>";

	$email .= "<pre>" . print_r($vars, 1) . "</pre>";

	$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

	// Email the error to someone...
	error_log($email, 1, 'you@youremail.com', $headers);

	// Make sure that you decide how to respond to errors (on the user's side)
	// Either echo an error message, or kill the entire project. Up to you...
	// The code below ensures that we only "die" if the error was more than
	// just a NOTICE.
	if ( ($number !== E_NOTICE) && ($number < 2048) ) {
		die("There was an error. Please try again later.");
	}
}

// We should use our custom function to handle errors.
set_error_handler('nettuts_error_handler');

// Trigger an error... (var doesn't exist)
echo $somevarthatdoesnotexist;

Source: http://net.tutsplus.com/tutorials/php/quick-tip…


WPCandy on 15 January 2012, 3:28 pm   Category: Blog

George Ortiz presented at WordCamp Birmingham today, and announced that PressTrends will be coming out of closed beta this week on Tuesday. The public launch will also bring the launch of a plugin for WordPress users that will offer statistics and analysis based on information gathered by all sites tracked by PressTrends. PressTrends has been in private beta since November, serving statistics to selected theme authors and shops.

Based on the brief demo Ortiz gave (see the photo below) the upcoming plugin will track a site’s posts, comments, and active plugins. Based on performance, Ortiz said, he hopes that the stats will be able to offer bloggers tips for how to improve the number of comments and success that bloggers see.

Currently PressTrends works with only theme authors and theme companies, but as of the plugin’s release on Tuesday they will begin to gather statistics on how users are using their WordPress sites as well. The example of the plugin that Ortiz demonstrated (pictured just after the jump) showed a breakdown of the number of posts, comments per post, and plugins in use compared to the rest of the tracked PressTrends community.

The PressTrends API, Ortiz said, will also allow theme developers to track custom variables like theme options and shortcode usage, for example. Many themes nowadays will integrate a lot of shortcodes, and using Ortiz theme authors can discover just how many users are actually dropping them into their content.

According to Ortiz, by the end of the day today 5,000 websites will be sending back data to PressTrends. One thousand new sites are sending data to PressTrends each week since the beginning of the year. He said that over 100 themes have integrated PressTrends reporting with their themes from providers like WooThemes, and the Mojo Themes marketplace will be rolling it out to their theme authors soon too.

In addition to themes, plugins will be trackable by PressTrends. Ortiz talked more about this in a blog post published not long after his presentation:

Yup, we’re adding plugin support. We’re really excited about this as this will allow developers to get aggregated insights and how their plugins are performing. Granted, plugins do a wide range of functions, they way those functions are implemented can be aggregated. We’re also including support features that will allow developers to provide better support for users based on new metrics.

For the theme and plugin developers: what kinds of statistics would you like to learn about the way your users are using your themes? Will you be signing up for PressTrends once it comes out of private beta? For the users, what would make you interested in trying out another statistic/analytics plugin?

You just finished reading PressTrends out of beta Tuesday, releasing plugin for users on WPCandy. Please consider leaving a comment!


WPCandy on 15 January 2012, 3:17 pm   Category: Blog

Nathan Ingram shared a chart at his WordCamp Birmingham workshop session, literally minutes ago, of many of the available WordPress backup solutions, their features, and their prices. It’s really quite handy. Ryan and I have been here all weekend (well, I actually live here) and it’s been a great time. This is one example of the great things people put together when they go to WordCamps.

You just finished reading Nathan Ingram shares his WordPress backup comparison chart on WPCandy. Please consider leaving a comment!


Sayulita 3 weeks ago.

Matt Mullenweg on 15 January 2012, 2:55 pm   Category: Blog

First full day at the Automattic Janitorial meetup in Sayulita. All taken with a NEX-7.

DSC00283 DSC00285 DSC00286 DSC00287 DSC00288 DSC00290 DSC00291 DSC00293 DSC00294 DSC00295 DSC00298 DSC00302 DSC00308 DSC00309 DSC00312 DSC00315 DSC00317 DSC00318 DSC00320 DSC00321 DSC00323 DSC00327 DSC00328 DSC00333 DSC00334 DSC00335 DSC00337 DSC00338 DSC00340 DSC00346 DSC00348 DSC00350 DSC00352 DSC00353 DSC00356 DSC00359 DSC00360 DSC00361 DSC00362 DSC00363 DSC00366 DSC00367 DSC00368 DSC00369 DSC00370 DSC00371 DSC00372 DSC00374 DSC00379 DSC00383 DSC00385 DSC00386 DSC00387 DSC00390 DSC00391 DSC00392 DSC00393 DSC00394 DSC00395 DSC00396 DSC00397 DSC00399 DSC00400 DSC00401 DSC00402 DSC00403 DSC00404 DSC00405 DSC00406 DSC00407 DSC00408 DSC00409 DSC00410 DSC00411 DSC00412 DSC00414 DSC00417 DSC00420 DSC00421 DSC00422 DSC00423 DSC00424 DSC00428 DSC00430 DSC00434 DSC00435 DSC00436 DSC00437 DSC00443 DSC00444 DSC00445 DSC00446 DSC00447


Matt Mullenweg on 13 January 2012, 1:31 pm   Category: Blog

A surprisingly candid and funny report from CES, Fever Dream of a Guilt-Ridden Gadget Reporter.


Weblog Tools Collection on 13 January 2012, 8:00 am   Category: Blog

Since its launch well over a year ago, WP-Snippets has quickly grown into the most popular one-stop-shop for useful WordPress code snippets.

WP-Snippets has finally received a major upgrade, making it even easier for you to find the code you’re looking for. The various snippets have now been broken up into categories, and more words can be filtered to narrow down the choices to just the snippet you need. If you find one that you’re particularly fond of, you can now favorite a snippet to leave it on the front page when you come back to the site. Speaking of the site, it now has a fully responsive design, so it looks great on your mobile phone when gathering snippets on the go.

If you’re a fan of WordPress and have a few snippets to share on WP-Snippets, there is also a new contribute page to satisfy your urge to share your knowledge.

There are tons of snippets available at WP-Snippets, so dive in and see what you can find, or help out by adding tons of your own.


WPCandy on 13 January 2012, 7:50 am   Category: Blog

One thing I spend some amount of time thinking about each week is managing my multi-author blog at WPCandy. There are only a handful of authors that have joined WPCandy in the last year, but we’ve still spent a good deal of time improving our workflow as a multi-author blog. I’ve even picked up a few (what I would call) tips in the process.

If you find yourself in a similar position, hopefully some of these tips will help you along. If you run a blog with a number of authors, be sure to jump down into the comments and share your experiences too.

Establish a team blog

If you want your team to feel like, well, a team, they need a place to come together and chat about what they’re working on. One hundred percent of my team of contributors is distributed all over the planet, so if we didn’t have a team blog of some sort we all wouldn’t have as many chances to talk.

I’ve opted to use the P2 theme from Automattic, because like many others I think it fits nicely between the traditional blog and a chat room. I’d recommend setting up a private P2 instance at a sub domain of your site, like at team.yoursite.com, and making sure that everyone on your team is always able to use it.

In addition to P2, I’ve found that using Subscribe to Comments and Subscribe2 cover our bases when it comes to post notifications. This is also just a matter of preference, but I like to keep a list of useful links in the sidebar of the P2 blog along with a list of all the authors on the blog.

Of course you don’t have to use P2. The key is to have a location where your team can easily chat about what’s going on. Do whatever works best for your particular group.

Establish proper author/editor capabilities

This one will highly depend on your needs, but in my case I’m kind of a (what’s the word?) control freak. Because of this I still personally edit every word that gets published on WPCandy, so authors on WPCandy don’t have the ability to publish but can only submit posts for review.

There are a couple of ways to do it, but I opt to manage capabilities using Members by Justin Tadlock. Really I haven’t done much more than remove the publish capability from authors.

Just as important as the technical side of things is making sure that roles and abilities are known by your editorial team. Make sure everyone knows what’s expected of them and what they can do on their own, either using a team blog (see above) or help text (see below).

Use Edit Flow

I tried the Edit Flow plugin around a year ago, and just didn’t think it was quite there yet. I’m happy to say that wherever the aforementioned there is, Edit Flow is squarely in the middle of that location. The developers, led by Automattician Daniel Bachhuber, released version 0.7 this week and it brought some features that really got me excited to use it—features like a drag and drop editorial calendar:

In short, Edit Flow is a plugin that gives your WordPress Dashboard a newspaper-like editorial workflow. Along with the editorial calendar I mentioned above, Edit Flow gives more granular control over post statuses (like Pitch, Assigned, and Changes Needed in addition to Draft and Pending Review), enables author-only editorial discussion of posts as they come together, and  allows authors and editors to be notified when changes are made to posts.

Before Edit Flow the WPCandy team was using a ticketing system—on a sub blog using WooThemes’ FaultPress, actually—but the changeover was worthwhile. The old system, while it worked, also required a layer of translation between the ticketing system and WPCandy itself. When a post was started in one place, a ticket in another place had to be updated. Notes for the post (sources, contacts, etc.) had to be pulled from the ticket and used to write the post. And when a post was published, the ticket elsewhere had to be updated again.

Kind of a mess, right?

There’s nothing wrong with FaultPress, of course. Edit Flow is just perfect for multi-author blogs because it streamlined this process so that it all happens in one place.

Author checklist for post submissions

This is one of those tips that is useful not only for your site’s authors, but likely for yourself (at least it was for me). As you edit and publish content on your blog, pay attention to the steps you take over and over. If there’s a way to streamline those steps, such as setting a new default category to better represent the majority of your content, then definitely do that. But for other things it’s worth maintaining a checklist.

I’ve resorted to posting the checklist to the team blog or our help section (see below) but I’ve also see options like Blogging Checklist before. I haven’t tried it myself, but it could be something useful if your authors need to run down a few key steps for every post they write.

In general, though, communicate best practices to your authors to make the editing process (and hopefully the writing process, in the long run) as efficient as it can be.

Proper author attribution

If you have other authors on your blog it’s important to give them credit where it’s due. You want them to know they are receiving proper credit for their work, but it’s also important to make sure readers know who they’re reading.

Bylines are the most important thing to get right here. As an author, seeing your name presented prominently next to your work is important. It’s important at such a basic level, really, that it’s weird to mess this one up.

And as a reader, I can’t tell you how disappointed I end up being when I find out a post I’m looking at doesn’t have proper author attribution. I want to know who I’m reading just as much as what I’m reading.

If you wonder exactly how you should pull this one off, a good rule of thumb is to put other author’s names in the same place you’d put your own. In addition you might consider an area, perhaps beneath the post, where more information about the author is given. We have used these on WPCandy for a while and they tend to work pretty well.

One of my favorite social WordPress plugins is WordTwit from BraveNewCode. WordTwit is a handy plugin that will tweet out messages (either automatically or manually generated) when you publish new posts. In a recent update they made it really easy to automatically mention the author’s Twitter name in the tweets, and we’ve started using that here for the bulk of our posts. For a site like ours, where a lot of our community and traffic comes from Twitter, I think it’s important to give credit to post authors there too.

Set up author emails

This isn’t something you can set up within WordPress itself, but believe me when I say it will make your multi-author blog all the more professional. I prefer using Google Apps to run my domain-specific emails, and I highly recommend it, but honestly use whatever you have to and get that done.

Not only will having theirname@yoursite.com give your authors a sense of ownership in the site, but it will make their emails with people for your site all the better.

Share a group RSS subscription

I talked before about the number of RSS feeds I follow to keep up with WordPress company and project blogs. It’s quite a few. One small but helpful way to make the process of tracking new and interesting stories a bit easier is to open it up to the rest of your team and allow them to review potential story ideas too. This one will take a good deal of trust in your authors, but it can really be worth it once you have more than a few feeds/sources that are updating daily.

For the group RSS account I use one of my Google Apps emails set up with a Google Reader account. I have intended to move the various Twitter accounts I follow into one that the whole team can use, but I just haven’t gotten to it yet.

Maintain author help texts

You can establish this copy anywhere you like, really, but I prefer to keep as much within the bounds of the WordPress Dashboard as I can. It keeps things simpler and, to be honest, I just like it better.

So I really like WP Help, a plugin by Mark Jaquith that lets you keep help text for the authors on your blog.

There are other ways to maintain this sort of information, but this one’s my favorite. In our help section we try to keep things like:

  • what to do as a new author on the site,
  • tips for writing posts,
  • how to use our taxonomies properly,
  • the types of images we generally like to use,
  • WPCandy logos that authors can use, and
  • how to modify the parts of the site they can modify.
I find these documents most helpful when it comes time to bring a new author on board. As long as things are up to date, I have to do little more than direct them over to the help section to get them rolling as a contributor.

How about you?

There are undoubtedly more things to consider when running a blog with more than one author. I’ve based these tips only on my own experiences, which aren’t even that expansive. If you’ve run a multi-author blog (using WordPress or even something else) please jump down to the comments and share your experiences and tips.

You just finished reading How to manage a proper multi-author WordPress blog on WPCandy. Please consider leaving a comment!


WordPress.com on 12 January 2012, 5:40 pm   Category: Blog

Today we’ve got a new theme for you that is so fresh and clean that it’s called…Fresh & Clean. Designed by AJ Clarke, Fresh & Clean is a responsive, spick-and-span theme that lets you put your best content forward with minimal frills.

Fresh & Clean utilizes Featured Images to help you to easily transform your blog into a stylish online portfolio. There’s a featured slider on the front page that highlights Sticky Posts that have large Featured Images. All other Featured Images appear as prominent thumbnails next to their respective posts.

Not looking to build an online portfolio at this time? No problem, Fresh & Clean is great as an all-purpose blogging theme! Take a moment to read more about Fresh & Clean and its features on the Theme Showcase.



WPCandy on 12 January 2012, 12:47 pm   Category: Blog

WooThemes developer and sometimes-WPCandy-contributor Matty Cohen wrote a post explaining how to get started with WordPress’ transient API. The codex describes transients as “very similar to the Options API but with the added feature of an expiration time”, and developers can use them in a number of different ways.

You just finished reading Matty walks through the transient API on WPCandy. Please consider leaving a comment!


WPCandy on 12 January 2012, 12:35 pm   Category: Blog

On the 29th episode of the WPCandy Podcast we talked about the sometimes poor state of plugin user interfaces. Many WordPress plugins are inconsistent with the native WordPress user interface in how they implement settings in the administration area for users.

I’m writing this guide to outline a (completely unofficial) set of best practices for implementing settings pages that is consistent and current with the native WordPress administration user interface. I’ve based these guidelines on my observations and experiences with using plugins in WordPress. They’re also totally a work in progress—if you have suggestions, feel free to add them in the comments section.

Navigation

When utilizing the Settings API it is important to place the link to your plugin’s settings page appropriately, otherwise a user with even a moderate amount of plugins installed can get confused about where each settings page is.

As a general rule of thumb, unless your plugin adds significant functionality to WordPress, it should sit as a secondary item under the general “Settings” panel. If you aren’t sure what significant functionality means, ask yourself if your settings page has multiple pages and/or includes options to manage or view content that a user will need to navigate to often. These are only guidelines, of course, and answering “yes” to any of these questions does not mean that your plugin needs its own top-level entry.

Proper placement of navigation.

Above you can see two plugins that following this guideline correctly. The form plugin adds a new type of content, with settings to view and manage all that content. The plugin appropriately take a place as a top-level menu item. The caching plugin’s developer correctly determined that the page would not be accessed often enough to call for a top-level item.

If you do choose to include your plugin’s settings as a top-level menu item, you should consider where in the list it will go. The side panel is loosely divided into two sections: content management (top) and settings (bottom.) Where you put your panel should depend on what category it falls under. Placement within these sections is at the plugin author’s discretion, though it is probably best not to place your panel in a spot that disrupts the location of commonly used panels such as the Posts Screen. This can mean placing the panel above or below such items, depending on what section you’re in and what you’re trying to avoid.

Improper use of colored icons

When setting up your admin menu icon, keep in mind:

  • All icons should stay monochromatic gray until the user hovers over the panel. This is easily the most overlooked design convention of the side panel. Being the only colorful spot on the sidebar draws undue attention to your settings panel and distracts users.
  • If you choose to display a colorized version of your icon on hover, try to use the same color palette that the other icons do. Use a color picker to find the hex codes in use on the menu.
  • Try to use an icon that resembles the feel of the other icons. Please see the aforementioned form plugin to see this in action. If you can’t do this, it might be helpful to choose one of the default icons that is closest to what your plugin does.

Tertiary Tabs

If your plugin is complex enough to call for options spanning multiple pages but does not meet the criteria for creating a top-level panel, you should create a tabbed navigation on the settings page itself. This is a native WordPress user interface element that you can see in use on the Themes Screen. The developer of the aforementioned caching plugin has used this method correctly on his settings page, albeit with one abnormality.

Tabbed navigation

He has placed the title of the settings page above the tabbed navigation, as opposed to the left of it. This is acceptable in cases (and probably this case) where the title and tabs might be too wide and create a horizontal scroll bar for users on smaller screens. However, best practice is to put the heading (with an icon/logo) of the settings page to the left of the tabs. Below is the general markup of the tabbed navigation with the heading added in its correct place.

<h2 class="nav-tab-wrapper">
Plugin Settings
<a href="#" class="nav-tab nav-tab-active">Tab 1</a>
<a href="#" class="nav-tab">Tab 2</a>
</h2>

Toolbar

The bar at the top of WordPress is a relatively new feature (a new form since 3.3, actually) meant to provide shortcuts to common actions in the admin area. It encourages plugin authors  to take advantage of this feature as a means of improving their plugin’s usability.

If you do choose to add an action to the bar, make sure that it is one that really belongs there. For instance, the author of the aforementioned cache plugin added an action to clear the cache to the admin bar in his latest update. This is easily the most common reason people navigate to his settings page and he saved people a bit of time. Do not assume that your plugins needs an entry on this bar, and please don’t add most of your plugin’s functionality to this bar.

If you believe you’ll have a few of these actions, create a drop down menu.

Dashboard Widgets

The dashboard’s purpose is to give users a quick look into important information on their WordPress installation. It is not meant as a way for you to advertise your services to users or publish a news feed from your site that is only tangentially related to the plugin itself. Although dashboard widgets are easily hidden and rearranged, not every user has the technical skill to do so. Please consider heavily whether or not your plugin really needs a dashboard widget before creating one. Another idea is to have the widget be opt-in, so that only users who explicitly want it have it.

If you decide to create a dashboard widget, the colors and styles should be consistent with the rest of the WordPress admin UI. The widget should attempt to display all pertinent information in the most efficient space possible. As usual, try to look at the standard widgets to get a feel for how yours should look.

Design of Settings Page

It should go without saying that the design of a settings page is extremely important to a plugin’s usability. While inventing interesting and unique interfaces might be a little much to ask of plugin developers, it is possible for every plugin to at least include a competent user interface by following a few guidelines.

Options page that is inconsistent with admin UI.

In general, keep this tips in mind for your settings pages:

  • Make your page free of any custom elements that clash with the native WordPress administration UI.
  • Infer structure of pages from WordPress core settings page designs. Be on the lookout for updates in this UI with each major version release.
  • Use native WordPress IDs and classes for form elements. Not doing this is the number one way to have a bad settings page.
  • Try to consider real use case scenarios when laying out the options. Not every single thing has to be changeable or customizable.
Ryan also wrote up an editorial on this topic a few months back that generated quite a bit of discussion.

That’s it!

Still with me? Excellent. This completes a basic primer of plugin user interfaces. If you like the guidelines, be sure to check every plugin you submit against them and hopefully we’ll be on our way to a better WordPress experience for everybody.

Do you have any tips for plugin developers that aren’t listed above? Have you run into any inconsistent UI practices that are worth warning against?

You just finished reading WPCandy's Completely Unofficial Guide to Plugin UI on WPCandy. Please consider leaving a comment!


Get in touch