Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Plugins & Atahualpa (http://forum.bytesforall.com/forumdisplay.php?f=16)
-   -   Vote the Post Plugin (http://forum.bytesforall.com/showthread.php?t=2100)

janey73 Jun 18, 2009 06:54 PM

Vote the Post Plugin
 
I just posted this under my other userid, which wasn't connected to Paypal. So I created a new userid and was able to make a donation.

I'm using Theme Atahualpa 333 (really wonderful! Thank you.) and have installed the Vote the Post plugin.

It works beautifully on single post pages, showing the rating stars and a message.
http://innovation.marin.org/blog/c/?p=83

However, on the multiple posting pages, it loses the stars and the text, skips a line, and then places the question mark at the beginning of the post.

http://innovation.marin.org/blog/c/?cat=4

I tested it on a different theme and it worked fine, but I'd like to use it in Atahualpa 333. Any suggestions?

Many thanks.

juggledad Jun 19, 2009 03:50 AM

You have 'Only Excerpts' set in the option ATO->Paost or Excerpts->Posts or excerpts on CATEGORY pages? - change this to 'Full Posts' and the start sill show up.

janey73 Jun 19, 2009 12:15 PM

Thanks JuggleDad,

For overview reasons, we are needing the posts to be excerpts on the category pages. Then the user can drill down deeper if he/she wants to see more information.

I looked at the code being generated on the excerpt category pages, and it appears that Atahaulpa is putting <p> in various places just past the "Rating 3.00 out of 5" so that is cuts off the stars and puts the [?] on a new line. Any suggestions on how to get it to handle the same way on the excerpt category pages as on the full-post pages?

Much appreciated.

BTW, I just tried to donate to you in Firefox 3.0.11. there is no active button for:
" click this button >> donating to juggledad "

juggledad Jun 20, 2009 09:03 AM

The problem here is that when you choose to display an excerpt, Atahualpa calls the WordPress routine to provide the extract. Eventually you get to the function wp_trim_excerpt.

This routing takes the post, and calls the PHP function strip_tags() which, as you can guess from it's name, strips all HTMLT, XML, and PHP tags from a string.

Now the 'stars' in the Vote-the-post plugin are actually a clever <span> and set of <div.'s that the CSS ends up substituting a gif of a star for. BUT as a reault of the strip_tags call, this <span> and the <div>'s are removed, so there is no code for the CSS to cause stars to show up.

The other theme I tried this on, did infact show the stars, but it was because when displaying the categories, it displayed the entire post, not the excerpt.

Flynn Jun 20, 2009 08:54 PM

Post updated 6-24-2009:

You can stop Wordpress from stripping certain tags from excerpts by adding this:

function bfa_wp_trim_excerpt($text) { // Fakes an excerpt if needed
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text, '<p><span><div>');
$excerpt_length = 55;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '<p>Continue reading <a href="'. get_permalink() . '">'. the_title('','',FALSE) . '</a></p>');
$text = implode(' ', $words);
}
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'bfa_wp_trim_excerpt');


at the bottom of Atahualpa's functions.php, before the last closing ?> tag.


Customize the code:
  • <p><span><div> = tags to be "excluded from being removed". The tags you include here will be left untouched. Only the opening tag is required, i.e. <span> to hold back Wordpress from removing <span class="bla"> and </span> inside excerpts
  • 55 = Excerpt length (word count)
  • <p>Continue reading <a href="'. get_permalink() . '">'. the_title('','',FALSE) . '</a></p> = Replaces the default [...] ellipsis at the end of excerpts. To keep using the default [...] replace the green text in the code with [...]

janey73 Jun 22, 2009 05:50 PM

Thanks for the explanation, JuggleDad. That helps!

And thanks for the code, Flynn. I put it in, but it didn't seem to make a difference. It still stripped it out. http://innovation.marin.org/blog/c/?cat=3

Here's the bottom part of the function.php code with the change put in.

// new comment template for WP 2.7+, legacy template for old WP 2.6 and older
if (!function_exists('paged_comments')) {
include_once (TEMPLATEPATH . '/functions/bfa_custom_comments.php');
function legacy_comments($file) {
if(!function_exists('wp_list_comments'))
$file = TEMPLATEPATH . '/legacy.comments.php';

return $file;
}
add_filter('comments_template', 'legacy_comments');
}
remove_filter('the_excerpt', 'wptexturize');
?>

If this is too big of a pain, don't worry about it. thanks so much for your help.

janey73 Jun 23, 2009 12:04 PM

JuggleDad, here is another bug you might want to check out. :-)

I was able to donate to you through Safari but not through Firefox (it didn't have a button or a live link). I am working with the latest versions of Safari, Firefox and OS X.

Flynn Jun 24, 2009 08:43 AM

Quote:

Originally Posted by janey73 (Post 8967)
And thanks for the code, Flynn. I put it in, but it didn't seem to make a difference.

Sorry for that, I updated the post. Please try again.

janey73 Jun 24, 2009 04:28 PM

I love love love the "continued reading" portion that was added above. JUST what I was wanting. Thank you!

For some reason, the <span> tag is having <p> tags generated around it, so that the stars are on one line and the rest is on the next line, with the line spacing being funky.

Here is the page:

http://innovation.marin.org/?cat=5

<div class="rating-info">Rating 4.50 out of 5</div>
<p> <span class="rating4">
<div class="star1" rel="1"></div>
<div class="star2" rel="2"></div>
<div class="star3" rel="3"></div>
<div class="star4" rel="4"></div>
<div class="star5" rel="5"></div>
<p></span></p>
<div class="status-info">Thank you for voting!</div>

juggledad Jun 25, 2009 09:01 AM

try changing the '$excerpt_length = 55;' to '$excerpt_length = 9999;'

Flynn Jun 25, 2009 09:47 AM

For the missing link add <a> to the non-removable tags

$text = strip_tags($text, '<p><span><div><a>');

As for the <p>'s, not sure where they are coming from, are you adding some code for the Vote Post plugin into each posts. perhaps the <P> get created at that point

You could add this to the above code

$text = strip_tags($text, '<p><span><div>');
$text = str_ireplace("<p></span></p>", "</span>", $text);
$text = preg_replace("/
out of 5<\/div>\n<p>/i", "out of 5</div>", $text);
$excerpt_length =
55;



Or consider putting the whole Vote thing into the Byline at Theme Options -> Post/Page Info Items. Does the plugin provide a template tag, something like <?php vote_the_post(); ?> ? If so, you could put that into the Byline as you can use PHP there. Then you wouldn't have to deal with Excerpts at all. The Byline can be several lines, also with DIV's to create a horizontal line like the one you have now. Example:

various post info items here
<div style="border-top: 1px dotted #ccc; margin-top: 10px; padding-top: 10px">
<?php vote_the_post(); ?></div>

juggledad Jun 26, 2009 08:08 AM

The line
$text = preg_replace("/out of 5</div>\n<p>/i", "out of 5</div>", $text);
causes $text to come back null. If you comment it out, the $text coming out of this routine looks great, BUT...

something is adding the extra <p> after this routine finishes (I put an 'echo $text;' just before the return to see)

This extra <p> is messing with the Vote-the-Post's java script. I may have time to look deeper later, but I have to leave now.

janey73 Jun 26, 2009 03:52 PM

Flynn and JuggleDad,

Thanks for your diligence in pursuing a way to make this work, and get rid of the pesky <p>'s.

As it turns out, this problem is bypassed with another creative solution you provided for me. I didn't really want the excerpt information in the category pages and you gave me a great solution.

http://forum.bytesforall.com/showthread.php?t=2171

And with that, the Vote the Post section is eliminated on the category pages, which is fine. I only want people to vote from the post page. So all is well.

Again, many thanks!!

Flynn Jun 26, 2009 04:21 PM

Quote:

Originally Posted by juggledad (Post 9196)
The line
$text = preg_replace("/out of 5</div>\n<p>/i", "out of 5</div>", $text);
causes $text to come back null.


Probably should have escaped the one slash inside the string, I updated the code above

$text = preg_replace("/out of 5<\/div>\n<p>/i", "out of 5</div>", $text);


All times are GMT -6. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.