WP Rocket Hooks

after_rocket_clean_post action is fired after clear cache of a post. add_action( ‘after_rocket_clean_post’, function( $post ) { if ( $post->post_name == ‘foo’ ) { rocket_clean_files( ‘https://example.com/foo/’ ); } }); after_rocket_clean_domain action is fired after clear cache of whole domain (clear all

WP Smush using WP-CLI

If you use WP Smush then you should know that you can use it via WP-CLI too. This feature became available since the version 3.1 Here are some commands: /** * Optimize image. * * ## OPTIONS * * [–type=<type>]

Remove any action or filter in WordPress

Sometimes we need to remove actions or filters added via Themes or Plugins. To remove a action or filter check mekshq.com’s guide. But sometimes that is not enough, sometimes some hooks are too stubborn to remove. In that case use

Delete comment replies when deleting comment in WordPress

By default when a comment is deleted, WordPress does not delete the replies of that comment. With this function whenever a comment is deleted, its replies will be automatically deleted. /** * Delete comment replies when deleting comment. */ add_action(

Useful Linux Commands

Run command without output command > /dev/null 2>&1 Run command in background without output nohup command > /dev/null 2>&1 & List all files recursively find -type f -printf “%[email protected] %p\n” | cut -d\ -f2- Search for specific file recursively find

Cloudflare optimal & recommended settings

If you Google “cloudflare settings for wordpress” you will find a lot people giving tutorials how to speed up sites using cloudflare. Let me tell you all of them are bullshit. The more you optimize cloudflare the more problems you’re

Useful Yoast Hacks

I use Yoast SEO on all of my WordPress setup. Here are some hacks that I use for it. Disable Yoast JSON-LD completely add_filter( ‘wpseo_json_ld_output’, ‘__return_false’ ); Noindex paginated pages Since the version 7.0 Yoast SEO started paginated pages indexation

Stop generating additional image sizes in WordPress

When a image added to media library, WordPress will generate 6 default image sizes and store them separately. Then theme and plugins might generate some additional image sizes. In my case total of 13 additional image sizes were created. 🤯

How I put a stop to spam in Contact Form 7

Contact Form 7 Limit Submissions: Unfortunately there was no available plugins or codes to limit the submissions in Contact Form 7, so I built one. This is how I built it. Create Table in Database: First I created a table

Useful Nginx Hacks

The Regular Expression translates to: “rewrite all URLs without any ‘.’ (dot) in them that don’t end with a ‘/’ to the URI + ‘/’” Or simply: “If the URI doesn’t have a period and does not end with a

Useful RunCloud Hacks

In this page I shared all the RunCloud hacks that I have been using. 1) WordPress under subdirectory in Nginx If you want to install WordPress under subdirectory in RunCloud Native Nginx stack, then this will help you configure it.

How I almost got hacked

This is a story about how I almost got hacked. By “almost” I meant the virus infected me but the attacker did not accomplish what he was supposed to. Let me tell you briefly. Today I was debugging & testing

How I discovered faulty code in a WordPress theme

Update: I can’t seem to reproduce the issue anymore. I don’t know what exactly happened. I have been using Publisher WordPress Theme by Better-Studio for a long time. 5 of my clients uses it. And to be honest this is

Force HTTPS non-www or www using .htaccess

Use the following codes on .htaccess to force non-www or www on your site. The below codes works perfectly when your setup using Nginx in front of Apache as a reverse proxy. Force non-www + HTTPS # Force non-www+https <IfModule