Development Archives

  1. http_build_query() Separator Tip

    I ran into an interesting “bug” in Twitter Tools last night that I traced back to http_build_query(). I expected that the query strings generated by this function used & as a separator for the key=value pairs, but on one of our test servers, the separator being used was &. This is a php.ini config setting,…

  2. Twitter Tools 3.0 beta 2

    I’ve packaged beta 2 of the next generation version of Twitter Tools. Version 3.0 is a ground-up rewrite on top of the Social platform, with a few features included for backward compatibility. If you’d like to test the beta, grab it from GitHub. This version fixes several bugs that were found in our QA process,…

  3. WP_Query by “Standard” Post Format

    When using WordPress post formats, you’ll quickly start looking for a way to query WordPress content by the “standard” post format. This Trac ticket seeks to work on solving this. The implementation there handles URL-based requests: http://example.com/type/standard/ quite nicely. However the code in that patch doesn’t (yet) handle direct WP_Query calls. I was hacking on…

  4. Popularity Contest is Dead (and on GitHub)

    I wrote the Popularity Contest plugin for WordPress back in May of 2005. It had a good run, but that run is over. We are no longer developing or supporting Popularity Contest, and I recommend letting it rest peacefully. Why? It does too much, and too little at the same time. It does too much.…

  5. WordPress Plugins and Symlinks

    If you’re doing serious development for WordPress you will quickly find yourself in a situation where you need to test a plugin in multiple installations. Using symlinks is a great way to make sure that you don’t end up editing in multiple locations, perhaps forgetting to commit a change, etc. However, there are some headaches…

  6. Not Getting GitHub Notifications?

    I have been moving Crowd Favorite‘s Open Source projects to GitHub (as well as my personal projects). GitHub has great tools for this. We created an organization, added the team members to that organization, and created repositories for our projects. As a few of our projects have enjoyed exactly the sort of developer community engagement…

  7. WordPress Post Format Fallbacks

    Post Format Fallbacks

    While our post formats admin UI is getting a nice warm reception (100+ tweets, pings and comments, wow!), there is a concern that has popped up a few times – one that I included a nod towards in my original post. What happens when publishers put important data in the post format custom fields, then…

  8. WordPress Post Formats Admin UI

    format-standard

    The Post Formats feature that landed in WordPress 3.1 is a great framework feature. I’m leveraging it extensively on this site to drive my link, status, photo and gallery posts. While it is a great framework feature, it only really exists as something developers leverage to extend WordPress. There is no UI that ships with…

  9. wp_publish_post() Does Not Set post_*

    The inline documentation for wp_publish_post() says that it will: Publish a post by transitioning the post status. and that’s exactly what it does. Moreover, that’s all it does. If you are creating a draft post via wp_insert_post() (or wp_update_post(), which calls wp_insert_post()), certain defaults will be set for you when the post status is set…

  10. Wanted: Multiple Incognito Sessions

    Steve laments the lack of easy “Incognito” windows in Firefox. I tried Safari as my primary browser for a few weeks when I upgraded to Lion and I really missed this as well. Once it becomes part of your workflow, it’s really hard to go back. I actually want it to go a step further.…

  11. Modernizr.touch and BlackBerry Browsers

    If you’re using Moderinzr to detect browser support for touch events, be aware that non-touch BlackBerry devices claim to support touch events. As you might expect, the touch events are pretty much impossible to trigger on a non-touch device. I worked around this by making the check for touch vs. non-touch browsers also test for…

  12. Custom Fields vs. Taxonomies

    For years I’ve used custom fields (post meta) in WordPress as a primary storage area for misc. data about specific posts (including pages, custom post types, etc.). Recently, I’ve realized that I should be using custom taxonomies instead of custom fields in a variety of situations. Custom fields are still the right choice for misc.…

  13. Where to Host WordPress Code?

    I talked to a number of developers about at this year’s WordCamp SF about where best to publish WordPress code as a developer. We definitely want to use the SVN repositories on WordPress.org so that released plugins can be easily available to the community, but there is very little developer community there. We’ve also used…

  14. WordPress Filter for Pingbacks

    My team and I have been working on a plugin to enable a better UI for post formats in the WordPress admin (more on this later, but feel free to grab the code and play with it). One of the things we’ve done is standardize on some custom field names for various bits of data…

  15. WordPress GUIDs Must Be URLs

    If you are customizing the GUID value of a post in WordPress, make sure you maintain the format of the GUID as a valid URL format. There are security checks on the value that enforce the URL format. If you pass in a UUID as the GUID value when creating a post, your value will…

  16. Reminder: Post Formats are a Taxonomy

    If you hook in to get_the_terms and try to make a get_post_format() call within your callback without first removing your filter, you’re going to get an infinite loop (perhaps a seg fault). Good times!

  17. Use $content_width to Set Width of oEmbeds in WordPress

    If you want resulting oEmbed code to scale to a specific size (width) in WordPress, you can do this really easily by setting the $content_width global variable before calling your oEmbed processing. Example: global $wp_embed, $content_width; $content_width = ’600′; // set to desired width $string_with_embedded_content = $wp_embed->autoembed($string_with_oembed_url); I only recently ran across this feature (just…

  18. Detecting Lightboxed Pages in WordPress Admin

    When you want inject something into the WordPress admin, you might not think to account for pages that load inside lightboxes (plugin updates, media upload, etc.). Generally, you don’t want to add your JS/CSS/etc. to these pages. To check for this type of page load, you can check for the IFRAME_REQUEST constant. View the code…

  19. WordPress Code Snippet to Detect “Main” Loop

    Cribbed from the WP-Hackers list, the following sample code should give you a good way to test if the current “in the loop” action is within the main loop or a different loop: function main_loop_test($query) { global $wp_the_query; if ($query === $wp_the_query) { echo “main loop”; } } add_action(‘loop_start’, ‘main_loop_test’); Thanks Nacin and Konrad. This…

  20. Passthrough File Download Tip

    At some point you’re going to need to do the following in your web app: Receive a request to download a file. Authenticate the user/validate the request using some information stored in a database. Upon successful authentication/validation, deliver the file to the requestor (but deny access to the general public). This is a pretty standard…

  21. SimpleMath

    I have to do basic arithmetic on a fairly regular basis. My tool of choice for the last few years has been LeanCalc. It does the job well for the most part, but it doesn’t ignore non 0-9 characters, I would commonly use it to calculate a percentage of a dollar value. I’d paste in…

  22. Developer Expectations

    Old developers are wary of frameworks and assume something about them will end up biting them in the end; they are wary of using features they haven’t created. Young developers assume that frameworks and tools work, use them without hesitation, and are surprised when things go wrong. The truth, as usual, rests somewhere in between.