<commit_before><?php
namespace Podlove;

/**
 * Adds feed discover links to WordPress head.
 */
class FeedDiscoverability {

	public static function init() {
		
		// priority 2 so they are placed below the WordPress default discovery links
		add_action( 'wp_head', array(__CLASS__, 'add_feed_discoverability'), 2 );

		// hide WordPress default link discovery
		if ( \Podlove\get_setting( 'website', 'hide_wp_feed_discovery' ) === 'on' ) {
			remove_action( 'wp_head', 'feed_links',       2 );
			remove_action( 'wp_head', 'feed_links_extra', 3 );
		}
		
	}

	public static function add_feed_discoverability() {

		if ( is_admin() )
			return;

		if ( ! function_exists( '\Podlove\Feeds\prepare_for_feed' ) )
			require_once \PODLOVE\PLUGIN_DIR . 'lib/feeds/base.php';

		$feeds = \Podlove\Model\Feed::all( 'ORDER BY position ASC' );

		foreach ( $feeds as $feed ) {
			if ( $feed->discoverable )
				echo '<link rel="alternate" type="' . $feed->get_content_type() . '" title="' . \Podlove\Feeds\prepare_for_feed( $feed->title_for_discovery() ) . '" href="' . $feed->get_subscribe_url() . "\" />\n";			
		}
	}

}<commit_msg>cache feed discoverability html<commit_after><?php
namespace Podlove;

use \Podlove\Model\Feed;
use \Podlove\Cache\TemplateCache;

/**
 * Adds feed discover links to WordPress head.
 */
class FeedDiscoverability {

	public static function init() {
		
		// priority 2 so they are placed below the WordPress default discovery links
		add_action( 'wp_head', array(__CLASS__, 'add_feed_discoverability'), 2 );

		// hide WordPress default link discovery
		if ( \Podlove\get_setting( 'website', 'hide_wp_feed_discovery' ) === 'on' ) {
			remove_action( 'wp_head', 'feed_links',       2 );
			remove_action( 'wp_head', 'feed_links_extra', 3 );
		}
		
	}

	public static function add_feed_discoverability() {

		if ( is_admin() )
			return;

		if ( ! function_exists( '\Podlove\Feeds\prepare_for_feed' ) )
			require_once \PODLOVE\PLUGIN_DIR . 'lib/feeds/base.php';

		echo TemplateCache::get_instance()->cache_for('', function() {
			$html = '';
			foreach (Feed::all('ORDER BY position ASC') as $feed) {
				if ($feed->discoverable)
					$html .= '<link rel="alternate" type="' . $feed->get_content_type() . '" title="' . \Podlove\Feeds\prepare_for_feed($feed->title_for_discovery()) . '" href="' . $feed->get_subscribe_url() . "\" />\n";			
			}
			return $html;
		});
	}

}
{'fraction_non_alphanumeric': 0.15664160401002505, 'fraction_numerical': 0.003341687552213868, 'mean_word_length': 3.7995991983967934, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '95106', 'n_tokens_mistral': 898, 'n_tokens_neox': 793, 'n_words': 183}