Support » Plugin: WordPress File Monitor Plus » [Plugin: WordPress File Monitor Plus] Ignore File Patterns

  • Resolved mistaecko


    I don’t think it is currently possible to ignore/exclude file patterns. It would be really nice though!
    E.g. look at the latest timthumb version. It uses .txt files for cached files. I would like to ignore those but still be able to see changes to any other file in the cache directory.

    Personally, I’d be thrilled to see an additional filter that uses regex and works on the full path of the file. This would allow for maximum flexibility while not generating any problems for backwards compatibility!

    Another option is to allow for simple wildcard patterns, e.g.


    (Internally I would still translate this to regular expressions though).



Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Author Scott Cariss


    Hi mistaecko,

    I’ve been looking into this in the past but what has stopped me doing this that regular expressions in programming is my weak spot. I really struggle to understand them so it’s always put me off attempting this feature.

    What I’m thinking though as a half way point is an input box that lets you enter your own regular expressions. So to use it you would have to be a bit of an expert. Not as easy using wildcards unfortunately.

    Yeah, I totally understand. Regular Expressions are a beast! ๐Ÿ˜‰

    I am not so sure that there would be a lot of people using this feature anyway.

    What would really be nice is the wildcard support I guess.

    I wonder whether it would make sense to enable simple wildcard support (*) on the individual fields. This could be done by using regex internally.

    You don’t really need to understand the detailed syntax of regular expressions to use them to implement wildcard support.
    The concept is as follows:
    1. Take the user input and run it through preg_quote – this will put a backslash in front of every character that is part of the regex syntax
    $input = preg_quote($input);

    2. Then use str_replace to turn all wildcards into the correct regex syntax – the wildcard * should match any character, which in regex syntax is .* (dot means any character, and asterix means 0 or more times). We have to consider that in step 1. all asterix wildcards have been prefixed with a backslash
    $input = str_replace("\\*", ".*", $input);

    3. Then add a ^ at the beginning and a $ at the end. These are the regex markers for line beginning and line ending.

    I am still reflecting on whether there are better solutions. I had a look around (google) to see if there are any PHP projects or libs out there which have implemented something similar. Sometimes it’s better not to reinvent the wheel. But haven’t found anything convincing yet.


    And, of course, you would then have to match your string (filename, dir name, absolute dir or file path) against each pattern with
    if (preg_match("/$pattern/i", $nameOrPath))
    The slashes are part of the regex definition, the i is a ‘switch’ that makes the pattern case insensitive. preg_match will return the number of matches or 0 in case of no match. Since we added line beginning and line ending markers there can only be 1 match or none at all, but all int values greater than 0 will evaluate to TRUE anyway.

    Plugin Author Scott Cariss


    I’m thinking using would be better to match when using wildcards *

    What do you think?

    You are probably right!

    Starting from PHP 5.3 this should work on Windows as well.

    I didn’t really get the meaning of the parameters by reading the PHP docs. Found a better explanation of FNM_PATHNAME here.

    If the FNM_ PATHNAME flag is set in the Flags parameter, a / (slash) in the String parameter is explicitly matched by a / in the Pattern parameter. It is not matched by either the * (asterisk) or ? (question-mark) special characters, nor by a bracket expression. If the FNM_PATHNAME flag is not set, the / is treated as an ordinary character.

    If I understand correctly, the difference is this:

    FNM_PATHNAME=1  /abc/def/file.txt does *not* match /abc/*.txt
    FNM_PATHNAME=0 /abc/def/file.txt *does* match /abc/*.txt

    I would rather expect FNM_PATHNAME=1 behavior. However, the turning it off (=0) could be more powerful. One could do something like /blbla/cache/*.txt and this would ignore all text files in all subdirs of the /blbla/cache directory.

    Or maybe even */cache/*.txt

    What do you think?

    Plugin Author Scott Cariss


    Well if you follow the comments on the PHP page you can see people have provided alternatives for windows support that fall back to preg_match().

    I havent looked into fnmatch much yet as I’m very busy at work atm. Not going to be free really till the new year to try this out. Might get a go on xmas day when there is nothing on the television.

    Plugin Author Scott Cariss


    Now supported in version 1.4

    Hi Scott,

    I upgraded to v.1.4.

    But the feature doesn’t work.
    When I upgraded, my setting automatically changed the new format.
    For example,
    Exact Dirs To Ignore E:\WWWROOT\wp-content\blogs.dir\3\files
    ====>> Dirs/Files To Ignore E:\WWWROOT\wp-content\blogs.dir\3\files\*

    But the plugin does not ignore the directory.
    What’s wrong? Do I need something else?

    Plugin Author Scott Cariss


    Hi o6asan,

    Please try version 1.4.1

    Hi Scott,

    Now I update to version 1.4.1 and it works very well.

    Thanks so much for your quick job.

    By the way, I’ll send a new language zip.

    Plugin Author Scott Cariss


    Good stuff.

    Hi Scott,

    ignoring one folder is working fine for me. But I cannot get multiple folders to work. I tried separating them by lines and by lines plus colons.
    Could you give a hint how to do it right?

    MANY THANKS for a great plugin that really adds to WP security!

    Cheers, Jรถrg.

    Plugin Author Scott Cariss


    Simply putting entries on a new line should work.

    What are your exact ignore settings. Maybe from that I can tell you where you are going wrong.

    Hi Scott,

    I tried several approaches:

    Multiple lines


    Multiple lines, comma separated


    Single line, comma separated


    … and all of the comma versions with semicolon instead of comma.

    Plugin Author Scott Cariss



    ^^ that one should work fine….

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘[Plugin: WordPress File Monitor Plus] Ignore File Patterns’ is closed to new replies.