<?php

function xmlsf_advanced_news_filter_request( $request ) {
	if ( isset($request['feed']) && strpos($request['feed'],'sitemap-news') === 0 ) {
		include XMLSF_NEWS_ADV_DIR . '/models/functions.public.php';

		add_filter( 'xmlsf_news_stock_tickers', 'xmlsf_news_stock_tickers' );
		add_filter( 'xmlsf_news_keywords', 'xmlsf_news_keywords' );
	}

	return $request;
}

/**
 * Filter news post types
 *
 * @since 1.2
 * @param $post_types array
 * @return array
 */
function xmlsf_advanced_news_allow_hierarchical( $post_types ) {
	if ( ! is_admin() ) return $post_types;

	$post_types = (array) $post_types;

	$options = get_option('xmlsf_news_advanced');

	if ( !empty($options['allow_hierarchical'] ) ) {
		$hierarchical = get_post_types( array( 'public' => true, 'hierarchical' => true ) );
		if ( is_array($hierarchical) )
			$post_types = array_merge( $post_types, $hierarchical );
	}

	return array_filter( $post_types );
}
