Code Archives

  1. Disable Submit Button After a Form is Submitted

    Once a user has submitted a form, you generally don’t want them to submit it a second time.1 A nice way to handle this is to disable the submit button once the form has been submitted, while replacing the text in the submit button with a message to let the user know that their desired…

  2. Sane Laravel 5 Mail Example

    For some reason, the example code in the Laravel docs for their Mail feature neglect to show how to pass defined variables into the closure. Here is something a little more useful. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in…

  3. Setting the wp_remote_get() User Agent

    I was recently trying to make some API requests from within WordPress using `wp_remote_get()`, but the site I was asking for data from was rejecting requests from the default WordPress User Agent. I tried to set the user agent to something different, but it still wasn’t working: $response = wp_remote_get($url, array(   ‘timeout’ => 20,   ‘User-Agent’…

  4. SASS Variables for Selectors

    I’ve been getting friendly with SASS as Crowd Favorite has standardized on that for our CSS pre-processing. Today I was excited to learn1 I can use variables for selectors (and for property names, etc.) as well as for property values (the common usage). This file contains bidirectional Unicode text that may be interpreted or compiled…

  5. My Content-Powered Projects Page

    projects-page-crop

    As alluded to earlier, I’ve cleaned up my projects page which is now powered by a new taxonomy, custom post type and the content I’ve generated here over the last decade plus. Turns out, I’ve generated quite a few projects. 🙂 I’m not completely done creating and managing the content, but I’m pretty happy with…

  6. The Right Way to Include a Plugin in a WordPress Theme

    In our FavePersonal theme we integrated the excellent Social plugin from MailChimp and included an option to turn it on or off. Most importantly we did it in a way that still allows the Social plugin to be installed and updated independently. We made sure that we implemented this in a manner that: respected users’…

  7. Add a Preview Button to the Fullscreen Editor in WordPress

    I really like the fullscreen editor in WordPress. I use it nearly all of the time when composing long-form content, often in conjunction with the excellent Markdown on Save plugin by Mark Jaquith. It has always bugged me that there wasn’t a Preview button in the fullscreen mode toolbar. Problem solved. Here’s the code. This…

  8. Anonomize Non-Public WordPress User Data

    If you need to remove non-public user data from a WordPress database, these SQL queries should do the trick for you: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional…

  9. bbcurl: view source in BBEdit

    A super simple bash function for opening the source of a URL in BBEdit. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters bbcurl ()…