Code Duplication    Length = 11-11 lines in 2 locations

src/admin/WL_Metabox/class-wl-metabox-field-sameas.php 1 location

@@ 35-45 (lines=11) @@
32
		// Only use mb_* functions when mbstring is available.
33
		//
34
		// See https://github.com/insideout10/wordlift-plugin/issues/693.
35
		if ( extension_loaded( 'mbstring' ) ) {
36
			mb_regex_encoding( 'UTF-8' );
37
38
			$merged = array_reduce( (array) $values, function ( $carry, $item ) {
39
				return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) );
40
			}, array() );
41
		} else {
42
			$merged = array_reduce( (array) $values, function ( $carry, $item ) {
43
				return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) );
44
			}, array() );
45
		}
46
47
		// Convert all escaped special characters to their original.
48
		$merged = array_map( 'urldecode', $merged );

src/admin/class-wordlift-admin-term-adapter.php 1 location

@@ 130-140 (lines=11) @@
127
		// Only use mb_* functions when mbstring is available.
128
		//
129
		// See https://github.com/insideout10/wordlift-plugin/issues/693.
130
		if ( extension_loaded( 'mbstring' ) ) {
131
			mb_regex_encoding( 'UTF-8' );
132
133
			$merged = array_reduce( (array) $_POST['wl_entity_id'], function ( $carry, $item ) {
134
				return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) );
135
			}, array() );
136
		} else {
137
			$merged = array_reduce( (array) $_POST['wl_entity_id'], function ( $carry, $item ) {
138
				return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) );
139
			}, array() );
140
		}
141
142
		delete_term_meta( $term_id, self::META_KEY );
143
		foreach ( array_unique( array_filter( $merged ) ) as $single ) {