Useful Snippets

Welcome!


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

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Subscribe to RSS feed


Fix errors in NS Cloner Pro plugin

Stanislav KhromovStanislav Khromov

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)

<?php
/*
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: http://profiles.wordpress.org/khromov/
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)
            error_reporting(0);
    }
});

Full-stack impostor syndrome sufferer & Software Engineer at Schibsted Media Group

Comments 1
  • Never Settle
    Posted on

    Never Settle Never Settle

    Reply Author

    Thank you for working with the Cloner and sharing this band-aid on the issue. We’re taking your point to heart and rebuilding V3 with errors enabled :) We’ll also have all of this cleaned up when we release the next version in the near future, and are always open to feedback on how to improve our products!

    Much appreciated!
    NS