.htaccess – Moved images to another folder

07/05/2020 | By Dev | No Comments | Filed in: htaccess.

When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined. Consider the following rule:

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: https://stackoverflow.com/questions/152975/how-do-i-detect-a-click-outside-an-element

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 http://stackoverflow.com/questions/25199501/wordpress-custom-type-append-post-id-at-the-end?answertab=votes#tab-top