How do I detect a click outside an element?

25/04/2019 | By Dev | No Comments | Filed in: JavaScript.

You can listen for a click event on document and then make sure #dropdownmenu is not an ancestor or the target of the clicked element by using .closest(). For those who don’t want to use jQuery. Here’s the above code in plain vanillaJS (ECMAScript6). Source:

Generating a WordPress plugin activation link url

21/04/2019 | By Dev | No Comments | Filed in: WordPress.

As I might need it again I’ve put together a gist for a WordPress function that will generate a plugin activation url like the ones WordPress will generate in the plugins administration screen The function will require a string input like my-plugin/my-plugin.php which can be hard-coded knowing a specific plugin folder and main plugin file information or using another function that will • Read More »

Creating NGINX Rewrite Rules

12/04/2019 | By Dev | No Comments | Filed in: nginx.

Comparing the return, rewrite, and try_filesDirectives The two directives for general‑purpose NGINX rewrite are return and rewrite, and the try_files directive is a handy way to direct requests to application servers. Let’s review what the directives do and how they differ. The return Directive The return directive is the simpler of the two general‑purpose directives and for that reason we recommend using it instead of rewrite when possible (more • Read More »

How to replace post name slug with post ID in Custom Post Types

10/04/2019 | By Dev | No Comments | Filed in: WordPress.

Here is a way to replace the post slug with the post ID in a custom post type permalink structure. Example. Change To Assuming the post type already exists with Refresh permalinks Refer

Native image lazy-loading for the web!

10/04/2019 | By Dev | No Comments | Filed in: JavaScript.

In this post, we’ll look at the new loading attribute which brings native <img> and <iframe> lazy-loading to the web!. For the curious, here’s a sneak preview of it in action: We are hoping to ship support for loading in Chrome 75 and are working on a deep-dive of the feature we’ll publish soon. Until then, let’s dive into how loading works. Introduction Web pages often contain • Read More »