Code Duplication    Length = 27-27 lines in 2 locations

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

@@ 362-388 (lines=27) @@
359
					$response[$key] = 'standard';
360
				}
361
				break;
362
			case 'geo' : // (object|false)
363
				if ( !$geo ) {
364
					$response[$key] = false;
365
				} else {
366
					$geo_data       = $geo->get_geo( 'post', $post->ID );
367
					$response[$key] = false;
368
					if ( $geo_data ) {
369
						$geo_data = array_intersect_key( $geo_data, array( 'latitude' => true, 'longitude' => true, 'address' => true, 'public' => true ) );
370
						if ( $geo_data ) {
371
							$response[$key] = (object) array(
372
								'latitude'  => isset( $geo_data['latitude']  ) ? (float)  $geo_data['latitude']  : 0,
373
								'longitude' => isset( $geo_data['longitude'] ) ? (float)  $geo_data['longitude'] : 0,
374
								'address'   => isset( $geo_data['address'] )   ? (string) $geo_data['address']   : '',
375
							);
376
						} else {
377
							$response[$key] = false;
378
						}
379
						// Private
380
						if ( !isset( $geo_data['public'] ) || !$geo_data['public'] ) {
381
							if ( 'edit' !== $context || ! $capabilities['edit_post'] ) {
382
								// user can't access
383
								$response[$key] = false;
384
							}
385
						}
386
					}
387
				}
388
				break;
389
			case 'menu_order':
390
				$response[$key] = (int) $post->menu_order;
391
				break;

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

@@ 345-371 (lines=27) @@
342
					$response[$key] = 'standard';
343
				}
344
				break;
345
			case 'geo' : // (object|false)
346
				if ( !$geo ) {
347
					$response[$key] = false;
348
				} else {
349
					$geo_data       = $geo->get_geo( 'post', $post->ID );
350
					$response[$key] = false;
351
					if ( $geo_data ) {
352
						$geo_data = array_intersect_key( $geo_data, array( 'latitude' => true, 'longitude' => true, 'address' => true, 'public' => true ) );
353
						if ( $geo_data ) {
354
							$response[$key] = (object) array(
355
								'latitude'  => isset( $geo_data['latitude']  ) ? (float)  $geo_data['latitude']  : 0,
356
								'longitude' => isset( $geo_data['longitude'] ) ? (float)  $geo_data['longitude'] : 0,
357
								'address'   => isset( $geo_data['address'] )   ? (string) $geo_data['address']   : '',
358
							);
359
						} else {
360
							$response[$key] = false;
361
						}
362
						// Private
363
						if ( !isset( $geo_data['public'] ) || !$geo_data['public'] ) {
364
							if ( 'edit' !== $context || ! $capabilities['edit_post'] ) {
365
								// user can't access
366
								$response[$key] = false;
367
							}
368
						}
369
					}
370
				}
371
				break;
372
			case 'menu_order':
373
				$response[$key] = (int) $post->menu_order;
374
				break;