Panowie pytanie dotyczy shortcode. Mam taki skrypt jak widać przez echo mogę wywoływać tę funkcję i zmienić parametry name, procenty itp. Chciał bym móc to zmieniać przy wykorzystaniu shortcode w wordpressie. Ale nie wiem jak. Czy ktoś pomoże? Dodam iż jestem początkującym programistom więc łopatologicznie proszę (IMG:
style_emoticons/default/biggrin.gif)
function pullRating($name,$show5 = true, $showPerc = false, $showVotes = true, $static = NULL){
// Check if they have already voted...
$text = '';
$sel = mysql_query("SELECT id FROM ratings WHERE IP = '".$_SERVER['REMOTE_ADDR']."' AND rating_id = '$name'");
if($show5 || $showPerc || $showVotes){
$text .= '<div class="rated_text">';
}
if($show5){
$text .= 'Rated <span id="outOfFive_'.$name.'" class="out5Class">'.outOfFive($name).'</span>/5';
}
if($showPerc){
$text .= ' (<span id="percentage_'.$name.'" class="percentClass">'.getRating($name).'</span>)';
}
if($showVotes){
$text .= ' (<span id="showvotes_'.$name.'" class="votesClass">'.getVotes($name).'</span>)';
}
if($show5 || $showPerc || $showVotes){
$text .= '</div>';
}
return $text.'
<ul class="star-rating2" id="rater_'.$name.'">
<li class="current-rating" style="width:'.getRating($name).';" id="ul_'.$name.'"></li>
<li><a onclick="return false;" href="#" title="1 star out of 5" class="one-star" >1</a></li>
<li><a onclick="return false;" href="#" title="2 stars out of 5" class="two-stars">2</a></li>
<li><a onclick="return false;" href="#" title="3 stars out of 5" class="three-stars">3</a></li>
<li><a onclick="return false;" href="#" title="4 stars out of 5" class="four-stars">4</a></li>
<li><a onclick="return false;" href="#" title="5 stars out of 5" class="five-stars">5</a></li>
</ul>
<div id="loading_'.$name.'"></div>';
} else {
if($show5 || $showPerc || $showVotes){
$text .= '<div class="rated_text">';
}
if($show5){
$show5bool = 'true';
$text .= 'Rated <span id="outOfFive_'.$name.'" class="out5Class">'.outOfFive($name).'</span>/5';
} else {
$show5bool = 'false';
}
if($showPerc){
$showPercbool = 'true';
$text .= ' (<span id="percentage_'.$name.'" class="percentClass">'.getRating($name).'</span>)';
} else {
$showPercbool = 'false';
}
if($showVotes){
$showVotesbool = 'true';
$text .= ' (<span id="showvotes_'.$name.'" class="votesClass">'.getVotes($name).'</span>)';
} else {
$showVotesbool = 'false';
}
if($show5 || $showPerc || $showVotes){
$text .= '</div>';
}
return $text.'
<ul class="star-rating" id="rater_'.$name.'">
<li class="current-rating" style="width:'.getRating($name).';" id="ul_'.$name.'"></li>
<li><a onclick="rate(\'1\',\''.$name.'\','.$show5bool.','.$showPercbool.','.$showVotesbool.'); return false;" href="includes/rating_process.php?id='.$name.'&rating=1" title="1 star out of 5" class="one-star" >1</a></li>
<li><a onclick="rate(\'2\',\''.$name.'\','.$show5bool.','.$showPercbool.','.$showVotesbool.'); return false;" href="includes/rating_process.php?id='.$name.'&rating=2" title="2 stars out of 5" class="two-stars">2</a></li>
<li><a onclick="rate(\'3\',\''.$name.'\','.$show5bool.','.$showPercbool.','.$showVotesbool.'); return false;" href="includes/rating_process.php?id='.$name.'&rating=3" title="3 stars out of 5" class="three-stars">3</a></li>
<li><a onclick="rate(\'4\',\''.$name.'\','.$show5bool.','.$showPercbool.','.$showVotesbool.'); return false;" href="includes/rating_process.php?id='.$name.'&rating=4" title="4 stars out of 5" class="four-stars">4</a></li>
<li><a onclick="rate(\'5\',\''.$name.'\','.$show5bool.','.$showPercbool.','.$showVotesbool.'); return false;" href="includes/rating_process.php?id='.$name.'&rating=5" title="5 stars out of 5" class="five-stars">5</a></li>
</ul>
<div id="loading_'.$name.'"></div>';
}
}add_shortcode('rater', 'pullRating');
Ten post edytował kedzier11 25.03.2014, 15:54:04