我对这个问题的"基本性"感到尴尬,但是在浪费了几个小时之后,这里就开始了.
为了尝试使用jQuery Calculation插件,我正在使用插件网站上的订单表单的基本示例.我希望将总计作为表单字段而不是文本字段,因此我可以使用该值.
计算和显示总计的函数是:
function ($this){
// sum the total of the $("[id^=total_item]") selector
var sum = $this.sum();
$("#grandTotal").text(
// round the results to 2 digits
sum.toFixed(2)
);
}
Run Code Online (Sandbox Code Playgroud)
关键字的总更新:
<span id="grandTotal"></span>
Run Code Online (Sandbox Code Playgroud)
但这不适用于:
<input type="text" id="grandTotal" value=""/>
Run Code Online (Sandbox Code Playgroud)
任何人都可以指出我需要添加/更改以使其工作吗?打电话给我的javascript基本会是一种恭维,所以请跟我说话,就像我什么都不知道!
我想限制贡献者和作者用户只能查看和管理自己帖子的评论。
我尝试过以下过滤器但没有成功。
//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)