Category Archives: Uncategorized

Bose QC25 Equalizer preset

The Bose QC25 are great-sounding headphones. However the bass is way too heavy, which results in a muddled midsection. By bringing the lower frequencies down a bit and increasing high frequencies, you will get a much more balanced sounds profile. Simply tweak your equalizer according to the graph above and to your personal preference.

If you use foobar2000 you can download the exact preset here for the foo_dsp_xgeq component here.

Force WordPress security upgrade to latest minor version

Create a file in the WP root directory called force-minor-update.php and call it via your web browser.

Use this code:

require( dirname(__FILE__) . '/wp-load.php' );

//Clear transients
global $wpdb;
$sql = "DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_%'";
$clean = $wpdb->query( $sql );

//Clear object cache

//Attempt auto update

Original source

WordPress Request Buster


WordPress has functions for getting remote resources (using cURL or PHP streams). When these functions run during a page load request, they will slow down your site, because WordPress has to wait for the external request before returning the page. This is bad practice, yet so many plugins and themes use it. Debugging is notoriously hard because requests appear only occasionally (they are often cached via the Transients API).

Request Buster is a plugin that shows you in the top admin bar if any remote requests were triggered by the current page load. Keeping it open as you develop and use your site will let you find plugins that make remote requests.

The plugin is available on GitHub – click here.

The correct way

The correct way to handle loading of remote resources are:

  • Serving the page and grabbing the remote resource via AJAX OR
  • Schedule the remote request to go through WP CRON.

Here are the functions this plugin catches:


Trimming down Yoast SEO in the admin panel – updated 2014 version

Yoast SEO has an obnoxious habit of taking over your admin interface, so it looks something like this:


Notice how much space Yoast takes up. Unless you are hardcore about your SEO, you really don’t want all that screen estate being wasted.

With just a few lines of code inside your themes functions.php file you can go from that crowded mess to this: yoast-seo-uncluttered

Here’s the snippet you need:

//Remove "page analysis" and annoying SEO columns
add_filter( 'wpseo_use_page_analysis', '__return_false' );

//Make sure the SEO box is at the very bottom of the post edit screen
add_filter( 'wpseo_metabox_prio', 'custom_metabox_prio');
function custom_metabox_prio($in)
    return 'low';

//Remove SEO menu from Admin bar
add_action( 'wp_before_admin_bar_render', 'custom_admin_bar_render' );
function custom_admin_bar_render()
    global $wp_admin_bar;

//Remove "Has been updated" notification and tour bubble.
add_action( 'get_user_metadata', 'custom_get_user_metadata', 10, 4 );
function custom_get_user_metadata($value, $object_id, $meta_key, $single) {
  if($meta_key === 'wpseo_ignore_tour') {
    return true;

  if($meta_key === 'wpseo_seen_about_version') {
    return defined('WPSEO_VERSION') ? WPSEO_VERSION : null;

  return $value;

You can still change the per-page SEO settings, it just won’t clutter your admin.

It is also possible to remove the SEO box from the post edit screen by going up to Screen Options (top right) and uncheck the “WordPress SEO by Yoast” box.

This post was inspired by the following snippet by Jonathan Warren.

Fix errors in NS Cloner Pro plugin

I like developing with errors enabled. Unfortunately the team who makes NS Cloner does not, which results in tons of errors when using NS Cloner pro. These are mostly trivial errors like uninitialized variables and deprecation warnings. Regardless, they make the plugin unusable for me.

Here is a quick plugin that disables PHP errors altogether when you’re in the NS Cloner Pro tab. Save this snippet as: /wp-content/mu-plugins/ns-cloner-fix.php

(If you don’t have an mu-plugins directory, create it)

Plugin Name: NS Cloner error fix
Plugin URI:
Description: Disables error reporting while we're on the NS Cloner tab
Version: 2014.04.01
Author: khromov
Author URI:
License: GPL2

add_action('muplugins_loaded', function()
    if(get_current_blog_id() === 1)
        $siteurl = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
        if(strpos($siteurl, '/wp-admin/network/sites.php?page=ns-cloner-pro') !== false)

GeoIP Browser Language Redirect for WPML


I needed to send users reliably to the correct WPML translation depending on the country they came from. The “Browser language redirect” option that WPML provides is a very simple method using the HTTP_ACCEPT_LANGUAGE header. It doesn’t work reliably, and assumes you have named your languages after proper locale names.

GeoIP Redirector for WPML to the rescue!

It uses a GeoIP database (MaxMind) to pinpoint user location more exactly. It also lets you specify your own mappings (user country to language) easily.

Feel free to fork the plugin on GitHub, or download it directly. (Please read for instructions on setting the plugin up.)

InfiniteWP snippet library for Code Snippets Addon

InfiniteWP Logo

InfiniteWP Code Snippets Addon is a great tool to easily run code snippets on all your wordpress sites simultaneously.

Below you will find a couple of useful snippets for it. I’m going to add more snippets shortly. In the mean time feel free to post any good snippets you have in the comments!

Show blog title

echo get_bloginfo();    

Here is what that snippet looks in InfiniteWP. (More snippets after the image)

Code snippet example

Basic database interaction, getting the site URL

global $wpdb;
$table_name = $wpdb->prefix . "options";
$sql = "SELECT option_value FROM ".$table_name." WHERE option_name = 'siteurl';";
$root_url = $wpdb->get_var($sql);
echo $root_url;

This will return your site URL from the database.

Show server load averages

$loads = '';
foreach(sys_getloadavg() as $load)
    $loads .= $load . ', ';
echo substr($loads, 0, -2);

Show disk space (total/free) on your host

function decodeSize($bytes)
    $types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
    for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /= 1024, $i++ );
    return( round( $bytes, 2 ) . " " . $types[$i] );

function freeSpacePercentage($folder = ".")
    return round((decodeSize(disk_free_space("."))/decodeSize(disk_total_space("."))*100)) . "%";

function usedSpacePercentage($folder = ".")
    return round(((100*decodeSize(disk_free_space("."))/decodeSize(disk_total_space(".")))-100)*-1) . "%";

echo "Disk space: " . decodeSize(disk_free_space(".")) . " of " . decodeSize(disk_total_space("."));
echo " - ";
echo freeSpacePercentage() . ' free.';

Note 1: Some shared hosts have disabled the disk_total_space(). In those circumstances the snippet does not work.
Note 2: Free space is free space on the physical drive where WordPress is installed. On shared hosts this does not accurately represent your disk quota.

Purpose of this blog

My name is Stanislav. I am a driven web developer with a passion for both UX and backend system design.

I work at Aftonbladet (Schibsted Media Group). Check me out on LinkedIn!

This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Check out my older blog for more programming and server maintenance-related content!