I used to apply this php preg_match:
<?php preg_match( '!<div class="thumblock ">(.*)</div>!si' , wp_gdsr_render_article_thumbs(0, false, "", 0, "", false) , $n );
$thumbs_number = strip_tags( $n[1] ); ?>
to extract the number (in this case 2) between the .rating-result
span tags (only):
<div class="thumblock">
<span class="rating-result">2</span>
<div class="ratingtext">
<div id="gdsr_thumb_124_a_up" class="gdt-size-20 gdthumb gdup">
<div class="gdt-starrating"></div>
</div>
<div id="gdsr_thumb_124_a_dw" class="gdt-size-20 gdthumb gddw">
<div class="gdt-starrating"></div>
</div>
</div>
<div class="raterclear"></div>
</div>
Now, I modified the output (I added an extra div which surrounds the .rating-result
span tags):
<div class="thumblock">
<div id="gdsr_thumb_text_137_a" class="gdt-size-20 voted inactive gdthumbtext">
<span class="rating-result">2</span>
</div>
<div class="ratingtext">
<div id="gdsr_thumb_137_a_up" class="gdt-size-20 gdthumb gdup">
<div class="gdt-starrating"></div>
</div>
<div id="gdsr_thumb_137_a_dw" class="gdt-size-20 gdthumb gddw">
<div class="gdt-starrating"></div>
</div>
</div>
<div class="raterclear"></div>
</div>
Doing var_dump
to the first $thumbs_number
outputs: string(2) "+1"
Doing var_dump
to the second $thumbs_number
outputs: string(2) "+1"
But the function where I use the variable $thumbs_number
doesn't work any more (get_rating_class();
is placed in a div's class to add a class according to the number of thumbs):
function get_rating_class($thumbs_number) {
if ($thumbs_number < 0) return ' bad';
if ($thumbs_number < 2) return ' average';
if ($thumbs_number < 4) return ' good';
return ' excellent';
}
function rating_class($thumbs_number) {
echo get_rating_class($thumbs_number);
}
Which is absolutely the same, but it seems like
How should I modified the preg_match
in order to make it extract that number as it did before?