How to create a subdirectory in a child-theme via functions.php from the Theme editor without FTP acces?

Question

I would like to override a file from a WC-vendor plugin with a file I place in the child theme, but I do not have access to the server via FTP or the Terminal. So I can not just create and upload folders easy. My approach is to use functions.php file from the child theme in the Theme Editor:

I can create a new file

// Create a new file in a subfolder
add_action('after_setup_theme', function() {
    $file = get_stylesheet_directory() . '/settings.php';
    touch($file);
});  

but when I use a path with subfolders it does not create the file

// Create a new file in a subfolder
add_action('after_setup_theme', function() {
    $file = get_stylesheet_directory() . '/wc-vendors/dashboard/settings/settings.php';
    touch($file);
});

On my local machine it spits out following error message

file or directory in /Applications/MAMP/htdocs/panfruta/wp-content/themes/astra-child/functions.php on line 31

I tried to create folder with

mkdir($file, 0777);

without success.

Is there a workaround to create the desired folder structure?

0
Merlin Kucklick 2 months 0 Answers 10 views 0

Leave an answer