Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Dokładka shortcode do skryptu w Wordpress
kedzier11
post
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 13.01.2014

Ostrzeżenie: (0%)
-----


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)
  1. function pullRating($name,$show5 = true, $showPerc = false, $showVotes = true, $static = NULL){
  2.  
  3. // Check if they have already voted...
  4. $text = '';
  5.  
  6. $sel = mysql_query("SELECT id FROM ratings WHERE IP = '".$_SERVER['REMOTE_ADDR']."' AND rating_id = '$name'");
  7. if(mysql_num_rows($sel) > 0 || $static == 'novote' || isset($_COOKIE['has_voted_'.$name])){
  8.  
  9.  
  10.  
  11. if($show5 || $showPerc || $showVotes){
  12.  
  13. $text .= '<div class="rated_text">';
  14.  
  15. }
  16.  
  17. if($show5){
  18. $text .= 'Rated <span id="outOfFive_'.$name.'" class="out5Class">'.outOfFive($name).'</span>/5';
  19. }
  20. if($showPerc){
  21. $text .= ' (<span id="percentage_'.$name.'" class="percentClass">'.getRating($name).'</span>)';
  22. }
  23. if($showVotes){
  24. $text .= ' (<span id="showvotes_'.$name.'" class="votesClass">'.getVotes($name).'</span>)';
  25. }
  26.  
  27. if($show5 || $showPerc || $showVotes){
  28.  
  29. $text .= '</div>';
  30.  
  31. }
  32.  
  33.  
  34. return $text.'
  35. <ul class="star-rating2" id="rater_'.$name.'">
  36. <li class="current-rating" style="width:'.getRating($name).';" id="ul_'.$name.'"></li>
  37. <li><a onclick="return false;" href="#" title="1 star out of 5" class="one-star" >1</a></li>
  38. <li><a onclick="return false;" href="#" title="2 stars out of 5" class="two-stars">2</a></li>
  39. <li><a onclick="return false;" href="#" title="3 stars out of 5" class="three-stars">3</a></li>
  40. <li><a onclick="return false;" href="#" title="4 stars out of 5" class="four-stars">4</a></li>
  41. <li><a onclick="return false;" href="#" title="5 stars out of 5" class="five-stars">5</a></li>
  42. </ul>
  43. <div id="loading_'.$name.'"></div>';
  44.  
  45.  
  46. } else {
  47.  
  48. if($show5 || $showPerc || $showVotes){
  49.  
  50. $text .= '<div class="rated_text">';
  51.  
  52. }
  53. if($show5){
  54. $show5bool = 'true';
  55. $text .= 'Rated <span id="outOfFive_'.$name.'" class="out5Class">'.outOfFive($name).'</span>/5';
  56. } else {
  57. $show5bool = 'false';
  58. }
  59. if($showPerc){
  60. $showPercbool = 'true';
  61. $text .= ' (<span id="percentage_'.$name.'" class="percentClass">'.getRating($name).'</span>)';
  62. } else {
  63. $showPercbool = 'false';
  64. }
  65. if($showVotes){
  66. $showVotesbool = 'true';
  67. $text .= ' (<span id="showvotes_'.$name.'" class="votesClass">'.getVotes($name).'</span>)';
  68. } else {
  69. $showVotesbool = 'false';
  70. }
  71.  
  72. if($show5 || $showPerc || $showVotes){
  73.  
  74. $text .= '</div>';
  75.  
  76. }
  77.  
  78. return $text.'
  79. <ul class="star-rating" id="rater_'.$name.'">
  80. <li class="current-rating" style="width:'.getRating($name).';" id="ul_'.$name.'"></li>
  81. <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>
  82. <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>
  83. <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>
  84. <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>
  85. <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>
  86. </ul>
  87. <div id="loading_'.$name.'"></div>';
  88.  
  89. }
  90. }add_shortcode('rater', 'pullRating');


Ten post edytował kedzier11 25.03.2014, 15:54:04
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 17.10.2025 - 00:37