File: /home/nudepix.eu/public_html/wp-content/themes/cpp/functions.php
<?php
define('IMWB_INTEREST_VERSION', '1.6');
require_once ( get_template_directory() . '/theme-options.php' );
add_action("after_setup_theme", "imwb_interest_setup");
add_action("widgets_init", "imwb_interest_widgets_init");
add_action('wp_head','imwb_interest_open_graph_head',50);
add_filter('imwb_interest_filter_content', 'imwb_interest_content_filter', 10, 2);
if (!is_admin()) {
add_action('wp_enqueue_scripts', 'imwb_interest_enqueue_scripts');
}
else {
// Theme Update Check
require_once('theme-admin-update.php');
// Initialize Update Object
$themeUpdate = new IMWB_Interest_Update('imwb_interest');
$themeUpdate->lastUpdateCheck();
if($themeUpdate->update['latest_version'] > IMWB_INTEREST_VERSION)
add_action('admin_notices', 'imwb_interest_admin_update_notice');
}
function imwb_interest_admin_update_notice(){
GLOBAL $themeUpdate;
echo '<div class="updated">'.$themeUpdate->update['after_plugin_row'].'</div>';
}
function imwb_interest_get_blogtitle() {
wp_title("|", true, "right");
bloginfo("name");
}
function imwb_interest_setup() {
add_theme_support("automatic-feed-links");
add_theme_support("post-thumbnails");
$bgDefaults = array(
'default-color' => '000000',
'default-image' => get_template_directory_uri() . '/images/background.png'
);
$headerDefaults = array(
'default-image' => '',
'random-default' => false,
'width' => 520,
'height' => 40,
'flex-height' => false,
'flex-width' => false,
'default-text-color' => 'CB2027',
'header-text' => true,
'uploads' => true,
'admin-head-callback' => 'imwb_interest_admin_header_style'
);
if ( imwb_interest_is_wp_version( '3.4' ) ) {
add_theme_support( 'custom-background', $bgDefaults);
add_theme_support( 'custom-header', $headerDefaults);
}
else {
define( 'HEADER_TEXTCOLOR', $headerDefaults['default-text-color'] );
define( 'HEADER_IMAGE', '' );
define( 'HEADER_IMAGE_WIDTH', $headerDefaults['width'] );
define( 'HEADER_IMAGE_HEIGHT', $headerDefaults['height'] );
add_custom_background( 'imwb_interest_custom_background_callback' );
add_custom_image_header( $headerDefaults['wp-head-callback'], $headerDefaults['admin-head-callback'], $headerDefaults['admin-preview-callback'] );
}
add_image_size( 'imwb-interest-thumb', 192, 9999 );
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'cpp_page_menu', 'CPP Header Menu' );
}
function imwb_interest_enqueue_scripts() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery_masonry', get_template_directory_uri().'/scripts/jquery.masonry.min.js', array('jquery') );
wp_enqueue_script( 'jquery_infinitescroll', get_template_directory_uri().'/scripts/jquery.infinitescroll.min.js', array('jquery') );
}
function imwb_interest_get_option($element) {
$defaults = imwb_interest_get_default_theme_options();
$imwb_interest_current_options = get_option('imwb_interest_theme_options', $defaults);
if(isset($imwb_interest_current_options[$element]))
return stripslashes($imwb_interest_current_options[$element]);
else if ( isset($defaults[$element]) )
return stripslashes($defaults[$element]);
else
return false;
}
function imwb_interest_widgets_init() {
register_sidebar(array(
"name" => "Main Sidebar"
,"id" => "sidebar-widget"
,"before_widget"=> '<li id="%1$s" class="widget-container %2$s">'
,"after_widget" => "</li>"
,"before_title" => "<h3 class=\"widget-title\">"
,"after_title" => "</h3>"
));
register_sidebar(array(
"name" => "Top Nag Bar [640 x 70]"
,"id" => "nag-bar-widget"
,"before_widget"=> '<div id="%1$s" class="widget-container %2$s">'
,"after_widget" => "</div>"
,"before_title" => "<h3 class=\"widget-title\">"
,"after_title" => "</h3>"
));
register_sidebar(array(
"name" => "Single Post/Page Sidebar"
,"id" => "sidebar-post-widget"
,"before_widget"=> '<li id="%1$s" class="widget-container %2$s">'
,"after_widget" => "</li>"
,"before_title" => "<h3 class=\"widget-title\">"
,"after_title" => "</h3>"
));
$active_widgets = get_option( 'sidebars_widgets' );
if (!empty( $active_widgets['nag-bar-widget']))
return;
// Note that widgets are numbered. We need a counter:
$counter = 1;
// Add a 'demo' widget to the top sidebar …
$active_widgets['nag-bar-widget'][0] = 'text-' . $counter;
$widget_content[ $counter ] = array ( 'title' => '', 'text' => '<p>This is a widget area - If you go to "Appearance" in your WP-Admin you can change the content of this box in "Widgets", or you can remove this box completely under "Theme Options"</p>' );
update_option( 'widget_text', $widget_content );
// Now save the $active_widgets array.
update_option( 'sidebars_widgets', $active_widgets );
}
function imwb_interest_content_filter($content, $postImageSrc)
{
if($postImageSrc == '')
$content = preg_replace('#(<[/]?img.*>)#U', '', $content);
else
$content = preg_replace('#<\s*img.+src=["\']'.preg_quote($postImageSrc).'["\'].*>#Ui', '', $content);
return $content;
}
function imwb_wp_list_categories($args) {
$exclude = imwb_interest_get_option('excludecats');
$catList = wp_list_categories("echo=0&exclude=".$exclude."&".$args);
$catList = preg_replace('~(</li>)(\s+)~', '$1<span> · </span>', trim($catList));
echo $catList;
}
function imwb_interest_get_logo() {
// if(imwb_interest_get_option('logourl') != '')
// return '<a href="'.home_url( '/' ).'" alt=""> <img src="'.imwb_interest_get_option('logourl').'" /> </a>';
// else
// return '<a href="'.home_url( '/' ).'" alt=""><h1 id="blog_title">'.get_bloginfo('name').'</h1></a><h2 id="blog_tagline">'.get_bloginfo('description').'</h2>';
$text_color = get_header_textcolor();
$header_image = get_header_image();
if ( $text_color && $text_color != 'blank' )
$text_style = ' style="color:#' . $text_color . '"';
else
$text_style = '';
if(!empty($header_image) && !empty($text_style)) {
echo '<div id="logo" style="background-image: URL('.get_header_image().')">';
echo '<a href="'.home_url( '/' ).'" alt=""><h1 id="blog_title" '.$text_style.'>'.get_bloginfo('name').'</h1></a><h2 id="blog_tagline" '.$text_style.'>'.get_bloginfo('description').'</h2>';
}
else if(!empty($header_image) && empty($text_style)) {
echo '<div id="logo">';
echo '<a href="'.home_url( '/' ).'" alt=""> <img src="'.get_header_image().'" /> </a>';
}
else if(empty($header_image) && !empty($text_style)) {
echo '<div id="logo">';
echo '<a href="'.home_url( '/' ).'" alt=""><h1 id="blog_title" '.$text_style.'>'.get_bloginfo('name').'</h1></a><h2 id="blog_tagline" '.$text_style.'>'.get_bloginfo('description').'</h2>';
}
else {
echo '<div id="logo">';
// echo '<a href="'.home_url( '/' ).'" alt=""><h1 id="blog_title" >'.get_bloginfo('name').'</h1></a><h2 id="blog_tagline" >'.get_bloginfo('description').'</h2>';
}
echo '</div>';
}
function imwb_interest_get_the_image( $args = array() ) {
global $post;
/* Make sure Covert Video Content Video Thumbnail included in custom field search */
$custom_fields = array('_video_thumbnail');
if(imwb_interest_get_option('imgfields') != '')
$custom_fields = array_merge($custom_fields, explode(',', imwb_interest_get_option('imgfields')));
/* Set the default arguments. */
$defaults = array(
'custom_fields' => $custom_fields,
'post_id' => $post->ID,
'size' => 'imwb-interest-thumb',
'order_of_image' => 1,
'link_to_post' => true,
'image_alt' => true,
'image_scan' => true,
'image_class' => 'tack_img',
'use_image_scan_link' => false,
'image_scan_link' => '',
'echo' => true
);
/* Merge the input arguments and the defaults. */
$args = wp_parse_args( $args, $defaults );
/* Extract the array to allow easy use of variables. */
extract( $args );
/* If a custom field key (array) is defined, check for images by custom field. */
if (!empty( $custom_fields ))
$image = imwb_interest_get_image_custom_fields( $args );
/* If no image found check for a post thumbnail image. */
if (empty( $image ))
$image = imwb_interest_image_post_thumbnail( $args );
/* If no image found and $image_scan is set to true, scan the post for images. */
if ( empty( $image ) && !empty( $image_scan ) )
$image = imwb_interest_image_in_post( $args );
/* If no image found check for an image by attachment. */
// if (empty( $image ))
// $image = imwb_interest_image_attachment( $args );
/* If no image found and a $default_image is set, get the default image. */
if (empty($image))
$image = imwb_interest_default_image( $args );
$image = imwb_interest_image_format($args, $image);
/* Or, if $echo is set to false, return the formatted image. */
if ( false === $echo ) {
return $image;
}
/* Display the image if we get to this point. */
echo $image;
}
/**
* Calls images by custom field key. Script loops through multiple custom field keys. If that particular key
* is found, $image is set and the loop breaks. If an image is found, it is returned.
*
*/
function imwb_interest_get_image_custom_fields( $args = array() ) {
$image = '';
if ( is_array( $args['custom_fields'] ) ) {
/* Loop through each of the given meta keys. */
foreach ( $args['custom_fields'] as $custom_fields ) {
/* Get the image URL by the current meta key in the loop. */
$image = get_post_meta( $args['post_id'], $custom_fields, true );
/* If an image was found, break out of the loop. */
if ( !empty( $image ) )
break;
}
}
/* If a custom key value has been given for one of the keys, return the image URL. */
if ( !empty( $image ) )
return $image;
return false;
}
/**
* Checks for images using a custom version of the WordPress 2.9+ get_the_post_thumbnail() function.
* If an image is found, return it and the $post_thumbnail_id. The WordPress function's other filters are
* later added in the display_the_image() function.
*
*/
function imwb_interest_image_post_thumbnail( $args = array() ) {
/* Check for a post image ID (set by WP as a custom field). */
$post_tid = get_post_thumbnail_id( $args['post_id'] );
/* If no post image ID is found, return false. */
if ( empty( $post_tid ) )
return false;
/* Apply filters on post_thumbnail_size because this is a default WP filter used with its image feature. */
$size = apply_filters( 'post_thumbnail_size', $args['size'] );
/* Get the attachment image source. This should return an array. */
$image = wp_get_attachment_image_src( $post_tid, $size );
return $image[0];
}
/**
* Check for attachment images. Uses get_children() to check if the post has images attached. If image
* attachments are found, loop through each. The loop only breaks once $order_of_image is reached.
*
*/
function imwb_interest_image_attachment( $args = array() ) {
/* Get attachments for the inputted $post_id. */
$attachments = get_children( array( 'post_parent' => $args['post_id'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) );
/* If no attachments are found, check if the post itself is an attachment and grab its image. */
if ( empty( $attachments ) && $args['size'] ) {
if ( 'attachment' == get_post_type( $args['post_id'] ) ) {
$image = wp_get_attachment_image_src( $args['post_id'], $args['size'] );
}
}
/* If no attachments or image is found, return false. */
if ( empty( $attachments ) && empty( $image ) )
return false;
/* Set the default iterator to 0. */
$i = 0;
/* Loop through each attachment. Once the $order_of_image (default is '1') is reached, break the loop. */
foreach ( $attachments as $id => $attachment ) {
if ( ++$i == $args['order_of_image'] ) {
$image = wp_get_attachment_image_src( $id, $args['size'] );
break;
}
}
/* Return the image URL. */
return $image[0];
}
/**
* Scans the post for images within the content. Not called by default with get_the_image(). Shouldn't use
* if using large images within posts, better to use the other options.
*
*/
function imwb_interest_image_in_post( &$args = array() ) {
/* See if we need to try and grab the Anchor tag around an image */
if($args['use_image_scan_link']) {
preg_match_all( '|(<a.*?.>)\s*<img.*?src=[\'"](.*?)[\'"].*?>\s*</a>|i', get_post_field( 'post_content', $args['post_id'] ), $matches );
/* If there is a match for anchor tag and image, return its URL. */
if ( isset( $matches ) && !empty( $matches[1][0] ) ) {
// Make sure were not grabbing an buy button from Covert Content
if(!stristr($matches[1][0],'class="amzBuyBtn"') && !stristr($matches[1][0],'class="cjBuyBtn"') && !stristr($matches[1][0],'class="cbBuyBtn"')) {
$args['image_scan_link'] = $matches[1][0];
return $matches[2][0];
}
}
}
/* Either not wanting Anchor tag or none found */
/* Search the post's content for the <img /> tag and get its URL. */
preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', get_post_field( 'post_content', $args['post_id'] ), $matches );
/* If there is a match for the image, return its URL. */
if ( isset( $matches ) && !empty( $matches[1][0] ) )
return $matches[1][0];
return false;
}
/**
* IF default images are set then chooses a random one, othrwise return the standard theme deault one
*
*/
function imwb_interest_default_image( $args = array() ) {
$noDefaultImage = true;
// Get the images
for($i = 1; $i < 4; $i++) {
$defImage = imwb_interest_get_option('defimage'.$i);
if($defImage != '') {
$defImages[] = $defImage;
$noDefaultImage = false;
}
}
if($noDefaultImage) {
$num = rand(1,5);
return get_template_directory_uri().'/images/defaultimage0'.$num.'.jpg';
}
// See how many set and choose a random one
return $defImages[rand(0, count($defImages)-1)];
}
/**
* Formats an image with appropriate alt text and class. Adds a link to the post if argument is set. Should
* only be called if there is an image to display, but will handle it if not.
*
*/
function imwb_interest_image_format( $args = array(), $image = false ) {
/* If there is no image URL, return false. */
if ( empty( $image ) )
return false;
/* Extract the arguments for easy-to-use variables. */
extract( $args );
/* If there is alt text, set it. Otherwise, default to the post title. */
$image_alt = ((empty($image_alt)) ? '' : apply_filters( 'the_title', get_post_field( 'post_title', $post_id ) ) );
/* Add the image attributes to the <img /> element. */
$html = '<img src="' . $image . '" alt="' . esc_attr( strip_tags( $image_alt ) ) . '" title="' . esc_attr( apply_filters( 'the_title', get_post_field( 'post_title', $post_id ) ) ) . '" class="'.$image_class.'" />';
/* If $link_to_post is set to true, link the image to its post. */
if ( $link_to_post )
$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( apply_filters( 'the_title', get_post_field( 'post_title', $post_id ) ) ) . '">' . $html . '</a>';
if($use_image_scan_link && !empty($image_scan_link))
$html = $image_scan_link . $html . '</a>';
return $html;
}
/**
* Post Meta Data Box and Custom fields
*
*/
add_action( 'load-post.php', 'imwb_interest_meta_boxes_setup' );
add_action( 'load-post-new.php', 'imwb_interest_meta_boxes_setup' );
function imwb_interest_meta_boxes_setup() {
/* Add meta boxes on the 'add_meta_boxes' hook. */
add_action( 'add_meta_boxes', 'imwb_interest_add_post_meta_boxes' );
add_action( 'save_post', 'imwb_interest_save_post_links_meta', 10, 2 );
}
function imwb_interest_add_post_meta_boxes() {
add_meta_box(
'imwb_interest-post-links', // Unique ID
esc_html__( 'Post From Links', 'imwb_interest' ), // Title
'imwb_interest_post_links_meta_box', // Callback function
'post', // Admin page (or post type)
'side', // Context
'default' // Priority
);
add_meta_box(
'imwb_interest-post-links', // Unique ID
esc_html__( 'Post From Links', 'imwb_interest' ), // Title
'imwb_interest_post_links_meta_box', // Callback function
'page', // Admin page (or post type)
'side', // Context
'default' // Priority
);
}
function imwb_interest_post_links_meta_box( $object, $box ) { ?>
<?php wp_nonce_field( basename( __FILE__ ), 'imwb_interest-post-links_nonce' ); ?>
<p>
<label for="imwb_interest_post_links-url">Link URL:</label>
<input class="widefat" type="text" name="imwb_interest_post_links-url" id="imwb_interest_post_links-url" value="<?php echo esc_attr( get_post_meta( $object->ID, 'imwb_interest_post_link_url', true ) ); ?>" size="30" />
<label for="imwb_interest_post_links-text">Link Text:</label>
<input class="widefat" type="text" name="imwb_interest_post_links-text" id="imwb_interest_post_links-text" value="<?php echo esc_attr( get_post_meta( $object->ID, 'imwb_interest_post_link_text', true ) ); ?>" size="30" />
</p>
<?php }
function imwb_interest_save_post_links_meta( $post_id, $post ) {
// verify if this is an auto save routine.
// If it is our form has not been submitted, so we dont want to do anything
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
/* Verify the nonce before proceeding. */
if ( !isset( $_POST['imwb_interest-post-links_nonce'] ) || !wp_verify_nonce( $_POST['imwb_interest-post-links_nonce'], basename( __FILE__ ) ) )
return $post_id;
// Check permissions
if ( 'page' == $_POST['post_type'] )
{
if ( !current_user_can( 'edit_page', $post_id ) )
return;
}
else
{
if ( !current_user_can( 'edit_post', $post_id ) )
return;
}
/* Get the post type object. */
$post_type = get_post_type_object( $post->post_type );
/* Get the posted data and sanitize it for use as an HTML class. */
$new_meta_value = ( isset( $_POST['imwb_interest_post_links-url'] ) ? $_POST['imwb_interest_post_links-url'] : '' );
/* Get the meta key. */
$meta_key = 'imwb_interest_post_link_url';
/* Get the meta value of the custom field key. */
$meta_value = get_post_meta( $post_id, $meta_key, true );
/* If a new meta value was added and there was no previous value, add it. */
if ( $new_meta_value && '' == $meta_value )
add_post_meta( $post_id, $meta_key, $new_meta_value, true );
/* If the new meta value does not match the old value, update it. */
elseif ( $new_meta_value && $new_meta_value != $meta_value )
update_post_meta( $post_id, $meta_key, $new_meta_value );
/* If there is no new meta value but an old value exists, delete it. */
elseif ( '' == $new_meta_value && $meta_value )
delete_post_meta( $post_id, $meta_key, $meta_value );
/* Get the posted data and sanitize it for use as an HTML class. */
$new_meta_value = ( isset( $_POST['imwb_interest_post_links-text'] ) ? $_POST['imwb_interest_post_links-text'] : '' );
/* Get the meta key. */
$meta_key = 'imwb_interest_post_link_text';
/* Get the meta value of the custom field key. */
$meta_value = get_post_meta( $post_id, $meta_key, true );
/* If a new meta value was added and there was no previous value, add it. */
if ( $new_meta_value && '' == $meta_value )
add_post_meta( $post_id, $meta_key, $new_meta_value, true );
/* If the new meta value does not match the old value, update it. */
elseif ( $new_meta_value && $new_meta_value != $meta_value )
update_post_meta( $post_id, $meta_key, $new_meta_value );
/* If there is no new meta value but an old value exists, delete it. */
elseif ( '' == $new_meta_value && $meta_value )
delete_post_meta( $post_id, $meta_key, $meta_value );
}
// checks is WP is at least a certain version (makes sure it has sufficient comparison decimals
function imwb_interest_is_wp_version( $is_ver ) {
$wp_ver = explode( '.', get_bloginfo( 'version' ) );
$is_ver = explode( '.', $is_ver );
for( $i=0; $i<=count( $is_ver ); $i++ )
if( !isset( $wp_ver[$i] ) ) array_push( $wp_ver, 0 );
foreach( $is_ver as $i => $is_val )
if( $wp_ver[$i] < $is_val ) return false;
return true;
}
function imwb_interest_custom_background_callback() {
/* Get the background image. */
$image = get_background_image();
/* If there's an image, just call the normal WordPress callback. We won't do anything here. */
if ( !empty( $image ) ) {
_custom_background_cb();
return;
}
/* Get the background color. */
$color = get_background_color();
/* If no background color, return. */
if ( empty( $color ) ) {
echo '<style type="text/css">body { background: url('.get_template_directory_uri() . '/images/background.png); }</style>';
}
/* Use 'background' instead of 'background-color'. */
$style = "background: #{$color};";
?>
<style type="text/css">body { <?php echo trim( $style ); ?> }</style>
<?php
}
/**
* Styles the header image displayed on the Appearance > Header admin panel.
*
*/
function imwb_interest_admin_header_style() {
?>
<style type="text/css">
.appearance_page_custom-header #headimg {
border: none;
font-size: 10px;
text-align: center;
top: 2px;
min-height: 40px;
}
#headimg h1,
#desc {
font-family: "helvetica neue",arial,sans-serif;
}
#headimg h1 {
font-size: 1.75em; margin: 2px 0 0 0;
}
#headimg h1 a {
text-decoration: none;
}
#desc {
font-size: 1.15em; margin: 0;color: #8C7E7E;
}
<?php
// If the user has set a custom color for the text use that
if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
?>
#site-title a,
#site-description {
color: #<?php echo get_header_textcolor(); ?>;
}
<?php endif; ?>
#headimg img {
max-width: 520px;
height: auto;
width: 100%;
}
</style>
<?php
}
// build ogp meta
function imwb_interest_open_graph_head() {
global $post;
echo "\n<!-- Open Graph protocol meta data -->\n";
// Which URL we need
if (is_home() || is_front_page() || is_search() || is_category() )
$ogp_url = get_bloginfo( 'url' );
else
$ogp_url = 'http' . (is_ssl() ? 's' : '') . "://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
echo '<meta property="og:url" content="' . esc_url($ogp_url) . '">' . "\n";
// Site Title
echo '<meta property="og:title" content="' . esc_attr( wp_title("|", false, "right").get_bloginfo( 'name' ) ) . '">' . "\n";
// Site Name
echo '<meta property="og:site_name" content="' . get_bloginfo( 'name' ) . '">' . "\n";
// Descriptions
if ( is_single() || is_page() ) {
if ( has_excerpt( $post->ID ) )
$ogp_description = strip_tags( get_the_excerpt( $post->ID ) );
else
$ogp_description = str_replace( "\r\n", ' ' , substr( strip_tags( strip_shortcodes( $post->post_content ) ), 0, 160 ) );
}
else
$ogp_description = get_bloginfo( 'description' );
echo '<meta property="og:description" content="' . esc_attr( $ogp_description ). '">' . "\n";
// OG Type
if ( is_single() || is_page()) {
$ogp_type = 'article';
} else {
$ogp_type = 'website';
}
echo '<meta property="og:type" content="' . esc_attr($ogp_type) . '">' . "\n";
// Find/output any images for use in the OGP tags
$wpfbogp_images = array();
// Image details
if ( is_single() || is_page()) {
$postImage = imwb_interest_get_the_image(Array('image_class' => 'tack_entry_img', "link_to_post" => false, 'echo' => false, 'size' => '', 'use_image_scan_link' => true));
preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', $postImage, $matches );
$postImageSrc = $matches[1][0];
echo '<meta property="og:image" content="' . esc_url($postImageSrc) . '">' . "\n";
}
else
// No images were outputted because they have no default image (at the very least)
echo "<!-- Could not find an image! -->\n";
// Locale
echo '<meta property="og:locale" content="' . strtolower( esc_attr( get_locale() ) ) . '">' . "\n";
echo "<!-- Open Graph protocol meta data -->\n";
}
// Check to see if post is a Covert Video Content generated one and has video attached.
function is_cvc_post($post_id) {
/* Get the video URL. */
$video_url = get_post_meta( $post_id, 'imwb_videopress_post_video_url', true );
if(empty($video_url))
return false;
return true;
}
/*
* RSS Feed functions
*/
add_action('rss2_ns', 'imwb_interest_yahoo_media_tag');
add_action('rss_item', 'imwb_interest_feed_item');
add_action('rss2_item', 'imwb_interest_feed_item');
add_filter('the_excerpt_rss', 'imwb_interest_feed_content');
add_filter('the_content_feed', 'imwb_interest_feed_content');
function imwb_interest_yahoo_media_tag() {
echo 'xmlns:media="http://search.yahoo.com/mrss/"';
}
function imwb_interest_feed_item($content) {
global $post;
$postImage = imwb_interest_get_the_image(Array('image_class' => 'tack_entry_img', "link_to_post" => false, 'echo' => false, 'size' => '', 'use_image_scan_link' => true));
preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', $postImage, $matches );
$image_url = $matches[1][0];
if (!empty($image_url)) {
echo '<enclosure url="' . $image_url . '" type="image/jpg" />';
echo '<media:content url="'.$image_url.'" width="200" height="140" medium="image" type="'.image_type_to_mime_type($type).'" />';
}
}
function imwb_interest_feed_content($content) {
global $post;
$postImage = imwb_interest_get_the_image(Array('image_class' => 'tack_entry_img', "link_to_post" => false, 'echo' => false, 'size' => '', 'use_image_scan_link' => true));
preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', $postImage, $matches );
$image_url = $matches[1][0];
if(empty($image_url))
return $content;
$img = sprintf('<img src="%s" width="200px" height="140px" style="float:left; margin-right: 10px;">', $image_url);
$content = '' . $img . '' . $content;
return $content;
}
?>