Tag Archives: Plugins

Using the WordPress 3.5 Media Uploader in Your Plugin or Theme

Back in 2010, I wrote a post on Using the WordPress Uploader in Your Plugin or Theme that went on to be one of my most popular tutorials of all time. Then the WordPress team went and added a much cooler media uploader in version 3.5 and make that post outdated. Since most of you probably want to add the new uploader in a theme or plugin you’re working on right now, I figured it was time for an updated post.

WordPress 3.5 Media Uploader

The process required to add the new uploader is a bit different, but not too much more difficult. I was able to adapt the old tutorial a little, so it shouldn’t be too hard to replace some code in an existing project and get the new uploader instead of the old.

Continue reading →

WordPress Core Control

I’ve been working on a WordPress plugin that takes advantage of the WP-Cron system (which, for the uninitiated, is a sort of event scheduling system that runs functions in WordPress at predetermined intervals). Unfortunately, that’s a bit of a pain considering the nature of the task. How do you test functions that are designed to run intermittently, say twice a day? The easy/hacky solution is to add a function call that runs the task on every page load, and then remove it when you’re done. But if you want a solution that doesn’t involve editing your code, there’s a handy plugin that’s perfect for this scenario.

Core Control is a plugin that lets you monitor and adjust several parts of WordPress for diagnostic and development purposes. It makes it easy to view registered WP-Cron events, and trigger them with a click. It can also force WordPress to check for ore, plugin or theme updates, log any HTTP requests WordPress makes to external servers and determine which filesystem access method WordPress is using.

Automattic Releases Jetpack 2.0, Featuring the New Photon CDN

Automattic’s Jetpack plugin has certainly grown since I first looked at it. I originally dismissed it, not wanting to unnecessarily tie my own self-hosted blogs to WordPress.com for a few niceties like in-Dashboard traffic stats and very thorough spelling and grammar checking via After the Deadline.

I decided to try it out again now that it hit the big two-point-oh, and was surprised now only by the amount of functionality it offers, but by how many other plugins it can conceivably replace. The Publicize module, for instance, will automatically post links to new posts on Twitter, Facebook and other popular social networks, so you don’t need another plugin for that if you run Jetpack. I also found the Mobile Push Notifications and JSON API modules to be intriguing. The former sends push notifications to your iPhone/iPad when new comments are posted, and lets you jump right over to the WordPress iOS app to manage them, and the latter is primarily of interest to developers looking to integrate a WordPress blog into another web site or application. (Previously I used this plugin, but Jetpack looks roughly equivalent.)

The big new feature in this version is a free service called Photon, an “image acceleration and editing service” which acts as a CDN for your images. It mirrors images it finds in your posts (or ones a theme or plugin developer specifies via an API) on WordPress.com’s servers, which enables them to be served faster and takes load off your server. This would be excellent for blogs hosted on cheap shared hosting, especially if coupled with a static caching plugin like WP Super Cache or W3 Total Cache.

Easily Embed Whole Tweets in Your Blog Posts With Tweetable 1.2.4

Have you ever wanted to embed an entire tweet into a WordPress post for some reason? Maybe you were doing a short write-up about a recent news story, and wanted to quote someone’s amusing tweet on the matter. You could just use a simple blockquote, and link to the tweet, but wouldn’t you rather embed the whole thing, complete with information about the user and interactive buttons?

The latest version of my Tweetable plugin, version 1.2.4, includes support for Twitter’s new embedding API, which enables you to do that with minimal effort. If you have the plugin installed (and “Auto-embeds” is turned on in the Media page of your Settings), you can just paste a properly-formatted URL from Twitter onto a new line in your post. After you hit Publish, it will appear in your post, thanks to the magic of oEmbed.

The best part? This is going to be built-in to WordPress 3.4, so you have ensured forward-compatibility. Otto, one of the major contributors to the WordPress core, has already worked up a patch and it is currently slated to be included in version 3.4. Beat me to it. :P

WordPress BlackBox Debug Bar Plugin

BlackBox is a handy WordPress plugin that I’m going to have to try out for development. It adds a debug bar along the top of each page, with items that would be invaluable for plugin and theme developers but probably of little interest to bloggers who don’t like getting under the hood.

With the theme you can have a look at all of the globals, see any errors generated, and keep tabs on the MySQL queries (including their execution times) behind the page generation. It even includes a profiler.

StatDash: Statistics on Your WordPress Dashboard

Wouldn’t it be neat to have an at-a-glance display of common statistical information on your WordPress Dashboard? The StatDash plugin does exactly that, adding a customizable widget that shows stats from Google Analytics, Feedburner, Twitter and even your earnings from the Envato Marketplaces.

You can choose which of the services are displayed, as well as hide the chart if you wish to have the widget be a bit more compact.

StatDash is my first item to be released on Code Canyon. It’s priced at $8, and is GPL compliant of course.

WordPress Admin Bar Plugin Roundup

WordPress 3.1 added an “admin bar” that floats along the top of your blog when you are logged in with an account of sufficient privileges, giving you easy access to frequently-accessed pages in the WordPress admin.

It didn’t take long for plugin developers to start finding ways to extend it.

Weblog Tools Collection has a small roundup of admin bar plugins, which add additional functionality to the admin bar. One lets you manage what appears on the bar, and several add entirely new items such as debugging tools.

Admin Bar Plugin Roundup [Weblog Tools Collection]

My Idea for Canonical WordPress Plugins

There has been no shortage of debate over the plans to include canonical (or “core”) plugins in WordPress. While I haven’t fully decided what my stance on the matter is, I do have an idea for what the concept should become.

Core plugins shouldn’t be about “let’s have an official plugin for x.” They should instead be frameworks of additional classes and hooks that can be extended by plugins and themes. Instead of having, say, a canonical plugin to integrate Facebook into WordPress, you could have a “Microblogging” core plugin that doesn’t do much aside from add a bunch of new microblogging-related hooks (along with classes for interacting with the Twitter, Facebook, Tumblr, etc. APIs.). Plugins and themes could then hook into the microblogging core plugin, using it’s generic methods to update one social network or many simultaneously.

Does that make sense? :)

The GPL Doesn’t Apply to Premium Themes or Plugins

Mike Wasylik of Perpetual Beta has an interesting argument in the legendary GPL debate surrounding premium WordPress themes and plugins. He thinks that themes and plugins shouldn’t be required to be licensed under the GPL for the simple reason that they’re not derivative. U.S. copyright law defines a derivative work as one that physically includes a portion of the copyrighted work, which plugins and themes do not.

…even a theme or plugin that entirely dependens on WordPress to run at all, or simply improves WordPress in some way, would not be a derivative work and the GPL would not apply. For the vast majority of themes I’ve seen, the GPL would not apply because the theme is not, in my opinion, a derivative work. (In fact, if any one thing “incorporates” another, it’s most likely WordPress incorporating the theme, by use of the PHP include() call, rather than the other way around.)

According to the article, the copy of the GPL included in every download of WordPress even states that a derivative work is “a work containing the Program or a portion of it, either verbatim or with modifications.” I’ve been making a similar argument for awhile now. I have yet to see a theme or plugin that actually incorporates WordPress into the plugin code itself, rather than being included by WordPress. It sounds to me like WordPress, if anyone, is the one doing the deriving…

Most WordPress themes and plugins are unique code for the most part, with a few hooks or function calls. I must have missed the memo that utilizing a third-party API makes your application a subset of the other software. (That would mean any desktop application would be a derivative of the operating system.)

A follow-up article from the same author makes the additional case that, whether the GPL applies or not, the Fair Use Doctrine can protect developers from the licensing terms of the original creator. The same laws that ensure you can quote part of an article without having to pay whatever licensing fee the publisher can cook up apply to software. As little, if any, WordPress code is used in a theme, it would likely be considered fair use.

I like some of the ideology behind the GPL, and quite a few software packages licensed under it. However, it seems that in this case one party is misusing (or misinterpreting) it to prevent small developers from earning a living while further enriching the WordPress community. For what reason, good intentioned or no, I cannot guess.

Using the WordPress Uploader in Your Plugin or Theme

WordPress has a nice media uploader dialog that it uses on the editor pages. Now wouldn’t it be nice if you could use it to handle image uploads for part of a plugin or theme you’re writing? Maybe you want to add an easy way to change the logo in a theme? A simple “Upload Image” button would work quite well for that, wouldn’t it?

It’s fairly simple to implement, providing you already have a bit of experience with the WordPress API.

The first step is to prepare your HTML. Put it wherever the code for your admin page is. You want to have a text input for the image URL, and a button that will launch the uploader dialog.

Continue reading →