• Resolved ImageManni79

    (@manni79)


    Hello,

    do someone knows a possibility to exclude in sub-folders in the theme folder? I have to exclude some folders there.

    If I need a paid upgrade, please tell me which are needed.

    I read about WP filter which can be placed in function.php which can filter updraftplus files/directories also in theme folder.
    But I did not understand how it works to exculde a sub-folder. If someone knows about that please give me a small example for exclude for an example folder “/themename/sub1/sub2” under the wp theme folder. And of course recursively so everything in subfolders have to be also excluded.

    And please give me a tip if I have can place it somewhere in the functions.php of the child theme or if I have to place it to a specific part of the file.

    Thanks a lot and best regards
    Manni

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author ImageDavid Anderson / Team Updraft

    (@davidanderson)

    Hi Manni,

    There are up to six different mechanisms you can use to exclude things, documented in an FAQ here:
    https://updraftplus.com/faqs/how-can-i-exclude-particular-filesdirectories-from-the-backup/

    David

    Thread Starter ImageManni79

    (@manni79)

    Hello David,

    I know that already. But for example your normal excludes are only working for “uploads” and not for the “theme” directory. So I don’t need 6 solutions which are not able to filter a sub-directory out of the theme folder. On your link, solution 1 is only for uploads. Solution 2 is bad for theme directory perhaps they can have files changed on updates. Solution 3 only for extension…

    So, instead of showing your good, simply a good example for filtering a sub-folder as example “/themename/sub1/sub2”, would be very kind of you.

    Thanks a lot
    Manni

    Plugin Contributor Imagebcrodua

    (@bcrodua)

    Hi Manni,

    Will #2 from our guide help you achieve what you want? I copied it below.

    2. Create a file called .donotbackup in a directory

    If you create a file called “.donotbackup” (without the quotes) in any directory, then that directory (and its sub-directories) will be excluded from the backup.

    Regards,
    Bryle

    Thread Starter ImageManni79

    (@manni79)

    As I wrote “Solution #2 is bad for theme directory, perhaps they can have files changed on updates” … or by reinstall the theme.

    Also I don’t like solution #2 because I think it’s not a good idea to control behavior of plugins by creating files specific folders. It’s not good for overview and maintainability. How do you get a fast overview about excluded sub-folders, only by searching all theme folders for “.donotbackup” files? I think it’s not a good idea.

    Normally these kinds of plugin behavior should be controlled in the plugin itself. (But the plugin UI only supports “uploads” folder and not “theme”.)

    Under the official link is a solution #5 with placing some lines of code in the functions.php to exclude something.
    Perhaps you could give an example for filtering a “theme”-sub-folder as example “/themename/sub1/sub2” on this functions.php solution?

    And with a small advice, if I have to put it in the top/bottom of the functions.php of the child theme or if I can put it anywhere in that file.

    Thanks a lot
    Manni

    • This reply was modified 6 years, 7 months ago by ImageManni79.
    Plugin Contributor ImageDNutbourne

    (@dnutbourne)

    Hi Manni,

    For a filter that excludes a subfolder of a theme:

    add_filter('updraftplus_exclude_directory', 'my_updraftplus_exclude_directory', 10, 3);
    function my_updraftplus_exclude_directory($filter, $full_dir, $path) {
    return ($path == 'themes/<THEME NAME>/<sub_folder>') ? true : $filter;
    }

    This can be placed anywhere in the functions.php file.

    Thread Starter ImageManni79

    (@manni79)

    thank you! Solved.

    Would be nice to see this example in your official exclude-examples, because this filter is missing there.

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

The topic ‘Exclude in theme folder’ is closed to new replies.