Code Duplication    Length = 43-44 lines in 4 locations

includes/acf/core/location.php 4 locations

@@ 975-1018 (lines=44) @@
972
	*  @return	$options (array)
973
	*/
974
	
975
	function rule_match_taxonomy( $match, $rule, $options ) {
976
		
977
		// vars
978
		$taxonomy = $options['taxonomy'];
979
		
980
		
981
		// validate
982
		if( !$taxonomy ) {
983
			
984
			return false;
985
			
986
		}
987
		
988
		
989
		// compare
990
		if( $rule['operator'] == "==" ) {
991
			
992
        	$match = ( $taxonomy == $rule['value'] );
993
        	
994
        	// override for "all"
995
	        if( $rule['value'] == "all" ) {
996
	        
997
				$match = true;
998
				
999
			}
1000
			
1001
        } elseif( $rule['operator'] == "!=" ) {
1002
        	
1003
        	$match = ( $taxonomy != $rule['value'] );
1004
        		
1005
        	// override for "all"
1006
	        if( $rule['value'] == "all" ) {
1007
	        	
1008
				$match = false;
1009
				
1010
			}
1011
			
1012
        }
1013
		
1014
        
1015
        // return
1016
        return $match;
1017
        
1018
    }
1019
    
1020
    
1021
    /*
@@ 1035-1078 (lines=44) @@
1032
	*  @return	$options (array)
1033
	*/
1034
	
1035
	function rule_match_attachment( $match, $rule, $options ) {
1036
		
1037
		// vars
1038
		$attachment = $options['attachment'];
1039
		
1040
		
1041
		// validate
1042
		if( ! $attachment ) {
1043
			
1044
			return false;
1045
			
1046
		}
1047
		
1048
		
1049
		// compare
1050
		if( $rule['operator'] == "==" ) {
1051
			
1052
        	$match = ( $attachment == $rule['value'] );
1053
        	
1054
        	// override for "all"
1055
	        if( $rule['value'] == "all" ) {
1056
	        
1057
				$match = true;
1058
				
1059
			}
1060
			
1061
        } elseif( $rule['operator'] == "!=" ) {
1062
        	
1063
        	$match = ( $attachment != $rule['value'] );
1064
        		
1065
        	// override for "all"
1066
	        if( $rule['value'] == "all" ) {
1067
	        
1068
				$match = false;
1069
				
1070
			}
1071
			
1072
        }
1073
        
1074
        
1075
        // return
1076
        return $match;
1077
        
1078
    }
1079
    
1080
    
1081
    
@@ 1096-1139 (lines=44) @@
1093
	*  @return	$options (array)
1094
	*/
1095
	
1096
	function rule_match_comment( $match, $rule, $options ) {
1097
		
1098
		// vars
1099
		$comment = $options['comment'];
1100
		
1101
		
1102
		// validate
1103
		if( ! $comment ) {
1104
			
1105
			return false;
1106
			
1107
		}
1108
		
1109
		
1110
		// compare
1111
		if( $rule['operator'] == "==" ) {
1112
			
1113
        	$match = ( $comment == $rule['value'] );
1114
        	
1115
        	// override for "all"
1116
	        if( $rule['value'] == "all" ) {
1117
	        
1118
				$match = true;
1119
				
1120
			}
1121
			
1122
        } elseif( $rule['operator'] == "!=" ) {
1123
        	
1124
        	$match = ( $comment != $rule['value'] );
1125
        		
1126
        	// override for "all"
1127
	        if( $rule['value'] == "all" ) {
1128
	        
1129
				$match = false;
1130
				
1131
			}
1132
			
1133
        }
1134
        
1135
        
1136
        // return
1137
        return $match;
1138
        
1139
    }
1140
    
1141
    
1142
    /*
@@ 1156-1198 (lines=43) @@
1153
	*  @return	$options (array)
1154
	*/
1155
    
1156
    function rule_match_widget( $match, $rule, $options ) {
1157
		
1158
		// vars
1159
		$widget = $options['widget'];
1160
		
1161
		
1162
		// validate
1163
		if( ! $widget ) {
1164
			
1165
			return false;
1166
			
1167
		}
1168
		
1169
		
1170
		// compare
1171
		if( $rule['operator'] == "==" ) {
1172
			
1173
        	$match = ( $widget == $rule['value'] );
1174
        	
1175
        	// override for "all"
1176
	        if( $rule['value'] == "all" ) {
1177
	        
1178
				$match = true;
1179
				
1180
			}
1181
			
1182
        } elseif( $rule['operator'] == "!=" ) {
1183
        	
1184
        	$match = ( $widget != $rule['value'] );
1185
        		
1186
        	// override for "all"
1187
	        if( $rule['value'] == "all" ) {
1188
	        
1189
				$match = false;
1190
				
1191
			}
1192
			
1193
        }
1194
        
1195
                
1196
        // return
1197
        return $match;
1198
    }
1199
			
1200
}
1201