• So I have this website that reviews various japanese animation shows. I’ve been long wanting a way for the site’s various writers to be able to add review scores on their own, instead of having to hard code a table or use an image.

    I found an old plugin called review box, which best suited my needs (The other review box system use either stars, or are customer rating based)

    The problem is that the “review box” plugin only has one overall score bar, and a pros and cons thing. I wanted to add seperate scorebars for “Story”, “characters” “art” “animation” and “sound”, as well as add a grade option in the table.

    From what I can see, I did the right coding, but when I uploaded the files and reactivated the plugin wordpress said that “there was one unexpected output” and then whenever I used any script in wordpress whether it be simplying posting a comment, or editing a post, the page would end up blank.

    Here’s the original code;

    <?php
    
    function addCSS() {
    
    	echo '<link type="text/css" rel="stylesheet" href="' . plugins_url ( plugin_basename ( dirname ( __FILE__ ) ) ) .'/review-box.css" />';
    
    }
    
    function review_prettify($atts) {
    
    	extract( shortcode_atts( array(
    
    		'title' => 'Review',
    
    		'title_url' => '',
    
    		'score' => '100',
    
    		'pros' => '<em>None</em>',
    
    		'cons' => '<em>None</em>',
    
    		'verdict' => '',
    
    		), $atts ));
    
    	if ( $score > 100 ) {
    
    		$score = 100;
    
    	}
    
    	elseif ( $score < 0 ) {
    
    		$score = 0;
    
    	}
    
    	$width = 450;
    
    	/*
    
    	The width of the review box is controlled programattically this time, instead of via CSS. This should produce a better result. If you want to change this value, set it above. THIS MUST BE IN PIXEL (PX) VALUES.
    
    In newer versions, this should be an admin page option
    
    */
    
    	#title system.
    
    	if ( $title == 'none' ) {
    
    		$title_bar = '';
    
    	} else {
    
    		$title_bar = '<h2>'. do_shortcode($title) .'</h2>';
    
    	}
    
    	#Verdict box
    
    	if ( $verdict == null ) {
    
    		$verdict_box = '';
    
    	} else {
    
    		$verdict_box = '<tr><th>Verdict</th><td>'. $verdict .'</td></tr>';
    
    	}
    
    	$result = '<a name="review"></a><div class="review">
    
    		'. $title_bar .'
    
    		<div class="mainbox">
    
    			<div class="procons">
    
    	<table>
    
    			<tr><th>Pros</th><th>Cons</th></tr>
    
    			<tr><td>' . do_shortcode($pros) . '</td><td>' . do_shortcode($cons) . '</td></tr>
    
    			' . $verdict_box . '
    
    			</table>
    
    			</div>
    
                            <table class="review_grid">
    
                                    <tr><td class="review_label">Rating</td><td><div class="rating_bg" style="width: ' . $width . 'px"><span class="rating_bar" style="width: ' . $width * ($score/100) . 'px;"><span class="rating_bar_content">' . $score . '%</span></span></div></td></tr>
    
                            </table>
    
    		</div></div>';
    
    	return $result;
    
    }
    
    add_action('wp_head', 'addCSS');
    
    add_shortcode('review','review_prettify');
    
    ?>

    and here’s my customized code:

    <?php
    
    function addCSS() {
    
    	echo '<link type="text/css" rel="stylesheet" href="' . plugins_url ( plugin_basename ( dirname ( __FILE__ ) ) ) .'/review-box.css" />';
    
    }
    
    function review_prettify($atts) {
    
    	extract( shortcode_atts( array(
    
    		'title' => 'Review',
    
    		'title_url' => '',
    
    		'story' => '100',
    
    		'characters' => '100',
    
    		'art' => '100',
    
    		'animation' => '100',
    
    		'sound' => '100',
    
    		'score' => '100',
    
    		'pros' => '<em>None</em>',
    
    		'cons' => '<em>None</em>',
    
    		'grade' => '',
    
    		'verdict' => '',
    
    		), $atts ));
    
    	if ( $score > 100 ) {
    
    		$score = 100;
    		$grade = 'A+';
    
    	}
    
    	elseif ( $score > 94 && $score < 101 ) {
    
    		$grade = 'A+';
    
    	}
    
    	elseif ( $score > 89 && $score < 95 ) {
    
    		$grade = 'A';
    
    	}
    
    	elseif ( $score > 84 && $score < 90 ) {
    
    		$grade = 'B+';
    
    	}
    
    	elseif ( $score > 79 && $score < 85 ) {
    
    		$grade = 'B';
    
    	}
    
    	elseif ( $score > 74 && $score < 80 ) {
    
    		$grade = 'C+';
    
    	}
    
    	elseif ( $score > 69 && $score < 75 ) {
    
    		$grade = 'C';
    
    	}
    
    	elseif ( $score > 59 && $score < 70 ) {
    
    		$grade = 'D';
    
    	}
    
    	elseif ( $score > 0 && $score < 60 ) {
    
    		$grade = 'F';
    
    	}
    
    	elseif ( $score < 0 ) {
    
    		$score = 0;
    		$grade = 'U';
    
    	}
    
    	$width = 450;
    
    	/*
    
    	The width of the review box is controlled programattically this time, instead of via CSS. This should produce a better result. If you want to change this value, set it above. THIS MUST BE IN PIXEL (PX) VALUES.
    
    In newer versions, this should be an admin page option
    
    */
    
    	#title system.
    
    	if ( $title == 'none' ) {
    
    		$title_bar = '';
    
    	} else {
    
    		$title_bar = '<h2>'. do_shortcode($title) .'</h2>';
    
    	}
    
    	#Verdict box
    
    	if ( $verdict == null ) {
    
    		$verdict_box = '';
    
    	} else {
    
    		$verdict_box = '<tr><th>Verdict</th><td>'. $verdict .'</td></tr>';
    
    	}
    
    	$result = '<a name="review"></a><div class="review">
    
    		'. $title_bar .'
    
    		<div class="mainbox">
    
    			<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
    
        <td align="center" width="15%" class="grade">' . $grade . '</td>
    
        <td width="85%">
    
        <table class="review_grid">
    
                                    <tr><td class="review_label">Story</td><td><div class="rating_bg" style="width: ' . $width . 'px"><span class="rating_bar" style="width: ' . $width * ($story/100) . 'px;"><span class="rating_bar_content">' . $story . '%</span></span></div></td></tr>
    
              </table>
    
              <table class="review_grid">
    
                                    <tr><td class="review_label">Characters</td><td><div class="rating_bg" style="width: ' . $width . 'px"><span class="rating_bar" style="width: ' . $width * ($characters/100) . 'px;"><span class="rating_bar_content">' . $characters . '%</span></span></div></td></tr>
    
              </table>
    
              <table class="review_grid">
    
                                    <tr><td class="review_label">Art</td><td><div class="rating_bg" style="width: ' . $width . 'px"><span class="rating_bar" style="width: ' . $width * ($art/100) . 'px;"><span class="rating_bar_content">' . $art . '%</span></span></div></td></tr>
    
              </table>
    
              <table class="review_grid">
    
                                    <tr><td class="review_label">Animation</td><td><div class="rating_bg" style="width: ' . $width . 'px"><span class="rating_bar" style="width: ' . $width * ($animation/100) . 'px;"><span class="rating_bar_content">' . $animation . '%</span></span></div></td></tr>
    
              </table>
    
              <table class="review_grid">
    
                                    <tr><td class="review_label">Sound</td><td><div class="rating_bg" style="width: ' . $width . 'px"><span class="rating_bar" style="width: ' . $width * ($sound/100) . 'px;"><span class="rating_bar_content">' . $sound . '%</span></span></div></td></tr>
    
              </table>
    
              <table class="review_grid">
    
                                    <tr><td class="review_label">Overall</td><td><div class="rating_bg" style="width: ' . $width . 'px"><span class="rating_bar" style="width: ' . $width * ($score/100) . 'px;"><span class="rating_bar_content">' . $score . '%</span></span></div></td></tr>
    
              </table>
        </td>
    
      </tr>
    </table>
    
              <div class="procons">
    
    	<table>
    
    			<tr><th>Pros</th><th>Cons</th></tr>
    
    			<tr><td>' . do_shortcode($pros) . '</td><td>' . do_shortcode($cons) . '</td></tr>
    
    			' . $verdict_box . '
    
    			</table>
    
    			</div>
    
    		</div></div>';
    
    	return $result;
    
    }
    
    add_action('wp_head', 'addCSS');
    
    add_shortcode('review','review_prettify');
    
    ?>

    I’d really appreciate if someone can tell me what I’m doing wrong!

The topic ‘Review-Box Plugin Customizing not working’ is closed to new replies.