Code Duplication    Length = 46-46 lines in 2 locations

ui/fields/plupload.php 1 location

@@ 76-121 (lines=46) @@
73
74
$limit_types = trim( str_replace( array( ' ', '.', "\n", "\t", ';' ), array( '', ',', ',', ',' ), $limit_types ), ',' );
75
76
if ( pods_version_check( 'wp', '3.5' ) ) {
77
    $mime_types = wp_get_mime_types();
78
79
    if ( in_array( $limit_file_type, array( 'images', 'audio', 'video' ) ) ) {
80
        $new_limit_types = array();
81
82
        foreach ( $mime_types as $type => $mime ) {
83
            if ( 0 === strpos( $mime, $limit_file_type ) ) {
84
                $type = explode( '|', $type );
85
86
                $new_limit_types = array_merge( $new_limit_types, $type );
87
            }
88
        }
89
90
        if ( !empty( $new_limit_types ) )
91
            $limit_types = implode( ',', $new_limit_types );
92
    }
93
    elseif ( 'any' != $limit_file_type ) {
94
        $new_limit_types = array();
95
96
        $limit_types = explode( ',', $limit_types );
97
98
        foreach ( $limit_types as $k => $limit_type ) {
99
            $found = false;
100
101
            foreach ( $mime_types as $type => $mime ) {
102
                if ( 0 === strpos( $mime, $limit_type ) ) {
103
                    $type = explode( '|', $type );
104
105
                    foreach ( $type as $t ) {
106
                        if ( !in_array( $t, $new_limit_types ) )
107
                            $new_limit_types[] = $t;
108
                    }
109
110
                    $found = true;
111
                }
112
            }
113
114
            if ( !$found )
115
                $new_limit_types[] = $limit_type;
116
        }
117
118
        if ( !empty( $new_limit_types ) )
119
            $limit_types = implode( ',', $new_limit_types );
120
    }
121
}
122
123
if ( !empty( $limit_types ) )
124
    $plupload_init[ 'filters' ][ 0 ][ 'extensions' ] = $limit_types;

classes/fields/file.php 1 location

@@ 689-734 (lines=46) @@
686
687
            $limit_types = trim( str_replace( array( ' ', '.', "\n", "\t", ';' ), array( '', ',', ',', ',' ), $limit_types ), ',' );
688
689
            if ( pods_version_check( 'wp', '3.5' ) ) {
690
                $mime_types = wp_get_mime_types();
691
692
                if ( in_array( $limit_file_type, array( 'images', 'audio', 'video' ) ) ) {
693
                    $new_limit_types = array();
694
695
                    foreach ( $mime_types as $type => $mime ) {
696
                        if ( 0 === strpos( $mime, $limit_file_type ) ) {
697
                            $type = explode( '|', $type );
698
699
                            $new_limit_types = array_merge( $new_limit_types, $type );
700
                        }
701
                    }
702
703
                    if ( !empty( $new_limit_types ) )
704
                        $limit_types = implode( ',', $new_limit_types );
705
                }
706
                elseif ( 'any' != $limit_file_type ) {
707
                    $new_limit_types = array();
708
709
                    $limit_types = explode( ',', $limit_types );
710
711
                    foreach ( $limit_types as $k => $limit_type ) {
712
                        $found = false;
713
714
                        foreach ( $mime_types as $type => $mime ) {
715
                            if ( 0 === strpos( $mime, $limit_type ) ) {
716
                                $type = explode( '|', $type );
717
718
                                foreach ( $type as $t ) {
719
                                    if ( !in_array( $t, $new_limit_types ) )
720
                                        $new_limit_types[] = $t;
721
                                }
722
723
                                $found = true;
724
                            }
725
                        }
726
727
                        if ( !$found )
728
                            $new_limit_types[] = $limit_type;
729
                    }
730
731
                    if ( !empty( $new_limit_types ) )
732
                        $limit_types = implode( ',', $new_limit_types );
733
                }
734
            }
735
736
            $limit_types = explode( ',', $limit_types );
737