To transfer WordPress.org plugin ownership to someone else: Update the plugin’s readme.txt file, changing the Author, Author URI and Contributors in the plugin header and commit those changes to the SVN repository. Log in to wordpress.org and navigate to your plugin’s page. Click the “Advanced View” link in the right sidebar. From here, add and […]

Read more

The following function can be used to get the absolute path to the WordPress uploads directory: View the code on Gist. It will return a path to where the WordPress /uploads/ directory is, whether it’s in the default location or whether an UPLOADS constant has been defined to specify an alternate location. The path it returns will look […]

Read more

I’ve seen posts and documentation online for how to get just the customer notes for an order, but no great ones for how to get all WooCommerce order notes. Here’s my solution for that: View the code on Gist. You just pass that function the order ID (post ID) for any order and it returns an […]

Read more

Per this Trac ticket, WP intentionally disallows adding the ‘unfiltered_html’ capability to any non-Super Admin users on the WordPress multisite network. This is due to potential security vulnerabilities that could result from doing to. As that ticket points out: Any user could add Javascript code to steal the login cookies of any visitor who runs a blog […]

Read more

If somewhere in the code for a WordPress site there is a filter hooked to post_link that’s replacing the URL so that it no longer contains the %postname% placeholder, WordPress will assume there’s nothing to edit. It will therefore output the permalink on the post edit screen without the edit button next to it, and […]

Read more

Using the Gravity Forms + Custom Post Types WordPress plugin to map your Gravity-Forms-generated posts to a custom post type is very handy, but I noticed that it doesn’t seem to work with file uploads. This is because by default, Gravity Forms saves files to /wp-content/uploads/gravity_forms and stores their URLs. ACF on the other hand, saves files to the WP Media Library […]

Read more

The get_the_excerpt() entry in the WordPress Codex says that it returns “…either a user-supplied excerpt, that is returned unchanged, or an automatically generated word-counted trimmed-down version of the full post content” (although the more up-to-date WordPress Developer Resources entry has no such language). I find that calling get_the_excerpt() doesn’t work when a post has post content but not a post excerpt. […]

Read more

The function below can be used to get a user’s first and last name with a space between them, like “Kellen Mace”. If they only have a first name saved, it will return that, and it will return their WP login as a last resort. This is useful if you want to display the users’ […]

Read more

WordPress has a built in username_exists() function to check if a user exists by their username, but there isn’t a similar function for checking if a user exists by their user ID. I’ve seen posts online where folks suggest a way of doing that with a direct database query using $wpdb. While that works, the function […]

Read more