Code Duplication    Length = 21-21 lines in 3 locations

modules/sitemaps/sitemap-builder.php 3 locations

@@ 420-440 (lines=21) @@
417
			JP_SITEMAP_MAX_BYTES
418
		);
419
420
		if ( 0 < $max[ JP_PAGE_SITEMAP_TYPE ]['number'] ) {
421
			if ( 1 === $max[ JP_PAGE_SITEMAP_TYPE ]['number'] ) {
422
				$page['filename'] = jp_sitemap_filename( JP_PAGE_SITEMAP_TYPE, 1 );
423
				$page['last_modified'] = jp_sitemap_datetime( $max[ JP_PAGE_SITEMAP_TYPE ]['lastmod'] );
424
			} else {
425
				$page['filename'] = jp_sitemap_filename(
426
					JP_PAGE_SITEMAP_INDEX_TYPE,
427
					$max[ JP_PAGE_SITEMAP_INDEX_TYPE ]['number']
428
				);
429
				$page['last_modified'] = jp_sitemap_datetime( $max[ JP_PAGE_SITEMAP_INDEX_TYPE ]['lastmod'] );
430
			}
431
432
			$buffer->append(
433
				array(
434
					'sitemap' => array(
435
						'loc'     => $this->finder->construct_sitemap_url( $page['filename'] ),
436
						'lastmod' => $page['last_modified'],
437
					),
438
				)
439
			);
440
		}
441
442
		if ( 0 < $max[ JP_IMAGE_SITEMAP_TYPE ]['number'] ) {
443
			if ( 1 === $max[ JP_IMAGE_SITEMAP_TYPE ]['number'] ) {
@@ 442-462 (lines=21) @@
439
			);
440
		}
441
442
		if ( 0 < $max[ JP_IMAGE_SITEMAP_TYPE ]['number'] ) {
443
			if ( 1 === $max[ JP_IMAGE_SITEMAP_TYPE ]['number'] ) {
444
				$image['filename'] = jp_sitemap_filename( JP_IMAGE_SITEMAP_TYPE, 1 );
445
				$image['last_modified'] = jp_sitemap_datetime( $max[ JP_IMAGE_SITEMAP_TYPE ]['lastmod'] );
446
			} else {
447
				$image['filename'] = jp_sitemap_filename(
448
					JP_IMAGE_SITEMAP_INDEX_TYPE,
449
					$max[ JP_IMAGE_SITEMAP_INDEX_TYPE ]['number']
450
				);
451
				$image['last_modified'] = jp_sitemap_datetime( $max[ JP_IMAGE_SITEMAP_INDEX_TYPE ]['lastmod'] );
452
			}
453
454
			$buffer->append(
455
				array(
456
					'sitemap' => array(
457
						'loc'     => $this->finder->construct_sitemap_url( $image['filename'] ),
458
						'lastmod' => $image['last_modified'],
459
					),
460
				)
461
			);
462
		}
463
464
		if ( 0 < $max[ JP_VIDEO_SITEMAP_TYPE ]['number'] ) {
465
			if ( 1 === $max[ JP_VIDEO_SITEMAP_TYPE ]['number'] ) {
@@ 464-484 (lines=21) @@
461
			);
462
		}
463
464
		if ( 0 < $max[ JP_VIDEO_SITEMAP_TYPE ]['number'] ) {
465
			if ( 1 === $max[ JP_VIDEO_SITEMAP_TYPE ]['number'] ) {
466
				$video['filename'] = jp_sitemap_filename( JP_VIDEO_SITEMAP_TYPE, 1 );
467
				$video['last_modified'] = $max[ JP_VIDEO_SITEMAP_TYPE ]['lastmod'];
468
			} else {
469
				$video['filename'] = jp_sitemap_filename(
470
					JP_VIDEO_SITEMAP_INDEX_TYPE,
471
					$max[ JP_VIDEO_SITEMAP_INDEX_TYPE ]['number']
472
				);
473
				$video['last_modified'] = $max[ JP_VIDEO_SITEMAP_INDEX_TYPE ]['lastmod'];
474
			}
475
476
			$buffer->append(
477
				array(
478
					'sitemap' => array(
479
						'loc'     => $this->finder->construct_sitemap_url( $video['filename'] ),
480
						'lastmod' => $video['last_modified'],
481
					),
482
				)
483
			);
484
		}
485
486
		$this->librarian->store_sitemap_data(
487
			0,