Code Duplication    Length = 24-24 lines in 2 locations

modules/sitemaps/sitemaps.php 2 locations

@@ 716-739 (lines=24) @@
713
	 * @param bool $discover_sitemap Make default sitemap discoverable to robots.
714
	 */
715
	$discover_sitemap = apply_filters( 'jetpack_sitemap_generate', true );
716
	if ( $discover_sitemap ) {
717
		add_action( 'do_robotstxt', 'jetpack_sitemap_discovery', 5, 0 );
718
719
		if ( get_option( 'permalink_structure' ) ) {
720
			/** This filter is documented in modules/sitemaps/sitemaps.php */
721
			$sitemap = apply_filters( 'jetpack_sitemap_location', home_url( '/sitemap.xml' ) );
722
			$sitemap = parse_url( $sitemap, PHP_URL_PATH );
723
		} else {
724
			/** This filter is documented in modules/sitemaps/sitemaps.php */
725
			$sitemap = apply_filters( 'jetpack_sitemap_location', home_url( '/?jetpack-sitemap=true' ) );
726
			$sitemap = preg_replace( '/(=.*?)$/i', '', parse_url( $sitemap, PHP_URL_QUERY ) );
727
		}
728
729
		// Sitemap XML
730
		if ( preg_match( '#(' . $sitemap . ')$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET[ $sitemap ] ) && 'true' == $_GET[ $sitemap ] ) ) {
731
			// run later so things like custom post types have been registered
732
			add_action( 'init', 'jetpack_print_sitemap', 999 );
733
		}
734
735
		// XSLT for sitemap
736
		if ( preg_match( '#(/sitemap\.xsl)$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET['jetpack-sitemap-xsl'] ) && 'true' == $_GET['jetpack-sitemap-xsl'] ) ) {
737
			add_action( 'init', 'jetpack_print_sitemap_xsl' );
738
		}
739
	}
740
741
	/**
742
	 * Filter whether to make the news sitemap discoverable to robots or not.
@@ 751-774 (lines=24) @@
748
	 * @param bool $discover_news_sitemap Make default news sitemap discoverable to robots.
749
	 */
750
	$discover_news_sitemap = apply_filters( 'jetpack_news_sitemap_generate', true );
751
	if ( $discover_news_sitemap ) {
752
		add_action( 'do_robotstxt', 'jetpack_news_sitemap_discovery', 5, 0 );
753
754
		if ( get_option( 'permalink_structure' ) ) {
755
			/** This filter is documented in modules/sitemaps/sitemaps.php */
756
			$sitemap = apply_filters( 'jetpack_news_sitemap_location', home_url( '/news-sitemap.xml' ) );
757
			$sitemap = parse_url( $sitemap, PHP_URL_PATH );
758
		} else {
759
			/** This filter is documented in modules/sitemaps/sitemaps.php */
760
			$sitemap = apply_filters( 'jetpack_news_sitemap_location', home_url( '/?jetpack-news-sitemap=true' ) );
761
			$sitemap = preg_replace( '/(=.*?)$/i', '', parse_url( $sitemap, PHP_URL_QUERY ) );
762
		}
763
764
		// News Sitemap XML
765
		if ( preg_match( '#(' . $sitemap . ')$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET[ $sitemap ] ) && 'true' == $_GET[ $sitemap ] ) ) {
766
			// run later so things like custom post types have been registered
767
			add_action( 'init', 'jetpack_print_news_sitemap', 999 );
768
		}
769
770
		// XSLT for sitemap
771
		if ( preg_match( '#(/news-sitemap\.xsl)$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET['jetpack-news-sitemap-xsl'] ) && 'true' == $_GET['jetpack-news-sitemap-xsl'] ) ) {
772
			add_action( 'init', 'jetpack_print_news_sitemap_xsl' );
773
		}
774
	}
775
}
776
777
// Initialize sitemaps once themes can filter the initialization.