Problem

I’ve been trying like crazy to get to my local website at site.dev, but I keep getting redirected to https://site.dev and of course it doesn’t work because I don’t have a SSL certificate for that domain.

Solution

As of December 2017, Chrome 63, Chrome is forcing all .dev domains to be redirected to HTTPS via a preloaded HTTP Strict Transport Security (HSTS) header. The .dev TLD is an actual legitimate TLD so you will need to change your local development setup to use something like http://site.localhost .

Problem

IE 10 shows a skewed svg image who’s width is set to a specific value and height is auto.

Solution

The problem is the width and height in the SVG file is set and IE is following those specs if you don’t set it. So if you’re image is 100×100 and you set only the width to 50px, the height will remain at 100px. The solution is to remove the width and height attributes in the <svg> tag.

Caveats

A solution on a github gist suggests that removing the width and height attributes force the image to occupy the full width of its container in non-IE browers. All my current images with SVG are supposed to fill the width so this isn’t a problem for me.
Link to the gist: https://gist.github.com/larrybotha/7881691

Problem

When running wpdb->insert the result returns false. All the values seem to check out to be fine.

Solution

The problem might be due to this bug in WordPress. Basically one of your fields is too long and WordPress is not completing the insert. Reading through the ticket, it seems it is a WordPress error and not a MySql error so it would be pretty difficult to go through all the fields, determine the column field size limits, and then return an error of some sort. Anyway, this is one possible reason to wpdb->insert returning false.

Problem

WordPress’ cron doesn’t work when a site has basic authentication. You basically would get a 401 error.

Solution

Thanks to Nick Ohrn (in 2014) this problem is solved with a simple mu-plugin. You just need to set the username and password in a constant in wp-config and add some code to the mu-plugins directory. Here is his quick tip.

Problem:

When zooming in or out on Chrome, the widths of elements increases very slightly and causes some elements to shift to the next line.

Solution:

The actual problem is Chrome adjusts the widths of elements by tenths. So something like 141px will turn into 141.1px which in turn causes all your elements to be just slightly bigger and not fit on one line.

I thought the solution to this was to go through all the problem elements and re-set the size to the original size. However, it turns out you just have to go through the elements in javascript and Chrome will re-set the widths for you. This leads me to believe this width adjustment on zoom is a bug in Chrome. Below is what solved my problem in jQuery:

WordPress checks if it’s an email like it should, but it does this even if an empty string is passed. If this needs to be an optional field, the only way I see around it is to not set the format to email.

This error occurs because the_post_thumbnail_caption is a new function in WordPress 4.6. However, people have been using this function for over 5 years now. How? Stackoverflow and other WordPress forums are flooded with questions asking how they can print out the thumbnail caption. Since this wasn’t a built-in function before, the answer was to make your own function which was appropriately named the_post_thumbnail_caption.

Many theme authors, myself included, are now guilty of simply copy-pasting this function without adding their own theme prefix. To avoid errors like this, functions within a theme should be prefixed with something unique to the theme like “mymonkeytheme_the_post_thumbnail_caption”.

If you have this error, contact your theme author and ask them to fix the theme.

This may be obvious to the git experts, but I am not that. There also may be a better way to do this, but again, not a git expert.

I have a git repo set up on WPEngine, but they only allow the whole server to be a repo, not just a single plugin. This was a problem since the whole server directory was not in my current repo. So it was either make a new repo which was basically a copy of my current repo but a different folder structure or keep on using SFTP. I decided to make a new duplicate repo. The problem (which i also had with SFTP) was finding the files that changed and pushing them to the server. This is both error-prone and slow. I found a script that could copy all changed files from the last commit into my WPEngine deploy directory and also discovered a way to do this automatically when pushing from my main repo.

Create/Save this script in .git/hooks/pre-push file. This would be in the main git repo I work in. This copies all changed files to the WPEngine deployment repo.
#!/bin/bash