如何删除WP-PostRating插件的消息输出?

时间:2011-07-05 作者:jwp

当用户单击投票图像时,图像将变为投票状态。如果用户再次单击处于投票状态的图像,将弹出一条消息,说明:

你已经给这篇文章打分了。Post ID#X

我希望它不会弹出此消息,“投票”图像保持原样。

下面是我认为进行此更改所需的相关代码。它来自wp postratings的558-633行。php。如果有人能看一看,让我知道我需要改变什么,我将非常感激。

### Function: Process Ratings
process_ratings();
function process_ratings() {
    global $wpdb, $user_identity, $user_ID;
    $rate = intval($_GET[\'rate\']);
    $post_id = intval($_GET[\'pid\']);
    if($rate > 0 && $post_id > 0 && 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\');
        $useragent = $_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\').\'\');
        postratings_textdomain();
        $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 && !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->post_title);
                $post_ratings = get_post_custom($post_id);
                $post_ratings_users = intval($post_ratings[\'ratings_users\'][0]);
                $post_ratings_score = intval($post_ratings[\'ratings_score\'][0]);    
                // Check For Ratings Lesser Than 1 And Greater Than $ratings_max
                if($rate < 1 || $rate > $ratings_max) {
                    $rate = 0;
                }
                $post_ratings_users = ($post_ratings_users+1);
                $post_ratings_score = ($post_ratings_score+intval($ratings_value[$rate-1]));
                $post_ratings_average = round($post_ratings_score/$post_ratings_users, 2);
                if (!update_post_meta($post_id, \'ratings_users\', $post_ratings_users)) {
                    add_post_meta($post_id, \'ratings_users\', $post_ratings_users, true);
                }
                if(!update_post_meta($post_id, \'ratings_score\', $post_ratings_score)) {
                    add_post_meta($post_id, \'ratings_score\', $post_ratings_score, true);
                }
                if(!update_post_meta($post_id, \'ratings_average\', $post_ratings_average)) {
                    add_post_meta($post_id, \'ratings_average\', $post_ratings_average, true);    
                }
                // 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_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], time() + 30000000, COOKIEPATH);
                }
                // Log Ratings No Matter What
                $rate_log = $wpdb->query("INSERT INTO $wpdb->ratings VALUES (0, $post_id, \'$post_title\', ".$ratings_value[$rate-1].",\'".current_time(\'timestamp\')."\', \'".get_ipaddress()."\', \'".@gethostbyaddr(get_ipaddress())."\' ,\'$rate_user\', $rate_userid)");
                // Output AJAX Result
                echo the_ratings_results($post_id, $post_ratings_users, $post_ratings_score, $post_ratings_average);
                exit();
            } else {
                printf(__(\'Invalid Post ID. Post ID #%s.\', \'wp-postratings\'), $post_id);
                exit();
            } // End if($post)
        } else {
            printf(__(\'You Had Already Rated This Post. Post ID #%s.\', \'wp-postratings\'), $post_id);
            exit(); 
        }// End if(!$rated)
    } // End if($rate && $post_id && check_allowtorate())
}
编辑:您可以找到插件here

1 个回复
最合适的回答,由SO网友:kaiser 整理而成

只需注释(或更改)以下行:

// printf(__(\'You Had Already Rated This Post. Post ID #%s.\', \'wp-postratings\'), $post_id);
如果你只是不想$post_id, 将行更改为以下内容:

_e(\'You Had Already Rated This Post. Post ID #%s.\', \'wp-postratings\');

Btw: If you change a plugin and then make an update, all your changes are gone.

结束

相关推荐

GPL and plugins

插件开发中心说:“您的插件必须与GPLv2兼容。”。但我发现Topsy插件在GPLv3下。http://www.gnu.org/licenses/rms-why-gplv3.html 声明GPLv2和GPLv3不兼容。那么这应该被允许吗?我想使用Topsy插件中的一些代码。那么,我应该在GPLv2或GPLv3下发布插件吗??

如何删除WP-PostRating插件的消息输出? - 小码农CODE - 行之有效找到问题解决它

如何删除WP-PostRating插件的消息输出?

时间:2011-07-05 作者:jwp

当用户单击投票图像时,图像将变为投票状态。如果用户再次单击处于投票状态的图像,将弹出一条消息,说明:

你已经给这篇文章打分了。Post ID#X

我希望它不会弹出此消息,“投票”图像保持原样。

下面是我认为进行此更改所需的相关代码。它来自wp postratings的558-633行。php。如果有人能看一看,让我知道我需要改变什么,我将非常感激。

### Function: Process Ratings
process_ratings();
function process_ratings() {
    global $wpdb, $user_identity, $user_ID;
    $rate = intval($_GET[\'rate\']);
    $post_id = intval($_GET[\'pid\']);
    if($rate > 0 && $post_id > 0 && 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\');
        $useragent = $_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\').\'\');
        postratings_textdomain();
        $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 && !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->post_title);
                $post_ratings = get_post_custom($post_id);
                $post_ratings_users = intval($post_ratings[\'ratings_users\'][0]);
                $post_ratings_score = intval($post_ratings[\'ratings_score\'][0]);    
                // Check For Ratings Lesser Than 1 And Greater Than $ratings_max
                if($rate < 1 || $rate > $ratings_max) {
                    $rate = 0;
                }
                $post_ratings_users = ($post_ratings_users+1);
                $post_ratings_score = ($post_ratings_score+intval($ratings_value[$rate-1]));
                $post_ratings_average = round($post_ratings_score/$post_ratings_users, 2);
                if (!update_post_meta($post_id, \'ratings_users\', $post_ratings_users)) {
                    add_post_meta($post_id, \'ratings_users\', $post_ratings_users, true);
                }
                if(!update_post_meta($post_id, \'ratings_score\', $post_ratings_score)) {
                    add_post_meta($post_id, \'ratings_score\', $post_ratings_score, true);
                }
                if(!update_post_meta($post_id, \'ratings_average\', $post_ratings_average)) {
                    add_post_meta($post_id, \'ratings_average\', $post_ratings_average, true);    
                }
                // 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_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], time() + 30000000, COOKIEPATH);
                }
                // Log Ratings No Matter What
                $rate_log = $wpdb->query("INSERT INTO $wpdb->ratings VALUES (0, $post_id, \'$post_title\', ".$ratings_value[$rate-1].",\'".current_time(\'timestamp\')."\', \'".get_ipaddress()."\', \'".@gethostbyaddr(get_ipaddress())."\' ,\'$rate_user\', $rate_userid)");
                // Output AJAX Result
                echo the_ratings_results($post_id, $post_ratings_users, $post_ratings_score, $post_ratings_average);
                exit();
            } else {
                printf(__(\'Invalid Post ID. Post ID #%s.\', \'wp-postratings\'), $post_id);
                exit();
            } // End if($post)
        } else {
            printf(__(\'You Had Already Rated This Post. Post ID #%s.\', \'wp-postratings\'), $post_id);
            exit(); 
        }// End if(!$rated)
    } // End if($rate && $post_id && check_allowtorate())
}
编辑:您可以找到插件here

1 个回复
最合适的回答,由SO网友:kaiser 整理而成

只需注释(或更改)以下行:

// printf(__(\'You Had Already Rated This Post. Post ID #%s.\', \'wp-postratings\'), $post_id);
如果你只是不想$post_id, 将行更改为以下内容:

_e(\'You Had Already Rated This Post. Post ID #%s.\', \'wp-postratings\');

Btw: If you change a plugin and then make an update, all your changes are gone.

如何删除WP-PostRating插件的消息输出? - 小码农CODE - 行之有效找到问题解决它

如何删除WP-PostRating插件的消息输出?

时间:2011-07-05 作者:jwp

当用户单击投票图像时,图像将变为投票状态。如果用户再次单击处于投票状态的图像,将弹出一条消息,说明:

你已经给这篇文章打分了。Post ID#X

我希望它不会弹出此消息,“投票”图像保持原样。

下面是我认为进行此更改所需的相关代码。它来自wp postratings的558-633行。php。如果有人能看一看,让我知道我需要改变什么,我将非常感激。

### Function: Process Ratings
process_ratings();
function process_ratings() {
    global $wpdb, $user_identity, $user_ID;
    $rate = intval($_GET[\'rate\']);
    $post_id = intval($_GET[\'pid\']);
    if($rate > 0 && $post_id > 0 && 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\');
        $useragent = $_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\').\'\');
        postratings_textdomain();
        $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 && !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->post_title);
                $post_ratings = get_post_custom($post_id);
                $post_ratings_users = intval($post_ratings[\'ratings_users\'][0]);
                $post_ratings_score = intval($post_ratings[\'ratings_score\'][0]);    
                // Check For Ratings Lesser Than 1 And Greater Than $ratings_max
                if($rate < 1 || $rate > $ratings_max) {
                    $rate = 0;
                }
                $post_ratings_users = ($post_ratings_users+1);
                $post_ratings_score = ($post_ratings_score+intval($ratings_value[$rate-1]));
                $post_ratings_average = round($post_ratings_score/$post_ratings_users, 2);
                if (!update_post_meta($post_id, \'ratings_users\', $post_ratings_users)) {
                    add_post_meta($post_id, \'ratings_users\', $post_ratings_users, true);
                }
                if(!update_post_meta($post_id, \'ratings_score\', $post_ratings_score)) {
                    add_post_meta($post_id, \'ratings_score\', $post_ratings_score, true);
                }
                if(!update_post_meta($post_id, \'ratings_average\', $post_ratings_average)) {
                    add_post_meta($post_id, \'ratings_average\', $post_ratings_average, true);    
                }
                // 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_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], time() + 30000000, COOKIEPATH);
                }
                // Log Ratings No Matter What
                $rate_log = $wpdb->query("INSERT INTO $wpdb->ratings VALUES (0, $post_id, \'$post_title\', ".$ratings_value[$rate-1].",\'".current_time(\'timestamp\')."\', \'".get_ipaddress()."\', \'".@gethostbyaddr(get_ipaddress())."\' ,\'$rate_user\', $rate_userid)");
                // Output AJAX Result
                echo the_ratings_results($post_id, $post_ratings_users, $post_ratings_score, $post_ratings_average);
                exit();
            } else {
                printf(__(\'Invalid Post ID. Post ID #%s.\', \'wp-postratings\'), $post_id);
                exit();
            } // End if($post)
        } else {
            printf(__(\'You Had Already Rated This Post. Post ID #%s.\', \'wp-postratings\'), $post_id);
            exit(); 
        }// End if(!$rated)
    } // End if($rate && $post_id && check_allowtorate())
}
编辑:您可以找到插件here

1 个回复
最合适的回答,由SO网友:kaiser 整理而成

只需注释(或更改)以下行:

// printf(__(\'You Had Already Rated This Post. Post ID #%s.\', \'wp-postratings\'), $post_id);
如果你只是不想$post_id, 将行更改为以下内容:

_e(\'You Had Already Rated This Post. Post ID #%s.\', \'wp-postratings\');

Btw: If you change a plugin and then make an update, all your changes are gone.