VS Code doesn’t select the $$$

When using Microsoft Visual Studio Code / Monaco for PHP it’s really annoying to me how double-clicking a variable doesn’t include the dollar sign in the selection. Go to the settings and search for editor.wordSeparators: Word Separators Characters that will be used as word separators when doing word related navigations or operations. You can simply […]

Add a spinner to a submit button for slow forms

If you have a form that is slow to submit, this is a simple way to replace the submit button with a spinner. You may need to change the two selectors in the Javascript to be more specific, or different. Border-color may also want to be different, that’s the color of the spinner. <script>document.querySelector(‘form’).addEventListener(‘submit’,function(){ document.querySelector(‘[type=submit]’).className+=’ […]

Delete Wordpress post revisions older than x days

Delete post revisions older than 10 days: DELETE FROM wp_posts WHERE post_type = ‘revision’ AND post_modified_gmt < DATE_SUB(NOW(), INTERVAL 10 DAY) Delete post revisions older than 2 months: DELETE FROM wp_posts WHERE post_type = 'revision' AND post_modified_gmt < DATE_SUB(NOW(), INTERVAL 2 MONTH)

Forcing SSL with Apache mod_rewrite

Paste this into your .htaccess file # BEGIN Force SSL <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} =off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule> # END Force SSL I once had the needed to exclude a directory, so http:// versions would still be served. This was just one extra line: RewriteCond %{HTTPS} =off RewriteCond %{REQUEST_URI} !^/directory/ RewriteRule […]

Using UTM parameters in forms and anywhere shortcodes can be used

// Shortcode for retrieving Session params if ( ! shortcode_exists(‘get_cookie’) ) { function readycat_get_cookie( $atts ) { // check for shortcode param if ( empty( $atts[‘key’] ) ) return ‘Please specify a key=whatever_value in the shortcode.’; $default = !empty( $atts[‘default’] ) ? $atts[‘default’] : ”; if ( ! empty( $_GET[ $atts[‘key’] ] ) ) { […]

Restore Default User Roles in WordPress

This is a pretty goofy function, but a client once deleted the default user roles using some plugin, and I just threw this into functions.php to re-create them. It’s hooked onto admin_init, so it runs when you load any back-end page.  I set a transient that keeps the function from running more than once (and […]