Skip to content

Instantly share code, notes, and snippets.

@timwhitlock
Created May 6, 2017 10:35
Show Gist options
  • Save timwhitlock/babbd588b4a49765cd2b014acb4df9f8 to your computer and use it in GitHub Desktop.
Save timwhitlock/babbd588b4a49765cd2b014acb4df9f8 to your computer and use it in GitHub Desktop.
Ensures custom SSH2 class is loaded before autoloader is triggered by class_exists
<?php
/*
Plugin Name: Preload SSH class
Plugin URI: https://wordpress.org/support/topic/conflict-with-ssh-sftp-updater-support-ssh2-fs_method/
Description: Ensures custom SSH2 class is loaded before autoloader is triggered by class_exists
Author: Tim Whitlock
*/
function filter_filesystem_method( $method = '' ){
if( 'ssh2' === $method && ! class_exists('WP_Filesystem_SSH2',false) ){
if( $path = phpseclib_filesystem_method_file('','ssh2') ){
require_once $path;
}
}
return $method;
};
add_filter('filesystem_method','filter_filesystem_method',10,1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment