Tutorials
Building a settings import and export feature
A feature you will often see large plugins provide is the ability to import and export their settings, making it much easier to migrate sites or to simply replicate the same setup across multiple sites.
Template File Loaders in Plugins
Template files are very standard for themes and heavily used in child themes. For example, if a user wants to modify the layout of their site pages, they can simply copy page.php from their parent theme to a child theme, modify the HTML structure, and the changes will be reflected on the site. While it’s…
Sometimes direct $wpdb queries are better
WordPress has some really awesome functions and classes for retrieving data from the database: WP_Query, WP_User_Query, get_comments(), get_the_terms(), and many, many more. Most of the time these are the functions and classes you should use when querying data from the database–they have some great benefits, such as caching–but there are times when it is actually…
The dangers of the gettext filter
Get array of all URLs in a string
WordPress 3.7 introduced a new function called wp_extract_urls(). This is a handy function that allows you to extract URLs from text strings. Simply pass the text string to the function and it will return an array of URLs.
User Follow System – Part 7
In this final part of the User Follow System tutorial series, we will create two short codes, one for displaying a follow/unfollow link for a user and one for displaying a list of recent posts from users you (the currently logged-in user) follow. We will wrap up the series by also showing a few areas…
User Follow System – Part 6
In part 5 of this tutorial series we wrote the Javascript that is responsible for firing off the ajax events when a user is followed or unfollowed. Now, in this part, we are going to write the PHP side of the ajax events that takes care of processing the requests and sending a response back…
Restricting Menu Items to Active Members in Restrict Content Pro
If you want to restrict menu items to active subscription holders, or members of specific subscription levels in Restrict Content Pro, the Menu Item Visibility Control will make your job pretty easy and provide complete control.
Building good template files
It is becoming more and more common for plugins to provide template files that can be copied to a theme’s folder and then safely modified. This means that the site owner that is using the plugin can add, remove, and modify the markup of the plugin without hampering the upgrade process when new versions are…
Plugin Development 101 – Your First OOP Plugin
Checking if a dependent plugin is active
When you write plugins that depend on others, such as extensions for Easy Digital Downloads, you often need to check if the dependent plugin is active and only perform certain actions if it is. There are several ways to check if a plugin is active and I’d like to walk you through some of them.
Using the WordPress Heartbeat API
WordPress 3.6 introduced a new API called the “WordPress Heartbeat”. This is the API that behind a lot of the improvements in WordPress 3.6, including better revision tracking, user’s session management, and more. I’m going to show you a quick example of how you can use the API to perform “live” actions. What is the…
Get all media attached to a post
WordPress 3.6 introduced the new get_attached_media() function that makes it really simple to retrieve all media attached to a specific post.
Retrieving the image URLs from all gallery images in a post
WordPress 3.6 introduced quite a few new functions that are helpful when working with media attached to a post. One of my personal favorites is a helper function that lets you retrieve the URLs of images that have been inserted as parts of galleries in the post.