Code Duplication    Length = 26-26 lines in 2 locations

json-endpoints/class.wpcom-json-api-post-endpoint.php 1 location

@@ 441-466 (lines=26) @@
438
				}
439
				$response[$key] = (object) $response[$key];
440
				break;
441
			case 'metadata' : // (array|false)
442
				$metadata = array();
443
				foreach ( (array) has_meta( $post_id ) as $meta ) {
444
					// Don't expose protected fields.
445
					$show = false;
446
					if ( $this->is_metadata_public( $meta['meta_key'] ) )
447
						$show = true;
448
					if ( current_user_can( 'edit_post_meta', $post_id , $meta['meta_key'] ) )
449
						$show = true;
450
451
					if ( !$show )
452
						continue;
453
454
					$metadata[] = array(
455
						'id'    => $meta['meta_id'],
456
						'key'   => $meta['meta_key'],
457
						'value' => maybe_unserialize( $meta['meta_value'] ),
458
					);
459
				}
460
461
				if ( ! empty( $metadata ) ) {
462
					$response[$key] = $metadata;
463
				} else {
464
					$response[$key] = false;
465
				}
466
				break;
467
			case 'meta' :
468
				$response[$key] = (object) array(
469
					'links' => (object) array(

json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php 1 location

@@ 429-454 (lines=26) @@
426
				$response['attachment_count'] = $_attachments->found_posts;
427
				$response[$key] = (object) $response[$key];
428
				break;
429
			case 'metadata' : // (array|false)
430
				$metadata = array();
431
				foreach ( (array) has_meta( $post_id ) as $meta ) {
432
					// Don't expose protected fields.
433
					$show = false;
434
					if ( $this->is_metadata_public( $meta['meta_key'] ) )
435
						$show = true;
436
					if ( current_user_can( 'edit_post_meta', $post_id , $meta['meta_key'] ) )
437
						$show = true;
438
439
					if ( !$show )
440
						continue;
441
442
					$metadata[] = array(
443
						'id'    => $meta['meta_id'],
444
						'key'   => $meta['meta_key'],
445
						'value' => maybe_unserialize( $meta['meta_value'] ),
446
					);
447
				}
448
449
				if ( ! empty( $metadata ) ) {
450
					$response[$key] = $metadata;
451
				} else {
452
					$response[$key] = false;
453
				}
454
				break;
455
			case 'meta' :
456
				$response[$key] = (object) array(
457
					'links' => (object) array(