File tree Expand file tree Collapse file tree 1 file changed +20
-9
lines changed Expand file tree Collapse file tree 1 file changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -16,21 +16,32 @@ final class Optml_Filters {
16
16
* @return bool Should do action on page?
17
17
*/
18
18
public static function should_do_page ( $ contains_flags , $ match_flags ) {
19
+
20
+ if ( empty ( $ contains_flags ) && empty ( $ match_flags ) ) {
21
+ return true ;
22
+ }
23
+
19
24
if ( ! isset ( $ _SERVER ['REQUEST_URI ' ] ) ) {
20
25
return true ;
21
26
}
22
27
23
- foreach ( $ match_flags as $ rule_flag => $ status ) {
24
- if ( $ rule_flag === $ _SERVER ['REQUEST_URI ' ] ) {
25
- return false ;
26
- }
28
+ $ check_against = [ $ _SERVER ['REQUEST_URI ' ] ];
29
+ if ( isset ( $ _SERVER ['HTTP_REFERER ' ] ) ) {
30
+ $ check_against [] = $ _SERVER ['HTTP_REFERER ' ];
27
31
}
28
- foreach ( $ contains_flags as $ rule_flag => $ status ) {
29
- if ( strpos ( $ _SERVER ['REQUEST_URI ' ], $ rule_flag ) !== false ) {
30
- return false ;
32
+ foreach ( $ check_against as $ check ) {
33
+ foreach ( $ match_flags as $ rule_flag => $ status ) {
34
+ if ( $ rule_flag === $ check ) {
35
+ return false ;
36
+ }
31
37
}
32
- if ( $ rule_flag === 'home ' && ( empty ( $ _SERVER ['REQUEST_URI ' ] ) || $ _SERVER ['REQUEST_URI ' ] === '/ ' ) ) {
33
- return false ;
38
+ foreach ( $ contains_flags as $ rule_flag => $ status ) {
39
+ if ( strpos ( $ check , $ rule_flag ) !== false ) {
40
+ return false ;
41
+ }
42
+ if ( $ rule_flag === 'home ' && ( empty ( $ check ) || $ check === '/ ' ) ) {
43
+ return false ;
44
+ }
34
45
}
35
46
}
36
47
You can’t perform that action at this time.
0 commit comments