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. View the code on Gist.

  3. Submit a Form on Command + Enter from Textarea with jQuery

    I’m a big fan of keyboard control in productivity applications. I love being able to type my changes/additions and submit them without needing to tab around too much, or gasp grab the mouse. I’m not the only one who feels this way. David Walsh has a great post explaining how to submit web forms with…

  4. 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’…

  5. 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). View the code on Gist. I’m going to really like this for…

  6. 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 the…

  7. 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’…

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

    fullscreen-preview-button

    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. View…

  9. 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: View the code on Gist. Note that if you have plugins, etc. that store additional user data in user meta you might need to clear those out as well.