1 | <?php |
||
8 | class Excludes { |
||
9 | |||
10 | /** |
||
11 | * The array of exclude rules. |
||
12 | * |
||
13 | * @var array |
||
14 | */ |
||
15 | private $excludes; |
||
16 | |||
17 | /** |
||
18 | * The array of default exclude rules |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | private $default_excludes = array( |
||
23 | '.svn', |
||
24 | '_svn', |
||
25 | 'CVS', |
||
26 | '_darcs', |
||
27 | '.arch-params', |
||
28 | '.monotone', |
||
29 | '.bzr', |
||
30 | '.git', |
||
31 | '.hg', |
||
32 | 'backwpup-*', |
||
33 | 'updraft', |
||
34 | 'wp-snapshots', |
||
35 | 'backupbuddy_backups', |
||
36 | 'pb_backupbuddy', |
||
37 | 'backup-db', |
||
38 | 'Envato-backups', |
||
39 | 'managewp', |
||
40 | 'backupwordpress-*-backups', |
||
41 | ); |
||
42 | |||
43 | public function __construct( $excludes = array() ) { |
||
46 | |||
47 | /** |
||
48 | * Set the exclude rules. |
||
49 | * |
||
50 | * Excludes rules should be a complete or partial directory or file path. |
||
51 | * Wildcards can be specified with the * character. |
||
52 | * |
||
53 | * @param string|array $excludes The list of exclude rules, accepts either |
||
54 | * a comma separated list or an array. |
||
55 | */ |
||
56 | public function set_excludes( $excludes ) { |
||
57 | |||
58 | if ( is_string( $excludes ) ) { |
||
59 | $excludes = explode( ',', $excludes ); |
||
60 | } |
||
61 | |||
62 | $this->excludes = $excludes; |
||
63 | |||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Get the excludes |
||
68 | * |
||
69 | * Returns any user set excludes as well as the default list. |
||
70 | * |
||
71 | * @return array The array of exclude rules. |
||
72 | */ |
||
73 | public function get_excludes() { |
||
76 | |||
77 | /** |
||
78 | * Get the excludes prepared for use with regex. |
||
79 | * |
||
80 | * The primary difference being that any wildcard (*) rules are converted to the regex |
||
81 | * fragment `[\s\S]*?`. |
||
82 | * |
||
83 | * @return array The array of exclude rules |
||
84 | */ |
||
85 | public function get_excludes_for_regex() { |
||
109 | |||
110 | /** |
||
111 | * Get the user defined excludes. |
||
112 | * |
||
113 | * @return array The array of excludes. |
||
114 | */ |
||
115 | public function get_user_excludes() { |
||
126 | |||
127 | /** |
||
128 | * Get the array of default excludes. |
||
129 | * |
||
130 | * @return array The array of excludes. |
||
131 | */ |
||
132 | public function get_default_excludes() { |
||
153 | |||
154 | /** |
||
155 | * normalise the exclude rules so they are ready to work with. |
||
156 | * |
||
157 | * @param array $excludes The array of exclude rules to normalise. |
||
158 | * |
||
159 | * @return array The array of normalised rules. |
||
160 | */ |
||
161 | public function normalize( $excludes ) { |
||
186 | } |
||
187 |