Web Dev Snippets

A collection of (mostly) WordPress/ClassicPress-related snippets and references I’ve found useful and worth keeping where I can find them. 
NOTE: Some of these snippets are old and may be outdated. Feel free to use what you like, and point me to better snippets or references.

SmoothScroll to Top

Positions element at top on scrolling using jQuery scrollTop.
Javascript, jQuery | Type: Javascript

Specify minimum size for image upload

//specify minimum size for uploaded images (including featured images) add_filter('wp_handle_upload_prefilter','tc_handle_upload_prefilter'); function tc_handle_upload_prefilter($file) { $img=getimagesize($file['tmp_name']); $minimum = array('width' => '300', 'height' => '300'); $width= $img[0]; $height =$img[1]; [...]
Images, WP/CP | Type: PHP

Toggling search form and focus search field

Nothing tricky about toggling a search form, but making the search field focus upon showing was hard to find. For an example, see the search button [...]
Forms, Javascript, jQuery | Type: PHP

Turn off AI features in WP 7

Fortunately, this is fairly easy to do by adding a line to the wp-config.php file, or if you prefer, with the plugin Turn Off AI Features. [...]

Turn Start Date into Pretty Date

Once you've established a date, display it as you like (see catholic fdn single-events.php for complex usage)
ACF, PHP, WP/CP | Type: PHP