Cookie based permission in htaccess – restrict WordPress admin access by IP address

In my previous post about htaccess based restriction i showed how to restrict wp-admin or other file/page access by IP address. That’s very good solution when we are using VPN static IP.

But if we are using multiple connections (office, home, caffee, or multiple VPN-s with different IP addresses), then we need to have some easier solution.

And that can be cookie-based permission. Let’s see how to do that.

Continue reading “Cookie based permission in htaccess – restrict WordPress admin access by IP address”

Ready to use snippet for WP REST API

WP-REST is great tool to connect 3rd party applications to your website and interact with it.

If you want to use it deeply in your website, you need to go to official website and read its handbook.

but what if you just want to use it for some small task and you don’t want to lose more time on reading docs? Then you might need JS code for frontend, and some backend codes for initialization and processing.

In this article i am giving you ready to use snippet, you just put it to your theme’s functions.php and it works.

Of course you will need to change the codes inside response function. In my example i am giving you an example which counts post_views.

Let’s create simple WordPress rest api custom endpoint. Here we go:

Continue reading “Ready to use snippet for WP REST API”

How to log all WP-admin activities in WordPress

If you have several admin accounts, it is usual to see some options, settings changes where there is no any trace to see who has done that any change.

Of course it is not about Post, Page updates, they have some information about who updated the given post object.

But for the rest wp-admin pages there is no such trace collector.

Such kind of data can be useful if you have suspicion that someone you don’t have stolen admin password and logs in to your wp-admin as a wordpress ghost admin. So this snippet might be helpful when you want to stop/prevent wordpress admin panel hack too.

So, let’s write small snippet which will collect, who and when did any activity inside wp-admin.

Continue reading “How to log all WP-admin activities in WordPress”

WooCommerce – Add short link support when it returns 404

This quick post is about the issue when in WooCommerce website your WP short links (aka WordPress Plain URL) returns 404 error.

f.e. should open (redirected to user friendly URL) the page of single post, where 912 is the ID of that post.

But in some WooCommerce websites due to complex permalinks rules, this redirection doesn’t work.

The reason is simple – The route requires the value for post_type – in order to determine what kind of post type is that $_GET[“p”] is.

So, let’s just help the route to find it:

Continue reading “WooCommerce – Add short link support when it returns 404”

Neural Network that finds what season the given day belongs to

Neural Network - find what season it is

Today i am creating new category branch in my blog, where i will post simple and useful AI snippets that is very easy to implement. My main focus would be E-Commerce and mining useful data from WordPress user sessions.

As a start, i will post very simple starter example.

I will use JavaScript based AI engines in general – simply because those are very easy to implement, work in browser, don’t require any software installation. So you will be able create neural network online without installing any tool.

So, let’s get started.

Continue reading “Neural Network that finds what season the given day belongs to”

Remove pagination trails from WooCommerce Breadcrumb

Today i am sharing small snippet that removes Pagination Trail from WooCommerce breadcrumbs.

Some shop owners may dislike this built-in feature and would like remove WooCommerce pagination links from WooCommerce navigation breadcrumb.

First let’s see how is before-after state of this change.



Now let’s write a snippet for that:

Continue reading “Remove pagination trails from WooCommerce Breadcrumb”

Slow WP-Admin? Boost WP_Admin performance by disabling update checker.

In modern WordPress era things about theme and plugin repositories are far from ideal.

We don’t have centralized “app store” in WordPress world (similar to Apple Store and Google Play Store of mobile platforms) – that’s why we can list at least 3 different branches as defragmented segments:

  1. – where only free plugins are allowed.
  2. ThemeForest+Codecanyon – which doesn’t have own repository, but by using some 3rd party tools it is possible to have repository like channel.
  3. Premium self-hosted plugin/theme markets – Each of them has their own repositories.

Alongside with defragmantation this issue has another negative side – WP-Admin checks updates at background, with some transient-expire logic. When you have just one repository(official one – – that’s not a problem. But when you are using different 3rd party plugins, it causes nightmare.

Few months ago one of my clients asked me to check why his wp-admin works so slowly.

First as a quick check i made quick monitoring with Query Monitor plugin – and discovered that connecting to external hosts takes 4-10 seconds (!) each time – Some of repositories had a problem with response time – and that was affecting whole wp-admin performance.

So i decided to disable Update Checking in wp-admin, excluding Plugins.php page itself.

I wrote such small snippet and put it to functions.php of the theme:

if(is_admin() and strpos($_SERVER["REQUEST_URI"],'plugins.php')===false){

And that did the JOB. Update checking occurs when the client enters to plugins.php to see of there is an update. And that’s exactly what we needed.