<commit_before><?php
namespace Podlove\Feeds;
use \Podlove\Model;

# Prio 11 so it hooks *after* the domain mapping plugin.
# This is important when one moves a domain. That way the domain gets
# remapped/redirected correctly by the domain mapper before being redirected by us.
add_action('template_redirect', '\Podlove\Feeds\handle_feed_proxy_redirects', 11);

add_action('init', '\Podlove\Feeds\register_podcast_feeds');

function register_podcast_feeds()
{
	foreach (Model\Feed::all() as $feed) {
		if ($feed->slug)
			add_feed($feed->slug,  "\Podlove\Feeds\generate_podcast_feed");
	}

	// changing feed settings may affect permalinks, so we need to flush
	if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'podlove_feeds_settings_handle') {
		set_transient('podlove_needs_to_flush_rewrite_rules', true);
	}
}

/**
 * Handles feed requests
 * 
 * - ensures correct feed URL protocol
 * - ensures canonical feed URL
 * - redirects to feed proxy if necessary
 * - prepares podcast feed (adds all metadata etc. to RSS)
 */
function handle_feed_proxy_redirects() {

	if (!$feed = get_feed())
		return;

	header( 'Content-Type: application/rss+xml; charset=' . get_option( 'blog_charset' ), true );

	maybe_redirect_to_forced_protocol();
	maybe_redirect_to_canonical_url();
	
	if ($feed->is_redirect_enabled() && !is_page_in_feed()  && should_redirect_to_proxy()) {
		header(sprintf("Location: %s", $feed->get_redirect_url()), TRUE, $feed->get_redirect_http_status_code());
		exit;
	} else { // don't redirect; prepare feed
		status_header(200);
		RSS::prepare_feed( $feed->slug );<commit_msg>fix: don't proxy if there is no known redirect URL<commit_after><?php
namespace Podlove\Feeds;
use \Podlove\Model;

# Prio 11 so it hooks *after* the domain mapping plugin.
# This is important when one moves a domain. That way the domain gets
# remapped/redirected correctly by the domain mapper before being redirected by us.
add_action('template_redirect', '\Podlove\Feeds\handle_feed_proxy_redirects', 11);

add_action('init', '\Podlove\Feeds\register_podcast_feeds');

function register_podcast_feeds()
{
	foreach (Model\Feed::all() as $feed) {
		if ($feed->slug)
			add_feed($feed->slug,  "\Podlove\Feeds\generate_podcast_feed");
	}

	// changing feed settings may affect permalinks, so we need to flush
	if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'podlove_feeds_settings_handle') {
		set_transient('podlove_needs_to_flush_rewrite_rules', true);
	}
}

/**
 * Handles feed requests
 * 
 * - ensures correct feed URL protocol
 * - ensures canonical feed URL
 * - redirects to feed proxy if necessary
 * - prepares podcast feed (adds all metadata etc. to RSS)
 */
function handle_feed_proxy_redirects() {

	if (!$feed = get_feed())
		return;

	header( 'Content-Type: application/rss+xml; charset=' . get_option( 'blog_charset' ), true );

	maybe_redirect_to_forced_protocol();
	maybe_redirect_to_canonical_url();
	
  $redirect_url = $feed->get_redirect_url();

	if ($redirect_url && $feed->is_redirect_enabled() && !is_page_in_feed()  && should_redirect_to_proxy()) {
		header(sprintf("Location: %s", $redirect_url), TRUE, $feed->get_redirect_http_status_code());
		exit;
	} else { // don't redirect; prepare feed
		status_header(200);
		RSS::prepare_feed( $feed->slug );
{'fraction_non_alphanumeric': 0.13270286760219646, 'fraction_numerical': 0.004270896888346553, 'mean_word_length': 5.305769230769231, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '292229', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1054, 'n_words': 274}