简体   繁体   English

WordPress wp-评论-post.php

[英]Wordpress wp-comments-post.php

In order to add comment meta data when a new comment is added I modified the wp-comments-post.php file.为了在添加新评论时添加评论元数据,我修改了 wp-comments-post.php 文件。 Now my worry is that when you upgrade wordpress, you will lose it.现在我担心的是,当你升级 wordpress 时,你会丢失它。

So I am looking to find out whether the file is replaced during upgrade, and if so, what is the standard practice to do this?所以我想知道升级过程中文件是否被替换,如果是这样,这样做的标准做法是什么?

The modifications I made were:我所做的修改是:

if(isset($_POST['rating'])){
        $rate = wp_filter_nohtml_kses($_POST['rating']);
        add_comment_meta($comment_id, 'coumment_rating', $rate, false);
    }

Check out the example in the codex,,add that example into your themes functions file with what you did in your mod inside that function...always avoid modifying core wordpress files unless absolutely necessay..and in most cases you can add action hooks similar to the example in this case http://codex.wordpress.org/Function_Reference/add_comment_meta查看 codex 中的示例,将该示例添加到您的主题函数文件中,以及您在该函数中的 mod 中所做的...除非绝对必要,否则请始终避免修改核心 wordpress 文件..在大多数情况下,您可以添加操作挂钩类似于本例中的示例http://codex.wordpress.org/Function_Reference/add_comment_meta

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM