标签: comments

允许用户仅管理自己帖子的评论

我想限制贡献者和作者用户只能查看和管理自己帖子的评论。

我尝试过以下过滤器但没有成功。

//Manage Your Own Comments Only
    function myplugin_comments_thisuseronly( $wp_query ) {
if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit-comments.php' ) !== false ) {
    if ( !current_user_can( 'edit_others_posts' ) ) {
        global $current_user;global $wpdb;
        $usersposts = $wpdb->get_results( $wpdb->prepare("SELECT ID FROM wp_posts WHERE post_author = %s", $current_user->id) );
        $wp_query->set('comment_post_ID', array($usersposts));
    }
}
}
Run Code Online (Sandbox Code Playgroud)

add_filter('parse_query', 'myplugin_comments_thisuseronly');

我也尝试过

$wp_query->set('comment_post_ID__in', array($usersposts));
Run Code Online (Sandbox Code Playgroud)

php wordpress comments admin filter

0
推荐指数
1
解决办法
1773
查看次数

按批准过滤 wordpress 评论

我用它来为我的自定义主题获取 wordpress 评论:

get_comments( array('status' => 'aprove','order' => 'ASC', 'post_id' => $newpost->ID) );
Run Code Online (Sandbox Code Playgroud)

除了等待审核的评论未被过滤这一事实之外,一切正常。遵循法典:http : //codex.wordpress.org/Function_Reference/get_comment'status' => 'approve'应该过滤掉那些,但这似乎没有发生。

我没有正确使用它吗?

php wordpress comments wordpress-theming

0
推荐指数
1
解决办法
2238
查看次数

用于在 shell 脚本上显示注释的简单命令

假设您有以下脚本:

# My comment line 1
# My comment line 2
# My comment line 3

echo "My script"
cd $MY_PATH
./anotherScript.ksh
Run Code Online (Sandbox Code Playgroud)

是否有任何命令可以显示:

# My comment line 1
# My comment line 2
# My comment line 3
Run Code Online (Sandbox Code Playgroud)

或者,我可以编写一个脚本来检测第一块注释。

谢谢

linux shell command comments

0
推荐指数
1
解决办法
8477
查看次数

我应该如何评论python代码?

我经常看到开源或“专业”python 代码中的注释——比如 webapp2 或 webob,看起来很间隔。评论似乎超过了代码。我注意到个别开发人员也在他们自己的应用程序中这样做。大间距,大量注释,然后是每隔一段时间写几行代码。

我想我喜欢这种风格,它确实感觉更有条理。现在我是用 python 做的更大的项目,我想知道我是否应该像我看到其他人所做的那样,用代码和注释来组织一个大项目。我认为这可能会使它更具可读性和可维护性,并且可能使我成为一个更好的编码员——因为事情会更清楚。

只是想:这个问题在代码审查上更好吗?听就是服从

目前我只是这样评论,例如:

    #U - Idempotent. b-atching requests 
    # which can be PUT, DELETE or GET. 
    #@control.access.collector_or_owner        
    def patch(s,*a,**k):
            s.resolve(*a,**k)
            for mod in s.requested_modifications:
                    method = mod.get('method') or 'PUT'
                    point = s.current_point+mod.get('point') or ''
                    body = mod.get('body') or ''
                    s.say('Will execute %s on %s for %s\n' % (method,point,body))
                    # create the in-app request
                    mod_request = webapp2.Request.blank(point)
                    mod_request.body = str(body)
                    mod_request.method = method
                    mod_request.app = s.app
                    # then find the handler and report …
Run Code Online (Sandbox Code Playgroud)

python comments

0
推荐指数
1
解决办法
903
查看次数

许可证样板注释究竟是什么,它需要采用什么格式?

我正在阅读Google C++ Style Guide以尝试模仿良好的编码实践。当我通读关于如何评论我的代码的部分时,它要求我用license boilerplate开始每个文件。我所能找到的关于这个术语的所有信息都来自Mozilla以及我认为是他们的评论标准。许可证样板注释究竟是什么,它需要采用什么格式?

注意:明确地说,我并不是说 Google C++ 风格指南是遵循良好编码实践的完美指南。我只是用它来获得关于如何改进我的编码风格的新想法。

c++ comments coding-style boilerplate

0
推荐指数
1
解决办法
1921
查看次数

在Java中评论约定

所有Java开发人员都知道使用slashslash(// Comment)和slashstar(/* Comment */)进行注释的约定.但是我从第69行开始看到了codehausJSONArray文档:

使用斜杠,斜杠和散列约定编写的注释将被忽略.

什么是哈希约定?怎么用?谷歌无法获得相关的好结果.

java arrays comments

0
推荐指数
1
解决办法
94
查看次数

打字稿:是否有任何约定来记录带注释的代码?

我习惯于以特定的方式记录C#项目中的代码,以提高团队生产力,从Visual Studio中的Intellisense等中受益.

代码看起来类似于:

/// <summary>
/// Loads a user with a specific id.
/// </summary>
/// <param name="id">The id of the user to search for.</param>
/// <returns>A user with the given id.</returns>
public User GetUserById(string id) {
    ...
}
Run Code Online (Sandbox Code Playgroud)

用于评论和文档的Typescript是否有类似的约定?甚至是使用这些约定从代码注释(如JavaDoc)生成html文档页面的工具?

c# documentation comments conventions typescript

0
推荐指数
2
解决办法
2087
查看次数

为什么 Python 会忽略注释缩进?

显然,这:

def f():
    pass
# maybe the function is over
    pass  # oh wait, it's not

f()
Run Code Online (Sandbox Code Playgroud)

是有效的语法,而这不是:

def f():
    pass
''' maybe the function is over '''
    pass  # oh wait, it's not

f()
Run Code Online (Sandbox Code Playgroud)

这对我来说是一个巨大的惊喜。所以我的问题是:

  • 为什么?为什么 Python 不认为第一个版本是语法错误?
  • PEP8 中是否有任何建议不要这样做?

python whitespace comments indentation

0
推荐指数
1
解决办法
181
查看次数

如何防止 /* 创建注释块?

我正在尝试打印出以下内容:

cout << *pointer1/*pointer2 << endl;
Run Code Online (Sandbox Code Playgroud)

然而,因为/*打开了一个注释块,所有过去的/*都被视为注释。到目前为止,我提出的解决方案是:

int tempPointer = *pointer;
cout << *pointer1/tempPointer << endl;
Run Code Online (Sandbox Code Playgroud)

这有效,但不是很优雅。

有没有办法防止/*在这种情况下创建评论块?

c++ comments

0
推荐指数
1
解决办法
79
查看次数

BASH 注释:#(散列)-vs- 之间的区别:(冒号)注释

在 bash GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)或任何稳定版本中,您可以使用#:进行评论

这两个和有用性有什么区别?

我注意到#注释使整行成为注释,而:作用域/效果仅在它到达第一个\n;字符(在给定行中)之前。

[gigauser@someserver ~]$ # this is a # comment; echo this will not print
[gigauser@someserver ~]$ : this is a : comment; echo this will print
this will print
Run Code Online (Sandbox Code Playgroud)

在下面的代码中,为什么最后 2 条评论没有按预期工作,然后将它们视为评论(尽管::如果它出现在: ?

[gigauser@someserver ~]$ #
[gigauser@someserver ~]$ ##
[gigauser@someserver ~]$ ####
[gigauser@someserver ~]$ ####
[gigauser@someserver ~]$ : : : : : : : : : …
Run Code Online (Sandbox Code Playgroud)

unix linux bash command comments

0
推荐指数
1
解决办法
50
查看次数