Title: Plugin always throws Error if FS_METHOD is not direct
Last modified: July 23, 2025

---

# Plugin always throws Error if FS_METHOD is not direct

 *  Resolved [Hidenori ISHIKAWA](https://wordpress.org/support/users/hideishi/)
 * (@hideishi)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/plugin-always-throws-error-if-fs_method-is-not-direct/)
 * NEVER CALL WP_Filesystem() WITHOUT ANY ARGUMENTS.
 * The root cause is in ultimate-addons-for-gutenberg/lib/gutenberg-templates/ast-
   block-plugin-loader.php public static function get_filesystem().
 * If FS_METHOD is not direct (ftpext for example), WP_Filesystem() returns a filesystem
   that cannot be accessed. This causes following put_contents() and other APIs 
   to raise error.
 * You need to set proper credentials as you do in ultimate-addons-for-gutenberg/
   classes/class-uagb-filesystem.php public function get_filesystem(). Othewise,
   check FS_METHOD is direct before you call get_filesystem()->put_contents().
    -  This topic was modified 10 months, 2 weeks ago by [Hidenori ISHIKAWA](https://wordpress.org/support/users/hideishi/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [Hidenori ISHIKAWA](https://wordpress.org/support/users/hideishi/)
 * (@hideishi)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/plugin-always-throws-error-if-fs_method-is-not-direct/#post-18566817)
 * Following is an extract from PHP error_log.
 *     ```wp-block-code
       PHP Fatal error:  Uncaught TypeError: ftp_fput(): Argument #1 ($ftp) must be of type FTP\Connection, null given in /DocumentRoot/wp-admin/includes/class-wp-filesystem-ftpext.php:212Stack trace:#0 /DocumentRoot/wp-admin/includes/class-wp-filesystem-ftpext.php(212): ftp_fput()#1 /DocumentRoot/wp-content/plugins/ultimate-addons-for-gutenberg/lib/gutenberg-templates/inc/classes/ast-block-templates-notices.php(36): WP_Filesystem_FTPext->put_contents()#2 /DocumentRoot/wp-content/plugins/ultimate-addons-for-gutenberg/lib/gutenberg-templates/ast-block-plugin-loader.php(106): Gutenberg_Templates\Inc\Classes\Ast_Block_Templates_Notices->has_file_read_write()#3 /DocumentRoot/wp-includes/class-wp-hook.php(324): Gutenberg_Templates\Ast_Block_Plugin_Loader->load_classes()#4 /DocumentRoot/wp-includes/class-wp-h...
       ```
   
 *  [Mohsin Ghouri](https://wordpress.org/support/users/mohsinbsf/)
 * (@mohsinbsf)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/plugin-always-throws-error-if-fs_method-is-not-direct/#post-18570701)
 * Hi [@hideishi](https://wordpress.org/support/users/hideishi/),
 * Sorry for the inconvenience caused to you.
 * I am not able to replicate the issue on my installation. I request you open a
   support ticket from here:[https://wpspectra.com/support/](https://wpspectra.com/support/)
   so that our support dev can check your site configuration and assist you.
 * Looking forward to hearing from you.
 *  Thread Starter [Hidenori ISHIKAWA](https://wordpress.org/support/users/hideishi/)
 * (@hideishi)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/plugin-always-throws-error-if-fs_method-is-not-direct/#post-18573292)
 * [@mohsinbsf](https://wordpress.org/support/users/mohsinbsf/)
 * Thank you for your comment. I should have written the steps to reproduce the 
   problem.
    1. Use PHP 8.2 or later. Also use latest WordPress and latest Spectra Gutenberg
       Blocks plugin.
    2. Use FS_METHOD as direct first.
    3. Create some blocks with the plugin.
    4. Change FS_METHOD as ftpext and also specify all necessary defines (such as FTP_USER,
       FTP_PASS, etc. those are required for FS_METHOD=ftpext).
    5. Access the site again.
 * As I wrote above, while initializing the plugin, plugin calls WP_Filesystem()
   function without any arguments passed to the function. This is the root cause.
 * By commenting out the code or properly supplying the arguments (i.e. credentials)
   in ultimate-addons-for-gutenberg/lib/gutenberg-templates/ast-block-plugin-loader.
   php where it calls WP_Filesystem(), you can bypass the error raised.
 * So I strongly advise you to fix the code that calls WP_Filesystem() without any
   credentials. Specification in WordPress codecs also states that you need to supply
   the credential to this function if the filesystem requires any credentials. FS_METHOD
   = direct is the only exception that does not require any credentials. You should
   not blindy suppose that everybody using WordPress uses FS_METHOD = direct.
    -  This reply was modified 10 months, 2 weeks ago by [Hidenori ISHIKAWA](https://wordpress.org/support/users/hideishi/).
 *  [Mohsin Ghouri](https://wordpress.org/support/users/mohsinbsf/)
 * (@mohsinbsf)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/plugin-always-throws-error-if-fs_method-is-not-direct/#post-18575356)
 * Hi [@hideishi](https://wordpress.org/support/users/hideishi/),
 * Sorry for the inconvenience caused to you.
 * I will surely convey your feedback to our concerned developers. We are always
   keen to listen to our customers and to receive their feedback. This is the best
   way to improve our products and services and maintain our client’s satisfaction.
   🙂
 * Have a nice day!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Plugin always throws Error if FS_METHOD is not direct’ is closed to new
replies.

 * ![](https://ps.w.org/ultimate-addons-for-gutenberg/assets/icon-256x256.gif?rev
   =3240412)
 * [Spectra Gutenberg Blocks – Website Builder for the Block Editor](https://wordpress.org/plugins/ultimate-addons-for-gutenberg/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-addons-for-gutenberg/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-addons-for-gutenberg/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-addons-for-gutenberg/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-addons-for-gutenberg/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-addons-for-gutenberg/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Mohsin Ghouri](https://wordpress.org/support/users/mohsinbsf/)
 * Last activity: [10 months, 2 weeks ago](https://wordpress.org/support/topic/plugin-always-throws-error-if-fs_method-is-not-direct/#post-18575356)
 * Status: resolved