There is a plugin WP-PostRatings , which allows you to bring the stars of vote for an article. To the site where it is installed, raids began to make and mallerably to put a variety of articles. I thought and decided to add a functionality so that the message was displayed when inserting the unit, and the score was not counted. As a result, the WP-PostRatings.php file initially had such a code:
### Function: Process Ratings
Add_action ('WP_AJAX_POSTRATings', 'Process_ratings');
Add_action ('WP_AJAX_NOPRIV_POSTRATINGS', 'Process_ratings');
FUNCTION PROCESS_RATINGS () {
Global $ WPDB, $ user_identity, $ user_id;
If (isset ($ _ request ['action']) & amp; & amp; $ _request ['action'] == 'PostRatings')
{
$ raate = intval ($ _ request ['rate']);
$ post_id = intval ($ _ request ['pid']);
// Verify Referer.
If (! check_ajax_referer ('postratings _'. $ post_id .'- NONCE ',' PostRatings _ '. $ Post_id .'_ Nonce', False))
{
ESC_HTML_E ('Failed to Verify Referrer', 'WP-PostRatings');
exit ();
}
if ($ rate & gt; 0 & amp; & amp; $ post_id & gt; 0 & amp; & amp; check_allowtorate ()) {
// Check for Bot
$ bots_useragent = Array ('googleBot', 'google', 'msnbot', 'ia_archiver', 'lycos',' jeeves', 'scooter', 'fast-webcrawler', 'slurp @ inktomi', 'turnitinbot', ' TECHNORATI ',' YAHOO ',' FINDEXA ',' FINDLINKS ',' GAISBO ',' ZYBORG ',' SURVEYBOT ',' BLOGLINES ',' BLOGSEARCH ',' UBSUB ',' SYNDIC8 ',' Userland ',' Gigabot ' , 'become.com');
$ useRegent = $ _Server ['http_user_agent'];
Foreach ($ Bots_useragent AS $ Bot) {
if (STRISTR ($ USERAGENT, $ Bot)! == FALSE) {
Return;
}
}
Header ('Content-Type: text / html; charset ='. get_option ('blog_charset'));
$ rated = check_rated ($ post_id);
// Check Whether Post Has Been Rated by User
if (! $ rated) {
// Check Whether Is There A Valid Post
$ post = get_post ($ post_id);
// IF Valid Post Then We Rate It
if ($ post & amp; & amp;! WP_IS_POST_Revision ($ Post)) {
$ ratings_max = intval (get_option ('postratings_max'));
$ ratings_custom = intval (get_option ('postratings_customrating'));
$ Ratings_Value = Get_Option ('PostRatings_RatingsValue');
$ post_title = addslashes ($ post- & gt; post_title);
$ post_ratings = get_post_custom ($ post_id);
$ post_ratings_users =! Empty ($ post_ratings ['ratings_users'])? INTVAL ($ post_ratings ['ratings_users'] [0]): 0;
$ post_ratings_score =! Empty ($ post_ratings ['ratings_score'])? INTVAL ($ post_ratings ['ratings_score'] [0]): 0;
// Check for Ratings Lesser Than 1 and Greater than $ Ratings_max
if ($ rate & lt; 1 || $ rate & gt; $ ratings_max) {
$ rate = 0;
}
$ post_ratings_users = ($ post_ratings_users + 1);
$ post_ratings_score = ($ post_ratings_score + intval ($ ratings_value [$ raate-1]));
$ Post_ratings_AVerage = Round ($ post_ratings_score / $ post_ratings_users, 2);
update_post_meta ($ post_id, 'ratings_users', $ post_ratings_users);
Update_Post_Meta ($ post_id, 'ratings_score', $ post_ratings_score);
update_post_meta ($ post_id, 'ratings_average', $ post_ratings_averge);
// Add Log.
If (! Empty ($ User_identity)) {
$ rate_user = addslashes ($ user_identity);
} elseif (! Empty ($ _ cookie ['COMMENT_AUTHOR _'. Cookiehash])) {
$ Rate_user = addslashes ($ _ cookie ['COMMENT_AUTHOR _'. Cookiehash]);
} else {
$ rate_user = __ ('Guest', 'WP-PostRatings');
}
$ RATE_USER = Apply_Filters ('WP_POSTRATINGS_PROCESS_RATINGS_USER', $ RATE_USER);
$ Rate_userid = Apply_Filters ('WP_POSTRATINGS_PROCESS_RATINGS_USERID', INTVAL ($ user_id));
// Only Create Cookie IF User Choose Logging Method 1 OR 3
$ postratings_logging_method = intval (get_option ('postratings_logging_method'));
if ($ postratings_logging_method == 1 || $ postratings_logging_method == 3) {
$ Rate_Cookie = Setcookie ("Rated _". $ post_id, $ ratings_value [$ rate-1], Apply_Filters ('WP_POSTRATINGS_COOKIE_EXPIRATION', (TIME () + 30000000)), Apply_Filters ('WP_POSTRATINGS_COOKIPATH', SITECOOKIEPATH));
}
// Log Ratings No Matter What
$ rate_log = $ wpdb- & gt; query ($ WPDB- & GT; Prepare ("INSERT INTO {$ WPDB- & GT; Ratings} Values (% d,% d,% S,% d,% d,% s,% s ,% s,% d) ", 0, $ post_id, $ post_title, $ ratings_value [$ rate-1], current_time ('timestamp'), get_ipaddress (), @GethostByaddr (get_iPaddress ()), $ rate_user, $ rate_userid ));
// Allow Other Plugins to Hook WHEN A POST IS RATED
do_action ('rate_post', $ rate_userid, $ post_id, $ ratings_value [$ raate-1]);
// Output Ajax Result
echo the_ratings_results ($ post_id, $ post_ratings_users, $ post_ratings_score, $ post_ratings_averge);
exit ();
} else {
PrintF (ESC_HTML __ ('Invalid Post ID (#% S).', 'WP-PostRatings'), $ post_id);
exit ();
} // End if ($ post)
} else {
Printf (ESC_HTML __ ('You Had Already Rated This Post. POST ID #% s.', 'WP-PostRatings'), $ post_id);
exit ();
} // End if (! $ Rated)
} // End if ($ rate & amp; & amp; $ post_id & amp; & amp; check_allowtorate ())
} // END if (ISSET ($ _ Request [Action ']) & amp; & amp; $ _request [' action '] ==' postratings')
}
I modified it in this way:
... ttp_user_agent '];
Foreach ($ Bots_useragent AS $ Bot) {
if (STRISTR ($ USERAGENT, $ Bot)! == FALSE) {
Return;
}
}
if ($ RATE & LT; 2) {
Printf (__ ('& lt; span class = "Mess" & gt; & lt; strong & gt; write in the comments why the article deserves units. We will improve it. & lt; / strong & gt; & lt; / span & gt;'), $ post_id);
exit ();
}
Header ('Content-Type: text / html; charset ='. get_option ('blog_charset'));
$ rated = check_rated ($ post_id);
// Check Whether POST ...
Message is displayed. But I think that I did not quite correctly formed the line of the output, because For the text specified in it, a priori no translation.
And in general, did I not violate the functionality? In tests, everything seems to work as needed …
Answer 1
The functionality you did not violate. There is a translation, there is no it – it does not affect anything. In addition to the translation itself.