forked from buddyboss/buddyboss-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoper.inc.php
More file actions
189 lines (173 loc) · 4.33 KB
/
Copy pathscoper.inc.php
File metadata and controls
189 lines (173 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
declare( strict_types=1 );
use Symfony\Component\Finder\Finder;
$namespace = 'BuddyBossPlatform';
return array(
// The prefix configuration. If a non null value will be used, a random prefix will be generated.
'prefix' => $namespace,
// Excludes specific namespaces from being prefixed.
'whitelist' => array(
// Composer and vendor namespaces.
'Composer\\*',
'MyCLabs',
'MyCLabs\\*',
// Global namespace classes and functions that should not be prefixed.
'\\WP_*',
'\\Plugin_*',
'\\Theme_*',
'\\Core_*',
'\\Language_*',
'\\Bulk_*',
'\\Automatic_*',
'\\Ajax_*',
'\\Walker*',
'\\SimplePie*',
// WordPress core classes without namespace (global namespace).
'WP_*',
'Plugin_*',
'Theme_*',
'Core_*',
'Language_*',
'Bulk_*',
'Automatic_*',
'Ajax_*',
'Walker*',
'SimplePie*',
// PHP built-in classes and functions (global namespace).
'Exception',
'Error',
'ErrorException',
'Throwable',
'Closure',
'Generator',
'Iterator',
'IteratorAggregate',
'ArrayAccess',
'Serializable',
'Countable',
'Stringable',
'stdClass',
'Reflection*',
'PDO*',
'DateTime*',
'DateInterval',
'DatePeriod',
'DateTimeZone',
'DateTimeImmutable',
'DateTimeInterface',
'JsonSerializable',
'Traversable',
'RecursiveIterator',
'RecursiveIteratorIterator',
'FilterIterator',
'LimitIterator',
'NoRewindIterator',
'InfiniteIterator',
'AppendIterator',
'MultipleIterator',
'DirectoryIterator',
'FilesystemIterator',
'RecursiveDirectoryIterator',
'GlobIterator',
'Spl*',
// WordPress constants.
'ABSPATH',
'WP_DEBUG',
'WP_CONTENT_DIR',
'WP_PLUGIN_DIR',
'WPINC',
'WP_CONTENT_URL',
'WP_PLUGIN_URL',
'WP_HOME',
'WP_SITEURL',
'WP_ADMIN',
'WP_LOAD',
),
'finders' => array(),
'patchers' => array(
function ( $file_path, $prefix, $contents ) {
// Check the file path and possibly return the original contents.
if ( strpos( $file_path, 'myclabs/php-enum' ) !== false ) {
return file_get_contents( $file_path ); // Revert to original contents.
}
// Fix any WordPress core classes that might have been prefixed.
$contents = str_replace(
array(
$prefix . '\\WP_',
$prefix . '\\Plugin_',
$prefix . '\\Theme_',
$prefix . '\\Core_',
$prefix . '\\Language_',
$prefix . '\\Bulk_',
$prefix . '\\Automatic_',
$prefix . '\\Ajax_',
$prefix . '\\Walker',
$prefix . '\\SimplePie',
// Also catch any other prefixed WordPress classes.
$prefix . '\\WP_Upgrader',
$prefix . '\\WP_Upgrader_Skin',
$prefix . '\\Plugin_Upgrader',
$prefix . '\\Theme_Upgrader',
$prefix . '\\Language_Pack_Upgrader',
$prefix . '\\Core_Upgrade',
$prefix . '\\File_Upload_Upgrader',
$prefix . '\\Automatic_Upgrader_Skin',
$prefix . '\\Bulk_Upgrader_Skin',
$prefix . '\\Bulk_Plugin_Upgrader_Skin',
$prefix . '\\Bulk_Theme_Upgrader_Skin',
$prefix . '\\Plugin_Installer_Skin',
$prefix . '\\Theme_Installer_Skin',
$prefix . '\\Language_Pack_Upgrader_Skin',
$prefix . '\\Plugin_Upgrader_Skin',
$prefix . '\\Theme_Upgrader_Skin',
$prefix . '\\WP_Ajax_Upgrader_Skin',
$prefix . '\\WP_Automatic_Updater',
),
array(
'WP_',
'Plugin_',
'Theme_',
'Core_',
'Language_',
'Bulk_',
'Automatic_',
'Ajax_',
'Walker',
'SimplePie',
// Also catch any other prefixed WordPress classes.
'WP_Upgrader',
'WP_Upgrader_Skin',
'Plugin_Upgrader',
'Theme_Upgrader',
'Language_Pack_Upgrader',
'Core_Upgrade',
'File_Upload_Upgrader',
'Automatic_Upgrader_Skin',
'Bulk_Upgrader_Skin',
'Bulk_Plugin_Upgrader_Skin',
'Bulk_Theme_Upgrader_Skin',
'Plugin_Installer_Skin',
'Theme_Installer_Skin',
'Language_Pack_Upgrader_Skin',
'Plugin_Upgrader_Skin',
'Theme_Upgrader_Skin',
'WP_Ajax_Upgrader_Skin',
'WP_Automatic_Updater',
),
$contents
);
// Additional fix for any remaining prefixed WordPress classes.
$contents = preg_replace(
'/\\\\' . preg_quote($prefix) . '\\\\WP_([A-Za-z_]+)/',
'WP_$1',
$contents
);
$contents = preg_replace(
'/\\\\' . preg_quote($prefix) . '\\\\(Plugin|Theme|Core|Language|Bulk|Automatic|Ajax|Walker|SimplePie)([A-Za-z_]*)/',
'$1$2',
$contents
);
return $contents;
},
),
);