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

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