• Home

jQuery is not defined in WordPress admin

If you have a WordPress install with many different plugins, you may experience that some jQuery functionality will be lost in the admin panel (i.e. you won’t be able to move the content blocks around your Dashboard). When you open the console (press F12 in most browsers), you will see several errors that will read:
Uncaught ReferenceError: jQuery is not defined
You may also see something like:
Failed to load resource: the server responded with a status of 403 - https://www.yourdomain.com/wp-admin/load-scripts.php?c=1&load%5B%5D=sa…ry-ui-slider,jquery-touc&load%5B%5D=h-punch,iris,wp-color-picker&ver=4.3.1
Here is how you fix both of these with two easy steps…

Continue Reading

How to always load latest version of your CSS stylesheet or JavaScript file

In today’s web development world, especially if we have a continuous project that we constantly update and add stuff to, we usually have a development and production versions of the website (commonly located on different servers with identical configuration). We perform fixes and add new features on development server first, test it, and then transfer all changes to the live (production) server for the site visitors to enjoy and take advantage of. Here comes the tricky part, which leads us to one of the most common user-related “issues” – cached CSS and JavaScript files. Imagine that you made some intensive changes to your CSS or JS file, tested it in your browser by hard-refreshing the pages (because you know that your CSS and JS are being cached by the browser), everything looked good, so you uploaded it to your production server. Now, how many end-users know how to hard-refresh the page if something doesn’t look right? You know it – very few. In this short manual I will explain one trick that will save you time trying to explain to your customer that he/she has to “hard-refresh the page to update cached CSS file. Please press CTRL+F5 :)”. Please note that your CSS/JS files will still be cached (your browser will not request them every time you load the site), however if your local cached version will not match the one currently on the server, it will request it from the server and will replace the local cached version with the most recent one.

Continue Reading

Embed Google Map with several locations (GeoCode addresses and display “info window” for each marker)

1. Include javascript at the top of the page. It will create a map, get a string of addresses and their respective “project names” and “amount of images” from a form that we fill during the database fetching process (see Step #3 below).

The script will then geocode each address (get latitude and longitude) and place a marker on the map. By clicking on the marker you will get an “info-window” (in our example – with project name and the amount of photos for each project). We specify the image for the marker as well.

Continue Reading

Form-based paging with PHP and JavaScript

If you have a blog or news section on your custom website, which you want to separate by pages, use the steps below to implement a paging module. First, I usually create a file called pager.php in your /includes/ folder. The content of that file is below:

Continue Reading

Keep checkboxes checked with MySQL and PHP

Most of the time we have a website or a back-end solution, written in PHP, where we use check-boxes as “flags” (to activate a user or a product for example – 1=active, 0=inactive).

Below is the example that I will base on our fictional “products” page in the back-end solution, where we specify if a given product is active or inactive (in order to show or hide it on the front of the site).

Continue Reading