I have function in my plugin that is:
add_filter('comment_text', 'commentimage_comment_text');
function commentimage_comment_text($comment = '') {
$options = get_option('commentimage');
$id = get_comment_ID();
$images = $options['images'];
if (!isset($images) || !is_numeric($images)) $images = 1;
$url = get_option('siteurl');
for ($i=0; $i<$images; $i++) {
if (file_exists(ABSPATH . 'wp-content/comment-image/' . $id . ($i==0?'':('-'.$i)) . '-tn.jpg')) {
$comment .= '<p><a href="' . $url . '/wp-content/comment-image/' . commentimage_find_original($id, $i) . '"><img src="' . $url . '/wp-content/comment-image/' . $id . ($i==0?'':('-'.$i)) . '-tn.jpg"/></a></p>';
}
}
return $comment;
}
Now it is showing a successful image uploaded by my viewers. I want my viewers to have the option of rating them, so for that I write in my plugin just below the above line the following code:
add_filter('comment_text', 'commentimage_comment_text2');
function commentimage_comment_text2()
{
$rtt= "<br>Rating";
return $rtt;
}
Then my pictures are gone and it shows text rating – I will change the text rating to my desired needs once I get the answer on how to overcome over writing.
It looks like you are overwriting the comment text with your
commentimage_comment_text2
filter, try this to append the ratings text:ps: you forgot the
$comment
input parameter.Here is a poor man’s skematic picture of the filter flow in WordPress 😉
The filter icon was taken from here.
In your case the filter’s name is
comment_text
and your two callbacks arecommentimage_comment_text
andcommentimage_comment_text2
with priority10
(the default).You can view all the callbacks for this filter with this code snippet:
On my install I get the following output (in my theme’s footer part)
of all these callbacks with the corresponding assigned pirorities.
I added your two callbacks
commentimage_comment_text
andcommentimage_comment_text2
so you can see them too: