Changeset 2471362
- Timestamp:
- 02/09/2021 07:27:48 AM (5 years ago)
- Location:
- wp-mini-program
- Files:
-
- 2 edited
-
tags/1.3.7/router/comments.php (modified) (3 diffs)
-
trunk/router/comments.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-mini-program/tags/1.3.7/router/comments.php
r2471336 r2471362 251 251 } else { 252 252 $message = wp_miniprogram_comment_type( $type ); 253 $eliminate = apply_filters( 'custom_comment_type_eliminate', $type ); ;253 $eliminate = apply_filters( 'custom_comment_type_eliminate', $type ); 254 254 if( $eliminate ) { 255 if( $parent_id != 0 ) { 256 return new WP_Error( 'error', '父类 ID 错误, ID 必须为 0', array( 'status' => 403 ) ); 257 } 255 258 $args = array('post_id' => $post_id, 'type__in' => array( $type ), 'user_id' => $user_id, 'parent' => 0, 'status' => 'approve', 'orderby' => 'comment_date', 'order' => 'DESC'); 256 259 $custom_comment = get_comments( $args ); … … 271 274 } else { 272 275 $customarr = array( 273 'comment_post_ID' => $post_id, // to which post the comment will show up274 'comment_author' => ucfirst($user_name), //fixed value - can be dynamic275 'comment_author_email' => $user_email, //fixed value - can be dynamic276 'comment_author_url' => $user_url, //fixed value - can be dynamic277 'comment_content' => $content, //fixed value - can be dynamic276 'comment_post_ID' => $post_id, 277 'comment_author' => ucfirst($user_name), 278 'comment_author_email' => $user_email, 279 'comment_author_url' => $user_url, 280 'comment_content' => $content, 278 281 'comment_author_IP' => '', 279 'comment_type' => $type, //empty for regular comments, 'pingback' for pingbacks, 'trackback' for trackbacks280 'comment_parent' => $parent_id, //0 if it's not a reply to another comment; if it's a reply, mention the parent comment ID here281 'comment_approved' => 1, // Whether the comment has been approved282 'user_id' => $user_id , //passing current user ID or any predefined as per the demand282 'comment_type' => $type, 283 'comment_parent' => $parent_id, 284 'comment_approved' => 1, 285 'user_id' => $user_id 283 286 ); 284 287 $comment_id = wp_insert_comment( $customarr ); … … 294 297 } 295 298 } else { 299 $args = array('post_id' => $post_id, 'type__in' => array( $type ), 'user_id' => $user_id, 'parent' => $parent_id, 'status' => 'approve', 'orderby' => 'comment_date', 'order' => 'DESC'); 300 $custom_comment = get_comments( $args ); 301 if( $custom_comment ) { 302 foreach ( $custom_comment as $comment ) { 303 $parent_id = (int)$comment->comment_ID; 304 } 305 } 296 306 $customarr = array( 297 'comment_post_ID' => $post_id, // to which post the comment will show up298 'comment_author' => ucfirst($user_name), //fixed value - can be dynamic299 'comment_author_email' => $user_email, //fixed value - can be dynamic300 'comment_author_url' => $user_url, //fixed value - can be dynamic301 'comment_content' => $content, //fixed value - can be dynamic307 'comment_post_ID' => $post_id, 308 'comment_author' => ucfirst($user_name), 309 'comment_author_email' => $user_email, 310 'comment_author_url' => $user_url, 311 'comment_content' => $content, 302 312 'comment_author_IP' => '', 303 'comment_type' => $type, //empty for regular comments, 'pingback' for pingbacks, 'trackback' for trackbacks304 'comment_parent' => $parent_id, //0 if it's not a reply to another comment; if it's a reply, mention the parent comment ID here305 'comment_approved' => 1, // Whether the comment has been approved306 'user_id' => $user_id , //passing current user ID or any predefined as per the demand313 'comment_type' => $type, 314 'comment_parent' => $parent_id, 315 'comment_approved' => 1, 316 'user_id' => $user_id 307 317 ); 308 318 $comment_id = wp_insert_comment( $customarr ); -
wp-mini-program/trunk/router/comments.php
r2471336 r2471362 251 251 } else { 252 252 $message = wp_miniprogram_comment_type( $type ); 253 $eliminate = apply_filters( 'custom_comment_type_eliminate', $type ); ;253 $eliminate = apply_filters( 'custom_comment_type_eliminate', $type ); 254 254 if( $eliminate ) { 255 if( $parent_id != 0 ) { 256 return new WP_Error( 'error', '父类 ID 错误, ID 必须为 0', array( 'status' => 403 ) ); 257 } 255 258 $args = array('post_id' => $post_id, 'type__in' => array( $type ), 'user_id' => $user_id, 'parent' => 0, 'status' => 'approve', 'orderby' => 'comment_date', 'order' => 'DESC'); 256 259 $custom_comment = get_comments( $args ); … … 271 274 } else { 272 275 $customarr = array( 273 'comment_post_ID' => $post_id, // to which post the comment will show up274 'comment_author' => ucfirst($user_name), //fixed value - can be dynamic275 'comment_author_email' => $user_email, //fixed value - can be dynamic276 'comment_author_url' => $user_url, //fixed value - can be dynamic277 'comment_content' => $content, //fixed value - can be dynamic276 'comment_post_ID' => $post_id, 277 'comment_author' => ucfirst($user_name), 278 'comment_author_email' => $user_email, 279 'comment_author_url' => $user_url, 280 'comment_content' => $content, 278 281 'comment_author_IP' => '', 279 'comment_type' => $type, //empty for regular comments, 'pingback' for pingbacks, 'trackback' for trackbacks280 'comment_parent' => $parent_id, //0 if it's not a reply to another comment; if it's a reply, mention the parent comment ID here281 'comment_approved' => 1, // Whether the comment has been approved282 'user_id' => $user_id , //passing current user ID or any predefined as per the demand282 'comment_type' => $type, 283 'comment_parent' => $parent_id, 284 'comment_approved' => 1, 285 'user_id' => $user_id 283 286 ); 284 287 $comment_id = wp_insert_comment( $customarr ); … … 294 297 } 295 298 } else { 299 $args = array('post_id' => $post_id, 'type__in' => array( $type ), 'user_id' => $user_id, 'parent' => $parent_id, 'status' => 'approve', 'orderby' => 'comment_date', 'order' => 'DESC'); 300 $custom_comment = get_comments( $args ); 301 if( $custom_comment ) { 302 foreach ( $custom_comment as $comment ) { 303 $parent_id = (int)$comment->comment_ID; 304 } 305 } 296 306 $customarr = array( 297 'comment_post_ID' => $post_id, // to which post the comment will show up298 'comment_author' => ucfirst($user_name), //fixed value - can be dynamic299 'comment_author_email' => $user_email, //fixed value - can be dynamic300 'comment_author_url' => $user_url, //fixed value - can be dynamic301 'comment_content' => $content, //fixed value - can be dynamic307 'comment_post_ID' => $post_id, 308 'comment_author' => ucfirst($user_name), 309 'comment_author_email' => $user_email, 310 'comment_author_url' => $user_url, 311 'comment_content' => $content, 302 312 'comment_author_IP' => '', 303 'comment_type' => $type, //empty for regular comments, 'pingback' for pingbacks, 'trackback' for trackbacks304 'comment_parent' => $parent_id, //0 if it's not a reply to another comment; if it's a reply, mention the parent comment ID here305 'comment_approved' => 1, // Whether the comment has been approved306 'user_id' => $user_id , //passing current user ID or any predefined as per the demand313 'comment_type' => $type, 314 'comment_parent' => $parent_id, 315 'comment_approved' => 1, 316 'user_id' => $user_id 307 317 ); 308 318 $comment_id = wp_insert_comment( $customarr );
Note: See TracChangeset
for help on using the changeset viewer.