JRoy
1/13/2020 - 1:20 AM

Disable Plugins Conditionally - Speed Test

<?php 
 
$request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
 
$is_admin = strpos( $request_uri, '/wp-admin/' );
 
if( false === $is_admin && isset($_GET['dev']) ){
	
	add_filter( 'option_active_plugins', function( $plugins ){
		$uninstall = array(

        );
        
        if( !empty($uninstall) ) {
            foreach( $uninstall as $uninstall_plugin ) {
                $k = array_search( $uninstall_plugin, $plugins );
                if( false !== $k ){ unset( $plugins[$k] ); }
            }
        }
		
		return $plugins;
	});
	
	
	$active_plugins = get_option( 'active_plugins' );
	$plugins = "";
	if( count( $active_plugins ) > 0 ){
		$plugins = "<ul>";
		foreach ( $active_plugins as $plugin ) {
			$plugins .= "<li>" . $plugin . "</li>";
		}
		$plugins .= "</ul>";
	}
	echo $plugins;
}
 
?>