I'm building a Wordpress theme which has a
WP_Filesystem call in it:
<?php $wp_filesystem = new WP_Filesystem_Direct(null); echo $wp_filesystem->get_contents(get_stylesheet_directory() . '/assets/images/Search_Glyph.svg'); ?>
I know that the
WP_Filesystem needs some dependencies. I load them now like this in
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
I don't know if this is the correct way to load the dependencies for the filesystem. I found an other question for plugin development and after some research I made the following code, which also works:
require_once ( ABSPATH . '/wp-admin/includes/file.php' ); WP_Filesystem();
What is the best way to load the dependencies for the
WP_Filesystem? The first or the second code part? Or is there other code which I should use?
To me it seems the second, because
WP_Filesystem() is a Wordpress function, but I don't know what it does exactly.
Many thanks in advance!