background preloader

Plugin Development

Facebook Twitter

[WordPress plugin] Flickr foto info at SANIsoft – PHP for E Biz. If you embed Flickr photos on your site you can always link them to the original page where visitors to your site can get all the details but that is not really a good user experience as it sends the visitor away from your blog.

[WordPress plugin] Flickr foto info at SANIsoft – PHP for E Biz

I don’t really like how Flickr almost hides away the link to EXIF and the location map. Also at least for Central India Google Maps has a better resolution than Yahoo Maps which Flickr uses. This plugin was written to itch these irritating factors. So what does this plugin really do? Well with a bit of javascript magic it places a small toolbar over images in your post which are from Flickr when you hover your mouse over them. All this information is shown in a Thickbox thus your visitor need not navigate away from your site. Installation Demo: Click here Download: Click here Feedback, suggestions, patches, bug reports most welcome. Tarique Sani Dr. Why Should You Add Your Plugin to WordPress Extend? WordPress has a huge community with a active user base contributing in the form of excellent plugins, however most of the plugins are scattered all over the internet making it more and more difficult for users to find them and also for plugin authors to send out updates whenever there are any.

Why Should You Add Your Plugin to WordPress Extend?

However to solve the problem there is WordPress Extend, a place where plugin developers can add their plugins, making it easier for others to find them. It would be really good if more and more developers started using WordPress Extend to distribute their plugins, I would like to discuss a few benefits developers get when they add their plugins to WordPress extend to make that decision easier. Hint: If you are unaware of how to add your plugin to WordPress Extend, read our earlier tutorials. Here are the benefits of adding your plugin to WordPress Extend. Free Hosting Space. Introduction to PHP’s Serialize Function.

I was tinkering with a WordPress database the other day and was nosing around through some tables, looking for some statistical data which I never found, and noticed that a few of the tables were storing data in an unusual format (to me at least).

Introduction to PHP’s Serialize Function

Specifically one record I found looked like this: Whoa. Looked like some sort of delimited data (it is) but not in a form I recognized. Now over the years I thought I had seen my share of input that is stored in a database. Like most PHP developers I didn’t learn PHP through a class, I learned it by reading and trial and error, but I don’t remember seeing something like this before. Cache a large array: JSON, serialize or var_export? - TechBlog. Monday 06 July 2009 10:30 While developing software like our framework you will need to cache a large data array to a file at some point sooner or later.

Cache a large array: JSON, serialize or var_export? - TechBlog

At such a point you need to choose what caching method you will be using. In this article I will compare three methods: JSON, serialization and var_export() combined with include(). By Taco van den Broek Too curious? The JSON method uses the json_encode and json_decode functions. Code example file_put_contents($cachePath, json_encode($myDataArray)); $myDataArray = json_decode(file_get_contents($cachePath)); Add New Headers to WordPress Plugins or Themes – Nerdaphernalia.

I’ve had a few patches committed to WordPress core in the last few versions, and have sadly neglected to do writeups about them so that others could take advantage of the new features. I hope to remedy that in the next few posts. Use Classes in your WordPress plugins to increase code portability and reduce name conflicts – Nerdaphernalia. One of the most powerful features of WordPress is the huge community of developers making plugins that extend the software far beyond what the core application provides.

It also allows people to add just what they want to use, rather than having a single bloated homogeneous download. There are drawbacks as well, of course. Any time a software package opens itself up to third-party additions, there is a potential for mischief. With WordPress, different plugins can end up stumbling over each other, as each is coded for the core but doesn’t anticipate other plugins. You can also have naming conflicts — when functions or variables in different plugins are given the same name.

These problems can be avoided by using classes If you have multiple plugins, you probably have a good bit of code that you reuse in all of them. These problems and others can be avoided by using classes. By wrapping your plugin’s functions in a PHP class, you gain a number of advantages. Consolidate Options with Arrays in your WordPress Plugins – Nerdaphernalia. If you’ve ever written a plugin for WordPress you’ve probably dealt with giving the end user options. Unless you’ve taken the low road and forced the user to directly edit the plugin file, “options” means a Settings screen in the WordPress admin, and most likely you are storing those options in the blog’s wp-options table.

Over time, bloggers using various plugins can end up with hundreds of extraneous records in their options table * . If they ever stop using a plugin, or if they ever want to manually clear out options, this job can be made difficult by all the clutter, and the problem is made far worse when plugin authors add a new record for each separate setting in a plugin. Beyond the mess, plugins written this way generally make many more calls to the database than they need to, which adds unnecessary burden on the server. WordPress Plugin Creation "Saving Options" Most WordPress plugins, if not all, have options (also known as settings) that are stored in the blog’s MySQL database, ready to be called upon when needed.

WordPress Plugin Creation "Saving Options"

In this tutorial we will explore three different PHP methods to store options. The first and most commonly used method is to save each option with separate variables. To save the option: We use the $_POST variable to save form data in a variable. The variable is then used to update an option. $variable = $_POST['option01']; update_option('my-plugin-options', $variable); To call the option: To call an option we simply use the get_option function and set the chosen option to a variable.

$variable = get_option('my-plugin-options'); Method Two – Arrays and the Extract Function The first method is easy enough to implement, but can be very bothersome and less efficient for some plugins. To save your options in an array: First the options will be saved into an array. Post Formats. Post Formats Languages: English • Español • 日本語 • Português do Brasil • Русский • 한국어 • 中文(简体) • 中文(繁體) • (Add your language) Intro Post Formats is a theme feature introduced with Version 3.1.

Post Formats

A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post. The Post Formats feature provides a standardized list of formats that are available to all themes that support the feature. Trunk. Template Tags. Languages: English • Español • Français • Italiano • 日本語 • Português do Brasil • Русский • ไทย • Türkçe • 中文(简体) • 中文(繁體) • (Add your language) Template tags are used within your blog's Templates to display information dynamically or otherwise customize your blog, providing the tools to make it as individual and interesting as you are.

Template Tags

Below is a list of the general user tags available in WordPress, sorted by function-specific category. For further information on template tags and templates in general, see the following: Stepping Into Template Tags - an introduction to Template Tags. Anatomy of a Template Tag - details of how to put Tags into Template files. Pluggable Functions ? WordPress Codex. Pluggable Functions Pluggable functions were introduced in WordPress 1.5.1 These functions let you override certain core functions via plugins.

Pluggable Functions ? WordPress Codex

The most up-to-date list of core functions that WordPress allows plugins to override is available at wp-includes/pluggable.php. WordPress loads the built-in functions only if they are undefined after all plugins have been loaded. Pluggable functions are no longer being added to WordPress core. All new functions instead use filters on their output to allow for similar overriding of their functionality. Note: A function can only be reassigned this way once, so you can’t install two plugins that plug the same function for different reasons.

New Plugin – “I Make Plugins” « Mark on WordPress. I have several WordPress plugins.

New Plugin – “I Make Plugins” « Mark on WordPress

They’re hosted on the plugin repository, but I also have a page for each plugin on my own site. I’ve found it tedious to have to update both places separately. Things get out of sync, or worse, I put off plugin updates because I loathe updating two places (with two different formats) with the same information. The WordPress plugin repository has an API. Let’s use it! Adding a plugin is as simple as creating a new subpage of your plugin listing page, and giving it the name of your plugin in the repository.

Here is a nine and a half minute. boring-as-hell screencast with a full tour of the plugin. Excluding your plugin or theme from update checks « Mark on WordPress. There has been a vigorous discussion going on regarding what data WordPress installs send to when doing update checks.

Excluding your plugin or theme from update checks « Mark on WordPress

Because WordPress (the software) doesn’t know whether a theme or plugin is listed in the repositories, it has to check them all, and let the repository sort it out. Some have expressed concern that private plugins developed for a single client could contain sensitive information in their headers, like contact information for the developer, etc. If you, as a plugin or theme developer, would like to exclude one of your plugins or themes from the update array, the following code will do the trick.

Block-level comments trick « Mark on WordPress. Block-level comments are useful for commenting out an entire block of code in PHP, CSS, and other code contexts. The only problem with this is that when you go to re-activate this code, you have to change both the opening and closing comment markers. That’s a pain. While I was at WordCamp NYC last week, I saw Daisy Olsen using a very clever trick in her lightning round talk. See what she did there? Using PHP5 object constructors in WP Widget API « Mark on WordPress. TextMate WordPress Widget Snippet « Mark on WordPress.

I love WordPress’ sidebar widgets. I also despise coding them. 8 steps to get started as a freelance WordPress developer « Mark on WordPress. Escaping API updates for WordPress 2.8 « Mark on WordPress. The WordPress escaping API functions have been updated. Escaping is a way of using untrusted text that “neuters” anything that could do damage. Escaping is used in WordPress to avoid SQL injection and cross-site scripting/script injection (XSS), among other things.

The old functions still work, so if you were using the old ones, you’re fine. Why WordPress Themes are Derivative of WordPress « Mark on WordPress.

Plugin Installer

2.0.3: Nonces « Mark on WordPress. WordPress 2.0.3 has some security enhancements that a lot of people are wondering about, so here’s my attempt at explaining them. Custom Queries. Custom Queries NOTICE: This article discusses how to modify queries using hooks. AJAX in Plugins. Modifying Options Pages. Function Reference/add meta box. Function Reference/add meta box. Creating Options Pages. Creating Options Pages. Creating Tables with Plugins ? WordPress Codex. Creating Admin Themes ? WordPress Codex. Creating Admin Themes. TinyMCE Custom Buttons. Writing a Plugin. WordPress hooks database - action and filter hooks for wp plugin developers.