Remove image sizes in WordPress

/** * Function to Remove image size. * @param [string] $size */ function remove_image_size_by_size($size) { $dimension = explode(‘x’, $size); global

Handful WP-CLI Tricks

Delete posts based on search # Spaces needs replace with + (plus sign) # Eg: hello+world wp post delete $(wp

Fix CMD output when using shell_exec() from PHP

/** * Fix weird output encoding. */ function run_command($command) { $string = shell_exec($command); $string = mb_convert_encoding($string, ‘UTF-8’, ‘UTF-16LE’); return $string;

Linux touch command for Windows

Create touch.cmd with the following content and it to ENV Path. @echo off setlocal enableextensions disabledelayedexpansion (for %%a in (%*)

Things to do after deploying a Ubuntu server

Disable ipv6 Create /etc/sysctl.d/60-ipv6-disable.conf with the following contents: net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 Run service procps

Tweaking OneSignal WordPress Plugin

/** * Send push based on last active time (Intelligent Delivery). */ add_filter( ‘onesignal_send_notification’, function( $fields ) { $fields[‘delayed_option’] =

Tweaking WordPress

/** * Logged in for 1 year. */ add_filter( ‘auth_cookie_expiration’, function() { return YEAR_IN_SECONDS; });

Use CDN with WP Offload Media

add_filter(‘as3cf_get_attachment_url’, function($url) { // Regex matches both http and https. $url = ‘’ . preg_replace(‘#^https?://#’, ”, $url); return $url; });

Tweaking Mail-in-a-Box

Disable Greylisting Disabling Greylisting helps to receive emails without any delay. touch /etc/postgrey/whitelist_clients.local nano /etc/postgrey/whitelist_clients.local Add contents: # Don’t greylist

Tweaking WSL (Windows Subsystem for Linux)

Fix files/folder permissions Add some useful aliases cd && touch .bash_aliases add below lines to .bash_aliases # Open Windows

Use Rocket-Nginx under RunCloud

Login as root then enter following commands. cd /etc/nginx-rc git clone cd rocket-nginx cp rocket-nginx.ini.disabled rocket-nginx.ini php rocket-parser.php As