Code Duplication    Length = 24-24 lines in 2 locations

modules/sitemaps/sitemaps.php 2 locations

@@ 730-753 (lines=24) @@
727
	 * @param bool $discover_sitemap Make default sitemap discoverable to robots.
728
	 */
729
	$discover_sitemap = apply_filters( 'jetpack_sitemap_generate', true );
730
	if ( $discover_sitemap ) {
731
		add_action( 'do_robotstxt', 'jetpack_sitemap_discovery', 5, 0 );
732
733
		if ( get_option( 'permalink_structure' ) ) {
734
			/** This filter is documented in modules/sitemaps/sitemaps.php */
735
			$sitemap = apply_filters( 'jetpack_sitemap_location', home_url( '/sitemap.xml' ) );
736
			$sitemap = parse_url( $sitemap, PHP_URL_PATH );
737
		} else {
738
			/** This filter is documented in modules/sitemaps/sitemaps.php */
739
			$sitemap = apply_filters( 'jetpack_sitemap_location', home_url( '/?jetpack-sitemap=true' ) );
740
			$sitemap = preg_replace( '/(=.*?)$/i', '', parse_url( $sitemap, PHP_URL_QUERY ) );
741
		}
742
743
		// Sitemap XML
744
		if ( preg_match( '#(' . $sitemap . ')$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET[ $sitemap ] ) && 'true' == $_GET[ $sitemap ] ) ) {
745
			// run later so things like custom post types have been registered
746
			add_action( 'init', 'jetpack_print_sitemap', 999 );
747
		}
748
749
		// XSLT for sitemap
750
		if ( preg_match( '#(/sitemap\.xsl)$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET['jetpack-sitemap-xsl'] ) && 'true' == $_GET['jetpack-sitemap-xsl'] ) ) {
751
			add_action( 'init', 'jetpack_print_sitemap_xsl' );
752
		}
753
	}
754
755
	/**
756
	 * Filter whether to make the news sitemap discoverable to robots or not.
@@ 765-788 (lines=24) @@
762
	 * @param bool $discover_news_sitemap Make default news sitemap discoverable to robots.
763
	 */
764
	$discover_news_sitemap = apply_filters( 'jetpack_news_sitemap_generate', true );
765
	if ( $discover_news_sitemap ) {
766
		add_action( 'do_robotstxt', 'jetpack_news_sitemap_discovery', 5, 0 );
767
768
		if ( get_option( 'permalink_structure' ) ) {
769
			/** This filter is documented in modules/sitemaps/sitemaps.php */
770
			$sitemap = apply_filters( 'jetpack_news_sitemap_location', home_url( '/news-sitemap.xml' ) );
771
			$sitemap = parse_url( $sitemap, PHP_URL_PATH );
772
		} else {
773
			/** This filter is documented in modules/sitemaps/sitemaps.php */
774
			$sitemap = apply_filters( 'jetpack_news_sitemap_location', home_url( '/?jetpack-news-sitemap=true' ) );
775
			$sitemap = preg_replace( '/(=.*?)$/i', '', parse_url( $sitemap, PHP_URL_QUERY ) );
776
		}
777
778
		// News Sitemap XML
779
		if ( preg_match( '#(' . $sitemap . ')$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET[ $sitemap ] ) && 'true' == $_GET[ $sitemap ] ) ) {
780
			// run later so things like custom post types have been registered
781
			add_action( 'init', 'jetpack_print_news_sitemap', 999 );
782
		}
783
784
		// XSLT for sitemap
785
		if ( preg_match( '#(/news-sitemap\.xsl)$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET['jetpack-news-sitemap-xsl'] ) && 'true' == $_GET['jetpack-news-sitemap-xsl'] ) ) {
786
			add_action( 'init', 'jetpack_print_news_sitemap_xsl' );
787
		}
788
	}
789
}
790
791
// Initialize sitemaps once themes can filter the initialization.