194 lines
5.6 KiB
PHP
194 lines
5.6 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Add your own functions here. You can also copy some of the theme functions into this file.
|
|
* Wordpress will use those functions instead of the original functions then.
|
|
*/
|
|
function wpb_alter_comment_form_fields($fields) {
|
|
//unset($fields['author']);
|
|
unset($fields['email']);
|
|
unset($fields['url']);
|
|
return $fields;
|
|
}
|
|
add_filter('comment_form_default_fields', 'wpb_alter_comment_form_fields');
|
|
|
|
/* remove ip address from comments
|
|
*
|
|
*/
|
|
|
|
function wpb_remove_commentsip( $comment_author_ip ) {
|
|
return '';
|
|
}
|
|
add_filter( 'pre_comment_user_ip', 'wpb_remove_commentsip' );
|
|
|
|
if ( !function_exists('base_rss_feed') ) {
|
|
|
|
function base_rss_feed($size = 4, $feed = 'https://', $date = false, $cache_time = 1800)
|
|
{
|
|
// Include SimplePie RSS parsing engine
|
|
include_once ABSPATH . WPINC . '/feed.php';
|
|
// Set the cache time for SimplePie
|
|
add_filter( 'wp_feed_cache_transient_lifetime', create_function( '$a', "return $cache_time;" ) );
|
|
// Build the SimplePie object
|
|
$rss = fetch_feed($feed);
|
|
// Check for errors in the RSS XML
|
|
if ( !is_wp_error( $rss ) ) {
|
|
// Set a limit for the number of items to parse
|
|
$maxitems = $rss->get_item_quantity($size);
|
|
$rss_items = $rss->get_items( 0, $maxitems);
|
|
// Store the total number of items found in the feed
|
|
$i = 0;
|
|
$total_entries = count($rss_items);
|
|
// Output HTML
|
|
$html = "";
|
|
//$html = var_dump($rss);
|
|
$rownum=1;
|
|
$r2=1;
|
|
foreach ($rss_items as $item) {
|
|
$i++;
|
|
// Add a class of "last" to the last item in the list
|
|
if( $total_entries == $i ) {
|
|
$last = " class='last'";
|
|
} else {
|
|
$last = "";
|
|
}
|
|
// Store the data we need from the feed
|
|
$title = $item->get_title();
|
|
$link = $item->get_permalink();
|
|
$desc = $item->get_description();
|
|
$date_posted = $item->get_date('F j, Y');
|
|
$feed_cat = $item->get_category();
|
|
$feed_cat = $feed_cat->get_label();
|
|
$en="";
|
|
if ($enclosure = $item->get_enclosure())
|
|
{
|
|
$rss_medium = $enclosure->get_medium(); // medium - image video
|
|
//if($rss_medium =="image"){$en = $enclosure->get_link();}
|
|
$en = $enclosure->get_link();
|
|
}
|
|
$feed_thumb=$en;
|
|
$pos = strpos($feed_thumb, 'base64');
|
|
if(1 > 0){
|
|
// Output
|
|
if(!$pos===false || $feed_thumb=="")
|
|
{
|
|
$feed_thumb="/wp-content/uploads/2015/02/fireworks.jpg";
|
|
}
|
|
else
|
|
{
|
|
$default_opts = array(
|
|
'http'=>array(
|
|
'method'=>"GET",
|
|
'header'=>"Referer: http://www.fakesite.com/hotlink-check/",
|
|
)
|
|
);
|
|
stream_context_set_default($default_opts);
|
|
$url = $feed_thumb;
|
|
$headers = get_headers($url, 1);
|
|
if (preg_match('/403/', $headers[0])) {
|
|
$feed_thumb="/wp-content/uploads/2015/02/fireworks.jpg";
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
if($rownum==1) {
|
|
$html .= '<div class="nooverlay atwone" style="padding-bottom:20px;">';
|
|
//if( $date == true ) $html .= '<span style="font-weight:bold;">'.$date_posted.'</span>';
|
|
$html .= '<div class="hp35" style="background-color:transparent;"><a href="'.$link.'" target="_blank" rel="nofollow"><img src="'.$feed_thumb.'" style="width:100%;height:auto;"/></a></div>';
|
|
$html .= '<h3 class="hp35h2"><a href="'.$link.'" target="_blank" rel="nofollow">'.$title.'</a></h3>';
|
|
$html .='<div style="clear:both;border-bottom:1px solid #ff6600;border-width:1px;font-size:1px;paddding:0px;margin:0px;line-height:3px;"> </div>';
|
|
//$html .= '<p>'.$desc.'</p>'p
|
|
|
|
$rownum++;
|
|
}
|
|
|
|
else
|
|
{
|
|
$rownum++;
|
|
if($rs2 <= 5)
|
|
{
|
|
|
|
$bcrss="";
|
|
if($rs2==1)
|
|
{
|
|
$bcrss="";
|
|
}
|
|
$html .= '<div style="clear:both;padding-top:20px;">';
|
|
$html .= '<a href="'.$link.'" target="_blank" class="rs-thumbnail-link" rel="nofollow"><img src="'.$feed_thumb.'" alt=" " /></a>';
|
|
$html .= '<h3 style="font-size:130%;line-height:130%;padding:0 5px 0px 0px;"><a href="'.$link.'" target="_blank" rel="nofollow">'.$title.'</a></h3><div class="clearfix"></div><div style="border-bottom:1px solid #ff6600;border-width:1px;clear:both;width:100%;"> </div>';
|
|
if( $date == true ) $html .= '';
|
|
$rs2++;
|
|
if($rs2==5)
|
|
{
|
|
|
|
$rs2=9;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
//$html .= "<p>$desc</p>";
|
|
//$html .= "<p>$feed_cat</p>";
|
|
$html .= '</div>';
|
|
}
|
|
}
|
|
$html .= "";
|
|
} else {
|
|
$html = "An error occurred while parsing your RSS feed. Check that it's a valid XML file.";
|
|
}
|
|
return $html;
|
|
}
|
|
}
|
|
|
|
|
|
/** Define [rss] shortcode */
|
|
if( function_exists('base_rss_feed') && !function_exists('base_rss_shortcode') ) {
|
|
function base_rss_shortcode($atts) {
|
|
extract(shortcode_atts(array(
|
|
'size' => '10',
|
|
'feed' => 'https://',
|
|
'date' => false,
|
|
), $atts));
|
|
|
|
$content = base_rss_feed($size, $feed, $date);
|
|
return $content;
|
|
}
|
|
add_shortcode("rss", "base_rss_shortcode");
|
|
}
|
|
|
|
// add the requisite tag where a thumbnail exists
|
|
function add_media_thumbnail() {
|
|
global $post;
|
|
if( has_post_thumbnail( $post->ID )) {
|
|
$thumb_ID = get_post_thumbnail_id( $post->ID );
|
|
$details = wp_get_attachment_image_src($thumb_ID, 'portfolio_small');
|
|
if( is_array($details) ) {
|
|
echo '<url>' . $details[0]
|
|
. '</url>';
|
|
}
|
|
}
|
|
}
|
|
|
|
// add the two functions above into the relevant WP hooks
|
|
add_action( 'rss2_ns', 'add_media_namespace' );
|
|
add_action( 'rss2_item', 'add_media_thumbnail' );
|
|
|
|
|
|
// end of rss feed
|
|
|
|
|
|
/* run youtube videos in text widget */
|
|
add_filter( 'widget_text', array( $wp_embed, 'run_shortcode' ), 8 );
|
|
add_filter( 'widget_text', array( $wp_embed, 'autoembed'), 8 );
|
|
|
|
|
|
/* Plugin Name: No Comment Cookies
|
|
* Author: Thomas Scholz <info@toscho.de>
|
|
* Author URI: http://toscho.de
|
|
*/
|
|
remove_action( 'set_comment_cookies', 'wp_set_comment_cookies' );
|
|
|
|
do_shortcode( '[cf7-db-display-ip]' );
|