Code Duplication    Length = 6-6 lines in 5 locations

classes/wordpress.php 5 locations

@@ 1089-1094 (lines=6) @@
1086
	private function user_update( $user_id, $params, $id_field = 'ID' ) {
1087
		$content              = array();
1088
		$content[ $id_field ] = $user_id;
1089
		foreach ( $params as $key => $value ) {
1090
			if ( 'wp_update_user' === $value['method_modify'] ) {
1091
				$content[ $key ] = $value['value'];
1092
				unset( $params[ $key ] );
1093
			}
1094
		}
1095
1096
		$user_id = wp_update_user( $content );
1097
@@ 1421-1426 (lines=6) @@
1418
	private function post_update( $post_id, $params, $id_field = 'ID', $post_type = '' ) {
1419
		$content              = array();
1420
		$content[ $id_field ] = $post_id;
1421
		foreach ( $params as $key => $value ) {
1422
			if ( 'wp_update_post' === $value['method_modify'] ) {
1423
				$content[ $key ] = $value['value'];
1424
				unset( $params[ $key ] );
1425
			}
1426
		}
1427
1428
		if ( '' !== $post_type ) {
1429
			$content['post_type'] = $post_type;
@@ 1744-1749 (lines=6) @@
1741
	private function attachment_update( $attachment_id, $params, $id_field = 'ID' ) {
1742
		$content              = array();
1743
		$content[ $id_field ] = $attachment_id;
1744
		foreach ( $params as $key => $value ) {
1745
			if ( 'wp_insert_attachment' === $value['method_modify'] ) { // Should also be insert attachment maybe.
1746
				$content[ $key ] = $value['value'];
1747
				unset( $params[ $key ] );
1748
			}
1749
		}
1750
1751
		if ( isset( $params['filename']['value'] ) ) {
1752
			$filename = $params['filename']['value'];
@@ 2079-2084 (lines=6) @@
2076
			$taxonomy = 'post_tag';
2077
		}
2078
		$args = array();
2079
		foreach ( $params as $key => $value ) {
2080
			if ( 'wp_update_term' === $value['method_modify'] ) {
2081
				$args[ $key ] = $value['value'];
2082
				unset( $params[ $key ] );
2083
			}
2084
		}
2085
		$term = wp_update_term( $term_id, $taxonomy, $args );
2086
2087
		if ( is_wp_error( $term ) ) {
@@ 2431-2436 (lines=6) @@
2428
	private function comment_update( $comment_id, $params, $id_field = 'comment_ID' ) {
2429
		$content              = array();
2430
		$content[ $id_field ] = $comment_id;
2431
		foreach ( $params as $key => $value ) {
2432
			if ( 'wp_update_comment' === $value['method_modify'] ) {
2433
				$content[ $key ] = $value['value'];
2434
				unset( $params[ $key ] );
2435
			}
2436
		}
2437
2438
		$updated = wp_update_comment( $content );
2439