Vladimir’s WordPress Forum


 
Current User: Guest
Search Forums:


 






Wildcard Usage:
*    matches any number of characters
%    matches exactly one character

popup ok locally but blank online

Add a New Topic Reply to Post
UserPost

14:05
21 May, 2011


Herb

Guest

Vladimir, thank you for a great plugin!

I am getting a "No post found." response on my XAMMP local setup, as expected. However, using the same code on a shared host online the popups fade in, but they are blank for every link in the blogroll. I've checked that at least some of the links' RSS are active, so I'm confused about that. I'm following your Plugin Development book and am using the code up to pg.77 – the last step before introducing the advanced Ajax call. It should work at this point, but the popup is still blank at this site: usethatherb.com

How long would you say the RSS should take to be parsed? On the order of minutes?

Thanks for any help!

12:34
24 May, 2011


Vladimir

Admin

posts 707

Hi Herb

RSS should be pretty much instant, and it's hard to say what is causing the problem with this available information.

14:16
24 May, 2011


Herb

Guest

My basic question is, how can the code work on my local machine and not work on a different server? Right away, it makes one think the paths are not right. WordPress is installed at the root of usethatherb.com, not a subdirectory.

I verified that the .css file path is correct by altering a value and observing the change on screen. The .js path is ok as I could alter the location of the popup box that appears when hovering over a link in the blogroll. Since the popup box is appearing, there must be some error in getting the feeds or processing them. It's curious why there isn't a "No post found" message in the popup box.

Changing "fetch_rss" (it's deprecated) to "fetch_feed" in the 2 php files had no observable effect.

I can't see what's gone wrong to produce a blank popup box. Can you? Any help is appreciated.

Of course, a little code could help to find the problem. Here it is:

………..

Content of wp-live-blogroll.php –

//define plugin path
$wp_live_blogroll_plugin_url = trailingslashit(WP_PLUGIN_URL.'/'.dirname(plugin_basename(__FILE__)));

//include file that contains functions for parsing RSS feeds
require_once(ABSPATH . WPINC . '/rss.php');

//filter hook for changing display of bookmarks or blogroll
//add_filter('get_bookmarks', 'WPLiveRoll_GetBookmarksFilter');
//above line not used because javascript now included at end of this file

//filter function to get bookmarks
function WPLiveRoll_GetBookmarksFilter($items)
{
//do nothing if in the admin menu
if (is_admin())
{
return $items;
}

//parse all blogroll items
foreach($items as $item)
{
//check if the link is public
if ($item->link_visible=='Y')
{
$link_url=trailingslashit($item->link_url);

//simple feed guessing
if (strstr($link_url,"blogspot"))
{
//blogspot blog
$feed_url=$link_url."feeds/posts/default/";
}
elseif (strstr($link_url,"typepad"))
{
//typepad blog
$feed_url=$link_url."atom.xml";
}
else
{
//own domain or wordpress blog
$feed_url=$link_url."feed/";
}

// use WordPress to fetch the RSS feed, $feedfile should be array of posts
$feedfile = fetch_feed($feed_url);

//check if we got a valid response
if (is_array($feedfile->items) && !empty($feedfile->items))
{
//this is the most recent post
$feeditem=$feedfile->items[0];

//replace blogroll link name and url with post link and title
$item->link_url=$feeditem['link'];
$item->link_name=$feeditem['title'];
}
}
}

//return the items
return $items;
}

//embed blogroll into .livelinks class
add_filter('wp_list_bookmarks', 'WPLiveRoll_ListBookmarksFilter');

function WPLiveRoll_ListBookmarksFilter($content)
{
return '<span class="livelinks">'.$content.'</span>';
}

//load javascript with page
add_action('wp_print_scripts', 'WPLiveRoll_ScriptsAction');

function WPLiveRoll_ScriptsAction()
{
global $wp_live_blogroll_plugin_url;

if (!is_admin())
{
wp_enqueue_script('jquery');
wp_enqueue_script('wp_live_roll_script', $wp_live_blogroll_plugin_url.'/wp-live-blogroll.js', array('jquery'));

// pass parameters to JavaScript
wp_localize_script('wp_live_roll_script', 'LiverollSettings', array('plugin_url' => $wp_live_blogroll_plugin_url));
}
}

//load CSS style with wp_head action filter
add_action('wp_head', 'WPLiveRoll_HeadAction');

function WPLiveRoll_HeadAction()
{
global $wp_live_blogroll_plugin_url;
echo '<link rel="stylesheet" href="'.$wp_live_blogroll_plugin_url.'/wp-live-blogroll.css" type="text/css" />';
}
?>

Content of wp-live-blogroll.js –

/*Javascript file for use with live-blogroll WordPress plugin*/

//setup everything when document is ready
jQuery(document).ready(function($)
{
//connect to hover event of <a> in .livelinks
$('.livelinks a').hover(function(e)
{

//set the text we want to display
//this.tip="Recent posts from " + this.href + " will be displayed here…";

//create a new div and append it to the link
$(this).append('<div id="lb_popup"></div>');

//get coordinates
var mouseX = e.pageX || (e.clientX ? e.clientX + document.body.scrollLeft: 0);
var mouseY = e.pageY || (e.clientY ? e.clientY + document.body.scrollTop: 0);

//move the top left corner left and down
mouseX -= 400;
mouseY += 5;

//position the div
$('#lb_popup').css({
left: mouseX + "px",
top: mouseY + "px"
});

// use load() method to make an Ajax request
$('#lb_popup').load(LiverollSettings.plugin_url + '/wp-live-blogroll-ajax.php?link_url=' + this.href);

//show it using a fadeIn function
$('#lb_popup').fadeIn(300);
},

//when the mouse hovers out
function()
{
//remove it
$(this).children().remove();
});
});

Content of wp-live-blogroll-ajax.php –

<?php
/* Ajax file for use with live blogroll wordpress plugin */

require_once("../../../wp-config.php");
require_once(ABSPATH . WPINC . '/rss.php');

//fetch information from GET method
$link_url = $_GET['link_url'];

//function call to do something with URL parameter
WPLiveRoll_HandleAjax($link_url);

//function to get excerpt of text as the first 20 words of post
function WPLiveRoll_GetExcerpt($text, $length = 20)
{
$text = strip_tags($text);
$words = explode(' ', $text, $length + 1);
if (count($words) > $length)
{
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
}
return $text;
}

//function to parse the RSS feed and return results in formatted HTML
function WPLiveRoll_HandleAjax($link_url)
{
//we will return final HTML code in this variable
$result="";

//number of posts we are showing
$number = 5;
$link_url=trailingslashit($link_url);

//pick the RSS feed based on the site
if (strstr($link_url, "blogspot"))
{
//blogspot blog
$feed_url=$link_url."feeds/posts/default/";
}
else if (strstr($link_url, "typepad"))
{
//typepad blog
$feed_url=$link_url."atom.xml";
}
else
{
//own domain with wordpress blog
$feed_url=$link_url."feed/";
}

//use WordPress to fetch the RSS feed
$feedfile = fetch_feed($feed_url);

//check if we got valid response
if (is_array($feedfile->items) && !empty($feedfile->items))
{
//slice the number of items we need
$feedfile->items = array_slice($feedfile->items, 0, $number);

//create HTML from posts
$result.= '<ul>';
foreach($feedfile->items as $item)
{
// fetch the information
$item_title = $item['title'];
$item_link = $item['link'];
$item_description = WPLiveRoll_GetExcerpt($item['description']);

//form result
$result.= '<li><a class="lb_link" href="'.$item_link.'">'.$item_title.'</a><p class="lb_desc">'.$item_description.'</p></li>';
}
$result.= '</ul>';
}
else
{
// in case we were unable to parse the feed
$result.= "No posts available.";
}
//return the HTML code
die($result);
}
?>

……..Confused

Reply to Post

Reply to Topic:
popup ok locally but blank online

Guest Name (Required):

Guest Email (Required):

HTML Editor
Smileys
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell
Post New Reply

Guest URL (required)

Math Required!
What is the sum of:
12 + 9