Example #1
0
/**
 * Return feed title.
 * 
 * @return string
 */
function get_feed_title()
{
    $info = strip_tags(Settings\get_site_option('title'));
    $title = apply_filters('get_bloginfo_rss', convert_chars($info));
    if (!$title) {
        $title = get_bloginfo_rss('name');
        $title .= get_wp_title_rss();
    }
    return apply_filters('inpsmf_feed_title', $title);
}
do_action('atom_ns');
/**
 * Fires inside the feed tag in the Atom comment feed.
 *
 * @since 2.8.0
 */
do_action('atom_comments_ns');
?>
>
	<title type="text"><?php 
if (is_singular()) {
    printf(ent2ncr(__('Comments on %s')), get_the_title_rss());
} elseif (is_search()) {
    printf(ent2ncr(__('Comments for %1$s searching on %2$s')), get_bloginfo_rss('name'), get_search_query());
} else {
    printf(ent2ncr(__('Comments for %s')), get_wp_title_rss());
}
?>
</title>
	<subtitle type="text"><?php 
bloginfo_rss('description');
?>
</subtitle>

	<updated><?php 
echo mysql2date('Y-m-d\\TH:i:s\\Z', get_lastcommentmodified('GMT'), false);
?>
</updated>

<?php 
if (is_singular()) {
Example #3
0
/**
 * Display the blog title for display of the feed title.
 *
 * @package WordPress
 * @subpackage Feed
 * @since 2.2.0
 * @uses apply_filters() Calls 'wp_title_rss' on the blog title.
 * @see wp_title() $sep parameter usage.
 *
 * @param string $sep Optional.
 */
function wp_title_rss($sep = '&#187;')
{
    echo apply_filters('wp_title_rss', get_wp_title_rss($sep));
}
/**
 * Output an RSS2 feed of replies, based on the query passed.
 *
 * @since bbPress (r3171)
 *
 * @uses bbp_version()
 * @uses bbp_is_single_topic()
 * @uses bbp_user_can_view_forum()
 * @uses bbp_get_topic_forum_id()
 * @uses bbp_show_load_topic()
 * @uses bbp_topic_permalink()
 * @uses bbp_topic_title()
 * @uses bbp_get_topic_reply_count()
 * @uses bbp_topic_content()
 * @uses bbp_has_replies()
 * @uses bbp_replies()
 * @uses bbp_the_reply()
 * @uses bbp_reply_url()
 * @uses bbp_reply_title()
 * @uses bbp_reply_content()
 * @uses get_wp_title_rss()
 * @uses get_option()
 * @uses bloginfo_rss
 * @uses self_link()
 * @uses the_author()
 * @uses get_post_time()
 * @uses rss_enclosure()
 * @uses do_action()
 * @uses apply_filters()
 *
 * @param array $replies_query
 */
function bbp_display_replies_feed_rss2($replies_query = array())
{
    // User cannot access forum this topic is in
    if (bbp_is_single_topic() && !bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) {
        return;
    }
    // Adjust the title based on context
    if (bbp_is_single_topic() && bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) {
        $title = apply_filters('wp_title_rss', get_wp_title_rss(' &#187; '));
    } elseif (!bbp_show_lead_topic()) {
        $title = ' &#187; ' . __('All Posts', 'bbpress');
    } else {
        $title = ' &#187; ' . __('All Replies', 'bbpress');
    }
    // Display the feed
    header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
    header('Status: 200 OK');
    echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
    ?>

	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

		<?php 
    do_action('bbp_feed');
    ?>
	>

	<channel>
		<title><?php 
    bloginfo_rss('name');
    echo $title;
    ?>
</title>
		<atom:link href="<?php 
    self_link();
    ?>
" rel="self" type="application/rss+xml" />
		<link><?php 
    self_link();
    ?>
</link>
		<description><?php 
    //
    ?>
</description>
		<pubDate><?php 
    echo mysql2date('D, d M Y H:i:s O', current_time('mysql'), false);
    ?>
</pubDate>
		<generator>http://bbpress.org/?v=<?php 
    bbp_version();
    ?>
</generator>
		<language><?php 
    bloginfo_rss('language');
    ?>
</language>

		<?php 
    do_action('bbp_feed_head');
    ?>

		<?php 
    if (bbp_is_single_topic()) {
        ?>
			<?php 
        if (bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) {
            ?>
				<?php 
            if (bbp_show_lead_topic()) {
                ?>

					<item>
						<guid><?php 
                bbp_topic_permalink();
                ?>
</guid>
						<title><![CDATA[<?php 
                bbp_topic_title();
                ?>
]]></title>
						<link><?php 
                bbp_topic_permalink();
                ?>
</link>
						<pubDate><?php 
                echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false);
                ?>
</pubDate>
						<dc:creator><?php 
                the_author();
                ?>
</dc:creator>

						<description>
							<![CDATA[
							<p><?php 
                printf(__('Replies: %s', 'bbpress'), bbp_get_topic_reply_count());
                ?>
</p>
							<?php 
                bbp_topic_content();
                ?>
							]]>
						</description>

						<?php 
                rss_enclosure();
                ?>

						<?php 
                do_action('bbp_feed_item');
                ?>

					</item>

				<?php 
            }
            ?>
			<?php 
        }
        ?>
		<?php 
    }
    ?>

		<?php 
    if (bbp_has_replies($replies_query)) {
        ?>
			<?php 
        while (bbp_replies()) {
            bbp_the_reply();
            ?>

				<item>
					<guid><?php 
            bbp_reply_url();
            ?>
</guid>
					<title><![CDATA[<?php 
            bbp_reply_title();
            ?>
]]></title>
					<link><?php 
            bbp_reply_url();
            ?>
</link>
					<pubDate><?php 
            echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false);
            ?>
</pubDate>
					<dc:creator><?php 
            the_author();
            ?>
</dc:creator>

					<description>
						<![CDATA[
						<?php 
            bbp_reply_content();
            ?>
						]]>
					</description>

					<?php 
            rss_enclosure();
            ?>

					<?php 
            do_action('bbp_feed_item');
            ?>

				</item>

			<?php 
        }
        ?>
		<?php 
    }
    ?>

		<?php 
    do_action('bbp_feed_footer');
    ?>

	</channel>
	</rss>

<?php 
    // We're done here
    exit;
}
/**
 * Universal Feed Loader
 * hooked function
 * supports custom settings
 * NOTE uses just-in-time initialization
 * @see     functions.php, feed-links include module
 * @uses    Universal Feed Writer class
 */
function tLoadFeed()
{
    global $tFeeds, $tCurrentFeed, $wp_query, $post;
    $tCurrentFeed = get_query_var('feed');
    // FB::trace($tCurrentFeed);
    if (empty($tCurrentFeed) || $tCurrentFeed == 'feed') {
        $tCurrentFeed = get_default_feed();
        # rss2
    }
    $args =& $tFeeds[$tCurrentFeed];
    $defaults = array('num_entries' => get_option('posts_per_rss'), 'do_images' => true, 'size_image' => 'large', 'feed_type' => defined('TFEED') ? TFEED : 'atom', 'feed_title' => 'Recent Posts', 'feed_description' => 'An unfiltered list limited to ' . $num_entries . ' posts');
    $args = apply_filters('t_load_feed_args', $args);
    $args = wp_parse_args($args, $defaults);
    # customizing default info
    if (is_category()) {
        $category = t_get_term_name(get_query_var('cat'), 'category');
        $args['feed_title'] = 'Feed for ' . $category;
        $args['feed_description'] = 'A list limited to ' . $args['num_entries'] . ' posts categorized under ' . $category;
    }
    if ($wp_query->is_comment_feed) {
        # comment feed
        if (is_singular()) {
            $args['feed_title'] = 'Recent comments on ' . get_the_title_rss();
        } elseif (is_search()) {
            $args['feed_title'] = 'Comments for search on ' . attribute_escape($wp_query->query_vars['s']);
        } else {
            $args['feed_title'] = 'Recent comments for ' . get_wp_title_rss();
        }
        $args['feed_title'] = ent2ncr($args['feed_title']);
        $args['feed_description'] = 'A list limited to ' . $args['num_entries'] . ' comments';
    }
    $args['query'] = tGetFeedQuery();
    if (is_array($args['query'])) {
        $args['query']['showposts'] =& $args['num_entries'];
    }
    if ($tCurrentFeed == 'rss' || $tCurrentFeed == 'rss2' || $tCurrentFeed == 'atom') {
        $args['feed_type'] = $tCurrentFeed;
    } else {
        $args['feed_title'] = ucwords(str_replace('_', ' ', $tCurrentFeed));
    }
    extract($args);
    # namespacing
    switch ($feed_type) {
        case 'rss2':
            $namespace = '
                 xmlns:dc="http://purl.org/dc/elements/1.1/"
                 xmlns:atom="http://www.w3.org/2005/Atom"
                 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
                ';
            $feedType = RSS2;
            break;
        case 'rss':
            $namespace = '
                 xmlns:dc="http://purl.org/dc/elements/1.1/"
                 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
                 xmlns:admin="http://webns.net/mvcb/"
                 xmlns:content="http://purl.org/rss/1.0/modules/content/"
                ';
            $feedType = RSS1;
            break;
        case 'atom':
        default:
            $namespace = '
                 xmlns:thr="http://purl.org/syndication/thread/1.0"
                 xml:lang="' . get_option('rss_language') . '"
                 xml:base="' . get_bloginfo_rss('url') . '"
                 ';
            $feedType = ATOM;
            break;
    }
    $GLOBALS['t_feed_ns'] = $namespace;
    # for use in FeedWriter
    add_filter('t_feed_ns', create_function('$default', 'return $default . $GLOBALS["t_feed_ns"];'));
    # start
    $feedWriter = new FeedWriter($feedType);
    require TDIR . TMODINC . 'feed-head.php';
    require TDIR . TMODINC . 'feed-body.php';
    # output
    $out = ob_get_contents();
    $out = str_replace(array("\n", "\r", "\t", ' '), '', $input);
    ob_end_clean();
    $feedWriter->generateFeed();
    // lifestream_rss_feed();
    // FB::info($args);
}
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	<?php 
do_action('rss2_ns');
do_action('rss2_comments_ns');
?>
>
<channel>
	<title><?php 
if (is_singular()) {
    printf(ent2ncr(__('Comments on: %s')), get_the_title_rss() . ' by ' . $user_print_name);
} elseif (is_search()) {
    printf(ent2ncr(__('Comments for %s searching on %s')), get_bloginfo_rss('name'), esc_attr($wp_query->query_vars['s']));
} else {
    printf(ent2ncr(__('Comments for %s')), get_bloginfo_rss('name') . ' by ' . $user_print_name . get_wp_title_rss());
}
?>
</title>
	<atom:link href="<?php 
self_link();
?>
" rel="self" type="application/rss+xml" />
	<link><?php 
is_single() ? the_permalink_rss() : bloginfo_rss("url");
?>
</link>
	<description><?php 
bloginfo_rss("description");
?>
</description>
/**
 * Display the blog title for display of the feed title.
 *
 * @since 2.2.0
 * @see wp_title() $sep parameter usage.
 *
 * @param string $sep Optional.
 */
function wp_title_rss($sep = '&#187;')
{
    /**
     * Filter the blog title for display of the feed title.
     *
     * @since 2.2.0
     *
     * @see get_wp_title_rss()
     *
     * @param string $wp_title The current blog title.
     * @param string $sep      Separator used by wp_title().
     */
    echo apply_filters('wp_title_rss', get_wp_title_rss($sep), $sep);
}
function weaverii_sc_info()
{
    global $current_user;
    $out = '<strong>' . WEAVERII_THEMEVERSION . ' Info</strong><hr />';
    get_currentuserinfo();
    if (isset($current_user->display_name)) {
        $out .= '<em>User:</em> ' . $current_user->display_name . '<br />';
    }
    $out .= '&nbsp;&nbsp;' . wp_register('', '<br />', false);
    $out .= '&nbsp;&nbsp;' . wp_loginout('', false) . '<br />';
    global $weaverii_mobile;
    $device = $weaverii_mobile;
    $out .= '<em>Browser:</em> ' . ($device ? $device['browser'] . '/' . $device['type'] . '/' . $device['os'] : 'Non-Mobile Browser') . '<br />';
    $agent = 'Not Available';
    if (isset($_SERVER["HTTP_USER_AGENT"])) {
        $agent = $_SERVER['HTTP_USER_AGENT'];
    }
    $out .= '<em>User Agent</em>: <small>' . $agent . '</small>';
    $out .= '<div id="example"></div>
<script type="text/javascript">
var txt = "";
var myWidth;
if( typeof( window.innerWidth ) == "number" ) {
//Non-IE
myWidth = window.innerWidth;
} else if( document.documentElement &&
( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in "standards compliant mode"
myWidth = document.documentElement.clientWidth;
} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
}
txt+= "<em>Browser Width: </em>" + myWidth + " px<br>";
document.getElementById("example").innerHTML=txt;
</script>';
    if (!weaverii_use_inline_css(weaverii_get_css_filename())) {
        $out .= '<em>Using CSS file:</em> ' . weaverii_get_css_filename();
    } else {
        $out .= '<em>Using Inline CSS</em>';
    }
    $out .= '<br /><em>Mobile Mode: </em> ' . weaverii_getopt('_wii_mode_mobile');
    $out .= '<br /><em>Feed title:</em> ' . get_bloginfo_rss('name') . get_wp_title_rss();
    $out .= '<br /><em>You are using</em> WordPress ' . $GLOBALS['wp_version'] . '<br /><em>PHP Version:</em> ' . phpversion();
    $out .= '<br /><em>Memory:</em> ' . round(memory_get_usage() / 1024 / 1024, 2) . 'M of ' . (int) ini_get('memory_limit') . 'M <hr />';
    return $out;
}
/**
 * Inject into RSS2 xml header
 * @see http://www.w3schools.com/rss/rss_reference.asp
 */
function ts_feed_spruce_rss2_head()
{
    $options = ts_feed_spruce_get_options();
    if (!empty($options['rss2image'])) {
        echo "<image>";
        echo "<link>" . get_bloginfo_rss('url') . '</link>';
        echo "<title>" . get_bloginfo_rss('name') . get_wp_title_rss('&#187;') . '</title>';
        echo "<url>" . esc_url($options['rss2image']) . '</url>';
        echo "</image>";
    }
    echo '<copyright><![CDATA[';
    if (!empty($options['copyright'])) {
        echo ent2ncr(strip_tags(str_ireplace('%year%', copyright_date(), $options['copyright'])));
    } else {
        echo ent2ncr('(c) ' . copyright_date() . ' ' . get_bloginfo('name'));
    }
    echo ']]></copyright>';
}
Example #10
0
function amt_metadata_analysis($default_text, $metadata_block_head, $metadata_block_footer, $metadata_block_content_filter)
{
    // Analysis is appended only o content pages
    if (!is_singular()) {
        return $default_text;
    }
    // Check the filter based switch
    if (!apply_filters('amt_metadata_analysis_enable', true)) {
        return $default_text;
    }
    //
    // Collect data
    //
    $options = amt_get_options();
    $post = amt_get_queried_object();
    if (!isset($post->ID) || $post->ID <= 0) {
        return $default_text;
    }
    // Content and stats
    // Post content
    $post_content = strtolower(amt_get_clean_post_content($options, $post));
    $post_content_length = strlen($post_content);
    //var_dump($post_content);
    // Total words
    if (function_exists('wordstats_words')) {
        $post_word_count = wordstats_words($post_content);
        // provided by the word-statistics-plugin by FD
    } else {
        $post_word_count = str_word_count($post_content);
    }
    // Total sentences
    if (function_exists('wordstats_sentences')) {
        $post_sentence_count = wordstats_sentences($post_content);
        // provided by the word-statistics-plugin by FD
    } else {
        $post_sentence_count = preg_match_all('/[.!?\\r]/', $post_content, $dummy);
    }
    // Total syllables
    // TODO: Find better function
    $post_syllable_count = preg_match_all('/[aeiouy]/', $post_content, $dummy);
    // Titles
    // Original
    $post_title = strtolower(strip_tags(get_the_title($post->ID)));
    // Title HTML element
    if ($options['enable_advanced_title_management'] == '1') {
        // If Advanced Title management is enabled, use this directly:
        $post_title_html_element = strtolower(amt_get_title_for_title_element($options, $post));
    } else {
        if (version_compare(get_bloginfo('version'), '4.4', '>=')) {
            // Since WP 4.4
            // - https://make.wordpress.org/core/2015/10/20/document-title-in-4-4/
            //$post_title_html_element = strtolower( apply_filters('document_title_parts', array('title' => $post_title) ) );
            //$post_title_html_element = wp_get_document_title();
            $post_title_html_element = strtolower(get_wp_title_rss());
        } else {
            // Reverting back to the one argument version of the fitlering function.
            //$post_title_html_element = strtolower( apply_filters('wp_title', $post_title) );
            // Until testing is performed on old WP versions we just use post title
            $post_title_html_element = $post_title;
        }
    }
    //var_dump($post_title_html_element);
    // Title in metadata
    $post_title_metadata = strtolower(amt_get_title_for_metadata($options, $post));
    //var_dump($post_title_metadata);
    // URL
    $post_url = str_replace(get_bloginfo('url'), '', amt_get_permalink_for_multipage($post));
    //var_dump($post_url);
    // Description
    $description = '';
    if (array_key_exists('basic:description', $metadata_block_head)) {
        $description = strtolower(preg_replace('#^.*content="([^"]+)".*$#', '$1', $metadata_block_head['basic:description']));
    }
    //var_dump($description);
    // Keywords
    $keywords = array();
    if (array_key_exists('basic:keywords', $metadata_block_head)) {
        $keywords_content = strtolower(preg_replace('#^.*content="([^"]+)".*$#', '$1', $metadata_block_head['basic:keywords']));
        $keywords = explode(',', str_replace(', ', ',', $keywords_content));
    }
    //var_dump($keywords);
    // Keyword matching pattern
    //$keyword_matching_pattern = '#(?:%s)#';
    //$keyword_matching_pattern = '#(?:%s)[[:^alpha:]]#';
    //$keyword_matching_pattern = '#(?:%s)[[:^alpha:]]?#';
    $keyword_matching_pattern = '#(?:%s)(?:[[:^alpha:]]|$)#';
    $keyword_matching_pattern = apply_filters('amt_metadata_analysis_keyword_matching_pattern', $keyword_matching_pattern);
    // Whether to use topic keywords field or the keywords from the 'keywords' meta tag.
    $use_keywords = false;
    // First check for a field that contains topic keywords.
    $topic_keywords_field_name = apply_filters('amt_metadata_analysis_topic_keywords_field', 'topic_keywords');
    $topic_keywords_field_value = get_post_meta($post->ID, $topic_keywords_field_name, true);
    if (!empty($topic_keywords_field_value)) {
        $topic_keywords = explode(',', str_replace(', ', ',', $topic_keywords_field_value));
    } else {
        $topic_keywords = $keywords;
        $use_keywords = true;
        //var_dump($topic_keywords);
    }
    $BR = PHP_EOL;
    if ($options['review_mode_omit_notices'] == '0') {
        $output = $default_text . $BR . $BR;
        //$output .= $BR . '<span class="">Text analysis</span>' . $BR;
    } else {
        $output = '';
    }
    if ($options['review_mode_omit_notices'] == '0') {
        $output .= 'Metadata Overview' . $BR;
        $output .= '=================' . $BR;
        //$output .= 'This overview has been generated by the Add-Meta-Tags plugin for statistical and' . $BR;
        //$output .= 'informational purposes only. Please do not modify or base your work upon this report.' . $BR . $BR;
        $output .= 'NOTICE: Add-Meta-Tags does not provide SEO advice and does not rate your content.' . $BR;
        $output .= 'This <a target="_blank" href="http://www.codetrax.org/projects/wp-add-meta-tags/wiki/Metadata_Overview">overview</a> has been generated for statistical and informational purposes only.' . $BR . $BR;
        //$output .= '<a target="_blank" href="http://www.codetrax.org/projects/wp-add-meta-tags/wiki/FAQ#Is-Add-Meta-Tags-an-SEO-plugin">Read more</a> about the mentality upon which the development of this plugin has been based.' . $BR;
        //$output .= 'Please use this statistical information to identify keyword overstuffing' . $BR;
        //$output .= 'and stay away from following any patterns or being bound by the numbers.' . $BR . $BR;
    }
    if ($use_keywords) {
        $output .= sprintf('This overview has been based on post keywords, because the Custom Field \'<em>%s</em>\' could not be found.', $topic_keywords_field_name) . $BR;
    } else {
        $output .= sprintf('This overview has been based on <em>topic keywords</em> retrieved from the Custom Field \'<em>%s</em>\'.', $topic_keywords_field_name) . $BR;
    }
    if ($options['review_mode_omit_notices'] == '0') {
        $output .= 'Keyword Analysis' . $BR;
        $output .= '----------------' . $BR;
    } else {
        $output .= $BR;
    }
    $output .= '<table class="amt-ht-table">';
    $output .= '<tr> <th>Topic Keyword</th> <th>Content</th> <th>Description</th> <th>Keywords</th> <th>Post Title</th> <th>HTML title</th> <th>Metadata titles</th> <th>Post URL</th> </tr>';
    foreach ($topic_keywords as $topic_keyword) {
        $output .= sprintf('<tr> <td>%s</td>', $topic_keyword);
        $is_into = array();
        // Check content
        $is_into['content'] = '';
        $occurrences = preg_match_all(sprintf($keyword_matching_pattern, $topic_keyword), $post_content, $matches);
        if ($occurrences) {
            // Only for content
            $topic_keyword_desnity = round($occurrences / $post_word_count * 100, 2);
            $output .= sprintf(' <td>%d (%.2f%%)</td>', $occurrences, $topic_keyword_desnity);
        } else {
            $output .= '<td> </td>';
        }
        // Check description
        $occurrences = preg_match_all(sprintf($keyword_matching_pattern, $topic_keyword), $description, $matches);
        if ($occurrences) {
            $output .= sprintf(' <td>%d</td>', $occurrences);
        } else {
            $output .= '<td> </td>';
        }
        // Check keywords
        if ($use_keywords) {
            $output .= '<td>N/A</td>';
            $is_into['keywords'] = 'N/A';
        } elseif (in_array($topic_keyword, $keywords)) {
            // Always 1
            $output .= '<td>1</td>';
        } else {
            $output .= '<td> </td>';
        }
        // Check original title
        $occurrences = preg_match_all(sprintf($keyword_matching_pattern, $topic_keyword), $post_title, $matches);
        if ($occurrences) {
            $output .= sprintf(' <td>%d</td>', $occurrences);
        } else {
            $output .= '<td> </td>';
        }
        // Check title element
        $occurrences = preg_match_all(sprintf($keyword_matching_pattern, $topic_keyword), $post_title_html_element, $matches);
        if ($occurrences) {
            $output .= sprintf(' <td>%d</td>', $occurrences);
        } else {
            $output .= '<td> </td>';
        }
        // Check metadata titles
        $occurrences = preg_match_all(sprintf($keyword_matching_pattern, $topic_keyword), $post_title_metadata, $matches);
        if ($occurrences) {
            $output .= sprintf(' <td>%d</td>', $occurrences);
        } else {
            $output .= '<td> </td>';
        }
        // Check post URL
        $occurrences = preg_match_all(sprintf($keyword_matching_pattern, $topic_keyword), $post_url, $matches);
        if ($occurrences) {
            $output .= sprintf(' <td>%d</td>', $occurrences);
        } else {
            $output .= '<td> </td>';
        }
        // Close row
        $output .= ' </tr>' . $BR;
    }
    $output .= '</table>' . $BR;
    // Topic Keywords Distribution Graph
    if ($options['review_mode_omit_notices'] == '0') {
        $output .= 'Topic Keywords Distribution Graph' . $BR;
        $output .= '---------------------------------' . $BR;
        $output .= 'The following text based graph shows how the <em>topic keywords</em> are distributed within your content.' . $BR;
        $output .= 'You can use it to identify incidents of keyword overstuffing.' . $BR . $BR;
    }
    //$output .= $BR . $BR;
    $total_bars = 39;
    // zero based
    $step = $post_content_length / $total_bars;
    // Debug
    //$output .= $BR . $post_content_length . '  ' . $step . $BR;
    $max_weight = null;
    $weights = array();
    // Reset weights
    for ($x = 0; $x <= $total_bars; $x++) {
        $weights[$x] = 1;
    }
    foreach ($topic_keywords as $topic_keyword) {
        // Use preg_match_all with PREG_OFFSET_CAPTURE -- http://php.net/manual/en/function.preg-match-all.php
        $topic_keyword_occurrences = preg_match_all(sprintf($keyword_matching_pattern, $topic_keyword), $post_content, $matches, PREG_OFFSET_CAPTURE);
        //var_dump($matches);
        if (!empty($topic_keyword_occurrences)) {
            foreach ($matches[0] as $match) {
                $pos = $match[1];
                $step_index = absint($pos / $step);
                $weights[$step_index] = $weights[$step_index] + 1;
                if ($weights[$step_index] > $max_weight) {
                    $max_weight = $weights[$step_index];
                }
                // Debug
                //$output .= sprintf('kw: %s, pos: %s, step index: %s, step weight: %s', $topic_keyword, $pos, $step_index, $weights[$step_index]) . $BR;
            }
        }
    }
    //var_dump($weights);
    for ($x = $max_weight - 1; $x >= 1; $x--) {
        $line = '';
        for ($y = 0; $y <= $total_bars; $y++) {
            if ($weights[$y] > $x) {
                $line .= '#';
            } else {
                $line .= ' ';
            }
        }
        $output .= $line . $BR;
    }
    // Currently this text based ruler is used as base line.
    $output .= str_repeat('---------+', ($total_bars + 1) / 10) . $BR;
    if ($options['review_mode_omit_notices'] == '0') {
        $output .= $BR . '<code>#</code>: indicates a single occurrence of a <em>topic keyword</em>.' . $BR;
    } else {
        $output .= $BR;
    }
    // Stats and scores by algos provided by the word-statistics-plugin by FD
    if (function_exists('wordstats_words')) {
        // Readability Tests
        if ($options['review_mode_omit_notices'] == '0') {
            $output .= $BR . 'Readability Scores and Text Statistics' . $BR;
            $output .= '--------------------------------------' . $BR;
            $output .= 'These readability scores and text statistics are based on algorithms provided by the <em>FD Word Statistics Plugin</em>.' . $BR . $BR;
        }
        if (function_exists('wordstats_words')) {
            $output .= sprintf(' &#9679; Total words: <strong>%d</strong>', wordstats_words($post_content)) . $BR;
        }
        if (function_exists('wordstats_sentences')) {
            $output .= sprintf(' &#9679; Total sentences: <strong>%d</strong>', wordstats_sentences($post_content)) . $BR;
        }
        if (function_exists('wordstats_flesch_kincaid')) {
            $output .= sprintf(' &#9679; Flesch-Kincaid US grade level: <strong>%.1f</strong> <em>(For instance, a score of 9.3 means suitable for a 9th grade student in the US, <a target="_blank" href="%s">read more</a>.)</em>', wordstats_flesch_kincaid($post_content), 'https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests#Flesch.E2.80.93Kincaid_grade_level') . $BR;
        }
        if (function_exists('wordstats_flesch')) {
            $output .= sprintf(' &#9679; Flesch reading ease: <strong>%.1f%%</strong> <em>(avg 11 y.o. student: 90-100%%, 13-15 y.o. students: 60-70%%, university graduates: 0-30%%, <a target="_blank" href="%s">read more</a>.)</em>', wordstats_flesch($post_content), 'https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests#Flesch_reading_ease') . $BR;
        }
        if (function_exists('wordstats_fog')) {
            $output .= sprintf(' &#9679; Gunning fog index: <strong>%.1f</strong> <em>(wide audience: < 12, near universal understanding: < 8, <a target="_blank" href="%s">read more</a>.)</em>', wordstats_fog($post_content), 'https://en.wikipedia.org/wiki/Gunning_fog_index') . $BR;
        }
        $output .= $BR;
    } else {
        if ($options['review_mode_omit_notices'] == '0') {
            $output .= $BR . $BR . 'Note: There is experimental support for <em>FD Word Statistics Plugin</em>.';
            $output .= $BR . 'If installed, you can get some readability scores and text statistics here.' . $BR . $BR;
        }
    }
    return $output;
}
    /**
     * Display icons in RSS2.
     */
    public function rss2_icon()
    {
        /** This filter is documented in modules/site-icon/jetpack-site-icon.php */
        if (apply_filters('site_icon_has_favicon', false)) {
            return;
        }
        $rss_title = get_wp_title_rss();
        if (empty($rss_title)) {
            $rss_title = get_bloginfo_rss('name');
        }
        $icon = jetpack_site_icon_url(null, 32);
        if ($icon) {
            echo '
	<image>
		<url>' . convert_chars($icon) . '</url>
		<title>' . $rss_title . '</title>
		<link>' . get_bloginfo_rss('url') . '</link>
		<width>32</width>
		<height>32</height>
	</image> ' . "\n";
        }
    }
Example #12
0
        function enable_seo()
        {
            global $post;
            global $wp_query;
            $post_datas = mars_get_post_data($post->ID);
            $meta = NULL;
            $layout = get_post_meta($post->ID, 'layout', true) ? get_post_meta($post->ID, 'layout', true) : 'small';
            if ($layout == 'large') {
                ### Fullwidth Video
                $width = 1140;
                $height = 641;
            } else {
                ### Right sidebar Video
                $width = 750;
                $height = 442;
            }
            ### meta title
            $meta .= '<meta name="title" content="' . get_wp_title_rss() . '">';
            ### meta description, keywords
            if (is_home() || is_front_page() || is_archive() || is_category()) {
                $meta .= '<meta name="description" content="' . get_bloginfo('description') . '">';
                $meta .= '<meta name="keywords" content="' . get_bloginfo('name') . '">';
            } elseif (get_post_type($post->ID) == 'video') {
                $meta .= '<meta name="description" content="' . mars_seo_limit_leng_titlewords(wp_filter_nohtml_kses($post_datas->post_content, 30)) . '">';
                $meta .= '<meta name="keywords" content="' . $this->wp_get_post_terms_string($post->ID, 'video_tag') . '">';
            } else {
                $meta .= '<meta name="description" content="' . mars_seo_limit_leng_titlewords(wp_filter_nohtml_kses($post_datas->post_content, 30)) . '">';
                $meta .= '<meta name="keywords" content="' . $this->wp_get_post_terms_string($post->ID, 'post_tag') . '">';
            }
            ### og tag.
            $meta .= '<meta property="og:site_name" content="' . get_wp_title_rss() . '">';
            if (is_home() && !is_front_page()) {
                $meta .= '<meta property="og:url" content="' . home_url() . '">';
                $meta .= '<meta property="og:title" content="' . get_bloginfo('name') . '">';
                $meta .= '<meta property="og:description" content="' . get_bloginfo('description') . '">';
            }
            if (is_archive()) {
                $meta .= '<meta property="og:url" content="' . get_post_type_archive_link(get_post_type()) . '">';
                $meta .= '<meta property="og:title" content="' . $wp_query->get_queried_object()->name . '">';
                $meta .= '<meta property="og:description" content="' . $wp_query->get_queried_object()->name . '">';
            }
            if (is_tax() || is_category() || is_tag()) {
                $meta .= '<meta property="og:url" content="' . get_term_link($wp_query->get_queried_object()->term_id, $wp_query->get_queried_object()->taxonomy) . '">';
                $meta .= '<meta property="og:title" content="' . $wp_query->get_queried_object()->name . '">';
                $meta .= '<meta property="og:description" content="' . $wp_query->get_queried_object()->name . '">';
            }
            if (is_single() || is_singular('video') || is_page()) {
                $meta .= '<meta property="og:url" content="' . get_permalink($post->ID) . '">';
                $meta .= '<meta property="og:title" content="' . $post_datas->post_title . '">';
                if (is_singular('video')) {
                    $meta .= '<meta property="og:type" content="video">';
                }
                if (has_post_thumbnail($post->ID)) {
                    $thumb_id = get_post_thumbnail_id($post->ID);
                    $thumb_url = wp_get_attachment_image_src($thumb_id, 'full', true);
                    $meta .= '<meta property="og:image" content="' . $thumb_url[0] . '">';
                }
                $meta .= '<meta property="og:description" content="' . $post_datas->post_title . '">';
                if (get_post_type($post->ID) == 'video') {
                    $video_file_url = wp_get_attachment_url(get_post_meta($post->ID, 'video_file', true));
                    if ($video_file_url) {
                        $meta .= '<meta property="og:video" content="' . $video_file_url . '">';
                    } else {
                        $meta .= '<meta property="og:video" content="' . get_permalink($post->ID) . '">';
                    }
                    $meta .= '
						<meta property="og:video:type" content="application/x-shockwave-flash">
						<meta property="og:video:width" content="' . $width . '">
						<meta property="og:video:height" content="' . $height . '">
					';
                }
            }
            print $meta;
        }
Example #13
0
function powerpress_rss2_head()
{
    global $powerpress_feed;
    if (!powerpress_is_podcast_feed()) {
        return;
    }
    // Not a feed we manage
    $feed_slug = get_query_var('feed');
    $cat_ID = get_query_var('cat');
    $Feed = get_option('powerpress_feed');
    // Get the main feed settings
    if (!empty($powerpress_feed['category'])) {
        $CustomFeed = get_option('powerpress_cat_feed_' . $powerpress_feed['category']);
        // Get the custom podcast feed settings saved in the database
        if ($CustomFeed) {
            $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed);
        }
    } else {
        if (!empty($powerpress_feed['term_taxonomy_id'])) {
            $CustomFeed = get_option('powerpress_taxonomy_' . $powerpress_feed['term_taxonomy_id']);
            // Get the taxonomy podcast settings saved in the database
            if ($CustomFeed) {
                $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed);
            }
        } else {
            if (powerpress_is_custom_podcast_feed()) {
                $CustomFeed = get_option('powerpress_feed_' . $feed_slug);
                // Get the custom podcast feed settings saved in the database
                $Feed = powerpress_merge_empty_feed_settings($CustomFeed, $Feed, $feed_slug == 'podcast');
            }
        }
    }
    if (!isset($Feed['url']) || trim($Feed['url']) == '') {
        if (is_category()) {
            $Feed['url'] = get_category_link($cat_ID);
        } else {
            $Feed['url'] = get_bloginfo('url');
        }
    }
    $General = get_option('powerpress_general');
    // We made it this far, lets write stuff to the feed!
    echo '<!-- podcast_generator="Blubrry PowerPress/' . POWERPRESS_VERSION . '" ';
    if (isset($General['advanced_mode_2']) && empty($General['advanced_mode_2'])) {
        echo 'mode="simple" ';
    } else {
        echo 'mode="advanced" ';
    }
    if (defined('POWERPRESS_DEBUG')) {
        if (!empty($powerpress_feed['category'])) {
            echo 'category="' . $powerpress_feed['category'] . '" ';
        }
        if (!empty($powerpress_feed['term_taxonomy_id'])) {
            echo 'ttid="' . $powerpress_feed['term_taxonomy_id'] . '" ';
        }
        if (!empty($powerpress_feed['post_type'])) {
            echo 'posttype="' . $powerpress_feed['post_type'] . '" ';
        }
        if (!empty($powerpress_feed['feed-slug'])) {
            echo 'feedslug="' . $powerpress_feed['feed-slug'] . '" ';
        }
    }
    echo '-->' . PHP_EOL;
    // add the itunes:new-feed-url tag to feed
    if (powerpress_is_custom_podcast_feed()) {
        if (!empty($Feed['itunes_new_feed_url'])) {
            $Feed['itunes_new_feed_url'] = str_replace('&amp;', '&', $Feed['itunes_new_feed_url']);
            echo "\t<itunes:new-feed-url>" . htmlspecialchars(trim($Feed['itunes_new_feed_url'])) . '</itunes:new-feed-url>' . PHP_EOL;
        }
    } else {
        if (!empty($Feed['itunes_new_feed_url']) && ($feed_slug == 'feed' || $feed_slug == 'rss2')) {
            $Feed['itunes_new_feed_url'] = str_replace('&amp;', '&', $Feed['itunes_new_feed_url']);
            echo "\t<itunes:new-feed-url>" . htmlspecialchars(trim($Feed['itunes_new_feed_url'])) . '</itunes:new-feed-url>' . PHP_EOL;
        }
    }
    if (!empty($Feed['itunes_summary'])) {
        echo "\t" . '<itunes:summary>' . powerpress_format_itunes_value($Feed['itunes_summary'], 'summary') . '</itunes:summary>' . PHP_EOL;
    } else {
        echo "\t" . '<itunes:summary>' . powerpress_format_itunes_value(get_bloginfo('description'), 'summary') . '</itunes:summary>' . PHP_EOL;
    }
    if (!empty($powerpress_feed['itunes_talent_name'])) {
        echo "\t<itunes:author>" . esc_html($powerpress_feed['itunes_talent_name']) . '</itunes:author>' . PHP_EOL;
    }
    if (!empty($powerpress_feed['explicit'])) {
        echo "\t" . '<itunes:explicit>' . $powerpress_feed['explicit'] . '</itunes:explicit>' . PHP_EOL;
    }
    if (!empty($Feed['itunes_block'])) {
        echo "\t<itunes:block>yes</itunes:block>" . PHP_EOL;
    }
    if (!empty($Feed['itunes_complete'])) {
        echo "\t<itunes:complete>yes</itunes:complete>" . PHP_EOL;
    }
    if (!empty($Feed['itunes_image'])) {
        echo "\t" . '<itunes:image href="' . esc_html(str_replace(' ', '+', $Feed['itunes_image']), 'double') . '" />' . PHP_EOL;
    } else {
        echo "\t" . '<itunes:image href="' . powerpress_get_root_url() . 'itunes_default.jpg" />' . PHP_EOL;
    }
    if (!empty($Feed['email'])) {
        echo "\t" . '<itunes:owner>' . PHP_EOL;
        echo "\t\t" . '<itunes:name>' . esc_html($powerpress_feed['itunes_talent_name']) . '</itunes:name>' . PHP_EOL;
        echo "\t\t" . '<itunes:email>' . esc_html($Feed['email']) . '</itunes:email>' . PHP_EOL;
        echo "\t" . '</itunes:owner>' . PHP_EOL;
        echo "\t" . '<managingEditor>' . esc_html($Feed['email'] . ' (' . $powerpress_feed['itunes_talent_name'] . ')') . '</managingEditor>' . PHP_EOL;
    }
    if (!empty($Feed['copyright'])) {
        // In case the user entered the copyright html version or the copyright UTF-8 or ASCII symbol or just (c)
        $Feed['copyright'] = str_replace(array('&copy;', '(c)', '(C)', chr(194) . chr(169), chr(169)), '&#xA9;', $Feed['copyright']);
        echo "\t" . '<copyright>' . esc_html($Feed['copyright']) . '</copyright>' . PHP_EOL;
    }
    if (!empty($Feed['itunes_subtitle'])) {
        echo "\t" . '<itunes:subtitle>' . powerpress_format_itunes_value($Feed['itunes_subtitle'], 'subtitle') . '</itunes:subtitle>' . PHP_EOL;
    } else {
        echo "\t" . '<itunes:subtitle>' . powerpress_format_itunes_value(get_bloginfo('description'), 'subtitle') . '</itunes:subtitle>' . PHP_EOL;
    }
    if (!empty($Feed['rss2_image']) || !empty($Feed['itunes_image'])) {
        if (!empty($Feed['rss2_image'])) {
            // If the RSS image is set, use it, otherwise use the iTunes image...
            $rss_image = $Feed['rss2_image'];
        } else {
            $rss_image = $Feed['itunes_image'];
        }
        echo "\t" . '<image>' . PHP_EOL;
        if (is_category() && !empty($Feed['title'])) {
            echo "\t\t" . '<title>' . esc_html(get_bloginfo_rss('name')) . '</title>' . PHP_EOL;
        } else {
            echo "\t\t" . '<title>' . esc_html(get_bloginfo_rss('name') . get_wp_title_rss()) . '</title>' . PHP_EOL;
        }
        echo "\t\t" . '<url>' . esc_html(str_replace(' ', '+', $rss_image)) . '</url>' . PHP_EOL;
        echo "\t\t" . '<link>' . $Feed['url'] . '</link>' . PHP_EOL;
        echo "\t" . '</image>' . PHP_EOL;
    } else {
        echo "\t" . '<image>' . PHP_EOL;
        if ((is_category() || is_tax() || is_tag()) && !empty($Feed['title'])) {
            echo "\t\t" . '<title>' . esc_html(get_bloginfo_rss('name')) . '</title>' . PHP_EOL;
        } else {
            echo "\t\t" . '<title>' . esc_html(get_bloginfo_rss('name') . get_wp_title_rss()) . '</title>' . PHP_EOL;
        }
        echo "\t\t" . '<url>' . powerpress_get_root_url() . 'rss_default.jpg</url>' . PHP_EOL;
        echo "\t\t" . '<link>' . $Feed['url'] . '</link>' . PHP_EOL;
        echo "\t" . '</image>' . PHP_EOL;
    }
    // Handle iTunes categories
    $Categories = powerpress_itunes_categories();
    $Cat1 = false;
    $Cat2 = false;
    $Cat3 = false;
    if (!empty($Feed['itunes_cat_1'])) {
        list($Cat1, $SubCat1) = explode('-', $Feed['itunes_cat_1']);
    }
    if (!empty($Feed['itunes_cat_2'])) {
        list($Cat2, $SubCat2) = explode('-', $Feed['itunes_cat_2']);
    }
    if (!empty($Feed['itunes_cat_3'])) {
        list($Cat3, $SubCat3) = explode('-', $Feed['itunes_cat_3']);
    }
    if ($Cat1) {
        $CatDesc = $Categories[$Cat1 . '-00'];
        $SubCatDesc = $Categories[$Cat1 . '-' . $SubCat1];
        if ($Cat1 != $Cat2 && $SubCat1 == '00') {
            echo "\t" . '<itunes:category text="' . esc_html($CatDesc) . '" />' . PHP_EOL;
        } else {
            echo "\t" . '<itunes:category text="' . esc_html($CatDesc) . '">' . PHP_EOL;
            if ($SubCat1 != '00') {
                echo "\t\t" . '<itunes:category text="' . esc_html($SubCatDesc) . '" />' . PHP_EOL;
            }
            // End this category set
            if ($Cat1 != $Cat2) {
                echo "\t" . '</itunes:category>' . PHP_EOL;
            }
        }
    }
    if ($Cat2) {
        $CatDesc = $Categories[$Cat2 . '-00'];
        $SubCatDesc = $Categories[$Cat2 . '-' . $SubCat2];
        // It's a continuation of the last category...
        if ($Cat1 == $Cat2) {
            if ($SubCat2 != '00') {
                echo "\t\t" . '<itunes:category text="' . esc_html($SubCatDesc) . '" />' . PHP_EOL;
            }
            // End this category set
            if ($Cat2 != $Cat3) {
                echo "\t" . '</itunes:category>' . PHP_EOL;
            }
        } else {
            if ($Cat2 != $Cat3 && $SubCat2 == '00') {
                echo "\t" . '<itunes:category text="' . esc_html($CatDesc) . '" />' . PHP_EOL;
            } else {
                if ($Cat1 != $Cat2) {
                    // Start a new category set
                    echo "\t" . '<itunes:category text="' . esc_html($CatDesc) . '">' . PHP_EOL;
                }
                if ($SubCat2 != '00') {
                    echo "\t\t" . '<itunes:category text="' . esc_html($SubCatDesc) . '" />' . PHP_EOL;
                }
                if ($Cat2 != $Cat3) {
                    // End this category set
                    echo "\t" . '</itunes:category>' . PHP_EOL;
                }
            }
        }
    }
    if ($Cat3) {
        $CatDesc = $Categories[$Cat3 . '-00'];
        $SubCatDesc = $Categories[$Cat3 . '-' . $SubCat3];
        // It's a continuation of the last category...
        if ($Cat2 == $Cat3) {
            if ($SubCat3 != '00') {
                echo "\t\t" . '<itunes:category text="' . esc_html($SubCatDesc) . '" />' . PHP_EOL;
            }
            // End this category set
            echo "\t" . '</itunes:category>' . PHP_EOL;
        } else {
            if ($Cat2 != $Cat3 && $SubCat3 == '00') {
                echo "\t" . '<itunes:category text="' . esc_html($CatDesc) . '" />' . PHP_EOL;
            } else {
                if ($Cat2 != $Cat3) {
                    // Start a new category set
                    echo "\t" . '<itunes:category text="' . esc_html($CatDesc) . '">' . PHP_EOL;
                }
                if ($SubCat3 != '00') {
                    echo "\t\t" . '<itunes:category text="' . esc_html($SubCatDesc) . '" />' . PHP_EOL;
                }
                // End this category set
                echo "\t" . '</itunes:category>' . PHP_EOL;
            }
        }
    }
    // End Handle iTunes categories
    // RawVoice RSS Tags
    if (!defined('POWERPRESS_RAWVOICE_RSS') || POWERPRESS_RAWVOICE_RSS != false) {
        if (!empty($Feed['parental_rating'])) {
            echo "\t\t<rawvoice:rating>" . $Feed['parental_rating'] . "</rawvoice:rating>" . PHP_EOL;
        }
        if (!empty($Feed['location'])) {
            echo "\t\t<rawvoice:location>" . htmlspecialchars($Feed['location']) . "</rawvoice:location>" . PHP_EOL;
        }
        if (!empty($Feed['frequency'])) {
            echo "\t\t<rawvoice:frequency>" . htmlspecialchars($Feed['frequency']) . "</rawvoice:frequency>" . PHP_EOL;
        }
    }
}
function powerpress_load_general_feed_settings()
{
    global $wp_query;
    global $powerpress_feed;
    if ($powerpress_feed !== false) {
        $powerpress_feed = false;
        // Get the powerpress settings
        $GeneralSettings = get_option('powerpress_general');
        if (!isset($GeneralSettings['custom_feeds']['podcast'])) {
            $GeneralSettings['custom_feeds']['podcast'] = 'Podcast Feed';
        }
        // Fixes scenario where the user never configured the custom default podcast feed.
        if ($GeneralSettings) {
            $FeedSettingsBasic = get_option('powerpress_feed');
            // Get overall feed settings
            if (is_feed() && defined('WPCACHEHOME') && empty($GeneralSettings['allow_feed_comments'])) {
                global $wp_super_cache_comments;
                $wp_super_cache_comments = 0;
            }
            if (is_feed() && defined('W3TC') && empty($GeneralSettings['allow_feed_comments'])) {
                add_filter('w3tc_can_print_comment', 'powerpress_w3tc_can_print_comment', 10, 1);
            }
            // If we're in advanced mode and we're dealing with a category feed we're extending, lets work with it...
            if (is_category() && isset($GeneralSettings['custom_cat_feeds']) && is_array($GeneralSettings['custom_cat_feeds']) && in_array(get_query_var('cat'), $GeneralSettings['custom_cat_feeds'])) {
                $cat_ID = get_query_var('cat');
                $FeedCustom = get_option('powerpress_cat_feed_' . $cat_ID);
                // Get custom feed specific settings
                $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic);
                $powerpress_feed = array();
                $powerpress_feed['is_custom'] = true;
                $powerpress_feed['category'] = $cat_ID;
                $powerpress_feed['process_podpress'] = !empty($GeneralSettings['process_podpress']);
                // Category feeds could originate from Podpress
                $powerpress_feed['rss_language'] = '';
                // default, let WordPress set the language
                $powerpress_feed['default_url'] = '';
                if (!empty($GeneralSettings['default_url'])) {
                    $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') . '/';
                }
                $explicit_array = array("no", "yes", "clean");
                $powerpress_feed['explicit'] = $explicit_array[$Feed['itunes_explicit']];
                if (!empty($Feed['itunes_talent_name'])) {
                    $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
                } else {
                    $powerpress_feed['itunes_talent_name'] = get_wp_title_rss();
                }
                $powerpress_feed['enhance_itunes_summary'] = $Feed['enhance_itunes_summary'];
                if (!empty($GeneralSettings['seo_itunes'])) {
                    $powerpress_feed['enhance_itunes_summary'] = 1;
                }
                $powerpress_feed['posts_per_rss'] = false;
                if (!empty($Feed['posts_per_rss']) && is_numeric($Feed['posts_per_rss']) && $Feed['posts_per_rss'] > 0) {
                    $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
                }
                $powerpress_feed['feed_redirect_url'] = '';
                if (!empty($Feed['feed_redirect_url'])) {
                    $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
                }
                if ($Feed['itunes_author_post'] == true) {
                    $powerpress_feed['itunes_author_post'] = true;
                }
                if ($Feed['rss_language'] != '') {
                    $powerpress_feed['rss_language'] = $Feed['rss_language'];
                }
                if (!empty($GeneralSettings['podcast_embed_in_feed'])) {
                    $powerpress_feed['podcast_embed_in_feed'] = true;
                }
                if (!empty($Feed['episode_itunes_image']) && !empty($Feed['itunes_image'])) {
                    $powerpress_feed['itunes_image'] = $Feed['itunes_image'];
                }
                return;
            } else {
                if ((defined('POWERPRESS_TAXONOMY_PODCASTING') || !empty($GeneralSettings['taxonomy_podcasting'])) && (is_tag() || is_tax())) {
                    // We need to get the term_id and the tax_id (tt_id)
                    $term_slug = get_query_var('term');
                    $taxonomy = get_query_var('taxonomy');
                    if (empty($term_slug) && empty($taxonomy)) {
                        $term_slug = get_query_var('tag');
                        if (!empty($term_slug)) {
                            $taxonomy = 'post_tag';
                        }
                    }
                    $term = false;
                    if (!empty($term_slug) && !empty($taxonomy)) {
                        $term = term_exists($term_slug, $taxonomy);
                    }
                    if (!empty($term['term_taxonomy_id'])) {
                        $FeedCustom = get_option('powerpress_taxonomy_' . $term['term_taxonomy_id']);
                        // Get custom feed specific settings
                        if ($FeedCustom) {
                            $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic);
                            $powerpress_feed = array();
                            $powerpress_feed['is_custom'] = true;
                            $powerpress_feed['term_taxonomy_id'] = $term['term_taxonomy_id'];
                            $powerpress_feed['process_podpress'] = false;
                            // Taxonomy feeds will not originate from Podpress
                            $powerpress_feed['rss_language'] = '';
                            // default, let WordPress set the language
                            $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') . '/';
                            $explicit_array = array("no", "yes", "clean");
                            $powerpress_feed['explicit'] = $explicit_array[$Feed['itunes_explicit']];
                            if (!empty($Feed['itunes_talent_name'])) {
                                $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
                            } else {
                                $powerpress_feed['itunes_talent_name'] = get_wp_title_rss();
                            }
                            $powerpress_feed['enhance_itunes_summary'] = $Feed['enhance_itunes_summary'];
                            if (!empty($GeneralSettings['seo_itunes'])) {
                                $powerpress_feed['enhance_itunes_summary'] = 1;
                            }
                            $powerpress_feed['posts_per_rss'] = false;
                            if (!empty($Feed['posts_per_rss']) && is_numeric($Feed['posts_per_rss']) && $Feed['posts_per_rss'] > 0) {
                                $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
                            }
                            if ($Feed['feed_redirect_url'] != '') {
                                $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
                            }
                            if ($Feed['itunes_author_post'] == true) {
                                $powerpress_feed['itunes_author_post'] = true;
                            }
                            if ($Feed['rss_language'] != '') {
                                $powerpress_feed['rss_language'] = $Feed['rss_language'];
                            }
                            if (!empty($GeneralSettings['podcast_embed_in_feed'])) {
                                $powerpress_feed['podcast_embed_in_feed'] = true;
                            }
                            if (!empty($Feed['episode_itunes_image']) && !empty($Feed['itunes_image'])) {
                                $powerpress_feed['itunes_image'] = $Feed['itunes_image'];
                            }
                            return;
                        }
                    }
                }
            }
            $feed_slug = get_query_var('feed');
            // Are we dealing with a custom podcast channel or a custom post type podcast feed...
            if (!empty($GeneralSettings['posttype_podcasting']) || !empty($GeneralSettings['custom_feeds'][$feed_slug])) {
                $Feed = false;
                if (!empty($GeneralSettings['posttype_podcasting'])) {
                    $post_type = get_query_var('post_type');
                    //$post_type = get_post_type();
                    // Get the settings for this podcast post type
                    $PostTypeSettingsArray = get_option('powerpress_posttype_' . $post_type);
                    if (!empty($PostTypeSettingsArray[$feed_slug])) {
                        $FeedCustom = $PostTypeSettingsArray[$feed_slug];
                        $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic);
                        $Feed['post_type'] = $post_type;
                    }
                }
                if (empty($Feed) && !empty($GeneralSettings['custom_feeds'][$feed_slug])) {
                    $FeedCustom = get_option('powerpress_feed_' . $feed_slug);
                    // Get custom feed specific settings
                    $Feed = powerpress_merge_empty_feed_settings($FeedCustom, $FeedSettingsBasic, $feed_slug == 'podcast');
                }
                if ($Feed) {
                    $powerpress_feed = array();
                    $powerpress_feed['is_custom'] = true;
                    $powerpress_feed['feed-slug'] = $feed_slug;
                    if (!empty($Feed['post_type'])) {
                        $powerpress_feed['post_type'] = $Feed['post_type'];
                    }
                    $powerpress_feed['process_podpress'] = $feed_slug == 'podcast' ? !empty($GeneralSettings['process_podpress']) : false;
                    // We don't touch podpress data for custom feeds
                    $powerpress_feed['rss_language'] = '';
                    // RSS language should be set by WordPress by default
                    $powerpress_feed['default_url'] = '';
                    if (!empty($powerpress_feed['default_url'])) {
                        $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') . '/';
                    }
                    $explicit = array("no", "yes", "clean");
                    $powerpress_feed['explicit'] = 'no';
                    if (!empty($Feed['itunes_explicit'])) {
                        $powerpress_feed['explicit'] = $explicit[$Feed['itunes_explicit']];
                    }
                    if (!empty($Feed['itunes_talent_name'])) {
                        $powerpress_feed['itunes_talent_name'] = $Feed['itunes_talent_name'];
                    } else {
                        $powerpress_feed['itunes_talent_name'] = get_wp_title_rss();
                    }
                    $powerpress_feed['enhance_itunes_summary'] = $Feed['enhance_itunes_summary'];
                    if (!empty($GeneralSettings['seo_itunes'])) {
                        $powerpress_feed['enhance_itunes_summary'] = 1;
                    }
                    $powerpress_feed['posts_per_rss'] = false;
                    if (!empty($Feed['posts_per_rss']) && is_numeric($Feed['posts_per_rss']) && $Feed['posts_per_rss'] > 0) {
                        $powerpress_feed['posts_per_rss'] = $Feed['posts_per_rss'];
                    }
                    if (!empty($Feed['feed_redirect_url'])) {
                        $powerpress_feed['feed_redirect_url'] = $Feed['feed_redirect_url'];
                    }
                    if (!empty($Feed['itunes_author_post'])) {
                        $powerpress_feed['itunes_author_post'] = true;
                    }
                    if (!empty($Feed['rss_language'])) {
                        $powerpress_feed['rss_language'] = $Feed['rss_language'];
                    }
                    if (!empty($GeneralSettings['podcast_embed_in_feed'])) {
                        $powerpress_feed['podcast_embed_in_feed'] = true;
                    }
                    if (!empty($Feed['maximize_feed'])) {
                        $powerpress_feed['maximize_feed'] = true;
                    }
                    if (!empty($Feed['episode_itunes_image']) && !empty($Feed['itunes_image'])) {
                        $powerpress_feed['itunes_image'] = $Feed['itunes_image'];
                    }
                    return;
                }
            }
            if (!isset($FeedSettingsBasic['apply_to'])) {
                $FeedSettingsBasic['apply_to'] = 1;
            }
            // We fell this far,we must be in simple mode or the user never saved customized their custom feed settings
            switch ($FeedSettingsBasic['apply_to']) {
                case 0:
                    if ($feed_slug != 'podcast') {
                        break;
                    }
                    // important: no break here!
                // important: no break here!
                case 2:
                    if ($feed_slug != 'feed' && $feed_slug != 'rss2' && $feed_slug != 'podcast') {
                        break;
                    }
                    // We're only adding podcasts to the rss2 feed in this situation
                    if ($wp_query->is_category) {
                        // don't touch the category feeds...
                        break;
                    }
                    if ($wp_query->is_tag) {
                        // don't touch the tag feeds...
                        break;
                    }
                    if ($wp_query->is_comment_feed) {
                        // don't touch the comments feeds...
                        break;
                    }
                    // important: no break here!
                // important: no break here!
                case 1:
                    $powerpress_feed = array();
                    // Only store what's needed for each feed item
                    $powerpress_feed['is_custom'] = false;
                    // ($feed_slug == 'podcast'?true:false);
                    $powerpress_feed['feed-slug'] = $feed_slug;
                    $powerpress_feed['process_podpress'] = !empty($GeneralSettings['process_podpress']);
                    // We don't touch podpress data for custom feeds
                    $powerpress_feed['default_url'] = '';
                    if (!empty($GeneralSettings['default_url'])) {
                        $powerpress_feed['default_url'] = rtrim($GeneralSettings['default_url'], '/') . '/';
                    }
                    $explicit = array("no", "yes", "clean");
                    $powerpress_feed['explicit'] = 'no';
                    if (!empty($FeedSettingsBasic['itunes_explicit'])) {
                        $powerpress_feed['explicit'] = $explicit[$FeedSettingsBasic['itunes_explicit']];
                    }
                    if (!empty($FeedSettingsBasic['itunes_talent_name'])) {
                        $powerpress_feed['itunes_talent_name'] = $FeedSettingsBasic['itunes_talent_name'];
                    } else {
                        $powerpress_feed['itunes_talent_name'] = get_wp_title_rss();
                    }
                    $powerpress_feed['enhance_itunes_summary'] = 0;
                    if (isset($FeedSettingsBasic['enhance_itunes_summary'])) {
                        $powerpress_feed['enhance_itunes_summary'] = $FeedSettingsBasic['enhance_itunes_summary'];
                    }
                    if (!empty($GeneralSettings['seo_itunes'])) {
                        $powerpress_feed['enhance_itunes_summary'] = 1;
                    }
                    $powerpress_feed['posts_per_rss'] = false;
                    if (!empty($FeedSettingsBasic['posts_per_rss']) && is_numeric($FeedSettingsBasic['posts_per_rss']) && $FeedSettingsBasic['posts_per_rss'] > 0) {
                        $powerpress_feed['posts_per_rss'] = $FeedSettingsBasic['posts_per_rss'];
                    }
                    if (!empty($FeedSettingsBasic['itunes_author_post'])) {
                        $powerpress_feed['itunes_author_post'] = true;
                    }
                    $powerpress_feed['rss_language'] = '';
                    // Cannot set the language setting in simple mode
                    if (!empty($GeneralSettings['podcast_embed_in_feed'])) {
                        $powerpress_feed['podcast_embed_in_feed'] = true;
                    }
                    if (!empty($FeedSettingsBasic['episode_itunes_image']) && !empty($FeedSettingsBasic['itunes_image'])) {
                        $powerpress_feed['itunes_image'] = $FeedSettingsBasic['itunes_image'];
                    }
                    break;
                    // All other cases we let fall through
            }
        }
    }
}
Example #15
0
File: feed.php Project: RA2WP/RA2WP
/**
 * Displays Site Icon in RSS2.
 *
 * @since 4.3.0
 */
function rss2_site_icon()
{
    $rss_title = get_wp_title_rss();
    if (empty($rss_title)) {
        $rss_title = get_bloginfo_rss('name');
    }
    $url = get_site_icon_url(32);
    if ($url) {
        echo '
<image>
	<url>' . convert_chars($url) . '</url>
	<title>' . $rss_title . '</title>
	<link>' . get_bloginfo_rss('url') . '</link>
	<width>32</width>
	<height>32</height>
</image> ' . "\n";
    }
}
function powerpresssubscribe_get_settings($ExtraData)
{
    $GeneralSettings = get_option('powerpress_general');
    $feed_slug = empty($ExtraData['feed']) ? 'podcast' : $ExtraData['feed'];
    $post_type = empty($ExtraData['post_type']) ? false : $ExtraData['post_type'];
    $category_id = empty($ExtraData['cat_id']) ? false : $ExtraData['cat_id'];
    $taxonomy_term_id = empty($ExtraData['taxonomy_term_id']) ? false : $ExtraData['taxonomy_term_id'];
    if (empty($ExtraData['subscribe_type'])) {
        // Make sure this value is set
        $ExtraData['subscribe_type'] = '';
    }
    switch ($ExtraData['subscribe_type']) {
        case 'post_type':
            $category_id = 0;
            $taxonomy_term_id = 0;
            break;
        case 'category':
            $feed_slug = 'podcast';
            $taxonomy_term_id = 0;
            $post_type = '';
            break;
        case 'ttid':
            $feed_slug = 'podcast';
            $category_id = 0;
            if (empty($post_type)) {
                $post_type = get_post_type();
            }
            break;
        case 'channel':
        case 'general':
        default:
            $category_id = 0;
            $post_type = '';
            $taxonomy_term_id = 0;
            break;
    }
    // We need to know if category podcasting is enabled, if it is then we may need to dig deeper for this info....
    if (!empty($GeneralSettings['cat_casting']) && $feed_slug == 'podcast' && (empty($ExtraData['subscribe_type']) || $ExtraData['subscribe_type'] == 'category')) {
        if (!$category_id && is_category()) {
            $category_id = get_query_var('cat');
        }
        if (!$category_id && is_single()) {
            $categories = wp_get_post_categories(get_the_ID());
            if (count($categories) == 1) {
                list($null, $category_id) = each($categories);
            }
        }
        if ($category_id) {
            $Settings = get_option('powerpress_cat_feed_' . $category_id);
            if (!empty($Settings)) {
                //$Settings['title'] = $Settings['title'];
                if (empty($Settings['title'])) {
                    $Settings['title'] = get_bloginfo('name') . get_wp_title_rss();
                }
                // Get category title
                if (!empty($Settings['feed_redirect_url'])) {
                    $Settings['feed_url'] = $Settings['feed_redirect_url'];
                } else {
                    $Settings['feed_url'] = get_category_feed_link($category_id);
                }
                // Get category feed URL
                $Settings['subscribe_page_url'] = powerpresssubscribe_get_subscribe_page($Settings);
                $Settings['itunes_url'] = powerpresssubscribe_get_itunes_url($Settings);
                $Settings['image_url'] = $Settings['itunes_image'];
                $Settings['subscribe_feature_email'] = !empty($GeneralSettings['subscribe_feature_email']);
                return $Settings;
            }
        }
        if ($ExtraData['subscribe_type'] == 'category') {
            return false;
        }
        // let fall through to find better settings
    }
    // Taxonomy
    if ($ExtraData['subscribe_type'] == 'ttid') {
        if (!empty($GeneralSettings['taxonomy_podcasting'])) {
            // TODO! Taxonomy Podcasting subscription options
        }
        return false;
    }
    // Post Type Podcasting
    if ($ExtraData['subscribe_type'] == 'post_type') {
        if (!empty($GeneralSettings['posttype_podcasting'])) {
            if (empty($post_type) && !empty($ExtraData['id'])) {
                $post_type = get_post_type($ExtraData['id']);
            }
            switch ($post_type) {
                case 'page':
                case 'post':
                    // SWEET, CARRY ON!
                    break;
                default:
                    $SettingsArray = get_option('powerpress_posttype_' . $post_type);
                    $Settings = false;
                    if (!empty($SettingsArray[$feed_slug])) {
                        $Settings = $SettingsArray[$feed_slug];
                    }
                    if (!empty($Settings)) {
                        $Settings['title'] = $Settings['title'];
                        if (empty($Settings['title'])) {
                            $Settings['title'] = get_bloginfo('name') . get_wp_title_rss();
                        }
                        // Get category title
                        if (!empty($Settings['feed_redirect_url'])) {
                            $Settings['feed_url'] = $Settings['feed_redirect_url'];
                        } else {
                            $Settings['feed_url'] = get_post_type_archive_feed_link($post_type, $feed_slug);
                        }
                        // Get category feed URL
                        $Settings['subscribe_page_url'] = powerpresssubscribe_get_subscribe_page($Settings);
                        $Settings['itunes_url'] = powerpresssubscribe_get_itunes_url($Settings);
                        $Settings['image_url'] = $Settings['itunes_image'];
                        $Settings['subscribe_feature_email'] = !empty($GeneralSettings['subscribe_feature_email']);
                        return $Settings;
                    }
                    break;
            }
        }
        return false;
    }
    // Podcast default and channel feed settings
    $FeedSettings = get_option('powerpress_feed_' . $feed_slug);
    if (empty($FeedSettings) && $feed_slug == 'podcast') {
        $FeedSettings = get_option('powerpress_feed');
    }
    // Get the main feed settings
    if (!empty($FeedSettings)) {
        $FeedSettings['title'] = $FeedSettings['title'];
        if (empty($FeedSettings['title'])) {
            $FeedSettings['title'] = get_bloginfo('name');
        }
        // Get blog title
        if (!empty($FeedSettings['feed_redirect_url'])) {
            $FeedSettings['feed_url'] = $FeedSettings['feed_redirect_url'];
        } else {
            $FeedSettings['feed_url'] = get_feed_link($feed_slug);
        }
        // Get Podcast RSS Feed
        $FeedSettings['subscribe_page_url'] = powerpresssubscribe_get_subscribe_page($FeedSettings);
        $FeedSettings['itunes_url'] = powerpresssubscribe_get_itunes_url($FeedSettings);
        $FeedSettings['image_url'] = $FeedSettings['itunes_image'];
        $FeedSettings['subscribe_feature_email'] = !empty($GeneralSettings['subscribe_feature_email']);
        return $FeedSettings;
    }
    return false;
}
	xml:lang="<?php 
echo get_option('rss_language');
?>
"
	xmlns:thr="http://purl.org/syndication/thread/1.0"
	<?php 
do_action('atom_ns');
?>
>
	<title type="text"><?php 
if (is_singular()) {
    printf(ent2ncr(__('Comments on: %s')), get_the_title_rss());
} elseif (is_search()) {
    printf(ent2ncr(__('Comments for %1$s searching on %2$s')), get_bloginfo_rss('name'), attribute_escape(get_search_query()));
} else {
    printf(ent2ncr(__('Comments for %s')), get_bloginfo_rss('name') . get_wp_title_rss());
}
?>
</title>
	<subtitle type="text"><?php 
bloginfo_rss('description');
?>
</subtitle>

	<updated><?php 
echo mysql2date('Y-m-d\\TH:i:s\\Z', get_lastcommentmodified('GMT'));
?>
</updated>
	<?php 
the_generator('atom');
?>
function wvrx_ts_weaverx_sc_info()
{
    // [info]  ======================
    global $current_user;
    $out = __('<strong>Theme/User Info</strong><hr />', 'weaverx-theme-support');
    get_currentuserinfo();
    if (isset($current_user->display_name)) {
        $out .= __('<em>User:</em> ', 'weaverx-theme-support') . $current_user->display_name . '<br />';
    }
    $out .= '&nbsp;&nbsp;' . wp_register('', '<br />', false);
    $out .= '&nbsp;&nbsp;' . wp_loginout('', false) . '<br />';
    $agent = __('Not Available', 'weaverx-theme-support');
    if (isset($_SERVER["HTTP_USER_AGENT"])) {
        $agent = $_SERVER['HTTP_USER_AGENT'];
    }
    $out .= __('<em>User Agent</em>:', 'weaverx-theme-support') . ' <small>' . $agent . '</small>';
    $out .= '<div id="example"></div>
<script type="text/javascript">
var txt = "";
var myWidth;
if( typeof( window.innerWidth ) == "number" ) {
//Non-IE
myWidth = window.innerWidth;
} else if( document.documentElement &&
( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in "standards compliant mode"
myWidth = document.documentElement.clientWidth;
} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
}
txt+= "<em>Browser Width: </em>" + myWidth + " px</br>";
document.getElementById("example").innerHTML=txt;
</script>';
    $out .= __('<em>Feed title:</em> ', 'weaverx-theme-support') . get_bloginfo_rss('name') . '<br />' . get_wp_title_rss();
    $out .= __('<br /><em>You are using</em> WordPress ', 'weaverx-theme-support') . $GLOBALS['wp_version'] . '<br /><em>PHP Version:</em> ' . phpversion();
    $out .= __('<br /><em>Memory:</em> ', 'weaverx-theme-support') . round(memory_get_usage() / 1024 / 1024, 2) . 'M of ' . (int) ini_get('memory_limit') . 'M <hr />';
    return $out;
}